[Pkg-ceph-commits] [ceph] 01/03: Imported Upstream version 10.0.3

James Downing Page jamespage at moszumanska.debian.org
Mon Feb 29 09:26:42 UTC 2016


This is an automated email from the git hooks/post-receive script.

jamespage pushed a commit to branch jewel
in repository ceph.

commit d45dbe30e871fd6f240b88bc2e11b91d95aa5de1
Author: James Page <james.page at ubuntu.com>
Date:   Wed Feb 24 12:44:40 2016 +0000

    Imported Upstream version 10.0.3
---
 AUTHORS                                            |    37 +-
 ChangeLog                                          |  1224 ++-
 Makefile.in                                        |    50 +-
 aclocal.m4                                         |    73 +-
 ar-lib                                             |     2 +-
 ceph.spec                                          |    24 +-
 ceph.spec.in                                       |    22 +-
 compile                                            |     2 +-
 config.guess                                       |   233 +-
 config.sub                                         |    60 +-
 configure                                          |  3191 +++---
 configure.ac                                       |     9 +-
 depcomp                                            |     2 +-
 doc/Makefile.in                                    |    24 +-
 doc/man/8/rados.rst                                |     7 +-
 doc/man/8/radosgw-admin.rst                        |     3 +-
 install-sh                                         |   373 +-
 ltmain.sh                                          |  5533 ++++++----
 m4/libtool.m4                                      |  2521 +++--
 m4/ltoptions.m4                                    |   127 +-
 m4/ltsugar.m4                                      |     7 +-
 m4/ltversion.m4                                    |    12 +-
 m4/lt~obsolete.m4                                  |     7 +-
 m4/pkg.m4                                          |   230 +-
 man/Makefile.in                                    |    29 +-
 man/ceph-authtool.8                                |     2 +-
 man/ceph-clsinfo.8                                 |     2 +-
 man/ceph-conf.8                                    |     2 +-
 man/ceph-create-keys.8                             |     2 +-
 man/ceph-debugpack.8                               |     2 +-
 man/ceph-dencoder.8                                |     2 +-
 man/ceph-deploy.8                                  |     4 +-
 man/ceph-detect-init.8                             |     2 +-
 man/ceph-disk.8                                    |    24 +-
 man/ceph-fuse.8                                    |     2 +-
 man/ceph-mds.8                                     |     2 +-
 man/ceph-mon.8                                     |     2 +-
 man/ceph-osd.8                                     |     2 +-
 man/ceph-post-file.8                               |     2 +-
 man/ceph-rbdnamer.8                                |     2 +-
 man/ceph-rest-api.8                                |     2 +-
 man/ceph-run.8                                     |     2 +-
 man/ceph-syn.8                                     |     2 +-
 man/ceph.8                                         |     2 +-
 man/cephfs.8                                       |     2 +-
 man/crushtool.8                                    |     2 +-
 man/librados-config.8                              |     2 +-
 man/monmaptool.8                                   |     2 +-
 man/mount.ceph.8                                   |     2 +-
 man/osdmaptool.8                                   |     2 +-
 man/rados.8                                        |     9 +-
 man/radosgw-admin.8                                |     5 +-
 man/radosgw.8                                      |     2 +-
 man/rbd-fuse.8                                     |     2 +-
 man/rbd-nbd.8                                      |     2 +-
 man/rbd-replay-many.8                              |     2 +-
 man/rbd-replay-prep.8                              |     2 +-
 man/rbd-replay.8                                   |     2 +-
 man/rbd.8                                          |     2 +-
 missing                                            |     2 +-
 py-compile                                         |     2 +-
 selinux/Makefile.in                                |    24 +-
 src/.git_version                                   |     4 +-
 src/Makefile-client.am                             |     1 +
 src/Makefile-env.am                                |    10 +-
 src/Makefile-rocksdb.am                            |   832 +-
 src/Makefile.am                                    |     2 +-
 src/Makefile.in                                    |  4945 +++++----
 src/acconfig.h.in                                  |     3 +-
 src/ceph-detect-init/tests/test_all.py             |    17 +-
 src/ceph-disk                                      |   354 +-
 src/ceph.in                                        |    17 +-
 src/ceph_fuse.cc                                   |     7 +-
 src/ceph_mds.cc                                    |     4 +-
 src/ceph_mon.cc                                    |     2 +-
 src/client/Client.cc                               |  1191 ++-
 src/client/Client.h                                |    93 +-
 src/client/Inode.cc                                |    30 +-
 src/client/Inode.h                                 |     5 +-
 src/client/Makefile.am                             |     7 +-
 src/client/MetaRequest.cc                          |     2 +
 src/client/MetaRequest.h                           |    37 +-
 src/client/MetaSession.h                           |     1 +
 src/client/ObjecterWriteback.h                     |    29 +-
 src/client/SyntheticClient.cc                      |    21 +-
 src/client/UserGroups.h                            |    12 +
 src/client/fuse_ll.cc                              |   165 +-
 src/client/posix_acl.cc                            |   283 +
 src/client/posix_acl.h                             |    35 +
 src/cls/rbd/cls_rbd.cc                             |    83 +-
 src/cls/rgw/cls_rgw.cc                             |     2 +-
 src/cls/user/cls_user.cc                           |    12 +-
 src/cls/user/cls_user_client.cc                    |    10 +-
 src/cls/user/cls_user_client.h                     |     7 +-
 src/cls/user/cls_user_ops.h                        |     9 +-
 src/common/Cond.h                                  |    30 +-
 src/common/Finisher.cc                             |     2 +-
 src/common/Finisher.h                              |     8 +-
 src/common/Formatter.cc                            |     4 +-
 src/common/HeartbeatMap.cc                         |     5 +
 src/common/Makefile.am                             |     6 +-
 src/common/Mutex.cc                                |     8 +
 src/common/OutputDataSocket.cc                     |     2 +-
 src/common/RWLock.h                                |     4 +
 src/common/RefCountedObj.h                         |     8 +-
 src/common/Thread.cc                               |     5 +-
 src/common/Thread.h                                |     2 +-
 src/common/Timer.cc                                |     2 +-
 src/common/TracepointProvider.h                    |     2 +-
 src/common/WorkQueue.cc                            |    12 +-
 src/common/WorkQueue.h                             |    14 +-
 src/common/address_helper.cc                       |     1 +
 src/common/admin_socket.cc                         |     2 +-
 src/common/assert.cc                               |    10 +-
 src/common/buffer.cc                               |    58 +-
 src/common/ceph_context.cc                         |    13 +-
 src/common/ceph_context.h                          |     5 +-
 src/common/ceph_strings.cc                         |     1 +
 src/common/ceph_time.cc                            |   112 +
 src/common/ceph_time.h                             |   383 +
 src/common/ceph_timer.h                            |   309 +
 src/common/common_init.cc                          |     2 +
 src/common/config.cc                               |    23 +-
 src/common/config_opts.h                           |   133 +-
 src/common/ipaddr.cc                               |     6 +
 src/common/lockdep.cc                              |     7 +-
 src/common/obj_bencher.cc                          |     3 +
 src/common/perf_counters.cc                        |    23 +
 src/common/perf_counters.h                         |     5 +
 src/common/shared_cache.hpp                        |    25 +-
 src/common/simple_cache.hpp                        |    32 +-
 src/common/sync_filesystem.h                       |     2 +-
 src/common/util.cc                                 |    20 -
 src/common/valgrind.h                              |    10 +-
 src/compressor/AsyncCompressor.cc                  |     4 +-
 src/compressor/AsyncCompressor.h                   |     2 +-
 src/compressor/CompressionPlugin.h                 |    45 +
 src/compressor/Compressor.cc                       |    20 +-
 src/compressor/Compressor.h                        |     8 +-
 src/compressor/Makefile.am                         |    15 +-
 src/compressor/snappy/CompressionPluginSnappy.cc   |    57 +
 src/compressor/snappy/Makefile.am                  |    22 +
 src/compressor/{ => snappy}/SnappyCompressor.h     |     3 +-
 src/crush/CrushCompiler.cc                         |    24 +-
 src/crush/CrushTester.cc                           |    47 +
 src/crush/CrushTester.h                            |     4 +
 src/crush/CrushWrapper.cc                          |    39 +-
 src/crush/CrushWrapper.h                           |    57 +-
 src/crush/crush.h                                  |     8 +-
 src/crush/grammar.h                                |     4 +
 src/crush/mapper.c                                 |    20 +-
 src/global/signal_handler.cc                       |     7 +-
 src/global/signal_handler.h                        |     8 +
 src/gmock/Makefile.in                              |    70 +-
 src/gmock/aclocal.m4                               |  2741 ++---
 src/gmock/build-aux/compile                        |     2 +-
 src/gmock/build-aux/config.guess                   |   233 +-
 src/gmock/build-aux/config.h.in                    |     3 +-
 src/gmock/build-aux/config.sub                     |    60 +-
 src/gmock/build-aux/depcomp                        |     2 +-
 src/gmock/build-aux/install-sh                     |   373 +-
 src/gmock/build-aux/ltmain.sh                      |  5533 ++++++----
 src/gmock/build-aux/missing                        |     2 +-
 src/gmock/build-aux/test-driver                    |    15 +-
 src/gmock/configure                                |  3124 +++---
 src/gmock/gtest/Makefile.in                        |    70 +-
 src/gmock/gtest/aclocal.m4                         |    67 +-
 src/gmock/gtest/build-aux/compile                  |     2 +-
 src/gmock/gtest/build-aux/config.guess             |   233 +-
 src/gmock/gtest/build-aux/config.h.in              |     3 +-
 src/gmock/gtest/build-aux/config.sub               |    60 +-
 src/gmock/gtest/build-aux/depcomp                  |     2 +-
 src/gmock/gtest/build-aux/install-sh               |   373 +-
 src/gmock/gtest/build-aux/ltmain.sh                |  5533 ++++++----
 src/gmock/gtest/build-aux/missing                  |     2 +-
 src/gmock/gtest/build-aux/test-driver              |    15 +-
 src/gmock/gtest/configure                          |  3124 +++---
 src/gmock/gtest/m4/libtool.m4                      |  2521 +++--
 src/gmock/gtest/m4/ltoptions.m4                    |   127 +-
 src/gmock/gtest/m4/ltsugar.m4                      |     7 +-
 src/gmock/gtest/m4/ltversion.m4                    |    12 +-
 src/gmock/gtest/m4/lt~obsolete.m4                  |     7 +-
 src/include/assert.h                               |     6 -
 src/include/buffer.h                               |     3 +-
 src/include/ceph_features.h                        |     3 +
 src/include/ceph_fs.h                              |    19 +-
 src/include/cephfs/libcephfs.h                     |    13 +
 src/include/interval_set.h                         |    24 +-
 src/include/rados/buffer.h                         |     3 +-
 src/include/rados/librados.h                       |    67 +
 src/include/rados/librados.hpp                     |    43 +
 src/include/radosstriper/libradosstriper.hpp       |     2 +-
 src/include/rbd/librbd.hpp                         |     4 +-
 src/include/rbd_types.h                            |     2 -
 src/include/util.h                                 |     4 -
 src/include/utime.h                                |    22 +-
 src/java/Makefile.in                               |    24 +-
 src/java/test/com/ceph/fs/CephMountCreateTest.java |     1 +
 src/java/test/com/ceph/fs/CephMountTest.java       |     1 +
 src/kv/KeyValueDB.cc                               |     5 +-
 src/kv/KeyValueDB.h                                |    14 +-
 src/kv/LevelDBStore.cc                             |    39 +-
 src/kv/LevelDBStore.h                              |    12 +
 src/kv/Makefile.am                                 |     4 +-
 src/kv/RocksDBStore.cc                             |   133 +-
 src/kv/RocksDBStore.h                              |    12 +-
 src/libcephfs.cc                                   |    18 +-
 src/librados-config.cc                             |    11 +-
 src/librados/IoCtxImpl.cc                          |   102 +-
 src/librados/IoCtxImpl.h                           |    11 +-
 src/librados/RadosClient.cc                        |     7 +-
 src/librados/librados.cc                           |   291 +-
 src/libradosstriper/RadosStriperImpl.cc            |    13 +-
 src/libradosstriper/RadosStriperImpl.h             |     2 +-
 src/libradosstriper/libradosstriper.cc             |     4 +
 src/librbd/AioImageRequest.cc                      |    42 +-
 src/librbd/AioImageRequest.h                       |    23 +-
 src/librbd/AioImageRequestWQ.cc                    |    27 +-
 src/librbd/AioImageRequestWQ.h                     |    21 +-
 src/librbd/AioObjectRequest.cc                     |     4 +-
 src/librbd/AsyncRequest.h                          |     7 +-
 src/librbd/CopyupRequest.cc                        |     4 +-
 src/librbd/ExclusiveLock.cc                        |     4 +-
 src/librbd/ImageCtx.cc                             |    24 +-
 src/librbd/ImageCtx.h                              |    11 +-
 src/librbd/ImageWatcher.cc                         |    32 +-
 src/librbd/Journal.cc                              |   579 +-
 src/librbd/Journal.h                               |   210 +-
 src/librbd/JournalReplay.cc                        |   192 -
 src/librbd/JournalReplay.h                         |    77 -
 src/librbd/LibrbdAdminSocketHook.cc                |    11 +-
 src/librbd/LibrbdWriteback.cc                      |    35 +-
 src/librbd/LibrbdWriteback.h                       |    18 +-
 src/librbd/Makefile.am                             |    10 +-
 src/librbd/Operations.cc                           |   811 ++
 src/librbd/Operations.h                            |    75 +
 src/librbd/exclusive_lock/AcquireRequest.h         |     2 +-
 src/librbd/exclusive_lock/ReleaseRequest.h         |     2 +-
 src/librbd/image/RefreshRequest.cc                 |     2 +-
 src/librbd/image/RefreshRequest.h                  |     3 -
 src/librbd/internal.cc                             |   826 +-
 src/librbd/internal.h                              |    32 +-
 src/librbd/{JournalTypes.cc => journal/Entries.cc} |    60 +-
 src/librbd/{JournalTypes.h => journal/Entries.h}   |   128 +-
 src/librbd/journal/Replay.cc                       |   606 ++
 src/librbd/journal/Replay.h                        |   171 +
 src/librbd/librbd.cc                               |    72 +-
 src/librbd/object_map/Request.cc                   |     2 +-
 src/librbd/object_map/Request.h                    |     3 +-
 src/librbd/object_map/ResizeRequest.cc             |     2 +-
 src/librbd/object_map/ResizeRequest.h              |     2 +-
 src/librbd/object_map/SnapshotCreateRequest.h      |     3 -
 src/librbd/object_map/SnapshotRemoveRequest.h      |     3 -
 src/librbd/object_map/SnapshotRollbackRequest.h    |     3 -
 src/librbd/object_map/UpdateRequest.cc             |     2 +-
 src/librbd/object_map/UpdateRequest.h              |     2 +-
 src/librbd/operation/FlattenRequest.h              |     4 +-
 src/librbd/operation/RebuildObjectMapRequest.cc    |     6 +-
 src/librbd/operation/RenameRequest.h               |     4 +-
 src/librbd/operation/Request.cc                    |   119 +-
 src/librbd/operation/Request.h                     |    68 +-
 src/librbd/operation/ResizeRequest.cc              |   374 +-
 src/librbd/operation/ResizeRequest.h               |   120 +-
 src/librbd/operation/SnapshotCreateRequest.cc      |   356 +-
 src/librbd/operation/SnapshotCreateRequest.h       |    93 +-
 src/librbd/operation/SnapshotProtectRequest.h      |     4 +-
 src/librbd/operation/SnapshotRemoveRequest.cc      |     5 +
 src/librbd/operation/SnapshotRemoveRequest.h       |     7 +-
 src/librbd/operation/SnapshotRenameRequest.h       |     4 +-
 src/librbd/operation/SnapshotRollbackRequest.cc    |   221 +-
 src/librbd/operation/SnapshotRollbackRequest.h     |    72 +-
 src/librbd/operation/SnapshotUnprotectRequest.h    |     4 +-
 src/librbd/operation/TrimRequest.h                 |    13 +-
 src/log/Log.cc                                     |     5 +-
 src/mds/CDir.cc                                    |    10 +-
 src/mds/CInode.cc                                  |    18 +-
 src/mds/JournalPointer.cc                          |     8 +-
 src/mds/Locker.cc                                  |    20 +-
 src/mds/MDCache.cc                                 |    34 +-
 src/mds/MDCache.h                                  |     7 +
 src/mds/MDLog.cc                                   |    43 +-
 src/mds/MDLog.h                                    |     3 +
 src/mds/MDSAuthCaps.cc                             |    26 +
 src/mds/MDSAuthCaps.h                              |     9 +
 src/mds/MDSDaemon.cc                               |    62 +-
 src/mds/MDSDaemon.h                                |     6 +-
 src/mds/MDSRank.cc                                 |    45 +-
 src/mds/MDSRank.h                                  |    12 +-
 src/mds/MDSTable.cc                                |     2 +-
 src/mds/RecoveryQueue.cc                           |     4 +-
 src/mds/Server.cc                                  |    35 +-
 src/mds/Server.h                                   |     1 +
 src/mds/SessionMap.cc                              |    13 +-
 src/mds/StrayManager.cc                            |    23 +-
 src/messages/MClientCaps.h                         |     2 +
 src/messages/MOSDOp.h                              |     3 +
 src/mon/AuthMonitor.cc                             |    16 +-
 src/mon/ConfigKeyService.cc                        |     3 -
 src/mon/LogMonitor.cc                              |     6 +-
 src/mon/MDSMonitor.cc                              |    22 +-
 src/mon/MonCommands.h                              |    11 +-
 src/mon/Monitor.cc                                 |    54 +-
 src/mon/MonitorDBStore.h                           |    14 +-
 src/mon/MonmapMonitor.cc                           |   163 +-
 src/mon/OSDMonitor.cc                              |    23 +-
 src/mon/PGMap.cc                                   |   197 +-
 src/mon/PGMonitor.cc                               |   467 +-
 src/mon/PGMonitor.h                                |     3 +-
 src/mon/Paxos.cc                                   |     2 +-
 src/mon/Paxos.h                                    |     2 +-
 src/msg/Dispatcher.h                               |    20 +-
 src/msg/Message.h                                  |     2 +-
 src/msg/async/AsyncConnection.cc                   |    69 +-
 src/msg/async/AsyncConnection.h                    |    48 +-
 src/msg/async/AsyncMessenger.cc                    |    43 +-
 src/msg/async/AsyncMessenger.h                     |    48 +-
 src/msg/async/Event.cc                             |     5 +-
 src/msg/async/Event.h                              |     4 +-
 src/msg/simple/Accepter.cc                         |     2 +-
 src/msg/simple/DispatchQueue.cc                    |     4 +-
 src/msg/simple/Pipe.cc                             |    62 +-
 src/msg/simple/Pipe.h                              |    21 +-
 src/msg/simple/PipeConnection.h                    |    10 +-
 src/msg/simple/SimpleMessenger.cc                  |     8 +-
 src/msg/xio/XioConnection.h                        |    22 +-
 src/msg/xio/XioMessenger.cc                        |     7 +-
 src/ocf/Makefile.in                                |    26 +-
 src/os/Makefile.am                                 |   139 +-
 src/os/ObjectMap.h                                 |     5 +-
 src/os/ObjectStore.cc                              |    27 +-
 src/os/ObjectStore.h                               |     5 +-
 src/os/bluestore/Allocator.cc                      |    16 +
 src/os/bluestore/Allocator.h                       |    50 +
 src/os/bluestore/BlockDevice.cc                    |   550 +
 src/os/bluestore/BlockDevice.h                     |   120 +
 src/os/bluestore/BlueFS.cc                         |  1564 +++
 src/os/bluestore/BlueFS.h                          |   351 +
 src/os/bluestore/BlueRocksEnv.cc                   |   552 +
 src/os/bluestore/BlueRocksEnv.h                    |   158 +
 src/os/bluestore/BlueStore.cc                      |  6217 +++++++++++
 .../{newstore/NewStore.h => bluestore/BlueStore.h} |   374 +-
 src/os/bluestore/FreelistManager.cc                |   248 +
 src/os/bluestore/FreelistManager.h                 |    51 +
 src/os/bluestore/StupidAllocator.cc                |   306 +
 src/os/bluestore/StupidAllocator.h                 |    55 +
 src/os/bluestore/bluefs_tool.cc                    |    85 +
 src/os/bluestore/bluefs_types.cc                   |   234 +
 src/os/bluestore/bluefs_types.h                    |   170 +
 src/os/bluestore/bluestore_types.cc                |   601 ++
 src/os/bluestore/bluestore_types.h                 |   312 +
 src/os/bluestore/kv.cc                             |    61 +
 src/os/bluestore/kv.h                              |    15 +
 src/os/{ => filestore}/BtrfsFileStoreBackend.cc    |     2 +-
 src/os/{ => filestore}/BtrfsFileStoreBackend.h     |     0
 src/os/{ => filestore}/CollectionIndex.h           |    18 +-
 src/os/{ => filestore}/DBObjectMap.cc              |     4 +-
 src/os/{ => filestore}/DBObjectMap.h               |     6 +-
 src/os/{ => filestore}/FDCache.h                   |     0
 src/os/{ => filestore}/FileJournal.cc              |   189 +-
 src/os/{ => filestore}/FileJournal.h               |    29 +-
 src/os/{ => filestore}/FileStore.cc                |   244 +-
 src/os/{ => filestore}/FileStore.h                 |    40 +-
 src/os/{ => filestore}/GenericFileStoreBackend.cc  |     2 +-
 src/os/{ => filestore}/GenericFileStoreBackend.h   |     0
 src/os/{ => filestore}/HashIndex.cc                |    14 +-
 src/os/{ => filestore}/HashIndex.h                 |    30 +-
 src/os/{ => filestore}/IndexManager.cc             |    12 +-
 src/os/{ => filestore}/IndexManager.h              |     6 +-
 src/os/{ => filestore}/Journal.h                   |     8 +-
 src/os/{ => filestore}/JournalingObjectStore.cc    |    15 +-
 src/os/{ => filestore}/JournalingObjectStore.h     |    10 +-
 src/os/{ => filestore}/LFNIndex.cc                 |    87 +-
 src/os/{ => filestore}/LFNIndex.h                  |    44 +-
 src/os/{ => filestore}/SequencerPosition.h         |     2 +-
 src/os/{ => filestore}/WBThrottle.cc               |     6 +-
 src/os/{ => filestore}/WBThrottle.h                |     0
 src/os/{ => filestore}/XfsFileStoreBackend.cc      |     2 +-
 src/os/{ => filestore}/XfsFileStoreBackend.h       |     2 +-
 src/os/{ => filestore}/ZFSFileStoreBackend.cc      |     0
 src/os/{ => filestore}/ZFSFileStoreBackend.h       |     2 +-
 src/os/{ => filestore}/chain_xattr.cc              |     4 +-
 src/os/{ => filestore}/chain_xattr.h               |     0
 src/os/fs/FS.h                                     |    30 +-
 src/os/{ => fs}/ZFS.cc                             |     0
 src/os/{ => fs}/ZFS.h                              |     0
 src/os/{ => fs}/btrfs_ioctl.h                      |     0
 src/os/{ => keyvaluestore}/GenericObjectMap.cc     |     4 +-
 src/os/{ => keyvaluestore}/GenericObjectMap.h      |     2 +-
 src/os/{ => keyvaluestore}/KeyValueStore.cc        |    34 +-
 src/os/{ => keyvaluestore}/KeyValueStore.h         |    20 +-
 src/os/{newstore/NewStore.cc => kstore/KStore.cc}  |  3028 +++---
 src/os/{newstore/NewStore.h => kstore/KStore.h}    |   358 +-
 src/os/kstore/kstore_types.cc                      |    99 +
 src/os/kstore/kstore_types.h                       |    66 +
 src/os/kstore/kv.cc                                |    61 +
 src/os/kstore/kv.h                                 |    15 +
 src/os/{ => memstore}/MemStore.cc                  |    58 +-
 src/os/{ => memstore}/MemStore.h                   |    25 +-
 src/os/{ => memstore}/PageSet.h                    |     0
 src/os/newstore/newstore_types.cc                  |   304 -
 src/os/newstore/newstore_types.h                   |   192 -
 src/osd/ECBackend.cc                               |    34 +-
 src/osd/ECBackend.h                                |     3 +-
 src/osd/OSD.cc                                     |   230 +-
 src/osd/OSD.h                                      |    30 +-
 src/osd/OSDMap.cc                                  |    25 +-
 src/osd/OSDMap.h                                   |    13 +-
 src/osd/PG.cc                                      |    26 +-
 src/osd/PG.h                                       |     6 +-
 src/osd/PGBackend.cc                               |    44 +-
 src/osd/PGLog.cc                                   |    46 +-
 src/osd/PGLog.h                                    |   222 +-
 src/osd/ReplicatedBackend.cc                       |    28 +-
 src/osd/ReplicatedBackend.h                        |     3 +-
 src/osd/ReplicatedPG.cc                            |   200 +-
 src/osd/ReplicatedPG.h                             |     9 +-
 src/osd/osd_types.cc                               |   329 +-
 src/osd/osd_types.h                                |   143 +-
 src/osdc/Filer.cc                                  |   141 +-
 src/osdc/Filer.h                                   |   202 +-
 src/osdc/Journaler.cc                              |   343 +-
 src/osdc/Journaler.h                               |   139 +-
 src/osdc/ObjectCacher.cc                           |  1150 ++-
 src/osdc/ObjectCacher.h                            |   220 +-
 src/osdc/Objecter.cc                               |  1159 ++-
 src/osdc/Objecter.h                                |   819 +-
 src/osdc/Striper.cc                                |   155 +-
 src/osdc/Striper.h                                 |    48 +-
 src/osdc/WritebackHandler.h                        |    21 +-
 src/pybind/ceph_volume_client.py                   |   791 ++
 src/pybind/cephfs.py                               |    27 +-
 src/pybind/rbd.pyx                                 |    18 +-
 src/rbd_fuse/rbd-fuse.cc                           |    54 +-
 src/rgw/rgw_admin.cc                               |    13 +-
 src/rgw/rgw_bucket.cc                              |    24 +-
 src/rgw/rgw_bucket.h                               |     3 +-
 src/rgw/rgw_civetweb.cc                            |    21 +-
 src/rgw/rgw_civetweb.h                             |     3 +-
 src/rgw/rgw_client_io.h                            |     2 +-
 src/rgw/rgw_common.cc                              |     2 +-
 src/rgw/rgw_common.h                               |     5 +
 src/rgw/rgw_fcgi.cc                                |    15 +-
 src/rgw/rgw_fcgi.h                                 |     7 +-
 src/rgw/rgw_gc.cc                                  |     2 +-
 src/rgw/rgw_http_errors.h                          |     5 +
 src/rgw/rgw_loadgen.cc                             |     2 +-
 src/rgw/rgw_loadgen.h                              |     2 +-
 src/rgw/rgw_main.cc                                |    14 +-
 src/rgw/rgw_metadata.cc                            |    10 +-
 src/rgw/rgw_object_expirer_core.cc                 |     2 +-
 src/rgw/rgw_op.cc                                  |    13 +-
 src/rgw/rgw_op.h                                   |     1 +
 src/rgw/rgw_orphan.cc                              |    11 +-
 src/rgw/rgw_quota.cc                               |     4 +-
 src/rgw/rgw_rados.cc                               |     9 +-
 src/rgw/rgw_rados.h                                |     7 +-
 src/rgw/rgw_rest.cc                                |    10 +-
 src/rgw/rgw_rest.h                                 |    15 +-
 src/rgw/rgw_rest_swift.cc                          |     1 +
 src/rgw/rgw_swift.cc                               |     2 +-
 src/rgw/rgw_user.cc                                |   135 +-
 src/rgw/rgw_user.h                                 |     4 +-
 src/rocksdb/.travis.yml                            |     2 +-
 src/rocksdb/CMakeLists.txt                         |   105 +-
 src/rocksdb/HISTORY.md                             |    30 +-
 src/rocksdb/INSTALL.md                             |    14 +-
 src/rocksdb/Makefile                               |   128 +-
 src/rocksdb/appveyor.yml                           |    10 +-
 src/rocksdb/appveyordailytests.yml                 |    22 -
 .../arcanist_util/cpp_linter/FbcodeCppLinter.php   |     3 +
 src/rocksdb/build_tools/build_detect_platform      |     5 +-
 src/rocksdb/build_tools/fbcode_config.sh           |     8 +-
 src/rocksdb/build_tools/fbcode_config4.8.1.sh      |    59 +-
 src/rocksdb/build_tools/rocksdb-lego-determinator  |   116 +-
 src/rocksdb/build_tools/run_ci_db_test.ps1         |   216 +-
 src/rocksdb/db/builder.cc                          |    23 +-
 src/rocksdb/db/builder.h                           |    12 +-
 src/rocksdb/db/c.cc                                |    10 +
 src/rocksdb/db/column_family.cc                    |    27 +-
 src/rocksdb/db/column_family_test.cc               |   112 +-
 src/rocksdb/db/compact_files_test.cc               |    57 +
 src/rocksdb/db/compaction.cc                       |     5 +-
 src/rocksdb/db/compaction.h                        |    11 +
 src/rocksdb/db/compaction_iterator.cc              |   134 +-
 src/rocksdb/db/compaction_iterator.h               |    17 +-
 src/rocksdb/db/compaction_iterator_test.cc         |     6 +-
 src/rocksdb/db/compaction_job.cc                   |    48 +-
 src/rocksdb/db/compaction_job.h                    |     9 +-
 src/rocksdb/db/compaction_job_stats_test.cc        |     6 +-
 src/rocksdb/db/compaction_job_test.cc              |   303 +-
 src/rocksdb/db/compaction_picker.cc                |    23 +-
 src/rocksdb/db/compaction_picker.h                 |     2 +-
 src/rocksdb/db/comparator_db_test.cc               |     3 +-
 src/rocksdb/db/corruption_test.cc                  |    12 +-
 src/rocksdb/db/db_bench.cc                         |   214 +-
 src/rocksdb/db/db_compaction_filter_test.cc        |   166 +-
 src/rocksdb/db/db_compaction_test.cc               |    95 +-
 src/rocksdb/db/db_dynamic_level_test.cc            |     8 +-
 src/rocksdb/db/db_impl.cc                          |   767 +-
 src/rocksdb/db/db_impl.h                           |    97 +-
 src/rocksdb/db/db_impl_debug.cc                    |    40 +-
 src/rocksdb/db/db_inplace_update_test.cc           |     2 +-
 src/rocksdb/db/db_iter.cc                          |    74 +-
 src/rocksdb/db/db_iter.h                           |    27 +-
 src/rocksdb/db/db_iter_test.cc                     |    10 +-
 src/rocksdb/db/db_log_iter_test.cc                 |     8 +-
 src/rocksdb/db/db_table_properties_test.cc         |   226 +
 src/rocksdb/db/db_tailing_iter_test.cc             |    18 +-
 src/rocksdb/db/db_test.cc                          |  1380 ++-
 src/rocksdb/{util => db}/db_test_util.cc           |   200 +-
 src/rocksdb/{util => db}/db_test_util.h            |   175 +-
 src/rocksdb/db/db_universal_compaction_test.cc     |    57 +-
 src/rocksdb/db/db_wal_test.cc                      |    10 +-
 src/rocksdb/db/event_helpers.cc                    |     2 +-
 src/rocksdb/db/fault_injection_test.cc             |     8 -
 src/rocksdb/db/file_indexer.h                      |     6 +-
 src/rocksdb/db/filename.cc                         |    44 +-
 src/rocksdb/db/filename.h                          |    16 +-
 src/rocksdb/db/flush_job.cc                        |    18 +-
 src/rocksdb/db/flush_job.h                         |     4 +-
 src/rocksdb/db/flush_job_test.cc                   |     2 +-
 src/rocksdb/db/forward_iterator.cc                 |   136 +-
 src/rocksdb/db/forward_iterator.h                  |    22 +-
 src/rocksdb/db/forward_iterator_bench.cc           |   374 +
 src/rocksdb/db/{skiplist.h => inlineskiplist.h}    |   335 +-
 src/rocksdb/db/inlineskiplist_test.cc              |   391 +
 src/rocksdb/db/internal_stats.cc                   |    76 +-
 src/rocksdb/db/internal_stats.h                    |    32 +-
 src/rocksdb/db/listener_test.cc                    |    59 +-
 src/rocksdb/db/log_format.h                        |    14 +-
 src/rocksdb/db/log_reader.cc                       |   209 +-
 src/rocksdb/db/log_reader.h                        |    37 +-
 src/rocksdb/db/log_test.cc                         |   272 +-
 src/rocksdb/db/log_writer.cc                       |    81 +-
 src/rocksdb/db/log_writer.h                        |    21 +-
 src/rocksdb/{util => db}/manual_compaction_test.cc |     0
 src/rocksdb/db/memtable.cc                         |     6 +-
 src/rocksdb/db/memtable.h                          |     3 +-
 src/rocksdb/db/memtable_list.cc                    |     6 +-
 src/rocksdb/db/memtable_list.h                     |     3 +-
 src/rocksdb/db/memtablerep_bench.cc                |     4 +-
 src/rocksdb/db/merge_helper.cc                     |     4 +-
 src/rocksdb/db/merge_helper.h                      |     4 +-
 src/rocksdb/db/options_file_test.cc                |   119 +
 src/rocksdb/db/perf_context_test.cc                |    46 +
 src/rocksdb/db/prefix_test.cc                      |    57 +
 src/rocksdb/db/repair.cc                           |    19 +-
 src/rocksdb/db/skiplist.h                          |    22 +-
 src/rocksdb/db/snapshot_impl.cc                    |     3 +
 src/rocksdb/db/snapshot_impl.h                     |    23 +-
 src/rocksdb/db/table_cache.cc                      |    19 +-
 src/rocksdb/db/table_cache.h                       |    13 +-
 src/rocksdb/db/table_properties_collector.h        |    13 +-
 src/rocksdb/db/table_properties_collector_test.cc  |    12 +-
 src/rocksdb/db/transaction_log_impl.cc             |     6 +-
 src/rocksdb/db/version_builder.cc                  |    19 +-
 src/rocksdb/db/version_builder.h                   |     2 +-
 src/rocksdb/db/version_edit.cc                     |   124 +-
 src/rocksdb/db/version_edit.h                      |     2 +
 src/rocksdb/db/version_edit_test.cc                |   116 +
 src/rocksdb/db/version_set.cc                      |   168 +-
 src/rocksdb/db/version_set.h                       |    46 +-
 src/rocksdb/db/wal_manager.cc                      |     4 +-
 src/rocksdb/db/wal_manager_test.cc                 |     5 +-
 src/rocksdb/db/write_batch.cc                      |   225 +-
 src/rocksdb/db/write_batch_internal.h              |    34 +-
 src/rocksdb/db/write_batch_test.cc                 |    14 +-
 src/rocksdb/db/write_controller.cc                 |     2 +-
 src/rocksdb/db/write_thread.cc                     |     7 +-
 src/rocksdb/doc/log_format.txt                     |     2 +-
 src/rocksdb/examples/Makefile                      |     3 +
 src/rocksdb/examples/options_file_example.cc       |   113 +
 .../examples/rocksdb_option_file_example.ini       |   140 +-
 src/rocksdb/hdfs/README                            |     2 +-
 src/rocksdb/include/rocksdb/c.h                    |     5 +
 src/rocksdb/include/rocksdb/cache.h                |     4 +-
 src/rocksdb/include/rocksdb/compaction_filter.h    |    26 +-
 src/rocksdb/include/rocksdb/convenience.h          |    18 +-
 src/rocksdb/include/rocksdb/db.h                   |   130 +-
 src/rocksdb/include/rocksdb/env.h                  |    38 +-
 src/rocksdb/include/rocksdb/iterator.h             |    44 +-
 src/rocksdb/include/rocksdb/listener.h             |    27 +-
 src/rocksdb/include/rocksdb/options.h              |    86 +-
 src/rocksdb/include/rocksdb/perf_context.h         |    32 +-
 src/rocksdb/include/rocksdb/slice.h                |    10 +
 src/rocksdb/include/rocksdb/snapshot.h             |     3 +
 src/rocksdb/include/rocksdb/status.h               |     2 +-
 src/rocksdb/include/rocksdb/table.h                |    32 +-
 src/rocksdb/include/rocksdb/table_properties.h     |    16 +-
 .../include/rocksdb/utilities/backupable_db.h      |     9 +
 src/rocksdb/include/rocksdb/utilities/env_mirror.h |   166 +
 src/rocksdb/include/rocksdb/utilities/geo_db.h     |    21 +-
 .../include/rocksdb/utilities/memory_util.h        |    50 +
 .../include/rocksdb/utilities/options_util.h       |    80 +
 .../include/rocksdb/utilities/stackable_db.h       |    28 +-
 .../include/rocksdb/utilities/transaction.h        |    70 +-
 src/rocksdb/include/rocksdb/version.h              |     2 +-
 src/rocksdb/include/rocksdb/wal_filter.h           |    66 +
 src/rocksdb/include/rocksdb/write_batch.h          |    38 +-
 src/rocksdb/java/RELEASE.md                        |     2 +-
 src/rocksdb/java/crossbuild/Vagrantfile            |     2 +-
 src/rocksdb/java/crossbuild/build-linux-centos.sh  |     8 +-
 src/rocksdb/java/rocksjni/options.cc               |    53 +
 src/rocksdb/java/rocksjni/write_batch.cc           |     2 +-
 src/rocksdb/java/rocksjni/write_batch_test.cc      |     2 +-
 .../org/rocksdb/ColumnFamilyOptionsInterface.java  |     6 +-
 .../main/java/org/rocksdb/DBOptionsInterface.java  |     2 +-
 src/rocksdb/{util => memtable}/hash_cuckoo_rep.cc  |    10 +-
 src/rocksdb/{util => memtable}/hash_cuckoo_rep.h   |     3 +-
 .../{util => memtable}/hash_linklist_rep.cc        |     2 +-
 src/rocksdb/{util => memtable}/hash_linklist_rep.h |     2 +-
 .../{util => memtable}/hash_skiplist_rep.cc        |     2 +-
 src/rocksdb/{util => memtable}/hash_skiplist_rep.h |     2 +-
 src/rocksdb/{util => memtable}/stl_wrappers.h      |    12 -
 src/rocksdb/port/port.h                            |     1 -
 src/rocksdb/port/port_posix.h                      |    10 +-
 src/rocksdb/port/win/env_win.cc                    |   181 +-
 src/rocksdb/port/win/port_win.cc                   |    53 +-
 src/rocksdb/port/win/port_win.h                    |   118 +-
 src/rocksdb/port/win/win_logger.cc                 |    21 +-
 src/rocksdb/port/win/win_logger.h                  |     3 +
 src/rocksdb/src.mk                                 |    36 +-
 src/rocksdb/table/adaptive_table_factory.cc        |     5 +-
 src/rocksdb/table/adaptive_table_factory.h         |     2 +-
 src/rocksdb/table/block.cc                         |     8 +-
 src/rocksdb/table/block.h                          |     8 +-
 src/rocksdb/table/block_based_table_builder.cc     |    17 +-
 src/rocksdb/table/block_based_table_builder.h      |     3 +-
 src/rocksdb/table/block_based_table_factory.cc     |    20 +-
 src/rocksdb/table/block_based_table_factory.h      |     6 +-
 src/rocksdb/table/block_based_table_reader.cc      |    76 +-
 src/rocksdb/table/block_based_table_reader.h       |    25 +-
 src/rocksdb/table/block_hash_index.cc              |     6 +-
 src/rocksdb/table/block_hash_index.h               |     7 +-
 src/rocksdb/table/block_hash_index_test.cc         |     3 +-
 src/rocksdb/table/block_test.cc                    |     6 +-
 src/rocksdb/table/cuckoo_table_factory.cc          |     2 +-
 src/rocksdb/table/cuckoo_table_factory.h           |     6 +-
 src/rocksdb/table/cuckoo_table_reader.cc           |    12 +-
 src/rocksdb/table/cuckoo_table_reader.h            |     4 +-
 src/rocksdb/table/cuckoo_table_reader_test.cc      |     4 +-
 .../iterator.h => table/internal_iterator.h}       |    49 +-
 src/rocksdb/table/iterator.cc                      |    54 +-
 src/rocksdb/table/iterator_wrapper.h               |    19 +-
 src/rocksdb/table/merger.cc                        |    20 +-
 src/rocksdb/table/merger.h                         |    14 +-
 src/rocksdb/table/merger_test.cc                   |     6 +-
 src/rocksdb/table/meta_blocks.cc                   |    11 +-
 src/rocksdb/table/meta_blocks.h                    |     5 +-
 src/rocksdb/table/mock_table.cc                    |    13 +-
 src/rocksdb/table/mock_table.h                     |    11 +-
 src/rocksdb/table/plain_table_builder.cc           |    10 +-
 src/rocksdb/table/plain_table_builder.h            |    10 +-
 src/rocksdb/table/plain_table_factory.cc           |    35 +-
 src/rocksdb/table/plain_table_factory.h            |    32 +-
 src/rocksdb/table/plain_table_reader.cc            |    31 +-
 src/rocksdb/table/plain_table_reader.h             |    10 +-
 .../{util => table}/scoped_arena_iterator.h        |    15 +-
 src/rocksdb/table/sst_file_writer.cc               |     7 +-
 src/rocksdb/table/table_properties.cc              |     6 +-
 src/rocksdb/table/table_properties_internal.h      |     4 +-
 src/rocksdb/table/table_reader.h                   |     4 +-
 src/rocksdb/table/table_reader_bench.cc            |    21 +-
 src/rocksdb/table/table_test.cc                    |    73 +-
 src/rocksdb/table/two_level_iterator.cc            |    19 +-
 src/rocksdb/table/two_level_iterator.h             |     9 +-
 .../gtest-1.7.0/fused-src/gtest/gtest-all.cc       |     2 +-
 src/rocksdb/thirdparty.inc                         |    65 +
 src/rocksdb/tools/auto_sanity_test.sh              |     6 +-
 src/rocksdb/tools/db_crashtest.py                  |   448 +-
 src/rocksdb/tools/db_crashtest2.py                 |   231 -
 src/rocksdb/tools/db_stress.cc                     |    35 +-
 src/rocksdb/{util => tools}/ldb_cmd.cc             |    58 +-
 src/rocksdb/{util => tools}/ldb_cmd.h              |     2 +-
 .../{util => tools}/ldb_cmd_execute_result.h       |     0
 src/rocksdb/{util => tools}/ldb_cmd_test.cc        |    13 +-
 src/rocksdb/{util => tools}/ldb_tool.cc            |    13 +-
 src/rocksdb/tools/reduce_levels_test.cc            |     2 +-
 src/rocksdb/{util => tools}/sst_dump_test.cc       |     1 +
 src/rocksdb/{util => tools}/sst_dump_tool.cc       |    12 +-
 src/rocksdb/{util => tools}/sst_dump_tool_imp.h    |     4 +-
 src/rocksdb/tools/write_stress.cc                  |   306 +
 src/rocksdb/tools/write_stress_runner.py           |    73 +
 src/rocksdb/util/auto_roll_logger.cc               |    26 +-
 src/rocksdb/util/auto_roll_logger.h                |    10 +-
 src/rocksdb/util/auto_roll_logger_test.cc          |     8 +-
 src/rocksdb/util/cache.cc                          |     6 +-
 src/rocksdb/util/coding.h                          |     4 +-
 src/rocksdb/util/compression.h                     |     4 +-
 src/rocksdb/util/env.cc                            |    16 +
 src/rocksdb/util/env_posix.cc                      |  1094 +-
 src/rocksdb/util/env_test.cc                       |     4 +-
 src/rocksdb/util/file_reader_writer.cc             |    71 +-
 src/rocksdb/util/file_reader_writer.h              |    13 +-
 src/rocksdb/util/file_reader_writer_test.cc        |    45 +-
 src/rocksdb/util/file_util.cc                      |     3 +-
 src/rocksdb/util/histogram.cc                      |     2 +-
 src/rocksdb/util/instrumented_mutex.cc             |    11 +-
 src/rocksdb/util/io_posix.cc                       |   655 ++
 src/rocksdb/util/io_posix.h                        |   174 +
 src/rocksdb/util/{stl_wrappers.h => kv_map.h}      |    15 -
 src/rocksdb/util/mutable_cf_options.cc             |     4 +-
 src/rocksdb/util/mutable_cf_options.h              |     9 +-
 src/rocksdb/util/options.cc                        |    53 +-
 src/rocksdb/util/options_builder.cc                |     4 +-
 src/rocksdb/util/options_helper.cc                 |   804 +-
 src/rocksdb/util/options_helper.h                  |   149 +
 src/rocksdb/util/options_parser.cc                 |   253 +-
 src/rocksdb/util/options_parser.h                  |    58 +-
 src/rocksdb/util/options_sanity_check.cc           |    38 +
 src/rocksdb/util/options_sanity_check.h            |    49 +
 src/rocksdb/util/options_test.cc                   |   702 +-
 src/rocksdb/util/perf_context_imp.h                |     7 +
 src/rocksdb/util/random.cc                         |    38 +
 src/rocksdb/util/random.h                          |    25 +-
 src/rocksdb/util/skiplistrep.cc                    |    22 +-
 src/rocksdb/util/sync_point.cc                     |    15 +-
 src/rocksdb/util/sync_point.h                      |    19 +-
 src/rocksdb/util/testutil.cc                       |   227 +-
 src/rocksdb/util/testutil.h                        |   322 +-
 src/rocksdb/util/thread_local.cc                   |    51 +-
 src/rocksdb/util/thread_local.h                    |    39 +-
 src/rocksdb/util/thread_local_test.cc              |    16 +-
 src/rocksdb/util/thread_posix.cc                   |   250 +
 src/rocksdb/util/thread_posix.h                    |    86 +
 src/rocksdb/util/vectorrep.cc                      |     2 +-
 src/rocksdb/util/xxhash.cc                         |     1 +
 src/rocksdb/utilities/backupable/backupable_db.cc  |    68 +-
 .../utilities/backupable/backupable_db_test.cc     |   377 +-
 .../backupable/backupable_db_testutil.h}           |    17 +-
 .../utilities/checkpoint/checkpoint_test.cc        |     8 -
 src/rocksdb/utilities/document/json_document.cc    |     4 +-
 .../utilities/document/json_document_builder.cc    |     7 +-
 src/rocksdb/utilities/env_mirror.cc                |   266 +
 src/rocksdb/utilities/env_mirror_test.cc           |   222 +
 src/rocksdb/utilities/geodb/geodb_impl.cc          |    58 +-
 src/rocksdb/utilities/geodb/geodb_impl.h           |     5 +-
 src/rocksdb/utilities/geodb/geodb_test.cc          |    18 +-
 src/rocksdb/utilities/memory/memory_test.cc        |   274 +
 src/rocksdb/utilities/memory/memory_util.cc        |    52 +
 .../merge_operators/string_append/stringappend.cc  |     3 -
 .../merge_operators/string_append/stringappend.h   |     4 +-
 .../merge_operators/string_append/stringappend2.cc |     1 -
 src/rocksdb/utilities/options/options_util.cc      |    99 +
 src/rocksdb/utilities/options/options_util_test.cc |   287 +
 src/rocksdb/utilities/redis/redis_list_iterator.h  |     7 +-
 .../compact_on_deletion_collector.cc               |     9 +-
 .../compact_on_deletion_collector.h                |     4 +-
 .../compact_on_deletion_collector_test.cc          |    13 +-
 .../transactions/optimistic_transaction_impl.cc    |     2 +
 .../utilities/transactions/transaction_base.cc     |    68 +-
 .../utilities/transactions/transaction_base.h      |    40 +-
 .../utilities/transactions/transaction_db_impl.cc  |    30 +-
 .../utilities/transactions/transaction_impl.cc     |   110 +-
 .../utilities/transactions/transaction_impl.h      |     3 +-
 .../utilities/transactions/transaction_test.cc     |   445 +
 .../write_batch_with_index.cc                      |     2 +-
 src/test/Makefile-client.am                        |    29 +-
 src/test/Makefile-server.am                        |    15 +-
 src/test/Makefile.am                               |    10 +-
 src/test/ObjectMap/test_object_map.cc              |     4 +-
 src/test/bench/dumb_backend.h                      |     4 +-
 src/test/bench/small_io_bench_dumb.cc              |     2 +-
 src/test/bench/small_io_bench_fs.cc                |     4 +-
 src/test/bench/tp_bench.cc                         |     2 +-
 src/test/bench_log.cc                              |    13 +-
 src/test/bufferlist.cc                             |    60 +-
 src/test/centos-6/ceph.spec.in                     |    22 +-
 src/test/centos-7/ceph.spec.in                     |    22 +-
 src/test/ceph-disk.sh                              |     1 +
 src/test/ceph_compatset.cc                         |     4 +-
 src/test/ceph_objectstore_tool.py                  |    11 +-
 src/test/cli/crushtool/arg-order-checks.t          |     2 +-
 src/test/cli/crushtool/build.t                     |     2 +-
 .../crushtool/check-overlapped-rules.crushmap.txt  |    89 +
 src/test/cli/crushtool/check-overlapped-rules.t    |     6 +
 src/test/cli/crushtool/help.t                      |    33 +-
 .../crushtool/test-map-hammer-tunables.crushmap    |   Bin 0 -> 3386 bytes
 src/test/cli/crushtool/test-map-hammer-tunables.t  | 10252 +++++++++++++++++++
 .../cli/crushtool/test-map-jewel-tunables.crushmap |   Bin 0 -> 3387 bytes
 src/test/cli/crushtool/test-map-jewel-tunables.t   | 10252 +++++++++++++++++++
 src/test/cli/osdmaptool/crush.t                    |     2 +-
 src/test/cli/radosgw-admin/help.t                  |     2 +
 src/test/common/Throttle.cc                        |    76 +-
 src/test/common/test_shared_cache.cc               |     6 +-
 src/test/common/test_sharedptr_registry.cc         |     6 +-
 src/test/common/test_time.cc                       |   145 +
 src/test/compressor/Makefile.am                    |    49 +
 src/test/compressor/compressor_example.h           |    53 +
 src/test/compressor/compressor_plugin_example.cc   |    57 +
 src/test/compressor/test_compression_plugin.cc     |    71 +
 .../compressor/test_compression_plugin_snappy.cc   |    58 +
 src/test/compressor/test_compression_snappy.cc     |    62 +
 src/test/crush/CrushWrapper.cc                     |     4 +-
 src/test/encoding/types.h                          |    15 +-
 src/test/erasure-code/TestErasureCodeIsa.cc        |     4 +-
 src/test/erasure-code/TestErasureCodePlugin.cc     |     2 +-
 src/test/fedora-21/ceph.spec.in                    |    22 +-
 src/test/filestore/TestFileStore.cc                |     2 +-
 src/test/libcephfs/access.cc                       |    31 +-
 src/test/libcephfs/acl.cc                          |   307 +
 src/test/libcephfs/caps.cc                         |     2 +-
 src/test/libcephfs/test.cc                         |    65 +-
 src/test/librados/TestCase.h                       |    13 +
 src/test/librados/cmd.cc                           |    64 +-
 src/test/librados/list.cc                          |   241 +
 src/test/librados/nlist.cc                         |    23 +
 src/test/librados/test.cc                          |   140 +-
 src/test/librados/test.h                           |     6 +-
 src/test/librados_test_stub/MockTestMemIoCtxImpl.h |    15 +
 src/test/librbd/fsx.cc                             |    27 +-
 .../test_Entries.cc}                               |     2 +-
 .../test_Replay.cc}                                |    23 +-
 src/test/librbd/journal/test_mock_Replay.cc        |   790 ++
 src/test/librbd/mock/MockImageCtx.h                |    35 +-
 src/test/librbd/mock/MockJournal.h                 |    14 +-
 src/test/librbd/mock/MockObjectMap.h               |     4 +
 src/test/librbd/mock/MockOperations.h              |    35 +
 .../object_map/test_mock_InvalidateRequest.cc      |     2 +-
 .../librbd/object_map/test_mock_ResizeRequest.cc   |     2 +-
 .../object_map/test_mock_SnapshotRemoveRequest.cc  |    14 +-
 .../test_mock_SnapshotRollbackRequest.cc           |     6 +-
 .../librbd/object_map/test_mock_UpdateRequest.cc   |     4 +-
 .../librbd/operation/test_mock_ResizeRequest.cc    |   359 +
 .../operation/test_mock_SnapshotCreateRequest.cc   |    12 +-
 .../operation/test_mock_SnapshotProtectRequest.cc  |    10 +-
 .../operation/test_mock_SnapshotRemoveRequest.cc   |    22 +-
 .../operation/test_mock_SnapshotRollbackRequest.cc |   310 +
 .../test_mock_SnapshotUnprotectRequest.cc          |    12 +-
 src/test/librbd/test_fixture.cc                    |    16 +
 src/test/librbd/test_fixture.h                     |     5 +
 src/test/librbd/test_internal.cc                   |    64 +-
 src/test/librbd/test_librbd.cc                     |    71 +-
 src/test/librbd/test_mock_ExclusiveLock.cc         |    14 +-
 src/test/librbd/test_mock_Journal.cc               |   898 ++
 src/test/librbd/test_mock_fixture.cc               |    51 +
 src/test/librbd/test_mock_fixture.h                |    12 +
 src/test/mon/mkfs.sh                               |     4 +
 src/test/mon/osd-erasure-code-profile.sh           |     2 +-
 src/test/mon/test_mon_workloadgen.cc               |     2 +-
 src/test/msgr/perf_msgr_client.cc                  |     2 +-
 src/test/msgr/perf_msgr_server.cc                  |     2 +-
 src/test/msgr/test_async_driver.cc                 |     6 +-
 src/test/objectstore/FileStoreDiff.cc              |     2 +-
 src/test/objectstore/FileStoreDiff.h               |     2 +-
 src/test/objectstore/FileStoreTracker.h            |     2 +-
 src/test/objectstore/TestRocksdbOptionParse.cc     |    14 +-
 src/test/objectstore/chain_xattr.cc                |     8 +-
 src/test/objectstore/store_test.cc                 |   850 +-
 src/test/objectstore/test_bluefs.cc                |   148 +
 src/test/objectstore/test_bluestore_types.cc       |   157 +
 src/test/objectstore/test_idempotent.cc            |     2 +-
 src/test/objectstore/test_idempotent_sequence.cc   |     2 +-
 src/test/opensuse-13.2/ceph.spec.in                |    22 +-
 src/test/os/TestLFNIndex.cc                        |     4 +-
 src/test/osd/Object.cc                             |    11 +-
 src/test/osd/TestPGLog.cc                          |    13 +-
 src/test/osd/osd-markdown.sh                       |   112 +
 src/test/osd/osd-reuse-id.sh                       |    51 +
 src/test/osd/osd-scrub-repair.sh                   |    53 +-
 src/test/osd/types.cc                              |    37 +-
 src/test/osdc/FakeWriteback.cc                     |    33 +-
 src/test/osdc/FakeWriteback.h                      |     9 +-
 src/test/osdc/object_cacher_stress.cc              |     5 +-
 src/test/perf_local.cc                             |     6 +-
 src/test/pybind/test_ceph_argparse.py              |    20 +-
 src/test/python/ceph-disk/tests/test_ceph_disk.py  |    32 +
 src/test/python/ceph-disk/tox.ini                  |     2 +-
 src/test/streamtest.cc                             |   192 -
 src/test/test_filejournal.cc                       |     4 +-
 src/test/test_ipaddr.cc                            |    18 +
 src/test/test_objectstore_memstore.sh              |     1 +
 src/test/test_pageset.cc                           |     2 +-
 src/test/test_snap_mapper.cc                       |     2 +-
 src/test/test_stress_watch.cc                      |     2 +-
 src/test/test_texttable.cc                         |     3 +-
 src/test/test_trans.cc                             |     4 +-
 src/test/test_workqueue.cc                         |     4 +-
 src/test/xattr_bench.cc                            |     2 +-
 src/tools/ceph_authtool.cc                         |   399 +-
 src/tools/ceph_monstore_tool.cc                    |   124 +
 src/tools/ceph_objectstore_tool.cc                 |   157 +-
 src/tools/ceph_osdomap_tool.cc                     |     2 +-
 src/tools/cephfs/Dumper.cc                         |    11 +-
 src/tools/cephfs/MDSUtility.cc                     |     2 +-
 src/tools/cephfs/MDSUtility.h                      |     1 +
 src/tools/crushtool.cc                             |    56 +-
 src/tools/rados/rados.cc                           |    23 +-
 src/tools/rbd/Shell.cc                             |    28 +-
 src/tools/rbd/Shell.h                              |     8 +-
 src/tools/rbd/Utils.cc                             |    17 +-
 src/tools/rbd/action/ImportDiff.cc                 |    14 +-
 src/tools/rbd/action/Journal.cc                    |     2 +-
 src/tools/rbd/action/MergeDiff.cc                  |     6 +-
 src/tools/rbd_nbd/rbd-nbd.cc                       |   218 +-
 src/tracing/librbd.tp                              |    26 +
 src/vstart.sh                                      |    39 +-
 systemd/Makefile.in                                |    24 +-
 test-driver                                        |    15 +-
 899 files changed, 96467 insertions(+), 32699 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 22e4399..8469180 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +1,9 @@
 Abhishek Dixit <dixitabhi at gmail.com>
 Abhishek Lekshmanan <abhishek.lekshmanan at ril.com>
+Abhishek Lekshmanan <abhishek at suse.com>
 Accela Zhao <accelazh at gmail.com>
 Adam C. Emerson <aemerson at linuxbox.com>
+Adam C. Emerson <aemerson at redhat.com>
 Adam Crume <adamcrume at gmail.com>
 Adam Kupczyk <akupczyk at mirantis.com>
 Adam Manzanares <nmtadam at gmail.com>
@@ -63,8 +65,8 @@ Bosse Klykken <larkly at gmail.com>
 Brad Hubbard <bhubbard at redhat.com>
 Brandon Seibel <brandon at seibelnet.ca>
 Brian Andrus <bandrus at redhat.com>
-brian <bjfelton at gmail.com>
 Brian Chrisman <brchrisman at gmail.com>
+Brian Felton <bjfelton at gmail.com>
 Brian Rak <dn at devicenull.org>
 Brown, David M JR <david.brown at pnl.gov>
 Burkhard Linke <Burkhard.Linke at computational.bio.uni-giessen.de>
@@ -88,7 +90,6 @@ Chengyuan Li <chengyli at ebay.com>
 Chris Dunlop <chris at onthe.net.au>
 Chris Glass <tribaal at gmail.com>
 Chris Holcombe <chris.holcombe at nebula.com>
-Chris Holcombe <xfactor973 at gmail.com>
 Christian Brunner <christian at brunner-muc.de>
 Christian Marie <pingu at anchor.net.au>
 Christian Theune <ct at gocept.com>
@@ -96,10 +97,10 @@ Christophe Courtaut <christophe.courtaut at gmail.com>
 Christopher O'Connell <jwriteclub at gmail.com>
 Christoph Hellwig <hch at infradead.org>
 Christos Stavrakakis <stavr.chris at gmail.com>
+Chuanhong Wang <wang.chuanhong at zte.com.cn>
 Cilang Zhao <zhao.cilang at h3c.com>
 Claire Massot <claire.massot93 at gmail.com>
 Clement Lebrun <clement.lebrun.31 at gmail.com>
-clever215 <wu.kongming at h3c.com>
 Colin Mattson <colinmattson at gmail.com>
 Colin P. McCabe <colinm at hq.newdream.net>
 Dan Chai <tengweicai at gmail.com>
@@ -110,6 +111,7 @@ Dan Mick <dan.mick at inktank.com>
 Dan Mick <dmick at redhat.com>
 Danny Al-Gaaf <danny.al-gaaf at bisect.de>
 Dan van der Ster <daniel.vanderster at cern.ch>
+Darrell Enns <darrell at darrellenns.com>
 David Anderson <dave at natulte.net>
 David Coles <dcoles at gaikai.com>
 David Disseldorp <ddiss at suse.de>
@@ -130,6 +132,7 @@ Dongsu Park <dpark1978 at gmail.com>
 Dong Yuan <yuandong1222 at gmail.com>
 Douglas Fuller <dfuller at redhat.com>
 Drunkard Zhang <gongfan193 at gmail.com>
+Dunrong Huang <dunrong.huang at eayun.com>
 Dunrong Huang <riegamaths at gmail.com>
 Eleanor Cawthon <eleanor.cawthon at inktank.com>
 Emily Popper <emily.popper at dreamhost.com>
@@ -148,7 +151,7 @@ Feng Wang <cyclonew at cs.ucsc.edu>
 Filippos Giannakos <philipgian at grnet.gr>
 Florent Bautista <florent at coppint.com>
 Florent Flament <florent.flament at cloudwatt.com>
-Florent Manens <florent at manens.org>
+Florent Manens <florent at beezim.fr>
 Florian Coste <fcoste21 at gmail.com>
 Florian Haas <florian at hastexo.com>
 Florian Marsylle <florian.marsylle at hotmail.fr>
@@ -181,11 +184,11 @@ Hector Martin <marcan at marcan.st>
 Henry C Chang <henry_c_chang at tcloudcomputing.com>
 Henry Chang <henry at bigtera.com>
 Herb Shiu <herb_shiu at tcloudcomputing.com>
-Herve Rousseau <hroussea at cern.ch>
 Hervé Rousseau <hroussea at cern.ch>
 Holger Macht <hmacht at suse.de>
 Huamin Chen <hchen at redhat.com>
 Huang Jun <hjwsm1989 at gmail.com>
+huanwen ren <ren.huanwen at zte.com.cn>
 Ian Holsman <lists at holsman.net>
 Ian Kelling <ian at iankelling.org>
 Igor Fedotov <ifedotov at mirantis.com>
@@ -193,11 +196,11 @@ Igor Podoski <igor.podoski at ts.fujitsu.com>
 Ilja Slepnev <islepnev at gmail.com>
 Ilya Dryomov <idryomov at redhat.com>
 Ilya Dryomov <ilya.dryomov at inktank.com>
+Ilya Shipitsin <ilia at localhost.localdomain>
 Ira Cooper <ira at samba.org>
 Ismael Serrano <ismael.serrano at gmail.com>
 Jacek J. Lakis <jacek.lakis at intel.com>
 Jacek J. Łakis <jacek.lakis at intel.com>
-Jacek J. Łakis <jlakis at gklab-126-033.igk.intel.com>
 James Page <james.page at ubuntu.com>
 James Ryan Cresawn <jrcresawn at gmail.com>
 Jan Harkes <jaharkes at cs.cmu.edu>
@@ -264,11 +267,14 @@ Kevin Dalley <kevin at kelphead.org>
 Kevin Jones <k.j.jonez at gmail.com>
 Kim Vandry <vandry at TZoNE.ORG>
 Kiseleva Alyona <akiselyova at mirantis.com>
+Kongming <wu.kongming at h3c.com>
+Kongming Wu <wu.kongming at h3c.com>
 Krzysztof Kosiński <krzysztof.kosinski at intel.com>
 Kuan Kai Chiu <big.chiu at bigtera.com>
 Kun Huang <academicgareth at gmail.com>
 Kyle Bader <kyle.bader at dreamhost.com>
 Kyle Marsh <kyle.marsh at dreamhost.com>
+lafont <francois.lafont at ac-versailles.fr>
 Laszlo Boszormenyi <gcs at debian.hu>
 Laurent Barbe <laurent at ksperis.com>
 Lee Revell <rlrevell at gmail.com>
@@ -276,6 +282,7 @@ Lei Dong <leidong at yahoo-inc.com>
 Lenz Grimmer <lenz at grimmer.com>
 Liam Monahan <liam at umiacs.umd.edu>
 Li Peng <lip at dtdream.com>
+litianqing <tianqing at unitedstack.com>
 Li Wang <li.wang at kylin-cloud.com>
 Lluis Pamies-Juarez <lluis.pamies-juarez at hgst.com>
 Loic Dachary <ldachary at redhat.com>
@@ -351,6 +358,7 @@ Pierre Rognant <prognant at oodrive.com>
 Piotr Dałek <piotr.dalek at ts.fujitsu.com>
 Qiankun Zheng <zheng.qiankun at h3c.com>
 Radoslaw Zarzynski <rzarzynski at mirantis.com>
+Rahul Aggarwal <rahul.1aggarwal at gmail.com>
 Rajesh Nambiar <rajesh.n at msystechnologies.com>
 Raju Kurunkad <raju.kurunkad at sandisk.com>
 Ray Lv <xiangyulv at gmail.com>
@@ -369,7 +377,7 @@ Rohan Mars <code at rohanmars.com>
 Roman Haritonov <reclosedev at gmail.com>
 Ron Allred <rallred at itrefined.com>
 Rongze Zhu <zrzhit at gmail.com>
-root <rahul.1aggarwal at gmail.com>
+root <liu.peiyang at h3c.com>
 root <root at phenom.dyweni.com>
 Ross Turk <ross.turk at inktank.com>
 Ross Turk <rturk at redhat.com>
@@ -386,6 +394,7 @@ Samuel Just <sjust at redhat.com>
 Sandon Van Ness <sandon at inktank.com>
 Sandon Van Ness <svanness at redhat.com>
 Sangdi Xu <xu.sangdi at h3c.com>
+scienceluo <scienceluo at qq.com>
 Scott A. Brandt <scott at cs.ucsc.edu>
 Scott Devoid <devoid at anl.gov>
 Sean Channel <pentabular at gmail.com>
@@ -405,6 +414,7 @@ Simone Gotti <simone.gotti at gmail.com>
 Simon Leinen <simon.leinen at switch.ch>
 Somnath Roy <somnath.roy at sandisk.com>
 Sondra.Menthers <sondra.menthers at dreamhost.com>
+songbaisen <song.baisen at zte.com.cn>
 Stanislav Sedov <stas at FreeBSD.org>
 Stefan Eilemann <Stefan.Eilemann at epfl.ch>
 Stephan Renatus <s.renatus at x-ion.de>
@@ -415,7 +425,6 @@ Steve MacGregor <grape at lapgoat-0.(none)>
 Steve Stock <steve at technolope.org>
 Stratos Psomadakis <psomas at grnet.gr>
 Stuart Longland <stuartl at vrt.com.au>
-suckowbiz <tobias at suckow.biz>
 Sushma Gurram <sushma.gurram at sandisk.com>
 Swami Reddy <swami.reddy at ril.com>
 Sylvain Baubeau <sbaubeau at redhat.com>
@@ -436,6 +445,7 @@ Tim Freund <tim at freunds.net>
 Tim Serong <tserong at suse.com>
 tmuthamizhan <tamil.muthamizhan at inktank.com>
 Tobias Florek <tobias.florek at bytesandbutter.de>
+Tobias Suckow <tobias at suckow.biz>
 Tomasz Paskowski <ss7pro at gmail.com>
 Tom Callaway <spot at redhat.com>
 Tommi Virtanen <tv at inktank.com>
@@ -447,7 +457,7 @@ Valentin Arshanes Thomas <valentin.arshanes.thomas at gmail.com>
 Vangelis Koukis <vkoukis at cslab.ece.ntua.gr>
 Varada Kari <varada.kari at sandisk.com>
 Vartika Rai <vartikarai17 at gmail.com>
-vasukulkarni <vasu.kulkarni at gmail.com>
+Vasu Kulkarni <vasu.kulkarni at gmail.com>
 Vasu Kulkarni <vasu at redhat.com>
 Venky Shankar <vshankar at redhat.com>
 Vicente Cheng <freeze.bilsted at gmail.com>
@@ -457,7 +467,6 @@ Volker Assmann <volker at twisted-nerve.de>
 VRan Liu <gliuwr at gmail.com>
 Vu Pham <vu at mellanox.com>
 Walter Huf <hufman at gmail.com>
-wangchaunhong <root at A22832429.(none)>
 Wang, Yaguang <yaguang.wang at intel.com>
 Warren Usui <warren.usui at inktank.com>
 Wei Feng <feng.wei at h3c.com>
@@ -469,6 +478,7 @@ Wenjun Huang <wenjunhuang at tencent.com>
 Wesley Spikes <wesley.spikes at dreamhost.com>
 Wido den Hollander <wido at 42on.com>
 William A. Kennington III <william at wkennington.com>
+wuxiangwei <wuxiangwei at h3c.com>
 Wu Xingyi <wuxingyi at letv.com>
 Wyllys Ingersoll <wyllys.ingersoll at keepertech.com>
 Xan Peng <xanpeng at gmail.com>
@@ -476,6 +486,9 @@ Xavier Roche <roche+git at exalead.com>
 Xiaowei Chen <chen.xiaowei at h3c.com>
 Xiaoxi Chen <xiaoxi.chen at intel.com>
 Xie Rui <875016668 at qq.com>
+xie xingguo <xie.xingguo at zte.com.cn>
+xie.xingguo <xie.xingguo at zte.com.cn>
+xiexingguo <xie.xingguo at zte.com.cn>
 Xie Xingguo <xie.xingguo at zte.com.cn>
 Xihui He <xihuihe at gmail.com>
 Xing Lin <xinglin at cs.utah.edu>
@@ -490,8 +503,10 @@ Yan, Zheng <zheng.z.yan at intel.com>
 Yan, Zheng <zyan at redhat.com>
 Yazen Ghannam <yazen.ghannam at linaro.org>
 Yehua Chen <chen.yehua at h3c.com>
+Yehua <chen.yehua at h3c.com>
 Yehuda Sadeh <yehuda at inktank.com>
 Yehuda Sadeh <ysadehwe at redhat.com>
+YiQiang Chen <cyqsign at 163.com>
 Yongqiang He <he.yongqiang at h3c.com>
 Yongyue Sun <abioy.sun at gmail.com>
 You Ji <youji at ebay.com>
@@ -505,4 +520,6 @@ Zhe Zhang <zzxuanyuan at gmail.com>
 Zhicheng Wei <zhicheng at opensourceforge.net>
 Zhi (David) Zhang <zhangz at yahoo-inc.com>
 Zhiqiang Wang <zhiqiang.wang at intel.com>
+Zhiqiang Wang <zhiqiang at xsky.com>
+Zhi Zhang <willzzhang at tencent.com>
 Zhi Zhang <zhangz.david at outlook.com>
diff --git a/ChangeLog b/ChangeLog
index 3327a42..c6f79ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,46 +1,740 @@
-86764ea (HEAD, tag: v10.0.2, origin/jewel) 10.0.2
+efc8134 (HEAD -> 10.0.3, tag: v10.0.3) v10.0.3
+db9408b ceph.spec.in: add license declaration
+23ec516 ceph.spec.in: add copyright notice
+820a760 ceph-disk: Fix trivial typo
+62906d8 osd/PG: fix scrub start object
+b0c2bcf os/bluestore: fix bluestore_wal_transaction_t encoding test
+68c7877 objecter: avoid recursive lock of Objecter::rwlock
+9183d43 cmake: test_build_libcephfs needs ${ALLOC_LIBS}
+d74a7c1 client: properly trim unlinked inode
+f526716 doc: fix "mon osd down out subtree limit" option name
+137d839 pybind/ceph_argparse: update test for "ceph mds setmap"
+8af0758 qa/workunits/cephtool/test.sh: update test for "ceph mds setmap"
+02d15bb mon/MDSMonitor: Add confirmation to "ceph mds rmfailed"
+a51fbf2 rgw: Parse --subuser better
+e153623 rgw: Drop a debugging message
+bd56e17 OSDService: Fix typo in osdmap comment
+1aa674c librbd: missing lock on state transition
+1215a1a helgrind: annotate false-positive race conditions
+bb4d7a7 qa: disable rbd/qemu-iotests test case 055 on RHEL/CentOS
+4c9345b cmake: add missing check for HAVE_EXECINFO_H
+aed8577 osd: disable filestore_xfs_extsize by default
+3286106 os/kstore: fix u64 decode checks
+1590b08 os/bluestore: fix _key_decode_u64 error checks
+92a5d1d os/bluestore/FreelistManager: switch to std::mutex
+fc3554e mon/MDSMonitor: Add confirmation to "ceph mds setmap"
+b4023a4 mon/MDSMonitor: handle invalid input for "ceph mds setmap"
+7bcc960 librbd: handle additional journal replay states
+41987c8 librbd: avoid recursive callback when replaying journal
+d093d83 tests: correct googlemock warnings
+a2ad7ec tests: update tests to support replaying snap create / resize
+9ab14f7 librbd: initial hook points for snap create / resize journal replay
+15170e6 librbd: journal events still possible during shutdown
+532c9d2 tests: new unit test for snap rollback state machine
+11f6a5f librbd: snapshot rollback should block writes
+254c8f4 librbd: track simple maintenance ops to coordinate replay
+0fff683 librbd: asynchronously replay journal events
+2b66a3b tests: unit test cases for all available journal events
+ca71a3e librbd: initial integration of maintenance op journal replay
+37df597 librbd: AioImageRequest base class is now templated
+20b9b2e tests: updated librbd test cases for updated maint ops API
+629c6f0 librbd: moved all maintenance ops to new Operations class
+58069aa tests: journal event handling test updates
+ce8fa3d tests: unit test case for librbd::operation::ResizeRequest
+bf7a1f6 librbd: properly order maintenance ops journal events
+ac86521 librbd: fixed "hidden" virtual methods
+1a17f61 librbd: handle journal and IO commits in either sequence
+89d6c27 librbd: allocate and associate op tids to maint op journal events
+8b2dc72 tests: unit tests for librbd Journal
+1192e9c librbd: journal replay flush should be async
+a1f7006 librbd: convert journal classes to templates for unit testing
+eb057e1 tests: compile RBD and RGW types into ceph-dencoder when enabled
+588ccfb librbd: move journal support classes to journal namespace
+10335c5 cmake: fix the build on trusty
+838b16a ceph_test_libcephfs: tolerate duplicated entries in readdir
+cbaee84 osd:osdmap some clean up
+19dc272 mds: add config option to suspend logging
+5d8d666 mds: fix completed cap flush handling
+dafb46b mds: delay handling client caps until corresponding inode is created
+300c2f7 Compressor: compressor plugins unit tests
+2cadc41 Compressor: compressor code extention: plugin system added
+7d52372 fsx: checkout old version until it compiles properly on miras
+256dc84 doc/release-notes: v10.0.2
+6a309c8 pybind/rbd.pyx: drop stray semicolon
+e92cbde os/bluestore/FreelistManager: fix _dump locking
+386834c pybind: remove extraneous semicolon in method
+9e07482 osd: less chatter about tick
+f6eb3e5 ceph.in:avoid a broken pipe error when use ceph command
+2be865c kstore: remove unreachable code
+a987fc3 BlueStore: decrease max listed object number from 5 to 1
+c8aae0c kstore: decrease max listed object number from 5 to 1
+d339554 BlueStore: kill warnings
+635bda3 BlueStore: fix wrong verification of object key
+3cdf36b BlueStore: fix unhandle error cases during block file setup
+2e77e9a BlueStore: remove unused local variable "empty"
+1f1f577 BlueStore: remove redundant omap_head check
+dc94eb7 BlueStore: fix potential null pointer access
+4e124e5 BlueStore: fix result code overwritten
+c64d339 BlueStore: fix shared_ptr leak during fsck
+0747e3b BlueStore: fix shared_ptr leak during mount
+de0a5d2 BlueStore: fix typo
+a0112a2 BlueStore: fix memory leak in several abnormal cases
+d5900ea BlueStore: reset result code to errno for better tracing
+295cdd6 BlueStore: skip CRC verification if unable to read label
+b085a56 BlueStore: differentiate error code for better tracing
+430bfaf ceph_test_libcephfs: check file open mode
+eae97f8 client: check if Fh is readable before read
+d8a3f6d ceph-fuse: double decreased the count to trim caps
+fa9c8e0 mon: paxos is_recovering calc error
+4c3b685 tests: snap rename and rebuild object map in client update test
+c172ca3 pybind/rbd.pyx: add rebuild_object_map method
+fb3246b add -f flag for btrfs mkfs
+3a8c674 os/bluestore: use auto for freelist map type
+e0a17b9 os/bluestore/BlockDevice: disable readahead of fd_buffered
+7202876 unittest_rocksdb_option_static: fix signed/unsigned warnings
+cf6ca24 os/bluestore: add flag to make reads default to buffered
+3992d6f tests: notification slave needs to wait for master
+67dfaeb librbd: log write/discard errors from clip operation
+df7108e mailmap: Igor Podoski affiliation
+86764ea (tag: v10.0.2) 10.0.2
+8cfbdfd AsyncMessenger: remove reap time wake since it's not safe
+9d6224d AsyncMessenger: delete reap time event when deleting messenger
+9dd5723 AsyncMessenger: fix end of iterator comparison
+837b2b8 AsyncConnection: Remove redundant set_socket_options which already done
+8b13281 AsyncMessenger: reap dead accepting connection too
+8c58934 AsyncMessenger: cleanup dead connection if toomuch or too long
+da05580 AsyncMessenger: Add reap_dead to collect unused connection ref
+dae7abd ceph_test_async_driver: fix scanning utility warning
+da9a470 osdc: hold rwlock when updating crush location config
+f60197b msg/simple: destroy spinlock in destructor
+4b018df osdc: hold writer lock when updating session ops
+33d477b librados: hold lock while testing state variable
+75a3d24 config: avoid re-entrant locking on observer callback
+8f7cf93 WorkQueue: delay registering PointerWQ with thread pool
+61d6489 helgrind: suppress race conditions in external libraries
+8f8b4e2 helgrind: annotate false-positive race conditions
+953bdfb deb,rpm: add valgrind to build dependencies
+2f01284 mailmap:  Jacek J. Łakis affiliation
+113118c mailmap: Drunkard Zhang affiliation
+a6fa1a1b mailmap: Anthony Alba affiliation
+4512886 mailmap: Dunrong Huang affiliation
+a62c3ec mailmap: Jeremy Qian affiliation
+05885a5 mailmap: Shang Ding affiliation
+14b4a75 mailmap: Chuanhong Wang affiliation
+24de350 mds: advance clientreplay when replying
+a64056c mailmap:  Marc Koderer affiliation
+70293c8 mailmap: Kongming Wu name normalization
+91db89d mailmap: Zhang Huan affiliation
+17842b7 mailmap: Wei Feng affiliation
+cf56490 tests: improve rbd-nbd tests
+299288c rbd-nbd: correctly set exit status if map command failed
+3ff60a6 rbd-nbd: returned length equal requested only for read and write
+19cc1e8 ReplicatedPG : clean up unused function
+c628d06 mailmap: Lenz Grimmer affiliation
+ab3fc3a kstore: fix wrong verification logic of object key
+b858e86 osd/PGLog: delay populating PG log hashmaps
+e39ccb4 mailmap: Igor Fedotov affiliation
+9e1c3d5 mailmap: Igor Podoski affiliation
+034ab09 mailmap: Cilang Zhao affiliation
+d9795f6 kstore: differentiate error code for better tracing
+f57e616 mds: fix flushing caps check
+af1a3b2 client: avoid re-sending cap flushes twice during MDS recovers
+21799ac kstore: fix wrong tips in comment
+d64d98c kstore: fix unclosed formatter session
+41aa50b client: add scattered write callback to ObjecterWriteback
+60d205f objectcacher: coalesce dirty buffers in one object into one IO
+eb2bbe1 mailmap: Hector Martin affiliation
+7b4f111 mailmap: Tao Chang affiliation
+b430484 mailmap: Florent Manens affiliation
+5265302 mailmap: Evgeniy Firsov affiliation
 ebdb0a9 packaging: add build dependency on python devel package
+e3d45f0 os/bluestore: don't include when building without libaio
 e59293d librbd: add additional granularity to lock states
 94b7d23 librbd: initialize object map before replaying journal
 4fa53ea librbd: do not accept RPC requests while transitioning lock state
 5216146 librbd: avoid error message when peer owns exclusive lock
+58a1a45 java/test: update for libcephfs permission check
+2b597ae mon: add a column 'RAW USED' for ceph df detail
+93d9d05 cmake: include access tests in test_libcephfs
+68ed47d client: allow user with WRITE perm to set atime/mtime to current time
+c9d42d2 BlueFS: use wrapper for error closing fd
+329106b common: remove unused buf_is_zero
+6537eda osd/osd_types.h: use optimized is_zero in object_stat_sum_t.is_zero()
+181608b BlueFS: return if we are unable to decode a transaction
+ca65fca BlueFS: fix memory leak
+6e8e590 client: reduce _getattr() calls during permission check
+f46513d test_libcephfs: update test cases for libcephfs permission check
+c1c8164 client: add permission check for libcephfs
+b2cf8ed client: apply umask for new files when posix acl is enabled
+e31f35f client: permission check for harklink
+a3dae8c client: permission check for setxattr/removexattr
+c2c89b2 client: permission check for lookup
+96f4af3 client: permission check for setattr
+817d682 client: permission check for creating/deleting files
+2879f4b client: refactor permission check for opening files
+0eb6d0b client: use fuse_req_getgroups() to get group list
+00b2ede client: cleanup 'fuse_req' parameter of ll_setlk/ll_flock
+a9f91d7 client: use thread local data to track fuse request
+cc9f739 client: refactor code that gets group list
+b84cf3e test_libcephfs: add POSIX ACL tests
+5064671 client: POSIX ACL support
+e063edd CrushTool: fix typo and improve indention
+db2e21c CrushTool: exit if fail to add a bucket
+d94cf5b os/memstore: fix fiemap
+fa1c64a os/kstore: fix split_collection to persist cnode
+00ec724 os/bluestore: fix split_collection to persist cnode
+092c5ea os/bluestore: simplify rebalance_freespace
+cec5069 os/bluestore/BlueFS: add reclaim_blocks interface
+d50ddba os/bluestore: base initial bluefs allocation on min_alloc_ratio
+95e885e Reduce string use in coll_t::calc_str()
+8d97df0 mailmap: Dongmao Zhang affiliation
+2c914e2 mailmap: sort files
+95f1035 RBD: remove redundant parent check
+bbb89c7 RBD: fix unhandle result code during list/list_children
+3df756c RBD: fix potential memory leak
+25d6522 Change organization for Dongmao Zhang
+8e65f45 Crush:Remove all the before and after space in better way.
+e6f2e8d cmake: Add ENABLE_GIT_VERSION to avoid rebuilding
+9ee941f os/bluestore: fix bluestore_wal_transaction_t encoding test
+9526b53 RBD: fix unmatched output format
+ed887a6 RBD: fix result code overwritten during header&footer write
+eb92c49 RBD: exit if we are unable to read object map footer
+a87470e os/bluestore: fix allocation vs reservation for bluefs extents
+ece7ef2 os/bluestore: bluestore_debug_prefill = <fill ratio>
+8480ede os/bluestore: pad trailing zeros for WAL write past eof
+d4bded2 os/kstore: make fiemap behave past EOF
+b1f76f7 os/bluestore: make fiemap return valid result beyond EOF
+9bcf046 vstart.sh: debug bluestore = 30
+d0de061 test/osd/RadosModel: fix sparse read result check
+bbfb464 os/kstore: implement minimal fiemap
+16e9cb9 os/bluestore: remove #warning cruft
+b0bd248 os/fs: make aio EAGAIN backoff exponential
+90a2f05 os/bluestore/BlockDevice: reduce aio queue size
+38503d5 os/bluestore: clean up _do_read debug output
+e7b2b18 os/bluestore/BlueFS: fix _compact_log seq jump
+b98ed82 os/bluestore/BlockDevice: make pread() safe
+e29ca1c os/bluestore: fix fiemap
+32dface os/bluestore: drop unused TransContext mutex and cond
+10a969b os/bluestore/BlockDevice: quieter default log level
+3120cbb os/bluestore/BlockDevice: make flush a no-op if there was no IO
+3974bb3 os/bluestore: fix fiemap on object with no data
+655912e os/bluestore/BlockDevice: initiate bufferd writes at aio_write time
+c16b46b os/bluestore/BlueFS: buffered writes
+0ee4747 os/bluestore/BlueFS: no lock on read
+5544897 os/bluestore/BlueFS: do not wait for IO on flush
+9a67fbb os/bluestore/BlueFS: read_random
+cfc8f4c os/bluestore/BlockDevice: read_buffered
+e04973b os/bluestore/BlueFS: keep bool random in FileReader
+323d83d os/bluestore: reserve first block for label when bluefs = false
+f545d72 os/bluestore: fix bdev label error message
+cb53591 os/bluestore: send all old bluefs IOContexts for reap by bdev
+dd8616d os/bluestore: fix valgrind warning on fsid read
+25f08e3 os/keyvaluestore: fix valgrind warning on fsid read
+0d93506 os/filestore: fix valgrind warning on fsid read
+3ec7729 test/mon/osd-erasure-code-profile: pick new mon port
+9b2059c rgw: fix compilation warning
+d6ce874 Objecter: fix typo and wrong tracing messages
+9c5839d Objecter: fix potential null pointer access
+7202f07 Objecter: exit if we detect read error
+52e796f Objecter: abort enumeration when we encouter pool dne
+9749240 pybind/test_rbd: fix test_create_defaults
+d8ae972 unittest_ipaddr: fix segv
+aa8a74a Add copyright for rbd-nbd
+4e732c3 unittest_bluefs: call close_for_write()
+4f53cde test/test_objectstore_memstore.sh: clear store_test_temp_dir
+9179ce8 osdc: Fix race condition with tick_event and shutdown
+5839a1b unittest_bufferlist: fix hexdump test
+d5c02f3 cls_rbd: enable object map checksums for object_map_save
 eb120e8 librbd: correct include guard in RenameRequest.h
+cf9cd80 crush/CrushTester: check for overlapped rules
+279e9fb doc: dev: document ceph-qa-suite
+3ded44d cmake: detect bzip2 and lz4 for rocksdb
+3626d86 cmake: add check for liblz4
+ede0e3a cmake: made rocksdb an imported library
 1329a09 librbd: disable write_full optimization if image has parent
 c425bf0 tests: new test case for write_full optimization
+3337eee mds: fix standby replay thread creation
 df79c3e librbd: directly execute copy-on-read copyup operations
+a286e7c rbd-nbd: prefork only for map command
+e10c67b rbd-nbd: set reply error properly
+b439829 rbd-nbd: improve logging
+132e566 ceph-disk: retry cryptsetup remove
+17430d0 ceph-disk: fix regression in cciss devices names
+35a0c94 ceph-disk: factorize duplicated dmcrypt mapping
+591d581 ceph-disk: list accepts absolute dev names
+756b8e6 ceph-disk: deactivate must unmap dmcrypted journal
+7aab4ed ceph-disk: display OSD details when listing dmcrypt devices
+499c80d tests: limit ceph-disk unit tests to test dir
+798ae1a tests: update ceph-disk workunit debug reminders
+a59b1d4 os: fix bluestore onode_t attr leak
+3ef9941 rgw:modify command stucking when operating radosgw-admin metadata list user
+8e9cf22 OSD: refactor OSD::session_handle_reset()
+21e6ba0 tools: monstore: add 'show-versions' command.
+54432f0 admin/build-doc: make paths absolute
 5f1a530 OSD::ScrubJob: correctly handle small osd_scrub_interval_randomize_ratio
 64cb6e5 Revert "osd: fix arithmetic exception when scrub_min_interval is small"
 67be35c OpRequest: release the message throttle when unregistered
 14fd1c7 librbd: disable copy-on-read when not exclusive lock owner
 8bfd23c tests: fsx should disable journaling feature for krbd
+cc30175 cmake: udev linking and Findudev module changes
+7151a47 cmake: Findxio.cmake update Xio OFF by default
+8ef0dfb cmake: Check for required Cython package
+e117dc5 cmake: Added cls_numops_client library
+73eaf00 cmake: test/erasure-code CMake additions
+0e9b592 cmake: test CMake additions
+31dbe67 cmake: src/erasure-code CMakeLists.txt's changes
+1d4a11f cmake: Missing binaries from src/tools added
+078e95f cmake: CMAKE_DL_LIBS is not linked into osdmaptool
+68c3b33 cmake: libradosstriper dir CMakeLists.txt added
+68aee43 cmake: Added librados_api library
+663dc8d cmake: Added common/Cycles.cc to libcommon
+cbb71a4 cmake: Boost libraries cleanup
+048f3bd cmake: add detection for HAVE_CURL_MULTI_WAIT
+bbf7641 cmake: rbd_replay CMakeLists.txt, rbd_replay fixes
+3307770 cmake: Babeltrace detection supported
+1aa7bc2 cmake: LTTng functionality added
+a614c3b cmake: Updated allocator checking
+b94f910 cmake: kv dir and bluestore unittests
+fee536d osd: Avoid debug std::string initialization in PG::get/set
+c1a0194 client: add client_metadata option to override metadata
 089673a qa/workunits/rbd: import_export should use clean temp space
 5b065aa librbd: reduce verbosity of common error condition logging
+4a4b447 threads: add thread names
+46030b2 client: EPERM instead of ETIMEDOUT on REJECT
+d799193 client: abort requests on session reject
+94ee1ea mds: add docstring for MDSAuthCaps::path_capable
+6c4b5d4 mds: fix client root metadata validation
+607d07c client: handle REJECT session messages from MDS
+8b7a8b2 mds: reject client sessions with bad root metadata
+bf932d3 include: define a new REJECT session message
+a4db99e client: report mount root in session metadata
+4932cb9 mds: validate client 'root' metadata field
+a327dd8 mds: add MDSAuthCaps.maybe_capable(path)
+f11ad56 mon/OSDMonitor: osdmap laggy set a maximum limit for interval
+d225522 os: fix overflow of collection_empty method
+c07dcd5 os: put a guard when read the entire object
+6c55cec os: fix unhandled error other than ENOENT
+e19e8f1 ceph.in: improve the error message
+392f784 rocksdb: remove rdb sources from dist tarball
 a3ac03e journal: disconnect watch after watch error
+31c3cbe mds: expose state of recovery to status ASOK command
+2334e5d os: fix returned type of _do_transaction
+55244c9 os: fix fd leak
+22aa547 os:fix returned type of _do_transaction
+beb99d7 PGMonitor: acting primary diff with cur_stat, should not set pg to stale.
+40a9c67 rbd: correct an output string for merge-diff
+9d10efb pkg: add ceph_volume_client to python-cephfs
+1ec0099 mds: fix `tell session evict`
+c665bf3 pybind: minor fixes to volumeclient
+a2de0db pybind: stray comment in volumeclient
+d72ab0e pybind/cephfs: exception on extra init args
+764be6f pybind: volumeclient fixes
+4557349 pybind: fix mkdir_p in ceph_volume_client
+b21e43e CMake: add libcephfs to cephfs_testing target
+aebce4b pybind: add ceph_volume_client
+3fe9d10 libcephfs: add ceph_create_from_rados
+fc9a0b1 pybind: add LibCephFS.create_with_rados
+c28492a CMake: link libcephfs the same as librados
+e3b9477 pybind: allow CephFS constructor to take ID
+05d79fa osd/PG: For performance start scrub scan at pool to skip temp objects
 7bcb744 Revert "rgw: use smart pointer for C_Reinitwatch"
+5c999b1 osd: Allow get_hash_info to use attrs map if available
+ca81563 osd: Add stat_error for regular scrub handling
+5924c3e osd: Fix ScrubMap::object::decode version
+771c869 osd/ReplicatedPG: for copy_get get omap, firstly check ob whether has omap.
+4a7f007 osd/PGBackend: Don't change error type from DEEP_ERROR to SHALLOW_ERROR.
+2c2d5c7 osd/ReplicatedBackend: Don't forget reset_tp_timeout for first read.
+5e114a4 osd/ReplicatedPG: For omapclear/omaprmkeys, no need call touch.
+1f93b55 osd/ReplicatedPG: for omapclear/omaprmkeys no neet set FLAG_OMAP.
+ef263b3 osd/ReplicatedPG: It should call clear_omap_digest.
+ad44bb5 test: Fix ceph-objectstore-tool test due to recent changes
+aa8583d ceph-objectstore-tool: Warn if --type specified and doesn't match fs
+e7afe62 ceph-objectstore-tool: Improve error message for --type option
 70a1392 qa/workunits/rbd: rbd-nbd test should use sudo for map/unmap ops
+b24378d tests: configure with rocksdb by default
+0fdf745 cmake: build and link rocksdb etc for bluestore
+63bfa0c cmake: add rocksdb include path for bluestore
+43dfe85 mon: MonmapMonitor: don't expose uncommitted state to client
+e9fcb6b mailmap: Chengyuan Li affiliation
+024ac69 mailmap: Hervé Rousseau name normalization
+c02811b mailmap: Chris Holcombe name normalization
+25a3b08 mailmap: Jianhui Yuan affiliation
+2797c66 mailmap: Joe Julian affiliation
+c5f3d03 mailmap: David Coles affiliation
+9691053 mailmap: Vasu Kulkarni affiliation
+ca42be2 mailmap: Tobias Suckow affiliation
+b9e73bf mailmap: Rahul Aggarwal affiliation
+b2f7fc6 mailmap: Brian Felton affiliation
+b0f6af8 tools: ceph_monstore_tool: add inflate-pgmap command
+a9b7c0d os: remove duplicated assignment
+d30ef37 os: remove redundant omap_head check logic
+02f8e92 os: remove unused local variable
+3f05f57 pipe: memory leak when signature check failed
+b1cf0d4 os: remove redundant cleanup
+909d573 os: reset result code to errno for better tracing
+3d0b479 os: fix potential null pointer access
+8d70b8b os: fix threads leak on error exit
+6daa3a5 ObjectCache: fix typo in comment
+e28dae1 librados: remove redundant assignment
+9fe0dde os:fix wrongly placed assert
+c198155 os:fix fd leak during mount
+295029d os: append null terminator manually
+485e586 os: fix return code of _do_copy_range
+31205ce os: fix return code if unable to sync
+dfc5b94 PGLog: clean up read_log
+a17f4e2 rgw: radosgw-admin bucket check --fix not work
+4502446 qa/workunits/rados/test_rados_tool.sh: fix path
+1097bd2 qa/workunits/rados/test_rados_tool: adapt to new buffer hexdump
+bc1cf95 uniform the type format
+757152f os/bluestore/BlueStore: fix overlay keys
+d6043d9 fs: fix unclosed formatter session
+37c6390 qa/workunits/cephtool/test.sh: leave sortbitwise set
+e7a84fe os/bluestore/BlueFS: remove deleted file from dirty list
+20dc14b os/bluestore: Don't forget close fd in _setup_block_symlink_or_file.
+56a964b os/bluestore: write 'type' file
+ee01a7a ceph-objectstore-tool: don't require journal path
+7dddecb ceph-objectstore-tool: get store type from 'type' file, if present
+198b156 os/bluestore/BlueFS: wait for flush aios to complete before returning
+7172a7e os/bluestore/BlockDevice: clean up aio completion a bit
+0336279 os/bluestore/BlueFS: delay IOContext dtor until after io completes
+7cb901c os/bluestore/BlueFS: fix a few leaks
+64b80f3 ceph_test_objectstore: close cct on shutdown
+3f8e2bd os/bluestore/BlueRocksEnv: fix several leaks
+3f4bd46 os/bluestore/BlueFS: fix leak of iocs in writer
+ef26205 kv/RocksDBStore: fix leak of custom Env
+acc8217 os/bluestore/BlockDevice: fix FS leak
+a3ef0ec vstart.sh: no need for 'quit' to ceph cli
+fc9d952 vstart.sh: k=2 for ec
+3fa09f0 os/bluestore: be tolerant of collection_list bounds
+88c3ee8 CMakeLists: update for os/ reorg
+491e2ce os/Makefile: fix typo
+645b535 os/kstore: cache in-flight stripe updates in memory
+5c62690 common/buffer: make hexdump look like 'hexdump -C ...'
+e4e1a7f os/kstore: debug nid
+b57fcf6 os/kstore: fix bugs in read stripe logic
+5950eae ceph_test_objectstore: clean out test dir for each test
+81243c0 os/kstore: clear coll_map on umount
+97373a7 osd: do not catch mkfs exceptions
+34a0f30 os/bluestore/StupidAllocator: be less stupid about alloc_unit
+602b8de unittest_bluestore_types: fix warnings
+893bfc7 os/bluestore/bluestore_types: fix bluestore_extent_ref_map_t test inst
+b16f591 os/Makefile: cosmetic
+d2b5e92 os/fs: move btrfs_ioctl.h to os/fs
+8fc65e1 os/ZFS: move to os/fs
+98a0e10 os/keyvaluestore: move KeyValueStore into os/keyvaluestore/*
+82cbc07 os/memstore: move MemStore into os/memstore/*
+ba2cc1e os/filestore: move FileStore to os/filestore/*
+e07ab3e ceph:small_io_bench_dumb: drop unused include
+6c1ef47 ceph-objectstore-tool: drop unused FileSTore include
+f941642 remove ceph_streamtest
+5b57b09 os/bluestore: allocate shouldn't fail if reserve succeeded
+6641482 os/bluestore/Allocator: add unreserve()
+2b2cc88 os/bluestore/StupidAllocator: fix reservation release on allocate
+193d25f os/bluestore/StupidAllocator: add reservation assertions
+624e996 os/kstore: do not include header in omap iterator result
+b25a242 os/bluestore: do not include header in iterator result
+0f85d86 osd/ReplicatedPG: print omap_digest in debug log
+0cde589 ceph_test_objectstore: add omap iterator test
+5f87bab ceph-objectstore-tool: add fsck command
+da9266d os/ObjectStore: add fsck to interface
+789e99c os/kstore: clear onode on _do_remove
+9aca4ad os/bluestore: clear onode in _do_remove
+fd2659d osd/PGBackend: fix omap digest error message
+56375c5 os: remove {get,set}_allow_sharded_objects from interface
+93964a7 os/bluestore/BlueFS: do not flush metadata on flush()
+cff5dc5 os/bluestore/BlockDevice: helpful error when aio cannot init
+d48a2ba os/bluestore/FreelistManager: audit
+5662bd8 os/bluestore/BlueFS: implement invalidate_cache
+225d3cd os/bluestore/BlockDevice: add invalidate_cache
+8e965db os/bluestore: simplify _do_remove
+e25cf20 os/bluestore: debug msg on statfs
+0a6f35d os/bluestore: optimize _dump_onode slightly
+de8a99d ceph_test_objectstore: enable bluestore debug options
+5534d2b os/bluestore/BlueStore: fsck_on_umount
+a684a59 os/bluestore/StupidAllocator: bluestore_debug_small_allocations
+4aa5f02 os/bluestore/BlueStore: fix _zero when previous extent partially unwritten
+b758d9f os/bluestore: support copy-on-write clones
+8ebb390 os/bluestore/BlueStore: only allow clone if hash matches
+64b4e2f os/bluestore: Enode infrastructure
+fd75b4e os/bluestore/bluestore_types: add extent FLAG_COW_{HEAD,TAIL}
+e93e926 unittest_bluefs, unittest_bluestore_types
+45801ed os/bluestore/bluestore_types: add contains(), clear(), empty() to extent_ref_map
+97bf343 os/bluestore/BlueStore: wal_op_t::OP_COPY
+d927919 os/bluestore/BlockDevice: fix waiter wakeup use-after-free race
+2f9be0c os/bluestore: add bluestore_debug_no_reuse_blocks
+a583e5d ceph_test_objectstore: do Synthetic tests over larger objects
+eeb2251 ceph_test_objectstore: use a few hash values for objects; clone between them
+82d2132 ceph_test_objectstore: dump actual vs expected on read data mismatch
+f884edf ceph_test_objectstore: add many clone tests
+ac08664 ceph_test_objectstore: validate full object contents after writes
+a77363c ceph_test_objectstore: debug enter/exit points
+c9659f9 ceph_test_objectstore: save map lookups for a few ops
+2162990 ceph_test_objectstore: fix locking for a few ops
+549a335 ceph_test_objectstore: fix clone
+1769163 ceph_test_objectstore: simplify object name generation
+48595ad ceph_test_objectstore: clone non-empty objects, not empty ones
+7e86bfd ceph_test_objectstore: clone objects with same hash
+3133eca os/bluestore: add some slow debug path
+27e44dd os/bluestore: clean up comments a bit
+dc5d33b os/bluestore/BlueStore: note wal releases in fsck
+8941e32 os/bluestore/BlueStore: fix read bug when there is a hole
+134a0e4 os/kstore: fix rename
+c206832 os/bluestore/BlueStore: fix rename
+bf1f02c os/bluestore/BlueStore: remove unused OnodeMap::remove
+95b81e5 os/bluestore/BlockDevice: adjust debug output
+e63dbda os/bluestore/BlockDevice: fix path
+6d41758 os/bluestore/BlueStore: do WAL ops buffered to avoid RMW issues
+e07fc75 rocksdb: debug log writes/reads
+9be0b53 os/bluestore: handle both buffered and direct+async IO
+a3de5b6 os/bluestore/BlockDevice: rename bdev options
+3d2bb7a os/bluestore/BlueStore: use BlueFS::get_usage()
+cf5d139 os/bluestore/BlueFS: get_usage()
+be598b7 os/bluestore/BlueFS: do not dirty file when overwriting bytes
+1605e04 os/bluestore/BlueFS: ignore flush when buffer is small
+5e4d3d2 os/bluestore: update freelist in individual transactions
+b1df8cb os/bluestore: better debugging on fsck alloc errors
+9df3d96 script/crash_bdev: simple script to inject bdev failures
+2158371 os/bluestore: fail mount of fsck finds errors
+6925a06 os/fs/FS.h: fix aio_t::pread
+4ebe78c os/bluestore/BlueStore: better error msg for bdev label check
+510b4c7 os/bluestore: don't create block.{db,wal} by default
+1f05196 vstart.sh: less noisy debug
+993c87f os/bluestore: fix fsck contains vs intersects
+6b28449 os/bluestore: bluestore bluefs = true
+0633468 rpm, debian: package ceph-bluefs-tool
+8c04a3b os/bluestore/BlueStore: fix error path if label set fails
+3f8d46c rocksdb: fix recycle replay
+aa844e5 Makefile-rocksdb.am: update
+22073a0 os/bluestore: default to 64k min_alloc_size
+65e5ff4 os/bluestore/BlueStore: fix _open_bdev() failure path
+08f919e kv/RocksDBStore: behave if options string is empty
+197c5ae os/bluestore: clear coll_map on umount, fsck finish
+499b40f os/kstore/KStore: fix object key decode with key
+196786d os/bluestore/BlueStore: fix object key decode with key
+02bd7d5 ceph_objectstore_test: fix warning
+e3affe6 os/KeyValueStore: drop kinetic #include
+669bec7 os/kstore: add new KStore backend
+bc0f2e6 os/bluestore/bluestore_types: localize types
+648f132 os/bluestore: add extent_ref_map_t
+7664ffa os/bluestore/FreelistManager: drop unused db ref
+423f797 os/bluestore: record kv backend
+a17fe3e os/bluestore: statfs
+5fb09a9 os/bluestore/BlockDevice: inject block failures
+c96e025 ceph_test_objectstore: clean up synthetic collections
+485557a os/bluestore: block.db support
+8094355 os/bluestore: less debug noise
+f80b335 os/bluestore/BlueFS: all overwrites on open_for_write
+de300b1 os/bluestore/BlueStore: drop internal EnvMirror
+07a47a3 rocksdb: pull up to master, include EnvMirror
+31307a5 os/bluestore: label all block devices
+9565f0d os/bluestore/BlueFS: flush log if needed
+2e1edef os/bluestore/BlueFS: fix replay of unlink
+3745afb os/bluestore: support second block.wal device
+02605a6 os/bluestore/BlueStore: fix zero gap bug
+9f114ac os/bluestore: disable overlay for now
+b487987 os/bluestore/BlockDevice: restructure interface
+1727ceb os/bluestore/BlueFS: fix overwrite
+13655fb os/bluestore/BlueFS: fix writes spanning extents
+ccce793 os/bluestore: reenable rocksdb recycling
+ef06380 os/bluestore/BlockDevice: lock device while open
+e3fd279 os/bluestore/BlockDevice: debug read result
+f6f4ed3 os/bluestore/BlockDevice: fix alignment check
+db754e7 os/bluestore/BlockDevice: check aio return values
+e7cce09c os/bluestore/BlueFS: avoid lock during reads
+05be4c6 os/bluestore/BlueFS: prevent read+write sharing
+9785bc9 vstart.sh: debug bluefs and rocksdb
+73adec4 os/bluestore/BlueFS: periodically compact log
+dd90149 os/bluestore/BlueFS: simplify extent list
+b073028 os/bluestore/BlueFS: fix read
+ac05b4c ceph_test_objectstore: trivial init fix
+9341eec kv/RocksDBStore: rocksdb_separate_wal_dir option
+3649a80 os/bluestore/BlueFS: ref count BlueFS::File *
+98485de os/bluestore/BlueFS: readdir list dirs, too
+b8630ee ceph-bluefs-tool: simple tool to export bluefs content
+2d05378 os/bluestore/BlueFS: many fixes
+e4f6148 os/bluestore/BlueStore: share space with BlueFS
+653882c os/bluestore/BlockDevice: move to simple mutex model
+dd04391 os/bluestore/BlueFS: simple file system to back rocksdb
+6f5ac50 ceph_test_objectstore: less verbose
+226b347 ceph_test_objectstore: less verbose on hash collision test
+1b8d5b6 os/bluestore/BlueStore: fix _do_read
+1ffd5e6 os/bluestore/StupidAllocator: fix locking
+1446048 os/bluestore/StupidAllocator: fix misc bugs
+08a94d9 os/bluestore/Allocator: init_rm_free
+65f720a kv/RocksDBStore: take custom Env
+a869f92 os/bluestore: fix _do_read return value
+d704628 os/bluestore/BlockDevice: fix read return value
+9d01b8d os/bluestore: separate Allocator from freelist storage
+a62ffb0 newstore -> bluestore
+3a4d583 os/newstore: always create db.wal
+ad9f9fa os/newstore: create db dir
+5658665 os/newstore: consume a raw block device
+32e7683 os/newstore: make collection_list tolerate sloppy start position
+2dae3df os/newstore: make key names more efficient
+5e566dd os/newstore: fix collection_list vs max entries
+84646ab os/newstore: do not set/change frag_size if there are overlays
+9291e16 os/newstore: define a fid_backpointer_t type
+b2db842 os/newstoer: add newstore types to ceph-dencoder
+0af0dbd os/newstore: set alloc hint on new frags
+f0f815f os/newstore: dump onode contents
+2993504 os/newstore: fixed fragment size
+be0528f os/newstore: recycle rocksdb log files
+feb2d3f rocksdb: latest master
+c25ff99 osd: clear pg_stat_queue after stopping pgs
+c01a314 mon/PGMap: show rd/wr iops separately in status reports
+6a59aae config: complains when a setting is not tracked
+2fd3f43 osd: remove repop_map in osd
+e29f55e osd: fix wip (l_osd_op_wip) perf counter
+1e120c8 osd: Avoid osd_recovery_sleep cause recovery-thread suicide.
+6f3f9d3 osd: add cache hint when pushing raw clone during recovery
+59f9058 rgw: do not abort when user passed bad parameters to set quota
+8350323 rgw: do not abort when user passed bad parameters to set metadata
+9b686c3 MonitorDBStore, LevelDBStore, RocksDBStore: make sure the provided bl is empty
+580588a OSD: simplify wake_pg_waiters a little
+ecd8784 ReplicatedPG: remove redundant result code checking
+dd8221d osd/OSD.cc Check health state before pre_booting
+9af4d56 test: enable changing subscribe level testing
+7485668 mon: don't send Mlog msg to client when there is no entries
+9ea99fa mon: remove conflicting subscribes when handle_subscribe
+4efa214 kv: implement value_as_ptr() and use it in .get()
+41fcd87 doc: s/InvalidCap/InvalidCapability
+8ea80a0 rgw: add a new error code for invalid admin capability
+4275ee6 rbd-fuse:image name can not include snap name
+9eefc43 tests:delete the default order of RBD in test_rbd
+636a984 client: make sync_fs() flush dirty data in objectcacher
+7817a81 ceph: wait unsafe requests in sync_fs()
+bd86c30 objectcacher: introduce ObjectCacher::flush_all()
+5246e78 objectcacher: make flush_set() only flushes dirty data in ObjectSet
+428a1f3 objectcacher: sort dirty_or_tx_bh in ObjectSet/Object/offset order
+a7501c9 client: fix 'wait unsafe requests' code in _fsync()
+8d2df89 client: wait unsafe requests that created/modified the file in fsync()
+c615feb rgw: let radosgw-admin bucket stats return a standard josn
+e85907f osd: Improve log message which isn't about a particular shard
+10b4a08 osd/OSD: clear_temp_objects() include removal of Hammer temp objects
+508deb9 common/address_help.cc: fix the leak in entity_addr_from_url()
 b4dbaa6 librbd: do not ignore self-managed snapshot release result
 bc309d9 librbd: properly handle replay of snap remove RPC message
+8e095de qa/workunits: merge_diff shouldn't attempt to use striping v2
 98157ab librbd: ensure librados callbacks are flushed prior to destroying image
+a069ea9 KeyValueStore: fix return code of mkfs
 b8d7aa2 librbd: clear error when older OSD doesn't support image flags
+65db403 rgw: return InvalidAccessKey for invalid access key specified
+ad1e648 rgw: add a new error code for invalid key type
+df6d323 rgw: add a new error code for invalid secret key
+e5d32b0 rgw: add a new error code for key conflict
+c227316 rgw: add a new error code for email conflict
+fff4941 mds: we should wait messenger when MDSDaemon suicide
+0dc0d42 Revert "Revert "makefiles: remove bz2-dev from dependencies""
+911e7a0 configure: link against bz2 and lz4 if detected
+6a560b5 async: don't use shared_ptr to manage EventCallback
+80c770e ceph-detect-init: fix py3 test
+54b12f5 rbd:must specify both of stripe-unit and stripe-count when specify striping features
+d821aca doc: document "readforward" and "readproxy" cache mode
+777564c doc:adding "--allow-shrink" in decreasing the size of the rbd block to distinguish from the increasing option
+c2e3913 man: document listwatchers cmd in "rados" manpage
+877f332 ceph doc fix slip of pen
+eb8057c ceph-fuse: fix double free of args
+93497e5 rgw: warn on suspicious civetweb frontend parameters
+eace76d osd: Avoid osd_op_thread suicide because osd_scrub_sleep > tp_suicide_timeout.
+8978cd6 osd: do not keep ref of old osdmap in pg
+b5b1736 osd: skip promote for writefull w/ FADVISE_DONTNEED/NOCACHE.
+b3aa29e ReplicatedPG: fix sparse-read result code checking logic
+b6d0fc9 filter lo addr when bind osd addr
+4dd86ca correct radosgw-admin command
+b1df12c delete default zone
+6a45bbc test: update test cases with the new snap_exists API
+6850d47 ECBackend: fix unmatched parenttheses
+e8abb83 rbd: stringify outputted error code
 e8911cf tests: flush op work queue prior to destroying MockImageCtx
+6395bf8 ceph-disk: protect deactivate with activate lock
+9dce05a ceph-disk: use blkid instead of sgdisk -i
+fe71647 ceph-disk: dereference symlinks in destroy and zap
+730b5d6 ceph-disk: increase partprobe / udevadm settle timeouts
+fd7fe8c tests: ceph-disk workunit increase verbosity
+b271a06 ceph-disk: fix typo
+f5d36b9 ceph-disk: log parted output
+5fa35ba ceph-disk: do not discard stderr
+845f4a1 cache-tier: Allow to config eviction check max size
+cd2947d Dispatcher.h: include assert.h
+c2a2499 xio: avoid conversion warning w/xio_queue_depth
+34bb892 xio: remove static declspec on buffer::create_msg
+9287e98 FileJournal: fix return code of create method
+eca5cc9 librbd: fix wrongly reported error code
+1908d32 Test: add tests for corrupted list/nlist process
+e259d71 Objecter: potential null pointer access in list_(n)objects.
+71eb4f9 rbd-fuse: discard space restriction for mv operation
+4a4048b librbd: string standard error number
+a752649 librbd: fix wrong tip message
+084f22c tools: replace snap_exists with a new safer version
+c97b1a6 librbd: fix snap_exists API overflow issue
+0c31a6e librbd: fix readahead counter update logic
+70b0962 osd: use atomic to generate ceph_tid
+96563fb msg/Message.h:remove unneeded inline
+6d9da6a librbd: uninitialized state in snap remove state machine
+ecf2beb time: Update OSDC for C++11 Time
+ac96425 osdc: Whitespace
+4367eb1 perfcounters: Allow C++11 time increment/decrement
+a3a7c03 timer: Another timer using new time/lock standards
+08f2676 time: Overload for std:chrono in Cond::TimedWait
+84dcfbd time: Add basic support for std::chrono based time
 bfc9690 librbd: skip journal event if write/discard was no-op
 f6659cc librbd: object map ENOENT optimizations should complete asynchronously
+b21152a rbd: fix "static initialization order fiasco"
+277b353 msg/Connection::add override to virutal methods
 913339f librbd: update exclusive lock state when shutting down
+744a29a rgw: dump_status() uses integer
+2a12ffc rgw: move status_num initialization into constructor
+4e5921d rgw: Do not send a Content-Length header on status 204
 200d310 librbd: extra request required if journal enabled w/ caching
 bab16bb librbd: stop the copyup thread during shutdown
+395bf8a librbd: exit if parent snap is gone during clone
+0de959f Drop deprecated removal pg type.
+d4cf79b mon: modify the level of a log about OSD's condition in OSDMonitor.cc
 69bcac5 qa/workunits/rbd: use --object-size instead of --order
 94cd34b rbd: process crushed, rbd creating with striping parameters
+127cd92 rbd: use default order value from g_conf
 8e93f3f log: Log.cc: Assign LOG_DEBUG priority to syslog calls
+fc39e6f os/MemStore: fix use-after-free on iterator
+750e412 memstore: fix loop in PageSetObject::clone()
+b88561a common/buffer: reset last_p on get_contiguous
+0e77e3b common/buffer: reset iterator on rebuild
+6634660 common/lockdep: increase max lock names
+3d6e51c rbd: fix "was hidden" warning
+95afcad newstore: fix was hidden warning
+3167608 rgw: use unsigned long to print to log
+432d26c cmake: no need to run configure from run-cmake-check.sh
+4269263 crush: fix the default type 0 name if it's not specified when decompiled
+895bf8b crushtool: set type 0 name "osd" for --build option
+d914448 OSD: fix null pointer access and race condition
+7daa1cc librbd: return error if we fail to delete object_map head object
+2e17c34 osdmap: remove unused local variables
+3296905 FileStore: Conditional collection of drive metadata
+fbd5959 doc/release-notes: v10.0.1
+4238974 mon: add `osd blacklist clear`
+4276fb3 Delete rbd'order define
+16d5045 Delete rbd'order setup process
+ec42514 osd: use unordered_map for repop_map With a prediction of expected per pg maximum ops to initialize the number of hash bucket
+d13f602 rbd:add destination image name validation for rbd-fuse mv operation
+8284165 rbd: process crushed, rbd creating with striping parameters
+e7b7e1a rgw: add a method to purge all associate keys when removing a subuser
 35542eb Revert "makefiles: remove bz2-dev from dependencies"
+79c7ccb osd: combine map.count() and map.find() into one searching operation
 fec5458 doc: fix typo in developer guide
+4bf6fbf rbd: specify pool name for rbd admin socket commands
 d465830 mds: fix setvxattr (broken in a536d114)
 a8b5920 makefiles: remove bz2-dev from dependencies
 9409e96 ceph-fuse: add process to ceph-fuse --help
+228aedf rbd: implement mv operation for rbd-fuse
 eadc771 doc: Update list of admin/build-doc dependencies
 b1429aa mds: tear down connections from `tell` commands
 8d68d02 test/encoding/readable.sh: add non-whole type skip
+d0ffeb8 osd/ReplicatedPG: when delete pg, don't forget free scrub resources.
+eb3b647 check for striping parameters
 34a6c2a rgw: remove unused variable
 a57784f rgw: fix the build failure
+d6c097d osd: fix wrong checking for uuid_d::parse() return
+6984239 kv/LevelDBStore: log leveldb to ceph log
+dda6c67 kv/RocksDBStore: log to ceph log
 d2d4bb4 librbd: refresh object map after rollback
 db2d495 librbd: refresh image asynchronously from watch/notify path
 16547c9 librbd: the journal state machine is now asynchronous
@@ -75,23 +769,37 @@ e2eb27f librbd: fix missing header dependencies for parent_types.h
 c67725b librbd: cleanup Context and librados AIO completion callbacks
 9180a92 (tag: v10.0.1) 10.0.1
 00cfe4e tests: new integration test for validating new RBD pools
+42b2386 msg/simple/Pipe.h:remove unneeded friend decl
 1fea4da librbd: optionally validate RBD pool configuration (snapshot support)
 664903f journal: avoid race between flush request and in-flight flushes
 3e6c990 librbd: fix test case race condition for maintenance requests
 15c840c rbd: fix build with "--without-rbd"
+8ad665d osd: object_stat_sum_t encoding optimization
+3b08500 common: eversion_t encoding optimization
+a977e39 common: utime_t encoding optimization
 d5cee59 doc/cephfs/posix: update
+beacff5 doc/rados/operations/crush-map: update docs on crush tunables
+425c644 crushtool: add mapping test for jewel tunables
+2245a0c erasure-code/TestErasureCodeIsa.cc: add const
 df0c1f5 journal: add iohint flags for journal replayer.
 84310c5 journal: Add iohint flags for journal write ops.
 5440334 doc: dev: introduction to tests
+74c249d common: improve cache efficiency if (weak_refs.count(key))   weak_refs[key] it traverses the b-tree twice replace it with weak_refs.find(key), which traverses b-tree once
+c3a383c common: improve cache, replace to unordered map with initializing hash bucket size Based on the PR https://github.com/ceph/ceph/pull/4441
 09e21b4 init-ceph: do umount when the path exists.
 14e9d29 mount/mtab.cc: memory leaks the free() should be called to free resources, in order to avoid memory leaks
 58bad43 client: modify a word in log
 c36d73e doc: Modified a note section in rbd-snapshot doc.
+f07e029 assert: abort() rather than throw
+4e28f9e osd/OSDMap: clear osd_info, osd_xinfo on osd deletion
 ad15b81 vstart.sh: mon osd reporter subtree level = osd
 8cc6301 mstop.sh, mrgw.sh: more scripts to control daemons in dev env
 df92e26 mrun: a tool to run commands against specific mstart cluster
 dfa403c mstart.sh: run multiple clusters in a single source tree
+a75a9a8 FileJournal: batch pop and unpop from writeq and completions
 61aa107 cmake: add run_cmake-check.sh
+54a6ba8 rados: implement radosstripper force remove when full.                     extend libradosstripper remove interface and rados tool                     rm force-full when use_stripper.
+db525ef rados: implement rm --force option to force remove when full.            librados extend remove interface, add flags parameter, and use             this extended interface to implement force remove when cluster full. Signed-off-by: Xiaowei Chen <chen.xiaowei at h3c.com>
 9f34737 mailmap: YankunLi affiliation
 b3c28b9 mailmap: Nishtha Rai affiliation
 0828cb4 mailmap: John Coyle affiliation
@@ -106,19 +814,29 @@ e2cd81d mailmap: You Ji affiliation
 ea8ad14 mailmap: Sangdi Xu name normalization
 e9aa132 mailmap: Robin H. Johnson name normalization
 fee41ad mailmap: Guang Yang name normalization
+5890760 test: add test case for c++ osd/pg command
+5f7f806 librados: add osd/pg command interface for c++
+c6cdc33 tests: verify it is possible to reuse an OSD id
 e2f163a tests: fix failure for osd-scrub-snap.sh
 5876829 tests: kill_daemons uses TERM instead of KILL
 68125dd librbd: fix merge-diff for >2GB diff-files
 213cd78 rgw: fix a glaring syntax error
 2b50a75 Implementation of rados_ioctx_snapshot_rollback
+4671c02 Fix end of newlines
+ad47b41 CodingStyle: Fix coding-style on PG related Monitor files
 7f5ee33 librbd: fix test case race condition for journaling ops
 9162bd2 Revert "LifeCycle feature"
+82c40b6 signal_handler: added support for using reentrant strsignal() implementations vs. sys_siglist[]
 99bcc7c tests: --osd-scrub-load-threshold=2000 for more consistency
-26008e8 ceph-detect-init: Ubuntu >= 15.04 uses systemd
+26008e8 (origin/wip/debian-infernalis-patches) ceph-detect-init: Ubuntu >= 15.04 uses systemd
 93cdc98 pybind/rbd.pyx: misc typo bugfixes
+8fabcbb ceph-fuse:print usage information when no parameter specified
 469b55a pybind/rbd.pyx: PyString -> PyBytes
+50022d3 os: skip checking pg_meta object existance in FileStore pg_meta object in FileStore is actually a logical object without any significant information. All it data writes to omap (leveldb), and actually no competition condition for the real object in FileStore Based on the optimazation, we further reduce _omap_setkeys() execution time (123.784us to 108.444us, about 15%), and save cpu usage 0.5% globally
+1df9705 test/librbd/fsx: musl libc doesn't implement random_r. Use c++11 std::mt19937 generator instead.
 6f1fb16 doc: osd: s/schedued/scheduled/
-7d93cf4 buffer: make usable outside of ceph source again
+7d93cf4 (upstream/wip-buffer-header) buffer: make usable outside of ceph source again
+93d3dfe Fixing NULL pointer dereference
 72785ee rgw: enforce SLO part's ETag match during GET on SLO of Swift.
 1cf149d rgw: append X-Static-Large-Object attribute during PUT on SLO.
 630eac1 rgw: add support for normalisation of ranged SLO requests.
@@ -144,36 +862,53 @@ b665b04 rgw: add support for Bulk Delete API of Swift.
 b48f3d7 rgw: fix wrong length in Content-Range HTTP header of Swift's DLO.
 66f47f3 rgw: fix wrong first byte pos in Content-Range HTTP header of Swift's DLO.
 2945bef rgw: add support for putting Swift's X-Object-Manifest through POST.
+94be452 rgw: refactor arrangement of parameters for rgw_read_user_buckets().
+58addda rgw: add support for "end_marker" on listing Swift account.
 1b6a7e3 doc: note that cephfs auth stuff is new in jewel
 2c7c712 tests: osd-scrub-snaps.sh to display full osd logs on error
 71690e7 rbd: add --object-size option
 a69367d ceph-mds:add --help/-h
 07c334a doc:file must be empty when writing layout fields of file use "setfattr"
 247ee60 build/ops: enable CR in CentOS 7
+f9a230a test/osd: add test case for shutdown_when_flapping
 b47eeae tests: centos7 needs the Continuous Release (CR) Repository enabled for libunwind
 7d48f62 LifeCycle feature As same as amazon S3 interface,"PUT Bucket lifecycle" and "DELETE Bucket lifecycle" have been implemented, "GET Bucket lifecycle" not realized yet as S3cmd has not realize it also. The feature`s main point is to remove expire file per day. Files transfer from hot layer to cold layer is not supported. ToDo:Maybe to transfer from replicate pool to EC pool or from ssd to sata pool will be valuable.
+0565055 rgw: fix a typo in init-radosgw
 cd0c13b qa/workunits/cephtool/test.sh: false positive fail on /tmp/obj1.
 a80ff1f common/ceph_context.cc:fix order of initialisers
 0186cdc rgw:dont update entrypoint when removing bucket
 a828a4d osd: fix arithmetic exception when scrub_min_interval is small
 9d88f1a osd: more scrubber fields in pg query output
 15b2405 osd: use hexdump when logging CRC values
+794e518 msg/Dispatcher.h:removed unneeded includes
 9af8d6f qa/krbd: Expunge generic/247
+b04fc89 rgw: fix wrong checking for JSONParser::parse() return
 2eb0bf3 tests: make sure no segfault occurs when using some bad keyring
 f2f92c8 cmake: add TracepointProvider.cc to libcommon
 3e23e45 doc: Fixed incorrect name of a "List Multipart Upload Parts" Response Entity
+1d84219 mon/Monitor.cc: improve error handling
+bb4936a mon/Monitor.cc: attempt to decode and extract keyring only if it is found.
+08ae31c mon/ceph_mon.cc: fail on any error, not just empty magicbl
+3da96b9 mon/Monitor.cc: Reuse empty bufferlist
+f5a7a3b mon/MonitorDBStore: use single-key LevelDB::get() method
+1e6cda0 mon/AuthMonitor: don't crash on ENOENT
+eec4611 mon: remove unnecessary key existence check
 c83d6db cmake: update for recent rbd changes
 25c70cf Update Jiaying Ren affinity
 c11ca42 Update Rongze Zhu affinity
 593c124 doc: rst style fix for pools document
-e62954e deb,rpm: package buffer_fwd.h
+e62954e (upstream/wip-fix-buffer) deb,rpm: package buffer_fwd.h
+b23b92d AsyncConnection: Fix potential return code overflow
+3443b6d Pipe: Fix potential return code overflow
 1adf306 SubmittingPatches: there is no next; only jewel
+c5ff6f6 Pipe: Fix large message data content length causing overflow
 8160f9e Add common/PluginRegistry.cc to CMakeLists.txt
 c1daf4e doc/dev/index.rst: wholesale refactor
 a62b5ac pybind: support ioctx:exec
 7f81728 common/Makefile: ship common/event_socket.h
 c8f7d44 build/ops: systemd ceph-disk unit must not assume /bin/flock
 73aab5e test: use sequential journal_tid for object cacher test
+534bd2b test/librados: increase timeout in wait_for_healthy
 6cbf128 tests: wait for mocked requests to complete
 fde9f78 librbd: do not complete AIO callbacks within caller's thread context
 32597ca librbd: include missing header for bool type
@@ -190,15 +925,27 @@ ebadfef librbd: debug: log journal metadata
 e9317f0 SubProcess: fix multiple definition bug
 02a9a41 osd: Test osd_find_best_info_ignore_history_les config in another assert
 04b4795 test/librados/test.cc: clean up EC pools' crush rules too
+6c74381 test: fix linkage on rbd/journal tests
 6807b35 doc/dev/index.rst: fix links
 f336640 doc/dev/index.rst: Flesh out the IRC section
 8d281bc doc/dev/index.rst: Make Issue tracker a separate chapter
+6036145 osdc/Objecter: end of pg if next pointer is MAX, not 0 items
+532254a librados: C++ bindings for new object_list methods
+dbc489c librados: update naming for new object list methods
+d70d3c1 osdc/Objecter: direct enumerate request at hash, not pg
+5555f9f test: tests for new-style pgls
+8b7b23d test/librados: util to set pg_num
+c3524d7 librados: new style pgls
+138f584 osdc/Objecter: new-style pgls
+3ee7731 osd: set handle to start of next PG on pgnls end of pg
+fc8ea3f osd/osd_types: add pg_t::get_hobj_{start,end} methods
 91f01bd librbd: partial revert of commit 9b0e359
 4e15c03 pybind/rbd.pyx: Return something useful from str() and repr()
 6e7f9c8 doc/dev/index.rst: start writing Bugfixing chapter
 b328131 cmake: add rgw_basic_types.cc to librgw.a
 002d26b doc/dev/index.rst: rewrite introductory material
 e4218a2 KeyValueStore: Don't queue NULL context under test purpose
+341e3f9 osd: do evict after flush
 ba346bf qa: add a test for the recovery_priority/recovery_op_priority pool settings.
 f0cc722 mon: support recovery_priority and recovery_op_priority with monitor commands
 cd2bc41 Objecter: clean up Objecter.h/ObjectOperation
@@ -212,7 +959,7 @@ fb120d7 osd: call on_new_interval on newly split child PG
 60519e2 librbd: correct lock ordering issues discovered by lockdep
 1997144 doc: remove unnecessary period in headline
 2a0263f journal: correct lock ordering issues discovered by lockdep
-4230504 rgw: remove comments
+4230504 (upstream/wip-5073) rgw: remove comments
 eda44cd rgw: a minor cleanup
 bf0a7b4 rgw: don't re-set bucket tenant and name when selecting location
 ddb4caa rgw: fix a typo
@@ -221,7 +968,7 @@ e5bfd94 rgw: avoid calling rgw_make_bucket_entry_name() when not needed
 9425b04 rgw: objexp hint name backward compatibility
 e8de349 rgw: inherit bucket tenant from user if not specified
 acda806 rgw: add a missing cap type
-bc091ed pybind/rbd.pyx: only set self.closed after a successful close
+bc091ed (upstream/wip-cython-rbd) pybind/rbd.pyx: only set self.closed after a successful close
 d10c61a pybind/rbd.pyx: remove redundant RBD.__init__ method
 8931875 ceph.spec: Cython is spelled python-Cython in OpenSuSE
 07ae545 pybind: Improvements to Cython build
@@ -238,6 +985,9 @@ f8a9aef librbd: snap create doesn't properly handle race conditions
 835989c librbd: convert op state machines to templates
 5b63666 tests: add gmock unit tests for librbd object map state machines
 dfbcbc7 librbd: ensure object map is invalidated on disk if forced
+b89179a OSD: remove heartbeat_epoch which is redundant
+414252c PG: remove redundant statements
+b9c7e81 PG: perfect publish_stats tip message
 dc2b176 common: PluginRegistry modification
 5eb64dd common: PluginRegistry
 e8002c3 configure.ac: macro fix
@@ -246,6 +996,7 @@ c4fbec7 rgw: fix partial read mime map issue
 e04beab tools/cephfs: enable tag filter in DataScan
 9e71aba tools/cephfs: fix datascan kwarg parsing
 786d111 cls_cephfs: add PGLSCephFSFilter
+bef3cae OSD: fix wrongly placed assert
 9c266e5 common: re-enable backtrace support
 e20ef4b ceph_test_libcephfs: don't check order of dentries in readdir result
 8a80652 client: don't choose dirfrag when opendir
@@ -257,6 +1008,7 @@ bff706f cls/cls_rbd.cc: no need to skip key == after.
 685fc1c journal: fire replay complete event after reading last object
 f914b8d rgw: fix rgw_admin partial read issue
 61f61a2 osd: add recovery_priority and recovery_op_priority to pool_opts_t
+5ca41e1 ceph-disk: warn for prepare partitions with bad GUIDs
 13925c7 init-ceph.in: Allow custom cluster names during startup.
 708ec2b tests and tools/scratchtool: Don't attempt to use NULL xattr
 4ec0def librados.cc: rados_getxattrs_next: don't try to use malloc(0)
@@ -313,6 +1065,7 @@ d133f42 rbd: don't append an extra newline after some errors
 77aef0d rgw: remove unused variable in RGWPutMetadataBucket::execute.
 117e630 Correct typo 'restared' to 'restarted'
 691199b CodingStyle: fix broken URLs
+3ee2f6d os/LFNIndex: check object whether exist for remove_object.
 6b402f5 ceph::buffer, Add cached_crc and cached_crc_adjust count in perf dump in order to track the hit rate and efficiency of crc_cache
 bcb8f36 mon: support min_down_reporter conuted by subtree level
 43c1ba7 tools: fix cephfs-data-scan scan_frags vs. nlink
@@ -330,9 +1083,14 @@ e9e0533 auth: fix double PK11_DestroyContext() if PK11_DigestFinal() failed
 e6dcf14 osd: store per pool scrub intervals in pool options
 2b252d2 tests: workunits should not have ./ (assume it in $PATH)
 73077dd osd: pg_pool_t: add dictionary for pool options
+9a14ff7 osd/OSD.cc: shutdown after flapping certain times
 09c0d8d librbd: fix tracepoint parameter
 014e2f0 ceph.spec.in: use %tmpfiles_create macro
+da52b5e Workunits : fs/misc/: check if cache is used in direct IO
 8a9db37 test/encoding/readable.sh fix
+84db496 os/CollectionIndex: Change meaning of last parameter for lookup function.
+a0a424e os/FileStore: cleanup code for lfn_unlink.
+1813ef3 os/LNFIndex: Remove the dupicated code.
 f76d5d6 pybind: decode empty string in conf_parse_argv() correctly
 9331e03 test: use sequential journal_tid for object cacher test
 720ac2b EventSocket: Add EventSocket structure used for event notification
@@ -344,6 +1102,15 @@ f5e0cce osd: don't update rollback_info for replicated pool rollback_info is jus
 b96c7e6 aix shared library build
 3680dc3 mon/OSDMonitor: block 'ceph osd pg-temp ...' if update is pending
 7a8fd0e tools: add cephfs-table-tool 'take_inos'
+ac7c7b6 crush: add 'jewel' tunables
+043a737 crush: add CEPH_FEATURE_CRUSH_TUNABLES5
+a79a72f crush: add step set chooseleaf stable
+983d44f crush: add chooseleaf_stable tunable tooling, wrapper infrastructure
+fdb3f66 crush: add chooseleaf_stable tunable
+07dbd93 crush: optimal is hammer
+6c2a4e7 crushtool: add hammer test map (with straw2 buckets)
+528eae9 osd: recency should look at newest (not oldest) hitsets
+180c874 osd/ReplicatedPG: fix promotion recency logic
 9bd0b11 rgw: fix tenant/bucket parsing
 f7ca00a rgw: make APIs to work with tenants
 1f19b60 rgw: buckets within tenant namespace
@@ -363,7 +1130,7 @@ a4924d4 ceph.spec.in: add BuildRequires: systemd
 917d85f osbench: Adds handling for the lack of required folders ( data & journal ) and adds checking for previous data presence to avoid assertion
 2902030 osbench: Fix race condition that may cause Sequencer::dtor assertion on benchmark completion
 daae180 Doubled marking from line 1151
-ada6e32 osd: slightly reduce actual size of pg_log_entry_t
+ada6e32 (upstream/bp-smaller-pglog-2) osd: slightly reduce actual size of pg_log_entry_t
 d1c9bf6 journal: support replay passed skipped splay objects
 56100ef tests: verify that journal player can handle skipped journal objects
 1509ada mailmap: Jenkins affiliation
@@ -603,7 +1370,7 @@ ef011da Update .organizationmap
 0fd8de3 msg/async: support of non-block connect in async messenger
 f7f55e3 scrub: compare omap_digest with each other
 785e58e scrub: clarify the result report
-a3aa565 journal: avoid holding lock while marking ops are complete
+a3aa565 (upstream/wip-11287-rebased) journal: avoid holding lock while marking ops are complete
 4719696 cmake: updates for refactored librbd IO path
 10deea8 librbd: flush journal entries prior to releasing lock
 b515314 librbd: only erase IO events after they are marked safe
@@ -725,7 +1492,7 @@ d28698b osd: fix trivial bug
 f7f5a08 internal: remove unused local variables
 c8fe5ae librados: cast oid to object explicitly before call ioctx methods Cast oid to object explicitly before call ioctx methods. Signed-off-by: xie xingguo <xie.xingguo at zte.com.cn>
 e986ade IoCtxImpl: remove unused variable sName
-a5651b8 Revert 0374bb4a2f5054d606e4aba2d97b5e6765e781b0
+a5651b8 (upstream/revert-6419-wip-openssl) Revert 0374bb4a2f5054d606e4aba2d97b5e6765e781b0
 7496741 rgw: fix modification to index attrs when setting acls
 9689fe0 kv: fix string ctor usage
 bfeb90e librbd: fixed deadlock while attempting to flush AIO requests
@@ -748,6 +1515,7 @@ e184ca2 os/LevelDBStore: faster LevelDBTransactionImpl::set
 338b4ed osd/ReplicatedPG: use bl-based setkeys/rmkeys
 402d181 tests: fix test_rados_tools.sh rados lookup
 fad3772 client: use null snapc to check pool permission
+4580cf5 qa/workunits/snaps: move snap tests into fs sub-directory
 f33dd76 librbd: start perf counters after id is initialized
 db85bdd FileStore: support multiple ondisk finish and apply finisher
 26befe1 cls_rbd: change object_map_update to return 0 on success, add logging
@@ -827,11 +1595,12 @@ b0536eb librbd : fix enable objectmap feature issue
 6e87d23 doc/release-notes: final infernalis notes
 78c5b9a radosgw-admin: metadata list user should return an empty list when pool is empty
 e8fe4bc tests: concatenate test_rados_test_tool from src and qa
+8f7ca9e client: bypass objectcacher for direct IO
 da6825d test/test_rados_tool.sh: Add tests for the new bench's write options
 9259e6e tools/rados/rados.cc: Add options to choose the benchmark's write destination
 7524e16 tools/rados/rados.cc: Write to different destinations
 00c6fa9 Objecter: pool_op callback may hang forever.
-400b0f4 Build internal plugins and classes as modules
+400b0f4 (upstream/javacruft-wip-ec-modules, origin/wip/ec-modules) Build internal plugins and classes as modules
 d457fc2 mds: apply validate_disk_state to dirs too
 6ba5bef mds: tidy up cdir scrub_initialize in scrubstack
 1930083 mds: write scrub tag during validation
@@ -852,7 +1621,7 @@ f8b2fb9 mds: inode_t: add scrub stamp and version for latest complete scrub
 b789edd mdstypes: dentry_key_t: add an is_valid() function
 e09e548 mds: CDir: rearrange constructor
 c4f68b0 common/buffer.h: removed unneeded list destructor
-bb2ecea (tag: v9.2.0, origin/infernalis) 9.2.0
+bb2ecea (tag: v9.2.0) 9.2.0
 a77bfd0 mds: refactor availability check
 8f0d796 mds: don't use g_conf from MDSMap
 21f5af0 client: a better check for MDS availability
@@ -901,12 +1670,12 @@ b3f8d56 osd: reoder fields in ObjectRecoveryProgress struct
 bf3c30c osd: reorder and trim fields SnapSetContext
 e0fd540 rgw:swift use Civetweb ssl can not get right url
 b698a76 rgw: Fix typo in RGWHTTPClient::process error message
-173bfd0 rgw: link against system openssl (instead of dlopen at runtime)
+173bfd0 (origin/wip-openssl) rgw: link against system openssl (instead of dlopen at runtime)
 8160af6 tools: ceph-monstore-update-crush: add "--test" to crushtool
 83afe15 test: ceph-disk: coverage list_format_dev_plain() new behavior.
 6253aea FileJournal:_fdump wrongly returns if journal is currently unreadable.
 39fb7f1 messages/MOSDOp: Cast in assert to eliminate warnings
-3047b56 rgw: Add default quota config
+3047b56 (origin/wip-12997) rgw: Add default quota config
 570285b ceph-disk: get Nonetype when ceph-disk list with --format plain on single device.
 f22f4ac mailmap: Xie Xingguo affiliation
 93ec538 crush/mapper: ensure take bucket value is valid
@@ -945,7 +1714,7 @@ f4906a1 tests: ceph-disk workunit uses configobj
 163de5b tests: ceph-disk workunit uses the ceph task
 c4fdbdd cmake: Use uname instead of arch. arch is deprecated in linux-utils and coreutils does not install it by default.
 03e556b doc: Removed the NOTE section about non-LTS supported distributions
-58414c5 librbd: potential assertion failure during cache read
+58414c5 (origin/wip-13559-infernalis) librbd: potential assertion failure during cache read
 011e9e5 tests: reproduce crash during read-induced CoW
 2a6b90f doc/release-notes.rst: recovery isn't in the unified queue yet
 9bf21ee doc: Updated the OS recommendations for newer Ceph releases
@@ -990,9 +1759,12 @@ dc21d8e rgw: add explicit success/error paths in RGWGetObj::execute()
 3d2ed6f mailmap: Dennis Schafroth affiliation
 ffd4f2a mailmap: Daniel Gryniewicz affiliation
 16e90c5 mailmap: Bo Cai name normalization
+6482f00 test/librbd/fsx: Include fcntl.h for flag defs.
 7b2e9fc ceph.in: Remove unused variable
 113d727 ceph.in: Don't drop out of command mode on certain kinds of errors
 bb5bcab makefile: For ceph command generation don't append another copy of ceph.in
+d4869a6 (upstream/wip-13441) test: add test for pg list_missing on EC pool
+531dd77 osd: list_missing should query missing_loc.needs_recovery_map
 597c43e tracing: add tracepoints for cache pin/unpin
 4783899 osd: return ENOENT when object doesn't exist for cache pin/unpin
 59d0de7 test/tier: add test for cache_pin
@@ -1073,7 +1845,7 @@ b15c541 libcephfs: only check file offset on glibc platforms
 e4b8600 rgw: Handle x-amz-request-payer in pre-signed urls
 f9c44ef osd: drop the interim set from load_pgs()
 1fb9fc9 librbd: fix rebuild_object_map() when no object map exists
-fb62c78 ceph_context: remove unsafe cast for singletons
+fb62c78 (origin/wip-13274-infernalis) ceph_context: remove unsafe cast for singletons
 24740a7 client: drop prefix from int types
 65d0fc4 doc: fix outdated content in cache tier
 477bb06 ceph.spec.in: only run systemd-tmpfiles on ceph run directory
@@ -1094,7 +1866,7 @@ e26469e mailmap: Alexander Chuzhoy affiliation
 fee7144 rgw: fix response of delete expired objects
 2cf8d20 update radosgw-admin command
 4a3f375 vstart: set cephfs root uid/gid to caller
-7060a3b doc/infernalis: hate hate
+7060a3b (upstream/loic-infernalis, origin/loic-infernalis) doc/infernalis: hate hate
 e6a9e62 doc/release-notes: i hate rst
 e98408d doc/release-notes: final infernalis notes
 b105449 doc/release-notes: fix some attributions
@@ -1102,7 +1874,7 @@ e9f200c doc/release-notes: infernalis notable changes
 638738f Revert "common, global: use lttng ust functions for handling fork-like calls"
 fca97db rgw, doc: remove remark for lack of custom account metadata of Swift.
 b4c5620 doc: remove toctree items under Create CephFS
-3be81ae 9.1.0
+3be81ae (tag: v9.1.0) 9.1.0
 036d36f debian/control: python-setuptools is a build dependency
 8e59595 doc/release-notes: 9.1.0
 1deb31d Init crush_location in Objecter from config file.
@@ -1165,7 +1937,7 @@ d258bf5 ceph.spec.in: drop MY_CONF_OPTS
 e675400 librbd: invalidate object map on error even w/o holding lock
 bc48ef0 selinux: Fix man page location
 378d56d man/Makefile-server.am: conditionalize make ceph_selinux manpage
-fb50ff6 mon: do not remove proxied sessions
+fb50ff6 (upstream/wip-13379, origin/wip-13379) mon: do not remove proxied sessions
 0d1cab4 test: add TestSessionFilter
 be3c4a8 mds: implement filtered "session ls" tell command
 47a1816 mds: call through to MDSRank in handle_command
@@ -1332,14 +2104,14 @@ a965378 ReplicatedPG: clearing a whiteout should create the object
 47f4a03 ceph-objectstore-tool: delete ObjectStore::Sequencer after umount
 f20f67e pybind/cephfs: fix DirEntry helpers
 7b1882f ceph.spec.in: correctly declare systemd dependency for SLE/openSUSE
-3f00042 rgw: set default value for env->get() call
+3f00042 (upstream/wip-13239-infernalis, origin/wip-13239-infernalis) rgw: set default value for env->get() call
 469d35f osd: init started to 0
 bba3ab3 mon: combine _ms_dispatch and dispatch
 612480b test/test_rados_tool.sh: implement regression test for bench verify crash
 0c8faf7 common/obj_bencher.cc: fix verification crashing when there's no objects
 e42c9aa ceph.spec.in: re-re-drop fdupes
 566c872 os/fs: fix aio submit method
-d7b620f ECBackend::handle_recovery_read_complete: do not expose the hash_info when getting the obc
+d7b620f (origin/wip-12983) ECBackend::handle_recovery_read_complete: do not expose the hash_info when getting the obc
 892800b ECBackend::handle_sub_read: restructure hash check and fix part of 12983
 80b7237 qa/workunits/cephtool/test.sh: don't assume crash_replay_interval=45
 c5a9275 osd/ReplicatedPG: preserve (some) flags when proxying reads
@@ -1368,7 +2140,7 @@ bf7e937 osdc/Objecter: set FULL_FORCE flag when honor_full is false
 95055e7 osd: add FULL_TRY and FULL_FORCE rados op flags
 7757342 qa: https://ceph.com/git -> https://git.ceph.com
 d4d65fb qa: http://ceph.com/qa -> http://download.ceph.com/qa
-cdccf11 osd/PG: compensate for sloppy hobject scrub bounds from hammer
+cdccf11 (upstream/wip-scrub-fix, origin/wip-scrub-fix) osd/PG: compensate for sloppy hobject scrub bounds from hammer
 acda626 osd: avoid duplicate MMonGetOSDMap requests
 f4bf14d Update Xinze affinity
 eb28eef Update Chen Min affinity
@@ -1563,10 +2335,11 @@ af39f98 .gitignore: ignore src/ceph.tmpe
 c57e868 rocksdb: ignore m4
 51abff1 ceph.spec: respect CEPH_EXTRA_CONFIGURE_ARGS
 4a5a5b3 qa/workunits/cephtool/test.sh: make mds epoch check more tolerant
-d33fea5 sd/PG: tolerate missing pgmeta object
+d33fea5 (upstream/wip-10617-again, origin/wip-10617-again) sd/PG: tolerate missing pgmeta object
 f15d958 osd: allow peek_map_epoch to return an error
 ff9600a osd/ReplicatedPG: remove stray debug line
 6e85433 AsyncMessenger: Kepp file_lock hold when accessing its event field
+f3f4141 doc: Updated the rados command man page to include the --run-name option under the bench sub-command
 4dea76e ceph.spec: include /etc/sysconfig/ceph
 8657081 doc: remove references to default data/metadata pools
 c3d23ca ceph-common: explicitly trigger /run/ceph creation
@@ -1652,8 +2425,8 @@ d5650c9 tests: new test case for librbd diff_iterate over discard extents
 d32a3be qa/workunits/rados/test_alloc_hint.sh: sudo to ls files
 ab4232b rgw: init_rados failed leads to repeated delete
 e48cec3 mon: disable gmt_hitset if not supported
-02f4461 test: mon: mon-scrub.sh: test 'mon scrub'
-8c2dfad osd: force promote for ops which ec base pool can't handle
+02f4461 (upstream/wip-leveldb-hang, origin/wip-leveldb-hang) test: mon: mon-scrub.sh: test 'mon scrub'
+8c2dfad (upstream/wonzhq-tmap-update, origin/wonzhq-tmap-update) osd: force promote for ops which ec base pool can't handle
 8c4323c PerfCounter: Make l_os_queue_lat contains the complete queue latency
 834842c OSD: Add perf counter to count osd thread prepare latency
 70d3108 mon: MonitorDBStore: make get_next_key() work properly
@@ -1670,7 +2443,7 @@ e6fbe53 improve error handle of rbd metadata operation & format output
 bfe359a osd: dump full map bl at 20 when crc doesn't match
 351d957 doc: fix the typo in command example
 7080e0f Thread.h: disable copy constr and assignment op
-7d781f7 doc: 'ceph --admin-daemon ...' -> 'ceph daemon ...'
+7d781f7 (upstream/wip-12966, origin/wip-12966) doc: 'ceph --admin-daemon ...' -> 'ceph daemon ...'
 404dd16 tests: base gmock class support for librbd
 e8749b2 librbd: support templating of ImageCtx for async state machines
 1c522be ceph.spec.in: put distro conditional around Group:
@@ -1725,11 +2498,11 @@ af8b3da Messenger: Make fast dispatch message set dispatch timestamp
 929ca5b ceph.spec.in: drop lsb-release dependency from ceph-common
 557e581   mon/MonClient: fix error in 'ceph ping mon.id'   Fixes: #12442
 f65267c rgw : setting max number of buckets for users via ceph.conf option
-64962aa qa/workunits/rados/test_alloc_hint.sh: sudo to list files
+64962aa (upstream/wip-5785, origin/wip-5785) qa/workunits/rados/test_alloc_hint.sh: sudo to list files
 75d9f58 osd/ReplicatedPG: use apply_ctx_stats() everywhere
 eb2993a osd/ReplicatedPG: create apply_ctx_stats() helper
 9bf103c osd/ReplicatedPG: snaptimmer: adjust stats through ctx->delta_stats
-3626db4 rgw: don't copy delete_at attr, unless it's intra region copy
+3626db4 (origin/wip-rgw-swift-expiration) rgw: don't copy delete_at attr, unless it's intra region copy
 a69a989 rgw: objexp shards index by key
 fa347d8 rgw: delete-at and delete-after also on obj put / copy
 14c400f add test for python binding
@@ -1748,7 +2521,7 @@ c938d1f rocksdb: fix 32-bit build
 67f5f52 memstore: fix the build on i386
 89aacaf doc: add the doc for min_write_recency_for_promote
 b02cc06 AsyncConnection: Don't use unsafe feature as message encode feature
-7bfb7f9 librbd: do write_full for whole object write
+7bfb7f9 (upstream/wonzhq-rbd-write-full, origin/wonzhq-rbd-write-full) librbd: do write_full for whole object write
 b199c49 ceph-osd-prestart.sh: fix osd data dir ownership check
 023c517 vstart.sh: enable all experimental features for vstart
 3a41ef4 ms/async: log message tx/rx at level 1
@@ -2037,7 +2810,7 @@ f2f23c2 rgw: implement object_is_expired function.
 aa5f1b8 rgw: a few fixes, guard bufferlist decodes
 4f9a843 rgw: add basic support for X-Delete-At header of Swift API.
 2bc5a48 osd: Decode use_gmt_hitset with a unique version
-38465f0 osd: refuse to boot if any pre-hammer or old hammer (<v0.94.4) are running
+38465f0 (upstream/liewegas-wip-hammer-feature, origin/liewegas-wip-hammer-feature) osd: refuse to boot if any pre-hammer or old hammer (<v0.94.4) are running
 f668c6c mon: use HAMMER_0_94_4 feature to require sufficiently new hammer
 470f970 include/ceph_features: define HAMMER_0_94_4 feature
 14e02bc PG::handle_advance_map: on_pool_change after handling the map change
@@ -2112,7 +2885,7 @@ b0882fb memstore: replace apply_lock with sequencer
 5d8307a memstore: add Object interface to hide bufferlist
 26f716e memstore: use intrusive_ptr instead of shared_ptr
 01a9a79 osbench: add multithreaded objectstore benchmark
-d7bf8cb rgw: init some manifest fields when handling explicit objs
+d7bf8cb (upstream/wip-11455, origin/wip-11455) rgw: init some manifest fields when handling explicit objs
 b610588 ceph.spec.in: remove obsolete SUSE-specific code
 df21a6e osd: expose PGLSFilter in objclass interface
 c318129 ceph.spec.in: Restart services only if they are running
@@ -2124,7 +2897,7 @@ fb1b6dd common: fix insert empty ptr when bufferlist rebuild
 347ac0f ceph_test_rados_api_tier: make PromoteOn2ndRead tolerate thrashing
 8a08acc common/hobject_t: fix is_temp() off-by-one
 7cc8d86 ceph_test_msgr: parse CEPH_ARGS
-dfd142f include/inline_memcpy: use __builtin_memcpy instead of explicit ptr copies
+dfd142f (upstream/wip-memcpy, origin/wip-memcpy) include/inline_memcpy: use __builtin_memcpy instead of explicit ptr copies
 98c0606 include/inline_memcpy: make prototype resemble memcpy's
 fc02a8a added boost timegm impl for cross platform support
 da6d5cf osd: bug fix hit_set_map size for tier pool
@@ -2163,7 +2936,7 @@ ea8609b mon/OSDMonitor: debug why pool creation fails
 88bfd79 test/erasure-code: drop directory from profile
 5df1271 do not include directory in ec profiles
 660ae5b osd: always load erasure plugins from the configured directory
-7295612 9.0.3
+7295612 (tag: v9.0.3, upstream/loic-v9.0.3, upstream/last, origin/loic-v9.0.3, origin/last) 9.0.3
 271513f erasure-code: shec plugin feature
 5e99a57 mon: add a cache layer over MonitorDBStore
 2d13a47 rbd: fix the FTBFS on old boost introduced by 2050d08
@@ -2254,7 +3027,7 @@ aa50321 cmake: add DiffIterate.cc to librbd
 de0b66a test: add test for the perf counter of CephContext
 5d109e9 common: support perf counter (for unhealthy workers) on CephContext
 5fa03e9 osd: expose the number of unhealthy threads from heartbeat map
-9b23392 ReplicatedPG::cancel_pull: also finish_degraded_object
+9b23392 (origin/wip-sam-working) ReplicatedPG::cancel_pull: also finish_degraded_object
 79f310a ReplicatedPG: treat object as degraded until on_global_recover
 5390072 ReplicatedPG: block writes on promote of rollback snap promotion
 35af63b ReplicatedPG: enforce write ordering on rollback
@@ -2308,7 +3081,7 @@ c8a83cd client: track flush TIDs for all pending flushing caps
 d742e79 tests: Add unit tests for CLS numops class
 d17f158 cls_numops: Add cls_numops client
 87f6b73 Add new cls_numops class for numeric operations
-0ba2e14 Revert "osd/ReplicatedPG: snapset is not persisted"
+0ba2e14 (upstream/revert-4927-snapset-obc, origin/revert-4927-snapset-obc) Revert "osd/ReplicatedPG: snapset is not persisted"
 b18558b osd/OSDMap: test_flag returns bool
 3540fb9 osdc/Objecter: restart listing this PG if sort order changes
 35c1970 osd/ReplicatedPG: fix missing set sort order on [N]PGLS
@@ -2316,7 +3089,7 @@ fc61fd7 osd/osd_types: add pg_missing_t::resort() method
 517921f osd/osd_types: make pg_missing_t sort order dynamic
 a5e27de osd: refuse to boot if SORTBITWISE not set but backend cannot sort nibblewise
 97c66e3 erasure-code: Update ISA-L to 2.14
-0bb57f1 configure: Fix checking for yasm compability
+0bb57f10 configure: Fix checking for yasm compability
 2743cc4 java: add libcommon to deps
 5afa21d java: search for JNI bits in common dirs
 af0ebee rbd:improve the error handle of rbd,check the return value.
@@ -2351,7 +3124,7 @@ d33ad15 Adding statfs api to KeyValueDB
 d57d36d osd: add flush/evict mode in pg stats
 af2a38b mon: fix the output of cache_io_rate_summary
 b78883b tests: be more generous with mon tests timeouts
-7e6f819 doc: update rgw configuration on multiple rgw rados handlers feature
+7e6f819 (upstream/wip-5072, origin/wip-5072) doc: update rgw configuration on multiple rgw rados handlers feature
 efc8969 Doc: Correcting the default number of copies.
 6f768a7 doc: Removed reference to RAID-4
 c6cf558 CMake: cut down unnecessary linkage on rados tests
@@ -2501,6 +3274,7 @@ cd4ac1c rbd: support size suffixes for size-based options
 d1735a4 rgw: rework X-Trans-Id header to be conform with Swift API.
 278a6ae qa: add fs layout case for stripe_size decrease
 880ffe9 mds: fix setting whole layout in one vxattr
+b34363a cleanup: fix the eol dumping in JSONFormatter flush & close_section
 1559d5e cmake: add global lib to rbd
 6b29233 mds: initialize InodeStoreBase::damage_flags
 5d7cb4c ceph-dencoder: add RGWRegion, RGWZoneParams, RGWOLHInfo support.
@@ -2544,7 +3318,7 @@ f68553e osd/osd_types.cc: get rid of str concat when making hash key
 111ecf8 radosgw-admin: use cout not cerr to print help message.
 145364b logrotate: fix log rotation with systemd
 85cb86d doc: change "--keyfile" description in man page of rbd help
-1ca6bf6 common/hobject_t: correctly decode pre-infernalis hobject_t min
+1ca6bf6 (upstream/wip-12536, origin/wip-12536) common/hobject_t: correctly decode pre-infernalis hobject_t min
 bc0d942 CMake: add crushtool
 fe970bc CMake: fix librados build
 2355c45 CMake: fix rbd build
@@ -2628,7 +3402,7 @@ cb51b17 mon: reject over-large values of max_mds
 258cb34 rbd: add "--keyring" option to help message
 5c395ff doc: add bucket object version description. bucket object version has been supported, but do not have description in the docs, so add this part.
 6ab9efe osd: copy the RecoveryCtx::handle when creating a new RecoveryCtx instance from another one
-1320e29 OSDMonitor::preprocess_get_osdmap: send the last map as well
+1320e29 (upstream/wip-12410, origin/wip-12410) OSDMonitor::preprocess_get_osdmap: send the last map as well
 f217865 test_librbd_fsx: invalidate before discard in krbd mode
 c4872dd Log::reopen_log_file: take m_flush_mutex
 0559fd3 tools/rados: change the first op id to 0
@@ -2679,7 +3453,7 @@ bbc5c71 rbd: import doesn't require image-spec arg, ditto for export and path
 0d2467a Compressor: Remove thread affinity options
 3482e68 AsyncConnection: Exit process loop if entering fault
 554c982 test/perf_local: disable tests on unsupported archs
-8778ab3 Log::reopen_log_file: take m_flush_mutex
+8778ab3 (upstream/wip-12465, origin/wip-12465) Log::reopen_log_file: take m_flush_mutex
 6f54c61 debian: Update maintainers and uploaders
 824c541   common: add nested-name-specifier ThreadPool before WorkQueueVal   Fixes: #12459
 992d959 mds: fix val used in inode->last_journaled
@@ -2908,7 +3682,7 @@ a063de1 mailmap: Dmitry Yatsushkevich name normalization
 2ff6bcf erasure code: shec performance optimization with SIMD instructions
 6e0498d MonitorDBStore : make monitor transaction more readable on dump
 da96a89 librados: Make librados pool_create respect default_crush_ruleset
-be422c8 9.0.2
+be422c8 (tag: v9.0.2) 9.0.2
 bbf5842 AsyncConnection: Make sign_message ahead of construct message bufferlist
 8bbe98a AsyncConnection: Fix non-fastdispatch message doesn't prepare case
 b7e9fe1 extend clone test to mock clone operation
@@ -3042,7 +3816,7 @@ e819a3c client: return EINVAL if iovcnt < 0 for p{read,write}v()
 db16353 mds: change mds_log_max_segments type from int to unsigned.
 8a91daa mds: fix mds crash when mds_max_log_events smaller.
 5614ec6 tests: fix segfault issue in preadv/pwritev tests
-7cf1f37 rgw: api adjustment following a rebase
+7cf1f37 (origin/wip-rgw-orphans-2) rgw: api adjustment following a rebase
 47edec3 rgw: orphans, fix check on number of shards
 5528f21 rgw: orphans, change default number of shards
 cac57ca rgw: change error output related to orphans
@@ -3250,7 +4024,7 @@ adfa2e0 librbd: flush operations need to acquire owner lock
 d3bd27f rgw: fix reset_loc()
 9298f93 mon/OSDMonitor: fix get_bucket_utilization return value
 e41d97c rgw: fix assignment of copy obj attributes
-4030774 mon: only send MMonMetadata to peer mons that support it
+4030774 (upstream/wip-12064, origin/wip-12064) mon: only send MMonMetadata to peer mons that support it
 54a516f configure.ac: Fix JUnit 4 detection on Fedora 22.
 7fbac49 doc: Change the type of list in doc Fixes: #12061. Signed-off-by: Maxime ROBERT <maxime.robert1992 at gmail.com>
 05c56b7 doc: ceph-deploy man page: typo #12063 Replace is initial monitor hostname with is the initial monitor hostname Fixes : #12063 Signed-off-by: CARADANT Kevin <kevin.caradant at gmail.com>
@@ -3371,7 +4145,7 @@ e1cb7e5 ceph.spec.in: move specific BuildRequires to where they belong
 37f7360 erasure-code: implement ErasureCode::sanity_check_k
 a8351eb unittest_crush_wrapper: attach buckets to root in adjust_item_weight test
 14c60b2 unittest_crush_wrapper: parse env
-997b3f9 9.0.1
+997b3f9 (tag: v9.0.1) 9.0.1
 d9dd5c5 librbd: don't cancel request lock early
 f97ce46 tests: new test for transitioning exclusive lock
 d2a1c22 tests: verify that librbd will periodically resend lock request
@@ -3590,7 +4364,7 @@ aa62dcb osdmaptool: dump 'osd tree' in specified format
 acdfd98 doc: fix typo in placement-groups.rst
 9c8f8d2 doc: fix a wrong quote in release.rst
 2cc7aee mon: MonitorDBStore: get_next_key() only if prefix matches
-2934909 mon: Monitor: allow updating scrub interval on demand
+2934909 (upstream/wip-mon-scrub, origin/wip-mon-scrub) mon: Monitor: allow updating scrub interval on demand
 e77b3f4 mon: Monitor: allow scrub to timeout after a while
 80ce9b0 mon: Monitor: inject missing key failures during scrub
 ba4a2c1 mon: Monitor: inject scrub failures
@@ -3713,7 +4487,7 @@ b2cd80c os/chain_xattr: s/ENODATA/ENOATTR/
 c6cdb40 os/chain_xattr: stripe shortish xattrs over small chunks for XFS
 8614dce os/chain_xattr: handle read on chnk-aligned xattr
 584ed2e ceph.spec.in: SUSE/openSUSE builds need libbz2-devel
-11b7801 OSDMonitor: disallow ec pools as tiers
+11b7801 (origin/wip-11493) OSDMonitor: disallow ec pools as tiers
 13c0fca src/test/librados/tier.cc: remove OmapOperation test
 363d957 ceph.spec.in: tweak ceph-common for SUSE/openSUSE
 46404dd ceph.spec.in: consolidate centos/rhel macros
@@ -3726,7 +4500,7 @@ f11de85 mds: fix handle_mds_map in standby_replay
 c199b7b KeyValueStore: Initialize the iterator
 ab30ff2 KeyValueStore: optimize the object header writes
 a46b333 do not return non-exist extents when doing sparse read
-389ae67 rgw: merge manifests correctly when there's prefix override
+389ae67 (upstream/wip-11622, origin/wip-11622) rgw: merge manifests correctly when there's prefix override
 9d8c115 init-radosgw.sysv: remove
 1c45f51 init-radosgw: unify init-radosgw[.sysv]
 a4bb992 init-radosgw: look in /var/lib/ceph/radosgw
@@ -3861,7 +4635,7 @@ e9300cb mailmap: Sergey Arkhipov affiliation
 f76bf6c mailmap: Xingyi Wu affiliation
 0f44127 mailmap: Ning Yao affiliation
 95a881f mailmap: Joao Eduardo Luis affiliation
-2738d02 ECBackend: eliminate transaction append, ECSubWrite copy
+2738d02 (upstream/wip-txn-noappend-sam-rebased, origin/wip-txn-noappend-sam-rebased) ECBackend: eliminate transaction append, ECSubWrite copy
 3699a73 mon: fix the FTBFS
 07cf4f7 doc: release notes for hammer v0.94.2
 e1f1c56 mon/PGMap: add more constness
@@ -3983,7 +4757,7 @@ fb484b6 mds: only add head dentry to bloom filter
 c26b21f AsyncConnection: Don't dispatch event when connection is stopped
 63eb432 librbd: don't notify_change on error when notify async complete
 9da4c45 doc: link to sepia report for lab info
-bd79891 9.0.0
+bd79891 (tag: v9.0.0) 9.0.0
 156e55b man: do not dist man pages if sphinx is not available
 f76293c test_async_driver: add dispatch_external_event tests
 c107b8e configure.ac: do not check for sphinx-build
@@ -4013,7 +4787,7 @@ a0f96de mds: in damaged() call flush_log before ending
 8803776 mon: add MonClient::flush_log
 a5e88fc librbd: invoking RBD::open twice will leak memory
 585bc2b mds: send FLUSHSNAP_ACK even if FLUSHSNAP message is unexpected
-fbfd50d OSD: handle the case where we resurrected an old, deleted pg
+fbfd50d (upstream/wip-11429, origin/wip-11429) OSD: handle the case where we resurrected an old, deleted pg
 32b8bf5 test: update CMakefile to sync with c44f8e7
 b7f4328 systest_runnable: adjust argument to suite Preforker
 9699246 mds: handle missing mydir dirfrag
@@ -4064,7 +4838,7 @@ d62f80d common/config: detect overflow of int values
 ab51130 Event: Delete driver after cleanup
 caa9f0e rgw: fix ListParts response
 04b0002 qa/workunits/post-file: pick a dir that's readable by world
-999dcc8 Revert "osd: For object op, first check object whether unfound."
+999dcc8 (upstream/wip-11464, origin/wip-11464) Revert "osd: For object op, first check object whether unfound."
 8e20240 librbd: TaskFinisher should finish all queued tasks
 ea5107c librbd: librados completions are not properly released
 ed5472a tests: fix valgrind errors with librbd unit test
@@ -4086,7 +4860,7 @@ fd7723a librbd: update ref count when queueing AioCompletion
 f141e02 librbd: flatten should return -EROFS if image is read-only
 594a661 librbd: allow snapshots to be created when snapshot is active
 32c41f8 cls_rbd: get_features needs to support legacy negative tests
-e97fd50 rgw: simplify content length handling
+e97fd50 (upstream/wip-rgw-content-length, origin/wip-rgw-content-length) rgw: simplify content length handling
 79d17af rgw: make compatability deconfliction optional.
 06d67d9 rgw_admin: add --remove-bad flag to bucket check
 8a7e58e AsyncMessenger: Don't need to join thread if not started
@@ -4338,7 +5112,7 @@ e3d62a9 common: make rados bench return correctly errno.
 0498b6a mds: add perf counters descriptions
 8ff8c57 doc/release-notes: note about SHEC
 1cc0181 doc: Corrects rgw.conf file path for Debian-based and RPM-based distros in radosgw man page.
-fb51175 TestCase: Change in testcase output
+fb51175 (upstream/wip-2862, origin/wip-2862) TestCase: Change in testcase output
 b15f6d0  Fix to some of the command line parsing (including rbd)
 b0172d8 rbd: create command throws inappropriate error messages
 d1cb94f RBD: update expunge set for latest test, parameterize test script
@@ -4359,7 +5133,7 @@ e34d31b osd: be slightly paranoid about value of okseed
 546d1c7 osd: be precise about "known" vs "best guess"
 c39e0e5 osd: record digest if object is clean (vs entire scrub chunk)
 1cf27ae doc/release-notes: make a note about rgw deployment; tweak dedication
-e61c4f0 0.94
+e61c4f0 (tag: v0.94) 0.94
 4651597 librbd: simplify AioRequest constructor parameters
 1926bb9 man: enable warning msgs for "all" target
 251ae61 doc: ref 9/ceph-mon using relative path
@@ -4518,7 +5292,7 @@ c4d8e65 Librbd: Add existing rbd configs to aware table
 cf715bd Librbd: Add tests for aware metadata config
 ccdeaf8 mds: fix out-of-order messages
 364e15b Librbd: Add basic metadata aware method
-59aa670 erasure-code: Update ISA-L to 2.13
+59aa670 (upstream/zhouyuan/isal_2.13, origin/zhouyuan/isal_2.13) erasure-code: Update ISA-L to 2.13
 ad15f7d osdc/Striper.cc fix stripe_count == 1 && stripe_unit != object_size
 eaf6e0c Always provide summary for non-healthy cluster.
 c6f1c07 Conditional-compile against minimal tcmalloc.
@@ -4544,7 +5318,7 @@ f9b98c9 ceph-objectstore-tool: Fix message and make it debug only to stderr
 d6acc6a Doc: Incomplete example in erasure-coded-pool.rst
 90c38b5 rocksdb: fix 32-bit build
 ddad2d4 Makefile-rocksdb.am: update for latest rocks
-c176ebf osd/: Move ReplicatedBackend methods into ReplicatedBackend.cc
+c176ebf (upstream/wip-move-code, origin/wip-move-code) osd/: Move ReplicatedBackend methods into ReplicatedBackend.cc
 e9d6096 ReplicatedPG: remove unused C_OnPushCommit
 6413209 mds: include damaged in MDSMap::dump
 3b2a091 mds: update peer failure response to account for damaged
@@ -4806,7 +5580,7 @@ d9ea168 Some sanitization work on .mailmap, .organizationmap, .peoplemap : Sorti
 90a0393 PendingReleaseNotes: warn about lttng LD_PRELOAD for daemons
 53cc492 ceph_test_rados_tier: add test case for delete+create compound ops
 c0e6227 mds: give up replicas of a stopping mds's stuff
-d47e622 doc/rados/operations/add-or-rm-mons: revise doc a bit to be less confusing
+d47e622 (upstream/wip-mon-doc, origin/wip-mon-doc) doc/rados/operations/add-or-rm-mons: revise doc a bit to be less confusing
 8a05092 debian: move /var/lib/ceph/mds to ceph-mds package
 353a325 ceph.spec.in: rm EOL Fedoras; add OBS RHEL5 instead
 703ba37 librbd: acquire cache_lock before refreshing parent
@@ -5100,7 +5874,7 @@ bc638cf doc/release-notes: fix typo
 3e03b2f doc/release-notes: v0.93 release notes
 1584104 librbd: moved flush / cache invalidate to resize state machine
 9fed4b9 librbd: add AIO version of invalidate_cache
-bebf8e9 0.93
+bebf8e9 (tag: v0.93) 0.93
 6f31458 Add GPLv2 text file
 fd0c612 rgw: enforce Content-Length in response for POST on Swift cont/obj.
 ea384f8 rgw: generate the "Date" HTTP header for civetweb.
@@ -5264,7 +6038,7 @@ d6e2689 PG: compensate for bug 10780 on older peers
 1d0d3dc PG: add a config option to enable (by default) recovery below min_size
 08eb584 librbd: fixed ImageWatcher recursive locking issues
 cd708e2 erasure code: add shec's documentation / change default layout
-21e7b5e mailmap: add Matt Richards to organizationmap
+21e7b5e5 mailmap: add Matt Richards to organizationmap
 849de71 mailmap: add Xie Rui to organizationmap
 48466f8 ReplicatedPG: only allow a degraded write if we have at least min_size copies
 d05539e ECBackend: use tbl for empty transaction as well if necessary
@@ -5489,7 +6263,7 @@ adebf22 rbd_recover_tool: move rbd_recover_tool directory to src/tools subdirect
 2f49de5 ReplicatedPG: block writes on degraded objects unless all peers support it
 2a83ef3 include/encoding: fix an compile warning
 71c6d98 msg: fixup for 2ffacbe (crc configuration in messenger)
-2598fc5 ObjectStore: fix Transaction encoding version number
+2598fc5 (upstream/wip-10734, origin/wip-10734) ObjectStore: fix Transaction encoding version number
 46f9ca4 pybind: fixed runtime errors with librbdpy
 9124a76 test/vstart_wrapper.sh: set PATH before calling vstart.sh
 189ef38 init-ceph.in: add $PWD to PATH if running as ./init-ceph
@@ -5568,13 +6342,13 @@ e0f12d9 Fix do_autogen.sh so that -L is allowed
 cfab01e rgw: move perf cleanup before context cleanup
 4074a91 pybind: fix error hiding and inconsistency on librados load.
 cfcfafc Objecter::_op_submit_with_budget: add timeout before call
-00a3ac3 0.92
+00a3ac3 (tag: v0.92, upstream/wip-sam-v0.92, origin/wip-sam-v0.92) 0.92
 c656bce PGLog: improve PGLog::check() debugging
 05ce2aa qa: use correct binary path on rpm-based systems
 eb526af rbd: watch command should unwatch before exiting
 2a0e9b7 encoding: ignore uninitialized instantiation in boost::optional decode
 f40ee8c do_autogen.sh: default to --with-lttng, -L to build without
-7590387 librados: add missing tracepoints
+7590387 (upstream/wip-assert-version, origin/wip-assert-version) librados: add missing tracepoints
 57bac8e osd:  change pg_stat plain to display CRUSH_ITEM_NONE in pgmap output section.
 4aa9f3f man: add rbd status to doc/man/8/rbd.rst
 a007c52 doc: add cephfs disaster recovery guidance
@@ -5638,7 +6412,7 @@ fc76c89 osdc: add new filed dontneed in BufferHead.
 c83a288 Rework ceph-disk to allow LUKS for encrypted partitions
 707c78b Only create a key of 256 bits length, not 256 bytes
 6a45b8e add all possible ceph-disk run-time requirements to build time deps
-4c50f6a rgw: more merge related fixes
+4c50f6a (upstream/wip-rgw-versioning-4, origin/wip-rgw-versioning-4) rgw: more merge related fixes
 01cc9d5 rgw: fix merge artifact
 e26023e PG: set scrubber.start = scrubber.end after scrub_compare_maps
 4f9e6ed PG: remove block_writes from scrubber
@@ -5695,7 +6469,7 @@ c4a6eab rgw: fixing rebase casualties
 b6d6f90 mon/MDSMonitor: fix gid/rank/state parsing
 9b9a682 msg/Pipe: set dscp as CS6 for heartbeat socket
 1e236a3 mds: don't join on thread which has not been runned.
-6939e8c Update git submodule to use the same https protocol
+6939e8c (upstream/zhouyuan-submodule_https_git, origin/zhouyuan-submodule_https_git) Update git submodule to use the same https protocol
 e393810 librbd: make librbd cache send read op with fadvise_flags.
 a23676b librbd: Don't do readahead for random read.
 8d0295c rgw: extend replica log api (purge-all)
@@ -5733,7 +6507,7 @@ e6f1280 librados: Expose RadosClient instance id through librados
 87ef462 rgw: format mtime of radosgw-admin bucket stats
 dc1630e librbd: trim would not complete if exclusive lock is lost
 3347e0d bug: error when installing ceph dependencies with install-deps.sh
-4e90a31 osd: add failure injection on pg removals
+4e90a31 (upstream/wip-10617, origin/wip-10617) osd: add failure injection on pg removals
 9b220bd ceph.spec.in: use wildcards to capture man pages
 51e3ffa rgw: reorder bucket cleanup on bucket overwrite
 313d6a5 rgw: access appropriate shard on bi_get(), bi_put()
@@ -5797,7 +6571,7 @@ b04f698 Doc: Fix the extra blank space in doc/start/quick-rbd.rst
 9ad9ba8 doc: Fix a typo in radosgw-admin doc
 008698b doc: Change Availability text in all of the man pages
 6f44f7a Revert "Revert "Merge remote-tracking branch 'origin/wip-bi-sharding-3' into next""
-90a90bb rgw: set default value for swift versioning extension
+90a90bb (upstream/wip-rgw-versioning-3, origin/wip-rgw-versioning-3) rgw: set default value for swift versioning extension
 dc11ef1 PGBackend: fix and clarify be_select_auth_object
 26656e3 rgw: fix bucket removal with data purge
 b18b14b ObjectStore::_update_op: treat CLONERANGE2 like CLONE
@@ -6048,7 +6822,7 @@ b383b52 rgw: enable s3 get/set versioning ops
 0d97b40 rgw: get bucket versioning status op
 8ed79d6 rgw: add versioning_enabled field to bucket info
 50547dc mon: PGMonitor: fix division by zero on stats dump
-dbaa142 rgw: bilog marker related fixes
+dbaa142 (upstream/wip-bi-sharding-3, origin/wip-bi-sharding-3) rgw: bilog marker related fixes
 c4548f6 pybind: ceph_argparse: validate incorrectly formed targets
 80a9d99 mon: Monitor: return 'required_features' on get_required_features()
 ab996c1 mon: Elector: output features in handle_propose()
@@ -6152,7 +6926,7 @@ d80ded9 mailmap: David Zhang affiliation
 33ba23f common/shared_cache.hpp: empty() iff weak_refs is empty
 d532f3e remove unused hold_map_lock in _open_lock_pg
 9748655 man: add help for rbd merge-diff command
-6986ec1 osd/PG: populate blocked_by with peers we are trying to activate
+6986ec1 (upstream/wip-10477, origin/wip-10477) osd/PG: populate blocked_by with peers we are trying to activate
 5b0e8ae mailmap: Yehuda Sadeh name normalization
 3f03a7b doc/release-notes: v0.91
 4ca6931 doc/release-notes: typo
@@ -6240,8 +7014,8 @@ f9b280e Adjust bi log listing to work with multiple bucket shards. Signed-off-by
 364b868 mon/Paxos: consolidate finish_round()
 67a90dd mon: accumulate a single pending transaction and propose it all at once
 d159586 PendingReleaseNotes: make a note about librados flag changes
-725d660 0.91
-9264d25 common/Formatter: new_formatter -> Formatter::create
+725d660 (tag: v0.91) 0.91
+9264d25 (upstream/wip-formatter, origin/wip-formatter) common/Formatter: new_formatter -> Formatter::create
 617ad5d common/Formatter: improve json-pretty whitespace
 83c3b13 common/Formatter: add newline to flushed output if m_pretty
 e2a7b17 osd/PG: remove unnecessary publish_stats_to_osd() in all_activated_and_committted()
@@ -6532,7 +7306,7 @@ e68d771 osd: drop vestigal invalid_snapcolls fields from scrub
 18d6b20 doc/release-notes: v0.90
 9b78daf osdc/Objecter: do notify completion callback in fast-dispatch context
 ecbdbb1 tests: temporarily disable unittest_msgr
-08bd1e1 0.90
+08bd1e1 (tag: v0.90) 0.90
 49c2322 doc: Instead of using admin socket, use 'ceph daemon' command.
 a302c44 ceph-disk: Fix wrong string formatting
 2f63e54 cleanup : remove sync_epoch
@@ -6547,7 +7321,7 @@ a302c44 ceph-disk: Fix wrong string formatting
 9783a5c test/msgr/test_msgr: Fix potential unsafe cond wakeup and wrap check
 bba4d35 librados: init last_objver
 2cd9dc0 messages/MClientCaps: init peer.flags
-679652a osd: fix leaked OSDMap
+679652a (upstream/wip-osdmap-leak, origin/wip-osdmap-leak) osd: fix leaked OSDMap
 18f545b librados: Avoid copy data from librados to caller buff when using rados_read_op_read.
 001ea29 Messenger: Create an Messenger implementation by name.
 3a2cb71 mds: fix asok on rank 0
@@ -6757,7 +7531,7 @@ b34e545 os/FileStore.cc: insert not empty list<Context*> to op_finisher/ondisk_f
 7ab4a39 ceph.conf: update sample
 efd9d8d tests: Minor cleanup to librbd test
 78a15ee Fix libstriprados::remove, use strtoll insdead of strtol
-2d4dca7 SimpleMessenger: Retry binding on addresses if binding fails
+2d4dca7 (upstream/wip-10029, origin/wip-10029) SimpleMessenger: Retry binding on addresses if binding fails
 e8063a1 test: modify cephfs quota test case
 31a0cdc mds: fix parse_quota_vxattr for invalid data
 bab7122 OSD: FileJournal: call writeq_cond.Signal if necessary in submit_entry
@@ -6766,7 +7540,7 @@ bab7122 OSD: FileJournal: call writeq_cond.Signal if necessary in submit_entry
 6b51a9f mds: set dirfrag version when fetching dirfrag is skipped
 17c72f5 ceph-osd: remove extra close of stderr
 5836899 Revert "client: support listxattr for quota attributes"
-89b2fee mon: 'osd crush reweight-all'
+89b2fee (upstream/wip-crush-straw, origin/wip-crush-straw) mon: 'osd crush reweight-all'
 dd7b58f crush: set straw_calc_version=1 for default+optimal; do not touch for presets
 adf5c6d crush/builder: a note about the original crush_calc_straw()
 9000068 mon: add 'osd crush {get,set}-tunable <name> [value]' commands
@@ -6775,7 +7549,7 @@ bf0d8d3 osd: Remove dead code related to old pg removal mechanism
 0827bb7 client: use remount to trim kernel dcache
 dfcb1c9 client: cleanup client callback registration
 2f52202 Revert "client: invalidate kernel dentries one by one"
-9902383 crush/CrushWrapper: fix create_or_move_item when name exists but item does not
+9902383 (upstream/wip-9998, origin/wip-9998) crush/CrushWrapper: fix create_or_move_item when name exists but item does not
 8c87e95 crush/builder: prevent bucket weight underflow on item removal
 eeadd60 crush/CrushWrapper: fix _search_item_exists
 a198dee Modifying the docs to add the Get pool commands to match the CLI. Signed-off-by: Chris Holcombe <chris.holcombe at nebula.com>
@@ -6940,7 +7714,7 @@ c133a83 crush/CrushWrapper: dump chooseleaf_vary_r with other tunables
 294b06c crushtool/CrushTester: output utilization even with 1 batch
 3506293 crush: recalculate straw scalers during a reweight
 7a99b48 osdmaptool: --test-map-pgs-dump
-68fdc0f 0.89
+68fdc0f (tag: v0.89) 0.89
 d98cec7 qa: fix teardown in cephtool's test_mon_mds
 8cd1fdd SimpleMessenger: allow RESETSESSION whenever we forget an endpoint
 8e5dbe7 common/perf_counters: Remove the duplicated code.
@@ -6966,7 +7740,7 @@ b8f6b5f doc: Added rbd-replay-many and restructured index.
 6862891 doc: Adds man page for ceph disk in TOC.
 491da51 client: invalidate kernel dentries one by one
 2fa4884 mds: fix race of trimming log segments
-70e1a5d doc: Document RBD Replay
+70e1a5d (upstream/wip-doc-rbd-replay, origin/wip-doc-rbd-replay) doc: Document RBD Replay
 131f092 mds: don't blindly create empty object when dirfrag is missing
 9b9e3ed mds: allow choosing action for wirte error
 dafef3c mds: add asok command to force MDS readonly
@@ -6979,7 +7753,7 @@ cfef515 mds: disallow slave requests when MDS is readonly
 4aed047 mds: keep locks in sync state when MDS is readonly
 2d4a746 mds: don't trim log when MDS is readonly
 4f6474f mds: disallow write operations when MDS is readonly
-01df222 osd: tolerate sessionless con in fast dispatch path
+01df222 (upstream/wip-10209, origin/wip-10209) osd: tolerate sessionless con in fast dispatch path
 0f1c9fd msg: do not const methods that return a mutable pointer
 0d6c803 osd/osd_types: drop category from object_info_t
 5ecdce3 osdc/Objecter: drop category from copy-get
@@ -7220,7 +7994,7 @@ e94d3c1 qa: allow small allocation diffs for exported rbds
 1342548 crush: fix tree bucket functions
 e444b22 crush/builder: replace printf with an empty dprintk macro
 109bcd4 Revert "osd: detect (some) misordered ondisk tmaps"
-4be687b 0.88
+4be687b (tag: v0.88) 0.88
 d12fa35 AsyncMessenger: Fix large bufferlist send segment fault
 d145cca AsyncMessenger: Try send in queue bufferlist
 123d364 AsyncMessenger: Normalise log informations
@@ -7340,7 +8114,7 @@ fe7bf06 rgw: RGWRados::get_obj() returns wrong len if len == 0
 f4ee949 osd: cache pool: flush object ignoring cache min flush age when cache pool is full Signed-off-by: Xinze Chi <xmdxcxz at gmail.com>
 6da9405 doc: Edited Key/Value store config reference.
 03be944 doc: Added Key/Value store config reference to index.
-72fc262 doc: Update for OpenStack Juno.
+72fc262 (upstream/wip-doc-openstack-juno, origin/wip-doc-openstack-juno) doc: Update for OpenStack Juno.
 65c3350 tools: skip up to expire_pos in journal-tool
 e0166a2 osdc/Objecter: Fix a bug of dead looping in Objecter::handle_osd_map
 31c584c osdc/Objecter: e shouldn't be zero in Objecter::handle_osd_map
@@ -7381,7 +8155,7 @@ c5f8d6e osd: past_interval display bug on acting
 c96fe59 doc: update RBD for Juno
 56ee3b4 doc/release-notes: it's 8MB, not 32MB
 f7431cc msg/Pipe: discard delay queue before incoming queue
-c51c8f9 0.87
+c51c8f9 (tag: v0.87) 0.87
 ce6f22d AsyncMessenger: Add kqueue support
 5a4c3aa client: allow xattr caps in inject_release_failure
 214ac9f doc: include 'fs new' stuff in cephfs quickstart
@@ -7486,7 +8260,7 @@ f76f83c osdc/Objecter: fix tick_event handling in shutdown vs tick race
 60eaeca .gitmodules: ignoring changes in rocksdb submodule
 a9dd4af rgw: send http status reason explicitly in fastcgi
 44a8d59 java: fill in stat structure correctly
-cb9262a Objecter: resend linger ops on any interval change
+cb9262a (upstream/wip-9806-giant, origin/wip-9806-giant) Objecter: resend linger ops on any interval change
 1a3ad30 ReplicatedPG: writeout hit_set object with correct prior_version
 8ae942a Remove unnecessary expressions about conf_journal_sz
 024efeb EC: document the LRC per layer plugin configuration
@@ -7604,7 +8378,7 @@ c9f9e72 Revert "Objecter: disable fast dispatch of CEPH_MSG_OSD_OPREPLY messages
 c4bac3e mds: fix inotable initialization/reset
 c95bb59 mds: fix inotable initialization/reset
 f1fccb1 rpm: 95-ceph-osd-alt.rules is not needed for centos7 / rhel7
-b73fe1a doc: remove node requirement from 'mon create-initial'
+b73fe1a (upstream/wip-9730, origin/wip-9730) doc: remove node requirement from 'mon create-initial'
 264f0fc doc: remove whitespace
 20b2766 Update vstart to setup users for s3-tests
 0969945 client: use finisher to abort MDS request
@@ -7621,7 +8395,7 @@ d947050 osd/osd_types: consider CRUSH_ITEM_NONE in check_new_interval() min_size
 50987ec libcephfs.h libcephfs.cc : Defined error codes for the mount function Used new error codes from libcephfs.h to replace the magic numbers in the mount functon found in libcephfs.cc.
 7bab093 return value of handle_message for MSG_OSD_SUBOP/MSG_OSD_SUBOPREPLY should be true
 d955676 rados: Use strict_strtoll instead of strtoll
-809ddd2 osdc/Objecter: fix use-after-frees in close_session, shutdown
+809ddd2 (upstream/wip-9706, origin/wip-9706) osdc/Objecter: fix use-after-frees in close_session, shutdown
 72a2ab1 osdc/Objecter: fix tick() session locking
 d98b755 librados: Fix function prototypes in librados.h
 d458b4f PGLog::IndexedLog::trim(): rollback_info_trimmed_to_riter may be log.rend()
@@ -7744,7 +8518,7 @@ d14ca34 0.86
 efb23b8 common: set_ioprio debug message including pid
 62f0ef4 common: do not set ioprio if pid is not set
 19c92d8 doc: missing osd prefix to ioprio config options
-97dcc05 0.86
+97dcc05 (tag: v0.86) 0.86
 32e8bcd Run configure without liblttng on squeeze as well.
 be6de4a Run configure without liblttng on squeeze as well.
 3535b7a common: ceph_ioprio_string_to_class always returns -EINVAL
@@ -7757,7 +8531,7 @@ b2e4bd5 msg: move SimpleMessenger to msg/simple/
 5eff0ee msg: use localized cct for derr
 06aef6f doc/release-notes: v0.86
 10fe7cf ceph_objectstore_tool: Accept CEPH_ARGS environment arguments
-6aba0ab Add reset_tp_timeout in long loop in add_source_info for suicide timeout
+6aba0ab (upstream/wip-9128, origin/wip-9128) Add reset_tp_timeout in long loop in add_source_info for suicide timeout
 52ac520 tools: remove old ceph.cc
 63c7e16 test/osd/Object: don't generate length of 0
 abe4c35 doc: update kernel recommendations, add tunables link
@@ -7902,7 +8676,7 @@ ed77178 erasure-code: run isa tests via libtool and valgrind
 6886224 mailmap: Yan Zheng affiliation
 fc1380b mailmap: Thorsten Glaser affiliation
 7973280 osd: Remove unused PG functions queue_notify(), queue_info(), queue_log()
-0f884fd For pgls OP, get/put budget on per list session basis, instead of per OP basis, which could lead to deadlock.
+0f884fd (upstream/wip-9008, origin/wip-9008) For pgls OP, get/put budget on per list session basis, instead of per OP basis, which could lead to deadlock.
 7f87cf1 ReplicatedPG: clean out completed trimmed objects as we go
 2cd9b5f tests: use memcmp to compare binary buffers
 c17ac03 ReplicatedPG: don't move on to the next snap immediately
@@ -8029,7 +8803,7 @@ bb49547 KeyValueStore: Reduce redundancy set_header call
 baf7be9 osdc/Objecter: cancel timeout before clearing op->session
 1149639 ceph-disk: mount xfs with inode64 by default
 ded1b30 erasure-code: preload fails if < 0
-27208db doc: Added feedback.
+27208db (upstream/wip-doc-preflight, origin/wip-doc-preflight) doc: Added feedback.
 a140439 mds: limit number of caps inspected in caps_tick
 bf590f8 mds: keep per-client revoking caps list
 a6a0fd8 xlist: implement copy constructor
@@ -8134,7 +8908,7 @@ b178e97 doc: Clean up syntax to suppress warnings.
 7531b28 lttng: Fix 'make tag' when configured --without-lttng
 1c34601 mon/Paxos: make is_readable debug output show result
 62ca27d mon/Paxos: don't spam log with is_readable at dout level 1
-a0c2284 0.85
+a0c2284 (tag: v0.85) 0.85
 f0e0c31 Include types.h after stdint.h to accomodate for older distributions. This fixes compilation on CentOS 5.
 9254792 rbd should use write-back when caching is enabled
 0fb3e52 correct error of repeatedly adding io_size to off in do_bench_write
@@ -8203,7 +8977,7 @@ a754ce5 ErasureCodeLrc.cc: fix -Wmaybe-uninitialized compiler warning
 16cbaba osd/PGLog.h: prefer ++operator for non-primitive iterators
 8f368c5 mailmap: Ashish Chandra affiliation
 5fd50c9 mailmap: Boris Ranto affiliation
-a5b4c58 lockdep: increase max locks (1000 -> 2000)
+a5b4c58 (upstream/wip-9309, origin/wip-9309) lockdep: increase max locks (1000 -> 2000)
 9fac072 documentation: add the mark_unfound_lost delete option
 bec3032 osd: MissingLoc::get_all_missing is const
 e13ddc7 tests: qa/workunits/cephtool/test.sh early fail
@@ -8516,7 +9290,7 @@ f7c0001 common: remove spurious uint32_t in buffer.c
 b0cc869 mds: rename a bunch of metrics
 31ef1a9 mds: set l_mds_req on client request
 06682c4 vstart.sh: debug rgw = 20 on -d
-00c677b rgw: use a separate callback for civetweb access log
+00c677b (upstream/wip-civetweb-log, origin/wip-civetweb-log) rgw: use a separate callback for civetweb access log
 850242c rgw: separate civetweb log from rgw log
 f246b56 common/shared_cache: dump weak refs on shutdown
 6cf583c common/shared_cache: take a cct
@@ -8648,7 +9422,7 @@ acee2e5 doc: Move wireshark documentation to dev.
 ce6e9a9 doc/release-notes: v0.84
 b016f84 doc: add notes on using "ceph fs new"
 948178a ceph_mon: check for existing mon store before opening db
-8336f81 0.84
+8336f81 (tag: v0.84) 0.84
 bda2301 qa/workunits/rbd/qemu-iotests: touch common.env
 1dc1fb8 qa/workunits/hadoop: move all hadoop tests into a hadoop/ dir
 3d3fcc9 qa/workunits/hadoop-wordcount: fix/use -rmr command
@@ -8688,7 +9462,7 @@ dd11042 os/FileStore: fix mount/remount force_sync race
 c83c90c rgw: update civetweb submodule
 0d6d1aa init-ceph: don't use bashism
 7df67a5 Fix -Wno-format and -Werror=format-security options clash
-ae0b9f1 osd: fix feature requirement for mons
+ae0b9f1 (upstream/wip-osd-mon-feature, origin/wip-osd-mon-feature) osd: fix feature requirement for mons
 0db3e51 ReplicatedPG::maybe_handle_cache: do not forward RWORDERED reads
 5040413 ReplicatedPG::cancel_copy: clear cop->obc
 2f0e295 unittest_osdmap: test EC rule and pool features
@@ -8718,7 +9492,7 @@ a1e79db rgw_admin: add --min-rewrite-stripe-size for object rewrite
 46d8c97 doc: Add documentation about Wireshark dissector.
 6a55543 rgw: fix compilation
 f6771f2 shared_cache: use a single lookup for lookup() too
-cec40da qa/workunits/cephtool: verify setmaxosd doesn't let you clobber osds
+cec40da (upstream/historic/old-wireshark-dissectors, origin/historic/old-wireshark-dissectors) qa/workunits/cephtool: verify setmaxosd doesn't let you clobber osds
 a1c3afb OSDMonitor: Do not allow OSD removal using setmaxosd
 16a4360 rgw: pass set_mtime to copy_obj_data()
 800eff2 rgw: copy_obj_data() uses atomic processor
@@ -9031,7 +9805,7 @@ c283ad4 mds: handle replaying old format journals
 e587088 mds: remove unused purge_prealloc_ino
 6be8087 mds: separate inode recovery queue from MDCache
 0d70989 python-ceph: require libcephfs.
-78ff1f0 0.83
+78ff1f0 (tag: v0.83) 0.83
 06c4736 Remove reference from mkcephfs.
 4045b2e doc/release-notes: typo
 df1bad8 doc/release-notes: v0.80.5 release notes
@@ -9050,7 +9824,7 @@ eb697dd librbd: make rbd_get_parent_info() accept NULL out params
 04d0526 PGMonitor: fix bug in caculating pool avail space
 b08470f configure.ac: link libboost_thread only with json-spirit
 9d23cc6 configure: don't link blkid, udev to everything
-de9cfca Only write bufferhead when it's dirty
+de9cfca (upstream/wip-flush-set, origin/wip-flush-set) Only write bufferhead when it's dirty
 1c26266 ObjectCacher: fix bh_{add,remove} dirty_or_tx_bh accounting
 727ac1d ObjectCacher: fix dirty_or_tx_bh logic in bh_set_state()
 5283cfe Wait tx state buffer in flush_set
@@ -9322,7 +10096,7 @@ c0ffa01 mon: Set crash_replay_interval automatically
 917ef15 test: use 0U with gtest to avoid spurious warnings
 522174b qa: support running under non privileged user
 8697d6a OSD: await_reserved_maps() prior to calling mark_down
-6f97206 osd: allow osd map cache size to be adjusted at runtime
+6f97206 (upstream/wip-osd-map-cache-size, origin/wip-osd-map-cache-size) osd: allow osd map cache size to be adjusted at runtime
 bcc09f9 qa/workunits/cephtool/test.sh: sudo ceph daemon
 959f2b2 PGLog: fix clear() to avoid the IndexLog::zero() asserts
 e0d3b78 rgw: fix uninit ofs in RGWObjManifect::obj_iterator
@@ -9411,7 +10185,7 @@ dc1a4df Revert "Give meaningful error when submodules are not checked out"
 9695535 Make <poolname> in "ceph osd tier --help" clearer.
 76361b8 mon: simplify output
 385fd6c do_autogen.sh: --disable-static
-14085f4 0.82
+14085f4 (tag: v0.82) 0.82
 152bbd6 osd: workaround race condition in tests
 cb740b3 mon: shut down perfcounters last
 524700f doc: Fix malformed parameters in librados.h
@@ -9527,7 +10301,7 @@ e720314 doc: Updated the OS Recommendations for Firefly.
 2e3302c doc: Updated the example configuration.
 5a31df2 doc: Updated doc for more recent versions.
 2eab1c1 Update RBD doc for OpenStack
-a290d34 test_librbd_fsx: fix sign-compare gcc warning
+a290d349 test_librbd_fsx: fix sign-compare gcc warning
 40c48bc qa: add script to test krbd setting ro/rw ioctl
 b2542f8 rgw: set a default data extra pool name
 94c8f70 doc: Made mention of "incomplete" status.
@@ -9621,7 +10395,7 @@ f4e81d3 librbd: clarify license header
 9c32cb2 doc: Added usage for pool quotas.
 86754cc doc: Added more discussion of new CRUSH types.
 cabb8f0 doc: Added a section for ceph df.
-8de9501 0.81
+8de9501 (tag: v0.81) 0.81
 4bc5aef doc: Updated packages to reference firefly.
 c18cbef qa: add run_xfstests_krbd.sh wrapper
 cd65246 qa: catch up with xfstests changes
@@ -10031,7 +10805,7 @@ bd8e026 rgw: don't allow multiple writers to same multiobject part
 3e387d6 osd/ReplicatedPG: fix whiteouts for other cache mode
 5cc5686 rgw: send user manifest header field
 e65a9da Revert "Fix installation into user home directory, broken by d3f0c0b"
-b78644e 0.80
+b78644e (tag: v0.80) 0.80
 cdbbf86 doc: Fixed artifacts from merge.
 a31b9e9 doc: Added sudo to setenforce. Restored merge artifact.
 5158272 doc: Added erasure coding and cache tiering notes. Special thanks to Loic Dachary.
@@ -10222,7 +10996,7 @@ d726251 doc: Fix hyperlink to CRUSH maps.
 0d964bc doc: Added new cache tiering doc to index/TOC.
 44e4e3d doc: Added new cache tiering doc to main docs.
 2182815 ReplicatedPG: handle ec pools in mark_all_unfound_lost
-6769f4d 0.80-rc1
+6769f4d (tag: v0.80-rc1) 0.80-rc1
 245923e ReplicatedPG: enable mark_unfound_lost delete for ec pools
 009e874 qa/workunits/rbd/copy.sh: skip some tests when tiering is enabled
 c0bff43 qa/workunits/rbd/copy.sh: fix test
@@ -10432,7 +11206,7 @@ a8a49a0 ReplicatedPG: use get_clone_bytes on evict/promote
 d0e2c98 ReplicatedPG::finish_promote: add debugging assert for clone_size
 e213ee1 qa: workunits: mon: auth_caps.sh: test 'auth' caps requirements
 85a1cf3 mon: MonCommands: have all 'auth' commands require 'execute' caps
-4c2d73a 0.79
+4c2d73a (tag: v0.79) 0.79
 51da3bb mds: fix uninit val in MMDSSlaveRequest
 09586ec client: pin parent dentry of inode who has ll_ref > 0
 76cbd5d mds: fix uninit MMDSSlaveRequest lock_type
@@ -10667,7 +11441,7 @@ e4f2d9f doc/release-notes: 0.78 final notes
 185bcc4 doc/release-notes: final 0.78
 1817c23 rgw: get rid of a memory allocation
 1e7cd10 rgw: remove memory allocation
-f6c746c 0.78
+f6c746c (tag: v0.78) 0.78
 28d8e7f Revert "ReplicatedPG: disallow trans which atomically create and remove an object"
 49a0190 doc/release-notes: 0.78 notes
 dbcf447 erasure-code: gf-complete detects SSE at runtime
@@ -11193,7 +11967,7 @@ c337f63 ReplicatedPG: fix stat uses to use the correct shard
 aa110af OSDMap::_apply_primary_affinity: skip CRUSH_ITEM_NONE in non-default check
 b3bb9ef doc/release-notes: v0.77
 fa96de9 doc/release-notes: v0.67.7
-1bca9c5 v0.77
+1bca9c5 (tag: v0.77) v0.77
 40bdcb8 osd/,mon/: add (up|acting)_primary to pg_stat_t
 0427f61 rgw: fix swift range response
 2b3e3c8 rgw: fix etag in multipart complete
@@ -11637,7 +12411,7 @@ a23a2c8 os/KeyValueStore: fix warning
 eb9ffd5 mon: use 'mds set inline_data ...' for enable/disable of inline data
 408b0c8 mon: fix 'mds set allow_new_snaps'
 e5ed1b2 mon: do not force proposal when no osds
-3b99013 v0.76
+3b99013 (tag: v0.76) v0.76
 7ff2b54 client: use 64-bit value in sync read eof logic
 2f85b8c doc: Incorporated feedback.
 684e5c4 Pipe, cephx: Message signing under config option
@@ -12036,7 +12810,7 @@ c3c1541 osd/ReplicatedPG: make find_object_context() pass missing_oid
 33b5ef4 mon/PGMap: make decode version match encode version
 a5aaab3 ceph-dencoder: include offset in 'stray data' error message
 1308225 buffer: do not append trailing newline when appending empty istream
-946d603 v0.75
+946d603 (tag: v0.75) v0.75
 9034370 doc: Added comment and example for SSL enablement in rgw.conf
 9615645 doc: Added python example of handle, and closing session examples.
 c0d92b6 osd: Implement multiple backfill target handling
@@ -12195,7 +12969,7 @@ e0bae95 Fix typos in erasure code documents
 f8e413f msgr: fix rebind() race stop the accepter and mark all pipes down before rebind to avoid race
 8fcfc91 qa: test rados listomapvals with >512 keys
 be5afa2 rados: allow listomapvals to list all k/v pairs
-c165483 v0.74
+c165483 (tag: v0.74) v0.74
 b4fc16c make: conditionally build filestore backends
 9d41fd2 test_cls_rbd: avoid warning -Wno-unnamed-template-args
 fdd8562 test_cls_rbd: avoid shift overflow
@@ -12323,7 +13097,7 @@ c7d8ba7 osd: better performances for the erasure code example
 ff9455b osd: conditionally disable dlclose of erasure code plugins
 8879e43 osd: Fix assert which doesn't apply when compat_mode on
 0bd5cb6 Add backward comptible acting set until all OSDs updated
-8d31f71 osd/ReplicatedPG: fix promote cancellation
+8d31f71b osd/ReplicatedPG: fix promote cancellation
 923bff1 osd/ReplicatedPG: drop RepGather::ondone callback
 2a9c6fc vstart.sh: go faster
 bc893f5 osd/ReplicatedPG: fix undirty on clean object
@@ -12420,7 +13194,7 @@ ebb3ad9 osd/PG: move some pg stat update into a helper
 05274f3 osd: include peer_info in pg query
 5fdcc56 mds: fix bug in MDCache::open_ino_finish
 71d1eb3 mds: add CEPH_FEATURE_EXPORT_PEER and bump the protocal version
-d0b744a client: handle session flush message
+d0b744a1 client: handle session flush message
 05b192f mds: simplify how to export non-auth caps
 9dc52ff mds: send cap import messages to clients after importing subtree succeeds
 6a56588 mds: re-send cap exports in resolve message.
@@ -12556,7 +13330,7 @@ e223e53 Monitor: encode and expose mon command sets
 420a2f1 man: update man/ from doc/man/8
 8d60cd1 man: Ceph is also an object store
 faaf546 os/MemStore: do on_apply_sync callback synchronously
-d8ad51e v0.73
+d8ad51e (tag: v0.73) v0.73
 990b2b5 ceph_test_rados_api_tier: make HitSetWrite handle pg splits
 a6f4d71 Elector: keep a list of classic mons instead of each mon's commands
 a888a57 crush: implement --show-bad-mappings for indep
@@ -12564,7 +13338,7 @@ a888a57 crush: implement --show-bad-mappings for indep
 fbc4f99 crush: remove scary message string
 472f495 crush: document the --test mode of operations
 ea86444 Monitor: Elector: share the classic command set if we have a classic mon
-f1ccdb4 Elector: share local command set when deferring
+f1ccdb41 Elector: share local command set when deferring
 ba673be Monitor: import MonCommands.h from original Dumpling and expose it
 3cb58f7 Monitor: validate incoming commands against the leader's set too
 cb51b1e Monitor: disseminate leader's command set instead of our own
@@ -12861,7 +13635,7 @@ d0cf2bf ErasureCodeExample.h: prefer prefix ++operator for non-primitive types
 a8e10d3 os/ObjectStore.cc: prefer prefix ++operator for non-primitive types
 555e717 mon/OSDMonitor.cc: prefer prefix ++operator for non-primitive types
 0803d60 common/buffer.cc: prefer prefix ++operator for non-primitive types
-5832e26 v0.72
+5832e26 (tag: v0.72) v0.72
 84fb1bf rgw: deny writes to a secondary zone by non-system users
 d8f0502 doc/release-notes: note crush update timeout on startup change
 1ee112f osdmaptool: fix cli tests
@@ -12989,7 +13763,7 @@ e22347d ceph: Fix memory leak in chain_listxattr
 905243b Fix memory leak in Backtrace::print()
 be12f7f mon: OSDMonitor: proper error msg on invalid epoch on 'osd getmap/dump'
 e5efd88 mon: MonmapMonitor: support 'mon getmap [epoch]'
-e11c975 v0.72-rc1
+e11c975 (tag: v0.72-rc1) v0.72-rc1
 a3119bc upstart, sysvinit: use ceph-crush-location hook
 9f6af8b ceph-crush-location: new crush location hook
 1e2e429 Revert "ceph-crush-location: new crush location hook"
@@ -13156,7 +13930,7 @@ eb0a3b7 doc/release-notes: v0.61.9
 d3f0c0b Makefile: fix /sbin vs /usr/sbin behavior
 15ec533 OSD: check for splitting when processing recover/backfill reservations
 08177f2 ceph: Remove unavailable option with clang
-e509cb1 v0.71
+e509cb1 (tag: v0.71) v0.71
 10b466e radosgw: create /var/log/radosgw in package, not init script
 5c280a2 .gitignore: ceph-kvstore-tool
 14e91bf debian, specfile: fix ceph-kvstore-tool packaging
@@ -13311,7 +14085,7 @@ ff17e45 PG,ReplicatedPG: expose PGBackend to PG
 e73ec48 common/hobject: add is_degenerate method
 c8a4411 PGMap: calc_min_last_epoch_clean() will now also use osd_epochs
 091809b PGMap,PGMonitor: maintain mapping of osd to recent stat epoch
-e3bb065 v0.70
+e3bb065 (tag: v0.70, tag: mark-v0.70-wip) v0.70
 806725a ReplicatedPG: copy: add op progression output
 639ff9f ReplicatedPG: copy: don't leak a ctx on failed copy ops
 469d471 ReplicatedPG: assert that we have succeeded in do_osd_ops on copyfrom repeats
@@ -13654,7 +14428,7 @@ e303b96 mds: re-integrate stray when link count >= 1
 9601092 os/FileStore: fix uninitialized var
 b66ac77 osdc/ObjectCacher: finish contexts after dropping object reference
 ce723b5 doc/release-notes: v0.69
-6ca6f2f v0.69
+6ca6f2f (tag: v0.69) v0.69
 5541a1d doc: Updated link to Storage Cluster Quick Start.
 6af8e3c doc: Updated link to Storage Cluster Quick Start.
 b1d58fa doc: Updated link to Storage Cluster Quick Start.
@@ -13818,7 +14592,7 @@ a9a516a Correct syntax for generate swift key
 ab69d99 mon: fix typo and remove redundant sentence
 7c09ede mon: fix typo in comment
 3c9f849 doc: erasure code ghobject is made of gen_t + shard_t
-b4cf0f2 v0.68
+b4cf0f2 (tag: v0.68) v0.68
 dcbdeaf doc: Fix repo URL for Ceph cloning (dev/generatedocs)
 996af2d ceph_test_rados: test COPY_FROM
 ed68079 osd: initial COPY_FROM (not viable for large objects)
@@ -14107,7 +14881,7 @@ ef9c991 mon: make pg info in 'status' more informative and visually parseable
 f417b10 osdmap: move oneliner summary to separate function
 6f5d803 librados: fix MWatchNotify leak
 810c52d rgw: do not leak handler in get_handler() error path
-e3b7bc5 v0.67
+e3b7bc5 (tag: v0.67) v0.67
 977b7f5 doc/release-notes: fix rst
 f501ec7 doc/release-notes: upgrade sequence
 de7bbdb doc/release-notes: roll-up of upgrade/compat notes from cuttlefish to dumpling
@@ -14221,7 +14995,7 @@ e70e08c cephtool/test.sh: add tests for mon daemon command
 47d0d64 Make all AdminSocket commands use argparse/cmdmap.
 736d6a1 rgw: fix set_buckets_enabled(), set_bucket_owner()
 0e125e0 Objecter: set c->session to NULL if acting is empty
-16adb91 v0.67-rc3
+16adb91 (tag: v0.67-rc3) v0.67-rc3
 e747fa8 Revert "Use dh_installinit to install upstart job files"
 ebab04e mon: add missing state name
 b8af38b mon: allow others to sync from us across bootstrap calls
@@ -14333,7 +15107,7 @@ e4dfe8a test_rgw_admin_meta.cc: remove unused variable 'creds'
 4c778e2 test_rgw_admin_meta.cc: use static_cast<>() instead of C-Style cast
 a8b70f0 doc/release-notes: v0.67-rc2
 41930b5 ceph.spec.in, debian/control: python-ceph depends on python-flask
-0018b45 v0.67-rc2
+0018b45 (tag: v0.67-rc2) v0.67-rc2
 fe2019c rest/test.py: cope with older requests.py versions
 fd1fd66 ceph-disk: use new get_dev_path helper for list
 0b8cad1 ceph_rest_api.py: allow config section fallback
@@ -14393,7 +15167,7 @@ b26b7f6 mon/Paxos: only share uncommitted value if it is next
 99e6054 mon/Paxos: accepted_pn_from has no semantic meaning
 a61635e ceph-monstore-tool: dump paxos transactions
 e60d14d ceph.in: reject --admin-daemon so it can't do harm
-835dd97 v0.67-rc1
+835dd97 (tag: v0.67-rc1) v0.67-rc1
 58c78db FileJournal: fix posix_fallocate error handling
 0897d3a OSD::_make_pg: use createmap, not osdmap
 2dbb273 src/*: make Context::finish private and switch all users to use complete
@@ -14787,7 +15561,7 @@ a498432 ReplicatedPG: pass a PushOp into handle_pull_response
 82cb922 ReplicatedPG: split send_push into build_push_op and send_push_op
 31e19a6 ReplicatedPG: _committed_pushed_object don't pass op
 0f51b60 ReplicatedPG: submit_push_data must take recovery_info as non-const
-b6b48db v0.66
+b6b48db (tag: v0.66) v0.66
 a990664 mon: implement simple 'scrub' command
 afd6c7d mon: fix osdmap stash, trim to retain complete history of full maps
 dd1e6d4 Revert "Makefile: fix ceph_sbindir"
@@ -14874,7 +15648,7 @@ ffe7045 install rules for init-rbdmap
 cfc1f2e rgw: modify RGWBucketInfo::creation_time encoding / decoding
 4089001 rgw: Fix return value for swift user not found
 c73a24b rgw: end-marker serves as last value, not as upperbound
-c414030 rgw: relax marker requirements for log apis
+c4140303 rgw: relax marker requirements for log apis
 b21a41a rgw: update log APIs to use markers
 ce7d816 rgw: cls_log_entry has id field
 064e92f Makefile.am: some more makefile rules fixes
@@ -14944,7 +15718,7 @@ c8f7936 mon/AuthMonitor: start at format 1 (latest) for new clusters
 0d73eb4 mon/PGMonitor: drop some dead code
 0fd776d mon/PGMap: make int type explicit
 29e14ba mon/PaxosService: s/get_version()/get_last_committed()/
-c2d517e v0.65
+c2d517e (tag: v0.65) v0.65
 3016f46 get_xattr() can return more than 4KB
 6e320a1 skip TEST(EXT4StoreTest, _detect_fs) if DISK or MOUNTPOINT are undefined
 63e81af rgw: multiple fixes related to metadata, bucket creation
@@ -15255,7 +16029,7 @@ c112fc8 mon: add is_shutdown() state helper/accessor
 652c599 mon: shut down Paxos on shutdown
 6630462 osd: break con <-> session cycle on reset
 99172c3 osd: do not leak HeartbeatSession on shutdown
-449bcd6 osd: close classes on shutdown
+449bcd6f osd: close classes on shutdown
 b56c965 osd: do not leak MOSDPings on shutdown
 d172c33 osd/ReplicatedPG: don't leak Session refs in do_osd_op_effects()
 cd1c289 messages/MMonSync: initialize crc in ctor
@@ -15296,7 +16070,7 @@ b70f565 ceph: flush stdout on watch print
 299f6a6 Usage log and ops log are disabled by defaults since 0.56
 de17238 mon: fix 'pg dump_stuck' stuckops type
 afa16b4 qa: multiple_rsync.sh: more output
-42e06c1 v0.64
+42e06c1 (tag: v0.64) v0.64
 68b5fa9 ceph-fuse: older libfuses don't support FUSE_IOCTL_COMPAT
 1577e20 ceph-create-keys: Make sure directories for admin and bootstrap keys exist
 95434d1 rgw: propagate mtime from remote rgw on copy
@@ -15570,7 +16344,7 @@ e634d9d Use new fuse package instead of fuse-utils
 4af917d os/LevelDBStore: do compact_prefix() work asynchronously
 dd35c26 osd: fix note_down_osd
 45b84f3 osd: fix hb con failure handler
-054e96c v0.63
+054e96c (tag: v0.63) v0.63
 64d1178 rgw: mdlog, bilog RESTful api cleanup
 fabe723 ceph: first cut at --completion
 2dcc266 ceph, MonCommands.h:  code format/help format tweaks
@@ -15929,7 +16703,7 @@ cab8e9b test/kv_store_bench.cc: fix resource leak
 d8cb7df filestore/test_idempotent_sequence.cc: fix FileStore leaks
 349cfb4 ceph-filestore-dump.cc: cleanup on error case
 df4c099 ceph-filestore-dump.cc: cleanup resource in error case
-9382379 v0.62
+9382379 (tag: v0.62) v0.62
 c5deb5d doc/release-notes: v0.61.2
 97a7309 rgw: tie bucket/user removal to mdlog differently
 4bb4063 ceph_test_libcephfs: parse environment
@@ -16168,7 +16942,7 @@ c693ba5 rados: add whole-object 'clonedata' command
 bd36e78 osd: make class load errors louder
 0b4c5c1 osd: optionally enable leveldb logging
 c1d5f81 mon: allow leveldb logging
-237f3f1 v0.61
+237f3f1 (tag: v0.61) v0.61
 eb69c7d os/: default to dio for non-block journals
 60603d0 ceph-disk: use separate lock files for prepare, activate
 e662b61 ceph-test.install: add ceph-monstore-tool and ceph-osdomap-tool
@@ -16656,7 +17430,7 @@ fc13f11 PG::_scan_list: assert if error is neither -EIO nor -ENOENT
 fcec1a0 ObjectStore: add allow_eio to read, stat, get_omap_header
 76ad956 librados: test empty ObjectWriteOperation
 690e4df Makefile.am: disable building ceph_test_cors when radosgw is not enabled
-f26f7a3 v0.60
+f26f7a3 (tag: v0.60) v0.60
 267ce0d librados: don't use lockdep for AioCompletionImpl
 78acc5c test: fix signed/unsigned comparison in test_cors
 d5b7970 PG: don't compare auth with itself
@@ -16982,7 +17756,7 @@ a27cb85 ceph-disk: fix adjust_symlink() replace 'canonical' with 'path'
 d3c60dc fix: Redefining name 'uuid' from outer scope (line 14)
 6a8120d ceph-disk: remove unused variables from list_partitions()
 3af7a1a ceph-disk: fix /dev/dm-[0-9] handling list_all_partitions()
-cbae6a4 v0.59
+cbae6a4 (tag: v0.59) v0.59
 9bcf5b6 ceph-disk: rename local variable shadowing builtin
 4adf088 ceph-disk: remove twice defined identical function unmount
 ea26ea0 ceph-disk: remove twice defined function mount
@@ -17383,7 +18157,7 @@ a6196de ceph-disk-prepare: verify device is not in use by device-mapper
 867586c debian: require >= python2.6 for ceph as well
 f03f626 ceph-disk-prepare: clean up stupid check for a digit
 5950554 ceph-disk-prepare: use os.path.realpath()
-ba3f91e v0.58
+ba3f91e (tag: v0.58) v0.58
 66df847 Add X-Python-Version >=2.6 to debian control file.
 a06ea30 PG,ReplicatedPG: use pg_has_reset_since to discard old async events
 83e9aa5 PG::build_scrub_map: detect race with peering via last_peering_reset
@@ -17697,7 +18471,7 @@ dbadb3e PG: remove weirdness log for last_complete < log.tail
 5fc83c8 os/FileStore: check replay guard on src for collection rename
 56c5a07 osd: requeue pg waiters at the front of the finished queue
 f1841e4 osd: pull requeued requests off one at a time
-9a7a9d0 v0.57
+9a7a9d0 (tag: v0.57) v0.57
 4002d70 osd: fix printf warning on pg_log_entry_t::get_key_name
 f80f849 qa: test_mon_workloadgen: use default config file path
 6d33859 qa: mon/workloadgen.sh: drop TEST_CEPH_CONF code
@@ -18531,7 +19305,7 @@ fcb9f98 mds: use null dentry to find old parent of renamed directory
 2627957 mds: don't trigger assertion when discover races with rename
 e10267b mds: fix Locker::simple_eval()
 7e23321 mds: don't renew revoking lease
-1a32f0a v0.56
+1a32f0a (tag: v0.56) v0.56
 49ebe1e client: fix _create created ino condition
 a10054b libcephfs: choose more unique nonce
 e2fef38 client: fix _create
@@ -18739,7 +19513,7 @@ e6dd068 qa: echo commands run by rbd map-unmap workunit
 ae100cf mount.fuse.ceph: add ceph-fuse mount helper
 ac92e4d /etc/init.d/ceph: fs_type assignment syntax error
 4605fdd filestore: Don't keep checking for syncfs if found
-8e25c8d v0.55.1
+8e25c8d (tag: v0.55.1) v0.55.1
 dba0960 OSD: pg might be removed during disconnect_session_watches
 047aecd PG,ReplicatedPG: handle_watch_timeout must not write during scrub/degraded
 0dfe6c8 ReplicatedPG:, remove_notify, put session after con
@@ -18858,7 +19632,7 @@ b76f12d doc: Edited striping section. Modified stripe graphic to pretty print. A
 8cd8f25 mds: don't create bloom filter for incomplete dir
 3ace9a7 logrotate: do not spam stdout
 a74a4ac doc: Added a striping section for Architecture.
-690f817 v0.55
+690f817 (tag: v0.55) v0.55
 234cc08 ceph.spec.in:  Add SLES and remove Fedora from debug package list.
 2604557 test_rados_api_misc: fix dup rmmkey test
 f2c7a60 doc: Fixed many hyperlinks, a few typos, and some minor clarifications.
@@ -19176,7 +19950,7 @@ a0eb891 osd: default pool min_size to 0 (which gives us size-size/2)
 735df02 mon: helpful warning in 'health detail' output about incomplete pgs
 1679a55 osd: start_boot() after init()
 65961ca vstart.sh: support -X by adding 'auth required = none' entries
-60b84b0 v0.54
+60b84b0 (tag: v0.54) v0.54
 5d27f3d rgw: compile with -Woverloaded-virtual
 1be9923 rgw: fix RGWCache api
 e0e33d2 rgw: fix RGWCache api
@@ -19681,7 +20455,7 @@ d2afddd rgw: multiple coverity fixes
 db97666 mds: explicitly queue messages for unconnected clients
 2542dd5 client: fix implemented caps update on release/flush
 b290dc3 MClientRequest: fix mode formatting
-2528b5e v0.43
+2528b5e (tag: v0.53) v0.43
 0d3a53d msg/Pipe: correctly read from peers without MSG_AUTH
 96e365b radosgw-admin manpage: Fix broken quotes
 412efc1 admin_socket: fix '0' protocol version
@@ -20053,7 +20827,7 @@ c9266d6 rgw: check that realloc succeeded
 25a9620 FileJournal: correctly check return value of lseek in write_fd
 303f640 OSDCap: remove grants added during failed parsing
 3144690 doc: fix injectargs syntax
-e488594 v0.52
+e488594 (tag: v0.52) v0.52
 9e9c5f2 osd: make 'pg <pgid> revert ...' command idempotent
 175465b cephfs:  Fix breakage of cephfs link
 8c3bfaa doc: update ceph-authtool man page
@@ -20582,7 +21356,7 @@ a30f714 rgw-admin: get rid of lazy remove option, other fixes
 721a6be rgw: implement garbage collector
 bd534bf mon: make parse_pos_long() error message more helpful
 c7d11cd osd: turn off lockdep during shutdown signal handler
-c03ca95 v0.51
+c03ca95 (tag: v0.51) v0.51
 aa91cf8 mon: require --id
 5fd2f10 mon: fix int parsing in monmon
 31c8ccb mon: check for int parsing errors in mdsmon
@@ -20739,7 +21513,7 @@ da35b4c msgr: make set_policy_throttler safe, act on default
 8af2cf3 msgr: expose get_policy() through generic Messenger API
 1740bd0 crush: add helper has_nondefault_tunables()
 c8af0fa cephtool: make command wait for osdmap explicit
-a4428bd v0.50
+a4428bd (tag: v0.50) v0.50
 ac02b34 msg/Pipe: discard_queue() -> discard_out_queue()
 d58df35 msg/Pipe: simplify Pipe::tcp_read() return value
 76954c1 msg/Pipe: document tcp_*()
@@ -20889,7 +21663,7 @@ a16d9c6 os: KeyValueDB: allow finer-grained control of transaction operations
 48bd839 librbd: replace assign_bid with client id and random number
 67832c3 osd: fix ACK ordering on resent ops
 96dbc41 rados::cls::lock: move api types into namespace
-ca6265d v0.49
+ca6265d (tag: v0.49) v0.49
 c8f1311 mon: make 'ceph osd rm ...' wipe out all state bits, not just EXISTS
 f42e187 cls_rbd, cls_rbd_client, test_cls_rbd: copyup method
 127ff61 librbd: drop unnecessary std:: and struct prefixes
@@ -21240,7 +22014,7 @@ b7007a1 msgr: preserve incoming message queue when replacing pipes
 2429556 msgr: fix pipe replacement assert
 204bc59 msgr: do not try to reconnect con with CLOSED pipe
 e6ad6d2 msgr: move to STANDBY if we replace during accept and then fail
-c2b20ca v0.48argonaut
+c2b20ca (tag: v0.48argonaut) v0.48argonaut
 b5098b3 ceph.spec.in: Change license of base package to GPL and use SPDX format
 a1fe589 mon: initialize quorum_features
 d82a502 qa: add rbd remove tests
@@ -21339,7 +22113,7 @@ ddf7e83 doc: ceph osd crush add is now ceph osd crush set
 1e539da doc: Normalized shell script syntax. Added generic cookbook path.
 7d38758 doc: Changed libvirt-dev to libvirt-bin, and cleaned up ./autogen.sh
 3e32dd0 doc: Typo.
-c467d9d v0.47.3
+c467d9d (tag: v0.47.3) v0.47.3
 17dcf60 filestore: disable 'filestore fiemap' by default
 88c7629 OSD: clear_temp: split delete into many transactions
 b84e1ed doc: document usage log
@@ -21693,7 +22467,7 @@ f1e4d44 upstart: support mds
 475e07a debian: Create placeholder dirs for mon and osd data directories.
 ab04d95 monmap: return ENOENT from build_from_host_list when no mons
 80c6278 monmap: ignore conf mon entries when -m is specified
-8bf9fde v0.47.2
+8bf9fde (tag: v0.47.2) v0.47.2
 26843ad Makefile: do not install librgw.h
 a330c64 Update ceph.spec for ceph-0.47
 244992d libs3: remove make install target
@@ -21741,7 +22515,7 @@ c9e9896 obj_bencher: adding stddev to bandwidth and latency
 bc9e592 obj_bencher: add min/max bandwidth
 133cd69 mon: fix 'no initial monitors' warning
 3a2dc96 libs3: remove make install target
-f5a9404 v0.47.1
+f5a9404 (tag: v0.47.1) v0.47.1
 4e3807b Makefile.am: only append libs3 to SUBDIRS when needed
 13b350a filestore: test xattrs on temporary file
 6c0a122 ceph-object-corpus: add some old v2 monmaps
@@ -21757,7 +22531,7 @@ dae2f53 mon: fix leak of MonMap
 7b2614b monmap: filter_initial_members -> set_initial_members
 13c86ca Update leveldb to remove CompactionInputErrorParanoid
 7d5fa4e man: Remove leftover --bin from ceph-authtool(8).
-ad663d5 v0.47
+ad663d5 (tag: v0.47) v0.47
 e2e7f58 keys: new release key
 5d2ec1d builder: make reweight helpers static, void
 63580a9 formatter: replace malloc with new
@@ -22035,7 +22809,7 @@ f3771b0 throttle: feed cct, name, and add logging
 7413828 osdmap: do no dereference NULL entity_addr_t pointer in addr accessors
 4c597fa OSD: add different config options for map bl caches
 cefaa7d mon: fix nion -> noin typo
-cb7f1c9 v0.46
+cb7f1c9 (tag: v0.46) v0.46
 88dda3b librbd: use unique error code for image removal failures
 580b520 run_xfstests.sh: drop #62
 4465c3a osdmap: fix identify_osd() and find_osd_on_ip()
@@ -22395,7 +23169,7 @@ cd4a760 osd: fix heartbeat set_port()
 4f030e1 osd_types: fix off by one error in is_temp
 31f16a4 rgw: list multipart response fix
 89fecda Makefile.am: remove some clutter
-0aea1cb v0.45
+0aea1cb (tag: v0.45) v0.45
 d348e1a configure: --with-system-leveldb
 34cc308 filestore: fix leveldb includes
 0b2e1cd cephfs: fix uninit var warning
@@ -22410,7 +23184,7 @@ dd8fd16 configure: HAVE_FALLOCATE -> CEPH_HAVE_FALLOCATE
 dfa043d config: {osd,mon}_data default to /var/lib/ceph/$type/$cluster-$id
 7680cda dencoder, rgw: make ceph-dencoder load much faster
 9832696 encoding: use iterator to copy_in encoded length
-689ac5d v0.44.2
+689ac5d (tag: v0.44.2) v0.44.2
 e0c4db9 FileStore: do not check dbobjectmap without option set
 38e24b1 config: include /etc/ceph/$cluster.keyring in keyring search path
 57dff03 config: expand metavariables for --show-config, --show-config-value
@@ -22516,7 +23290,7 @@ a52d048 rgw: throttle incoming requests
 c3b0464 paxos: share_state sends every unknown value, including the stashed one
 d5c4015 uclient: We want to release cache when we lose the CACHE cap, not gain it!
 d0ba27a doc: add a short thing on kernel client troubleshooting.
-c89b7f2 v0.44.1
+c89b7f2 (tag: v0.44.1) v0.44.1
 6044c5b hadoop: define subsystem, fix logging
 fe56818 config: configure log thresholds
 ce61a83 log: throttle message submission, trim recent
@@ -22571,7 +23345,7 @@ fc7a1bd ReplicatedPG: return -EBUSY on delete for objects with watchers
 c53194d Objecter: add op->resend_on_any_change
 2daff0e ReplicatedPG: osd_max_notify_timeout -> osd_default_notify_timeout
 6a5cbec rgw: replace bucket_id generation
-cdd5298 v0.44
+cdd5298 (tag: v0.44) v0.44
 e42fbb7 rgw: process default alt args before processing conf file
 e0b8f7a rgw: process default alt args before processing conf file
 51a0733 rgw: incrase socket backlog
@@ -22780,7 +23554,7 @@ ffa5955 msgr: Remove SimpleMessenger::register_entity
 3bd1d2a msgr: add start() and wait() stubs to the Messenger interface
 70360f8 github.com/NewDreamNetwork -> github.com/ceph
 cacf0fd filestore: fix rollback safety check
-9fa8781 v0.43
+9fa8781 (tag: v0.43) v0.43
 3a83517 RadosModel: separate initialization and construction
 cd31388 librados: only shutdown objecter after it's initialized
 2c275ef Makefile: add headers for distcheck
@@ -22834,7 +23608,7 @@ ee4d990 journaler: log on unexpected objecter error
 3ad6ccb debian: sdparm|hdparm, new standards version
 266902a rgw: initialize bucket_id in bucket structure
 f8f6e4d rgw: _exit(0) on SIGTERM
-732f3ec v0.42.2
+732f3ec (tag: v0.42.2) v0.42.2
 d85ed91 osd: fix array index
 722e9e5 lockdep: don't make noise on startup
 fdaed0a formatter: fix trailing dump_stream()
@@ -22854,7 +23628,7 @@ c9416e6 osd: 'tell osd.N mark_unfound_lost revert' -> 'pg <pgid> mark_unfound_lo
 5efa821 rgw: swift read acls allow bucket listing
 f09fb87 rgw: fix swift acl enforcement
 7c7349e ceph: fix help.t
-c3e1291 v0.42.1
+c3e1291 (tag: v0.42.1) v0.42.1
 0281f1c debian: add ceph-dencoder
 f6e42a8 ceph.spec.in: add ceph-dencoder
 730b9ee ceph-dencoder: man page
@@ -22917,7 +23691,7 @@ a4f2fdb osdmap: add Incremental::dump()
 d74e029 test/encoding/readable.sh: sh, not dash
 e33bf5a crushtool: fix clitests
 0429aa7 msgr: fix shutdown race again
-b205c64 v0.42
+b205c64 (tag: v0.42) v0.42
 76e88d1 msgr: fix accept shutdown race fault
 ca04ee1 mon: test injected crush map
 5dd24f9 crush: move crushtool --test into CrushTester
@@ -23277,7 +24051,7 @@ dbda1b6 CephContext: add method for retrieving admin socket
 56d164c mon: stale pgs -> HEALTH_WARN
 61c54a7 mon: mark pgs stale in pg_map if primary osd is down
 6e44af9 osd: add STALE pg state bit
-c1345f7 v0.41
+c1345f7 (tag: v0.41) v0.41
 374fec4 objector: document Objecter::init_ops()
 6d37d5c objecter: fix out_* initialization
 9472920 Revert "common/Throttle: Remove unused return type on Throttle::get()"
@@ -23404,7 +24178,7 @@ a6c0610 msgr: uninline operator<< on sockaddr_storage
 0ded7e4 ReplicatedPG: munge truncate_seq 1/truncate_size -1 to seq 0/size 0
 44cb076 rgw: limit object PUT size
 d575337 objecter: fix up stat, getxattrs handlers
-7eea40e v0.40
+7eea40e (tag: v0.40) v0.40
 81c0ad8 librados: make new ObjectReadOperations arguments non-optional
 7347538 rgw: use new librados ObjectReadOperation method arguments
 4815caf ReplicatedPG: Update stat accounting for truncate during write
@@ -23832,7 +24606,7 @@ c883100 rados.py: add list_pools method
 c45a849 mds: remove obsolete doc
 0c183ec crush: ignore forcefed input that doesn't exist
 faf5ce6 Revert "CrushWrapper: ignore forcefeed if it does not exist"
-321ecda v0.39
+321ecda (tag: v0.39) v0.39
 75aff02 OSDMap: build_simple_from_conf pg_num should not be 0 with one osd
 2f5bd5f objecter: initialize global_op_flags to zero
 813523a Doc: delete gratuitous index.html
@@ -23983,7 +24757,7 @@ add04d1 filejournal: fix replay of non-idempotent ops
 71bfe89 test/pybind: add test_rgw
 ea42e02 test/pybind: convert python rados and rgw tests to be runnable by nose
 25cde7f rados.py: fix Snap.get_timestamp
-b600ec2 v0.38
+b600ec2 (tag: v0.38) v0.38
 2a7fbe0c common: return null if mc.init() unsuccessful
 a177a70 rbd.py: fix list when there are no images
 27bb48c mon: overwrite in put_bl
@@ -24275,7 +25049,7 @@ edcd4d9 rgw: some more swift fixes
 9baf5ef ceph.spec: don't chkconfig
 21d941e ceph.spec: work around build.opensuse.org
 195a484 ceph.spec: capitalize first letter to make rpmlint happy
-a6f3bbb v0.37
+a6f3bbb (tag: v0.37) v0.37
 ca8f603 osd: fix assemble_backlog
 2fdec7b osd: fix add_next_event Missing::item::have
 c1cabf5 ceph: don't crash when sending message to !up osd
@@ -24337,7 +25111,7 @@ a50fbe2 PG: merge_old_entry: merged delete might not be in missing
 e07b956 rgw: implement some missing swift api, other swift fixes
 5790a36 rgw: encoded swift key contains full user name
 f883e63 rgw: multiple swift keys per user
-9b18e55 PG,OSD: clean up xlist::items on pg removal
+9b18e55e PG,OSD: clean up xlist::items on pg removal
 b43b864 osd: fix race between op requeueing and _dispatch
 f7ec9f7 thread: whitespace
 fc3aac6 filestore: clean up error output
@@ -24482,7 +25256,7 @@ f85dfa7 osd: combine log_op into append_log
 8111b61 mds: make jouranl writeable in MDLog::append()
 f4e61db mdcache: tolerate no subtrees in create_subtree_map()
 4922757 ceph.spec.in still packages libceph.so in 0.36
-877cacb v0.36
+877cacb (tag: v0.36) v0.36
 c00e06f doc: add documentation for librbd python bindings
 683f4dc rbd.py: add class and method documentation
 1c1785d rbd.py: use a dict to translate error codes
@@ -24695,7 +25469,7 @@ aa666b1 objclass: add stat operation
 2ec5f15 cls_rgw: list marker uses lower_bound
 894a8b6 client: tear down dir when setting I_COMPLETE on empty
 b9e32ff rados: accept '-b' as an argument.
-0afda37 v0.35
+0afda37 (tag: v0.35) v0.35
 2c28e1c Makefile: include config_opts.h
 6068fc8 osd: set reply version for dup requests
 43967f5 auth: keyring: whitespace
@@ -25011,7 +25785,7 @@ fbeafdf osd: make MOSDOp[Reply] encoding backwards compatible
 877aa92 osd: redo pg_t encoding with 64-bit pool id
 d8f1f1d osd: fix pg_pool_t::get_pg_num return types
 0b00350 ceph_context: whitespace
-2f039ee v0.34
+2f039ee (tag: v0.34) v0.34
 44cb5ee rgw: use formatter->dump_string() instead of dump_format()
 0e8bd0d rgw: get bucket info only if bucket name is not empty
 fa757b7 Makefile.am: install coverage files for libtool outputs as well
@@ -25223,7 +25997,7 @@ afdb1f3 rgw: list objects shows time in GMT, thread safety fix
 a311715 src/perfglue/heap_profiler.cc: fix snprintf
 14de6d2 client: compile with older libfuse2
 cb1f050 osd_types: fix merge
-340b434 v0.33
+340b434 (tag: v0.33) v0.33
 89eeb34 osd: pg_stat_t: throw exception on unknown encoding
 ce00564 qa: test rename into snapped dir
 e98669e mds: mark newly created snaprealms as open
@@ -25470,7 +26244,7 @@ e5dfa3d escape_json_attr: don't escape single quotes
 0dc235a mds: request attempt comes from fwd count, not retry flag
 15c344c mds: fix create_subtree_map for new dirs
 534afab vstart: static mapping of names to ranks
-c08d08b v0.32
+c08d08b (tag: v0.32) v0.32
 360ab7f rgw: don't silently ignore bad user/group when setting acl
 94239ec objecter: rename POOL_DISAPPEARED to POOL_DNE
 9447ce6 objecter: check for updated osdmap when requesting a non-existent pool
@@ -25776,7 +26550,7 @@ d2cdbe7 mds: defer lock eval if freezing or frozen
 9bdde93 rgw: cache lru
 dc41c8d client: remove unused variable
 4f73121 rgw: fix put of zero sized objects
-9019c6c v0.31
+9019c6c (tag: v0.31) v0.31
 bae40ea filejournal: parse kernel version 3.0+
 3f708ee rgw: fix copy operation (clean up acls)
 44e76fb rgw: when listing objects, set locator key only when needed
@@ -25886,7 +26660,7 @@ fab24c8 filestore: allow FIEMAP to be disabled via conf
 fb81442 testradospp: fix compilation
 1446d6d mon: Guard injectargs parsing to prevent crashes on bad input
 6a7e635 mds: Explicitly initialize layout fields, and to the correct values.
-64b1b2c v0.30
+64b1b2c (tag: v0.30) v0.30
 842ec22 debian: drop python-support version req
 e27a893 rados: encode bufferlist in watch-notify
 0111835 rados: encode bufferlist in watch-notify
@@ -25965,7 +26739,7 @@ f1f75df ceph_argparse_witharg: fix dashes in args
 4549501 common/Throttle: Remove unused return type on Throttle::get()
 c23d4c2 libceph: delogbalize, again
 92a3a47 Makefile: add missing common/dout.h header to dist tarball
-5da0662 librados: fix end_block calculation for aio_read
+5da06628 librados: fix end_block calculation for aio_read
 823a05c proflogger: only register one event for all loggers
 629ac0d librados: deglobalize, again
 9a3a685 OSDMap: kill some deadcode, deglobalize
@@ -26122,7 +26896,7 @@ bc1782a osd: fix find_object_context debug output
 9974b7e rgw: user suspension
 3aa6a4d qa: pjd must run as root
 8b4b838 rgw: get multipart list marker to work
-77d38e4 v0.29.1
+77d38e4 (tag: v0.29.1) v0.29.1
 a379c67 rgw: some multipart cleanups, fixes
 515f088 librbd: fix block_completion race condition
 e9e3fee rgw: implement list multiparts
@@ -26308,7 +27082,7 @@ b5011e2 mds: adjust subtree roots on rename
 10750f8 common: add module_type to CephContext; use to initialize rotating keys
 b28ba77 osd: use osd_op.soid in call
 5cc146e osd: allow src_oids to be snapped
-8e69c39 v0.29
+8e69c39 (tag: v0.29) v0.29
 f9af9ce remove dumpjournal
 0baa108 osd: src oid is in OSDOp now
 5a86126 osd: don't crash on malformed clone_range (now really)
@@ -26400,7 +27174,7 @@ e5c9100 osd: fix map sharing due to heartbeats
 5b7c8ae osd: protect recovery_wq ops with the recovery lock
 b3fb58e crushtool: add -v verbose for --test mode
 57ea502 Add content to obsync package
-2324204 v0.28.2
+2324204 (tag: v0.28.2) v0.28.2
 7e1de38 hadoop: track Hadoop API changes
 232cd6b rgw: generate random upload id
 4ddf8df SimpleMessenger: allow multiple calls to shutdown
@@ -26462,7 +27236,7 @@ ce04e3d osd: add ability to explicitly mark unfound as lost
 87309e9 osd: make automatically marking of unfound as lost optional
 cea7b65 mds: clean up get_or_create_stray
 081acc4 mds: initialize stray_index on startup
-d66c6ca v0.28.1
+d66c6ca (tag: v0.28.1) v0.28.1
 9a660ac librads, libceph: store CephContext
 13aed89 Add CephContext
 1c7b982 Split common_init_daemonize from common_init_finish
@@ -26555,7 +27329,7 @@ dbb2c38 PG: _remove_pg, reset info.last_update and info.log_tail on log zero
 14a3f26 Move crush into libcommon
 2fc13de Move crush into libcommon
 0d79f1d man: update cosd man page
-071881d v0.28
+071881d (tag: v0.28) v0.28
 b060f5c Revert "Makefile.am: link some utils with libcrush"
 f1c82aa logclient: get rid of send_log; simplify monitor special casing
 baba0a7 msgr: fix signedness in alloc_aligned_buffer
@@ -26737,7 +27511,7 @@ dc9be20 osdmap: fix temp osd pg mapping
 5c520fe mon: do not stop mds0 unless all other nodes have also stopped
 6ac5572 PG: handle MOSDPGLog messages in Active state.
 79b1a10 ceph_crypto: Fix ceph::crypto::init mutex for NSS.
-44900d4 v0.27.1
+44900d4 (tag: v0.27.1) v0.27.1
 27a48c1 ceph::crypto::init: add PTHREAD_MUTEX_INITIALIZER
 7d12d18 mds: fix --reset-journal
 28ccdf4 obsync: remove misguided strip_owner
@@ -26964,7 +27738,7 @@ a9d12cb mon: fix up pg health report
 70640bf mon: generalize health check a bit
 4368e97 Makefile.am: add -fno-strict-aliasing
 4fe53fc Makefile.am: Wpointer-arith, Wstrict-null-sentinel
-793034c v0.27
+793034c (tag: v0.27) v0.27
 268f189 clitests: fix osdmap unit test
 4b547cb Makefile: add some new warnings to CXXFLAGS
 474be65 mds: don't daemonize when doing journal reset.
@@ -27209,7 +27983,7 @@ b6084cf config: expand metavariables when needed
 94fade2 config: add ability to complain about parse errs
 4a27cec confutils: test unicode parsing
 0e26ece config: fix metavariable substitution
-9981ff9 v0.26
+9981ff9 (tag: v0.26) v0.26
 32e422e configure: change gtk dep to 2.12 instead of 2.13 for lenny
 3227405 config: remove some unecessary g_conf references
 05c281b Revert "autoconf: Complain if tcmalloc is not found."
@@ -27419,7 +28193,7 @@ b77a323 osync: fix automatic bucket creation
 fc99cca osync: add alternate syntax for file:// transfers
 e08b3a5 osync-test: test file-to-bucket transfers
 453e1f9 osync: add SRC_AKEY, etc. environment variables
-07ee631 v0.25.2
+07ee631 (tag: v0.25.2) v0.25.2
 41675b1 Fix manpage typos
 e7abf59 Remove unused cdbs build dependency
 e2f1d78 Change wording of Debian package descriptions
@@ -27469,7 +28243,7 @@ cae43fc Makefile: drop libradosgw_a LDFLAGS
 32fce3c rados_create: correctly handle null id
 f06f4ee librados: always call keyring_init in connect
 586fc66 librados: don't call keyring_init in init_internal
-9e1828a objecter: make response_data bufferlist static
+9e1828af objecter: make response_data bufferlist static
 251fd50 rados_create_internal calls keyring_init
 c548976 rados_create: set id based on parameter
 b1c3321 librados: add rados_create_internal
@@ -27497,7 +28271,7 @@ ca61378 rbd: int -> int64_t on do_export
 58ffd37 rados tool: close dir after reading through
 84b65b5 rados tool: recursively import from dir to pool
 df8c009 cfuse: set proper defaults
-7f4a161 v0.25.1
+7f4a161 (tag: v0.25.1) v0.25.1
 db25852 cfuse: always daemonize hack
 448010f osd: small pull recovery adjustments
 4046c4b ReplicatedPG,OSD: Track which osds we are pulling from
@@ -27636,7 +28410,7 @@ aa251bd safe_io: fix signed/unsigned comparisons
 0cbfbee tests/cli/osdmaptool: default pg_num changed
 7a529d5 crush: remove misleading comment
 46d63d9 crush: fix memory leak
-3fa121b v0.25
+3fa121b (tag: v0.25) v0.25
 4ac0881 Bump librados soname to 2.
 82282f2 config: back to 6 pg bits for now
 08af63d rgw: put object request returns etag
@@ -27959,7 +28733,7 @@ f70d904 config: Remove g_conf.num_osd, num_mds, num_mon
 a350296 common: bufferlist::read_file: use safe_read
 d431295 auth/Crypto.cc: use safe_read_exact
 22dece1 os/FileStore: remove unused variable
-2cd2c56 v0.24.3
+2cd2c56 (tag: v0.24.3) v0.24.3
 b60444b make:add messages/MOSDRepScrub.h to NOINST_HEADERS
 c695a61 cephtool: get_indata should use safe_read_exact
 378ba0a mon/MonitorStore.cc: use safe_read
@@ -28249,7 +29023,7 @@ bc98a0f MDSMonitor: fix bugs with standby-replay assignment.
 0fbbbad os: FileStore::mkfs error handling fixes
 212289f vstart: Add --standby_mds setting, for auto-creating standby-replays.
 58637ac debian: fix publish.sh for ubuntu
-f7572de v0.24.2
+f7572de (tag: v0.24.2) v0.24.2
 4a49a87 msgr: make connection pipe reset atomic
 3a30eb7 msgr: include con in debug output
 943fd14 filestore: don't wait min sync interval on explicit sync()
@@ -28418,7 +29192,7 @@ e189222 ReplicatedPG: Fix bug in rollback
 9b0d577 Use Google Test framework for unit tests.
 1a9ef3f Make git ignore generated files.
 1846355 os: don't crash on no-journal case
-630565f3 v0.24.1
+630565f3 (tag: v0.24.1) v0.24.1
 eace439 test_split.sh: add many_pools test
 a64ddbb ReplicatedPG: get_object_context ssc refcount leak
 fde4b97 mds: fix _dout_lock recursion recursion
@@ -28553,7 +29327,7 @@ ff6e4d4 common: make generic_usage a little prettier
 a410360 test: add TestSignalHandlers
 532522d rgw_admin: fix compile error in usage
 61f964c librados: Fix compile error by adding std:: namespace
-180a417 v0.24
+180a417 (tag: v0.24) v0.24
 69940e2 osd: compensate for replicas with tail > last_complete
 0e510db objectcacher: Fix erroneous reference to "lock" with "flock."
 b04b6f4 mds: make nested scatterlock state change check more robust
@@ -28722,7 +29496,7 @@ a3d8c52 filestore: call lower-level do_transactions() during journal replay
 f9fa855 filestore: fix journal locking on trailing mode
 cbb5620 rbd: use MIN instead of min()
 792b04b client: connect to export targets on cap EXPORT
-5bdae2a ceph v0.23.2
+5bdae2a (tag: v0.23.2) ceph v0.23.2
 bde0c72 filestore: do not autodetect BTRFS_IOC_SNAP_CREATE_ASYNC until interface is finalized
 4592c22 client: fix cap export handler
 15c272e man: fix monmaptool man page
@@ -28839,7 +29613,7 @@ c0c301d osd: PG::read_log: don't be clever with lost xattr
 8461228 Build might_have_unfound set at activation
 36c6569 monmaptool: Return a non-zero error code and print a useful error 	message if unable to read the monmap file.
 fc21254 mds: allow for old fs's with stray instead of stray0
-868665d v0.23.1
+868665d (tag: v0.23.1) v0.23.1
 c327c6a mon: always use send_reply for auth replies
 61dd4f0 mon: simplify send_reply code
 2c71bd3 osd: add assert to _process_pg_info
@@ -28951,7 +29725,7 @@ c5b2d28 uclient: insert lssnap results under snapdir, not live dir
 7ccdae8 msg: fix buffer size for IPv6 address parsing
 ce6d639 timer: rewrite mostly from scratch
 5484899 mds: hit inode created via CREATE
-5d1d8d0 v0.23
+5d1d8d0 (tag: v0.23) v0.23
 3d10b34 mds: fix null_snapflush with multiple intervening snaps
 85e0890 osd: scrub least recently scrubbed pgs first; once a day
 c12829a osd: don't scrub something we just scrubbed
@@ -29122,7 +29896,7 @@ ee3fc3b osd: Add scrub to the names of scrub scheduling-related things.
 e6df807 test: create test_unfound.sh
 1dd5042 fix make distcheck, make uninstall
 c044829 filestore: automatically choose appropriate journaling mode
-9f4fd4a v0.22.2
+9f4fd4a (tag: v0.22.2) v0.22.2
 5b06ca1 filestore: use updated btrfs ioctls
 a831b2a btrfs: update ioctls.h
 bb628d3 Get "make dist" working, fix gui build issues
@@ -29203,7 +29977,7 @@ e27f0b1 filestore: escape the xattr chunk names
 d4bbde5 ./ceph osd setcrushmap: validate crushmap
 394b071 crush: improve error handling in map decoding
 a869b35 cap_reconnect_t: ignore embedded NULLs in the path
-e912e68 v0.22.1
+e912e68 (tag: v0.22.1) v0.22.1
 96d4673 Makefile: add errno.h
 a974cfd mds: be quiet about snaprealm push/pop
 6907894 filestore: ignore ENOSPC on setxattr pending a better workaround
@@ -29290,7 +30064,7 @@ c0db71f debian: update standards-version; fix ceph-client-tools-dbg
 1b2e992 debian: update scripts to do packaging fixes
 d44267c Revert "messenger: introduce a "halt_delivery" flag, checked by queue_delivery."
 69b764a mon: add 'mds rm <gid>' and 'mds rmfailed <id>' commands
-8a7c95f v0.22
+8a7c95f (tag: v0.22) v0.22
 2bc159e debian: no libgoogle-perftools-dev on lenny
 180f441 mds: cleanup: clarify issue_seq in cap release debug output
 b8ab009 mds: cleanup: print waiter masks in hex
@@ -29497,7 +30271,7 @@ f4be4b9 librados: throttle messages via the objecter
 e64109e objecter: enable automatic throttling of all messages
 0c800a9 objecter: add accounting to keep track of total in-flight messages.
 c8de979 Revert "throttle: make count an atomic_t"
-e4e37a9 v0.21.3
+e4e37a9 (tag: v0.21.3) v0.21.3
 df1d5d8 cauthtool: update man page
 ce63cf4 client: increase default cache size to 16K dentries and lru insertion point .25
 487b8a6 debian: allow builddebs.sh build a specific dist
@@ -29613,7 +30387,7 @@ c80a1d0 mds: fix bad iterator usage in process_reconnected_caps()
 5ae8e26 class: fix adding of class library, when previously existed
 46a16b9 mds: fix bad iterator usage in process_reconnected_caps()
 783d2ed mon: more useful class debug output
-f24cee3 ceph v0.21.2
+f24cee3 (tag: v0.21.2) ceph v0.21.2
 85814d4 client: Make truncation work properly The previous if block didn't work because inode->size was usually changed well before handle_cap_trunc was ever invoked, so it never did the truncation in the objectcacher! This was okay if you just truncated a file and then closed it, but if you wrote a file, truncated part of it out, and then wrote past the (new) end you would get reads that returned the previously-truncated data out of what should have been a hole.
 610b2e9 osd: fix class timeouts
 79f86c9 osd: clean up class loading code a bit
@@ -29759,7 +30533,7 @@ dcedfb8 osd: improve l_osd_buf accuracy
 a3eefd5 msgr: don't leak message when sending to a closed connection
 a406cfa osd: log push ops as push, not pull
 d00f43a logger: fix logger counter reset
-7aa332c ceph v0.21.1
+7aa332c (tag: v0.21.1) ceph v0.21.1
 255bf71 mon: use elector's epoch
 acd17a5 Makefile: include logrotate.conf in tarball
 a234df0 debian: fix update_pbuilder.sh
@@ -29937,7 +30711,7 @@ b72c1bb monclient: use default port if not specified via -m
 11dc1af mon: fix signed/unsigned compile warning
 719aa18 debian: add update_pbuilder.sh script; don't do it during build
 f3ac22a bump unstable version to v0.22~rc
-090436f v0.21
+090436f (tag: v0.21) v0.21
 ea2ce9d cclass.in: fix libdir definition
 fd4029c debian/ceph.logrotate: enhance postrotate for "service" util
 6db8975 mon: trim old logm states
@@ -29964,7 +30738,7 @@ b01cc38 rgw: set default log level to 20
 6bd40ac qa: consistent snaptest-%d.sh naming
 9127cd9 mds: fix uninitialized LeaseStat for null lease
 5c714bf osd: log when we get marked down but aren't
-7fbe165 debug: no name symlink when explicit --log-file
+7fbe1655 debug: no name symlink when explicit --log-file
 3de9c8d client: some whitespace cleanup
 8195899 qa: add localized version of Thomas Mueller's snaptest-2.sh
 2d35d24 rgw: exit after 5 seconds from SIGUSR1 anyway
@@ -30666,7 +31440,7 @@ cea221c MPoolOp: rearrange parsing, for easier kernel implementation
 291c0ab filejournal: create if mkfs and journal is small OR dne.
 b53d0ed filejournal: return error instead of asserting
 60095d9 mon: correctly update up map when taking over for creating|starting mds
-266d207 debian: fix up debian scripts
+266d207 (tag: v0.20) debian: fix up debian scripts
 b022a28 ceph.spec.in: updates
 f244067 ceph.spec.in: from Josef
 974f2ee mds: fix trim_dentry on dentry under unlinked dir
@@ -31434,7 +32208,7 @@ aac8930 debug: fix warnings, use larger path buffers
 f8b2584 mds: add support for directory sticky bit
 4540b5e filestore: only do btrfs_snap if btrfs
 ef27fd6 update release checklist
-98f5be5 v0.19
+98f5be5 (tag: v0.19) v0.19
 801d248 mon: disable 'osd setmap'
 e2ed6db osdmap: fix uninit var warning
 f4a5f53 mon: add 'auth export ]name]' to export a full or partial keyring
@@ -31558,7 +32332,7 @@ ba515fe mkcephfs: generate cephx keys during mkfs
 329178d mount: set flags when getting -o sync
 6ea3030 mds: fix dumpcache
 6285b61 authtool: only create keyring if --create-keyring (or -c)
-f40957e config: rename 'keys file' to 'keyring'
+f40957eb config: rename 'keys file' to 'keyring'
 3ebf9a4 filestore: optionally checkpoint with snaps
 5bdb348 journal: make sure max_size is multiple of block_size
 54898b3 mds: print setattr'd values with MClientRequest
@@ -31786,7 +32560,7 @@ ff4e155 mds: debug reconnect timeouts
 3d97239 debian: only upload tarball whem building amd64
 9bea9d0 logger: use proper format for s64
 ee44121 qa: put qa used files on ceph.newdream.net
-2f10137 v0.18
+2f10137 (tag: v0.18) v0.18
 a08d961 rados: move librados.h, rados_bencher.h
 dc24351 mds: avoid scatter writebehind from predirty_*
 e71e361 crush: fix whitespace
@@ -31803,7 +32577,7 @@ e439bd3 config: add kill arguments for mds import/export
 b709a72 mds: bracket mds journal events with {start,submit}_entry
 95ee211 todo
 adbd7d8 dropped old aleung mds branch code
-714a9af mon: fix allocation of low global_ids after mon restart
+714a9af (upstream/historic/aleung_mds_security, origin/historic/aleung_mds_security) mon: fix allocation of low global_ids after mon restart
 89603b6 test_ioctls: print preferred_osd value from GET_LAYOUT ioctl
 54b8537 hash: fix whitespace
 fd0195a mds: set mdr->in[n] in rdlock_path_xlock_dentry
@@ -32068,7 +32842,7 @@ e97c152 auth: fix verify_authorize_reply stupid
 08fbca8 auth: simplify challenge key encoding
 05e198b buffer: make [], hexdump const
 6133f02 auth: break client/server challenge calc into helper
-9ea4e4a auth: CEPH_AUTH_NONE auth and caps working
+9ea4e4a5 auth: CEPH_AUTH_NONE auth and caps working
 e98eb90 auth: return correct auth type
 8de5de0 auth: auth-none protocol stubs
 0717270 auth: redefine CEPH_AUTH_NONE
@@ -32199,7 +32973,7 @@ fa77429 auth: add osd caps parser
 0b26194 osd: assert apply_transaction success
 2109a91 auth: get rid of AuthorizeServer
 1b4db2f todos
-dac3a8c v0.17
+dac3a8c (tag: v0.17) v0.17
 413340e auth: fix vstart.sh
 74be02f debian: don't try to sign packages; it fails anyway
 2d0a8b2 auth: send caps to principals with the ticket
@@ -32366,7 +33140,7 @@ ed08416 move tests around
 4c32af6 Hadoop: Add the patch and a Readme file.
 335cd8f debian: upload tarball before .deb build
 ae5bf1b debian: name unstable package version ${vers}git${stamp}
-53ca2a8 v0.16.1
+53ca2a8 (tag: v0.16.1) v0.16.1
 1e51d19 rgw: fix build errors on i386
 14ad6cd Makefile: include buffer.c in tarball, kclient package
 bfc18d2 rgw: encode time_t, size_t using fixed-size types
@@ -32377,7 +33151,7 @@ bc9b863 kclient: include fs/{Kconfig,Makefile} in patchset
 165a729 uclient: Only connect to offload targets if the mds goes down.
 3a3ccd8 kclient: checkpatch cleanups
 522f570 mds: fix default layout settings
-38dbaa5 v0.16
+38dbaa5 (tag: v0.16) v0.16
 e678fbc msgr: authorizer get/verify callbacks
 faa5fb5 msgr: get_authorizer hook?
 56f45b4 objecter: Session type
@@ -32560,7 +33334,7 @@ f255bbc auth: osd loads rotating keys on startup
 c6faf6a kclient: kill out_qlen
 1744628 make inline string functions non-inline
 c2b4dc3 kclient: whitespace
-ab3c421 v0.15
+ab3c421 (tag: v0.15) v0.15
 c6e5d6e Makefile: include ioctl-number.patch
 1f1ec71 msgr: don't print source in msg debug output
 13e6f34 todo
@@ -32685,7 +33459,7 @@ df985c4 mds: avoid client lookup by using per-connection msgr state
 c2b6534 kclient: checkpatch cleanups
 035b08f kclient: update Documentation/ioctl/ioctl-number.txt
 69f84d1 todo
-1ec1e8d v0.14
+1ec1e8d (tag: v0.14) v0.14
 b985882 kclient: remove msgpools for now
 3046334 init-ceph: fix pre/post commands
 deec333 auth: stop auth sequence after getting the tickets
@@ -32875,7 +33649,7 @@ e9b00e0 Hadoop: Clean up ceph_delete code as it's redundant.
 c5dd75e Hadoop: Add package.html; fix a NULL instead of null error (Java)
 bc372c7 Hadoop: Put guards up to prevent a nasty bug in case of unspecified preferences, and the unlikely case that initialize is called twice.
 1d7726e upload tarball with 'stable' deb
-2b32297 v0.13
+2b32297 (tag: v0.13) v0.13
 884ec32 auth: kernel side aes functions
 43dcbc2 todo
 88179a3 auth: rearrange types
@@ -33047,7 +33821,7 @@ f42bb1d Hadoop: Makes use of newly-available replication reporting.
 90b0a6c uClient: Change file data function names for clarity; add function stubs for Hadoop use.
 290233e Hadoop: time conversion between Ceph and Hadoop; ditch filling in the uid/gid since it's meaningless.
 2387afb uClient: fill_stat now fills times properly
-f524150 v0.12
+f524150 (tag: v0.12) v0.12
 dad494c Makefile: add missing header to noinst_HEADERS
 1b89c16 Makefile: remove java hadoop _SOURCES dep
 6b4d8f9 osdmap: kill unused/useless get_num_osds()
@@ -33155,7 +33929,7 @@ adf0477 Hadoop: Remove the silly clientPointer convention from the Java.
 e18b613 Hadoop: Created new and modified old CephFSInterface.cc methods
 38e8ce2 Hadoop: Newly-generated JNI files into CephFSInterface.h
 ee0e17b Hadoop: Adding JNI header files to repository.
-9fa6f5e v0.11
+9fa6f5e (tag: v0.11) v0.11
 a8de8c7 kclient: simple dout macro by default
 b66da8f todo
 ea54a6a kclient: msgr cleanup
@@ -33255,7 +34029,7 @@ cfc0e0e kclient: kill dout(0, ...) calls
 bc2a567 kclient: __attribute__ ((packed)) all around
 2870371 s3gw: fix operations with url encoded object name
 860f65c osd: don't crash on a zero length write (sage)
-007313f v0.10
+007313f (tag: v0.10) v0.10
 464d248 Makefile: fix up initscript packaging
 6b3309a initscripts: /etc, not /usr/etc
 348c2dd s3gw: prefix/delmiter can be used for listing objects
@@ -33521,7 +34295,7 @@ aa615b8 kclient: clean up unaligned pointer accesses
 1d21494 mon: allow repair of entire osd
 29a2b2f mds: reduce default memory, journal footprint
 e0097bc osd: do NOT include op vector when shipping raw transaction
-4148185 kclient: strip out kernel version compatibility cruft
+4148185 (tag: v0.9) kclient: strip out kernel version compatibility cruft
 7e51c52 kclient: update script importer
 58f2820 todo
 9f58773 osd: on scrub repair, update replica pg stats as necessary
@@ -33906,7 +34680,7 @@ d0bac06 rados: look up pool by name
 36f70f4 header comments
 b566903 osd: get rid of the grep op
 a05f6ef class: able to list loaded classes on the monitor
-284161c kclient: kill dput/d_drop debug cruft
+284161c (tag: v0.8) kclient: kill dput/d_drop debug cruft
 ba73ac8 kclient: remove bookkeeper
 e3efa40 kclient: fix kbuild.patch for 2.6.30
 de954bf changelog
@@ -34039,7 +34813,7 @@ c5e64e1 kclient: a few sparse fixes
 563024f mds: only issue sensible caps on directories
 0c3becd mds: make eval take a mask; kill try_*_eval
 7c344e6 start v0.8
-be072be msgr: kill static instance 'rank' of SimpleMessenger
+be072be (tag: v0.7.3) msgr: kill static instance 'rank' of SimpleMessenger
 2519f3c msgr: clean up refs to static 'rank'
 08daaa4 uclient: clean up mount wrt osdmap, mdsmap
 497ade3 journaler: store layout in journal header
@@ -34743,7 +35517,7 @@ e587771 remove user error induced asserts
 6ea23d7 initscript: fix btrfs path default to osd data
 4b60f10 kclient: add osdc data to sysfs
 c353d14 bump version to v0.7.1 for unstable branch
-c46e1b3 mkcephfs: btrfsctl -a between mkfs and mount
+c46e1b3 (tag: v0.7) mkcephfs: btrfsctl -a between mkfs and mount
 3260c75 kclient: patch series updates
 f5a3d61 kclient: fix /sys/fs/ceph/mdsmap
 e2afd17 kclient: sysfs whitespace cleanup
@@ -35169,7 +35943,7 @@ f49f78d osd: reset peering, in-flight repops on every pg change
 74f2a9c uclient: update caps code to match kclient logic
 33f4443 kclient: some caps cleanup
 0017712 kclient: improve snap locking scheme
-a4c752d v0.6
+a4c752d (tag: v0.6) v0.6
 00577b5 kclient: rename lookup_mds_session get_mds_session
 b078856 kclient: realm create does not take a ref count
 70365be kclient: split get_snap_realm to lookup and create
@@ -35873,7 +36647,7 @@ a1511eb mon: use generic stash mechism to manage latest version of paxos-managed
 01a3325 kclient: use generic timeout/retry code for various monitor request types
 cd32920 kclient: pick new mon if statfs is unresponsive; clean up other retry code
 e14818c streamtest: fix recursive locking
-1dd4209 journal: detect size of raw block devices properly
+1dd4209 (tag: v0.5) journal: detect size of raw block devices properly
 200c569 osd: only trim pg log if pg contains complete set of osds
 8c1908a osdmap: fix type conversions
 41065ee crush: mention license.  minor cleanup
@@ -36265,7 +37039,7 @@ b3d6eef journal: protect journal access (namely, completions) with mutex
 8618940 debian: include crun in osd, mds, mon packages
 6e669cf osdmaptool: fix silly num_dom bug
 7cb7ada ceph.spec.in: include crun
-13b1bf7 kclient: initializing kaddr (merge fix)
+13b1bf7 (tag: v0.4) kclient: initializing kaddr (merge fix)
 d9262de kclient: use both writepage and crc
 fbd3cfa kclient: disabling the readpage
 34dccf9 kclient: disabling readpage
@@ -36824,7 +37598,7 @@ f254beb mds: follow snaps in path_traverse, returning resulting snapid to caller
 0fcadab client: track snapdir ref to parent explicitly
 5a83812 filepath: don't remove dup /'s
 83f2e4f client: hidden .snap dir, lssnap fixes
-2e986fe include ceph.spec in configure.ac
+2e986fe (tag: v0.3) include ceph.spec in configure.ac
 d38b0af ceph.spec changes
 90a0dfc mds: fix purging for unlinked inodes with caps
 1949cce client: cache versioned inodes.  use high bits of ino in fuse client.
@@ -37323,7 +38097,7 @@ ed523d0 kclient: create -> mknod sets S_IFREG.  debug mode.
 80c023f mds: wake rdlock waiters on xlock_finish
 f56a91d kclient: fix up mdsc spinlocking a bit
 cd5cd72 mds: fix can_rdlock_soon vs xlock on FileLock
-2b5f76f readme
+2b5f76f (tag: v0.2) readme
 7f9f1ea kclient: use d_splice_alias in prepopulate
 41443ce kclient: create fall back to mknod if no nameidata (as with nfs-kernel-server)
 5e5ed11 kclient: drop nameidata printk
@@ -38053,7 +38827,7 @@ bbc61d9 mds: flush file (size+mtime) metadata to journal on close
 35ee017 cleanup
 638a997 added inode revalidation
 f19c71d fix mds cap interaction; echo blah > mnt/blah now works
-204c175 msg: blobhash on entity_name_t causes strange badness... should look into that, but avoid for now
+204c175 (tag: v0.1) msg: blobhash on entity_name_t causes strange badness... should look into that, but avoid for now
 39d2a25 mds: adjust cap issue sequence to avoid unnecessary file_caps messages
 8adc9da debian packing stuffs
 78924fb more automake.  make dist seems to work
@@ -38477,7 +39251,7 @@ d793b0f reworked message encoding/decoding header vs payload vs data payload, al
 d697bfc fixed header encoding/decoding
 ef4a4f1 some client request/reply struct redefinition; no more file_data_version, for now; utime_t now uses ceph_timeval
 425169f no more bufferlist; streamlined ceph_msg object instead
-b380858 all chunk sizes come first, before payload
+b3808583 all chunk sizes come first, before payload
 da820e7 build errors
 e30b0f5 random crap
 6369889 send_message func, creates new connections as needed
@@ -40485,7 +41259,7 @@ eba9e7e *** empty log message ***
 ee63c70 *** empty log message ***
 90a1c02 *** empty log message ***
 bac0031 *** empty log message ***
-2576492 import is currently broken
+25764921 import is currently broken
 b247412 *** empty log message ***
 61a5130 *** empty log message ***
 9475610 *** empty log message ***
@@ -40546,3 +41320,5 @@ fa8f4df *** empty log message ***
 0ac5aed *** empty log message ***
 1893aa1 *** empty log message ***
 48cdbbf New repository initialized by cvs2svn.
+23d8a34 rgw: modify documents and help infos' descriptions to the usage of option date when executing command "log show"
+7091d44 mon: degrade a log message to level 2
diff --git a/Makefile.in b/Makefile.in
index ccf6967..a611e93 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -79,11 +89,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = .
-DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/configure $(am__configure_deps) \
-	$(srcdir)/ceph.spec.in test-driver COPYING ar-lib compile \
-	config.guess config.sub install-sh missing ltmain.sh
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/ac_prog_jar.m4 \
@@ -102,6 +107,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+	$(am__configure_deps) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
@@ -367,6 +374,10 @@ TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
 	$(TEST_LOG_FLAGS)
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/ceph.spec.in AUTHORS \
+	COPYING ChangeLog INSTALL NEWS README ar-lib compile \
+	config.guess config.sub install-sh ltmain.sh missing \
+	py-compile test-driver
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -498,6 +509,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -594,6 +606,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -649,7 +662,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -816,7 +828,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 	if test -n "$$am__remaking_logs"; then \
 	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
 	       "recursion detected" >&2; \
-	else \
+	elif test -n "$$redo_logs"; then \
 	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
 	fi; \
 	if $(am__make_dryrun); then :; else \
@@ -1033,15 +1045,15 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
@@ -1077,17 +1089,17 @@ distcheck: dist
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_inst
+	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build \
-	  && ../configure \
+	  && $(am__cd) $(distdir)/_build/sub \
+	  && ../../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=.. --prefix="$$dc_install_base" \
+	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -1270,6 +1282,8 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \
 	uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # why is it so hard to make autotools to this?
 install-data-local::
diff --git a/aclocal.m4 b/aclocal.m4
index da19afc..aa640de 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.14'
+[am__api_version='1.15'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.14.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.14.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -118,7 +118,7 @@ AC_SUBST([AR])dnl
 
 # Figure out how to run the assembler.                      -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -138,7 +138,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -183,15 +183,14 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
 # configured tree to be moved without reconfiguration.
 
 AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 ])
 
 # AM_COND_IF                                            -*- Autoconf -*-
 
-# Copyright (C) 2008-2013 Free Software Foundation, Inc.
+# Copyright (C) 2008-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -228,7 +227,7 @@ fi[]dnl
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -259,7 +258,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -450,7 +449,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -526,7 +525,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -616,8 +615,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@@ -690,7 +689,11 @@ to "yes", and re-run configure.
 END
     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   fi
-fi])
+fi
+dnl The trailing newline in this macro's definition is deliberate, for
+dnl backward compatibility and to allow trailing 'dnl'-style comments
+dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
+])
 
 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
@@ -719,7 +722,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -730,7 +733,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -740,7 +743,7 @@ if test x"${install_sh}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -761,7 +764,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -811,7 +814,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -850,7 +853,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -879,7 +882,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -926,7 +929,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1161,7 +1164,7 @@ for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
 sys.exit(sys.hexversion < minverhex)"
   AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1180,7 +1183,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1261,7 +1264,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1321,7 +1324,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1349,7 +1352,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1368,7 +1371,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/ar-lib b/ar-lib
index fe2301e..463b9ec 100755
--- a/ar-lib
+++ b/ar-lib
@@ -4,7 +4,7 @@
 me=ar-lib
 scriptversion=2012-03-01.08; # UTC
 
-# Copyright (C) 2010-2013 Free Software Foundation, Inc.
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
 # Written by Peter Rosin <peda at lysator.liu.se>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/ceph.spec b/ceph.spec
index 57092d4..51811b5 100644
--- a/ceph.spec
+++ b/ceph.spec
@@ -1,4 +1,19 @@
 # vim: set noexpandtab ts=8 sw=8 :
+#
+# spec file for package ceph
+#
+# Copyright (C) 2004-2016 The Ceph Project Developers. See COPYING file
+# at the top-level directory of this distribution and at
+# https://github.com/ceph/ceph/blob/master/COPYING
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon.
+#
+# This file is under the GNU Lesser General Public License, version 2.1
+#
+# Please submit bugfixes or comments via http://tracker.ceph.com/
+# 
 %bcond_with ocf
 %bcond_without cephfs_java
 %bcond_with tests
@@ -55,7 +70,7 @@ restorecon -R /var/log/ceph > /dev/null 2>&1;
 # common
 #################################################################################
 Name:		ceph
-Version:	10.0.2
+Version:	10.0.3
 Release:	0%{?dist}
 Epoch:		1
 Summary:	User space components of the Ceph file system
@@ -133,6 +148,7 @@ BuildRequires:	python-requests
 BuildRequires:	python-virtualenv
 BuildRequires:	snappy-devel
 BuildRequires:	util-linux
+BuildRequires:	valgrind-devel
 BuildRequires:	xfsprogs
 BuildRequires:	xfsprogs-devel
 BuildRequires:	xmlstarlet
@@ -168,7 +184,6 @@ BuildRequires:	libatomic-ops-devel
 %if 0%{?_with_systemd}
 Requires:	systemd
 %endif
-BuildRequires:  bzip2-devel
 BuildRequires:	nss-devel
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	libatomic_ops-devel
@@ -790,6 +805,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ceph-mon
 %{_bindir}/ceph-mds
 %{_bindir}/ceph-objectstore-tool
+%{_bindir}/ceph-bluefs-tool
 %{_bindir}/ceph-osd
 %{_bindir}/ceph-detect-init
 %{_bindir}/librados-config
@@ -844,6 +860,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/rados-classes/libcls_journal.so*
 %dir %{_libdir}/ceph/erasure-code
 %{_libdir}/ceph/erasure-code/libec_*.so*
+%dir %{_libdir}/ceph/compressor
+%{_libdir}/ceph/compressor/libceph_*.so*
 %if 0%{?_with_lttng}
 %{_libdir}/libos_tp.so*
 %{_libdir}/libosd_tp.so*
@@ -1179,6 +1197,7 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %files -n python-cephfs
 %defattr(-,root,root,-)
 %{python_sitelib}/cephfs.py*
+%{python_sitelib}/ceph_volume_client.py*
 
 #################################################################################
 %files -n ceph-test
@@ -1204,7 +1223,6 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %{_bindir}/ceph_smalliobenchdumb
 %{_bindir}/ceph_smalliobenchfs
 %{_bindir}/ceph_smalliobenchrbd
-%{_bindir}/ceph_streamtest
 %{_bindir}/ceph_test_*
 %{_bindir}/ceph_tpbench
 %{_bindir}/ceph_xattr_bench
diff --git a/ceph.spec.in b/ceph.spec.in
index 52c5c1d..487232c 100644
--- a/ceph.spec.in
+++ b/ceph.spec.in
@@ -1,4 +1,19 @@
 # vim: set noexpandtab ts=8 sw=8 :
+#
+# spec file for package ceph
+#
+# Copyright (C) 2004-2016 The Ceph Project Developers. See COPYING file
+# at the top-level directory of this distribution and at
+# https://github.com/ceph/ceph/blob/master/COPYING
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon.
+#
+# This file is under the GNU Lesser General Public License, version 2.1
+#
+# Please submit bugfixes or comments via http://tracker.ceph.com/
+# 
 %bcond_with ocf
 %bcond_without cephfs_java
 %bcond_with tests
@@ -133,6 +148,7 @@ BuildRequires:	python-requests
 BuildRequires:	python-virtualenv
 BuildRequires:	snappy-devel
 BuildRequires:	util-linux
+BuildRequires:	valgrind-devel
 BuildRequires:	xfsprogs
 BuildRequires:	xfsprogs-devel
 BuildRequires:	xmlstarlet
@@ -168,7 +184,6 @@ BuildRequires:	libatomic-ops-devel
 %if 0%{?_with_systemd}
 Requires:	systemd
 %endif
-BuildRequires:  bzip2-devel
 BuildRequires:	nss-devel
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	libatomic_ops-devel
@@ -790,6 +805,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ceph-mon
 %{_bindir}/ceph-mds
 %{_bindir}/ceph-objectstore-tool
+%{_bindir}/ceph-bluefs-tool
 %{_bindir}/ceph-osd
 %{_bindir}/ceph-detect-init
 %{_bindir}/librados-config
@@ -844,6 +860,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/rados-classes/libcls_journal.so*
 %dir %{_libdir}/ceph/erasure-code
 %{_libdir}/ceph/erasure-code/libec_*.so*
+%dir %{_libdir}/ceph/compressor
+%{_libdir}/ceph/compressor/libceph_*.so*
 %if 0%{?_with_lttng}
 %{_libdir}/libos_tp.so*
 %{_libdir}/libosd_tp.so*
@@ -1179,6 +1197,7 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %files -n python-cephfs
 %defattr(-,root,root,-)
 %{python_sitelib}/cephfs.py*
+%{python_sitelib}/ceph_volume_client.py*
 
 #################################################################################
 %files -n ceph-test
@@ -1204,7 +1223,6 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %{_bindir}/ceph_smalliobenchdumb
 %{_bindir}/ceph_smalliobenchfs
 %{_bindir}/ceph_smalliobenchrbd
-%{_bindir}/ceph_streamtest
 %{_bindir}/ceph_test_*
 %{_bindir}/ceph_tpbench
 %{_bindir}/ceph_xattr_bench
diff --git a/compile b/compile
index 531136b..a85b723 100755
--- a/compile
+++ b/compile
@@ -3,7 +3,7 @@
 
 scriptversion=2012-10-14.11; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/config.guess b/config.guess
index b79252d..1659250 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2013 Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2013-06-10'
+timestamp='2015-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -24,12 +24,12 @@ timestamp='2013-06-10'
 # program.  This Exception is an additional permission under section 7
 # of the GNU General Public License, version 3 ("GPLv3").
 #
-# Originally written by Per Bothner.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 #
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 
 
 me=`echo "$0" | sed -e 's,.*/,,'`
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -149,7 +149,7 @@ Linux|GNU|GNU/*)
 	LIBC=gnu
 	#endif
 	EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
 	;;
 esac
 
@@ -168,20 +168,27 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
 	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+	    /sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || \
+	    echo unknown)`
 	case "${UNAME_MACHINE_ARCH}" in
 	    armeb) machine=armeb-unknown ;;
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
 	    sh3eb) machine=sh-unknown ;;
 	    sh5el) machine=sh5le-unknown ;;
+	    earmv*)
+		arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+		endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
+		machine=${arch}${endian}-unknown
+		;;
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently, or will in the future.
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
@@ -197,6 +204,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		os=netbsd
 		;;
 	esac
+	# Determine ABI tags.
+	case "${UNAME_MACHINE_ARCH}" in
+	    earm*)
+		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+		abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+		;;
+	esac
 	# The OS release
 	# Debian GNU/NetBSD machines have a different userland, and
 	# thus, need a distinct triplet. However, they do not need
@@ -207,13 +221,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		release='-gnu'
 		;;
 	    *)
-		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
 		;;
 	esac
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "${machine}-${os}${release}"
+	echo "${machine}-${os}${release}${abi}"
 	exit ;;
     *:Bitrig:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
@@ -235,6 +249,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:MirBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
+    *:Sortix:*:*)
+	echo ${UNAME_MACHINE}-unknown-sortix
+	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	*4.0)
@@ -579,8 +596,9 @@ EOF
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
+	if [ -x /usr/bin/lslpp ] ; then
+		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
@@ -826,7 +844,7 @@ EOF
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
-    i*:MSYS*:*)
+    *:MSYS*:*)
 	echo ${UNAME_MACHINE}-pc-msys
 	exit ;;
     i*:windows32*:*)
@@ -932,6 +950,9 @@ EOF
     crisv32:Linux:*:*)
 	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
+    e2k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     frv:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
@@ -969,10 +990,10 @@ EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
-    or1k:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+    openrisc*:Linux:*:*)
+	echo or1k-unknown-linux-${LIBC}
 	exit ;;
-    or32:Linux:*:*)
+    or32:Linux:*:* | or1k*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     padre:Linux:*:*)
@@ -1020,7 +1041,7 @@ EOF
 	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
     xtensa*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
@@ -1260,16 +1281,26 @@ EOF
 	if test "$UNAME_PROCESSOR" = unknown ; then
 	    UNAME_PROCESSOR=powerpc
 	fi
-	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		grep IS_64BIT_ARCH >/dev/null
-	    then
-		case $UNAME_PROCESSOR in
-		    i386) UNAME_PROCESSOR=x86_64 ;;
-		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
-		esac
+	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+	    if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		    (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		    grep IS_64BIT_ARCH >/dev/null
+		then
+		    case $UNAME_PROCESSOR in
+			i386) UNAME_PROCESSOR=x86_64 ;;
+			powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		    esac
+		fi
 	    fi
+	elif test "$UNAME_PROCESSOR" = i386 ; then
+	    # Avoid executing cc on OS X 10.9, as it ships with a stub
+	    # that puts up a graphical alert prompting to install
+	    # developer tools.  Any system running Mac OS X 10.7 or
+	    # later (Darwin 11 and later) is required to have a 64-bit
+	    # processor. This is not true of the ARM version of Darwin
+	    # that Apple uses in portable devices.
+	    UNAME_PROCESSOR=x86_64
 	fi
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
@@ -1361,154 +1392,6 @@ EOF
 	exit ;;
 esac
 
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-	"4"
-#else
-	""
-#endif
-	); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-	printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-	printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-	{ echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-	echo c1-convex-bsd
-	exit ;;
-    c2*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-	exit ;;
-    c34*)
-	echo c34-convex-bsd
-	exit ;;
-    c38*)
-	echo c38-convex-bsd
-	exit ;;
-    c4*)
-	echo c4-convex-bsd
-	exit ;;
-    esac
-fi
-
 cat >&2 <<EOF
 $0: unable to guess system type
 
diff --git a/config.sub b/config.sub
index 9633db7..1acc966 100755
--- a/config.sub
+++ b/config.sub
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2013 Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2013-08-10'
+timestamp='2015-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ timestamp='2013-08-10'
 # of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -68,7 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -117,7 +117,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
@@ -255,16 +255,18 @@ case $basic_machine in
 	| arc | arceb \
 	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
 	| avr | avr32 \
+	| ba \
 	| be32 | be64 \
 	| bfin \
 	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
-	| epiphany \
-	| fido | fr30 | frv \
+	| e2k | epiphany \
+	| fido | fr30 | frv | ft32 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| k1om \
 	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
@@ -282,8 +284,10 @@ case $basic_machine in
 	| mips64vr5900 | mips64vr5900el \
 	| mipsisa32 | mipsisa32el \
 	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa32r6 | mipsisa32r6el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64r6 | mipsisa64r6el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipsr5900 | mipsr5900el \
@@ -295,14 +299,14 @@ case $basic_machine in
 	| nds32 | nds32le | nds32be \
 	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
-	| open8 \
-	| or1k | or32 \
+	| open8 | or1k | or1knd | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
+	| riscv32 | riscv64 \
 	| rl78 | rx \
 	| score \
-	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -310,6 +314,7 @@ case $basic_machine in
 	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
 	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+	| visium \
 	| we32k \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
@@ -324,7 +329,10 @@ case $basic_machine in
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+	leon|leon[3-9])
+		basic_machine=sparc-$basic_machine
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -369,18 +377,20 @@ case $basic_machine in
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| ba-* \
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| c8051-* | clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
-	| elxsi-* \
+	| e2k-* | elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| k1om-* \
 	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
@@ -400,8 +410,10 @@ case $basic_machine in
 	| mips64vr5900-* | mips64vr5900el-* \
 	| mipsisa32-* | mipsisa32el-* \
 	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa32r6-* | mipsisa32r6el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64r6-* | mipsisa64r6el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipsr5900-* | mipsr5900el-* \
@@ -413,16 +425,18 @@ case $basic_machine in
 	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
+	| or1k*-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
+	| riscv32-* | riscv64-* \
 	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
 	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tile*-* \
@@ -430,6 +444,7 @@ case $basic_machine in
 	| ubicom32-* \
 	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
 	| vax-* \
+	| visium-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -506,6 +521,9 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-aros
 		;;
+        asmjs)
+		basic_machine=asmjs-unknown
+		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
@@ -767,6 +785,9 @@ case $basic_machine in
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	leon-*|leon[3-9]-*)
+		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
@@ -822,6 +843,10 @@ case $basic_machine in
 		basic_machine=powerpc-unknown
 		os=-morphos
 		;;
+	moxiebox)
+		basic_machine=moxie-unknown
+		os=-moxiebox
+		;;
 	msdos)
 		basic_machine=i386-pc
 		os=-msdos
@@ -1354,7 +1379,7 @@ case $os in
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* | -aros* \
+	      | -aos* | -aros* | -cloudabi* | -sortix* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
@@ -1367,14 +1392,14 @@ case $os in
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1592,9 +1617,6 @@ case $basic_machine in
 	mips*-*)
 		os=-elf
 		;;
-	or1k-*)
-		os=-elf
-		;;
 	or32-*)
 		os=-coff
 		;;
diff --git a/configure b/configure
index b1c790f..b5a8482 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ceph 10.0.2.
+# Generated by GNU Autoconf 2.69 for ceph 10.0.3.
 #
 # Report bugs to <ceph-devel at vger.kernel.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ceph'
 PACKAGE_TARNAME='ceph'
-PACKAGE_VERSION='10.0.2'
-PACKAGE_STRING='ceph 10.0.2'
+PACKAGE_VERSION='10.0.3'
+PACKAGE_STRING='ceph 10.0.3'
 PACKAGE_BUGREPORT='ceph-devel at vger.kernel.org'
 PACKAGE_URL=''
 
@@ -676,6 +676,10 @@ WITH_LIBXFS_FALSE
 WITH_LIBXFS_TRUE
 WITH_LIBAIO_FALSE
 WITH_LIBAIO_TRUE
+HAVE_LZ4_FALSE
+HAVE_LZ4_TRUE
+HAVE_BZLIB_FALSE
+HAVE_BZLIB_TRUE
 WITH_LIBROCKSDB_FALSE
 WITH_LIBROCKSDB_TRUE
 WITH_SLIBROCKSDB_FALSE
@@ -853,6 +857,7 @@ CCASFLAGS
 CCAS
 CXXCPP
 CPP
+LT_SYS_LIBRARY_PATH
 OTOOL64
 OTOOL
 LIPO
@@ -924,6 +929,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -951,6 +957,7 @@ enable_shared
 enable_static
 with_pic
 enable_fast_install
+with_aix_soname
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -1010,6 +1017,7 @@ CPPFLAGS
 CCC
 CC
 CFLAGS
+LT_SYS_LIBRARY_PATH
 CPP
 CXXCPP
 CCAS
@@ -1068,6 +1076,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1320,6 +1329,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1457,7 +1475,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1570,7 +1588,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ceph 10.0.2 to adapt to many kinds of systems.
+\`configure' configures ceph 10.0.3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1610,6 +1628,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1641,7 +1660,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ceph 10.0.2:";;
+     short | recursive ) echo "Configuration of ceph 10.0.3:";;
    esac
   cat <<\_ACEOF
 
@@ -1675,9 +1694,12 @@ Optional Packages:
   --with-man-pages        build man pages
   --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-aix-soname=aix|svr4|both
+                          shared library versioning (aka "SONAME") variant to
+                          provide on AIX, [default=aix].
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
-  --with-sysroot=DIR Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).
+  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
+                          compiler's sysroot if not specified).
   --with-rados            build with librados support
   --with-rbd              build rbd files
   --with-cython           build python bindings for librbd
@@ -1731,6 +1753,8 @@ Some influential environment variables:
               you have headers in a nonstandard directory <include dir>
   CC          C compiler command
   CFLAGS      C compiler flags
+  LT_SYS_LIBRARY_PATH
+              User-defined run-time library search path.
   CPP         C preprocessor
   CXXCPP      C++ preprocessor
   CCAS        assembler compiler command (defaults to CC)
@@ -1829,7 +1853,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ceph configure 10.0.2
+ceph configure 10.0.3
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2905,7 +2929,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ceph $as_me 10.0.2, which was
+It was created by ceph $as_me 10.0.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4219,8 +4243,8 @@ test -n "$target_alias" &&
   program_prefix=${target_alias}-
 
 # Fix automake problems in 1.12
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -5003,8 +5027,8 @@ esac
 
 
 
-macro_version='2.4.2'
-macro_revision='1.3337'
+macro_version='2.4.6'
+macro_revision='2.4.6'
 
 
 
@@ -5018,7 +5042,7 @@ macro_revision='1.3337'
 
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 # Backslashify metacharacters that are still active within
 # double-quoted strings.
@@ -5067,7 +5091,7 @@ func_echo_all ()
     $ECHO ""
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
 $as_echo "printf" >&6; } ;;
   print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
@@ -5390,19 +5414,19 @@ test -z "$GREP" && GREP=grep
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -5416,7 +5440,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -5427,7 +5451,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -5438,32 +5462,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -5506,33 +5530,38 @@ if ${lt_cv_path_NM+:} false; then :
 else
   if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -5543,15 +5572,15 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
@@ -5657,9 +5686,9 @@ esac
   fi
 fi
 
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -5667,8 +5696,8 @@ fi
     esac
   fi
 
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -5719,7 +5748,7 @@ if ${lt_cv_sys_max_cmd_len+:} false; then :
   $as_echo_n "(cached) " >&6
 else
     i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -5759,7 +5788,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -5810,22 +5839,22 @@ else
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -5843,7 +5872,7 @@ else
 
 fi
 
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 else
@@ -5861,30 +5890,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
-$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
-$as_echo "$xsi_shell" >&6; }
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
-$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
-$as_echo "$lt_shell_append" >&6; }
-
-
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
@@ -6007,13 +6012,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -6141,13 +6146,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[4-9]*)
@@ -6174,8 +6179,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -6271,8 +6275,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
@@ -6325,6 +6329,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 
 fi
@@ -6482,8 +6489,8 @@ else
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -6495,7 +6502,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 
@@ -6649,7 +6656,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
@@ -6657,7 +6664,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -6670,7 +6677,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
 $as_echo "$lt_cv_ar_at_file" >&6; }
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -6887,7 +6894,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -7019,7 +7026,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[ABCDEGRST]'
   fi
   ;;
@@ -7052,14 +7059,44 @@ case `$NM -V 2>&1` in
   symcode='[ABCDGIRSTW]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -7077,21 +7114,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK '"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -7139,11 +7179,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
@@ -7169,7 +7209,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -7189,13 +7229,13 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
 	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -7216,7 +7256,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -7269,6 +7309,16 @@ fi
 
 
 
+
+
+
+
+
+
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
 $as_echo_n "checking for sysroot... " >&6; }
 
@@ -7281,9 +7331,9 @@ fi
 
 
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -7293,8 +7343,8 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
-$as_echo "${with_sysroot}" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+$as_echo "$with_sysroot" >&6; }
    as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
    ;;
 esac
@@ -7306,18 +7356,99 @@ $as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+$as_echo_n "checking for a working dd... " >&6; }
+if ${ac_cv_path_lt_DD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+if test -z "$lt_DD"; then
+  ac_path_lt_DD_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in dd; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_lt_DD" || continue
+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi
+      $ac_path_lt_DD_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_lt_DD"; then
+    :
+  fi
+else
+  ac_cv_path_lt_DD=$lt_DD
+fi
+
+rm -f conftest.i conftest2.i conftest.out
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+$as_echo "$ac_cv_path_lt_DD" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+$as_echo_n "checking how to truncate binary pipes... " >&6; }
+if ${lt_cv_truncate_bin+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+$as_echo "$lt_cv_truncate_bin" >&6; }
+
+
+
+
+
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
 # Check whether --enable-libtool-lock was given.
 if test "${enable_libtool_lock+set}" = set; then :
   enableval=$enable_libtool_lock;
 fi
 
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7326,24 +7457,25 @@ ia64-*-hpux*)
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '#line '$LINENO' "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -7372,9 +7504,50 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7397,10 +7570,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -7419,10 +7592,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -7440,7 +7613,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
@@ -7480,13 +7653,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
 $as_echo "$lt_cv_cc_needs_belf" >&6; }
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -7498,7 +7672,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -7507,7 +7681,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -7523,7 +7697,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
@@ -7634,7 +7808,7 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
 $as_echo "$lt_cv_path_mainfest_tool" >&6; }
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 
@@ -8137,7 +8311,7 @@ if ${lt_cv_apple_cc_single_mod+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -8155,7 +8329,7 @@ else
 	  cat conftest.err >&5
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&5
@@ -8194,7 +8368,7 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
@@ -8223,7 +8397,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&5
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&5
@@ -8236,32 +8410,32 @@ fi
 $as_echo "$lt_cv_ld_force_load" >&6; }
     case $host_os in
     rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[012]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[012][,.]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -8269,6 +8443,41 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
     ;;
   esac
 
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -8553,9 +8762,9 @@ done
 
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case $2 in
+  .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;;
   esac
 } # func_stripname_cnf
 
@@ -8582,14 +8791,14 @@ if test "${enable_shared+set}" = set; then :
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8613,14 +8822,14 @@ if test "${enable_static+set}" = set; then :
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8644,14 +8853,14 @@ if test "${with_pic+set}" = set; then :
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8659,8 +8868,6 @@ else
 fi
 
 
-test -z "$pic_mode" && pic_mode=default
-
 
 
 
@@ -8676,14 +8883,14 @@ if test "${enable_fast_install+set}" = set; then :
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8697,11 +8904,63 @@ fi
 
 
 
+  shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[5-9]*,yes)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+$as_echo_n "checking which variant of shared library versioning to provide... " >&6; }
+
+# Check whether --with-aix-soname was given.
+if test "${with_aix_soname+set}" = set; then :
+  withval=$with_aix_soname; case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname
+else
+  if ${lt_cv_with_aix_soname+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_with_aix_soname=aix
+fi
+
+    with_aix_soname=$lt_cv_with_aix_soname
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+$as_echo "$with_aix_soname" >&6; }
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+
+
+
+
+
+
 
 
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -8750,7 +9009,7 @@ test -z "$LN_S" && LN_S="ln -s"
 
 
 
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -8789,7 +9048,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -8800,14 +9059,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -8816,15 +9075,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$LD" && LD=ld
 test -z "$ac_objext" && ac_objext=o
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
 # Only perform the check for file, if the check method requires it
@@ -8839,22 +9091,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+    if test -f "$ac_dir/${ac_tool_prefix}file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8877,13 +9129,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8905,22 +9157,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+    if test -f "$ac_dir/file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8943,13 +9195,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8970,7 +9222,7 @@ esac
 
 # Use C for the default configuration in the libtool script
 
-lt_save_CC="$CC"
+lt_save_CC=$CC
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -9032,7 +9284,7 @@ if test -n "$compiler"; then
 
 lt_prog_compiler_no_builtin_flag=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
@@ -9048,7 +9300,7 @@ else
   lt_cv_prog_compiler_rtti_exceptions=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -9078,7 +9330,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
     lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
 else
     :
@@ -9096,17 +9348,18 @@ lt_prog_compiler_pic=
 lt_prog_compiler_static=
 
 
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     lt_prog_compiler_wl='-Wl,'
     lt_prog_compiler_static='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       fi
+      lt_prog_compiler_pic='-fPIC'
       ;;
 
     amigaos*)
@@ -9117,8 +9370,8 @@ lt_prog_compiler_static=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -9134,6 +9387,11 @@ lt_prog_compiler_static=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -9204,7 +9462,7 @@ lt_prog_compiler_static=
     case $host_os in
     aix*)
       lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       else
@@ -9212,10 +9470,29 @@ lt_prog_compiler_static=
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        lt_prog_compiler_wl='-Wl,-Wl,,'
+        lt_prog_compiler_pic='-PIC'
+        lt_prog_compiler_static='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -9231,7 +9508,7 @@ lt_prog_compiler_static=
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      lt_prog_compiler_static='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -9242,7 +9519,7 @@ lt_prog_compiler_static=
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
@@ -9267,6 +9544,12 @@ lt_prog_compiler_static=
 	lt_prog_compiler_pic='-PIC'
 	lt_prog_compiler_static='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -9364,7 +9647,7 @@ lt_prog_compiler_static=
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	lt_prog_compiler_pic='-Kconform_pic'
 	lt_prog_compiler_static='-Bstatic'
       fi
@@ -9393,7 +9676,7 @@ lt_prog_compiler_static=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
     ;;
@@ -9425,7 +9708,7 @@ else
   lt_cv_prog_compiler_pic_works=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -9455,7 +9738,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works"; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -9487,7 +9770,7 @@ if ${lt_cv_prog_compiler_static_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -9506,13 +9789,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works"; then
     :
 else
     lt_prog_compiler_static=
@@ -9632,8 +9915,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -9645,9 +9928,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -9690,9 +9973,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # included in the symbol list
   include_expsyms=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -9707,7 +9990,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -9715,7 +9998,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
   linux* | k*bsd*-gnu | gnu*)
@@ -9728,7 +10011,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -9750,24 +10033,24 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
+    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+    export_dynamic_flag_spec='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       whole_archive_flag_spec=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -9780,7 +10063,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     case $host_os in
     aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
@@ -9799,7 +10082,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -9815,7 +10098,7 @@ _LT_EOF
 	allow_undefined_flag=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9825,7 +10108,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      export_dynamic_flag_spec='$wl--export-all-symbols'
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
@@ -9833,61 +10116,89 @@ _LT_EOF
       exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	ld_shlibs=no
       fi
       ;;
 
     haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       link_all_deplibs=yes
       ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
     interix[3-9]*)
       hardcode_direct=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
+      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+      export_dynamic_flag_spec='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -9898,42 +10209,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  whole_archive_flag_spec=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  export_dynamic_flag_spec='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	  hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
 	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -9947,8 +10263,8 @@ _LT_EOF
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -9966,8 +10282,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9979,7 +10295,7 @@ _LT_EOF
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -9994,9 +10310,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    ld_shlibs=no
 	  fi
@@ -10013,15 +10329,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
+    if test no = "$ld_shlibs"; then
       runpath_var=
       hardcode_libdir_flag_spec=
       export_dynamic_flag_spec=
@@ -10037,7 +10353,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
@@ -10045,34 +10361,57 @@ _LT_EOF
       ;;
 
     aix[4-9]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -10091,13 +10430,21 @@ _LT_EOF
       hardcode_direct_absolute=yes
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      file_list_spec='${wl}-f,'
+      file_list_spec='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	hardcode_direct=no
+	hardcode_direct_absolute=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -10116,36 +10463,42 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	link_all_deplibs=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      export_dynamic_flag_spec='${wl}-bexpall'
+      export_dynamic_flag_spec='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	allow_undefined_flag='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
+        if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -10180,7 +10533,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -10188,17 +10541,17 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
+	 if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -10233,7 +10586,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -10241,21 +10594,33 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  no_undefined_flag=' $wl-bernotok'
+	  allow_undefined_flag=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    whole_archive_flag_spec='$convenience'
 	  fi
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) >  [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -10264,7 +10629,7 @@ fi
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -10294,16 +10659,17 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
 	enable_shared_with_static_runtimes=yes
@@ -10312,18 +10678,18 @@ fi
 	# Don't use ranlib
 	old_postinstall_cmds='chmod 644 $oldlib'
 	postlink_cmds='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -10332,7 +10698,7 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -10351,24 +10717,24 @@ fi
   hardcode_direct=no
   hardcode_automatic=yes
   hardcode_shlibpath_var=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec=''
   fi
   link_all_deplibs=yes
-  allow_undefined_flag="$_lt_dar_allow_undefined"
+  allow_undefined_flag=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
   else
   ld_shlibs=no
@@ -10410,33 +10776,33 @@ fi
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_direct=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
+      export_dynamic_flag_spec='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 	hardcode_direct=yes
 	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='${wl}-E'
+	export_dynamic_flag_spec='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	hardcode_minus_L=yes
@@ -10444,25 +10810,25 @@ fi
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 
@@ -10474,7 +10840,7 @@ if ${lt_cv_prog_compiler__b+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler__b=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS -b"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -10493,14 +10859,14 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
 $as_echo "$lt_cv_prog_compiler__b" >&6; }
 
-if test x"$lt_cv_prog_compiler__b" = xyes; then
-    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+if test yes = "$lt_cv_prog_compiler__b"; then
+    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 else
     archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 fi
@@ -10508,8 +10874,8 @@ fi
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 
 	case $host_cpu in
@@ -10520,7 +10886,7 @@ fi
 	*)
 	  hardcode_direct=yes
 	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='${wl}-E'
+	  export_dynamic_flag_spec='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -10531,8 +10897,8 @@ fi
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
@@ -10542,8 +10908,8 @@ $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >
 if ${lt_cv_irix_exported_symbol+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+  save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo (void) { return 0; }
@@ -10555,24 +10921,35 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
+           LDFLAGS=$save_LDFLAGS
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
 $as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
+	link_all_deplibs=no
       else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       inherit_rpath=yes
       link_all_deplibs=yes
       ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	ld_shlibs=yes
+	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
     netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -10587,7 +10964,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     newsos6)
       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_shlibpath_var=no
       ;;
@@ -10595,27 +10972,19 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	hardcode_direct=yes
 	hardcode_shlibpath_var=no
 	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec='${wl}-E'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	  export_dynamic_flag_spec='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
 	fi
       else
 	ld_shlibs=no
@@ -10626,33 +10995,53 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       hardcode_libdir_flag_spec='-L$libdir'
       hardcode_minus_L=yes
       allow_undefined_flag=unsupported
-      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -10663,24 +11052,24 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
     solaris*)
       no_undefined_flag=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -10690,11 +11079,11 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       solaris2.[0-5] | solaris2.[0-5].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
 	fi
@@ -10704,10 +11093,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -10756,43 +11145,43 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='${wl}-z,text'
+      no_undefined_flag='$wl-z,text'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
+      no_undefined_flag='$wl-z,text'
+      allow_undefined_flag='$wl-z,nodefs'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_flag_spec='$wl-R,$libdir'
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
+      export_dynamic_flag_spec='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -10807,10 +11196,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	export_dynamic_flag_spec='$wl-Blargedynsym'
 	;;
       esac
     fi
@@ -10818,7 +11207,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
 $as_echo "$ld_shlibs" >&6; }
-test "$ld_shlibs" = no && can_build_shared=no
+test no = "$ld_shlibs" && can_build_shared=no
 
 with_gnu_ld=$with_gnu_ld
 
@@ -10844,7 +11233,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -11059,14 +11448,14 @@ esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -11082,28 +11471,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -11117,7 +11513,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -11126,7 +11522,7 @@ fi
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -11143,14 +11539,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -11158,41 +11556,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -11202,18 +11650,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -11221,8 +11669,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -11234,7 +11682,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -11243,8 +11691,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -11260,17 +11708,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -11279,8 +11727,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -11307,7 +11755,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -11320,8 +11768,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -11334,7 +11782,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -11347,8 +11795,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -11361,8 +11809,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -11380,12 +11828,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -11415,10 +11864,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -11436,14 +11885,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -11451,8 +11901,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -11461,8 +11911,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -11475,8 +11925,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -11487,7 +11937,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -11495,8 +11945,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -11515,8 +11965,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -11525,13 +11975,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -11575,7 +12045,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -11607,12 +12082,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -11622,7 +12097,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -11631,58 +12106,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -11693,8 +12178,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -11704,11 +12189,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -11716,8 +12201,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -11738,24 +12223,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -11773,7 +12258,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -11781,8 +12266,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -11792,20 +12277,35 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
+
+
+
 
 
 
@@ -11902,15 +12402,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" ||
    test -n "$runpath_var" ||
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test yes = "$hardcode_automatic"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct" != no &&
+  if test no != "$hardcode_direct" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
+     test no != "$hardcode_minus_L"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action=relink
   else
@@ -11925,12 +12425,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
 $as_echo "$hardcode_action" >&6; }
 
-if test "$hardcode_action" = relink ||
-   test "$inherit_rpath" = yes; then
+if test relink = "$hardcode_action" ||
+   test yes = "$inherit_rpath"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -11940,7 +12440,7 @@ fi
 
 
 
-  if test "x$enable_dlopen" != xyes; then
+  if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -11950,23 +12450,23 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
 if ${ac_cv_lib_dl_dlopen+:} false; then :
@@ -12004,10 +12504,10 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
 
-    lt_cv_dlopen="dyld"
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
 
@@ -12015,10 +12515,18 @@ fi
 
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
 if test "x$ac_cv_func_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load"
+  lt_cv_dlopen=shl_load
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
 $as_echo_n "checking for shl_load in -ldld... " >&6; }
@@ -12057,11 +12565,11 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
 else
   ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
 if test "x$ac_cv_func_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen"
+  lt_cv_dlopen=dlopen
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
@@ -12100,7 +12608,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
@@ -12139,7 +12647,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
 $as_echo_n "checking for dld_link in -ldld... " >&6; }
@@ -12178,7 +12686,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
 
 
@@ -12199,21 +12707,21 @@ fi
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
@@ -12221,7 +12729,7 @@ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -12268,9 +12776,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -12300,7 +12808,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -12320,14 +12828,14 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
 $as_echo "$lt_cv_dlopen_self" >&6; }
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self_static+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self_static=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -12374,9 +12882,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -12406,7 +12914,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -12427,9 +12935,9 @@ fi
 $as_echo "$lt_cv_dlopen_self_static" >&6; }
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -12473,7 +12981,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -12501,7 +13009,7 @@ fi
 
 
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
 $as_echo_n "checking if libtool supports shared libraries... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
@@ -12509,13 +13017,13 @@ $as_echo "$can_build_shared" >&6; }
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
 $as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -12523,8 +13031,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     ;;
 
   aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -12534,7 +13046,7 @@ $as_echo "$enable_shared" >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
 $as_echo_n "checking whether to build static libraries... " >&6; }
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
 $as_echo "$enable_static" >&6; }
 
@@ -12548,11 +13060,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-CC="$lt_save_CC"
+CC=$lt_save_CC
 
-      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+      if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -12731,7 +13243,7 @@ objext_CXX=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -12792,46 +13304,39 @@ $RM -r conftest*
   CFLAGS=$CXXFLAGS
   compiler=$CC
   compiler_CXX=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+  func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
     else
       lt_prog_compiler_no_builtin_flag_CXX=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
 
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -12845,7 +13350,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -12856,7 +13361,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -12867,32 +13372,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -12928,22 +13433,22 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+        export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           whole_archive_flag_spec_CXX=
         fi
@@ -12980,18 +13485,30 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         ld_shlibs_CXX=no
         ;;
       aix[4-9]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -13001,6 +13518,13 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -13019,13 +13543,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         hardcode_direct_absolute_CXX=yes
         hardcode_libdir_separator_CXX=':'
         link_all_deplibs_CXX=yes
-        file_list_spec_CXX='${wl}-f,'
+        file_list_spec_CXX='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          hardcode_direct_CXX=no
+          hardcode_direct_absolute_CXX=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[012]|aix4.[012].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -13043,36 +13575,44 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        export_dynamic_flag_spec_CXX='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         always_export_symbols_CXX=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          allow_undefined_flag_CXX='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          no_undefined_flag_CXX='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
-          if test "${lt_cv_aix_libpath+set}" = set; then
+          if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -13107,7 +13647,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -13115,18 +13655,18 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+          hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib'
 	    allow_undefined_flag_CXX="-z nodefs"
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
-	    if test "${lt_cv_aix_libpath+set}" = set; then
+	    if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -13161,7 +13701,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -13169,22 +13709,34 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    no_undefined_flag_CXX=' ${wl}-bernotok'
-	    allow_undefined_flag_CXX=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    no_undefined_flag_CXX=' $wl-bernotok'
+	    allow_undefined_flag_CXX=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      whole_archive_flag_spec_CXX='$convenience'
 	    fi
 	    archive_cmds_need_lc_CXX=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_sy [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -13194,7 +13746,7 @@ fi
 	  allow_undefined_flag_CXX=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  ld_shlibs_CXX=no
 	fi
@@ -13222,57 +13774,58 @@ fi
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
 	  enable_shared_with_static_runtimes_CXX=yes
 	  # Don't use ranlib
 	  old_postinstall_cmds_CXX='chmod 644 $oldlib'
 	  postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  hardcode_libdir_flag_spec_CXX='-L$libdir'
-	  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+	  export_dynamic_flag_spec_CXX='$wl--export-all-symbols'
 	  allow_undefined_flag_CXX=unsupported
 	  always_export_symbols_CXX=no
 	  enable_shared_with_static_runtimes_CXX=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    ld_shlibs_CXX=no
 	  fi
@@ -13286,27 +13839,27 @@ fi
   hardcode_direct_CXX=no
   hardcode_automatic_CXX=yes
   hardcode_shlibpath_var_CXX=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec_CXX=''
   fi
   link_all_deplibs_CXX=yes
-  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  allow_undefined_flag_CXX=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
+       if test yes != "$lt_cv_apple_cc_single_mod"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 
   else
@@ -13315,6 +13868,34 @@ fi
 
 	;;
 
+      os2*)
+	hardcode_libdir_flag_spec_CXX='-L$libdir'
+	hardcode_minus_L_CXX=yes
+	allow_undefined_flag_CXX=unsupported
+	shrext_cmds=.dll
+	archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	enable_shared_with_static_runtimes_CXX=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -13350,14 +13931,14 @@ fi
         ;;
 
       haiku*)
-        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         link_all_deplibs_CXX=yes
         ;;
 
       hpux9*)
-        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
         hardcode_libdir_separator_CXX=:
-        export_dynamic_flag_spec_CXX='${wl}-E'
+        export_dynamic_flag_spec_CXX='$wl-E'
         hardcode_direct_CXX=yes
         hardcode_minus_L_CXX=yes # Not in the search PATH,
 				             # but as the default
@@ -13369,7 +13950,7 @@ fi
             ld_shlibs_CXX=no
             ;;
           aCC*)
-            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -13378,11 +13959,11 @@ fi
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               ld_shlibs_CXX=no
@@ -13392,15 +13973,15 @@ fi
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
 	  hardcode_libdir_separator_CXX=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      export_dynamic_flag_spec_CXX='${wl}-E'
+	      export_dynamic_flag_spec_CXX='$wl-E'
               ;;
           esac
         fi
@@ -13426,13 +14007,13 @@ fi
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -13443,20 +14024,20 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -13471,22 +14052,22 @@ fi
       interix[3-9]*)
 	hardcode_direct_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}-E'
+	hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -13495,17 +14076,17 @@ fi
 	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    link_all_deplibs_CXX=yes
 	    ;;
         esac
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
         hardcode_libdir_separator_CXX=:
         inherit_rpath_CXX=yes
         ;;
@@ -13518,8 +14099,8 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -13528,10 +14109,10 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -13545,59 +14126,59 @@ fi
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    archive_cmds_need_lc_CXX=no
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
 	      prelink_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      old_archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      archive_expsym_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -13611,18 +14192,18 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -13630,10 +14211,10 @@ fi
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      no_undefined_flag_CXX=' -zdefs'
-	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      hardcode_libdir_flag_spec_CXX='-R$libdir'
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      compiler_needs_object_CXX=yes
 
 	      # Not sure whether something based on
@@ -13691,22 +14272,17 @@ fi
         ld_shlibs_CXX=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	ld_shlibs_CXX=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  hardcode_direct_CXX=yes
 	  hardcode_shlibpath_var_CXX=no
 	  hardcode_direct_absolute_CXX=yes
 	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    export_dynamic_flag_spec_CXX='${wl}-E'
-	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='$wl-E'
+	    whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -13722,9 +14298,9 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
 	    hardcode_libdir_separator_CXX=:
 
 	    # Archives containing C++ object files must be created using
@@ -13742,17 +14318,17 @@ fi
           cxx*)
 	    case $host in
 	      osf3*)
-	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	        allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        allow_undefined_flag_CXX=' -expect_unresolved \*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
 		;;
 	    esac
@@ -13767,21 +14343,21 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 	      hardcode_libdir_separator_CXX=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -13827,9 +14403,9 @@ fi
 	    # Sun C++ 4.2, 5.x and Centerline C++
             archive_cmds_need_lc_CXX=yes
 	    no_undefined_flag_CXX=' -zdefs'
-	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    hardcode_libdir_flag_spec_CXX='-R$libdir'
 	    hardcode_shlibpath_var_CXX=no
@@ -13837,7 +14413,7 @@ fi
 	      solaris2.[0-5] | solaris2.[0-5].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -13854,30 +14430,30 @@ fi
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      no_undefined_flag_CXX=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -13885,11 +14461,11 @@ fi
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[0-5] | solaris2.[0-5].*) ;;
 		*)
-		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -13898,52 +14474,52 @@ fi
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_CXX='${wl}-z,text'
+      no_undefined_flag_CXX='$wl-z,text'
       archive_cmds_need_lc_CXX=no
       hardcode_shlibpath_var_CXX=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	no_undefined_flag_CXX='${wl}-z,text'
-	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	no_undefined_flag_CXX='$wl-z,text'
+	allow_undefined_flag_CXX='$wl-z,nodefs'
 	archive_cmds_need_lc_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_flag_spec_CXX='$wl-R,$libdir'
 	hardcode_libdir_separator_CXX=':'
 	link_all_deplibs_CXX=yes
-	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	export_dynamic_flag_spec_CXX='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
-	      '"$old_archive_cmds_CXX"
+              '"$old_archive_cmds_CXX"
 	    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
-	      '"$reload_cmds_CXX"
+              '"$reload_cmds_CXX"
 	    ;;
 	  *)
-	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -13975,10 +14551,10 @@ fi
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-    test "$ld_shlibs_CXX" = no && can_build_shared=no
+    test no = "$ld_shlibs_CXX" && can_build_shared=no
 
-    GCC_CXX="$GXX"
-    LD_CXX="$LD"
+    GCC_CXX=$GXX
+    LD_CXX=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -14022,13 +14598,13 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -14044,16 +14620,16 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$compiler_lib_search_path_CXX"; then
-	     compiler_lib_search_path_CXX="${prev}${p}"
+	     compiler_lib_search_path_CXX=$prev$p
 	   else
-	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -14061,9 +14637,9 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 esac
        else
 	 if test -z "$postdeps_CXX"; then
-	   postdeps_CXX="${prev}${p}"
+	   postdeps_CXX=$prev$p
 	 else
-	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	   postdeps_CXX="${postdeps_CXX} $prev$p"
 	 fi
        fi
        prev=
@@ -14078,15 +14654,15 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$predep_objects_CXX"; then
-	   predep_objects_CXX="$p"
+	   predep_objects_CXX=$p
 	 else
 	   predep_objects_CXX="$predep_objects_CXX $p"
 	 fi
        else
 	 if test -z "$postdep_objects_CXX"; then
-	   postdep_objects_CXX="$p"
+	   postdep_objects_CXX=$p
 	 else
 	   postdep_objects_CXX="$postdep_objects_CXX $p"
 	 fi
@@ -14116,51 +14692,6 @@ interix[3-9]*)
   postdep_objects_CXX=
   postdeps_CXX=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 
 
@@ -14169,7 +14700,7 @@ case " $postdeps_CXX " in
 esac
  compiler_lib_search_dirs_CXX=
 if test -n "${compiler_lib_search_path_CXX}"; then
- compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 
 
@@ -14208,17 +14739,18 @@ lt_prog_compiler_static_CXX=
 
 
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     lt_prog_compiler_wl_CXX='-Wl,'
     lt_prog_compiler_static_CXX='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static_CXX='-Bstatic'
       fi
+      lt_prog_compiler_pic_CXX='-fPIC'
       ;;
 
     amigaos*)
@@ -14229,8 +14761,8 @@ lt_prog_compiler_static_CXX=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -14245,6 +14777,11 @@ lt_prog_compiler_static_CXX=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static_CXX='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -14294,7 +14831,7 @@ lt_prog_compiler_static_CXX=
     case $host_os in
       aix[4-9]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  lt_prog_compiler_static_CXX='-Bstatic'
 	else
@@ -14334,14 +14871,14 @@ lt_prog_compiler_static_CXX=
 	case $cc_basename in
 	  CC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -14378,7 +14915,7 @@ lt_prog_compiler_static_CXX=
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
@@ -14523,7 +15060,7 @@ lt_prog_compiler_static_CXX=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
     ;;
@@ -14555,7 +15092,7 @@ else
   lt_cv_prog_compiler_pic_works_CXX=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -14585,7 +15122,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then
     case $lt_prog_compiler_pic_CXX in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
@@ -14611,7 +15148,7 @@ if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -14630,13 +15167,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then
     :
 else
     lt_prog_compiler_static_CXX=
@@ -14750,8 +15287,8 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -14763,9 +15300,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -14782,17 +15319,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   case $host_os in
   aix[4-9]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    export_symbols_cmds_CXX="$ltdll_cmds"
+    export_symbols_cmds_CXX=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -14815,7 +15356,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-test "$ld_shlibs_CXX" = no && can_build_shared=no
+test no = "$ld_shlibs_CXX" && can_build_shared=no
 
 with_gnu_ld_CXX=$with_gnu_ld
 
@@ -14832,7 +15373,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc_CXX=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds_CXX in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -14960,7 +15501,7 @@ $as_echo_n "checking dynamic linker characteristics... " >&6; }
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -14977,14 +15518,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -14992,41 +15535,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -15036,18 +15629,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -15055,8 +15648,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -15068,7 +15661,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -15077,8 +15670,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -15094,16 +15687,16 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -15112,8 +15705,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -15140,7 +15733,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -15153,8 +15746,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -15167,7 +15760,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -15180,8 +15773,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -15193,8 +15786,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -15212,12 +15805,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -15247,10 +15841,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -15268,14 +15862,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -15283,8 +15878,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -15293,8 +15888,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -15307,8 +15902,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -15319,7 +15914,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -15327,8 +15922,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -15347,8 +15942,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -15357,13 +15952,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec_CXX='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -15407,7 +16022,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -15439,12 +16059,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -15454,7 +16074,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -15463,58 +16083,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -15525,8 +16155,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -15536,11 +16166,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -15548,8 +16178,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -15570,24 +16200,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -15605,7 +16235,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -15613,8 +16243,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -15624,20 +16254,32 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
 
 
 
@@ -15680,15 +16322,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" ||
    test -n "$runpath_var_CXX" ||
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+   test yes = "$hardcode_automatic_CXX"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct_CXX" != no &&
+  if test no != "$hardcode_direct_CXX" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
-     test "$hardcode_minus_L_CXX" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" &&
+     test no != "$hardcode_minus_L_CXX"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action_CXX=relink
   else
@@ -15703,12 +16345,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
 $as_echo "$hardcode_action_CXX" >&6; }
 
-if test "$hardcode_action_CXX" = relink ||
-   test "$inherit_rpath_CXX" = yes; then
+if test relink = "$hardcode_action_CXX" ||
+   test yes = "$inherit_rpath_CXX"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -15731,7 +16373,7 @@ fi
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -15968,7 +16610,7 @@ fi
 
 
 
-am__api_version='1.14'
+am__api_version='1.15'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -16157,7 +16799,7 @@ else
 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -16400,7 +17042,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='ceph'
- VERSION='10.0.2'
+ VERSION='10.0.3'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -16434,8 +17076,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 mkdir_p='$(MKDIR_P)'
 
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
@@ -16864,6 +17506,7 @@ END
     as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
   fi
 fi
+
 # enable make V=0 (if automake >1.11)
 # Check whether --enable-silent-rules was given.
 if test "${enable_silent_rules+set}" = set; then :
@@ -20696,7 +21339,7 @@ else
 JAVA_TEST=Test.java
 CLASS_TEST=Test.class
 cat << \EOF > $JAVA_TEST
-/* #line 20699 "configure" */
+/* #line 21342 "configure" */
 public class Test {
 }
 EOF
@@ -22392,6 +23035,39 @@ else
 fi
 
 
+# rocksdb detects bzlib and lz4 in its Makefile, which forces us to do the same.
+if test "x$with_librocksdb_static" = "xyes"; then :
+
+  ac_fn_c_check_header_mongrel "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_bzlib_h" = xyes; then :
+  have_bzlib=yes
+fi
+
+
+  ac_fn_c_check_header_mongrel "$LINENO" "lz4.h" "ac_cv_header_lz4_h" "$ac_includes_default"
+if test "x$ac_cv_header_lz4_h" = xyes; then :
+  have_lz4=yes
+fi
+
+
+fi
+ if test "x$have_bzlib" = "xyes"; then
+  HAVE_BZLIB_TRUE=
+  HAVE_BZLIB_FALSE='#'
+else
+  HAVE_BZLIB_TRUE='#'
+  HAVE_BZLIB_FALSE=
+fi
+
+ if test "x$have_lz4" = "xyes"; then
+  HAVE_LZ4_TRUE=
+  HAVE_LZ4_FALSE='#'
+else
+  HAVE_LZ4_TRUE='#'
+  HAVE_LZ4_FALSE=
+fi
+
+
 # error out if --with-jemalloc and --with-librocksdb_static as rocksdb uses tcmalloc
 if test "x$with_jemalloc" = "xyes"; then
 	if test "x$with_librocksdb_static" != "xno"; then
@@ -25346,6 +26022,14 @@ if test -z "${WITH_LIBROCKSDB_TRUE}" && test -z "${WITH_LIBROCKSDB_FALSE}"; then
   as_fn_error $? "conditional \"WITH_LIBROCKSDB\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_BZLIB_TRUE}" && test -z "${HAVE_BZLIB_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_BZLIB\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${HAVE_LZ4_TRUE}" && test -z "${HAVE_LZ4_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_LZ4\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${WITH_LIBAIO_TRUE}" && test -z "${WITH_LIBAIO_FALSE}"; then
   as_fn_error $? "conditional \"WITH_LIBAIO\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -25779,7 +26463,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ceph $as_me 10.0.2, which was
+This file was extended by ceph $as_me 10.0.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -25845,7 +26529,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ceph config.status 10.0.2
+ceph config.status 10.0.3
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -25979,6 +26663,7 @@ enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`'
 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
 PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
@@ -26028,10 +26713,13 @@ compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
 GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`'
 nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
 lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`'
 objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
 MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
@@ -26096,7 +26784,8 @@ finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
 finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
 hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
 sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
-sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`'
+configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`'
 hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
 enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
 enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
@@ -26201,9 +26890,12 @@ CFLAGS \
 compiler \
 lt_cv_sys_global_symbol_pipe \
 lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_import \
 lt_cv_sys_global_symbol_to_c_name_address \
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+lt_cv_nm_interface \
 nm_file_list_spec \
+lt_cv_truncate_bin \
 lt_prog_compiler_no_builtin_flag \
 lt_prog_compiler_pic \
 lt_prog_compiler_wl \
@@ -26269,7 +26961,7 @@ postdeps_CXX \
 compiler_lib_search_path_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -26296,7 +26988,8 @@ postinstall_cmds \
 postuninstall_cmds \
 finish_cmds \
 sys_lib_search_path_spec \
-sys_lib_dlsearch_path_spec \
+configure_time_dlsearch_path \
+configure_time_lt_sys_library_path \
 reload_cmds_CXX \
 old_archive_cmds_CXX \
 old_archive_from_new_cmds_CXX \
@@ -26310,7 +27003,7 @@ prelink_cmds_CXX \
 postlink_cmds_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -26319,19 +27012,16 @@ postlink_cmds_CXX; do
 done
 
 ac_aux_dir='$ac_aux_dir'
-xsi_shell='$xsi_shell'
-lt_shell_append='$lt_shell_append'
 
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
 
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'
 
@@ -26960,55 +27650,53 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
   case $ac_file$ac_mode in
     "libtool":C)
 
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # The names of the tagged configurations supported by this script.
-available_tags="CXX "
+available_tags='CXX '
+
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
 
 # ### BEGIN LIBTOOL CONFIG
 
@@ -27028,6 +27716,9 @@ pic_mode=$pic_mode
 # Whether or not to optimize for fast installation.
 fast_install=$enable_fast_install
 
+# Shared archive member basename,for filename based shared library versioning on AIX.
+shared_archive_member_spec=$shared_archive_member_spec
+
 # Shell to use when invoking shell scripts.
 SHELL=$lt_SHELL
 
@@ -27145,18 +27836,27 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 # Transform the output of nm in a proper C declaration.
 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
+# Transform the output of nm into a list of symbols to manually relocate.
+global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import
+
 # Transform the output of nm in a C name address pair.
 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
 # Transform the output of nm in a C name address pair when lib prefix is needed.
 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 
+# The name lister interface.
+nm_interface=$lt_lt_cv_nm_interface
+
 # Specify filename containing input files for \$NM.
 nm_file_list_spec=$lt_nm_file_list_spec
 
-# The root where to search for dependent libraries,and in which our libraries should be installed.
+# The root where to search for dependent libraries,and where our libraries should be installed.
 lt_sysroot=$lt_sysroot
 
+# Command to truncate a binary pipe.
+lt_truncate_bin=$lt_lt_cv_truncate_bin
+
 # The name of the directory that contains temporary libtool files.
 objdir=$objdir
 
@@ -27247,8 +27947,11 @@ hardcode_into_libs=$hardcode_into_libs
 # Compile-time system search path for libraries.
 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
-# Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+# Detected run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path
+
+# Explicit LT_SYS_LIBRARY_PATH set during ./configure time.
+configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path
 
 # Whether dlopen is supported.
 dlopen_support=$enable_dlopen
@@ -27341,13 +28044,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute
 
@@ -27413,13 +28116,72 @@ compiler_lib_search_path=$lt_compiler_lib_search_path
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -27428,7 +28190,7 @@ _LT_EOF
   esac
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 
   # We use sed instead of cat because bash on DJGPP gets confused if
@@ -27438,165 +28200,6 @@ ltmain="$ac_aux_dir/ltmain.sh"
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  if test x"$xsi_shell" = xyes; then
-  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
-func_dirname ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_basename ()$/,/^} # func_basename /c\
-func_basename ()\
-{\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
-func_dirname_and_basename ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
-func_stripname ()\
-{\
-\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
-\    # positional parameters, so assign one to ordinary parameter first.\
-\    func_stripname_result=${3}\
-\    func_stripname_result=${func_stripname_result#"${1}"}\
-\    func_stripname_result=${func_stripname_result%"${2}"}\
-} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
-func_split_long_opt ()\
-{\
-\    func_split_long_opt_name=${1%%=*}\
-\    func_split_long_opt_arg=${1#*=}\
-} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
-func_split_short_opt ()\
-{\
-\    func_split_short_opt_arg=${1#??}\
-\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
-} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
-func_lo2o ()\
-{\
-\    case ${1} in\
-\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
-\      *)    func_lo2o_result=${1} ;;\
-\    esac\
-} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_xform ()$/,/^} # func_xform /c\
-func_xform ()\
-{\
-    func_xform_result=${1%.*}.lo\
-} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_arith ()$/,/^} # func_arith /c\
-func_arith ()\
-{\
-    func_arith_result=$(( $* ))\
-} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_len ()$/,/^} # func_len /c\
-func_len ()\
-{\
-    func_len_result=${#1}\
-} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  sed -e '/^func_append ()$/,/^} # func_append /c\
-func_append ()\
-{\
-    eval "${1}+=\\${2}"\
-} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
-func_append_quoted ()\
-{\
-\    func_quote_for_eval "${2}"\
-\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
-} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
-$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
-fi
-
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -27683,13 +28286,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute_CXX
 
diff --git a/configure.ac b/configure.ac
index f391a4d..047076e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,7 +8,7 @@ AC_PREREQ(2.59)
 # VERSION define is not used by the code.  It gets a version string
 # from 'git describe'; see src/ceph_ver.[ch]
 
-AC_INIT([ceph], [10.0.2], [ceph-devel at vger.kernel.org])
+AC_INIT([ceph], [10.0.3], [ceph-devel at vger.kernel.org])
 
 AX_CXX_COMPILE_STDCXX_11(, mandatory)
 
@@ -819,6 +819,13 @@ AS_IF([test "x$with_librocksdb_static" = "xyes"],
 AM_CONDITIONAL(WITH_SLIBROCKSDB, [ test "x$with_librocksdb_static" = "xyes" ])
 AM_CONDITIONAL(WITH_LIBROCKSDB, [ test "x$with_librocksdb_static" = "xyes" -o "x$with_librocksdb" = "xyes" ])
 
+# rocksdb detects bzlib and lz4 in its Makefile, which forces us to do the same.
+AS_IF([test "x$with_librocksdb_static" = "xyes"], [
+  AC_CHECK_HEADER([bzlib.h], [have_bzlib=yes])
+  AC_CHECK_HEADER([lz4.h], [have_lz4=yes])])
+AM_CONDITIONAL(HAVE_BZLIB, [test "x$have_bzlib" = "xyes"])
+AM_CONDITIONAL(HAVE_LZ4, [test "x$have_lz4" = "xyes"])
+
 # error out if --with-jemalloc and --with-librocksdb_static as rocksdb uses tcmalloc
 if test "x$with_jemalloc" = "xyes"; then
 	if test "x$with_librocksdb_static" != "xno"; then
diff --git a/depcomp b/depcomp
index 4ebd5b3..fc98710 100755
--- a/depcomp
+++ b/depcomp
@@ -3,7 +3,7 @@
 
 scriptversion=2013-05-30.07; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 13fb9a0..f590595 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -79,7 +89,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = doc
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/ac_prog_jar.m4 \
@@ -98,6 +107,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/acconfig.h
 CONFIG_CLEAN_FILES =
@@ -122,6 +132,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -212,6 +223,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -308,6 +320,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -374,7 +387,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign doc/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -549,6 +561,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/doc/man/8/rados.rst b/doc/man/8/rados.rst
index ce8a803..fadfb72 100644
--- a/doc/man/8/rados.rst
+++ b/doc/man/8/rados.rst
@@ -92,6 +92,9 @@ Pool specific commands
 :command:`rm` *name*
   Remove object name.
 
+:command:`listwatchers` *name*
+  List the watchers of object name.
+
 :command:`ls` *outfile*
   List objects in given pool and write to outfile.
 
@@ -113,7 +116,9 @@ Pool specific commands
   sequential or random. Before running one of the reading benchmarks,
   run a write benchmark with the *--no-cleanup* option. The default
   object size is 4 MB, and the default number of simulated threads
-  (parallel writes) is 16.
+  (parallel writes) is 16. The *--run-name <label>* option is useful
+  for benchmarking a workload test from multiple clients. The *<label>*
+  is an arbitrary object name.
   Note: -b *objsize* option is valid only in *write* mode.
 
 :command:`cleanup`
diff --git a/doc/man/8/radosgw-admin.rst b/doc/man/8/radosgw-admin.rst
index f0c19f4..a523a63 100644
--- a/doc/man/8/radosgw-admin.rst
+++ b/doc/man/8/radosgw-admin.rst
@@ -148,6 +148,7 @@ which are as follows:
 
 :command:`log show`
   Dump a log from specific object or (bucket + date + bucket-id).
+  (NOTE: required to specify formatting of date to "YYYY-MM-DD-hh")
 
 :command:`log rm`
   Remove log object.
@@ -432,7 +433,7 @@ Remove a bucket::
 
 Show the logs of a bucket from April 1st, 2012::
 
-        $ radosgw-admin log show --bucket=foo --date=2012-04-01
+        $ radosgw-admin log show --bucket=foo --date=2012-04-01-01 --bucket-id=default.14193.1
 
 Show usage information for user from March 1st to (but not including) April 1st, 2012::
 
diff --git a/install-sh b/install-sh
index 377bb86..59990a1 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2011-11-20.07; # UTC
+scriptversion=2014-09-12.12; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
 # This script is compatible with the BSD install script, but was written
 # from scratch.
 
+tab='	'
 nl='
 '
-IFS=" ""	$nl"
+IFS=" $tab$nl"
 
-# set DOITPROG to echo to test this script
+# Set DOITPROG to "echo" to test this script.
 
-# Don't use :- since 4.3BSD and earlier shells don't like it.
 doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
+doit_exec=${doit:-exec}
 
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
 rmprog=${RMPROG-rm}
 stripprog=${STRIPPROG-strip}
 
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
 posix_mkdir=
 
 # Desired mode of installed file.
@@ -97,7 +82,7 @@ dir_arg=
 dst_arg=
 
 copy_on_change=false
-no_target_directory=
+is_target_a_directory=possibly
 
 usage="\
 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -137,46 +122,57 @@ while test $# -ne 0; do
     -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-	shift;;
+        shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-	case $mode in
-	  *' '* | *'	'* | *'
-'*	  | *'*'* | *'?'* | *'['*)
-	    echo "$0: invalid mode: $mode" >&2
-	    exit 1;;
-	esac
-	shift;;
+        case $mode in
+          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+            echo "$0: invalid mode: $mode" >&2
+            exit 1;;
+        esac
+        shift;;
 
     -o) chowncmd="$chownprog $2"
-	shift;;
+        shift;;
 
     -s) stripcmd=$stripprog;;
 
-    -t) dst_arg=$2
-	# Protect names problematic for 'test' and other utilities.
-	case $dst_arg in
-	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
-	esac
-	shift;;
+    -t)
+        is_target_a_directory=always
+        dst_arg=$2
+        # Protect names problematic for 'test' and other utilities.
+        case $dst_arg in
+          -* | [=\(\)!]) dst_arg=./$dst_arg;;
+        esac
+        shift;;
 
-    -T) no_target_directory=true;;
+    -T) is_target_a_directory=never;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    --)	shift
-	break;;
+    --) shift
+        break;;
 
-    -*)	echo "$0: invalid option: $1" >&2
-	exit 1;;
+    -*) echo "$0: invalid option: $1" >&2
+        exit 1;;
 
     *)  break;;
   esac
   shift
 done
 
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
+
+if test -n "$dir_arg"; then
+  if test -n "$dst_arg"; then
+    echo "$0: target directory not allowed when installing a directory." >&2
+    exit 1
+  fi
+fi
+
 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
@@ -208,6 +204,15 @@ if test $# -eq 0; then
 fi
 
 if test -z "$dir_arg"; then
+  if test $# -gt 1 || test "$is_target_a_directory" = always; then
+    if test ! -d "$dst_arg"; then
+      echo "$0: $dst_arg: Is not a directory." >&2
+      exit 1
+    fi
+  fi
+fi
+
+if test -z "$dir_arg"; then
   do_exit='(exit $ret); exit $ret'
   trap "ret=129; $do_exit" 1
   trap "ret=130; $do_exit" 2
@@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
 
     *[0-7])
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw='% 200'
+        u_plus_rw='% 200'
       fi
       cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
     *)
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw=,u+rw
+        u_plus_rw=,u+rw
       fi
       cp_umask=$mode$u_plus_rw;;
   esac
@@ -269,41 +274,15 @@ do
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-	echo "$0: $dst_arg: Is a directory" >&2
-	exit 1
+      if test "$is_target_a_directory" = never; then
+        echo "$0: $dst_arg: Is a directory" >&2
+        exit 1
       fi
       dstdir=$dst
       dst=$dstdir/`basename "$src"`
       dstdir_status=0
     else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-	(dirname "$dst") 2>/dev/null ||
-	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	     X"$dst" : 'X\(//\)[^/]' \| \
-	     X"$dst" : 'X\(//\)$' \| \
-	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-	echo X"$dst" |
-	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)[^/].*/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\).*/{
-		   s//\1/
-		   q
-		 }
-		 s/.*/./; q'
-      `
-
+      dstdir=`dirname "$dst"`
       test -d "$dstdir"
       dstdir_status=$?
     fi
@@ -314,74 +293,81 @@ do
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-	# Create intermediate dirs using mode 755 as modified by the umask.
-	# This is like FreeBSD 'install' as of 1997-10-28.
-	umask=`umask`
-	case $stripcmd.$umask in
-	  # Optimize common cases.
-	  *[2367][2367]) mkdir_umask=$umask;;
-	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-	  *[0-7])
-	    mkdir_umask=`expr $umask + 22 \
-	      - $umask % 100 % 40 + $umask % 20 \
-	      - $umask % 10 % 4 + $umask % 2
-	    `;;
-	  *) mkdir_umask=$umask,go-w;;
-	esac
-
-	# With -d, create the new directory with the user-specified mode.
-	# Otherwise, rely on $mkdir_umask.
-	if test -n "$dir_arg"; then
-	  mkdir_mode=-m$mode
-	else
-	  mkdir_mode=
-	fi
-
-	posix_mkdir=false
-	case $umask in
-	  *[123567][0-7][0-7])
-	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-	    ;;
-	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-	    if (umask $mkdir_umask &&
-		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-	    then
-	      if test -z "$dir_arg" || {
-		   # Check for POSIX incompatibilities with -m.
-		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writable bit of parent directory when it shouldn't.
-		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-		   case $ls_ld_tmpdir in
-		     d????-?r-*) different_mode=700;;
-		     d????-?--*) different_mode=755;;
-		     *) false;;
-		   esac &&
-		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-		   }
-		 }
-	      then posix_mkdir=:
-	      fi
-	      rmdir "$tmpdir/d" "$tmpdir"
-	    else
-	      # Remove any dirs left behind by ancient mkdir implementations.
-	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-	    fi
-	    trap '' 0;;
-	esac;;
+        # Create intermediate dirs using mode 755 as modified by the umask.
+        # This is like FreeBSD 'install' as of 1997-10-28.
+        umask=`umask`
+        case $stripcmd.$umask in
+          # Optimize common cases.
+          *[2367][2367]) mkdir_umask=$umask;;
+          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+          *[0-7])
+            mkdir_umask=`expr $umask + 22 \
+              - $umask % 100 % 40 + $umask % 20 \
+              - $umask % 10 % 4 + $umask % 2
+            `;;
+          *) mkdir_umask=$umask,go-w;;
+        esac
+
+        # With -d, create the new directory with the user-specified mode.
+        # Otherwise, rely on $mkdir_umask.
+        if test -n "$dir_arg"; then
+          mkdir_mode=-m$mode
+        else
+          mkdir_mode=
+        fi
+
+        posix_mkdir=false
+        case $umask in
+          *[123567][0-7][0-7])
+            # POSIX mkdir -p sets u+wx bits regardless of umask, which
+            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+            ;;
+          *)
+            # $RANDOM is not portable (e.g. dash);  use it when possible to
+            # lower collision chance
+            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+            trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+            # As "mkdir -p" follows symlinks and we work in /tmp possibly;  so
+            # create the $tmpdir first (and fail if unsuccessful) to make sure
+            # that nobody tries to guess the $tmpdir name.
+            if (umask $mkdir_umask &&
+                $mkdirprog $mkdir_mode "$tmpdir" &&
+                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
+            then
+              if test -z "$dir_arg" || {
+                   # Check for POSIX incompatibilities with -m.
+                   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                   # other-writable bit of parent directory when it shouldn't.
+                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                   test_tmpdir="$tmpdir/a"
+                   ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
+                   case $ls_ld_tmpdir in
+                     d????-?r-*) different_mode=700;;
+                     d????-?--*) different_mode=755;;
+                     *) false;;
+                   esac &&
+                   $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+                     ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
+                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                   }
+                 }
+              then posix_mkdir=:
+              fi
+              rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
+            else
+              # Remove any dirs left behind by ancient mkdir implementations.
+              rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
+            fi
+            trap '' 0;;
+        esac;;
     esac
 
     if
       $posix_mkdir && (
-	umask $mkdir_umask &&
-	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+        umask $mkdir_umask &&
+        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
       )
     then :
     else
@@ -391,53 +377,51 @@ do
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-	/*) prefix='/';;
-	[-=\(\)!]*) prefix='./';;
-	*)  prefix='';;
+        /*) prefix='/';;
+        [-=\(\)!]*) prefix='./';;
+        *)  prefix='';;
       esac
 
-      eval "$initialize_posix_glob"
-
       oIFS=$IFS
       IFS=/
-      $posix_glob set -f
+      set -f
       set fnord $dstdir
       shift
-      $posix_glob set +f
+      set +f
       IFS=$oIFS
 
       prefixes=
 
       for d
       do
-	test X"$d" = X && continue
-
-	prefix=$prefix$d
-	if test -d "$prefix"; then
-	  prefixes=
-	else
-	  if $posix_mkdir; then
-	    (umask=$mkdir_umask &&
-	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-	    # Don't fail if two instances are running concurrently.
-	    test -d "$prefix" || exit 1
-	  else
-	    case $prefix in
-	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-	      *) qprefix=$prefix;;
-	    esac
-	    prefixes="$prefixes '$qprefix'"
-	  fi
-	fi
-	prefix=$prefix/
+        test X"$d" = X && continue
+
+        prefix=$prefix$d
+        if test -d "$prefix"; then
+          prefixes=
+        else
+          if $posix_mkdir; then
+            (umask=$mkdir_umask &&
+             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+            # Don't fail if two instances are running concurrently.
+            test -d "$prefix" || exit 1
+          else
+            case $prefix in
+              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+              *) qprefix=$prefix;;
+            esac
+            prefixes="$prefixes '$qprefix'"
+          fi
+        fi
+        prefix=$prefix/
       done
 
       if test -n "$prefixes"; then
-	# Don't fail if two instances are running concurrently.
-	(umask $mkdir_umask &&
-	 eval "\$doit_exec \$mkdirprog $prefixes") ||
-	  test -d "$dstdir" || exit 1
-	obsolete_mkdir_used=true
+        # Don't fail if two instances are running concurrently.
+        (umask $mkdir_umask &&
+         eval "\$doit_exec \$mkdirprog $prefixes") ||
+          test -d "$dstdir" || exit 1
+        obsolete_mkdir_used=true
       fi
     fi
   fi
@@ -472,15 +456,12 @@ do
 
     # If -C, don't bother to copy if it wouldn't change the file.
     if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
+       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
+       set -f &&
        set X $old && old=:$2:$4:$5:$6 &&
        set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
+       set +f &&
        test "$old" = "$new" &&
        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     then
@@ -493,24 +474,24 @@ do
       # to itself, or perhaps because mv is so ancient that it does not
       # support -f.
       {
-	# Now remove or move aside any old file at destination location.
-	# We try this two ways since rm can't unlink itself on some
-	# systems and the destination file might be busy for other
-	# reasons.  In this case, the final cleanup might fail but the new
-	# file should still install successfully.
-	{
-	  test ! -f "$dst" ||
-	  $doit $rmcmd -f "$dst" 2>/dev/null ||
-	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-	  } ||
-	  { echo "$0: cannot unlink or rename $dst" >&2
-	    (exit 1); exit 1
-	  }
-	} &&
-
-	# Now rename the file to the real destination.
-	$doit $mvcmd "$dsttmp" "$dst"
+        # Now remove or move aside any old file at destination location.
+        # We try this two ways since rm can't unlink itself on some
+        # systems and the destination file might be busy for other
+        # reasons.  In this case, the final cleanup might fail but the new
+        # file should still install successfully.
+        {
+          test ! -f "$dst" ||
+          $doit $rmcmd -f "$dst" 2>/dev/null ||
+          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+          } ||
+          { echo "$0: cannot unlink or rename $dst" >&2
+            (exit 1); exit 1
+          }
+        } &&
+
+        # Now rename the file to the real destination.
+        $doit $mvcmd "$dsttmp" "$dst"
       }
     fi || exit 1
 
diff --git a/ltmain.sh b/ltmain.sh
index a356aca..147d758 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1,9 +1,12 @@
+#! /bin/sh
+## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
+##               by inline-source v2014-01-03.01
 
-# libtool (GNU libtool) 2.4.2
+# libtool (GNU libtool) 2.4.6
+# Provide generalized library-building support services.
 # Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2015 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -23,881 +26,2112 @@
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html,
-# or obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Usage: $progname [OPTION]... [MODE-ARG]...
-#
-# Provide generalized library-building support services.
-#
-#       --config             show all configuration variables
-#       --debug              enable verbose shell tracing
-#   -n, --dry-run            display commands without modifying any files
-#       --features           display basic configuration information and exit
-#       --mode=MODE          use operation mode MODE
-#       --preserve-dup-deps  don't remove duplicate dependency libraries
-#       --quiet, --silent    don't print informational messages
-#       --no-quiet, --no-silent
-#                            print informational messages (default)
-#       --no-warn            don't display warning messages
-#       --tag=TAG            use configuration variables from tag TAG
-#   -v, --verbose            print more informational messages than default
-#       --no-verbose         don't print the extra informational messages
-#       --version            print version information
-#   -h, --help, --help-all   print short, long, or detailed help message
-#
-# MODE must be one of the following:
-#
-#         clean              remove files from the build directory
-#         compile            compile a source file into a libtool object
-#         execute            automatically set library path, then run a program
-#         finish             complete the installation of libtool libraries
-#         install            install libraries or executables
-#         link               create a library or an executable
-#         uninstall          remove libraries from an installed directory
-#
-# MODE-ARGS vary depending on the MODE.  When passed as first option,
-# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
-# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
-#
-# When reporting a bug, please describe a test case to reproduce it and
-# include the following information:
-#
-#         host-triplet:	$host
-#         shell:		$SHELL
-#         compiler:		$LTCC
-#         compiler flags:		$LTCFLAGS
-#         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
-#         automake:	$automake_version
-#         autoconf:	$autoconf_version
-#
-# Report bugs to <bug-libtool at gnu.org>.
-# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
-# General help using GNU software: <http://www.gnu.org/gethelp/>.
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
-TIMESTAMP=""
-package_revision=1.3337
+VERSION="2.4.6 Debian-2.4.6-0.1"
+package_revision=2.4.6
 
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Run './libtool --help' for help with using this script from the
+# command line.
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# After configure completes, it has a better idea of some of the
+# shell tools we need than the defaults used by the functions shared
+# with bootstrap, so set those here where they can still be over-
+# ridden by the user, but otherwise take precedence.
+
+: ${AUTOCONF="autoconf"}
+: ${AUTOMAKE="automake"}
+
+
+## -------------------------- ##
+## Source external libraries. ##
+## -------------------------- ##
+
+# Much of our low-level functionality needs to be sourced from external
+# libraries, which are installed to $pkgauxdir.
+
+# Set a version string for this script.
+scriptversion=2015-01-20.17; # UTC
+
+# General shell script boiler plate, and helper functions.
+# Written by Gary V. Vaughan, 2004
+
+# Copyright (C) 2004-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# As a special exception to the GNU General Public License, if you distribute
+# this file as part of a program or library that is built using GNU Libtool,
+# you may include this file under the same distribution terms that you use
+# for the rest of that program.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Evaluate this file near the top of your script to gain access to
+# the functions and variables defined here:
+#
+#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
+#
+# If you need to override any of the default environment variable
+# settings, do that before evaluating this file.
+
+
+## -------------------- ##
+## Shell normalisation. ##
+## -------------------- ##
+
+# Some shells need a little help to be as Bourne compatible as possible.
+# Before doing anything else, make sure all that help has been provided!
+
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
 fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
 
-# NLS nuisances: We save the old values to restore during execute mode.
-lt_user_locale=
-lt_safe_locale=
-for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+# NLS nuisances: We save the old values in case they are required later.
+_G_user_locale=
+_G_safe_locale=
+for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
-  eval "if test \"\${$lt_var+set}\" = set; then
-          save_$lt_var=\$$lt_var
-          $lt_var=C
-	  export $lt_var
-	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
-	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+  eval "if test set = \"\${$_G_var+set}\"; then
+          save_$_G_var=\$$_G_var
+          $_G_var=C
+	  export $_G_var
+	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
+	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
 	fi"
 done
-LC_ALL=C
-LANGUAGE=C
-export LANGUAGE LC_ALL
 
-$lt_unset CDPATH
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Make sure IFS has a sensible default
+sp=' '
+nl='
+'
+IFS="$sp	$nl"
+
+# There are apparently some retarded systems that use ';' as a PATH separator!
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
 
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
 
 
+## ------------------------- ##
+## Locate command utilities. ##
+## ------------------------- ##
+
+
+# func_executable_p FILE
+# ----------------------
+# Check that FILE is an executable regular file.
+func_executable_p ()
+{
+    test -f "$1" && test -x "$1"
+}
+
+
+# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
+# --------------------------------------------
+# Search for either a program that responds to --version with output
+# containing "GNU", or else returned by CHECK_FUNC otherwise, by
+# trying all the directories in PATH with each of the elements of
+# PROGS_LIST.
+#
+# CHECK_FUNC should accept the path to a candidate program, and
+# set $func_check_prog_result if it truncates its output less than
+# $_G_path_prog_max characters.
+func_path_progs ()
+{
+    _G_progs_list=$1
+    _G_check_func=$2
+    _G_PATH=${3-"$PATH"}
+
+    _G_path_prog_max=0
+    _G_path_prog_found=false
+    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
+    for _G_dir in $_G_PATH; do
+      IFS=$_G_save_IFS
+      test -z "$_G_dir" && _G_dir=.
+      for _G_prog_name in $_G_progs_list; do
+        for _exeext in '' .EXE; do
+          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
+          func_executable_p "$_G_path_prog" || continue
+          case `"$_G_path_prog" --version 2>&1` in
+            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
+            *)     $_G_check_func $_G_path_prog
+		   func_path_progs_result=$func_check_prog_result
+		   ;;
+          esac
+          $_G_path_prog_found && break 3
+        done
+      done
+    done
+    IFS=$_G_save_IFS
+    test -z "$func_path_progs_result" && {
+      echo "no acceptable sed could be found in \$PATH" >&2
+      exit 1
+    }
+}
+
+
+# We want to be able to use the functions in this file before configure
+# has figured out where the best binaries are kept, which means we have
+# to search for them ourselves - except when the results are already set
+# where we skip the searches.
+
+# Unless the user overrides by setting SED, search the path for either GNU
+# sed, or the sed that truncates its output the least.
+test -z "$SED" && {
+  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+  for _G_i in 1 2 3 4 5 6 7; do
+    _G_sed_script=$_G_sed_script$nl$_G_sed_script
+  done
+  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
+  _G_sed_script=
+
+  func_check_prog_sed ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo '' >> conftest.nl
+      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
+  rm -f conftest.sed
+  SED=$func_path_progs_result
+}
+
+
+# Unless the user overrides by setting GREP, search the path for either GNU
+# grep, or the grep that truncates its output the least.
+test -z "$GREP" && {
+  func_check_prog_grep ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    _G_path_prog_max=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo 'GREP' >> conftest.nl
+      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
+  GREP=$func_path_progs_result
+}
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# All uppercase variable names are used for environment variables.  These
+# variables can be overridden by the user before calling a script that
+# uses them if a suitable command of that name is not already available
+# in the command search PATH.
 
 : ${CP="cp -f"}
-test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${ECHO="printf %s\n"}
+: ${EGREP="$GREP -E"}
+: ${FGREP="$GREP -F"}
+: ${LN_S="ln -s"}
 : ${MAKE="make"}
 : ${MKDIR="mkdir"}
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
-: ${Xsed="$SED -e 1s/^X//"}
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
-EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
-
-exit_status=$EXIT_SUCCESS
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
 
-dirname="s,/[^/]*$,,"
-basename="s,^.*/,,"
 
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
-    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-} # func_dirname may be replaced by extended shell implementation
+## -------------------- ##
+## Useful sed snippets. ##
+## -------------------- ##
 
+sed_dirname='s|/[^/]*$||'
+sed_basename='s|^.*/||'
 
-# func_basename file
-func_basename ()
-{
-    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
-} # func_basename may be replaced by extended shell implementation
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
 
+# Same as above, but do not quote variable references.
+sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-#             add APPEND to the result, otherwise set result
-#             to NONDIR_REPLACEMENT.
-#             value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-#             value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-    # Extract subdirectory from the argument.
-    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
-} # func_dirname_and_basename may be replaced by extended shell implementation
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
 
+# Sed substitution that converts a w32 file name or path
+# that contains forward slashes, into one that contains
+# (escaped) backslashes.  A very naive implementation.
+sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-'\' parameter expansions in output of sed_double_quote_subst that
+# were '\'-ed in input to the same.  If an odd number of '\' preceded a
+# '$' in input to sed_double_quote_subst, that '$' was protected from
+# expansion.  Since each input '\' is now two '\'s, look for any number
+# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
+_G_bs='\\'
+_G_bs2='\\\\'
+_G_bs4='\\\\\\\\'
+_G_dollar='\$'
+sed_double_backslash="\
+  s/$_G_bs4/&\\
+/g
+  s/^$_G_bs2$_G_dollar/$_G_bs&/
+  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
+  s/\n//g"
 
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-# func_strip_suffix prefix name
-func_stripname ()
-{
-    case ${2} in
-      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-    esac
-} # func_stripname may be replaced by extended shell implementation
 
+## ----------------- ##
+## Global variables. ##
+## ----------------- ##
 
-# These SED scripts presuppose an absolute path with a trailing slash.
-pathcar='s,^/\([^/]*\).*$,\1,'
-pathcdr='s,^/[^/]*,,'
-removedotparts=':dotsl
-		s@/\./@/@g
-		t dotsl
-		s,/\.$,/,'
-collapseslashes='s@/\{1,\}@/@g'
-finalslash='s,/*$,/,'
+# Except for the global variables explicitly listed below, the following
+# functions in the '^func_' namespace, and the '^require_' namespace
+# variables initialised in the 'Resource management' section, sourcing
+# this file will not pollute your global namespace with anything
+# else. There's no portable way to scope variables in Bourne shell
+# though, so actually running these functions will sometimes place
+# results into a variable named after the function, and often use
+# temporary variables in the '^_G_' namespace. If you are careful to
+# avoid using those namespaces casually in your sourcing script, things
+# should continue to work as you expect. And, of course, you can freely
+# overwrite any of the functions or variables defined here before
+# calling anything to customize them.
 
-# func_normal_abspath PATH
-# Remove doubled-up and trailing slashes, "." path components,
-# and cancel out any ".." path components in PATH after making
-# it an absolute path.
-#             value returned in "$func_normal_abspath_result"
-func_normal_abspath ()
-{
-  # Start from root dir and reassemble the path.
-  func_normal_abspath_result=
-  func_normal_abspath_tpath=$1
-  func_normal_abspath_altnamespace=
-  case $func_normal_abspath_tpath in
-    "")
-      # Empty path, that just means $cwd.
-      func_stripname '' '/' "`pwd`"
-      func_normal_abspath_result=$func_stripname_result
-      return
-    ;;
-    # The next three entries are used to spot a run of precisely
-    # two leading slashes without using negated character classes;
-    # we take advantage of case's first-match behaviour.
-    ///*)
-      # Unusual form of absolute path, do nothing.
-    ;;
-    //*)
-      # Not necessarily an ordinary path; POSIX reserves leading '//'
-      # and for example Cygwin uses it to access remote file shares
-      # over CIFS/SMB, so we conserve a leading double slash if found.
-      func_normal_abspath_altnamespace=/
-    ;;
-    /*)
-      # Absolute path, do nothing.
-    ;;
-    *)
-      # Relative path, prepend $cwd.
-      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
-    ;;
-  esac
-  # Cancel out all the simple stuff to save iterations.  We also want
-  # the path to end with a slash for ease of parsing, so make sure
-  # there is one (and only one) here.
-  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
-  while :; do
-    # Processed it all yet?
-    if test "$func_normal_abspath_tpath" = / ; then
-      # If we ascended to the root using ".." the result may be empty now.
-      if test -z "$func_normal_abspath_result" ; then
-        func_normal_abspath_result=/
-      fi
-      break
-    fi
-    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcar"`
-    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcdr"`
-    # Figure out what to do with it
-    case $func_normal_abspath_tcomponent in
-      "")
-        # Trailing empty path component, ignore it.
-      ;;
-      ..)
-        # Parent dir; strip last assembled component from result.
-        func_dirname "$func_normal_abspath_result"
-        func_normal_abspath_result=$func_dirname_result
-      ;;
-      *)
-        # Actual path component, append it.
-        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
-      ;;
-    esac
-  done
-  # Restore leading double-slash if one was found on entry.
-  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
-}
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 
-# func_relative_path SRCDIR DSTDIR
-# generates a relative path from SRCDIR to DSTDIR, with a trailing
-# slash if non-empty, suitable for immediately appending a filename
-# without needing to append a separator.
-#             value returned in "$func_relative_path_result"
-func_relative_path ()
-{
-  func_relative_path_result=
-  func_normal_abspath "$1"
-  func_relative_path_tlibdir=$func_normal_abspath_result
-  func_normal_abspath "$2"
-  func_relative_path_tbindir=$func_normal_abspath_result
-
-  # Ascend the tree starting from libdir
-  while :; do
-    # check if we have found a prefix of bindir
-    case $func_relative_path_tbindir in
-      $func_relative_path_tlibdir)
-        # found an exact match
-        func_relative_path_tcancelled=
-        break
-        ;;
-      $func_relative_path_tlibdir*)
-        # found a matching prefix
-        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
-        func_relative_path_tcancelled=$func_stripname_result
-        if test -z "$func_relative_path_result"; then
-          func_relative_path_result=.
-        fi
-        break
-        ;;
-      *)
-        func_dirname $func_relative_path_tlibdir
-        func_relative_path_tlibdir=${func_dirname_result}
-        if test "x$func_relative_path_tlibdir" = x ; then
-          # Have to descend all the way to the root!
-          func_relative_path_result=../$func_relative_path_result
-          func_relative_path_tcancelled=$func_relative_path_tbindir
-          break
-        fi
-        func_relative_path_result=../$func_relative_path_result
-        ;;
-    esac
-  done
+# Allow overriding, eg assuming that you follow the convention of
+# putting '$debug_cmd' at the start of all your functions, you can get
+# bash to show function call trace with:
+#
+#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+debug_cmd=${debug_cmd-":"}
+exit_cmd=:
 
-  # Now calculate path; take care to avoid doubling-up slashes.
-  func_stripname '' '/' "$func_relative_path_result"
-  func_relative_path_result=$func_stripname_result
-  func_stripname '/' '/' "$func_relative_path_tcancelled"
-  if test "x$func_stripname_result" != x ; then
-    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
-  fi
+# By convention, finish your script with:
+#
+#    exit $exit_status
+#
+# so that you can set exit_status to non-zero if you want to indicate
+# something went wrong during execution without actually bailing out at
+# the point of failure.
+exit_status=$EXIT_SUCCESS
 
-  # Normalisation. If bindir is libdir, return empty string,
-  # else relative path ending with a slash; either way, target
-  # file name can be directly appended.
-  if test ! -z "$func_relative_path_result"; then
-    func_stripname './' '' "$func_relative_path_result/"
-    func_relative_path_result=$func_stripname_result
-  fi
-}
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath=$0
 
-# The name of this program:
-func_dirname_and_basename "$progpath"
-progname=$func_basename_result
+# The name of this program.
+progname=`$ECHO "$progpath" |$SED "$sed_basename"`
 
-# Make sure we have an absolute path for reexecution:
+# Make sure we have an absolute progpath for reexecution:
 case $progpath in
   [\\/]*|[A-Za-z]:\\*) ;;
   *[\\/]*)
-     progdir=$func_dirname_result
+     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
      progdir=`cd "$progdir" && pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
   *)
-     save_IFS="$IFS"
+     _G_IFS=$IFS
      IFS=${PATH_SEPARATOR-:}
      for progdir in $PATH; do
-       IFS="$save_IFS"
+       IFS=$_G_IFS
        test -x "$progdir/$progname" && break
      done
-     IFS="$save_IFS"
+     IFS=$_G_IFS
      test -n "$progdir" || progdir=`pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
 esac
 
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# Sed substitution that turns a string into a regex matching for the
-# string literally.
-sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+## ----------------- ##
+## Standard options. ##
+## ----------------- ##
 
-# Sed substitution that converts a w32 file name or path
-# which contains forward slashes, into one that contains
-# (escaped) backslashes.  A very naive implementation.
-lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-
-# Re-`\' parameter expansions in output of double_quote_subst that were
-# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
-# in input to double_quote_subst, that '$' was protected from expansion.
-# Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
-bs='\\'
-bs2='\\\\'
-bs4='\\\\\\\\'
-dollar='\$'
-sed_double_backslash="\
-  s/$bs4/&\\
-/g
-  s/^$bs2$dollar/$bs&/
-  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
-  s/\n//g"
+# The following options affect the operation of the functions defined
+# below, and should be set appropriately depending on run-time para-
+# meters passed on the command line.
 
-# Standard options:
 opt_dry_run=false
-opt_help=false
 opt_quiet=false
 opt_verbose=false
-opt_warning=:
 
-# func_echo arg...
-# Echo program name prefixed message, along with the current mode
-# name if it has been set yet.
-func_echo ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
-}
+# Categories 'all' and 'none' are always available.  Append any others
+# you will pass as the first argument to func_warning from your own
+# code.
+warning_categories=
 
-# func_verbose arg...
-# Echo program name prefixed message in verbose mode only.
-func_verbose ()
-{
-    $opt_verbose && func_echo ${1+"$@"}
+# By default, display warnings according to 'opt_warning_types'.  Set
+# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
+# treat the next displayed warning as a fatal error.
+warning_func=func_warn_and_continue
 
-    # A bug in bash halts the script if the last line of a function
-    # fails when set -e is in force, so we need another command to
-    # work around that:
-    :
-}
+# Set to 'all' to display all warnings, 'none' to suppress all
+# warnings, or a space delimited list of some subset of
+# 'warning_categories' to display only the listed warnings.
+opt_warning_types=all
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*"
-}
 
-# func_error arg...
-# Echo program name prefixed message to standard error.
-func_error ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
-}
+## -------------------- ##
+## Resource management. ##
+## -------------------- ##
 
-# func_warning arg...
-# Echo program name prefixed warning message to standard error.
-func_warning ()
-{
-    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+# This section contains definitions for functions that each ensure a
+# particular resource (a file, or a non-empty configuration variable for
+# example) is available, and if appropriate to extract default values
+# from pertinent package files. Call them using their associated
+# 'require_*' variable to ensure that they are executed, at most, once.
+#
+# It's entirely deliberate that calling these functions can set
+# variables that don't obey the namespace limitations obeyed by the rest
+# of this file, in order that that they be as useful as possible to
+# callers.
 
-    # bash bug again:
-    :
-}
 
-# func_fatal_error arg...
-# Echo program name prefixed message to standard error, and exit.
-func_fatal_error ()
+# require_term_colors
+# -------------------
+# Allow display of bold text on terminals that support it.
+require_term_colors=func_require_term_colors
+func_require_term_colors ()
 {
-    func_error ${1+"$@"}
-    exit $EXIT_FAILURE
-}
+    $debug_cmd
+
+    test -t 1 && {
+      # COLORTERM and USE_ANSI_COLORS environment variables take
+      # precedence, because most terminfo databases neglect to describe
+      # whether color sequences are supported.
+      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
+
+      if test 1 = "$USE_ANSI_COLORS"; then
+        # Standard ANSI escape sequences
+        tc_reset=''
+        tc_bold='';   tc_standout=''
+        tc_red='';   tc_green=''
+        tc_blue='';  tc_cyan=''
+      else
+        # Otherwise trust the terminfo database after all.
+        test -n "`tput sgr0 2>/dev/null`" && {
+          tc_reset=`tput sgr0`
+          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
+          tc_standout=$tc_bold
+          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
+          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
+          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
+          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
+          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
+        }
+      fi
+    }
 
-# func_fatal_help arg...
-# Echo program name prefixed message to standard error, followed by
-# a help hint, and exit.
-func_fatal_help ()
-{
-    func_error ${1+"$@"}
-    func_fatal_error "$help"
+    require_term_colors=:
 }
-help="Try \`$progname --help' for more information."  ## default
 
 
-# func_grep expression filename
+## ----------------- ##
+## Function library. ##
+## ----------------- ##
+
+# This section contains a variety of useful functions to call in your
+# scripts. Take note of the portable wrappers for features provided by
+# some modern shells, which will fall back to slower equivalents on
+# less featureful shells.
+
+
+# func_append VAR VALUE
+# ---------------------
+# Append VALUE onto the existing contents of VAR.
+
+  # We should try to minimise forks, especially on Windows where they are
+  # unreasonably slow, so skip the feature probes when bash or zsh are
+  # being used:
+  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
+    : ${_G_HAVE_ARITH_OP="yes"}
+    : ${_G_HAVE_XSI_OPS="yes"}
+    # The += operator was introduced in bash 3.1
+    case $BASH_VERSION in
+      [12].* | 3.0 | 3.0*) ;;
+      *)
+        : ${_G_HAVE_PLUSEQ_OP="yes"}
+        ;;
+    esac
+  fi
+
+  # _G_HAVE_PLUSEQ_OP
+  # Can be empty, in which case the shell is probed, "yes" if += is
+  # useable or anything else if it does not work.
+  test -z "$_G_HAVE_PLUSEQ_OP" \
+    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
+    && _G_HAVE_PLUSEQ_OP=yes
+
+if test yes = "$_G_HAVE_PLUSEQ_OP"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_append ()
+  {
+    $debug_cmd
+
+    eval "$1+=\$2"
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_append ()
+  {
+    $debug_cmd
+
+    eval "$1=\$$1\$2"
+  }
+fi
+
+
+# func_append_quoted VAR VALUE
+# ----------------------------
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+  eval 'func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1+=\\ \$func_quote_for_eval_result"
+  }'
+else
+  func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1=\$$1\\ \$func_quote_for_eval_result"
+  }
+fi
+
+
+# func_append_uniq VAR VALUE
+# --------------------------
+# Append unique VALUE onto the existing contents of VAR, assuming
+# entries are delimited by the first character of VALUE.  For example:
+#
+#   func_append_uniq options " --another-option option-argument"
+#
+# will only append to $options if " --another-option option-argument "
+# is not already present somewhere in $options already (note spaces at
+# each end implied by leading space in second argument).
+func_append_uniq ()
+{
+    $debug_cmd
+
+    eval _G_current_value='`$ECHO $'$1'`'
+    _G_delim=`expr "$2" : '\(.\)'`
+
+    case $_G_delim$_G_current_value$_G_delim in
+      *"$2$_G_delim"*) ;;
+      *) func_append "$@" ;;
+    esac
+}
+
+
+# func_arith TERM...
+# ------------------
+# Set func_arith_result to the result of evaluating TERMs.
+  test -z "$_G_HAVE_ARITH_OP" \
+    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
+    && _G_HAVE_ARITH_OP=yes
+
+if test yes = "$_G_HAVE_ARITH_OP"; then
+  eval 'func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=$(( $* ))
+  }'
+else
+  func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=`expr "$@"`
+  }
+fi
+
+
+# func_basename FILE
+# ------------------
+# Set func_basename_result to FILE with everything up to and including
+# the last / stripped.
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  # If this shell supports suffix pattern removal, then use it to avoid
+  # forking. Hide the definitions single quotes in case the shell chokes
+  # on unsupported syntax...
+  _b='func_basename_result=${1##*/}'
+  _d='case $1 in
+        */*) func_dirname_result=${1%/*}$2 ;;
+        *  ) func_dirname_result=$3        ;;
+      esac'
+
+else
+  # ...otherwise fall back to using sed.
+  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
+  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
+      if test "X$func_dirname_result" = "X$1"; then
+        func_dirname_result=$3
+      else
+        func_append func_dirname_result "$2"
+      fi'
+fi
+
+eval 'func_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+}'
+
+
+# func_dirname FILE APPEND NONDIR_REPLACEMENT
+# -------------------------------------------
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+eval 'func_dirname ()
+{
+    $debug_cmd
+
+    '"$_d"'
+}'
+
+
+# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
+# --------------------------------------------------------
+# Perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# For efficiency, we do not delegate to the functions above but instead
+# duplicate the functionality here.
+eval 'func_dirname_and_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+    '"$_d"'
+}'
+
+
+# func_echo ARG...
+# ----------------
+# Echo program name prefixed message.
+func_echo ()
+{
+    $debug_cmd
+
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
+
+
+# func_echo_all ARG...
+# --------------------
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+
+# func_echo_infix_1 INFIX ARG...
+# ------------------------------
+# Echo program name, followed by INFIX on the first line, with any
+# additional lines not showing INFIX.
+func_echo_infix_1 ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    _G_infix=$1; shift
+    _G_indent=$_G_infix
+    _G_prefix="$progname: $_G_infix: "
+    _G_message=$*
+
+    # Strip color escape sequences before counting printable length
+    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
+    do
+      test -n "$_G_tc" && {
+        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
+        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
+      }
+    done
+    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
+
+    func_echo_infix_1_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_infix_1_IFS
+      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
+      _G_prefix=$_G_indent
+    done
+    IFS=$func_echo_infix_1_IFS
+}
+
+
+# func_error ARG...
+# -----------------
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
+}
+
+
+# func_fatal_error ARG...
+# -----------------------
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    $debug_cmd
+
+    func_error "$*"
+    exit $EXIT_FAILURE
+}
+
+
+# func_grep EXPRESSION FILENAME
+# -----------------------------
 # Check whether EXPRESSION matches any line of FILENAME, without output.
 func_grep ()
 {
+    $debug_cmd
+
     $GREP "$1" "$2" >/dev/null 2>&1
 }
 
 
-# func_mkdir_p directory-path
+# func_len STRING
+# ---------------
+# Set func_len_result to the length of STRING. STRING may not
+# start with a hyphen.
+  test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=${#1}
+  }'
+else
+  func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+  }
+fi
+
+
+# func_mkdir_p DIRECTORY-PATH
+# ---------------------------
 # Make sure the entire path to DIRECTORY-PATH is available.
 func_mkdir_p ()
 {
-    my_directory_path="$1"
-    my_dir_list=
+    $debug_cmd
 
-    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+    _G_directory_path=$1
+    _G_dir_list=
 
-      # Protect directory names starting with `-'
-      case $my_directory_path in
-        -*) my_directory_path="./$my_directory_path" ;;
+    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
+
+      # Protect directory names starting with '-'
+      case $_G_directory_path in
+        -*) _G_directory_path=./$_G_directory_path ;;
       esac
 
       # While some portion of DIR does not yet exist...
-      while test ! -d "$my_directory_path"; do
+      while test ! -d "$_G_directory_path"; do
         # ...make a list in topmost first order.  Use a colon delimited
 	# list incase some portion of path contains whitespace.
-        my_dir_list="$my_directory_path:$my_dir_list"
+        _G_dir_list=$_G_directory_path:$_G_dir_list
 
         # If the last portion added has no slash in it, the list is done
-        case $my_directory_path in */*) ;; *) break ;; esac
+        case $_G_directory_path in */*) ;; *) break ;; esac
 
         # ...otherwise throw away the child directory and loop
-        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
       done
-      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
 
-      save_mkdir_p_IFS="$IFS"; IFS=':'
-      for my_dir in $my_dir_list; do
-	IFS="$save_mkdir_p_IFS"
-        # mkdir can fail with a `File exist' error if two processes
+      func_mkdir_p_IFS=$IFS; IFS=:
+      for _G_dir in $_G_dir_list; do
+	IFS=$func_mkdir_p_IFS
+        # mkdir can fail with a 'File exist' error if two processes
         # try to create one of the directories concurrently.  Don't
         # stop in that case!
-        $MKDIR "$my_dir" 2>/dev/null || :
+        $MKDIR "$_G_dir" 2>/dev/null || :
       done
-      IFS="$save_mkdir_p_IFS"
+      IFS=$func_mkdir_p_IFS
 
       # Bail out if we (or some other process) failed to create a directory.
-      test -d "$my_directory_path" || \
-        func_fatal_error "Failed to create \`$1'"
+      test -d "$_G_directory_path" || \
+        func_fatal_error "Failed to create '$1'"
     fi
 }
 
 
-# func_mktempdir [string]
+# func_mktempdir [BASENAME]
+# -------------------------
 # Make a temporary directory that won't clash with other running
 # libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
+# given, BASENAME is the basename for that directory.
 func_mktempdir ()
 {
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
+    $debug_cmd
+
+    _G_template=${TMPDIR-/tmp}/${1-$progname}
 
-    if test "$opt_dry_run" = ":"; then
+    if test : = "$opt_dry_run"; then
       # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
+      _G_tmpdir=$_G_template-$$
     else
 
       # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
 
-      if test ! -d "$my_tmpdir"; then
+      if test ! -d "$_G_tmpdir"; then
         # Failing that, at least try and use $RANDOM to avoid a race
-        my_tmpdir="${my_template}-${RANDOM-0}$$"
+        _G_tmpdir=$_G_template-${RANDOM-0}$$
 
-        save_mktempdir_umask=`umask`
+        func_mktempdir_umask=`umask`
         umask 0077
-        $MKDIR "$my_tmpdir"
-        umask $save_mktempdir_umask
+        $MKDIR "$_G_tmpdir"
+        umask $func_mktempdir_umask
       fi
 
       # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || \
-        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+      test -d "$_G_tmpdir" || \
+        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
+    fi
+
+    $ECHO "$_G_tmpdir"
+}
+
+
+# func_normal_abspath PATH
+# ------------------------
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+func_normal_abspath ()
+{
+    $debug_cmd
+
+    # These SED scripts presuppose an absolute path with a trailing slash.
+    _G_pathcar='s|^/\([^/]*\).*$|\1|'
+    _G_pathcdr='s|^/[^/]*||'
+    _G_removedotparts=':dotsl
+		s|/\./|/|g
+		t dotsl
+		s|/\.$|/|'
+    _G_collapseslashes='s|/\{1,\}|/|g'
+    _G_finalslash='s|/*$|/|'
+
+    # Start from root dir and reassemble the path.
+    func_normal_abspath_result=
+    func_normal_abspath_tpath=$1
+    func_normal_abspath_altnamespace=
+    case $func_normal_abspath_tpath in
+      "")
+        # Empty path, that just means $cwd.
+        func_stripname '' '/' "`pwd`"
+        func_normal_abspath_result=$func_stripname_result
+        return
+        ;;
+      # The next three entries are used to spot a run of precisely
+      # two leading slashes without using negated character classes;
+      # we take advantage of case's first-match behaviour.
+      ///*)
+        # Unusual form of absolute path, do nothing.
+        ;;
+      //*)
+        # Not necessarily an ordinary path; POSIX reserves leading '//'
+        # and for example Cygwin uses it to access remote file shares
+        # over CIFS/SMB, so we conserve a leading double slash if found.
+        func_normal_abspath_altnamespace=/
+        ;;
+      /*)
+        # Absolute path, do nothing.
+        ;;
+      *)
+        # Relative path, prepend $cwd.
+        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+        ;;
+    esac
+
+    # Cancel out all the simple stuff to save iterations.  We also want
+    # the path to end with a slash for ease of parsing, so make sure
+    # there is one (and only one) here.
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
+    while :; do
+      # Processed it all yet?
+      if test / = "$func_normal_abspath_tpath"; then
+        # If we ascended to the root using ".." the result may be empty now.
+        if test -z "$func_normal_abspath_result"; then
+          func_normal_abspath_result=/
+        fi
+        break
+      fi
+      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcar"`
+      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcdr"`
+      # Figure out what to do with it
+      case $func_normal_abspath_tcomponent in
+        "")
+          # Trailing empty path component, ignore it.
+          ;;
+        ..)
+          # Parent dir; strip last assembled component from result.
+          func_dirname "$func_normal_abspath_result"
+          func_normal_abspath_result=$func_dirname_result
+          ;;
+        *)
+          # Actual path component, append it.
+          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
+          ;;
+      esac
+    done
+    # Restore leading double-slash if one was found on entry.
+    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+
+# func_notquiet ARG...
+# --------------------
+# Echo program name prefixed message only when not in quiet mode.
+func_notquiet ()
+{
+    $debug_cmd
+
+    $opt_quiet || func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+
+# func_relative_path SRCDIR DSTDIR
+# --------------------------------
+# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
+func_relative_path ()
+{
+    $debug_cmd
+
+    func_relative_path_result=
+    func_normal_abspath "$1"
+    func_relative_path_tlibdir=$func_normal_abspath_result
+    func_normal_abspath "$2"
+    func_relative_path_tbindir=$func_normal_abspath_result
+
+    # Ascend the tree starting from libdir
+    while :; do
+      # check if we have found a prefix of bindir
+      case $func_relative_path_tbindir in
+        $func_relative_path_tlibdir)
+          # found an exact match
+          func_relative_path_tcancelled=
+          break
+          ;;
+        $func_relative_path_tlibdir*)
+          # found a matching prefix
+          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+          func_relative_path_tcancelled=$func_stripname_result
+          if test -z "$func_relative_path_result"; then
+            func_relative_path_result=.
+          fi
+          break
+          ;;
+        *)
+          func_dirname $func_relative_path_tlibdir
+          func_relative_path_tlibdir=$func_dirname_result
+          if test -z "$func_relative_path_tlibdir"; then
+            # Have to descend all the way to the root!
+            func_relative_path_result=../$func_relative_path_result
+            func_relative_path_tcancelled=$func_relative_path_tbindir
+            break
+          fi
+          func_relative_path_result=../$func_relative_path_result
+          ;;
+      esac
+    done
+
+    # Now calculate path; take care to avoid doubling-up slashes.
+    func_stripname '' '/' "$func_relative_path_result"
+    func_relative_path_result=$func_stripname_result
+    func_stripname '/' '/' "$func_relative_path_tcancelled"
+    if test -n "$func_stripname_result"; then
+      func_append func_relative_path_result "/$func_stripname_result"
+    fi
+
+    # Normalisation. If bindir is libdir, return '.' else relative path.
+    if test -n "$func_relative_path_result"; then
+      func_stripname './' '' "$func_relative_path_result"
+      func_relative_path_result=$func_stripname_result
     fi
 
-    $ECHO "$my_tmpdir"
+    test -n "$func_relative_path_result" || func_relative_path_result=.
+
+    :
+}
+
+
+# func_quote_for_eval ARG...
+# --------------------------
+# Aesthetically quote ARGs to be evaled later.
+# This function returns two values:
+#   i) func_quote_for_eval_result
+#      double-quoted, suitable for a subsequent eval
+#  ii) func_quote_for_eval_unquoted_result
+#      has all characters that are still active within double
+#      quotes backslashified.
+func_quote_for_eval ()
+{
+    $debug_cmd
+
+    func_quote_for_eval_unquoted_result=
+    func_quote_for_eval_result=
+    while test 0 -lt $#; do
+      case $1 in
+        *[\\\`\"\$]*)
+	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+        *)
+          _G_unquoted_arg=$1 ;;
+      esac
+      if test -n "$func_quote_for_eval_unquoted_result"; then
+	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+      else
+        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+      fi
+
+      case $_G_unquoted_arg in
+        # Double-quote args containing shell metacharacters to delay
+        # word splitting, command substitution and variable expansion
+        # for a subsequent eval.
+        # Many Bourne shells cannot handle close brackets correctly
+        # in scan sets, so we specify it separately.
+        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+          _G_quoted_arg=\"$_G_unquoted_arg\"
+          ;;
+        *)
+          _G_quoted_arg=$_G_unquoted_arg
+	  ;;
+      esac
+
+      if test -n "$func_quote_for_eval_result"; then
+	func_append func_quote_for_eval_result " $_G_quoted_arg"
+      else
+        func_append func_quote_for_eval_result "$_G_quoted_arg"
+      fi
+      shift
+    done
+}
+
+
+# func_quote_for_expand ARG
+# -------------------------
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    $debug_cmd
+
+    case $1 in
+      *[\\\`\"]*)
+	_G_arg=`$ECHO "$1" | $SED \
+	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        _G_arg=$1 ;;
+    esac
+
+    case $_G_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        _G_arg=\"$_G_arg\"
+        ;;
+    esac
+
+    func_quote_for_expand_result=$_G_arg
+}
+
+
+# func_stripname PREFIX SUFFIX NAME
+# ---------------------------------
+# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_stripname ()
+  {
+    $debug_cmd
+
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary variable first.
+    func_stripname_result=$3
+    func_stripname_result=${func_stripname_result#"$1"}
+    func_stripname_result=${func_stripname_result%"$2"}
+  }'
+else
+  func_stripname ()
+  {
+    $debug_cmd
+
+    case $2 in
+      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
+      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
+    esac
+  }
+fi
+
+
+# func_show_eval CMD [FAIL_EXP]
+# -----------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    func_quote_for_expand "$_G_cmd"
+    eval "func_notquiet $func_quote_for_expand_result"
+
+    $opt_dry_run || {
+      eval "$_G_cmd"
+      _G_status=$?
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_show_eval_locale CMD [FAIL_EXP]
+# ------------------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    $opt_quiet || {
+      func_quote_for_expand "$_G_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    $opt_dry_run || {
+      eval "$_G_user_locale
+	    $_G_cmd"
+      _G_status=$?
+      eval "$_G_safe_locale"
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_tr_sh
+# ----------
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result.  All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+    $debug_cmd
+
+    case $1 in
+    [0-9]* | *[!a-zA-Z0-9_]*)
+      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
+      ;;
+    * )
+      func_tr_sh_result=$1
+      ;;
+    esac
+}
+
+
+# func_verbose ARG...
+# -------------------
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $debug_cmd
+
+    $opt_verbose && func_echo "$*"
+
+    :
+}
+
+
+# func_warn_and_continue ARG...
+# -----------------------------
+# Echo program name prefixed warning message to standard error.
+func_warn_and_continue ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
+}
+
+
+# func_warning CATEGORY ARG...
+# ----------------------------
+# Echo program name prefixed warning message to standard error. Warning
+# messages can be filtered according to CATEGORY, where this function
+# elides messages where CATEGORY is not listed in the global variable
+# 'opt_warning_types'.
+func_warning ()
+{
+    $debug_cmd
+
+    # CATEGORY must be in the warning_categories list!
+    case " $warning_categories " in
+      *" $1 "*) ;;
+      *) func_internal_error "invalid warning category '$1'" ;;
+    esac
+
+    _G_category=$1
+    shift
+
+    case " $opt_warning_types " in
+      *" $_G_category "*) $warning_func ${1+"$@"} ;;
+    esac
+}
+
+
+# func_sort_ver VER1 VER2
+# -----------------------
+# 'sort -V' is not generally available.
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+func_sort_ver ()
+{
+    $debug_cmd
+
+    printf '%s\n%s\n' "$1" "$2" \
+      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
+}
+
+# func_lt_ver PREV CURR
+# ---------------------
+# Return true if PREV and CURR are in the correct order according to
+# func_sort_ver, otherwise false.  Use it like this:
+#
+#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
+func_lt_ver ()
+{
+    $debug_cmd
+
+    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
+}
+
+
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
+#! /bin/sh
+
+# Set a version string for this script.
+scriptversion=2014-01-07.03; # UTC
+
+# A portable, pluggable option parser for Bourne shell.
+# Written by Gary V. Vaughan, 2010
+
+# Copyright (C) 2010-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# This file is a library for parsing options in your shell scripts along
+# with assorted other useful supporting features that you can make use
+# of too.
+#
+# For the simplest scripts you might need only:
+#
+#   #!/bin/sh
+#   . relative/path/to/funclib.sh
+#   . relative/path/to/options-parser
+#   scriptversion=1.0
+#   func_options ${1+"$@"}
+#   eval set dummy "$func_options_result"; shift
+#   ...rest of your script...
+#
+# In order for the '--version' option to work, you will need to have a
+# suitably formatted comment like the one at the top of this file
+# starting with '# Written by ' and ending with '# warranty; '.
+#
+# For '-h' and '--help' to work, you will also need a one line
+# description of your script's purpose in a comment directly above the
+# '# Written by ' line, like the one at the top of this file.
+#
+# The default options also support '--debug', which will turn on shell
+# execution tracing (see the comment above debug_cmd below for another
+# use), and '--verbose' and the func_verbose function to allow your script
+# to display verbose messages only when your user has specified
+# '--verbose'.
+#
+# After sourcing this file, you can plug processing for additional
+# options by amending the variables from the 'Configuration' section
+# below, and following the instructions in the 'Option parsing'
+# section further down.
+
+## -------------- ##
+## Configuration. ##
+## -------------- ##
+
+# You should override these variables in your script after sourcing this
+# file so that they reflect the customisations you have added to the
+# option parser.
+
+# The usage line for option parsing errors and the start of '-h' and
+# '--help' output messages. You can embed shell variables for delayed
+# expansion at the time the message is displayed, but you will need to
+# quote other shell meta-characters carefully to prevent them being
+# expanded when the contents are evaled.
+usage='$progpath [OPTION]...'
+
+# Short help message in response to '-h' and '--help'.  Add to this or
+# override it after sourcing this library to reflect the full set of
+# options your script accepts.
+usage_message="\
+       --debug        enable verbose shell tracing
+   -W, --warnings=CATEGORY
+                      report the warnings falling in CATEGORY [all]
+   -v, --verbose      verbosely report processing
+       --version      print version information and exit
+   -h, --help         print short or long help message and exit
+"
+
+# Additional text appended to 'usage_message' in response to '--help'.
+long_help_message="
+Warning categories include:
+       'all'          show all warnings
+       'none'         turn off all the warnings
+       'error'        warnings are treated as fatal errors"
+
+# Help message printed before fatal option parsing errors.
+fatal_help="Try '\$progname --help' for more information."
+
+
+
+## ------------------------- ##
+## Hook function management. ##
+## ------------------------- ##
+
+# This section contains functions for adding, removing, and running hooks
+# to the main code.  A hook is just a named list of of function, that can
+# be run in order later on.
+
+# func_hookable FUNC_NAME
+# -----------------------
+# Declare that FUNC_NAME will run hooks added with
+# 'func_add_hook FUNC_NAME ...'.
+func_hookable ()
+{
+    $debug_cmd
+
+    func_append hookable_fns " $1"
+}
+
+
+# func_add_hook FUNC_NAME HOOK_FUNC
+# ---------------------------------
+# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
+# first have been declared "hookable" by a call to 'func_hookable'.
+func_add_hook ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not accept hook functions." ;;
+    esac
+
+    eval func_append ${1}_hooks '" $2"'
+}
+
+
+# func_remove_hook FUNC_NAME HOOK_FUNC
+# ------------------------------------
+# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
+func_remove_hook ()
+{
+    $debug_cmd
+
+    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
+}
+
+
+# func_run_hooks FUNC_NAME [ARG]...
+# ---------------------------------
+# Run all hook functions registered to FUNC_NAME.
+# It is assumed that the list of hook functions contains nothing more
+# than a whitespace-delimited list of legal shell function names, and
+# no effort is wasted trying to catch shell meta-characters or preserve
+# whitespace.
+func_run_hooks ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+    esac
+
+    eval _G_hook_fns=\$$1_hooks; shift
+
+    for _G_hook in $_G_hook_fns; do
+      eval $_G_hook '"$@"'
+
+      # store returned options list back into positional
+      # parameters for next 'cmd' execution.
+      eval _G_hook_result=\$${_G_hook}_result
+      eval set dummy "$_G_hook_result"; shift
+    done
+
+    func_quote_for_eval ${1+"$@"}
+    func_run_hooks_result=$func_quote_for_eval_result
+}
+
+
+
+## --------------- ##
+## Option parsing. ##
+## --------------- ##
+
+# In order to add your own option parsing hooks, you must accept the
+# full positional parameter list in your hook function, remove any
+# options that you action, and then pass back the remaining unprocessed
+# options in '<hooked_function_name>_result', escaped suitably for
+# 'eval'.  Like this:
+#
+#    my_options_prep ()
+#    {
+#        $debug_cmd
+#
+#        # Extend the existing usage message.
+#        usage_message=$usage_message'
+#      -s, --silent       don'\''t print informational messages
+#    '
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_options_prep_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_options_prep my_options_prep
+#
+#
+#    my_silent_option ()
+#    {
+#        $debug_cmd
+#
+#        # Note that for efficiency, we parse as many options as we can
+#        # recognise in a loop before passing the remainder back to the
+#        # caller on the first unrecognised argument we encounter.
+#        while test $# -gt 0; do
+#          opt=$1; shift
+#          case $opt in
+#            --silent|-s) opt_silent=: ;;
+#            # Separate non-argument short options:
+#            -s*)         func_split_short_opt "$_G_opt"
+#                         set dummy "$func_split_short_opt_name" \
+#                             "-$func_split_short_opt_arg" ${1+"$@"}
+#                         shift
+#                         ;;
+#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#          esac
+#        done
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_silent_option_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_parse_options my_silent_option
+#
+#
+#    my_option_validation ()
+#    {
+#        $debug_cmd
+#
+#        $opt_silent && $opt_verbose && func_fatal_help "\
+#    '--silent' and '--verbose' options are mutually exclusive."
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_option_validation_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_validate_options my_option_validation
+#
+# You'll alse need to manually amend $usage_message to reflect the extra
+# options you parse.  It's preferable to append if you can, so that
+# multiple option parsing hooks can be added safely.
+
+
+# func_options [ARG]...
+# ---------------------
+# All the functions called inside func_options are hookable. See the
+# individual implementations for details.
+func_hookable func_options
+func_options ()
+{
+    $debug_cmd
+
+    func_options_prep ${1+"$@"}
+    eval func_parse_options \
+        ${func_options_prep_result+"$func_options_prep_result"}
+    eval func_validate_options \
+        ${func_parse_options_result+"$func_parse_options_result"}
+
+    eval func_run_hooks func_options \
+        ${func_validate_options_result+"$func_validate_options_result"}
+
+    # save modified positional parameters for caller
+    func_options_result=$func_run_hooks_result
 }
 
 
-# func_quote_for_eval arg
-# Aesthetically quote ARG to be evaled later.
-# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
-# is double-quoted, suitable for a subsequent eval, whereas
-# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
-# which are still active within double quotes backslashified.
-func_quote_for_eval ()
+# func_options_prep [ARG]...
+# --------------------------
+# All initialisations required before starting the option parse loop.
+# Note that when calling hook functions, we pass through the list of
+# positional parameters.  If a hook function modifies that list, and
+# needs to propogate that back to rest of this script, then the complete
+# modified list must be put in 'func_run_hooks_result' before
+# returning.
+func_hookable func_options_prep
+func_options_prep ()
 {
-    case $1 in
-      *[\\\`\"\$]*)
-	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
-      *)
-        func_quote_for_eval_unquoted_result="$1" ;;
-    esac
+    $debug_cmd
 
-    case $func_quote_for_eval_unquoted_result in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting, command substitution and and variable
-      # expansion for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
-        ;;
-      *)
-        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
-    esac
+    # Option defaults:
+    opt_verbose=false
+    opt_warning_types=
+
+    func_run_hooks func_options_prep ${1+"$@"}
+
+    # save modified positional parameters for caller
+    func_options_prep_result=$func_run_hooks_result
 }
 
 
-# func_quote_for_expand arg
-# Aesthetically quote ARG to be evaled later; same as above,
-# but do not quote variable references.
-func_quote_for_expand ()
+# func_parse_options [ARG]...
+# ---------------------------
+# The main option parsing loop.
+func_hookable func_parse_options
+func_parse_options ()
 {
-    case $1 in
-      *[\\\`\"]*)
-	my_arg=`$ECHO "$1" | $SED \
-	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
-      *)
-        my_arg="$1" ;;
-    esac
+    $debug_cmd
 
-    case $my_arg in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting and command substitution for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        my_arg="\"$my_arg\""
-        ;;
-    esac
+    func_parse_options_result=
 
-    func_quote_for_expand_result="$my_arg"
-}
+    # this just eases exit handling
+    while test $# -gt 0; do
+      # Defer to hook functions for initial option parsing, so they
+      # get priority in the event of reusing an option name.
+      func_run_hooks func_parse_options ${1+"$@"}
 
+      # Adjust func_parse_options positional parameters to match
+      eval set dummy "$func_run_hooks_result"; shift
 
-# func_show_eval cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.
-func_show_eval ()
-{
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+      # Break out of the loop if we already parsed every option.
+      test $# -gt 0 || break
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --debug|-x)   debug_cmd='set -x'
+                      func_echo "enabling shell trace mode"
+                      $debug_cmd
+                      ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                      set dummy --warnings none ${1+"$@"}
+                      shift
+		      ;;
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$my_cmd"
-      my_status=$?
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+        --warnings|--warning|-W)
+                      test $# = 0 && func_missing_arg $_G_opt && break
+                      case " $warning_categories $1" in
+                        *" $1 "*)
+                          # trailing space prevents matching last $1 above
+                          func_append_uniq opt_warning_types " $1"
+                          ;;
+                        *all)
+                          opt_warning_types=$warning_categories
+                          ;;
+                        *none)
+                          opt_warning_types=none
+                          warning_func=:
+                          ;;
+                        *error)
+                          opt_warning_types=$warning_categories
+                          warning_func=func_fatal_error
+                          ;;
+                        *)
+                          func_fatal_error \
+                             "unsupported warning category: '$1'"
+                          ;;
+                      esac
+                      shift
+                      ;;
+
+        --verbose|-v) opt_verbose=: ;;
+        --version)    func_version ;;
+        -\?|-h)       func_usage ;;
+        --help)       func_help ;;
+
+	# Separate optargs to long options (plugins may need this):
+	--*=*)        func_split_equals "$_G_opt"
+	              set dummy "$func_split_equals_lhs" \
+                          "$func_split_equals_rhs" ${1+"$@"}
+                      shift
+                      ;;
+
+       # Separate optargs to short options:
+        -W*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        # Separate non-argument short options:
+        -\?*|-h*|-v*|-x*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "-$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        --)           break ;;
+        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+      esac
+    done
+
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    func_parse_options_result=$func_quote_for_eval_result
 }
 
 
-# func_show_eval_locale cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.  Use the saved locale for evaluation.
-func_show_eval_locale ()
+# func_validate_options [ARG]...
+# ------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+func_hookable func_validate_options
+func_validate_options ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    # Display all warnings if -W was not given.
+    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$lt_user_locale
-	    $my_cmd"
-      my_status=$?
-      eval "$lt_safe_locale"
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
-}
+    func_run_hooks func_validate_options ${1+"$@"}
 
-# func_tr_sh
-# Turn $1 into a string suitable for a shell variable name.
-# Result is stored in $func_tr_sh_result.  All characters
-# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
-# if $1 begins with a digit, a '_' is prepended as well.
-func_tr_sh ()
-{
-  case $1 in
-  [0-9]* | *[!a-zA-Z0-9_]*)
-    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
-    ;;
-  * )
-    func_tr_sh_result=$1
-    ;;
-  esac
+    # Bail if the options were screwed!
+    $exit_cmd $EXIT_FAILURE
+
+    # save modified positional parameters for caller
+    func_validate_options_result=$func_run_hooks_result
 }
 
 
-# func_version
-# Echo version message to standard output and exit.
-func_version ()
-{
-    $opt_debug
 
-    $SED -n '/(C)/!b go
-	:more
-	/\./!{
-	  N
-	  s/\n# / /
-	  b more
-	}
-	:go
-	/^# '$PROGRAM' (GNU /,/# warranty; / {
-        s/^# //
-	s/^# *$//
-        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
-        p
-     }' < "$progpath"
-     exit $?
-}
+## ----------------- ##
+## Helper functions. ##
+## ----------------- ##
 
-# func_usage
-# Echo short help message to standard output and exit.
-func_usage ()
+# This section contains the helper functions used by the rest of the
+# hookable option parser framework in ascii-betical order.
+
+
+# func_fatal_help ARG...
+# ----------------------
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/^# Usage:/,/^#  *.*--help/ {
-        s/^# //
-	s/^# *$//
-	s/\$progname/'$progname'/
-	p
-    }' < "$progpath"
-    echo
-    $ECHO "run \`$progname --help | more' for full usage"
-    exit $?
+    eval \$ECHO \""Usage: $usage"\"
+    eval \$ECHO \""$fatal_help"\"
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
 }
 
-# func_help [NOEXIT]
-# Echo long help message to standard output and exit,
-# unless 'noexit' is passed as argument.
+
+# func_help
+# ---------
+# Echo long help message to standard output and exit.
 func_help ()
 {
-    $opt_debug
-
-    $SED -n '/^# Usage:/,/# Report bugs to/ {
-	:print
-        s/^# //
-	s/^# *$//
-	s*\$progname*'$progname'*
-	s*\$host*'"$host"'*
-	s*\$SHELL*'"$SHELL"'*
-	s*\$LTCC*'"$LTCC"'*
-	s*\$LTCFLAGS*'"$LTCFLAGS"'*
-	s*\$LD*'"$LD"'*
-	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
-	p
-	d
-     }
-     /^# .* home page:/b print
-     /^# General help using/b print
-     ' < "$progpath"
-    ret=$?
-    if test -z "$1"; then
-      exit $ret
-    fi
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message"
+    exit 0
 }
 
-# func_missing_arg argname
+
+# func_missing_arg ARGNAME
+# ------------------------
 # Echo program name prefixed message to standard error and set global
 # exit_cmd.
 func_missing_arg ()
 {
-    $opt_debug
+    $debug_cmd
 
-    func_error "missing argument for $1."
+    func_error "Missing argument for '$1'."
     exit_cmd=exit
 }
 
 
-# func_split_short_opt shortopt
+# func_split_equals STRING
+# ------------------------
+# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
+# splitting STRING at the '=' sign.
+test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=${1%%=*}
+      func_split_equals_rhs=${1#*=}
+      test "x$func_split_equals_lhs" = "x$1" \
+        && func_split_equals_rhs=
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
+      func_split_equals_rhs=
+      test "x$func_split_equals_lhs" = "x$1" \
+        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
+  }
+fi #func_split_equals
+
+
+# func_split_short_opt SHORTOPT
+# -----------------------------
 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 # variables after splitting SHORTOPT after the 2nd character.
-func_split_short_opt ()
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_arg=${1#??}
+      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
+      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
+  }
+fi #func_split_short_opt
+
+
+# func_usage
+# ----------
+# Echo short help message to standard output and exit.
+func_usage ()
 {
-    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
-    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+    $debug_cmd
 
-    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
-    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
-} # func_split_short_opt may be replaced by extended shell implementation
+    func_usage_message
+    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
+    exit 0
+}
 
 
-# func_split_long_opt longopt
-# Set func_split_long_opt_name and func_split_long_opt_arg shell
-# variables after splitting LONGOPT at the `=' sign.
-func_split_long_opt ()
+# func_usage_message
+# ------------------
+# Echo short help message to standard output.
+func_usage_message ()
 {
-    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
-    my_sed_long_arg='1s/^--[^=]*=//'
+    $debug_cmd
 
-    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
-    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
-} # func_split_long_opt may be replaced by extended shell implementation
+    eval \$ECHO \""Usage: $usage"\"
+    echo
+    $SED -n 's|^# ||
+        /^Written by/{
+          x;p;x
+        }
+	h
+	/^Written by/q' < "$progpath"
+    echo
+    eval \$ECHO \""$usage_message"\"
+}
 
-exit_cmd=:
 
+# func_version
+# ------------
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $debug_cmd
 
+    printf '%s\n' "$progname $scriptversion"
+    $SED -n '
+        /(C)/!b go
+        :more
+        /\./!{
+          N
+          s|\n# | |
+          b more
+        }
+        :go
+        /^# Written by /,/# warranty; / {
+          s|^# ||
+          s|^# *$||
+          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
+          p
+        }
+        /^# Written by / {
+          s|^# ||
+          p
+        }
+        /^warranty; /q' < "$progpath"
 
+    exit $?
+}
 
 
-magic="%%%MAGIC variable%%%"
-magic_exe="%%%MAGIC EXE variable%%%"
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
 
-# Global variables.
-nonopt=
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-extracted_archives=
-extracted_serial=0
+# Set a version string.
+scriptversion='(GNU libtool) 2.4.6'
 
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
 
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
+# func_echo ARG...
+# ----------------
+# Libtool also displays the current mode in messages, so override
+# funclib.sh func_echo with this custom definition.
+func_echo ()
 {
-    eval "${1}=\$${1}\${2}"
-} # func_append may be replaced by extended shell implementation
+    $debug_cmd
 
-# func_append_quoted var value
-# Quote VALUE and append to the end of shell variable VAR, separated
-# by a space.
-func_append_quoted ()
-{
-    func_quote_for_eval "${2}"
-    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
-} # func_append_quoted may be replaced by extended shell implementation
+    _G_message=$*
 
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
 
-# func_arith arithmetic-term...
-func_arith ()
+
+# func_warning ARG...
+# -------------------
+# Libtool warnings are not categorized, so override funclib.sh
+# func_warning with this simpler definition.
+func_warning ()
 {
-    func_arith_result=`expr "${@}"`
-} # func_arith may be replaced by extended shell implementation
+    $debug_cmd
 
+    $warning_func ${1+"$@"}
+}
 
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
-{
-    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
-} # func_len may be replaced by extended shell implementation
 
+## ---------------- ##
+## Options parsing. ##
+## ---------------- ##
+
+# Hook in the functions to make sure our own options are parsed during
+# the option parsing loop.
+
+usage='$progpath [OPTION]... [MODE-ARG]...'
+
+# Short help message in response to '-h'.
+usage_message="Options:
+       --config             show all configuration variables
+       --debug              enable verbose shell tracing
+   -n, --dry-run            display commands without modifying any files
+       --features           display basic configuration information and exit
+       --mode=MODE          use operation mode MODE
+       --no-warnings        equivalent to '-Wnone'
+       --preserve-dup-deps  don't remove duplicate dependency libraries
+       --quiet, --silent    don't print informational messages
+       --tag=TAG            use configuration variables from tag TAG
+   -v, --verbose            print more informational messages than default
+       --version            print version information
+   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
+   -h, --help, --help-all   print short, long, or detailed help message
+"
 
-# func_lo2o object
-func_lo2o ()
+# Additional text appended to 'usage_message' in response to '--help'.
+func_help ()
 {
-    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
-} # func_lo2o may be replaced by extended shell implementation
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message
+
+MODE must be one of the following:
+
+       clean           remove files from the build directory
+       compile         compile a source file into a libtool object
+       execute         automatically set library path, then run a program
+       finish          complete the installation of libtool libraries
+       install         install libraries or executables
+       link            create a library or an executable
+       uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  When passed as first option,
+'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
+Try '$progname --help --mode=MODE' for a more detailed description of MODE.
+
+When reporting a bug, please describe a test case to reproduce it and
+include the following information:
+
+       host-triplet:   $host
+       shell:          $SHELL
+       compiler:       $LTCC
+       compiler flags: $LTCFLAGS
+       linker:         $LD (gnu? $with_gnu_ld)
+       version:        $progname (GNU libtool) 2.4.6
+       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
+       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
+
+Report bugs to <bug-libtool at gnu.org>.
+GNU libtool home page: <http://www.gnu.org/s/libtool/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>."
+    exit 0
+}
 
 
-# func_xform libobj-or-source
-func_xform ()
-{
-    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
-} # func_xform may be replaced by extended shell implementation
+# func_lo2o OBJECT-NAME
+# ---------------------
+# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
+# object suffix.
+
+lo2o=s/\\.lo\$/.$objext/
+o2lo=s/\\.$objext\$/.lo/
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_lo2o ()
+  {
+    case $1 in
+      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
+      *   ) func_lo2o_result=$1               ;;
+    esac
+  }'
+
+  # func_xform LIBOBJ-OR-SOURCE
+  # ---------------------------
+  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
+  # suffix to a '.lo' libtool-object suffix.
+  eval 'func_xform ()
+  {
+    func_xform_result=${1%.*}.lo
+  }'
+else
+  # ...otherwise fall back to using sed.
+  func_lo2o ()
+  {
+    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
+  }
+
+  func_xform ()
+  {
+    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
+  }
+fi
 
 
-# func_fatal_configuration arg...
+# func_fatal_configuration ARG...
+# -------------------------------
 # Echo program name prefixed message to standard error, followed by
 # a configuration failure hint, and exit.
 func_fatal_configuration ()
 {
-    func_error ${1+"$@"}
-    func_error "See the $PACKAGE documentation for more information."
-    func_fatal_error "Fatal configuration error."
+    func__fatal_error ${1+"$@"} \
+      "See the $PACKAGE documentation for more information." \
+      "Fatal configuration error."
 }
 
 
 # func_config
+# -----------
 # Display the configuration for all the tags in this script.
 func_config ()
 {
@@ -915,17 +2149,19 @@ func_config ()
     exit $?
 }
 
+
 # func_features
+# -------------
 # Display the features supported by this script.
 func_features ()
 {
     echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       echo "enable shared libraries"
     else
       echo "disable shared libraries"
     fi
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       echo "enable static libraries"
     else
       echo "disable static libraries"
@@ -934,314 +2170,350 @@ func_features ()
     exit $?
 }
 
-# func_enable_tag tagname
+
+# func_enable_tag TAGNAME
+# -----------------------
 # Verify that TAGNAME is valid, and either flag an error and exit, or
 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 # variable here.
 func_enable_tag ()
 {
-  # Global variable:
-  tagname="$1"
+    # Global variable:
+    tagname=$1
 
-  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
-  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
-  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+    sed_extractcf=/$re_begincf/,/$re_endcf/p
 
-  # Validate tagname.
-  case $tagname in
-    *[!-_A-Za-z0-9,/]*)
-      func_fatal_error "invalid tag name: $tagname"
-      ;;
-  esac
+    # Validate tagname.
+    case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+        func_fatal_error "invalid tag name: $tagname"
+        ;;
+    esac
 
-  # Don't test for the "default" C tag, as we know it's
-  # there but not specially marked.
-  case $tagname in
-    CC) ;;
+    # Don't test for the "default" C tag, as we know it's
+    # there but not specially marked.
+    case $tagname in
+        CC) ;;
     *)
-      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
-	taglist="$taglist $tagname"
-
-	# Evaluate the configuration.  Be careful to quote the path
-	# and the sed script, to avoid splitting on whitespace, but
-	# also don't use non-portable quotes within backquotes within
-	# quotes we have to do it in 2 steps:
-	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
-	eval "$extractedcf"
-      else
-	func_error "ignoring unknown tag $tagname"
-      fi
-      ;;
-  esac
+        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	  taglist="$taglist $tagname"
+
+	  # Evaluate the configuration.  Be careful to quote the path
+	  # and the sed script, to avoid splitting on whitespace, but
+	  # also don't use non-portable quotes within backquotes within
+	  # quotes we have to do it in 2 steps:
+	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	  eval "$extractedcf"
+        else
+	  func_error "ignoring unknown tag $tagname"
+        fi
+        ;;
+    esac
 }
 
+
 # func_check_version_match
+# ------------------------
 # Ensure that we are using m4 macros, and libtool script from the same
 # release of libtool.
 func_check_version_match ()
 {
-  if test "$package_revision" != "$macro_revision"; then
-    if test "$VERSION" != "$macro_version"; then
-      if test -z "$macro_version"; then
-        cat >&2 <<_LT_EOF
+    if test "$package_revision" != "$macro_revision"; then
+      if test "$VERSION" != "$macro_version"; then
+        if test -z "$macro_version"; then
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from an older release.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      else
-        cat >&2 <<_LT_EOF
+        else
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      fi
-    else
-      cat >&2 <<_LT_EOF
+        fi
+      else
+        cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
 $progname: of $PACKAGE $VERSION and run autoconf again.
 _LT_EOF
-    fi
+      fi
 
-    exit $EXIT_MISMATCH
-  fi
+      exit $EXIT_MISMATCH
+    fi
 }
 
 
-# Shorthand for --mode=foo, only valid as the first argument
-case $1 in
-clean|clea|cle|cl)
-  shift; set dummy --mode clean ${1+"$@"}; shift
-  ;;
-compile|compil|compi|comp|com|co|c)
-  shift; set dummy --mode compile ${1+"$@"}; shift
-  ;;
-execute|execut|execu|exec|exe|ex|e)
-  shift; set dummy --mode execute ${1+"$@"}; shift
-  ;;
-finish|finis|fini|fin|fi|f)
-  shift; set dummy --mode finish ${1+"$@"}; shift
-  ;;
-install|instal|insta|inst|ins|in|i)
-  shift; set dummy --mode install ${1+"$@"}; shift
-  ;;
-link|lin|li|l)
-  shift; set dummy --mode link ${1+"$@"}; shift
-  ;;
-uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
-  shift; set dummy --mode uninstall ${1+"$@"}; shift
-  ;;
-esac
+# libtool_options_prep [ARG]...
+# -----------------------------
+# Preparation for options parsed by libtool.
+libtool_options_prep ()
+{
+    $debug_mode
 
+    # Option defaults:
+    opt_config=false
+    opt_dlopen=
+    opt_dry_run=false
+    opt_help=false
+    opt_mode=
+    opt_preserve_dup_deps=false
+    opt_quiet=false
 
+    nonopt=
+    preserve_args=
 
-# Option defaults:
-opt_debug=:
-opt_dry_run=false
-opt_config=false
-opt_preserve_dup_deps=false
-opt_features=false
-opt_finish=false
-opt_help=false
-opt_help_all=false
-opt_silent=:
-opt_warning=:
-opt_verbose=:
-opt_silent=false
-opt_verbose=false
+    # Shorthand for --mode=foo, only valid as the first argument
+    case $1 in
+    clean|clea|cle|cl)
+      shift; set dummy --mode clean ${1+"$@"}; shift
+      ;;
+    compile|compil|compi|comp|com|co|c)
+      shift; set dummy --mode compile ${1+"$@"}; shift
+      ;;
+    execute|execut|execu|exec|exe|ex|e)
+      shift; set dummy --mode execute ${1+"$@"}; shift
+      ;;
+    finish|finis|fini|fin|fi|f)
+      shift; set dummy --mode finish ${1+"$@"}; shift
+      ;;
+    install|instal|insta|inst|ins|in|i)
+      shift; set dummy --mode install ${1+"$@"}; shift
+      ;;
+    link|lin|li|l)
+      shift; set dummy --mode link ${1+"$@"}; shift
+      ;;
+    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+      shift; set dummy --mode uninstall ${1+"$@"}; shift
+      ;;
+    esac
+
+    # Pass back the list of options.
+    func_quote_for_eval ${1+"$@"}
+    libtool_options_prep_result=$func_quote_for_eval_result
+}
+func_add_hook func_options_prep libtool_options_prep
 
 
-# Parse options once, thoroughly.  This comes as soon as possible in the
-# script to make things like `--version' happen as quickly as we can.
+# libtool_parse_options [ARG]...
+# ---------------------------------
+# Provide handling for libtool specific options.
+libtool_parse_options ()
 {
-  # this just eases exit handling
-  while test $# -gt 0; do
-    opt="$1"
-    shift
-    case $opt in
-      --debug|-x)	opt_debug='set -x'
-			func_echo "enabling shell trace mode"
-			$opt_debug
-			;;
-      --dry-run|--dryrun|-n)
-			opt_dry_run=:
-			;;
-      --config)
-			opt_config=:
-func_config
-			;;
-      --dlopen|-dlopen)
-			optarg="$1"
-			opt_dlopen="${opt_dlopen+$opt_dlopen
-}$optarg"
-			shift
-			;;
-      --preserve-dup-deps)
-			opt_preserve_dup_deps=:
-			;;
-      --features)
-			opt_features=:
-func_features
-			;;
-      --finish)
-			opt_finish=:
-set dummy --mode finish ${1+"$@"}; shift
-			;;
-      --help)
-			opt_help=:
-			;;
-      --help-all)
-			opt_help_all=:
-opt_help=': help-all'
-			;;
-      --mode)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_mode="$optarg"
-case $optarg in
-  # Valid mode arguments:
-  clean|compile|execute|finish|install|link|relink|uninstall) ;;
-
-  # Catch anything else as an error
-  *) func_error "invalid argument for $opt"
-     exit_cmd=exit
-     break
-     ;;
-esac
-			shift
-			;;
-      --no-silent|--no-quiet)
-			opt_silent=false
-func_append preserve_args " $opt"
-			;;
-      --no-warning|--no-warn)
-			opt_warning=false
-func_append preserve_args " $opt"
-			;;
-      --no-verbose)
-			opt_verbose=false
-func_append preserve_args " $opt"
-			;;
-      --silent|--quiet)
-			opt_silent=:
-func_append preserve_args " $opt"
-        opt_verbose=false
-			;;
-      --verbose|-v)
-			opt_verbose=:
-func_append preserve_args " $opt"
-opt_silent=false
-			;;
-      --tag)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_tag="$optarg"
-func_append preserve_args " $opt $optarg"
-func_enable_tag "$optarg"
-			shift
-			;;
-
-      -\?|-h)		func_usage				;;
-      --help)		func_help				;;
-      --version)	func_version				;;
-
-      # Separate optargs to long options:
-      --*=*)
-			func_split_long_opt "$opt"
-			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      # Separate non-argument short options:
-      -\?*|-h*|-n*|-v*)
-			func_split_short_opt "$opt"
-			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      --)		break					;;
-      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
-      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
-    esac
-  done
+    $debug_cmd
 
-  # Validate options:
+    # Perform our own loop to consume as many options as possible in
+    # each iteration.
+    while test $# -gt 0; do
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --dry-run|--dryrun|-n)
+                        opt_dry_run=:
+                        ;;
+
+        --config)       func_config ;;
+
+        --dlopen|-dlopen)
+                        opt_dlopen="${opt_dlopen+$opt_dlopen
+}$1"
+                        shift
+                        ;;
+
+        --preserve-dup-deps)
+                        opt_preserve_dup_deps=: ;;
+
+        --features)     func_features ;;
+
+        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
+
+        --help)         opt_help=: ;;
+
+        --help-all)     opt_help=': help-all' ;;
+
+        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_mode=$1
+                        case $1 in
+                          # Valid mode arguments:
+                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+                          # Catch anything else as an error
+                          *) func_error "invalid argument for $_G_opt"
+                             exit_cmd=exit
+                             break
+                             ;;
+                        esac
+                        shift
+                        ;;
+
+        --no-silent|--no-quiet)
+                        opt_quiet=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                        opt_warning=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-verbose)
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --silent|--quiet)
+                        opt_quiet=:
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_tag=$1
+                        func_append preserve_args " $_G_opt $1"
+                        func_enable_tag "$1"
+                        shift
+                        ;;
+
+        --verbose|-v)   opt_quiet=false
+                        opt_verbose=:
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+	# An option not handled by this hook function:
+        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
+      esac
+    done
 
-  # save first non-option argument
-  if test "$#" -gt 0; then
-    nonopt="$opt"
-    shift
-  fi
 
-  # preserve --debug
-  test "$opt_debug" = : || func_append preserve_args " --debug"
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    libtool_parse_options_result=$func_quote_for_eval_result
+}
+func_add_hook func_parse_options libtool_parse_options
 
-  case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc*)
-      # don't eliminate duplications in $postdeps and $predeps
-      opt_duplicate_compiler_generated_deps=:
-      ;;
-    *)
-      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
-      ;;
-  esac
 
-  $opt_help || {
-    # Sanity checks first:
-    func_check_version_match
 
-    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-      func_fatal_configuration "not configured to build any kind of library"
+# libtool_validate_options [ARG]...
+# ---------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+libtool_validate_options ()
+{
+    # save first non-option argument
+    if test 0 -lt $#; then
+      nonopt=$1
+      shift
     fi
 
-    # Darwin sucks
-    eval std_shrext=\"$shrext_cmds\"
+    # preserve --debug
+    test : = "$debug_cmd" || func_append preserve_args " --debug"
 
-    # Only execute mode is allowed to have -dlopen flags.
-    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
-      func_error "unrecognized option \`-dlopen'"
-      $ECHO "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
+    case $host in
+      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
+      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
+      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
+        # don't eliminate duplications in $postdeps and $predeps
+        opt_duplicate_compiler_generated_deps=:
+        ;;
+      *)
+        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+        ;;
+    esac
 
-    # Change the help message to a mode-specific one.
-    generic_help="$help"
-    help="Try \`$progname --help --mode=$opt_mode' for more information."
-  }
+    $opt_help || {
+      # Sanity checks first:
+      func_check_version_match
+
+      test yes != "$build_libtool_libs" \
+        && test yes != "$build_old_libs" \
+        && func_fatal_configuration "not configured to build any kind of library"
+
+      # Darwin sucks
+      eval std_shrext=\"$shrext_cmds\"
+
+      # Only execute mode is allowed to have -dlopen flags.
+      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
+        func_error "unrecognized option '-dlopen'"
+        $ECHO "$help" 1>&2
+        exit $EXIT_FAILURE
+      fi
 
+      # Change the help message to a mode-specific one.
+      generic_help=$help
+      help="Try '$progname --help --mode=$opt_mode' for more information."
+    }
 
-  # Bail if the options were screwed
-  $exit_cmd $EXIT_FAILURE
+    # Pass back the unparsed argument list
+    func_quote_for_eval ${1+"$@"}
+    libtool_validate_options_result=$func_quote_for_eval_result
 }
+func_add_hook func_validate_options libtool_validate_options
 
 
+# Process options as early as possible so that --help and --version
+# can return quickly.
+func_options ${1+"$@"}
+eval set dummy "$func_options_result"; shift
+
 
 
 ## ----------- ##
 ##    Main.    ##
 ## ----------- ##
 
+magic='%%%MAGIC variable%%%'
+magic_exe='%%%MAGIC EXE variable%%%'
+
+# Global variables.
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# func_generated_by_libtool
+# True iff stdin has been generated by Libtool. This function is only
+# a basic sanity check; it will hardly flush out determined imposters.
+func_generated_by_libtool_p ()
+{
+  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
 # func_lalib_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function is only a basic sanity check; it will hardly flush out
 # determined imposters.
 func_lalib_p ()
 {
     test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
-        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_lalib_unsafe_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function implements the same check as func_lalib_p without
 # resorting to external programs.  To this end, it redirects stdin and
 # closes it afterwards, without saving the original file descriptor.
 # As a safety measure, use it only where a negative result would be
-# fatal anyway.  Works if `file' does not exist.
+# fatal anyway.  Works if 'file' does not exist.
 func_lalib_unsafe_p ()
 {
     lalib_p=no
@@ -1249,13 +2521,13 @@ func_lalib_unsafe_p ()
 	for lalib_p_l in 1 2 3 4
 	do
 	    read lalib_p_line
-	    case "$lalib_p_line" in
+	    case $lalib_p_line in
 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
 	    esac
 	done
 	exec 0<&5 5<&-
     fi
-    test "$lalib_p" = yes
+    test yes = "$lalib_p"
 }
 
 # func_ltwrapper_script_p file
@@ -1264,7 +2536,8 @@ func_lalib_unsafe_p ()
 # determined imposters.
 func_ltwrapper_script_p ()
 {
-    func_lalib_p "$1"
+    test -f "$1" &&
+      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_ltwrapper_executable_p file
@@ -1289,7 +2562,7 @@ func_ltwrapper_scriptname ()
 {
     func_dirname_and_basename "$1" "" "."
     func_stripname '' '.exe' "$func_basename_result"
-    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
 }
 
 # func_ltwrapper_p file
@@ -1308,11 +2581,13 @@ func_ltwrapper_p ()
 # FAIL_CMD may read-access the current command in variable CMD!
 func_execute_cmds ()
 {
-    $opt_debug
+    $debug_cmd
+
     save_ifs=$IFS; IFS='~'
     for cmd in $1; do
-      IFS=$save_ifs
+      IFS=$sp$nl
       eval cmd=\"$cmd\"
+      IFS=$save_ifs
       func_show_eval "$cmd" "${2-:}"
     done
     IFS=$save_ifs
@@ -1324,10 +2599,11 @@ func_execute_cmds ()
 # Note that it is not necessary on cygwin/mingw to append a dot to
 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-# `FILE.' does not work on cygwin managed mounts.
+# 'FILE.' does not work on cygwin managed mounts.
 func_source ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $1 in
     */* | *\\*)	. "$1" ;;
     *)		. "./$1" ;;
@@ -1354,10 +2630,10 @@ func_resolve_sysroot ()
 # store the result into func_replace_sysroot_result.
 func_replace_sysroot ()
 {
-  case "$lt_sysroot:$1" in
+  case $lt_sysroot:$1 in
   ?*:"$lt_sysroot"*)
     func_stripname "$lt_sysroot" '' "$1"
-    func_replace_sysroot_result="=$func_stripname_result"
+    func_replace_sysroot_result='='$func_stripname_result
     ;;
   *)
     # Including no sysroot.
@@ -1374,7 +2650,8 @@ func_replace_sysroot ()
 # arg is usually of the form 'gcc ...'
 func_infer_tag ()
 {
-    $opt_debug
+    $debug_cmd
+
     if test -n "$available_tags" && test -z "$tagname"; then
       CC_quoted=
       for arg in $CC; do
@@ -1393,7 +2670,7 @@ func_infer_tag ()
 	for z in $available_tags; do
 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
 	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
 	    CC_quoted=
 	    for arg in $CC; do
 	      # Double-quote args containing other shell metacharacters.
@@ -1418,7 +2695,7 @@ func_infer_tag ()
 	# line option must be used.
 	if test -z "$tagname"; then
 	  func_echo "unable to infer tagged configuration"
-	  func_fatal_error "specify a tag with \`--tag'"
+	  func_fatal_error "specify a tag with '--tag'"
 #	else
 #	  func_verbose "using $tagname tagged configuration"
 	fi
@@ -1434,15 +2711,15 @@ func_infer_tag ()
 # but don't create it if we're doing a dry run.
 func_write_libtool_object ()
 {
-    write_libobj=${1}
-    if test "$build_libtool_libs" = yes; then
-      write_lobj=\'${2}\'
+    write_libobj=$1
+    if test yes = "$build_libtool_libs"; then
+      write_lobj=\'$2\'
     else
       write_lobj=none
     fi
 
-    if test "$build_old_libs" = yes; then
-      write_oldobj=\'${3}\'
+    if test yes = "$build_old_libs"; then
+      write_oldobj=\'$3\'
     else
       write_oldobj=none
     fi
@@ -1450,7 +2727,7 @@ func_write_libtool_object ()
     $opt_dry_run || {
       cat >${write_libobj}T <<EOF
 # $write_libobj - a libtool object file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -1462,7 +2739,7 @@ pic_object=$write_lobj
 non_pic_object=$write_oldobj
 
 EOF
-      $MV "${write_libobj}T" "${write_libobj}"
+      $MV "${write_libobj}T" "$write_libobj"
     }
 }
 
@@ -1482,8 +2759,9 @@ EOF
 # be empty on error (or when ARG is empty)
 func_convert_core_file_wine_to_w32 ()
 {
-  $opt_debug
-  func_convert_core_file_wine_to_w32_result="$1"
+  $debug_cmd
+
+  func_convert_core_file_wine_to_w32_result=$1
   if test -n "$1"; then
     # Unfortunately, winepath does not exit with a non-zero error code, so we
     # are forced to check the contents of stdout. On the other hand, if the
@@ -1491,9 +2769,9 @@ func_convert_core_file_wine_to_w32 ()
     # *an error message* to stdout. So we must check for both error code of
     # zero AND non-empty stdout, which explains the odd construction:
     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
-    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
-        $SED -e "$lt_sed_naive_backslashify"`
+        $SED -e "$sed_naive_backslashify"`
     else
       func_convert_core_file_wine_to_w32_result=
     fi
@@ -1514,18 +2792,19 @@ func_convert_core_file_wine_to_w32 ()
 # are convertible, then the result may be empty.
 func_convert_core_path_wine_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # unfortunately, winepath doesn't convert paths, only file names
-  func_convert_core_path_wine_to_w32_result=""
+  func_convert_core_path_wine_to_w32_result=
   if test -n "$1"; then
     oldIFS=$IFS
     IFS=:
     for func_convert_core_path_wine_to_w32_f in $1; do
       IFS=$oldIFS
       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
-      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+      if test -n "$func_convert_core_file_wine_to_w32_result"; then
         if test -z "$func_convert_core_path_wine_to_w32_result"; then
-          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
         else
           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
         fi
@@ -1554,7 +2833,8 @@ func_convert_core_path_wine_to_w32 ()
 # environment variable; do not put it in $PATH.
 func_cygpath ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
     if test "$?" -ne 0; then
@@ -1563,7 +2843,7 @@ func_cygpath ()
     fi
   else
     func_cygpath_result=
-    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
   fi
 }
 #end: func_cygpath
@@ -1574,10 +2854,11 @@ func_cygpath ()
 # result in func_convert_core_msys_to_w32_result.
 func_convert_core_msys_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # awkward: cmd appends spaces to result
   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
-    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
 }
 #end: func_convert_core_msys_to_w32
 
@@ -1588,13 +2869,14 @@ func_convert_core_msys_to_w32 ()
 # func_to_host_file_result to ARG1).
 func_convert_file_check ()
 {
-  $opt_debug
-  if test -z "$2" && test -n "$1" ; then
+  $debug_cmd
+
+  if test -z "$2" && test -n "$1"; then
     func_error "Could not determine host file name corresponding to"
-    func_error "  \`$1'"
+    func_error "  '$1'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback:
-    func_to_host_file_result="$1"
+    func_to_host_file_result=$1
   fi
 }
 # end func_convert_file_check
@@ -1606,10 +2888,11 @@ func_convert_file_check ()
 # func_to_host_file_result to a simplistic fallback value (see below).
 func_convert_path_check ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$4" && test -n "$3"; then
     func_error "Could not determine the host path corresponding to"
-    func_error "  \`$3'"
+    func_error "  '$3'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback.  This is a deliberately simplistic "conversion" and
     # should not be "improved".  See libtool.info.
@@ -1618,7 +2901,7 @@ func_convert_path_check ()
       func_to_host_path_result=`echo "$3" |
         $SED -e "$lt_replace_pathsep_chars"`
     else
-      func_to_host_path_result="$3"
+      func_to_host_path_result=$3
     fi
   fi
 }
@@ -1630,9 +2913,10 @@ func_convert_path_check ()
 # and appending REPL if ORIG matches BACKPAT.
 func_convert_path_front_back_pathsep ()
 {
-  $opt_debug
+  $debug_cmd
+
   case $4 in
-  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+  $1 ) func_to_host_path_result=$3$func_to_host_path_result
     ;;
   esac
   case $4 in
@@ -1646,7 +2930,7 @@ func_convert_path_front_back_pathsep ()
 ##################################################
 # $build to $host FILE NAME CONVERSION FUNCTIONS #
 ##################################################
-# invoked via `$to_host_file_cmd ARG'
+# invoked via '$to_host_file_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # Result will be available in $func_to_host_file_result.
@@ -1657,7 +2941,8 @@ func_convert_path_front_back_pathsep ()
 # in func_to_host_file_result.
 func_to_host_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   $to_host_file_cmd "$1"
 }
 # end func_to_host_file
@@ -1669,7 +2954,8 @@ func_to_host_file ()
 # in (the comma separated) LAZY, no conversion takes place.
 func_to_tool_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   case ,$2, in
     *,"$to_tool_file_cmd",*)
       func_to_tool_file_result=$1
@@ -1687,7 +2973,7 @@ func_to_tool_file ()
 # Copy ARG to func_to_host_file_result.
 func_convert_file_noop ()
 {
-  func_to_host_file_result="$1"
+  func_to_host_file_result=$1
 }
 # end func_convert_file_noop
 
@@ -1698,11 +2984,12 @@ func_convert_file_noop ()
 # func_to_host_file_result.
 func_convert_file_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_file_result=$func_convert_core_msys_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1714,8 +3001,9 @@ func_convert_file_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_file_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
     # LT_CYGPATH in this case.
@@ -1731,11 +3019,12 @@ func_convert_file_cygwin_to_w32 ()
 # and a working winepath. Returns result in func_to_host_file_result.
 func_convert_file_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_file_wine_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1747,12 +3036,13 @@ func_convert_file_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_file_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
     func_cygpath -u "$func_convert_core_msys_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1765,13 +3055,14 @@ func_convert_file_msys_to_cygwin ()
 # in func_to_host_file_result.
 func_convert_file_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
     func_convert_core_file_wine_to_w32 "$1"
     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1781,7 +3072,7 @@ func_convert_file_nix_to_cygwin ()
 #############################################
 # $build to $host PATH CONVERSION FUNCTIONS #
 #############################################
-# invoked via `$to_host_path_cmd ARG'
+# invoked via '$to_host_path_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # The result will be available in $func_to_host_path_result.
@@ -1805,10 +3096,11 @@ func_convert_file_nix_to_cygwin ()
 to_host_path_cmd=
 func_init_to_host_path_cmd ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$to_host_path_cmd"; then
     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
-    to_host_path_cmd="func_convert_path_${func_stripname_result}"
+    to_host_path_cmd=func_convert_path_$func_stripname_result
   fi
 }
 
@@ -1818,7 +3110,8 @@ func_init_to_host_path_cmd ()
 # in func_to_host_path_result.
 func_to_host_path ()
 {
-  $opt_debug
+  $debug_cmd
+
   func_init_to_host_path_cmd
   $to_host_path_cmd "$1"
 }
@@ -1829,7 +3122,7 @@ func_to_host_path ()
 # Copy ARG to func_to_host_path_result.
 func_convert_path_noop ()
 {
-  func_to_host_path_result="$1"
+  func_to_host_path_result=$1
 }
 # end func_convert_path_noop
 
@@ -1840,8 +3133,9 @@ func_convert_path_noop ()
 # func_to_host_path_result.
 func_convert_path_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from ARG.  MSYS
     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
@@ -1849,7 +3143,7 @@ func_convert_path_msys_to_w32 ()
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_path_result=$func_convert_core_msys_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1863,8 +3157,9 @@ func_convert_path_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_path_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
@@ -1883,14 +3178,15 @@ func_convert_path_cygwin_to_w32 ()
 # a working winepath.  Returns result in func_to_host_file_result.
 func_convert_path_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1904,15 +3200,16 @@ func_convert_path_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_path_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1927,8 +3224,9 @@ func_convert_path_msys_to_cygwin ()
 # func_to_host_file_result.
 func_convert_path_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from
     # ARG. msys behavior is inconsistent here, cygpath turns them
@@ -1937,7 +3235,7 @@ func_convert_path_nix_to_cygwin ()
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1946,13 +3244,31 @@ func_convert_path_nix_to_cygwin ()
 # end func_convert_path_nix_to_cygwin
 
 
+# func_dll_def_p FILE
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with _LT_DLL_DEF_P in libtool.m4
+func_dll_def_p ()
+{
+  $debug_cmd
+
+  func_dll_def_p_tmp=`$SED -n \
+    -e 's/^[	 ]*//' \
+    -e '/^\(;.*\)*$/d' \
+    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
+    -e q \
+    "$1"`
+  test DEF = "$func_dll_def_p_tmp"
+}
+
+
 # func_mode_compile arg...
 func_mode_compile ()
 {
-    $opt_debug
+    $debug_cmd
+
     # Get the compilation command and the source file.
     base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
     suppress_opt=yes
     suppress_output=
     arg_mode=normal
@@ -1965,12 +3281,12 @@ func_mode_compile ()
       case $arg_mode in
       arg  )
 	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
+	lastarg=$arg
 	arg_mode=normal
 	;;
 
       target )
-	libobj="$arg"
+	libobj=$arg
 	arg_mode=normal
 	continue
 	;;
@@ -1980,7 +3296,7 @@ func_mode_compile ()
 	case $arg in
 	-o)
 	  test -n "$libobj" && \
-	    func_fatal_error "you cannot specify \`-o' more than once"
+	    func_fatal_error "you cannot specify '-o' more than once"
 	  arg_mode=target
 	  continue
 	  ;;
@@ -2009,12 +3325,12 @@ func_mode_compile ()
 	  func_stripname '-Wc,' '' "$arg"
 	  args=$func_stripname_result
 	  lastarg=
-	  save_ifs="$IFS"; IFS=','
+	  save_ifs=$IFS; IFS=,
 	  for arg in $args; do
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 	    func_append_quoted lastarg "$arg"
 	  done
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
 	  func_stripname ' ' '' "$lastarg"
 	  lastarg=$func_stripname_result
 
@@ -2027,8 +3343,8 @@ func_mode_compile ()
 	  # Accept the current argument as the source file.
 	  # The previous "srcfile" becomes the current argument.
 	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
+	  lastarg=$srcfile
+	  srcfile=$arg
 	  ;;
 	esac  #  case $arg
 	;;
@@ -2043,13 +3359,13 @@ func_mode_compile ()
       func_fatal_error "you must specify an argument for -Xcompile"
       ;;
     target)
-      func_fatal_error "you must specify a target with \`-o'"
+      func_fatal_error "you must specify a target with '-o'"
       ;;
     *)
       # Get the name of the library object.
       test -z "$libobj" && {
 	func_basename "$srcfile"
-	libobj="$func_basename_result"
+	libobj=$func_basename_result
       }
       ;;
     esac
@@ -2069,7 +3385,7 @@ func_mode_compile ()
     case $libobj in
     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
     *)
-      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      func_fatal_error "cannot determine name of library object from '$libobj'"
       ;;
     esac
 
@@ -2078,8 +3394,8 @@ func_mode_compile ()
     for arg in $later; do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes = "$build_libtool_libs" \
+	  || func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	continue
 	;;
@@ -2105,17 +3421,17 @@ func_mode_compile ()
     func_quote_for_eval "$libobj"
     test "X$libobj" != "X$func_quote_for_eval_result" \
       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
-      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+      && func_warning "libobj name '$libobj' may not contain shell special characters."
     func_dirname_and_basename "$obj" "/" ""
-    objname="$func_basename_result"
-    xdir="$func_dirname_result"
-    lobj=${xdir}$objdir/$objname
+    objname=$func_basename_result
+    xdir=$func_dirname_result
+    lobj=$xdir$objdir/$objname
 
     test -z "$base_compile" && \
       func_fatal_help "you must specify a compilation command"
 
     # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       removelist="$obj $lobj $libobj ${libobj}T"
     else
       removelist="$lobj $libobj ${libobj}T"
@@ -2127,16 +3443,16 @@ func_mode_compile ()
       pic_mode=default
       ;;
     esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
       # non-PIC code in shared libraries is not supported
       pic_mode=default
     fi
 
     # Calculate the filename of the output object if compiler does
     # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
+    if test no = "$compiler_c_o"; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
+      lockfile=$output_obj.lock
     else
       output_obj=
       need_locks=no
@@ -2145,12 +3461,12 @@ func_mode_compile ()
 
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
+    if test yes = "$need_locks"; then
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
 	sleep 2
       done
-    elif test "$need_locks" = warn; then
+    elif test warn = "$need_locks"; then
       if test -f "$lockfile"; then
 	$ECHO "\
 *** ERROR, $lockfile exists and contains:
@@ -2158,7 +3474,7 @@ func_mode_compile ()
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2180,11 +3496,11 @@ compiler."
     qsrcfile=$func_quote_for_eval_result
 
     # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       # Without this assignment, base_compile gets emptied.
       fbsd_hideous_sh_bug=$base_compile
 
-      if test "$pic_mode" != no; then
+      if test no != "$pic_mode"; then
 	command="$base_compile $qsrcfile $pic_flag"
       else
 	# Don't build PIC code
@@ -2201,7 +3517,7 @@ compiler."
       func_show_eval_locale "$command"	\
           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2212,7 +3528,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2228,20 +3544,20 @@ compiler."
       fi
 
       # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
+      if test yes = "$suppress_opt"; then
 	suppress_output=' >/dev/null 2>&1'
       fi
     fi
 
     # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
+    if test yes = "$build_old_libs"; then
+      if test yes != "$pic_mode"; then
 	# Don't build PIC code
 	command="$base_compile $qsrcfile$pie_flag"
       else
 	command="$base_compile $qsrcfile $pic_flag"
       fi
-      if test "$compiler_c_o" = yes; then
+      if test yes = "$compiler_c_o"; then
 	func_append command " -o $obj"
       fi
 
@@ -2250,7 +3566,7 @@ compiler."
       func_show_eval_locale "$command" \
         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2261,7 +3577,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2281,7 +3597,7 @@ compiler."
       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
 
       # Unlock the critical section if it was locked
-      if test "$need_locks" != no; then
+      if test no != "$need_locks"; then
 	removelist=$lockfile
         $RM "$lockfile"
       fi
@@ -2291,7 +3607,7 @@ compiler."
 }
 
 $opt_help || {
-  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
 }
 
 func_mode_help ()
@@ -2311,7 +3627,7 @@ func_mode_help ()
 Remove files from the build directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, object or program, all the files associated
@@ -2330,16 +3646,16 @@ This mode accepts the following additional options:
   -no-suppress      do not suppress compiler output for multiple passes
   -prefer-pic       try to build PIC objects only
   -prefer-non-pic   try to build non-PIC objects only
-  -shared           do not build a \`.o' file suitable for static linking
-  -static           only build a \`.o' file suitable for static linking
+  -shared           do not build a '.o' file suitable for static linking
+  -static           only build a '.o' file suitable for static linking
   -Wc,FLAG          pass FLAG directly to the compiler
 
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+COMPILE-COMMAND is a command to be used in creating a 'standard' object file
 from the given SOURCEFILE.
 
 The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
+SOURCEFILE, then substituting the C source code suffix '.c' with the
+library object suffix, '.lo'."
         ;;
 
       execute)
@@ -2352,7 +3668,7 @@ This mode accepts the following additional options:
 
   -dlopen FILE      add the directory containing FILE to the library path
 
-This mode sets the library path environment variable according to \`-dlopen'
+This mode sets the library path environment variable according to '-dlopen'
 flags.
 
 If any of the ARGS are libtool executable wrappers, then they are translated
@@ -2371,7 +3687,7 @@ Complete the installation of libtool libraries.
 Each LIBDIR is a directory that contains libtool libraries.
 
 The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
+the '--dry-run' option if you just want to see what would be executed."
         ;;
 
       install)
@@ -2381,7 +3697,7 @@ the \`--dry-run' option if you just want to see what would be executed."
 Install executables or libraries.
 
 INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
+either the 'install' or 'cp' program.
 
 The following components of INSTALL-COMMAND are treated specially:
 
@@ -2407,7 +3723,7 @@ The following components of LINK-COMMAND are treated specially:
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
@@ -2421,7 +3737,8 @@ The following components of LINK-COMMAND are treated specially:
   -no-install       link a not-installable executable
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -objectlist FILE  use a list of object files found in FILE to specify objects
+  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
   -precious-files-regex REGEX
                     don't remove output files matching REGEX
   -release RELEASE  specify package release information
@@ -2441,20 +3758,20 @@ The following components of LINK-COMMAND are treated specially:
   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
 
-All other options (arguments beginning with \`-') are ignored.
+All other options (arguments beginning with '-') are ignored.
 
-Every other argument is treated as a filename.  Files ending in \`.la' are
+Every other argument is treated as a filename.  Files ending in '.la' are
 treated as uninstalled libtool libraries, other files are standard or library
 object files.
 
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
+If the OUTPUT-FILE ends in '.la', then a libtool library is created,
+only library objects ('.lo' files) may be specified, and '-rpath' is
 required, except when creating a convenience library.
 
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
+If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
+using 'ar' and 'ranlib', or on Windows using 'lib'.
 
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
 is created, otherwise an executable program is created."
         ;;
 
@@ -2465,7 +3782,7 @@ is created, otherwise an executable program is created."
 Remove libraries from an installation directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, all the files associated with it are deleted.
@@ -2473,17 +3790,17 @@ Otherwise, only FILE itself is deleted using RM."
         ;;
 
       *)
-        func_fatal_help "invalid operation mode \`$opt_mode'"
+        func_fatal_help "invalid operation mode '$opt_mode'"
         ;;
     esac
 
     echo
-    $ECHO "Try \`$progname --help' for more information about other modes."
+    $ECHO "Try '$progname --help' for more information about other modes."
 }
 
 # Now that we've collected a possible --mode arg, show help if necessary
 if $opt_help; then
-  if test "$opt_help" = :; then
+  if test : = "$opt_help"; then
     func_mode_help
   else
     {
@@ -2491,7 +3808,7 @@ if $opt_help; then
       for opt_mode in compile link execute install finish uninstall clean; do
 	func_mode_help
       done
-    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
     {
       func_help noexit
       for opt_mode in compile link execute install finish uninstall clean; do
@@ -2499,7 +3816,7 @@ if $opt_help; then
 	func_mode_help
       done
     } |
-    sed '1d
+    $SED '1d
       /^When reporting/,/^Report/{
 	H
 	d
@@ -2516,16 +3833,17 @@ fi
 # func_mode_execute arg...
 func_mode_execute ()
 {
-    $opt_debug
+    $debug_cmd
+
     # The first argument is the command name.
-    cmd="$nonopt"
+    cmd=$nonopt
     test -z "$cmd" && \
       func_fatal_help "you must specify a COMMAND"
 
     # Handle -dlopen flags immediately.
     for file in $opt_dlopen; do
       test -f "$file" \
-	|| func_fatal_help "\`$file' is not a file"
+	|| func_fatal_help "'$file' is not a file"
 
       dir=
       case $file in
@@ -2535,7 +3853,7 @@ func_mode_execute ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+	  || func_fatal_help "'$lib' is not a valid libtool archive"
 
 	# Read the libtool library.
 	dlname=
@@ -2546,18 +3864,18 @@ func_mode_execute ()
 	if test -z "$dlname"; then
 	  # Warn if it was a shared library.
 	  test -n "$library_names" && \
-	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	    func_warning "'$file' was not linked with '-export-dynamic'"
 	  continue
 	fi
 
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 
 	if test -f "$dir/$objdir/$dlname"; then
 	  func_append dir "/$objdir"
 	else
 	  if test ! -f "$dir/$dlname"; then
-	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
 	  fi
 	fi
 	;;
@@ -2565,18 +3883,18 @@ func_mode_execute ()
       *.lo)
 	# Just add the directory containing the .lo file.
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	;;
 
       *)
-	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
 	continue
 	;;
       esac
 
       # Get the absolute pathname.
       absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
+      test -n "$absdir" && dir=$absdir
 
       # Now add the directory to shlibpath_var.
       if eval "test -z \"\$$shlibpath_var\""; then
@@ -2588,7 +3906,7 @@ func_mode_execute ()
 
     # This variable tells wrapper scripts just to set shlibpath_var
     # rather than running their programs.
-    libtool_execute_magic="$magic"
+    libtool_execute_magic=$magic
 
     # Check if any of the arguments is a wrapper script.
     args=
@@ -2601,12 +3919,12 @@ func_mode_execute ()
 	if func_ltwrapper_script_p "$file"; then
 	  func_source "$file"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	elif func_ltwrapper_executable_p "$file"; then
 	  func_ltwrapper_scriptname "$file"
 	  func_source "$func_ltwrapper_scriptname_result"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	fi
 	;;
       esac
@@ -2614,7 +3932,15 @@ func_mode_execute ()
       func_append_quoted args "$file"
     done
 
-    if test "X$opt_dry_run" = Xfalse; then
+    if $opt_dry_run; then
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    else
       if test -n "$shlibpath_var"; then
 	# Export the shlibpath_var.
 	eval "export $shlibpath_var"
@@ -2631,25 +3957,18 @@ func_mode_execute ()
       done
 
       # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
-	echo "export $shlibpath_var"
-      fi
-      $ECHO "$cmd$args"
-      exit $EXIT_SUCCESS
+      exec_cmd=\$cmd$args
     fi
 }
 
-test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
 
 
 # func_mode_finish arg...
 func_mode_finish ()
 {
-    $opt_debug
+    $debug_cmd
+
     libs=
     libdirs=
     admincmds=
@@ -2663,11 +3982,11 @@ func_mode_finish ()
 	if func_lalib_unsafe_p "$opt"; then
 	  func_append libs " $opt"
 	else
-	  func_warning "\`$opt' is not a valid libtool archive"
+	  func_warning "'$opt' is not a valid libtool archive"
 	fi
 
       else
-	func_fatal_error "invalid argument \`$opt'"
+	func_fatal_error "invalid argument '$opt'"
       fi
     done
 
@@ -2682,12 +4001,12 @@ func_mode_finish ()
       # Remove sysroot references
       if $opt_dry_run; then
         for lib in $libs; do
-          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
         done
       else
         tmpdir=`func_mktempdir`
         for lib in $libs; do
-	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
 	    > $tmpdir/tmp-la
 	  mv -f $tmpdir/tmp-la $lib
 	done
@@ -2712,7 +4031,7 @@ func_mode_finish ()
     fi
 
     # Exit here if they wanted silent mode.
-    $opt_silent && exit $EXIT_SUCCESS
+    $opt_quiet && exit $EXIT_SUCCESS
 
     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
       echo "----------------------------------------------------------------------"
@@ -2723,27 +4042,27 @@ func_mode_finish ()
       echo
       echo "If you ever happen to want to link against installed libraries"
       echo "in a given directory, LIBDIR, you must either use libtool, and"
-      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
       echo "flag during linking and do at least one of the following:"
       if test -n "$shlibpath_var"; then
-	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
 	echo "     during execution"
       fi
       if test -n "$runpath_var"; then
-	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+	echo "   - add LIBDIR to the '$runpath_var' environment variable"
 	echo "     during linking"
       fi
       if test -n "$hardcode_libdir_flag_spec"; then
 	libdir=LIBDIR
 	eval flag=\"$hardcode_libdir_flag_spec\"
 
-	$ECHO "   - use the \`$flag' linker flag"
+	$ECHO "   - use the '$flag' linker flag"
       fi
       if test -n "$admincmds"; then
 	$ECHO "   - have your system administrator run these commands:$admincmds"
       fi
       if test -f /etc/ld.so.conf; then
-	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
       fi
       echo
 
@@ -2762,18 +4081,20 @@ func_mode_finish ()
     exit $EXIT_SUCCESS
 }
 
-test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
 
 
 # func_mode_install arg...
 func_mode_install ()
 {
-    $opt_debug
+    $debug_cmd
+
     # There may be an optional sh(1) argument at the beginning of
     # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
        # Allow the use of GNU shtool's install command.
-       case $nonopt in *shtool*) :;; *) false;; esac; then
+       case $nonopt in *shtool*) :;; *) false;; esac
+    then
       # Aesthetically quote it.
       func_quote_for_eval "$nonopt"
       install_prog="$func_quote_for_eval_result "
@@ -2800,7 +4121,7 @@ func_mode_install ()
     opts=
     prev=
     install_type=
-    isdir=no
+    isdir=false
     stripme=
     no_mode=:
     for arg
@@ -2813,7 +4134,7 @@ func_mode_install ()
       fi
 
       case $arg in
-      -d) isdir=yes ;;
+      -d) isdir=: ;;
       -f)
 	if $install_cp; then :; else
 	  prev=$arg
@@ -2831,7 +4152,7 @@ func_mode_install ()
       *)
 	# If the previous option needed an argument, then skip it.
 	if test -n "$prev"; then
-	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
+	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
 	    arg2=$install_override_mode
 	    no_mode=false
 	  fi
@@ -2856,7 +4177,7 @@ func_mode_install ()
       func_fatal_help "you must specify an install program"
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prev' option requires an argument"
+      func_fatal_help "the '$prev' option requires an argument"
 
     if test -n "$install_override_mode" && $no_mode; then
       if $install_cp; then :; else
@@ -2878,19 +4199,19 @@ func_mode_install ()
     dest=$func_stripname_result
 
     # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
+    test -d "$dest" && isdir=:
+    if $isdir; then
+      destdir=$dest
       destname=
     else
       func_dirname_and_basename "$dest" "" "."
-      destdir="$func_dirname_result"
-      destname="$func_basename_result"
+      destdir=$func_dirname_result
+      destname=$func_basename_result
 
       # Not a directory, so check to see that there is only one file specified.
       set dummy $files; shift
       test "$#" -gt 1 && \
-	func_fatal_help "\`$dest' is not a directory"
+	func_fatal_help "'$dest' is not a directory"
     fi
     case $destdir in
     [\\/]* | [A-Za-z]:[\\/]*) ;;
@@ -2899,7 +4220,7 @@ func_mode_install ()
 	case $file in
 	*.lo) ;;
 	*)
-	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  func_fatal_help "'$destdir' must be an absolute directory name"
 	  ;;
 	esac
       done
@@ -2908,7 +4229,7 @@ func_mode_install ()
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     staticlibs=
     future_libdirs=
@@ -2928,7 +4249,7 @@ func_mode_install ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$file' is not a valid libtool archive"
+	  || func_fatal_help "'$file' is not a valid libtool archive"
 
 	library_names=
 	old_library=
@@ -2950,7 +4271,7 @@ func_mode_install ()
 	fi
 
 	func_dirname "$file" "/" ""
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	func_append dir "$objdir"
 
 	if test -n "$relink_command"; then
@@ -2964,7 +4285,7 @@ func_mode_install ()
 	  # are installed into $libdir/../bin (currently, that works fine)
 	  # but it's something to keep an eye on.
 	  test "$inst_prefix_dir" = "$destdir" && \
-	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
@@ -2973,29 +4294,36 @@ func_mode_install ()
 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
 	  fi
 
-	  func_warning "relinking \`$file'"
+	  func_warning "relinking '$file'"
 	  func_show_eval "$relink_command" \
-	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
 	fi
 
 	# See the names of the shared library.
 	set dummy $library_names; shift
 	if test -n "$1"; then
-	  realname="$1"
+	  realname=$1
 	  shift
 
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
+	  srcname=$realname
+	  test -n "$relink_command" && srcname=${realname}T
 
 	  # Install the shared library and build the symlinks.
 	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
 	      'exit $?'
-	  tstripme="$stripme"
+	  tstripme=$stripme
 	  case $host_os in
 	  cygwin* | mingw* | pw32* | cegcc*)
 	    case $realname in
 	    *.dll.a)
-	      tstripme=""
+	      tstripme=
+	      ;;
+	    esac
+	    ;;
+	  os2*)
+	    case $realname in
+	    *_dll.a)
+	      tstripme=
 	      ;;
 	    esac
 	    ;;
@@ -3006,7 +4334,7 @@ func_mode_install ()
 
 	  if test "$#" -gt 0; then
 	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # Try 'ln -sf' first, because the 'ln' binary might depend on
 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
 	    # so we also need to try rm && ln -s.
 	    for linkname
@@ -3017,14 +4345,14 @@ func_mode_install ()
 	  fi
 
 	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
+	  lib=$destdir/$realname
 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
 	fi
 
 	# Install the pseudo-library for information purposes.
 	func_basename "$file"
-	name="$func_basename_result"
-	instname="$dir/$name"i
+	name=$func_basename_result
+	instname=$dir/${name}i
 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
 
 	# Maybe install the static library, too.
@@ -3036,11 +4364,11 @@ func_mode_install ()
 
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# Deduce the name of the destination old-style object file.
@@ -3050,11 +4378,11 @@ func_mode_install ()
 	  staticdest=$func_lo2o_result
 	  ;;
 	*.$objext)
-	  staticdest="$destfile"
+	  staticdest=$destfile
 	  destfile=
 	  ;;
 	*)
-	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  func_fatal_help "cannot copy a libtool object to '$destfile'"
 	  ;;
 	esac
 
@@ -3063,7 +4391,7 @@ func_mode_install ()
 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
 
 	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
+	if test yes = "$build_old_libs"; then
 	  # Deduce the name of the old-style object file.
 	  func_lo2o "$file"
 	  staticobj=$func_lo2o_result
@@ -3075,23 +4403,23 @@ func_mode_install ()
       *)
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# If the file is missing, and there is a .exe on the end, strip it
 	# because it is most likely a libtool script we actually want to
 	# install
-	stripped_ext=""
+	stripped_ext=
 	case $file in
 	  *.exe)
 	    if test ! -f "$file"; then
 	      func_stripname '' '.exe' "$file"
 	      file=$func_stripname_result
-	      stripped_ext=".exe"
+	      stripped_ext=.exe
 	    fi
 	    ;;
 	esac
@@ -3119,19 +4447,19 @@ func_mode_install ()
 
 	  # Check the variables that should have been set.
 	  test -z "$generated_by_libtool_version" && \
-	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
 
-	  finalize=yes
+	  finalize=:
 	  for lib in $notinst_deplibs; do
 	    # Check to see that each library is installed.
 	    libdir=
 	    if test -f "$lib"; then
 	      func_source "$lib"
 	    fi
-	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
 	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      func_warning "\`$lib' has not been installed in \`$libdir'"
-	      finalize=no
+	      func_warning "'$lib' has not been installed in '$libdir'"
+	      finalize=false
 	    fi
 	  done
 
@@ -3139,29 +4467,29 @@ func_mode_install ()
 	  func_source "$wrapper"
 
 	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
+	  if test no = "$fast_install" && test -n "$relink_command"; then
 	    $opt_dry_run || {
-	      if test "$finalize" = yes; then
+	      if $finalize; then
 	        tmpdir=`func_mktempdir`
 		func_basename "$file$stripped_ext"
-		file="$func_basename_result"
-	        outputname="$tmpdir/$file"
+		file=$func_basename_result
+	        outputname=$tmpdir/$file
 	        # Replace the output file specification.
 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
 
-	        $opt_silent || {
+	        $opt_quiet || {
 	          func_quote_for_expand "$relink_command"
 		  eval "func_echo $func_quote_for_expand_result"
 	        }
 	        if eval "$relink_command"; then :
 	          else
-		  func_error "error: relink \`$file' with the above command before installing it"
+		  func_error "error: relink '$file' with the above command before installing it"
 		  $opt_dry_run || ${RM}r "$tmpdir"
 		  continue
 	        fi
-	        file="$outputname"
+	        file=$outputname
 	      else
-	        func_warning "cannot relink \`$file'"
+	        func_warning "cannot relink '$file'"
 	      fi
 	    }
 	  else
@@ -3198,10 +4526,10 @@ func_mode_install ()
 
     for file in $staticlibs; do
       func_basename "$file"
-      name="$func_basename_result"
+      name=$func_basename_result
 
       # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
+      oldlib=$destdir/$name
       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
       tool_oldlib=$func_to_tool_file_result
 
@@ -3216,18 +4544,18 @@ func_mode_install ()
     done
 
     test -n "$future_libdirs" && \
-      func_warning "remember to run \`$progname --finish$future_libdirs'"
+      func_warning "remember to run '$progname --finish$future_libdirs'"
 
     if test -n "$current_libdirs"; then
       # Maybe just do a dry run.
       $opt_dry_run && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
     else
       exit $EXIT_SUCCESS
     fi
 }
 
-test "$opt_mode" = install && func_mode_install ${1+"$@"}
+test install = "$opt_mode" && func_mode_install ${1+"$@"}
 
 
 # func_generate_dlsyms outputname originator pic_p
@@ -3235,16 +4563,17 @@ test "$opt_mode" = install && func_mode_install ${1+"$@"}
 # a dlpreopen symbol table.
 func_generate_dlsyms ()
 {
-    $opt_debug
-    my_outputname="$1"
-    my_originator="$2"
-    my_pic_p="${3-no}"
-    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    $debug_cmd
+
+    my_outputname=$1
+    my_originator=$2
+    my_pic_p=${3-false}
+    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
     my_dlsyms=
 
-    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
       if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	my_dlsyms="${my_outputname}S.c"
+	my_dlsyms=${my_outputname}S.c
       else
 	func_error "not configured to extract global symbols from dlpreopened files"
       fi
@@ -3255,7 +4584,7 @@ func_generate_dlsyms ()
       "") ;;
       *.c)
 	# Discover the nlist of each of the dlfiles.
-	nlist="$output_objdir/${my_outputname}.nm"
+	nlist=$output_objdir/$my_outputname.nm
 
 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
 
@@ -3263,34 +4592,36 @@ func_generate_dlsyms ()
 	func_verbose "creating $output_objdir/$my_dlsyms"
 
 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
-/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
-/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
 
 #ifdef __cplusplus
 extern \"C\" {
 #endif
 
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
 #endif
 
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
 # define LT_DLSYM_CONST const
 #endif
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* External symbol declarations for the compiler. */\
 "
 
-	if test "$dlself" = yes; then
-	  func_verbose "generating symbol list for \`$output'"
+	if test yes = "$dlself"; then
+	  func_verbose "generating symbol list for '$output'"
 
 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
 
@@ -3298,7 +4629,7 @@ extern \"C\" {
 	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	  for progfile in $progfiles; do
 	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
-	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
 	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
 	  done
 
@@ -3318,10 +4649,10 @@ extern \"C\" {
 
 	  # Prepare the list of exported symbols
 	  if test -z "$export_symbols"; then
-	    export_symbols="$output_objdir/$outputname.exp"
+	    export_symbols=$output_objdir/$outputname.exp
 	    $opt_dry_run || {
 	      $RM $export_symbols
-	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 	      case $host in
 	      *cygwin* | *mingw* | *cegcc* )
                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
@@ -3331,7 +4662,7 @@ extern \"C\" {
 	    }
 	  else
 	    $opt_dry_run || {
-	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 	      eval '$MV "$nlist"T "$nlist"'
 	      case $host in
@@ -3345,22 +4676,22 @@ extern \"C\" {
 	fi
 
 	for dlprefile in $dlprefiles; do
-	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_verbose "extracting global C symbols from '$dlprefile'"
 	  func_basename "$dlprefile"
-	  name="$func_basename_result"
+	  name=$func_basename_result
           case $host in
 	    *cygwin* | *mingw* | *cegcc* )
 	      # if an import library, we need to obtain dlname
 	      if func_win32_import_lib_p "$dlprefile"; then
 	        func_tr_sh "$dlprefile"
 	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
-	        dlprefile_dlbasename=""
+	        dlprefile_dlbasename=
 	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
 	          # Use subshell, to avoid clobbering current variable values
 	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
-	          if test -n "$dlprefile_dlname" ; then
+	          if test -n "$dlprefile_dlname"; then
 	            func_basename "$dlprefile_dlname"
-	            dlprefile_dlbasename="$func_basename_result"
+	            dlprefile_dlbasename=$func_basename_result
 	          else
 	            # no lafile. user explicitly requested -dlpreopen <import library>.
 	            $sharedlib_from_linklib_cmd "$dlprefile"
@@ -3368,7 +4699,7 @@ extern \"C\" {
 	          fi
 	        fi
 	        $opt_dry_run || {
-	          if test -n "$dlprefile_dlbasename" ; then
+	          if test -n "$dlprefile_dlbasename"; then
 	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
 	          else
 	            func_warning "Could not compute DLL name from $name"
@@ -3424,6 +4755,11 @@ extern \"C\" {
 	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
 	  fi
 
+	  func_show_eval '$RM "${nlist}I"'
+	  if test -n "$global_symbol_to_import"; then
+	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
+	  fi
+
 	  echo >> "$output_objdir/$my_dlsyms" "\
 
 /* The mapping between symbol names and symbols.  */
@@ -3432,11 +4768,30 @@ typedef struct {
   void *address;
 } lt_dlsymlist;
 extern LT_DLSYM_CONST lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[];
+lt_${my_prefix}_LTX_preloaded_symbols[];\
+"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+static void lt_syminit(void)
+{
+  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
+  for (; symbol->name; ++symbol)
+    {"
+	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
+	    echo >> "$output_objdir/$my_dlsyms" "\
+    }
+}"
+	  fi
+	  echo >> "$output_objdir/$my_dlsyms" "\
 LT_DLSYM_CONST lt_dlsymlist
 lt_${my_prefix}_LTX_preloaded_symbols[] =
-{\
-  { \"$my_originator\", (void *) 0 },"
+{ {\"$my_originator\", (void *) 0},"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+  {\"@INIT@\", (void *) &lt_syminit},"
+	  fi
 
 	  case $need_lib_prefix in
 	  no)
@@ -3478,9 +4833,7 @@ static const void *lt_preloaded_setup() {
 	  *-*-hpux*)
 	    pic_flag_for_symtable=" $pic_flag"  ;;
 	  *)
-	    if test "X$my_pic_p" != Xno; then
-	      pic_flag_for_symtable=" $pic_flag"
-	    fi
+	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
 	    ;;
 	  esac
 	  ;;
@@ -3497,10 +4850,10 @@ static const void *lt_preloaded_setup() {
 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
 
 	# Clean up the generated files.
-	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
 
 	# Transform the symbol file into the correct name.
-	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	symfileobj=$output_objdir/${my_outputname}S.$objext
 	case $host in
 	*cygwin* | *mingw* | *cegcc* )
 	  if test -f "$output_objdir/$my_outputname.def"; then
@@ -3518,7 +4871,7 @@ static const void *lt_preloaded_setup() {
 	esac
 	;;
       *)
-	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	func_fatal_error "unknown suffix for '$my_dlsyms'"
 	;;
       esac
     else
@@ -3532,6 +4885,32 @@ static const void *lt_preloaded_setup() {
     fi
 }
 
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+  test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+  test -n "$func_cygming_ms_implib_tmp"
+}
+
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -3541,8 +4920,9 @@ static const void *lt_preloaded_setup() {
 # Despite the name, also deal with 64 bit binaries.
 func_win32_libid ()
 {
-  $opt_debug
-  win32_libid_type="unknown"
+  $debug_cmd
+
+  win32_libid_type=unknown
   win32_fileres=`file -L $1 2>/dev/null`
   case $win32_fileres in
   *ar\ archive\ import\ library*) # definitely import
@@ -3552,16 +4932,29 @@ func_win32_libid ()
     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
-      func_to_tool_file "$1" func_convert_file_msys_to_w32
-      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
-	$SED -n -e '
+      case $nm_interface in
+      "MS dumpbin")
+	if func_cygming_ms_implib_p "$1" ||
+	   func_cygming_gnu_implib_p "$1"
+	then
+	  win32_nmres=import
+	else
+	  win32_nmres=
+	fi
+	;;
+      *)
+	func_to_tool_file "$1" func_convert_file_msys_to_w32
+	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+	  $SED -n -e '
 	    1,100{
 		/ I /{
-		    s,.*,import,
+		    s|.*|import|
 		    p
 		    q
 		}
 	    }'`
+	;;
+      esac
       case $win32_nmres in
       import*)  win32_libid_type="x86 archive import";;
       *)        win32_libid_type="x86 archive static";;
@@ -3593,7 +4986,8 @@ func_win32_libid ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib ()
 {
-  $opt_debug
+  $debug_cmd
+
   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
 }
 
@@ -3610,7 +5004,8 @@ func_cygming_dll_for_implib ()
 # specified import library.
 func_cygming_dll_for_implib_fallback_core ()
 {
-  $opt_debug
+  $debug_cmd
+
   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
     $SED '/^Contents of section '"$match_literal"':/{
@@ -3646,8 +5041,8 @@ func_cygming_dll_for_implib_fallback_core ()
       /./p' |
     # we now have a list, one entry per line, of the stringified
     # contents of the appropriate section of all members of the
-    # archive which possess that section. Heuristic: eliminate
-    # all those which have a first or second character that is
+    # archive that possess that section. Heuristic: eliminate
+    # all those that have a first or second character that is
     # a '.' (that is, objdump's representation of an unprintable
     # character.) This should work for all archives with less than
     # 0x302f exports -- but will fail for DLLs whose name actually
@@ -3658,30 +5053,6 @@ func_cygming_dll_for_implib_fallback_core ()
     $SED -e '/^\./d;/^.\./d;q'
 }
 
-# func_cygming_gnu_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is a GNU/binutils-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_gnu_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
-  test -n "$func_cygming_gnu_implib_tmp"
-}
-
-# func_cygming_ms_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is an MS-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_ms_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
-  test -n "$func_cygming_ms_implib_tmp"
-}
-
 # func_cygming_dll_for_implib_fallback ARG
 # Platform-specific function to extract the
 # name of the DLL associated with the specified
@@ -3695,16 +5066,17 @@ func_cygming_ms_implib_p ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib_fallback ()
 {
-  $opt_debug
-  if func_cygming_gnu_implib_p "$1" ; then
+  $debug_cmd
+
+  if func_cygming_gnu_implib_p "$1"; then
     # binutils import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
-  elif func_cygming_ms_implib_p "$1" ; then
+  elif func_cygming_ms_implib_p "$1"; then
     # ms-generated import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
   else
     # unknown
-    sharedlib_from_linklib_result=""
+    sharedlib_from_linklib_result=
   fi
 }
 
@@ -3712,10 +5084,11 @@ func_cygming_dll_for_implib_fallback ()
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
-    $opt_debug
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-    if test "$lock_old_archive_extraction" = yes; then
+    $debug_cmd
+
+    f_ex_an_ar_dir=$1; shift
+    f_ex_an_ar_oldlib=$1
+    if test yes = "$lock_old_archive_extraction"; then
       lockfile=$f_ex_an_ar_oldlib.lock
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
@@ -3724,7 +5097,7 @@ func_extract_an_archive ()
     fi
     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
 		   'stat=$?; rm -f "$lockfile"; exit $stat'
-    if test "$lock_old_archive_extraction" = yes; then
+    if test yes = "$lock_old_archive_extraction"; then
       $opt_dry_run || rm -f "$lockfile"
     fi
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
@@ -3738,22 +5111,23 @@ func_extract_an_archive ()
 # func_extract_archives gentop oldlib ...
 func_extract_archives ()
 {
-    $opt_debug
-    my_gentop="$1"; shift
+    $debug_cmd
+
+    my_gentop=$1; shift
     my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
+    my_oldobjs=
+    my_xlib=
+    my_xabs=
+    my_xdir=
 
     for my_xlib in $my_oldlibs; do
       # Extract the objects.
       case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       func_basename "$my_xlib"
-      my_xlib="$func_basename_result"
+      my_xlib=$func_basename_result
       my_xlib_u=$my_xlib
       while :; do
         case " $extracted_archives " in
@@ -3765,7 +5139,7 @@ func_extract_archives ()
 	esac
       done
       extracted_archives="$extracted_archives $my_xlib_u"
-      my_xdir="$my_gentop/$my_xlib_u"
+      my_xdir=$my_gentop/$my_xlib_u
 
       func_mkdir_p "$my_xdir"
 
@@ -3778,22 +5152,23 @@ func_extract_archives ()
 	  cd $my_xdir || exit $?
 	  darwin_archive=$my_xabs
 	  darwin_curdir=`pwd`
-	  darwin_base_archive=`basename "$darwin_archive"`
+	  func_basename "$darwin_archive"
+	  darwin_base_archive=$func_basename_result
 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
 	  if test -n "$darwin_arches"; then
 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
 	    darwin_arch=
 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	    for darwin_arch in  $darwin_arches; do
+	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
+	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
 	      cd "$darwin_curdir"
-	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
 	    done # $darwin_arches
             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
 	    darwin_file=
 	    darwin_files=
 	    for darwin_file in $darwin_filelist; do
@@ -3815,7 +5190,7 @@ func_extract_archives ()
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
     done
 
-    func_extract_archives_result="$my_oldobjs"
+    func_extract_archives_result=$my_oldobjs
 }
 
 
@@ -3830,7 +5205,7 @@ func_extract_archives ()
 #
 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
 # variable will take.  If 'yes', then the emitted script
-# will assume that the directory in which it is stored is
+# will assume that the directory where it is stored is
 # the $objdir directory.  This is a cygwin/mingw-specific
 # behavior.
 func_emit_wrapper ()
@@ -3841,7 +5216,7 @@ func_emit_wrapper ()
 #! $SHELL
 
 # $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # The $output program cannot be directly executed until all the libtool
 # libraries that it depends on are installed.
@@ -3898,9 +5273,9 @@ _LTECHO_EOF'
 
 # Very basic option parsing. These options are (a) specific to
 # the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
+# /script/ and the wrapper /executable/ that is used only on
 # windows platforms, and (c) all begin with the string "--lt-"
-# (application programs are unlikely to have options which match
+# (application programs are unlikely to have options that match
 # this pattern).
 #
 # There are only two supported options: --lt-debug and
@@ -3933,7 +5308,7 @@ func_parse_lt_options ()
 
   # Print the debug banner immediately:
   if test -n \"\$lt_option_debug\"; then
-    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
   fi
 }
 
@@ -3944,7 +5319,7 @@ func_lt_dump_args ()
   lt_dump_args_N=1;
   for lt_arg
   do
-    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
   done
 }
@@ -3958,7 +5333,7 @@ func_exec_program_core ()
   *-*-mingw | *-*-os2* | *-cegcc*)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
@@ -3968,7 +5343,7 @@ func_exec_program_core ()
   *)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir/\$program\" \${1+\"\$@\"}
@@ -4043,13 +5418,13 @@ func_exec_program ()
   test -n \"\$absdir\" && thisdir=\"\$absdir\"
 "
 
-	if test "$fast_install" = yes; then
+	if test yes = "$fast_install"; then
 	  $ECHO "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" ||
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 
     file=\"\$\$-\$program\"
@@ -4066,7 +5441,7 @@ func_exec_program ()
     if test -n \"\$relink_command\"; then
       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
       else
-	$ECHO \"\$relink_command_output\" >&2
+	\$ECHO \"\$relink_command_output\" >&2
 	$RM \"\$progdir/\$file\"
 	exit 1
       fi
@@ -4101,7 +5476,7 @@ func_exec_program ()
 	fi
 
 	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 	  $ECHO "\
     # Add our own library path to $shlibpath_var
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
@@ -4121,7 +5496,7 @@ func_exec_program ()
     fi
   else
     # The program doesn't exist.
-    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
     exit 1
@@ -4140,7 +5515,7 @@ func_emit_cwrapperexe_src ()
 	cat <<EOF
 
 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 
    The $output program cannot be directly executed until all the libtool
    libraries that it depends on are installed.
@@ -4175,47 +5550,45 @@ EOF
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* declarations of non-ANSI functions */
-#if defined(__MINGW32__)
+#if defined __MINGW32__
 # ifdef __STRICT_ANSI__
 int _putenv (const char *);
 # endif
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # ifdef __STRICT_ANSI__
 char *realpath (const char *, char *);
 int putenv (char *);
 int setenv (const char *, const char *, int);
 # endif
-/* #elif defined (other platforms) ... */
+/* #elif defined other_platform || defined ... */
 #endif
 
 /* portability defines, excluding path handling macros */
-#if defined(_MSC_VER)
+#if defined _MSC_VER
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
 # define S_IXUSR _S_IEXEC
-# ifndef _INTPTR_T_DEFINED
-#  define _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#elif defined(__MINGW32__)
+#elif defined __MINGW32__
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # define HAVE_SETENV
 # define FOPEN_WB "wb"
-/* #elif defined (other platforms) ... */
+/* #elif defined other platforms ... */
 #endif
 
-#if defined(PATH_MAX)
+#if defined PATH_MAX
 # define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
+#elif defined MAXPATHLEN
 # define LT_PATHMAX MAXPATHLEN
 #else
 # define LT_PATHMAX 1024
@@ -4234,8 +5607,8 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
+  defined __OS2__
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"
 # ifndef DIR_SEPARATOR_2
@@ -4268,10 +5641,10 @@ int setenv (const char *, const char *, int);
 
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
+  if (stale) { free (stale); stale = 0; } \
 } while (0)
 
-#if defined(LT_DEBUGWRAPPER)
+#if defined LT_DEBUGWRAPPER
 static int lt_debug = 1;
 #else
 static int lt_debug = 0;
@@ -4300,11 +5673,16 @@ void lt_dump_script (FILE *f);
 EOF
 
 	    cat <<EOF
-volatile const char * MAGIC_EXE = "$magic_exe";
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
+# define externally_visible volatile
+#else
+# define externally_visible __attribute__((externally_visible)) volatile
+#endif
+externally_visible const char * MAGIC_EXE = "$magic_exe";
 const char * LIB_PATH_VARNAME = "$shlibpath_var";
 EOF
 
-	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
               func_to_host_path "$temp_rpath"
 	      cat <<EOF
 const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
@@ -4328,7 +5706,7 @@ const char * EXE_PATH_VALUE   = "";
 EOF
 	    fi
 
-	    if test "$fast_install" = yes; then
+	    if test yes = "$fast_install"; then
 	      cat <<EOF
 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
 EOF
@@ -4357,12 +5735,12 @@ main (int argc, char *argv[])
   char *actual_cwrapper_name;
   char *target_name;
   char *lt_argv_zero;
-  intptr_t rval = 127;
+  int rval = 127;
 
   int i;
 
   program_name = (char *) xstrdup (base_name (argv[0]));
-  newargz = XMALLOC (char *, argc + 1);
+  newargz = XMALLOC (char *, (size_t) argc + 1);
 
   /* very simple arg parsing; don't want to rely on getopt
    * also, copy all non cwrapper options to newargz, except
@@ -4371,10 +5749,10 @@ main (int argc, char *argv[])
   newargc=0;
   for (i = 1; i < argc; i++)
     {
-      if (strcmp (argv[i], dumpscript_opt) == 0)
+      if (STREQ (argv[i], dumpscript_opt))
 	{
 EOF
-	    case "$host" in
+	    case $host in
 	      *mingw* | *cygwin* )
 		# make stdout use "unix" line endings
 		echo "          setmode(1,_O_BINARY);"
@@ -4385,12 +5763,12 @@ EOF
 	  lt_dump_script (stdout);
 	  return 0;
 	}
-      if (strcmp (argv[i], debug_opt) == 0)
+      if (STREQ (argv[i], debug_opt))
 	{
           lt_debug = 1;
           continue;
 	}
-      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+      if (STREQ (argv[i], ltwrapper_option_prefix))
         {
           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
              namespace, but it is not one of the ones we know about and
@@ -4413,7 +5791,7 @@ EOF
 EOF
 	    cat <<EOF
   /* The GNU banner must be the first non-error debug message */
-  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
 EOF
 	    cat <<"EOF"
   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
@@ -4524,7 +5902,7 @@ EOF
 		cat <<"EOF"
   /* execv doesn't actually work on mingw as expected on unix */
   newargz = prepare_spawn (newargz);
-  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
   if (rval == -1)
     {
       /* failed to start process */
@@ -4569,7 +5947,7 @@ base_name (const char *name)
 {
   const char *base;
 
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   /* Skip over the disk name in MSDOS pathnames. */
   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
     name += 2;
@@ -4628,7 +6006,7 @@ find_executable (const char *wrapper)
   const char *p_next;
   /* static buffer for getcwd */
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
+  size_t tmp_len;
   char *concat_name;
 
   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
@@ -4638,7 +6016,7 @@ find_executable (const char *wrapper)
     return NULL;
 
   /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
     {
       concat_name = xstrdup (wrapper);
@@ -4656,7 +6034,7 @@ find_executable (const char *wrapper)
 	    return concat_name;
 	  XFREE (concat_name);
 	}
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
     }
 #endif
 
@@ -4679,7 +6057,7 @@ find_executable (const char *wrapper)
 	      for (q = p; *q; q++)
 		if (IS_PATH_SEPARATOR (*q))
 		  break;
-	      p_len = q - p;
+	      p_len = (size_t) (q - p);
 	      p_next = (*q == '\0' ? q : q + 1);
 	      if (p_len == 0)
 		{
@@ -4798,7 +6176,7 @@ strendzap (char *str, const char *pat)
   if (patlen <= len)
     {
       str += len - patlen;
-      if (strcmp (str, pat) == 0)
+      if (STREQ (str, pat))
 	*str = '\0';
     }
   return str;
@@ -4863,7 +6241,7 @@ lt_setenv (const char *name, const char *value)
     char *str = xstrdup (value);
     setenv (name, str, 1);
 #else
-    int len = strlen (name) + 1 + strlen (value) + 1;
+    size_t len = strlen (name) + 1 + strlen (value) + 1;
     char *str = XMALLOC (char, len);
     sprintf (str, "%s=%s", name, value);
     if (putenv (str) != EXIT_SUCCESS)
@@ -4880,8 +6258,8 @@ lt_extend_str (const char *orig_value, const char *add, int to_end)
   char *new_value;
   if (orig_value && *orig_value)
     {
-      int orig_value_len = strlen (orig_value);
-      int add_len = strlen (add);
+      size_t orig_value_len = strlen (orig_value);
+      size_t add_len = strlen (add);
       new_value = XMALLOC (char, add_len + orig_value_len + 1);
       if (to_end)
         {
@@ -4912,10 +6290,10 @@ lt_update_exe_path (const char *name, const char *value)
     {
       char *new_value = lt_extend_str (getenv (name), value, 0);
       /* some systems can't cope with a ':'-terminated path #' */
-      int len = strlen (new_value);
-      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+      size_t len = strlen (new_value);
+      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
         {
-          new_value[len-1] = '\0';
+          new_value[--len] = '\0';
         }
       lt_setenv (name, new_value);
       XFREE (new_value);
@@ -5082,27 +6460,47 @@ EOF
 # True if ARG is an import lib, as indicated by $file_magic_cmd
 func_win32_import_lib_p ()
 {
-    $opt_debug
+    $debug_cmd
+
     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
     *import*) : ;;
     *) false ;;
     esac
 }
 
+# func_suncc_cstd_abi
+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
+# Several compiler flags select an ABI that is incompatible with the
+# Cstd library. Avoid specifying it if any are in CXXFLAGS.
+func_suncc_cstd_abi ()
+{
+    $debug_cmd
+
+    case " $compile_command " in
+    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
+      suncc_use_cstd_abi=no
+      ;;
+    *)
+      suncc_use_cstd_abi=yes
+      ;;
+    esac
+}
+
 # func_mode_link arg...
 func_mode_link ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $host in
     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
+      # what system we are compiling for in order to pass an extra
       # flag for every libtool invocation.
       # allow_undefined=no
 
       # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
+      # to make a dll that has undefined symbols, in which case not
       # even a static library is built.  For now, we need to specify
       # -no-undefined on the libtool link line when we can be certain
       # that all symbols are satisfied, otherwise we get a static library.
@@ -5146,10 +6544,11 @@ func_mode_link ()
     module=no
     no_install=no
     objs=
+    os2dllname=
     non_pic_objects=
     precious_files_regex=
     prefer_static_libs=no
-    preload=no
+    preload=false
     prev=
     prevarg=
     release=
@@ -5161,7 +6560,7 @@ func_mode_link ()
     vinfo=
     vinfo_number=no
     weak_libs=
-    single_module="${wl}-single_module"
+    single_module=$wl-single_module
     func_infer_tag $base_compile
 
     # We need to know -static, to get the right output filenames.
@@ -5169,15 +6568,15 @@ func_mode_link ()
     do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes != "$build_libtool_libs" \
+	  && func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	break
 	;;
       -all-static | -static | -static-libtool-libs)
 	case $arg in
 	-all-static)
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
 	    func_warning "complete static linking is impossible in this configuration"
 	  fi
 	  if test -n "$link_static_flag"; then
@@ -5210,7 +6609,7 @@ func_mode_link ()
 
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
-      arg="$1"
+      arg=$1
       shift
       func_quote_for_eval "$arg"
       qarg=$func_quote_for_eval_unquoted_result
@@ -5227,21 +6626,21 @@ func_mode_link ()
 
 	case $prev in
 	bindir)
-	  bindir="$arg"
+	  bindir=$arg
 	  prev=
 	  continue
 	  ;;
 	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
+	  $preload || {
 	    # Add the symbol object into the linking commands.
 	    func_append compile_command " @SYMFILE@"
 	    func_append finalize_command " @SYMFILE@"
-	    preload=yes
-	  fi
+	    preload=:
+	  }
 	  case $arg in
 	  *.la | *.lo) ;;  # We handle these cases below.
 	  force)
-	    if test "$dlself" = no; then
+	    if test no = "$dlself"; then
 	      dlself=needless
 	      export_dynamic=yes
 	    fi
@@ -5249,9 +6648,9 @@ func_mode_link ()
 	    continue
 	    ;;
 	  self)
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
 	      dlself=yes
 	    else
 	      dlself=needless
@@ -5261,7 +6660,7 @@ func_mode_link ()
 	    continue
 	    ;;
 	  *)
-	    if test "$prev" = dlfiles; then
+	    if test dlfiles = "$prev"; then
 	      func_append dlfiles " $arg"
 	    else
 	      func_append dlprefiles " $arg"
@@ -5272,14 +6671,14 @@ func_mode_link ()
 	  esac
 	  ;;
 	expsyms)
-	  export_symbols="$arg"
+	  export_symbols=$arg
 	  test -f "$arg" \
-	    || func_fatal_error "symbol file \`$arg' does not exist"
+	    || func_fatal_error "symbol file '$arg' does not exist"
 	  prev=
 	  continue
 	  ;;
 	expsyms_regex)
-	  export_symbols_regex="$arg"
+	  export_symbols_regex=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5297,7 +6696,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	inst_prefix)
-	  inst_prefix_dir="$arg"
+	  inst_prefix_dir=$arg
+	  prev=
+	  continue
+	  ;;
+	mllvm)
+	  # Clang does not use LLVM to link, so we can simply discard any
+	  # '-mllvm $arg' options when doing the link step.
 	  prev=
 	  continue
 	  ;;
@@ -5321,21 +6726,21 @@ func_mode_link ()
 
 		if test -z "$pic_object" ||
 		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none &&
-		   test "$non_pic_object" = none; then
-		  func_fatal_error "cannot find name of object for \`$arg'"
+		   test none = "$pic_object" &&
+		   test none = "$non_pic_object"; then
+		  func_fatal_error "cannot find name of object for '$arg'"
 		fi
 
 		# Extract subdirectory from the argument.
 		func_dirname "$arg" "/" ""
-		xdir="$func_dirname_result"
+		xdir=$func_dirname_result
 
-		if test "$pic_object" != none; then
+		if test none != "$pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
+		  pic_object=$xdir$pic_object
 
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		  if test dlfiles = "$prev"; then
+		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		      func_append dlfiles " $pic_object"
 		      prev=
 		      continue
@@ -5346,7 +6751,7 @@ func_mode_link ()
 		  fi
 
 		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
+		  if test dlprefiles = "$prev"; then
 		    # Preload the old-style object.
 		    func_append dlprefiles " $pic_object"
 		    prev=
@@ -5354,23 +6759,23 @@ func_mode_link ()
 
 		  # A PIC object.
 		  func_append libobjs " $pic_object"
-		  arg="$pic_object"
+		  arg=$pic_object
 		fi
 
 		# Non-PIC object.
-		if test "$non_pic_object" != none; then
+		if test none != "$non_pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
+		  non_pic_object=$xdir$non_pic_object
 
 		  # A standard non-PIC object
 		  func_append non_pic_objects " $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
+		  if test -z "$pic_object" || test none = "$pic_object"; then
+		    arg=$non_pic_object
 		  fi
 		else
 		  # If the PIC object exists, use it instead.
 		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
+		  non_pic_object=$pic_object
 		  func_append non_pic_objects " $non_pic_object"
 		fi
 	      else
@@ -5378,7 +6783,7 @@ func_mode_link ()
 		if $opt_dry_run; then
 		  # Extract subdirectory from the argument.
 		  func_dirname "$arg" "/" ""
-		  xdir="$func_dirname_result"
+		  xdir=$func_dirname_result
 
 		  func_lo2o "$arg"
 		  pic_object=$xdir$objdir/$func_lo2o_result
@@ -5386,24 +6791,29 @@ func_mode_link ()
 		  func_append libobjs " $pic_object"
 		  func_append non_pic_objects " $non_pic_object"
 	        else
-		  func_fatal_error "\`$arg' is not a valid libtool object"
+		  func_fatal_error "'$arg' is not a valid libtool object"
 		fi
 	      fi
 	    done
 	  else
-	    func_fatal_error "link input file \`$arg' does not exist"
+	    func_fatal_error "link input file '$arg' does not exist"
 	  fi
 	  arg=$save_arg
 	  prev=
 	  continue
 	  ;;
+	os2dllname)
+	  os2dllname=$arg
+	  prev=
+	  continue
+	  ;;
 	precious_regex)
-	  precious_files_regex="$arg"
+	  precious_files_regex=$arg
 	  prev=
 	  continue
 	  ;;
 	release)
-	  release="-$arg"
+	  release=-$arg
 	  prev=
 	  continue
 	  ;;
@@ -5415,7 +6825,7 @@ func_mode_link ()
 	    func_fatal_error "only absolute run-paths are allowed"
 	    ;;
 	  esac
-	  if test "$prev" = rpath; then
+	  if test rpath = "$prev"; then
 	    case "$rpath " in
 	    *" $arg "*) ;;
 	    *) func_append rpath " $arg" ;;
@@ -5430,7 +6840,7 @@ func_mode_link ()
 	  continue
 	  ;;
 	shrext)
-	  shrext_cmds="$arg"
+	  shrext_cmds=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5470,7 +6880,7 @@ func_mode_link ()
 	esac
       fi # test -n "$prev"
 
-      prevarg="$arg"
+      prevarg=$arg
 
       case $arg in
       -all-static)
@@ -5484,7 +6894,7 @@ func_mode_link ()
 
       -allow-undefined)
 	# FIXME: remove this flag sometime in the future.
-	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	func_fatal_error "'-allow-undefined' must not be used because it is the default"
 	;;
 
       -avoid-version)
@@ -5516,7 +6926,7 @@ func_mode_link ()
 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
 	fi
-	if test "X$arg" = "X-export-symbols"; then
+	if test X-export-symbols = "X$arg"; then
 	  prev=expsyms
 	else
 	  prev=expsyms_regex
@@ -5550,9 +6960,9 @@ func_mode_link ()
 	func_stripname "-L" '' "$arg"
 	if test -z "$func_stripname_result"; then
 	  if test "$#" -gt 0; then
-	    func_fatal_error "require no space between \`-L' and \`$1'"
+	    func_fatal_error "require no space between '-L' and '$1'"
 	  else
-	    func_fatal_error "need path for \`-L' option"
+	    func_fatal_error "need path for '-L' option"
 	  fi
 	fi
 	func_resolve_sysroot "$func_stripname_result"
@@ -5563,8 +6973,8 @@ func_mode_link ()
 	*)
 	  absdir=`cd "$dir" && pwd`
 	  test -z "$absdir" && \
-	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
-	  dir="$absdir"
+	    func_fatal_error "cannot determine absolute directory name of '$dir'"
+	  dir=$absdir
 	  ;;
 	esac
 	case "$deplibs " in
@@ -5599,7 +7009,7 @@ func_mode_link ()
 	;;
 
       -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # These systems don't actually have a C or math library (as such)
@@ -5607,11 +7017,11 @@ func_mode_link ()
 	    ;;
 	  *-*-os2*)
 	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-rhapsody* | *-*-darwin1.[012])
 	    # Rhapsody C and math libraries are in the System framework
@@ -5620,16 +7030,16 @@ func_mode_link ()
 	    ;;
 	  *-*-sco3.2v5* | *-*-sco5v6*)
 	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
 	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  esac
-	elif test "X$arg" = "X-lc_r"; then
+	elif test X-lc_r = "X$arg"; then
 	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	   # Do not include libc_r directly, use -pthread flag.
 	   continue
 	   ;;
@@ -5639,6 +7049,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -mllvm)
+	prev=mllvm
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -5668,7 +7083,7 @@ func_mode_link ()
 	;;
 
       -multi_module)
-	single_module="${wl}-multi_module"
+	single_module=$wl-multi_module
 	continue
 	;;
 
@@ -5682,8 +7097,8 @@ func_mode_link ()
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
 	  # The PATH hackery in wrapper scripts is required on Windows
 	  # and Darwin in order for the loader to find any dlls it needs.
-	  func_warning "\`-no-install' is ignored for $host"
-	  func_warning "assuming \`-no-fast-install' instead"
+	  func_warning "'-no-install' is ignored for $host"
+	  func_warning "assuming '-no-fast-install' instead"
 	  fast_install=no
 	  ;;
 	*) no_install=yes ;;
@@ -5701,6 +7116,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -os2dllname)
+	prev=os2dllname
+	continue
+	;;
+
       -o) prev=output ;;
 
       -precious-files-regex)
@@ -5788,14 +7208,14 @@ func_mode_link ()
 	func_stripname '-Wc,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $func_quote_for_eval_result"
 	  func_append compiler_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5804,15 +7224,15 @@ func_mode_link ()
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $wl$func_quote_for_eval_result"
 	  func_append compiler_flags " $wl$func_quote_for_eval_result"
 	  func_append linker_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5835,7 +7255,7 @@ func_mode_link ()
       # -msg_* for osf cc
       -msg_*)
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       # Flags to be passed through unchanged, with rationale:
@@ -5847,25 +7267,49 @@ func_mode_link ()
       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
       # -F/path              path to uninstalled frameworks, gcc on darwin
       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # -fstack-protector*   stack protector flags for GCC
       # @file                GCC response files
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
-      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -specs=*             GCC specs files
+      # -stdlib=*            select c++ std lib with clang
+      # -fsanitize=*         Clang/GCC memory and address sanitizer
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
+      -specs=*|-fsanitize=*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
         func_append finalize_command " $arg"
         func_append compiler_flags " $arg"
         continue
         ;;
 
+      -Z*)
+        if test os2 = "`expr $host : '.*\(os2\)'`"; then
+          # OS/2 uses -Zxxx to specify OS/2-specific options
+	  compiler_flags="$compiler_flags $arg"
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  case $arg in
+	  -Zlinker | -Zstack)
+	    prev=xcompiler
+	    ;;
+	  esac
+	  continue
+        else
+	  # Otherwise treat like 'Some other compiler flag' below
+	  func_quote_for_eval "$arg"
+	  arg=$func_quote_for_eval_result
+        fi
+	;;
+
       # Some other compiler flag.
       -* | +*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       *.$objext)
@@ -5886,21 +7330,21 @@ func_mode_link ()
 
 	  if test -z "$pic_object" ||
 	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none &&
-	     test "$non_pic_object" = none; then
-	    func_fatal_error "cannot find name of object for \`$arg'"
+	     test none = "$pic_object" &&
+	     test none = "$non_pic_object"; then
+	    func_fatal_error "cannot find name of object for '$arg'"
 	  fi
 
 	  # Extract subdirectory from the argument.
 	  func_dirname "$arg" "/" ""
-	  xdir="$func_dirname_result"
+	  xdir=$func_dirname_result
 
-	  if test "$pic_object" != none; then
+	  test none = "$pic_object" || {
 	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
+	    pic_object=$xdir$pic_object
 
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+	    if test dlfiles = "$prev"; then
+	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		func_append dlfiles " $pic_object"
 		prev=
 		continue
@@ -5911,7 +7355,7 @@ func_mode_link ()
 	    fi
 
 	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      # Preload the old-style object.
 	      func_append dlprefiles " $pic_object"
 	      prev=
@@ -5919,23 +7363,23 @@ func_mode_link ()
 
 	    # A PIC object.
 	    func_append libobjs " $pic_object"
-	    arg="$pic_object"
-	  fi
+	    arg=$pic_object
+	  }
 
 	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
+	  if test none != "$non_pic_object"; then
 	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
+	    non_pic_object=$xdir$non_pic_object
 
 	    # A standard non-PIC object
 	    func_append non_pic_objects " $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
+	    if test -z "$pic_object" || test none = "$pic_object"; then
+	      arg=$non_pic_object
 	    fi
 	  else
 	    # If the PIC object exists, use it instead.
 	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
+	    non_pic_object=$pic_object
 	    func_append non_pic_objects " $non_pic_object"
 	  fi
 	else
@@ -5943,7 +7387,7 @@ func_mode_link ()
 	  if $opt_dry_run; then
 	    # Extract subdirectory from the argument.
 	    func_dirname "$arg" "/" ""
-	    xdir="$func_dirname_result"
+	    xdir=$func_dirname_result
 
 	    func_lo2o "$arg"
 	    pic_object=$xdir$objdir/$func_lo2o_result
@@ -5951,7 +7395,7 @@ func_mode_link ()
 	    func_append libobjs " $pic_object"
 	    func_append non_pic_objects " $non_pic_object"
 	  else
-	    func_fatal_error "\`$arg' is not a valid libtool object"
+	    func_fatal_error "'$arg' is not a valid libtool object"
 	  fi
 	fi
 	;;
@@ -5967,11 +7411,11 @@ func_mode_link ()
 	# A libtool-controlled library.
 
 	func_resolve_sysroot "$arg"
-	if test "$prev" = dlfiles; then
+	if test dlfiles = "$prev"; then
 	  # This library was specified with -dlopen.
 	  func_append dlfiles " $func_resolve_sysroot_result"
 	  prev=
-	elif test "$prev" = dlprefiles; then
+	elif test dlprefiles = "$prev"; then
 	  # The library was specified with -dlpreopen.
 	  func_append dlprefiles " $func_resolve_sysroot_result"
 	  prev=
@@ -5986,7 +7430,7 @@ func_mode_link ()
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
       esac # arg
 
@@ -5998,9 +7442,9 @@ func_mode_link ()
     done # argument parsing loop
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prevarg' option requires an argument"
+      func_fatal_help "the '$prevarg' option requires an argument"
 
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
       eval arg=\"$export_dynamic_flag_spec\"
       func_append compile_command " $arg"
       func_append finalize_command " $arg"
@@ -6009,20 +7453,23 @@ func_mode_link ()
     oldlibs=
     # calculate the name of the file, without its directory
     func_basename "$output"
-    outputname="$func_basename_result"
-    libobjs_save="$libobjs"
+    outputname=$func_basename_result
+    libobjs_save=$libobjs
 
     if test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
     else
       shlib_search_path=
     fi
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    # Definition is injected by LT_CONFIG during libtool generation.
+    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
-    output_objdir="$func_dirname_result$objdir"
+    output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
     tool_output_objdir=$func_to_tool_file_result
     # Create the object directory.
@@ -6045,7 +7492,7 @@ func_mode_link ()
     # Find all interdependent deplibs by searching for libraries
     # that are linked more than once (e.g. -la -lb -la)
     for deplib in $deplibs; do
-      if $opt_preserve_dup_deps ; then
+      if $opt_preserve_dup_deps; then
 	case "$libs " in
 	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	esac
@@ -6053,7 +7500,7 @@ func_mode_link ()
       func_append libs " $deplib"
     done
 
-    if test "$linkmode" = lib; then
+    if test lib = "$linkmode"; then
       libs="$predeps $libs $compiler_lib_search_path $postdeps"
 
       # Compute libraries that are listed more than once in $predeps
@@ -6085,7 +7532,7 @@ func_mode_link ()
 	  case $file in
 	  *.la) ;;
 	  *)
-	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
 	    ;;
 	  esac
 	done
@@ -6093,7 +7540,7 @@ func_mode_link ()
     prog)
 	compile_deplibs=
 	finalize_deplibs=
-	alldeplibs=no
+	alldeplibs=false
 	newdlfiles=
 	newdlprefiles=
 	passes="conv scan dlopen dlpreopen link"
@@ -6105,32 +7552,32 @@ func_mode_link ()
     for pass in $passes; do
       # The preopen pass in lib mode reverses $deplibs; put it back here
       # so that -L comes before libs that need it for instance...
-      if test "$linkmode,$pass" = "lib,link"; then
+      if test lib,link = "$linkmode,$pass"; then
 	## FIXME: Find the place where the list is rebuilt in the wrong
 	##        order, and fix it there properly
         tmp_deplibs=
 	for deplib in $deplibs; do
 	  tmp_deplibs="$deplib $tmp_deplibs"
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
       fi
 
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
+      if test lib,link = "$linkmode,$pass" ||
+	 test prog,scan = "$linkmode,$pass"; then
+	libs=$deplibs
 	deplibs=
       fi
-      if test "$linkmode" = prog; then
+      if test prog = "$linkmode"; then
 	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
+	dlopen) libs=$dlfiles ;;
+	dlpreopen) libs=$dlprefiles ;;
 	link)
 	  libs="$deplibs %DEPLIBS%"
 	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
 	  ;;
 	esac
       fi
-      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+      if test lib,dlpreopen = "$linkmode,$pass"; then
 	# Collect and forward deplibs of preopened libtool libs
 	for lib in $dlprefiles; do
 	  # Ignore non-libtool-libs
@@ -6151,26 +7598,26 @@ func_mode_link ()
 	    esac
 	  done
 	done
-	libs="$dlprefiles"
+	libs=$dlprefiles
       fi
-      if test "$pass" = dlopen; then
+      if test dlopen = "$pass"; then
 	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
+	save_deplibs=$deplibs
 	deplibs=
       fi
 
       for deplib in $libs; do
 	lib=
-	found=no
+	found=false
 	case $deplib in
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    func_append compiler_flags " $deplib"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6180,13 +7627,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    func_warning "\`-l' is ignored for archives/objects"
+	  if test lib != "$linkmode" && test prog != "$linkmode"; then
+	    func_warning "'-l' is ignored for archives/objects"
 	    continue
 	  fi
 	  func_stripname '-l' '' "$deplib"
 	  name=$func_stripname_result
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
 	  else
 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
@@ -6194,31 +7641,22 @@ func_mode_link ()
 	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
+	      lib=$searchdir/lib$name$search_ext
 	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
+		if test .la = "$search_ext"; then
+		  found=:
 		else
-		  found=no
+		  found=false
 		fi
 		break 2
 	      fi
 	    done
 	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
+	  if $found; then
+	    # deplib is a libtool library
 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
 	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 	      case " $predeps $postdeps " in
 	      *" $deplib "*)
 		if func_lalib_p "$lib"; then
@@ -6226,19 +7664,19 @@ func_mode_link ()
 		  old_library=
 		  func_source "$lib"
 		  for l in $old_library $library_names; do
-		    ll="$l"
+		    ll=$l
 		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
+		  if test "X$ll" = "X$old_library"; then # only static version available
+		    found=false
 		    func_dirname "$lib" "" "."
-		    ladir="$func_dirname_result"
+		    ladir=$func_dirname_result
 		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
+		    if test prog,link = "$linkmode,$pass"; then
 		      compile_deplibs="$deplib $compile_deplibs"
 		      finalize_deplibs="$deplib $finalize_deplibs"
 		    else
 		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
 		    fi
 		    continue
 		  fi
@@ -6247,15 +7685,25 @@ func_mode_link ()
 	      *) ;;
 	      esac
 	    fi
+	  else
+	    # deplib doesn't seem to be a libtool library
+	    if test prog,link = "$linkmode,$pass"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
 	  fi
 	  ;; # -l
 	*.ltframework)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    deplibs="$deplib $deplibs"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6268,18 +7716,18 @@ func_mode_link ()
 	  case $linkmode in
 	  lib)
 	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
+	    test conv = "$pass" && continue
 	    newdependency_libs="$deplib $newdependency_libs"
 	    func_stripname '-L' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  prog)
-	    if test "$pass" = conv; then
+	    if test conv = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	      continue
 	    fi
-	    if test "$pass" = scan; then
+	    if test scan = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6290,13 +7738,13 @@ func_mode_link ()
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  *)
-	    func_warning "\`-L' is ignored for archives/objects"
+	    func_warning "'-L' is ignored for archives/objects"
 	    ;;
 	  esac # linkmode
 	  continue
 	  ;; # -L
 	-R*)
-	  if test "$pass" = link; then
+	  if test link = "$pass"; then
 	    func_stripname '-R' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    dir=$func_resolve_sysroot_result
@@ -6314,7 +7762,7 @@ func_mode_link ()
 	  lib=$func_resolve_sysroot_result
 	  ;;
 	*.$libext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
 	    continue
 	  fi
@@ -6325,21 +7773,26 @@ func_mode_link ()
 	    case " $dlpreconveniencelibs " in
 	    *" $deplib "*) ;;
 	    *)
-	      valid_a_lib=no
+	      valid_a_lib=false
 	      case $deplibs_check_method in
 		match_pattern*)
 		  set dummy $deplibs_check_method; shift
 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
 		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
 		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		    valid_a_lib=yes
+		    valid_a_lib=:
 		  fi
 		;;
 		pass_all)
-		  valid_a_lib=yes
+		  valid_a_lib=:
 		;;
 	      esac
-	      if test "$valid_a_lib" != yes; then
+	      if $valid_a_lib; then
+		echo
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      else
 		echo
 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
 		echo "*** I have the capability to make that library automatically link in when"
@@ -6347,18 +7800,13 @@ func_mode_link ()
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because the file extensions .$libext of this argument makes me believe"
 		echo "*** that it is just a static archive that I should not use here."
-	      else
-		echo
-		$ECHO "*** Warning: Linking the shared library $output against the"
-		$ECHO "*** static library $deplib is not portable!"
-		deplibs="$deplib $deplibs"
 	      fi
 	      ;;
 	    esac
 	    continue
 	    ;;
 	  prog)
-	    if test "$pass" != link; then
+	    if test link != "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6369,10 +7817,10 @@ func_mode_link ()
 	  esac # linkmode
 	  ;; # *.$libext
 	*.lo | *.$objext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	  elif test prog = "$linkmode"; then
+	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
 	      # If there is no dlopen support or we're linking statically,
 	      # we need to preload.
 	      func_append newdlprefiles " $deplib"
@@ -6385,22 +7833,20 @@ func_mode_link ()
 	  continue
 	  ;;
 	%DEPLIBS%)
-	  alldeplibs=yes
+	  alldeplibs=:
 	  continue
 	  ;;
 	esac # case $deplib
 
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
-	fi
+	$found || test -f "$lib" \
+	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$lib" \
-	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+	  || func_fatal_error "'$lib' is not a valid libtool archive"
 
 	func_dirname "$lib" "" "."
-	ladir="$func_dirname_result"
+	ladir=$func_dirname_result
 
 	dlname=
 	dlopen=
@@ -6430,19 +7876,19 @@ func_mode_link ()
 	  done
 	fi
 	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	if test lib,link = "$linkmode,$pass" ||
+	   test prog,scan = "$linkmode,$pass" ||
+	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
 	  test -n "$dlopen" && func_append dlfiles " $dlopen"
 	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
 	fi
 
-	if test "$pass" = conv; then
+	if test conv = "$pass"; then
 	  # Only check for convenience libraries
 	  deplibs="$lib $deplibs"
 	  if test -z "$libdir"; then
 	    if test -z "$old_library"; then
-	      func_fatal_error "cannot find name of link library for \`$lib'"
+	      func_fatal_error "cannot find name of link library for '$lib'"
 	    fi
 	    # It is a libtool convenience library, so add in its objects.
 	    func_append convenience " $ladir/$objdir/$old_library"
@@ -6450,15 +7896,15 @@ func_mode_link ()
 	    tmp_libs=
 	    for deplib in $dependency_libs; do
 	      deplibs="$deplib $deplibs"
-	      if $opt_preserve_dup_deps ; then
+	      if $opt_preserve_dup_deps; then
 		case "$tmp_libs " in
 		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 		esac
 	      fi
 	      func_append tmp_libs " $deplib"
 	    done
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    func_fatal_error "\`$lib' is not a convenience library"
+	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
+	    func_fatal_error "'$lib' is not a convenience library"
 	  fi
 	  continue
 	fi # $pass = conv
@@ -6467,26 +7913,26 @@ func_mode_link ()
 	# Get the name of the library we link against.
 	linklib=
 	if test -n "$old_library" &&
-	   { test "$prefer_static_libs" = yes ||
-	     test "$prefer_static_libs,$installed" = "built,no"; }; then
+	   { test yes = "$prefer_static_libs" ||
+	     test built,no = "$prefer_static_libs,$installed"; }; then
 	  linklib=$old_library
 	else
 	  for l in $old_library $library_names; do
-	    linklib="$l"
+	    linklib=$l
 	  done
 	fi
 	if test -z "$linklib"; then
-	  func_fatal_error "cannot find name of link library for \`$lib'"
+	  func_fatal_error "cannot find name of link library for '$lib'"
 	fi
 
 	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
-	  fi
+	if test dlopen = "$pass"; then
+	  test -z "$libdir" \
+	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
 	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
+	     test yes != "$dlopen_support" ||
+	     test no = "$build_libtool_libs"
+	  then
 	    # If there is no dlname, no dlopen support or we're linking
 	    # statically, we need to preload.  We also need to preload any
 	    # dependent libraries so libltdl's deplib preloader doesn't
@@ -6500,40 +7946,40 @@ func_mode_link ()
 
 	# We need an absolute path.
 	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
 	*)
 	  abs_ladir=`cd "$ladir" && pwd`
 	  if test -z "$abs_ladir"; then
-	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "cannot determine absolute directory name of '$ladir'"
 	    func_warning "passing it literally to the linker, although it might fail"
-	    abs_ladir="$ladir"
+	    abs_ladir=$ladir
 	  fi
 	  ;;
 	esac
 	func_basename "$lib"
-	laname="$func_basename_result"
+	laname=$func_basename_result
 
 	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
+	if test yes = "$installed"; then
 	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    func_warning "library \`$lib' was moved."
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
+	    func_warning "library '$lib' was moved."
+	    dir=$ladir
+	    absdir=$abs_ladir
+	    libdir=$abs_ladir
 	  else
-	    dir="$lt_sysroot$libdir"
-	    absdir="$lt_sysroot$libdir"
+	    dir=$lt_sysroot$libdir
+	    absdir=$lt_sysroot$libdir
 	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
 	else
 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
+	    dir=$ladir
+	    absdir=$abs_ladir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
+	    dir=$ladir/$objdir
+	    absdir=$abs_ladir/$objdir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  fi
@@ -6542,11 +7988,11 @@ func_mode_link ()
 	name=$func_stripname_result
 
 	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir" && test "$linkmode" = prog; then
-	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	if test dlpreopen = "$pass"; then
+	  if test -z "$libdir" && test prog = "$linkmode"; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
 	  fi
-	  case "$host" in
+	  case $host in
 	    # special handling for platforms with PE-DLLs.
 	    *cygwin* | *mingw* | *cegcc* )
 	      # Linker will automatically link against shared library if both
@@ -6590,9 +8036,9 @@ func_mode_link ()
 
 	if test -z "$libdir"; then
 	  # Link the convenience library
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
+	  elif test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$dir/$old_library $compile_deplibs"
 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
 	  else
@@ -6602,14 +8048,14 @@ func_mode_link ()
 	fi
 
 
-	if test "$linkmode" = prog && test "$pass" != link; then
+	if test prog = "$linkmode" && test link != "$pass"; then
 	  func_append newlib_search_path " $ladir"
 	  deplibs="$lib $deplibs"
 
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
+	  linkalldeplibs=false
+	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
+	     test no = "$build_libtool_libs"; then
+	    linkalldeplibs=:
 	  fi
 
 	  tmp_libs=
@@ -6621,14 +8067,14 @@ func_mode_link ()
 		 ;;
 	    esac
 	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
+	    if $linkalldeplibs; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      # Need to hardcode shared library paths
 	      # or/and link against static libraries
 	      newdependency_libs="$deplib $newdependency_libs"
 	    fi
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	      esac
@@ -6638,15 +8084,15 @@ func_mode_link ()
 	  continue
 	fi # $linkmode = prog...
 
-	if test "$linkmode,$pass" = "prog,link"; then
+	if test prog,link = "$linkmode,$pass"; then
 	  if test -n "$library_names" &&
-	     { { test "$prefer_static_libs" = no ||
-	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	     { { test no = "$prefer_static_libs" ||
+	         test built,yes = "$prefer_static_libs,$installed"; } ||
 	       test -z "$old_library"; }; then
 	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath:" in
+	      case $temp_rpath: in
 	      *"$absdir:"*) ;;
 	      *) func_append temp_rpath "$absdir:" ;;
 	      esac
@@ -6675,9 +8121,9 @@ func_mode_link ()
 	    esac
 	  fi # $linkmode,$pass = prog,link...
 
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
+	  if $alldeplibs &&
+	     { test pass_all = "$deplibs_check_method" ||
+	       { test yes = "$build_libtool_libs" &&
 		 test -n "$library_names"; }; }; then
 	    # We only need to search for static libraries
 	    continue
@@ -6686,19 +8132,19 @@ func_mode_link ()
 
 	link_static=no # Whether the deplib will be linked statically
 	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes; then
+	if test built = "$use_static_libs" && test yes = "$installed"; then
 	  use_static_libs=no
 	fi
 	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
+	  *cygwin* | *mingw* | *cegcc* | *os2*)
 	      # No point in relinking DLLs because paths are not encoded
 	      func_append notinst_deplibs " $lib"
 	      need_relink=no
 	    ;;
 	  *)
-	    if test "$installed" = no; then
+	    if test no = "$installed"; then
 	      func_append notinst_deplibs " $lib"
 	      need_relink=yes
 	    fi
@@ -6708,24 +8154,24 @@ func_mode_link ()
 
 	  # Warn about portability, can't link against -module's on some
 	  # systems (darwin).  Don't bleat about dlopened modules though!
-	  dlopenmodule=""
+	  dlopenmodule=
 	  for dlpremoduletest in $dlprefiles; do
 	    if test "X$dlpremoduletest" = "X$lib"; then
-	      dlopenmodule="$dlpremoduletest"
+	      dlopenmodule=$dlpremoduletest
 	      break
 	    fi
 	  done
-	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
 	    echo
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
 	    else
 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
 	    fi
 	    $ECHO "*** $linklib is not portable!"
 	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
+	  if test lib = "$linkmode" &&
+	     test yes = "$hardcode_into_libs"; then
 	    # Hardcode the library path.
 	    # Skip directories that are in the system default run-time
 	    # search path.
@@ -6753,43 +8199,43 @@ func_mode_link ()
 	    # figure out the soname
 	    set dummy $library_names
 	    shift
-	    realname="$1"
+	    realname=$1
 	    shift
 	    libname=`eval "\\$ECHO \"$libname_spec\""`
 	    # use dlname if we got it. it's perfectly good, no?
 	    if test -n "$dlname"; then
-	      soname="$dlname"
+	      soname=$dlname
 	    elif test -n "$soname_spec"; then
 	      # bleh windows
 	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
+	      *cygwin* | mingw* | *cegcc* | *os2*)
 	        func_arith $current - $age
 		major=$func_arith_result
-		versuffix="-$major"
+		versuffix=-$major
 		;;
 	      esac
 	      eval soname=\"$soname_spec\"
 	    else
-	      soname="$realname"
+	      soname=$realname
 	    fi
 
 	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
+	    soroot=$soname
 	    func_basename "$soroot"
-	    soname="$func_basename_result"
+	    soname=$func_basename_result
 	    func_stripname 'lib' '.dll' "$soname"
 	    newlib=libimp-$func_stripname_result.a
 
 	    # If the library has no export list, then create one now
 	    if test -f "$output_objdir/$soname-def"; then :
 	    else
-	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_verbose "extracting exported symbol list from '$soname'"
 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
 	    fi
 
 	    # Create $newlib
 	    if test -f "$output_objdir/$newlib"; then :; else
-	      func_verbose "generating import library for \`$soname'"
+	      func_verbose "generating import library for '$soname'"
 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
 	    fi
 	    # make sure the library variables are pointing to the new library
@@ -6797,58 +8243,58 @@ func_mode_link ()
 	    linklib=$newlib
 	  fi # test -n "$old_archive_from_expsyms_cmds"
 
-	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
+	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    lib_linked=yes
 	    case $hardcode_action in
 	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
+	      if test no = "$hardcode_direct"; then
+		add=$dir/$linklib
 		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
+		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
+		    *-*-unixware7*) add_dir=-L$dir ;;
 		  *-*-darwin* )
-		    # if the lib is a (non-dlopened) module then we can not
+		    # if the lib is a (non-dlopened) module then we cannot
 		    # link against it, someone is ignoring the earlier warnings
 		    if /usr/bin/file -L $add 2> /dev/null |
-			 $GREP ": [^:]* bundle" >/dev/null ; then
+			 $GREP ": [^:]* bundle" >/dev/null; then
 		      if test "X$dlopenmodule" != "X$lib"; then
 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
-			if test -z "$old_library" ; then
+			if test -z "$old_library"; then
 			  echo
 			  echo "*** And there doesn't seem to be a static archive available"
 			  echo "*** The link will probably fail, sorry"
 			else
-			  add="$dir/$old_library"
+			  add=$dir/$old_library
 			fi
 		      elif test -n "$old_library"; then
-			add="$dir/$old_library"
+			add=$dir/$old_library
 		      fi
 		    fi
 		esac
-	      elif test "$hardcode_minus_L" = no; then
+	      elif test no = "$hardcode_minus_L"; then
 		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
+		*-*-sunos*) add_shlibpath=$dir ;;
 		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add_dir=-L$dir
+		add=-l$name
+	      elif test no = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
 	      ;;
 	    relink)
-	      if test "$hardcode_direct" = yes &&
-	         test "$hardcode_direct_absolute" = no; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$absdir"
+	      if test yes = "$hardcode_direct" &&
+	         test no = "$hardcode_direct_absolute"; then
+		add=$dir/$linklib
+	      elif test yes = "$hardcode_minus_L"; then
+		add_dir=-L$absdir
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
 		  case $libdir in
@@ -6857,10 +8303,10 @@ func_mode_link ()
 		      ;;
 		  esac
 		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add=-l$name
+	      elif test yes = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
@@ -6868,7 +8314,7 @@ func_mode_link ()
 	    *) lib_linked=no ;;
 	    esac
 
-	    if test "$lib_linked" != yes; then
+	    if test yes != "$lib_linked"; then
 	      func_fatal_configuration "unsupported hardcode properties"
 	    fi
 
@@ -6878,15 +8324,15 @@ func_mode_link ()
 	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
 	      esac
 	    fi
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
 	    else
 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
 	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes &&
-		 test "$hardcode_minus_L" != yes &&
-		 test "$hardcode_shlibpath_var" = yes; then
+	      if test yes != "$hardcode_direct" &&
+		 test yes != "$hardcode_minus_L" &&
+		 test yes = "$hardcode_shlibpath_var"; then
 		case :$finalize_shlibpath: in
 		*":$libdir:"*) ;;
 		*) func_append finalize_shlibpath "$libdir:" ;;
@@ -6895,33 +8341,33 @@ func_mode_link ()
 	    fi
 	  fi
 
-	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
+	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes &&
-	       test "$hardcode_direct_absolute" = no; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
+	    if test yes = "$hardcode_direct" &&
+	       test no = "$hardcode_direct_absolute"; then
+	      add=$libdir/$linklib
+	    elif test yes = "$hardcode_minus_L"; then
+	      add_dir=-L$libdir
+	      add=-l$name
+	    elif test yes = "$hardcode_shlibpath_var"; then
 	      case :$finalize_shlibpath: in
 	      *":$libdir:"*) ;;
 	      *) func_append finalize_shlibpath "$libdir:" ;;
 	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
+	      add=-l$name
+	    elif test yes = "$hardcode_automatic"; then
 	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-		add="$inst_prefix_dir$libdir/$linklib"
+		 test -f "$inst_prefix_dir$libdir/$linklib"; then
+		add=$inst_prefix_dir$libdir/$linklib
 	      else
-		add="$libdir/$linklib"
+		add=$libdir/$linklib
 	      fi
 	    else
 	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
+	      add_dir=-L$libdir
 	      # Try looking first in the location we're being installed to.
 	      if test -n "$inst_prefix_dir"; then
 		case $libdir in
@@ -6930,10 +8376,10 @@ func_mode_link ()
 		    ;;
 		esac
 	      fi
-	      add="-l$name"
+	      add=-l$name
 	    fi
 
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
 	    else
@@ -6941,43 +8387,43 @@ func_mode_link ()
 	      test -n "$add" && deplibs="$add $deplibs"
 	    fi
 	  fi
-	elif test "$linkmode" = prog; then
+	elif test prog = "$linkmode"; then
 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
 	  # is not unsupported.  This is valid on all known static and
 	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
+	  if test unsupported != "$hardcode_direct"; then
+	    test -n "$old_library" && linklib=$old_library
 	    compile_deplibs="$dir/$linklib $compile_deplibs"
 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
 	  else
 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
 	  fi
-	elif test "$build_libtool_libs" = yes; then
+	elif test yes = "$build_libtool_libs"; then
 	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
+	  if test pass_all != "$deplibs_check_method"; then
 	    # We're trying link a shared library against a static one
 	    # but the system doesn't support it.
 
 	    # Just print a warning and add the library to dependency_libs so
 	    # that the program can be linked against the static library.
 	    echo
-	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
 	    echo "*** I have the capability to make that library automatically link in when"
 	    echo "*** you link to this library.  But I can only do this if you have a"
 	    echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
+	    if test yes = "$module"; then
 	      echo "*** But as you try to build a module library, libtool will still create "
 	      echo "*** a static module, that should work as long as the dlopening application"
 	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
 	      if test -z "$global_symbol_pipe"; then
 		echo
 		echo "*** However, this would only work if libtool was able to extract symbol"
-		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 		echo "*** not find such a program.  So, this module is probably useless."
-		echo "*** \`nm' from GNU binutils and a full rebuild may help."
+		echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	      fi
-	      if test "$build_old_libs" = no; then
+	      if test no = "$build_old_libs"; then
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -6990,11 +8436,11 @@ func_mode_link ()
 	  fi
 	fi # link shared/static library?
 
-	if test "$linkmode" = lib; then
+	if test lib = "$linkmode"; then
 	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
+	     { test yes != "$hardcode_into_libs" ||
+	       test yes = "$build_old_libs" ||
+	       test yes = "$link_static"; }; then
 	    # Extract -R from dependency_libs
 	    temp_deplibs=
 	    for libdir in $dependency_libs; do
@@ -7008,12 +8454,12 @@ func_mode_link ()
 	      *) func_append temp_deplibs " $libdir";;
 	      esac
 	    done
-	    dependency_libs="$temp_deplibs"
+	    dependency_libs=$temp_deplibs
 	  fi
 
 	  func_append newlib_search_path " $absdir"
 	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
 	  # ... and its dependency_libs
 	  tmp_libs=
 	  for deplib in $dependency_libs; do
@@ -7023,7 +8469,7 @@ func_mode_link ()
                    func_resolve_sysroot "$func_stripname_result";;
               *) func_resolve_sysroot "$deplib" ;;
             esac
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $func_resolve_sysroot_result "*)
                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
@@ -7032,12 +8478,12 @@ func_mode_link ()
 	    func_append tmp_libs " $func_resolve_sysroot_result"
 	  done
 
-	  if test "$link_all_deplibs" != no; then
+	  if test no != "$link_all_deplibs"; then
 	    # Add the search paths of all dependency libraries
 	    for deplib in $dependency_libs; do
 	      path=
 	      case $deplib in
-	      -L*) path="$deplib" ;;
+	      -L*) path=$deplib ;;
 	      *.la)
 	        func_resolve_sysroot "$deplib"
 	        deplib=$func_resolve_sysroot_result
@@ -7045,12 +8491,12 @@ func_mode_link ()
 		dir=$func_dirname_result
 		# We need an absolute path.
 		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
 		*)
 		  absdir=`cd "$dir" && pwd`
 		  if test -z "$absdir"; then
-		    func_warning "cannot determine absolute directory name of \`$dir'"
-		    absdir="$dir"
+		    func_warning "cannot determine absolute directory name of '$dir'"
+		    absdir=$dir
 		  fi
 		  ;;
 		esac
@@ -7058,35 +8504,35 @@ func_mode_link ()
 		case $host in
 		*-*-darwin*)
 		  depdepl=
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
+		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names"; then
+		    for tmp in $deplibrary_names; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$absdir/$objdir/$depdepl" ; then
-		      depdepl="$absdir/$objdir/$depdepl"
-		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+		    if test -f "$absdir/$objdir/$depdepl"; then
+		      depdepl=$absdir/$objdir/$depdepl
+		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
                       if test -z "$darwin_install_name"; then
-                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
                       fi
-		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
-		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
+		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
 		      path=
 		    fi
 		  fi
 		  ;;
 		*)
-		  path="-L$absdir/$objdir"
+		  path=-L$absdir/$objdir
 		  ;;
 		esac
 		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  test -z "$libdir" && \
-		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		    func_fatal_error "'$deplib' is not a valid libtool archive"
 		  test "$absdir" != "$libdir" && \
-		    func_warning "\`$deplib' seems to be moved"
+		    func_warning "'$deplib' seems to be moved"
 
-		  path="-L$absdir"
+		  path=-L$absdir
 		fi
 		;;
 	      esac
@@ -7098,23 +8544,23 @@ func_mode_link ()
 	  fi # link_all_deplibs != no
 	fi # linkmode = lib
       done # for deplib in $libs
-      if test "$pass" = link; then
-	if test "$linkmode" = "prog"; then
+      if test link = "$pass"; then
+	if test prog = "$linkmode"; then
 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
 	else
 	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
 	fi
       fi
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
+      dependency_libs=$newdependency_libs
+      if test dlpreopen = "$pass"; then
 	# Link the dlpreopened libraries before other libraries
 	for deplib in $save_deplibs; do
 	  deplibs="$deplib $deplibs"
 	done
       fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
+      if test dlopen != "$pass"; then
+	test conv = "$pass" || {
 	  # Make sure lib_search_path contains only unique directories.
 	  lib_search_path=
 	  for dir in $newlib_search_path; do
@@ -7124,12 +8570,12 @@ func_mode_link ()
 	    esac
 	  done
 	  newlib_search_path=
-	fi
+	}
 
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
+	if test prog,link = "$linkmode,$pass"; then
 	  vars="compile_deplibs finalize_deplibs"
+	else
+	  vars=deplibs
 	fi
 	for var in $vars dependency_libs; do
 	  # Add libraries to $var in reverse order
@@ -7187,62 +8633,93 @@ func_mode_link ()
 	  eval $var=\"$tmp_libs\"
 	done # for var
       fi
+
+      # Add Sun CC postdeps if required:
+      test CXX = "$tagname" && {
+        case $host_os in
+        linux*)
+          case `$CC -V 2>&1 | sed 5q` in
+          *Sun\ C*) # Sun C++ 5.9
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+
+        solaris*)
+          func_cc_basename "$CC"
+          case $func_cc_basename_result in
+          CC* | sunCC*)
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+        esac
+      }
+
       # Last step: remove runtime libs from dependency_libs
       # (they stay in deplibs)
       tmp_libs=
-      for i in $dependency_libs ; do
+      for i in $dependency_libs; do
 	case " $predeps $postdeps $compiler_lib_search_path " in
 	*" $i "*)
-	  i=""
+	  i=
 	  ;;
 	esac
-	if test -n "$i" ; then
+	if test -n "$i"; then
 	  func_append tmp_libs " $i"
 	fi
       done
       dependency_libs=$tmp_libs
     done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
+    if test prog = "$linkmode"; then
+      dlfiles=$newdlfiles
     fi
-    if test "$linkmode" = prog || test "$linkmode" = lib; then
-      dlprefiles="$newdlprefiles"
+    if test prog = "$linkmode" || test lib = "$linkmode"; then
+      dlprefiles=$newdlprefiles
     fi
 
     case $linkmode in
     oldlib)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for archives"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for archives"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+	func_warning "'-l' and '-L' are ignored for archives" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for archives"
+	func_warning "'-rpath' is ignored for archives"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for archives"
+	func_warning "'-R' is ignored for archives"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info/-version-number' is ignored for archives"
+	func_warning "'-version-info/-version-number' is ignored for archives"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for archives"
+	func_warning "'-release' is ignored for archives"
 
       test -n "$export_symbols$export_symbols_regex" && \
-	func_warning "\`-export-symbols' is ignored for archives"
+	func_warning "'-export-symbols' is ignored for archives"
 
       # Now set the variables for building old libraries.
       build_libtool_libs=no
-      oldlibs="$output"
+      oldlibs=$output
       func_append objs "$old_deplibs"
       ;;
 
     lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
+      # Make sure we only generate libraries of the form 'libNAME.la'.
       case $outputname in
       lib*)
 	func_stripname 'lib' '.la' "$outputname"
@@ -7251,10 +8728,10 @@ func_mode_link ()
 	eval libname=\"$libname_spec\"
 	;;
       *)
-	test "$module" = no && \
-	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+	test no = "$module" \
+	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
 
-	if test "$need_lib_prefix" != no; then
+	if test no != "$need_lib_prefix"; then
 	  # Add the "lib" prefix for modules if required
 	  func_stripname '' '.la' "$outputname"
 	  name=$func_stripname_result
@@ -7268,8 +8745,8 @@ func_mode_link ()
       esac
 
       if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	if test pass_all != "$deplibs_check_method"; then
+	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
 	else
 	  echo
 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
@@ -7278,21 +8755,21 @@ func_mode_link ()
 	fi
       fi
 
-      test "$dlself" != no && \
-	func_warning "\`-dlopen self' is ignored for libtool libraries"
+      test no = "$dlself" \
+	|| func_warning "'-dlopen self' is ignored for libtool libraries"
 
       set dummy $rpath
       shift
-      test "$#" -gt 1 && \
-	func_warning "ignoring multiple \`-rpath's for a libtool library"
+      test 1 -lt "$#" \
+	&& func_warning "ignoring multiple '-rpath's for a libtool library"
 
-      install_libdir="$1"
+      install_libdir=$1
 
       oldlibs=
       if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
+	if test yes = "$build_libtool_libs"; then
 	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
+	  # Some compilers have problems with a '.al' extension so
 	  # convenience libraries should have the same extension an
 	  # archive normally would.
 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
@@ -7301,20 +8778,20 @@ func_mode_link ()
 	fi
 
 	test -n "$vinfo" && \
-	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
 
 	test -n "$release" && \
-	  func_warning "\`-release' is ignored for convenience libraries"
+	  func_warning "'-release' is ignored for convenience libraries"
       else
 
 	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
+	save_ifs=$IFS; IFS=:
 	set dummy $vinfo 0 0 0
 	shift
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	test -n "$7" && \
-	  func_fatal_help "too many parameters to \`-version-info'"
+	  func_fatal_help "too many parameters to '-version-info'"
 
 	# convert absolute version numbers to libtool ages
 	# this retains compatibility with .la files and attempts
@@ -7322,45 +8799,45 @@ func_mode_link ()
 
 	case $vinfo_number in
 	yes)
-	  number_major="$1"
-	  number_minor="$2"
-	  number_revision="$3"
+	  number_major=$1
+	  number_minor=$2
+	  number_revision=$3
 	  #
 	  # There are really only two kinds -- those that
 	  # use the current revision as the major version
 	  # and those that subtract age and use age as
 	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
+	  # that has an extra 1 added just for fun
 	  #
 	  case $version_type in
 	  # correct linux to gnu/linux during the next big refactor
-	  darwin|linux|osf|windows|none)
+	  darwin|freebsd-elf|linux|osf|windows|none)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_revision"
+	    age=$number_minor
+	    revision=$number_revision
 	    ;;
-	  freebsd-aout|freebsd-elf|qnx|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
+	  freebsd-aout|qnx|sunos)
+	    current=$number_major
+	    revision=$number_minor
+	    age=0
 	    ;;
 	  irix|nonstopux)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_minor"
+	    age=$number_minor
+	    revision=$number_minor
 	    lt_irix_increment=no
 	    ;;
 	  *)
-	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
 	    ;;
 	  esac
 	  ;;
 	no)
-	  current="$1"
-	  revision="$2"
-	  age="$3"
+	  current=$1
+	  revision=$2
+	  age=$3
 	  ;;
 	esac
 
@@ -7368,30 +8845,30 @@ func_mode_link ()
 	case $current in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "CURRENT \`$current' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "CURRENT '$current' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $revision in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "REVISION \`$revision' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "REVISION '$revision' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $age in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "AGE \`$age' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	if test "$age" -gt "$current"; then
-	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' is greater than the current interface number '$current'"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	fi
 
 	# Calculate the version variables.
@@ -7406,26 +8883,36 @@ func_mode_link ()
 	  # verstring for coding it into the library header
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  # Darwin ld doesn't like 0 for these options...
 	  func_arith $current + 1
 	  minor_current=$func_arith_result
-	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+          # On Darwin other compilers
+          case $CC in
+              nagfor*)
+                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
+                  ;;
+              *)
+                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+                  ;;
+          esac
 	  ;;
 
 	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current"
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	irix | nonstopux)
-	  if test "X$lt_irix_increment" = "Xno"; then
+	  if test no = "$lt_irix_increment"; then
 	    func_arith $current - $age
 	  else
 	    func_arith $current - $age + 1
@@ -7436,69 +8923,74 @@ func_mode_link ()
 	    nonstopux) verstring_prefix=nonstopux ;;
 	    *)         verstring_prefix=sgi ;;
 	  esac
-	  verstring="$verstring_prefix$major.$revision"
+	  verstring=$verstring_prefix$major.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$revision
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $revision - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring_prefix$major.$iface:$verstring"
+	    verstring=$verstring_prefix$major.$iface:$verstring
 	  done
 
-	  # Before this point, $major must not contain `.'.
+	  # Before this point, $major must not contain '.'.
 	  major=.$major
-	  versuffix="$major.$revision"
+	  versuffix=$major.$revision
 	  ;;
 
 	linux) # correct to gnu/linux during the next big refactor
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	osf)
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
+	  versuffix=.$current.$age.$revision
+	  verstring=$current.$age.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$age
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $current - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring:${iface}.0"
+	    verstring=$verstring:$iface.0
 	  done
 
 	  # Make executables depend on our current version.
-	  func_append verstring ":${current}.0"
+	  func_append verstring ":$current.0"
 	  ;;
 
 	qnx)
-	  major=".$current"
-	  versuffix=".$current"
+	  major=.$current
+	  versuffix=.$current
+	  ;;
+
+	sco)
+	  major=.$current
+	  versuffix=.$current
 	  ;;
 
 	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	windows)
 	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
+	  # extension on DOS 8.3 file systems.
 	  func_arith $current - $age
 	  major=$func_arith_result
-	  versuffix="-$major"
+	  versuffix=-$major
 	  ;;
 
 	*)
-	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  func_fatal_configuration "unknown library version type '$version_type'"
 	  ;;
 	esac
 
@@ -7512,42 +9004,45 @@ func_mode_link ()
 	    verstring=
 	    ;;
 	  *)
-	    verstring="0.0"
+	    verstring=0.0
 	    ;;
 	  esac
-	  if test "$need_version" = no; then
+	  if test no = "$need_version"; then
 	    versuffix=
 	  else
-	    versuffix=".0.0"
+	    versuffix=.0.0
 	  fi
 	fi
 
 	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
+	if test yes,no = "$avoid_version,$need_version"; then
 	  major=
 	  versuffix=
-	  verstring=""
+	  verstring=
 	fi
 
 	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    func_warning "undefined symbols not allowed in $host shared libraries"
-	    build_libtool_libs=no
-	    build_old_libs=yes
+	if test yes = "$allow_undefined"; then
+	  if test unsupported = "$allow_undefined_flag"; then
+	    if test yes = "$build_old_libs"; then
+	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
+	      build_libtool_libs=no
+	    else
+	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
+	    fi
 	  fi
 	else
 	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
+	  allow_undefined_flag=$no_undefined_flag
 	fi
 
       fi
 
-      func_generate_dlsyms "$libname" "$libname" "yes"
+      func_generate_dlsyms "$libname" "$libname" :
       func_append libobjs " $symfileobj"
-      test "X$libobjs" = "X " && libobjs=
+      test " " = "$libobjs" && libobjs=
 
-      if test "$opt_mode" != relink; then
+      if test relink != "$opt_mode"; then
 	# Remove our outputs, but don't remove object files since they
 	# may have been created when compiling PIC objects.
 	removelist=
@@ -7556,8 +9051,8 @@ func_mode_link ()
 	  case $p in
 	    *.$objext | *.gcno)
 	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
+	       if test -n "$precious_files_regex"; then
 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
 		 then
 		   continue
@@ -7573,11 +9068,11 @@ func_mode_link ()
       fi
 
       # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
 	func_append oldlibs " $output_objdir/$libname.$libext"
 
 	# Transform .lo files to .o files.
-	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
       fi
 
       # Eliminate all temporary directories.
@@ -7598,13 +9093,13 @@ func_mode_link ()
 	  *) func_append finalize_rpath " $libdir" ;;
 	  esac
 	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
 	  dependency_libs="$temp_xrpath $dependency_libs"
 	fi
       fi
 
       # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
+      old_dlfiles=$dlfiles
       dlfiles=
       for lib in $old_dlfiles; do
 	case " $dlprefiles $dlfiles " in
@@ -7614,7 +9109,7 @@ func_mode_link ()
       done
 
       # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
+      old_dlprefiles=$dlprefiles
       dlprefiles=
       for lib in $old_dlprefiles; do
 	case "$dlprefiles " in
@@ -7623,7 +9118,7 @@ func_mode_link ()
 	esac
       done
 
-      if test "$build_libtool_libs" = yes; then
+      if test yes = "$build_libtool_libs"; then
 	if test -n "$rpath"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
@@ -7647,7 +9142,7 @@ func_mode_link ()
 	    ;;
 	  *)
 	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
+	    if test yes = "$build_libtool_need_lc"; then
 	      func_append deplibs " -lc"
 	    fi
 	    ;;
@@ -7663,9 +9158,9 @@ func_mode_link ()
 	# I'm not sure if I'm treating the release correctly.  I think
 	# release should show up in the -l (ie -lgmp5) so we don't want to
 	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
+	release=
+	versuffix=
+	major=
 	newdeplibs=
 	droppeddeps=no
 	case $deplibs_check_method in
@@ -7694,20 +9189,20 @@ EOF
 	      -l*)
 		func_stripname -l '' "$i"
 		name=$func_stripname_result
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
 		    func_append newdeplibs " $i"
-		    i=""
+		    i=
 		    ;;
 		  esac
 		fi
-		if test -n "$i" ; then
+		if test -n "$i"; then
 		  libname=`eval "\\$ECHO \"$libname_spec\""`
 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		  set dummy $deplib_matches; shift
 		  deplib_match=$1
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		    func_append newdeplibs " $i"
 		  else
 		    droppeddeps=yes
@@ -7737,20 +9232,20 @@ EOF
 		$opt_dry_run || $RM conftest
 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		    case " $predeps $postdeps " in
 		    *" $i "*)
 		      func_append newdeplibs " $i"
-		      i=""
+		      i=
 		      ;;
 		    esac
 		  fi
-		  if test -n "$i" ; then
+		  if test -n "$i"; then
 		    libname=`eval "\\$ECHO \"$libname_spec\""`
 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		    set dummy $deplib_matches; shift
 		    deplib_match=$1
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		      func_append newdeplibs " $i"
 		    else
 		      droppeddeps=yes
@@ -7787,24 +9282,24 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		if test -n "$file_magic_glob"; then
 		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
 		else
 		  libnameglob=$libname
 		fi
-		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  if test "$want_nocaseglob" = yes; then
+		  if test yes = "$want_nocaseglob"; then
 		    shopt -s nocaseglob
 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
 		    $nocaseglob
@@ -7822,25 +9317,25 @@ EOF
 		      # We might still enter an endless loop, since a link
 		      # loop can be closed while we follow links,
 		      # but so what?
-		      potlib="$potent_lib"
+		      potlib=$potent_lib
 		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
 			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
+			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
 			esac
 		      done
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
 			 $SED -e 10q |
 			 $EGREP "$file_magic_regex" > /dev/null; then
 			func_append newdeplibs " $a_deplib"
-			a_deplib=""
+			a_deplib=
 			break 2
 		      fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7848,7 +9343,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7871,30 +9366,30 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
 		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    potlib=$potent_lib # see symlink-check above in file_magic test
 		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
 		       $EGREP "$match_pattern_regex" > /dev/null; then
 		      func_append newdeplibs " $a_deplib"
-		      a_deplib=""
+		      a_deplib=
 		      break 2
 		    fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7902,7 +9397,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7918,18 +9413,18 @@ EOF
 	  done # Gone through all deplibs.
 	  ;;
 	none | unknown | *)
-	  newdeplibs=""
+	  newdeplibs=
 	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
+	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
+	    for i in $predeps $postdeps; do
 	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
 	    done
 	  fi
 	  case $tmp_deplibs in
 	  *[!\	\ ]*)
 	    echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
+	    if test none = "$deplibs_check_method"; then
 	      echo "*** Warning: inter-library dependencies are not supported in this platform."
 	    else
 	      echo "*** Warning: inter-library dependencies are not known to be supported."
@@ -7953,8 +9448,8 @@ EOF
 	  ;;
 	esac
 
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
+	if test yes = "$droppeddeps"; then
+	  if test yes = "$module"; then
 	    echo
 	    echo "*** Warning: libtool could not satisfy all declared inter-library"
 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
@@ -7963,12 +9458,12 @@ EOF
 	    if test -z "$global_symbol_pipe"; then
 	      echo
 	      echo "*** However, this would only work if libtool was able to extract symbol"
-	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 	      echo "*** not find such a program.  So, this module is probably useless."
-	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
+	    if test no = "$build_old_libs"; then
+	      oldlibs=$output_objdir/$libname.$libext
 	      build_libtool_libs=module
 	      build_old_libs=yes
 	    else
@@ -7979,14 +9474,14 @@ EOF
 	    echo "*** automatically added whenever a program is linked with this library"
 	    echo "*** or is declared to -dlopen it."
 
-	    if test "$allow_undefined" = no; then
+	    if test no = "$allow_undefined"; then
 	      echo
 	      echo "*** Since this library must not contain undefined symbols,"
 	      echo "*** because either the platform does not support them or"
 	      echo "*** it was explicitly requested with -no-undefined,"
 	      echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
+	      if test no = "$build_old_libs"; then
+		oldlibs=$output_objdir/$libname.$libext
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -8032,7 +9527,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      deplibs="$new_libs"
+      deplibs=$new_libs
 
       # All the library-specific variables (install_libdir is set above).
       library_names=
@@ -8040,25 +9535,25 @@ EOF
       dlname=
 
       # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	# Remove ${wl} instances when linking with ld.
+      if test yes = "$build_libtool_libs"; then
+	# Remove $wl instances when linking with ld.
 	# FIXME: should test the right _cmds variable.
 	case $archive_cmds in
 	  *\$LD\ *) wl= ;;
         esac
-	if test "$hardcode_into_libs" = yes; then
+	if test yes = "$hardcode_into_libs"; then
 	  # Hardcode the library paths
 	  hardcode_libdirs=
 	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+	  rpath=$finalize_rpath
+	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
 	  for libdir in $rpath; do
 	    if test -n "$hardcode_libdir_flag_spec"; then
 	      if test -n "$hardcode_libdir_separator"; then
 		func_replace_sysroot "$libdir"
 		libdir=$func_replace_sysroot_result
 		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
+		  hardcode_libdirs=$libdir
 		else
 		  # Just accumulate the unique libdirs.
 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8083,7 +9578,7 @@ EOF
 	  # Substitute the hardcoded libdirs into the rpath.
 	  if test -n "$hardcode_libdir_separator" &&
 	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
+	    libdir=$hardcode_libdirs
 	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
 	  fi
 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
@@ -8097,8 +9592,8 @@ EOF
 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
 	fi
 
-	shlibpath="$finalize_shlibpath"
-	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	shlibpath=$finalize_shlibpath
+	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
 	if test -n "$shlibpath"; then
 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
 	fi
@@ -8108,19 +9603,19 @@ EOF
 	eval library_names=\"$library_names_spec\"
 	set dummy $library_names
 	shift
-	realname="$1"
+	realname=$1
 	shift
 
 	if test -n "$soname_spec"; then
 	  eval soname=\"$soname_spec\"
 	else
-	  soname="$realname"
+	  soname=$realname
 	fi
 	if test -z "$dlname"; then
 	  dlname=$soname
 	fi
 
-	lib="$output_objdir/$realname"
+	lib=$output_objdir/$realname
 	linknames=
 	for link
 	do
@@ -8134,7 +9629,7 @@ EOF
 	delfiles=
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
-	  export_symbols="$output_objdir/$libname.uexp"
+	  export_symbols=$output_objdir/$libname.uexp
 	  func_append delfiles " $export_symbols"
 	fi
 
@@ -8143,31 +9638,31 @@ EOF
 	cygwin* | mingw* | cegcc*)
 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
 	    # exporting using user supplied symfile
-	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	    func_dll_def_p "$export_symbols" || {
 	      # and it's NOT already a .def file. Must figure out
 	      # which of the given symbols are data symbols and tag
 	      # them as such. So, trigger use of export_symbols_cmds.
 	      # export_symbols gets reassigned inside the "prepare
 	      # the list of exported symbols" if statement, so the
 	      # include_expsyms logic still works.
-	      orig_export_symbols="$export_symbols"
+	      orig_export_symbols=$export_symbols
 	      export_symbols=
 	      always_export_symbols=yes
-	    fi
+	    }
 	  fi
 	  ;;
 	esac
 
 	# Prepare the list of exported symbols
 	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    func_verbose "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
+	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for '$libname.la'"
+	    export_symbols=$output_objdir/$libname.exp
 	    $opt_dry_run || $RM $export_symbols
 	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd1 in $cmds; do
-	      IFS="$save_ifs"
+	      IFS=$save_ifs
 	      # Take the normal branch if the nm_file_list_spec branch
 	      # doesn't work or if tool conversion is not needed.
 	      case $nm_file_list_spec~$to_tool_file_cmd in
@@ -8181,7 +9676,7 @@ EOF
 		  try_normal_branch=no
 		  ;;
 	      esac
-	      if test "$try_normal_branch" = yes \
+	      if test yes = "$try_normal_branch" \
 		 && { test "$len" -lt "$max_cmd_len" \
 		      || test "$max_cmd_len" -le -1; }
 	      then
@@ -8192,7 +9687,7 @@ EOF
 		output_la=$func_basename_result
 		save_libobjs=$libobjs
 		save_output=$output
-		output=${output_objdir}/${output_la}.nm
+		output=$output_objdir/$output_la.nm
 		func_to_tool_file "$output"
 		libobjs=$nm_file_list_spec$func_to_tool_file_result
 		func_append delfiles " $output"
@@ -8215,8 +9710,8 @@ EOF
 		break
 	      fi
 	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	    IFS=$save_ifs
+	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
 	    fi
@@ -8224,16 +9719,16 @@ EOF
 	fi
 
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  tmp_export_symbols="$export_symbols"
-	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  tmp_export_symbols=$export_symbols
+	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	fi
 
-	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
 	  # The given exports_symbols file has to be filtered, so filter it.
-	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # 's' commands, which not all seds can handle. GNU sed should be fine
 	  # though. Also, the filter scales superlinearly with the number of
 	  # global variables. join(1) would be nice here, but unfortunately
 	  # isn't a blessed tool.
@@ -8252,11 +9747,11 @@ EOF
 	    ;;
 	  esac
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
 
 	if test -n "$convenience"; then
 	  if test -n "$whole_archive_flag_spec" &&
-	    test "$compiler_needs_object" = yes &&
+	    test yes = "$compiler_needs_object" &&
 	    test -z "$libobjs"; then
 	    # extract the archives, so we have objects to list.
 	    # TODO: could optimize this to just extract one archive.
@@ -8267,7 +9762,7 @@ EOF
 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
 	    test "X$libobjs" = "X " && libobjs=
 	  else
-	    gentop="$output_objdir/${outputname}x"
+	    gentop=$output_objdir/${outputname}x
 	    func_append generated " $gentop"
 
 	    func_extract_archives $gentop $convenience
@@ -8276,18 +9771,18 @@ EOF
 	  fi
 	fi
 
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
 	  eval flag=\"$thread_safe_flag_spec\"
 	  func_append linker_flags " $flag"
 	fi
 
 	# Make a backup of the uninstalled library when relinking
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
 	fi
 
 	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
+	if test yes = "$module" && test -n "$module_cmds"; then
 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	    eval test_cmds=\"$module_expsym_cmds\"
 	    cmds=$module_expsym_cmds
@@ -8305,7 +9800,7 @@ EOF
 	  fi
 	fi
 
-	if test "X$skipped_export" != "X:" &&
+	if test : != "$skipped_export" &&
 	   func_len " $test_cmds" &&
 	   len=$func_len_result &&
 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
@@ -8338,8 +9833,8 @@ EOF
 	  last_robj=
 	  k=1
 
-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
-	    output=${output_objdir}/${output_la}.lnkscript
+	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
+	    output=$output_objdir/$output_la.lnkscript
 	    func_verbose "creating GNU ld script: $output"
 	    echo 'INPUT (' > $output
 	    for obj in $save_libobjs
@@ -8351,14 +9846,14 @@ EOF
 	    func_append delfiles " $output"
 	    func_to_tool_file "$output"
 	    output=$func_to_tool_file_result
-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
-	    output=${output_objdir}/${output_la}.lnk
+	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
+	    output=$output_objdir/$output_la.lnk
 	    func_verbose "creating linker input file list: $output"
 	    : > $output
 	    set x $save_libobjs
 	    shift
 	    firstobj=
-	    if test "$compiler_needs_object" = yes; then
+	    if test yes = "$compiler_needs_object"; then
 	      firstobj="$1 "
 	      shift
 	    fi
@@ -8373,7 +9868,7 @@ EOF
 	  else
 	    if test -n "$save_libobjs"; then
 	      func_verbose "creating reloadable object files..."
-	      output=$output_objdir/$output_la-${k}.$objext
+	      output=$output_objdir/$output_la-$k.$objext
 	      eval test_cmds=\"$reload_cmds\"
 	      func_len " $test_cmds"
 	      len0=$func_len_result
@@ -8385,13 +9880,13 @@ EOF
 		func_len " $obj"
 		func_arith $len + $func_len_result
 		len=$func_arith_result
-		if test "X$objlist" = X ||
+		if test -z "$objlist" ||
 		   test "$len" -lt "$max_cmd_len"; then
 		  func_append objlist " $obj"
 		else
 		  # The command $test_cmds is almost too long, add a
 		  # command to the queue.
-		  if test "$k" -eq 1 ; then
+		  if test 1 -eq "$k"; then
 		    # The first file doesn't have a previous command to add.
 		    reload_objs=$objlist
 		    eval concat_cmds=\"$reload_cmds\"
@@ -8401,10 +9896,10 @@ EOF
 		    reload_objs="$objlist $last_robj"
 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
 		  fi
-		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  last_robj=$output_objdir/$output_la-$k.$objext
 		  func_arith $k + 1
 		  k=$func_arith_result
-		  output=$output_objdir/$output_la-${k}.$objext
+		  output=$output_objdir/$output_la-$k.$objext
 		  objlist=" $obj"
 		  func_len " $last_robj"
 		  func_arith $len0 + $func_len_result
@@ -8416,9 +9911,9 @@ EOF
 	      # files will link in the last one created.
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
 	      reload_objs="$objlist $last_robj"
-	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
 	      if test -n "$last_robj"; then
-	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
 	      func_append delfiles " $output"
 
@@ -8426,9 +9921,9 @@ EOF
 	      output=
 	    fi
 
-	    if ${skipped_export-false}; then
-	      func_verbose "generating symbol list for \`$libname.la'"
-	      export_symbols="$output_objdir/$libname.exp"
+	    ${skipped_export-false} && {
+	      func_verbose "generating symbol list for '$libname.la'"
+	      export_symbols=$output_objdir/$libname.exp
 	      $opt_dry_run || $RM $export_symbols
 	      libobjs=$output
 	      # Append the command to create the export file.
@@ -8437,16 +9932,16 @@ EOF
 	      if test -n "$last_robj"; then
 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
-	    fi
+	    }
 
 	    test -n "$save_libobjs" &&
 	      func_verbose "creating a temporary reloadable object file: $output"
 
 	    # Loop through the commands generated above and execute them.
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd in $concat_cmds; do
-	      IFS="$save_ifs"
-	      $opt_silent || {
+	      IFS=$save_ifs
+	      $opt_quiet || {
 		  func_quote_for_expand "$cmd"
 		  eval "func_echo $func_quote_for_expand_result"
 	      }
@@ -8454,7 +9949,7 @@ EOF
 		lt_exit=$?
 
 		# Restore the uninstalled library and exit
-		if test "$opt_mode" = relink; then
+		if test relink = "$opt_mode"; then
 		  ( cd "$output_objdir" && \
 		    $RM "${realname}T" && \
 		    $MV "${realname}U" "$realname" )
@@ -8463,7 +9958,7 @@ EOF
 		exit $lt_exit
 	      }
 	    done
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 
 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
@@ -8471,18 +9966,18 @@ EOF
 	    fi
 	  fi
 
-          if ${skipped_export-false}; then
+          ${skipped_export-false} && {
 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	      tmp_export_symbols="$export_symbols"
-	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      tmp_export_symbols=$export_symbols
+	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	    fi
 
 	    if test -n "$orig_export_symbols"; then
 	      # The given exports_symbols file has to be filtered, so filter it.
-	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # 's' commands, which not all seds can handle. GNU sed should be fine
 	      # though. Also, the filter scales superlinearly with the number of
 	      # global variables. join(1) would be nice here, but unfortunately
 	      # isn't a blessed tool.
@@ -8491,7 +9986,7 @@ EOF
 	      export_symbols=$output_objdir/$libname.def
 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
 	    fi
-	  fi
+	  }
 
 	  libobjs=$output
 	  # Restore the value of output.
@@ -8505,7 +10000,7 @@ EOF
 	  # value of $libobjs for piecewise linking.
 
 	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test yes = "$module" && test -n "$module_cmds"; then
 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	      cmds=$module_expsym_cmds
 	    else
@@ -8527,7 +10022,7 @@ EOF
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -8535,11 +10030,12 @@ EOF
 	  test "X$libobjs" = "X " && libobjs=
 	fi
 
-	save_ifs="$IFS"; IFS='~'
+	save_ifs=$IFS; IFS='~'
 	for cmd in $cmds; do
-	  IFS="$save_ifs"
+	  IFS=$sp$nl
 	  eval cmd=\"$cmd\"
-	  $opt_silent || {
+	  IFS=$save_ifs
+	  $opt_quiet || {
 	    func_quote_for_expand "$cmd"
 	    eval "func_echo $func_quote_for_expand_result"
 	  }
@@ -8547,7 +10043,7 @@ EOF
 	    lt_exit=$?
 
 	    # Restore the uninstalled library and exit
-	    if test "$opt_mode" = relink; then
+	    if test relink = "$opt_mode"; then
 	      ( cd "$output_objdir" && \
 	        $RM "${realname}T" && \
 		$MV "${realname}U" "$realname" )
@@ -8556,10 +10052,10 @@ EOF
 	    exit $lt_exit
 	  }
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	# Restore the uninstalled library and exit
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
 
 	  if test -n "$convenience"; then
@@ -8579,39 +10075,39 @@ EOF
 	done
 
 	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
+	if test yes = "$module" || test yes = "$export_dynamic"; then
 	  # On all known operating systems, these are identical.
-	  dlname="$soname"
+	  dlname=$soname
 	fi
       fi
       ;;
 
     obj)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for objects"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for objects"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+	func_warning "'-l' and '-L' are ignored for objects" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for objects"
+	func_warning "'-rpath' is ignored for objects"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for objects"
+	func_warning "'-R' is ignored for objects"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for objects"
+	func_warning "'-version-info' is ignored for objects"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for objects"
+	func_warning "'-release' is ignored for objects"
 
       case $output in
       *.lo)
 	test -n "$objs$old_deplibs" && \
-	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
 
 	libobj=$output
 	func_lo2o "$libobj"
@@ -8619,7 +10115,7 @@ EOF
 	;;
       *)
 	libobj=
-	obj="$output"
+	obj=$output
 	;;
       esac
 
@@ -8632,17 +10128,19 @@ EOF
       # the extraction.
       reload_conv_objs=
       gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec and hope we can get by with
-      # turning comma into space..
-      wl=
-
+      # if reload_cmds runs $LD directly, get rid of -Wl from
+      # whole_archive_flag_spec and hope we can get by with turning comma
+      # into space.
+      case $reload_cmds in
+        *\$LD[\ \$]*) wl= ;;
+      esac
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
-	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
 	else
-	  gentop="$output_objdir/${obj}x"
+	  gentop=$output_objdir/${obj}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $convenience
@@ -8651,12 +10149,12 @@ EOF
       fi
 
       # If we're not building shared, we need to use non_pic_objs
-      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
 
       # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
 
-      output="$obj"
+      output=$obj
       func_execute_cmds "$reload_cmds" 'exit $?'
 
       # Exit if we aren't doing a library object file.
@@ -8668,7 +10166,7 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$build_libtool_libs" != yes; then
+      test yes = "$build_libtool_libs" || {
 	if test -n "$gentop"; then
 	  func_show_eval '${RM}r "$gentop"'
 	fi
@@ -8678,12 +10176,12 @@ EOF
 	# $show "echo timestamp > $libobj"
 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
 	exit $EXIT_SUCCESS
-      fi
+      }
 
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
+      if test -n "$pic_flag" || test default != "$pic_mode"; then
 	# Only do commands if we really have different PIC objects.
 	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
+	output=$libobj
 	func_execute_cmds "$reload_cmds" 'exit $?'
       fi
 
@@ -8700,16 +10198,14 @@ EOF
 	          output=$func_stripname_result.exe;;
       esac
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for programs"
+	func_warning "'-version-info' is ignored for programs"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for programs"
+	func_warning "'-release' is ignored for programs"
 
-      test "$preload" = yes \
-        && test "$dlopen_support" = unknown \
-	&& test "$dlopen_self" = unknown \
-	&& test "$dlopen_self_static" = unknown && \
-	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+      $preload \
+	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
+	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
 
       case $host in
       *-*-rhapsody* | *-*-darwin1.[012])
@@ -8723,11 +10219,11 @@ EOF
       *-*-darwin*)
 	# Don't allow lazy linking, it breaks C++ global constructors
 	# But is supposedly fixed on 10.4 or later (yay!).
-	if test "$tagname" = CXX ; then
+	if test CXX = "$tagname"; then
 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
 	    10.[0123])
-	      func_append compile_command " ${wl}-bind_at_load"
-	      func_append finalize_command " ${wl}-bind_at_load"
+	      func_append compile_command " $wl-bind_at_load"
+	      func_append finalize_command " $wl-bind_at_load"
 	    ;;
 	  esac
 	fi
@@ -8763,7 +10259,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      compile_deplibs="$new_libs"
+      compile_deplibs=$new_libs
 
 
       func_append compile_command " $compile_deplibs"
@@ -8787,7 +10283,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8810,7 +10306,7 @@ EOF
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  ::) dllsearchpath=$libdir;;
@@ -8827,10 +10323,10 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      compile_rpath="$rpath"
+      compile_rpath=$rpath
 
       rpath=
       hardcode_libdirs=
@@ -8838,7 +10334,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8863,45 +10359,43 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      finalize_rpath="$rpath"
+      finalize_rpath=$rpath
 
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+      if test -n "$libobjs" && test yes = "$build_old_libs"; then
 	# Transform all the library objects into standard objects.
 	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
       fi
 
-      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+      func_generate_dlsyms "$outputname" "@PROGRAM@" false
 
       # template prelinking step
       if test -n "$prelink_cmds"; then
 	func_execute_cmds "$prelink_cmds" 'exit $?'
       fi
 
-      wrappers_required=yes
+      wrappers_required=:
       case $host in
       *cegcc* | *mingw32ce*)
         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
-        wrappers_required=no
+        wrappers_required=false
         ;;
       *cygwin* | *mingw* )
-        if test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
+        test yes = "$build_libtool_libs" || wrappers_required=false
         ;;
       *)
-        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-          wrappers_required=no
+        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
+          wrappers_required=false
         fi
         ;;
       esac
-      if test "$wrappers_required" = no; then
+      $wrappers_required || {
 	# Replace the output file specification.
 	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
+	link_command=$compile_command$compile_rpath
 
 	# We have no uninstalled library dependencies, so finalize right now.
 	exit_status=0
@@ -8914,12 +10408,12 @@ EOF
 	fi
 
 	# Delete the generated files.
-	if test -f "$output_objdir/${outputname}S.${objext}"; then
-	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	if test -f "$output_objdir/${outputname}S.$objext"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
 	fi
 
 	exit $exit_status
-      fi
+      }
 
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
@@ -8949,9 +10443,9 @@ EOF
 	fi
       fi
 
-      if test "$no_install" = yes; then
+      if test yes = "$no_install"; then
 	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
+	link_command=$compile_var$compile_command$compile_rpath
 	# Replace the output file specification.
 	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
 	# Delete the old output file.
@@ -8968,27 +10462,28 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
+      case $hardcode_action,$fast_install in
+        relink,*)
+	  # Fast installation is not supported
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
 
-	func_warning "this platform does not like uninstalled shared libraries"
-	func_warning "\`$output' will be relinked during installation"
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
+	  func_warning "this platform does not like uninstalled shared libraries"
+	  func_warning "'$output' will be relinked during installation"
+	  ;;
+        *,yes)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+          ;;
+	*,no)
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
+          ;;
+	*,needless)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=
+          ;;
+      esac
 
       # Replace the output file specification.
       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
@@ -9045,8 +10540,8 @@ EOF
 	    func_dirname_and_basename "$output" "" "."
 	    output_name=$func_basename_result
 	    output_path=$func_dirname_result
-	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
-	    cwrapper="$output_path/$output_name.exe"
+	    cwrappersource=$output_path/$objdir/lt-$output_name.c
+	    cwrapper=$output_path/$output_name.exe
 	    $RM $cwrappersource $cwrapper
 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
@@ -9067,7 +10562,7 @@ EOF
 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
 	    $opt_dry_run || {
 	      # note: this script will not be executed, so do not chmod.
-	      if test "x$build" = "x$host" ; then
+	      if test "x$build" = "x$host"; then
 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
 	      else
 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
@@ -9090,25 +10585,27 @@ EOF
     # See if we need to build an old-fashioned archive.
     for oldlib in $oldlibs; do
 
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save $symfileobj"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
+      case $build_libtool_libs in
+        convenience)
+	  oldobjs="$libobjs_save $symfileobj"
+	  addlibs=$convenience
 	  build_libtool_libs=no
-	else
+	  ;;
+	module)
+	  oldobjs=$libobjs_save
+	  addlibs=$old_convenience
+	  build_libtool_libs=no
+          ;;
+	*)
 	  oldobjs="$old_deplibs $non_pic_objects"
-	  if test "$preload" = yes && test -f "$symfileobj"; then
-	    func_append oldobjs " $symfileobj"
-	  fi
-	fi
-	addlibs="$old_convenience"
-      fi
+	  $preload && test -f "$symfileobj" \
+	    && func_append oldobjs " $symfileobj"
+	  addlibs=$old_convenience
+	  ;;
+      esac
 
       if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
+	gentop=$output_objdir/${outputname}x
 	func_append generated " $gentop"
 
 	func_extract_archives $gentop $addlibs
@@ -9116,13 +10613,13 @@ EOF
       fi
 
       # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
 	cmds=$old_archive_from_new_cmds
       else
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -9143,7 +10640,7 @@ EOF
 	  :
 	else
 	  echo "copying selected object files to avoid basename conflicts..."
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 	  func_mkdir_p "$gentop"
 	  save_oldobjs=$oldobjs
@@ -9152,7 +10649,7 @@ EOF
 	  for obj in $save_oldobjs
 	  do
 	    func_basename "$obj"
-	    objbase="$func_basename_result"
+	    objbase=$func_basename_result
 	    case " $oldobjs " in
 	    " ") oldobjs=$obj ;;
 	    *[\ /]"$objbase "*)
@@ -9221,18 +10718,18 @@ EOF
 	    else
 	      # the above command should be used before it gets too long
 	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
+	      if test "$obj" = "$last_oldobj"; then
 		RANLIB=$save_RANLIB
 	      fi
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
 	      objlist=
 	      len=$len0
 	    fi
 	  done
 	  RANLIB=$save_RANLIB
 	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
+	  if test -z "$oldobjs"; then
 	    eval cmds=\"\$concat_cmds\"
 	  else
 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
@@ -9249,7 +10746,7 @@ EOF
     case $output in
     *.la)
       old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      test yes = "$build_old_libs" && old_library=$libname.$libext
       func_verbose "creating $output"
 
       # Preserve any variables that may affect compiler behavior
@@ -9264,31 +10761,31 @@ EOF
 	fi
       done
       # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
+      if test yes = "$hardcode_automatic"; then
 	relink_command=
       fi
 
       # Only create the output if not a dry run.
       $opt_dry_run || {
 	for installed in no yes; do
-	  if test "$installed" = yes; then
+	  if test yes = "$installed"; then
 	    if test -z "$install_libdir"; then
 	      break
 	    fi
-	    output="$output_objdir/$outputname"i
+	    output=$output_objdir/${outputname}i
 	    # Replace all uninstalled libtool libraries with the installed ones
 	    newdependency_libs=
 	    for deplib in $dependency_libs; do
 	      case $deplib in
 	      *.la)
 		func_basename "$deplib"
-		name="$func_basename_result"
+		name=$func_basename_result
 		func_resolve_sysroot "$deplib"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  func_fatal_error "'$deplib' is not a valid libtool archive"
 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      -L*)
@@ -9304,23 +10801,23 @@ EOF
 	      *) func_append newdependency_libs " $deplib" ;;
 	      esac
 	    done
-	    dependency_libs="$newdependency_libs"
+	    dependency_libs=$newdependency_libs
 	    newdlfiles=
 
 	    for lib in $dlfiles; do
 	      case $lib in
 	      *.la)
 	        func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      *) func_append newdlfiles " $lib" ;;
 	      esac
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
@@ -9330,34 +10827,34 @@ EOF
 		# didn't already link the preopened objects directly into
 		# the library:
 		func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      esac
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  else
 	    newdlfiles=
 	    for lib in $dlfiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlfiles " $abs"
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlprefiles " $abs"
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  fi
 	  $RM $output
 	  # place dlname in correct position for cygwin
@@ -9373,10 +10870,9 @@ EOF
 	  case $host,$output,$installed,$module,$dlname in
 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
 	      # If a -bindir argument was supplied, place the dll there.
-	      if test "x$bindir" != x ;
-	      then
+	      if test -n "$bindir"; then
 		func_relative_path "$install_libdir" "$bindir"
-		tdlname=$func_relative_path_result$dlname
+		tdlname=$func_relative_path_result/$dlname
 	      else
 		# Otherwise fall back on heuristic.
 		tdlname=../bin/$dlname
@@ -9385,7 +10881,7 @@ EOF
 	  esac
 	  $ECHO > $output "\
 # $outputname - a libtool library file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -9399,7 +10895,7 @@ library_names='$library_names'
 # The name of the static archive.
 old_library='$old_library'
 
-# Linker flags that can not go in dependency_libs.
+# Linker flags that cannot go in dependency_libs.
 inherited_linker_flags='$new_inherited_linker_flags'
 
 # Libraries that this one depends upon.
@@ -9425,7 +10921,7 @@ dlpreopen='$dlprefiles'
 
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
+	  if test no,yes = "$installed,$need_relink"; then
 	    $ECHO >> $output "\
 relink_command=\"$relink_command\""
 	  fi
@@ -9440,27 +10936,29 @@ relink_command=\"$relink_command\""
     exit $EXIT_SUCCESS
 }
 
-{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
-    func_mode_link ${1+"$@"}
+if test link = "$opt_mode" || test relink = "$opt_mode"; then
+  func_mode_link ${1+"$@"}
+fi
 
 
 # func_mode_uninstall arg...
 func_mode_uninstall ()
 {
-    $opt_debug
-    RM="$nonopt"
+    $debug_cmd
+
+    RM=$nonopt
     files=
-    rmforce=
+    rmforce=false
     exit_status=0
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     for arg
     do
       case $arg in
-      -f) func_append RM " $arg"; rmforce=yes ;;
+      -f) func_append RM " $arg"; rmforce=: ;;
       -*) func_append RM " $arg" ;;
       *) func_append files " $arg" ;;
       esac
@@ -9473,18 +10971,18 @@ func_mode_uninstall ()
 
     for file in $files; do
       func_dirname "$file" "" "."
-      dir="$func_dirname_result"
-      if test "X$dir" = X.; then
-	odir="$objdir"
+      dir=$func_dirname_result
+      if test . = "$dir"; then
+	odir=$objdir
       else
-	odir="$dir/$objdir"
+	odir=$dir/$objdir
       fi
       func_basename "$file"
-      name="$func_basename_result"
-      test "$opt_mode" = uninstall && odir="$dir"
+      name=$func_basename_result
+      test uninstall = "$opt_mode" && odir=$dir
 
       # Remember odir for removal later, being careful to avoid duplicates
-      if test "$opt_mode" = clean; then
+      if test clean = "$opt_mode"; then
 	case " $rmdirs " in
 	  *" $odir "*) ;;
 	  *) func_append rmdirs " $odir" ;;
@@ -9499,11 +10997,11 @@ func_mode_uninstall ()
       elif test -d "$file"; then
 	exit_status=1
 	continue
-      elif test "$rmforce" = yes; then
+      elif $rmforce; then
 	continue
       fi
 
-      rmfiles="$file"
+      rmfiles=$file
 
       case $name in
       *.la)
@@ -9517,7 +11015,7 @@ func_mode_uninstall ()
 	  done
 	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
 
-	  case "$opt_mode" in
+	  case $opt_mode in
 	  clean)
 	    case " $library_names " in
 	    *" $dlname "*) ;;
@@ -9528,12 +11026,12 @@ func_mode_uninstall ()
 	  uninstall)
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
-	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 
 	    if test -n "$old_library"; then
 	      # Do each command in the old_postuninstall commands.
-	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
 	    ;;
@@ -9549,21 +11047,19 @@ func_mode_uninstall ()
 	  func_source $dir/$name
 
 	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" &&
-	     test "$pic_object" != none; then
+	  if test -n "$pic_object" && test none != "$pic_object"; then
 	    func_append rmfiles " $dir/$pic_object"
 	  fi
 
 	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" &&
-	     test "$non_pic_object" != none; then
+	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
 	    func_append rmfiles " $dir/$non_pic_object"
 	  fi
 	fi
 	;;
 
       *)
-	if test "$opt_mode" = clean ; then
+	if test clean = "$opt_mode"; then
 	  noexename=$name
 	  case $file in
 	  *.exe)
@@ -9590,12 +11086,12 @@ func_mode_uninstall ()
 
 	    # note $name still contains .exe if it was in $file originally
 	    # as does the version of $file that was added into $rmfiles
-	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
+	    if test yes = "$fast_install" && test -n "$relink_command"; then
 	      func_append rmfiles " $odir/lt-$name"
 	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      func_append rmfiles " $odir/lt-${noexename}.c"
+	    if test "X$noexename" != "X$name"; then
+	      func_append rmfiles " $odir/lt-$noexename.c"
 	    fi
 	  fi
 	fi
@@ -9604,7 +11100,7 @@ func_mode_uninstall ()
       func_show_eval "$RM $rmfiles" 'exit_status=1'
     done
 
-    # Try to remove the ${objdir}s in the directories where we deleted files
+    # Try to remove the $objdir's in the directories where we deleted files
     for dir in $rmdirs; do
       if test -d "$dir"; then
 	func_show_eval "rmdir $dir >/dev/null 2>&1"
@@ -9614,16 +11110,17 @@ func_mode_uninstall ()
     exit $exit_status
 }
 
-{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
-    func_mode_uninstall ${1+"$@"}
+if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
+  func_mode_uninstall ${1+"$@"}
+fi
 
 test -z "$opt_mode" && {
-  help="$generic_help"
+  help=$generic_help
   func_fatal_help "you must specify a MODE"
 }
 
 test -z "$exec_cmd" && \
-  func_fatal_help "invalid operation mode \`$opt_mode'"
+  func_fatal_help "invalid operation mode '$opt_mode'"
 
 if test -n "$exec_cmd"; then
   eval exec "$exec_cmd"
@@ -9634,7 +11131,7 @@ exit $exit_status
 
 
 # The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
+# where we disable both kinds of libraries.  Given conflicting
 # choices, we go for a static library, that is the most portable,
 # since we can't tell whether shared libraries were disabled because
 # the user asked for that or because the platform doesn't support
@@ -9657,5 +11154,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
 # mode:shell-script
 # sh-indentation:2
 # End:
-# vi:sw=2
-
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index d7c043f..10ab284 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1,8 +1,6 @@
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
+#   Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -10,36 +8,30 @@
 # modifications, as long as this notice is preserved.
 
 m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ])
 
-# serial 57 LT_INIT
+# serial 58 LT_INIT
 
 
 # LT_PREREQ(VERSION)
@@ -67,7 +59,7 @@ esac
 # LT_INIT([OPTIONS])
 # ------------------
 AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 AC_BEFORE([$0], [LT_LANG])dnl
 AC_BEFORE([$0], [LT_OUTPUT])dnl
@@ -91,7 +83,7 @@ dnl Parse OPTIONS
 _LT_SET_OPTIONS([$0], [$1])
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -111,26 +103,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in @S|@*""; do
+      case $cc_temp in
+        compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+        distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
 # _LT_CC_BASENAME(CC)
 # -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
 m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
 ])
 
 
 # _LT_FILEUTILS_DEFAULTS
 # ----------------------
 # It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
 m4_defun([_LT_FILEUTILS_DEFAULTS],
 [: ${CP="cp -f"}
 : ${MV="mv -f"}
@@ -177,15 +186,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
 m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
 
 _LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 ])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -198,7 +208,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -209,14 +219,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -269,14 +279,14 @@ no_glob_subst='s/\*/\\\*/g'
 
 # _LT_PROG_LTMAIN
 # ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
 # now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
 # so we pass a copy along to make sure it has a sensible value anyway.
 m4_defun([_LT_PROG_LTMAIN],
 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 ])# _LT_PROG_LTMAIN
 
 
@@ -286,7 +296,7 @@ ltmain="$ac_aux_dir/ltmain.sh"
 
 # So that we can recreate a full libtool script including additional
 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
 # label.
 
 
@@ -421,8 +431,8 @@ m4_define([_lt_decl_all_varnames],
 
 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
 # ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'.  VARNAME
 # must have a single quote delimited value for this to work.
 m4_define([_LT_CONFIG_STATUS_DECLARE],
 [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
@@ -446,7 +456,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
 # Output comment and list of tags supported by the script
 m4_defun([_LT_LIBTOOL_TAGS],
 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
 ])
 
 
@@ -474,7 +484,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
 # _LT_LIBTOOL_CONFIG_VARS
 # -----------------------
 # Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
 # script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
 # section) are produced by _LT_LIBTOOL_TAG_VARS.
 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -500,8 +510,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 # Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
 # variables for single and double quote escaping we saved from calls
 # to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'.  Finally, any additional code accumulated
 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
 m4_defun([_LT_CONFIG_COMMANDS],
 [AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -547,7 +557,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_quote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -560,7 +570,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_dquote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -576,7 +586,7 @@ _LT_OUTPUT_LIBTOOL_INIT
 # Generate a child script FILE with all initialization necessary to
 # reuse the environment learned by the parent script, and make the
 # file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
+# '#!' sequence but before initialization text begins.  After this
 # macro, additional text can be appended to FILE to form the body of
 # the child script.  The macro ends with non-zero status if the
 # file could not be fully written (such as if the disk is full).
@@ -598,7 +608,7 @@ AS_SHELL_SANITIZE
 _AS_PREPARE
 exec AS_MESSAGE_FD>&1
 _ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
 m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
 # LT_OUTPUT
@@ -621,7 +631,7 @@ exec AS_MESSAGE_LOG_FD>>config.log
 } >&AS_MESSAGE_LOG_FD
 
 lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
 for use in further configure time tests before the real libtool is
 generated.
 
@@ -643,7 +653,7 @@ Copyright (C) 2011 Free Software Foundation, Inc.
 This config.lt script is free software; the Free Software Foundation
 gives unlimited permision to copy, distribute and modify it."
 
-while test $[#] != 0
+while test 0 != $[#]
 do
   case $[1] in
     --version | --v* | -V )
@@ -656,10 +666,10 @@ do
       lt_cl_silent=: ;;
 
     -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
 
     *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
   esac
   shift
 done
@@ -685,7 +695,7 @@ chmod +x "$CONFIG_LT"
 # open by configure.  Here we exec the FD to /dev/null, effectively closing
 # config.log, so it can be properly (re)opened and appended to by config.lt.
 lt_cl_success=:
-test "$silent" = yes &&
+test yes = "$silent" &&
   lt_config_lt_args="$lt_config_lt_args --quiet"
 exec AS_MESSAGE_LOG_FD>/dev/null
 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
@@ -705,27 +715,31 @@ m4_defun([_LT_CONFIG],
 _LT_CONFIG_SAVE_COMMANDS([
   m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
   m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
 _LT_COPYING
 _LT_LIBTOOL_TAGS
 
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
 # ### BEGIN LIBTOOL CONFIG
 _LT_LIBTOOL_CONFIG_VARS
 _LT_LIBTOOL_TAG_VARS
@@ -733,13 +747,24 @@ _LT_LIBTOOL_TAG_VARS
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -756,8 +781,6 @@ _LT_EOF
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  _LT_PROG_REPLACE_SHELLFNS
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -775,7 +798,6 @@ _LT_EOF
 [m4_if([$1], [], [
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'], [])
 ])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -974,7 +996,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 
     AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
       [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -992,7 +1014,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1010,7 +1032,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
 	[lt_cv_ld_exported_symbols_list=yes],
 	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
     ])
 
     AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
@@ -1032,7 +1054,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&AS_MESSAGE_LOG_FD
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1042,32 +1064,32 @@ _LT_EOF
     ])
     case $host_os in
     rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]][[,.]]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -1087,29 +1109,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_automatic, $1)=yes
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
     m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
                   [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
   else
     _LT_TAGVAR(whole_archive_flag_spec, $1)=''
   fi
   _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
     m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[   if test yes != "$lt_cv_apple_cc_single_mod"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 ],[])
   else
@@ -1129,7 +1151,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
 # Allow to override them for all tags through lt_cv_aix_libpath.
 m4_defun([_LT_SYS_MODULE_PATH_AIX],
 [m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
+if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
@@ -1147,7 +1169,7 @@ else
     _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi],[])
   if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
   fi
   ])
   aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
@@ -1167,8 +1189,8 @@ m4_define([_LT_SHELL_INIT],
 # -----------------------
 # Find how we can fake an echo command that does not interpret backslash.
 # In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
 m4_defun([_LT_PROG_ECHO_BACKSLASH],
 [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
@@ -1196,10 +1218,10 @@ fi
 # Invoke $ECHO with all args, space-separated.
 func_echo_all ()
 {
-    $ECHO "$*" 
+    $ECHO "$*"
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) AC_MSG_RESULT([printf]) ;;
   print*) AC_MSG_RESULT([print -r]) ;;
   *) AC_MSG_RESULT([cat]) ;;
@@ -1225,16 +1247,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
 AC_DEFUN([_LT_WITH_SYSROOT],
 [AC_MSG_CHECKING([for sysroot])
 AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+  [Search for dependent libraries within DIR (or the compiler's sysroot
+   if not specified).])],
 [], [with_sysroot=no])
 
 dnl lt_sysroot will always be passed unquoted.  We quote it here
 dnl in case the user passed a directory name.
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -1244,14 +1267,14 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_RESULT([$with_sysroot])
    AC_MSG_ERROR([The sysroot must be an absolute path.])
    ;;
 esac
 
  AC_MSG_RESULT([${lt_sysroot:-no}])
 _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+[dependent libraries, and where our libraries should be installed.])])
 
 # _LT_ENABLE_LOCK
 # ---------------
@@ -1259,31 +1282,33 @@ m4_defun([_LT_ENABLE_LOCK],
 [AC_ARG_ENABLE([libtool-lock],
   [AS_HELP_STRING([--disable-libtool-lock],
     [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -1312,9 +1337,46 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1333,10 +1395,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1355,10 +1417,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -1376,19 +1438,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
     [AC_LANG_PUSH(C)
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
      AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1396,7 +1459,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -1405,7 +1468,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -1421,7 +1484,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 ])# _LT_ENABLE_LOCK
 
 
@@ -1440,11 +1503,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      [echo conftest.$ac_objext > conftest.lst
       lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
       AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -1452,7 +1515,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      ])
   ])
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -1483,7 +1546,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -1519,7 +1582,7 @@ AC_CACHE_CHECK([$1], [$2],
   [$2=no
    m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
+   lt_compiler_flag="$3"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -1546,7 +1609,7 @@ AC_CACHE_CHECK([$1], [$2],
    $RM conftest*
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$5], , :, [$5])
 else
     m4_if([$6], , :, [$6])
@@ -1568,7 +1631,7 @@ AC_DEFUN([_LT_LINKER_OPTION],
 m4_require([_LT_DECL_SED])dnl
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $3"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1587,10 +1650,10 @@ AC_CACHE_CHECK([$1], [$2],
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$4], , :, [$4])
 else
     m4_if([$5], , :, [$5])
@@ -1611,7 +1674,7 @@ AC_DEFUN([LT_CMD_MAX_LEN],
 AC_MSG_CHECKING([the maximum length of command line arguments])
 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -1651,7 +1714,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1702,22 +1765,22 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -1733,7 +1796,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     ;;
   esac
 ])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
 else
   AC_MSG_RESULT(none)
@@ -1761,7 +1824,7 @@ m4_defun([_LT_HEADER_DLFCN],
 # ----------------------------------------------------------------
 m4_defun([_LT_TRY_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
   [$4]
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -1808,9 +1871,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -1836,7 +1899,7 @@ int main ()
   return status;
 }]
 _LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+  if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -1857,7 +1920,7 @@ rm -fr conftest*
 # ------------------
 AC_DEFUN([LT_SYS_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -1867,44 +1930,52 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ])
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
+	  [lt_cv_dlopen=shl_load],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	    [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
 	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
+	      [lt_cv_dlopen=dlopen],
 	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
 	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+		  [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+		    [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
 	      ])
 	    ])
 	  ])
@@ -1913,21 +1984,21 @@ else
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1937,7 +2008,7 @@ else
 	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
     ])
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
 	  lt_cv_dlopen_self_static, [dnl
@@ -1947,9 +2018,9 @@ else
       ])
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -2041,8 +2112,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS],
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 _LT_COMPILER_C_O([$1])
 
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   AC_MSG_CHECKING([if we can lock with hard links])
   hard_links=yes
@@ -2052,8 +2123,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" !=
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+  if test no = "$hard_links"; then
+    AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
     need_locks=warn
   fi
 else
@@ -2080,8 +2151,8 @@ objdir=$lt_cv_objdir
 _LT_DECL([], [objdir], [0],
          [The name of the directory that contains temporary libtool files])dnl
 m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+  [Define to the sub-directory where libtool stores uninstalled libraries.])
 ])# _LT_CHECK_OBJDIR
 
 
@@ -2093,15 +2164,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
 _LT_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
    test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
 
   # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+  if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+     test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
     # Linking always hardcodes the temporary library directory.
     _LT_TAGVAR(hardcode_action, $1)=relink
   else
@@ -2115,12 +2186,12 @@ else
 fi
 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
 
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+   test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -2144,7 +2215,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       AC_MSG_RESULT([yes])
@@ -2162,6 +2233,47 @@ _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
 
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x at S|@2 in
+    x)
+        ;;
+    *:)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+        ;;
+    x:*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+        ;;
+    *)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
@@ -2172,17 +2284,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_OBJDUMP])dnl
 m4_require([_LT_DECL_SED])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
 	[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -2198,28 +2311,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -2233,7 +2353,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+      $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -2242,7 +2362,7 @@ fi])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -2259,14 +2379,17 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[[4-9]]*)
@@ -2274,41 +2397,91 @@ aix[[4-9]]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[[01]] | aix4.[[01]].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a[(]lib.so.V[)]'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -2318,18 +2491,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -2337,8 +2510,8 @@ beos*)
 bsdi[[45]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2350,7 +2523,7 @@ bsdi[[45]]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -2359,8 +2532,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -2376,17 +2549,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -2395,8 +2568,8 @@ m4_if([$1], [],[
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -2423,7 +2596,7 @@ m4_if([$1], [],[
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -2436,8 +2609,8 @@ m4_if([$1], [],[
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -2450,7 +2623,7 @@ m4_if([$1], [],[
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -2463,8 +2636,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2477,8 +2650,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2496,12 +2669,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -2531,10 +2705,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -2552,14 +2726,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -2567,8 +2742,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -2577,8 +2752,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -2591,8 +2766,8 @@ interix[[3-9]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2603,7 +2778,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -2611,8 +2786,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -2631,8 +2806,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -2641,13 +2816,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2672,7 +2867,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -2704,12 +2904,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -2719,7 +2919,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -2728,58 +2928,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -2790,8 +3000,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -2801,11 +3011,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -2813,8 +3023,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -2835,24 +3045,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2870,7 +3080,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -2878,8 +3088,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2888,20 +3098,30 @@ uts4*)
   ;;
 esac
 AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
 _LT_DECL([], [variables_saved_for_relink], [1],
     [Variables whose values should be saved in libtool wrapper scripts and
     restored at link time])
@@ -2934,39 +3154,41 @@ _LT_DECL([], [hardcode_into_libs], [0],
     [Whether we should hardcode library paths into libraries])
 _LT_DECL([], [sys_lib_search_path_spec], [2],
     [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+    [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+    [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
 ])# _LT_SYS_DYNAMIC_LINKER
 
 
 # _LT_PATH_TOOL_PREFIX(TOOL)
 # --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
 [m4_require([_LT_DECL_EGREP])dnl
 AC_MSG_CHECKING([for $1])
 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
 [case $MAGIC_CMD in
 [[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
 dnl $ac_dummy forces splitting on constant user-supplied paths.
 dnl POSIX.2 word splitting is done only on the output of word expansions,
 dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="m4_if([$2], , $PATH, [$2])"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+    if test -f "$ac_dir/$1"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -2989,11 +3211,11 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   AC_MSG_RESULT($MAGIC_CMD)
 else
@@ -3011,7 +3233,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
 
 # _LT_PATH_MAGIC
 # --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
 m4_defun([_LT_PATH_MAGIC],
 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -3038,16 +3260,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
 AC_ARG_WITH([gnu-ld],
     [AS_HELP_STRING([--with-gnu-ld],
 	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
+    [test no = "$withval" || with_gnu_ld=yes],
     [with_gnu_ld=no])dnl
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   AC_MSG_CHECKING([for ld used by $CC])
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -3061,7 +3283,7 @@ if test "$GCC" = yes; then
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -3072,37 +3294,37 @@ if test "$GCC" = yes; then
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   AC_MSG_CHECKING([for GNU ld])
 else
   AC_MSG_CHECKING([for non-GNU ld])
 fi
 AC_CACHE_VAL(lt_cv_path_LD,
 [if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi])
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   AC_MSG_RESULT($LD)
 else
@@ -3156,13 +3378,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -3173,6 +3395,43 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl
 ])# _LT_CMD_RELOAD
 
 
+# _LT_PATH_DD
+# -----------
+# find a working dd
+m4_defun([_LT_PATH_DD],
+[AC_CACHE_CHECK([for a working dd], [ac_cv_path_lt_DD],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+  [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
 # _LT_CHECK_MAGIC_METHOD
 # ----------------------
 # how to check for library dependencies
@@ -3188,13 +3447,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[[4-9]]*)
@@ -3221,8 +3480,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -3318,8 +3576,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3372,6 +3630,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 ])
 
@@ -3412,33 +3673,38 @@ AC_DEFUN([LT_PATH_NM],
 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
 [if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3449,21 +3715,21 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
     # Let the user override the test.
   else
     AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -3471,8 +3737,8 @@ else
     esac
   fi
   AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -3518,8 +3784,8 @@ lt_cv_sharedlib_from_linklib_cmd,
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -3531,7 +3797,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 ])
@@ -3558,13 +3824,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool
     lt_cv_path_mainfest_tool=yes
   fi
   rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
 ])# _LT_PATH_MANIFEST_TOOL
 
 
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+  test DEF = "`$SED -n dnl
+    -e '\''s/^[[	 ]]*//'\'' dnl Strip leading whitespace
+    -e '\''/^\(;.*\)*$/d'\'' dnl      Delete empty lines and comments
+    -e '\''s/^\(EXPORTS\|LIBRARY\)\([[	 ]].*\)*$/DEF/p'\'' dnl
+    -e q dnl                          Only consider the first "real" line
+    $1`" dnl
+])# _LT_DLL_DEF_P
+
+
 # LT_LIB_M
 # --------
 # check for math library
@@ -3576,11 +3857,11 @@ case $host in
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
   AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
   ;;
 *)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  AC_CHECK_LIB(m, cos, LIBM=-lm)
   ;;
 esac
 AC_SUBST([LIBM])
@@ -3599,7 +3880,7 @@ m4_defun([_LT_COMPILER_NO_RTTI],
 
 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
@@ -3651,7 +3932,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[[ABCDGISTW]]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[[ABCDEGRST]]'
   fi
   ;;
@@ -3684,14 +3965,44 @@ case `$NM -V 2>&1` in
   symcode='[[ABCDGIRSTW]]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -3709,21 +4020,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK ['"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx]"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -3763,11 +4077,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT@&t at _DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT@&t at _DLSYM_CONST
 #else
@@ -3793,7 +4107,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -3813,9 +4127,9 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	  if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -3836,7 +4150,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -3863,12 +4177,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
     [Take the output of nm and produce a listing of raw symbols and C names])
 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
     [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+    [Transform the output of nm into a list of symbols to manually relocate])
 _LT_DECL([global_symbol_to_c_name_address],
     [lt_cv_sys_global_symbol_to_c_name_address], [1],
     [Transform the output of nm in a C name address pair])
 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
     [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
     [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+    [The name lister interface])
 _LT_DECL([], [nm_file_list_spec], [1],
     [Specify filename containing input files for $NM])
 ]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3884,17 +4202,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)=
 
 m4_if([$1], [CXX], [
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -3905,8 +4224,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -3922,6 +4241,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -3971,7 +4295,7 @@ m4_if([$1], [CXX], [
     case $host_os in
       aix[[4-9]]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	else
@@ -4012,14 +4336,14 @@ m4_if([$1], [CXX], [
 	case $cc_basename in
 	  CC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -4056,7 +4380,7 @@ m4_if([$1], [CXX], [
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -4201,17 +4525,18 @@ m4_if([$1], [CXX], [
   fi
 ],
 [
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -4222,8 +4547,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -4240,6 +4565,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -4310,7 +4640,7 @@ m4_if([$1], [CXX], [
     case $host_os in
     aix*)
       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       else
@@ -4318,11 +4648,30 @@ m4_if([$1], [CXX], [
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -4338,7 +4687,7 @@ m4_if([$1], [CXX], [
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -4349,7 +4698,7 @@ m4_if([$1], [CXX], [
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -4374,6 +4723,12 @@ m4_if([$1], [CXX], [
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -4471,7 +4826,7 @@ m4_if([$1], [CXX], [
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
@@ -4500,7 +4855,7 @@ m4_if([$1], [CXX], [
   fi
 ])
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_TAGVAR(lt_prog_compiler_pic, $1)=
     ;;
@@ -4566,17 +4921,21 @@ m4_if([$1], [CXX], [
   case $host_os in
   aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+    _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -4625,9 +4984,9 @@ m4_if([$1], [CXX], [
   # included in the symbol list
   _LT_TAGVAR(include_expsyms, $1)=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4643,7 +5002,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -4651,7 +5010,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
   linux* | k*bsd*-gnu | gnu*)
@@ -4664,7 +5023,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -4686,24 +5045,24 @@ dnl Note also adjust exclude_expsyms for C++ above.
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       _LT_TAGVAR(whole_archive_flag_spec, $1)=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -4716,7 +5075,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     case $host_os in
     aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
@@ -4735,7 +5094,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -4751,7 +5110,7 @@ _LT_EOF
 	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4761,7 +5120,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_TAGVAR(always_export_symbols, $1)=no
       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -4769,61 +5128,89 @@ _LT_EOF
       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
     haiku*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
     interix[[3-9]]*)
       _LT_TAGVAR(hardcode_direct, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -4834,42 +5221,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -4883,8 +5275,8 @@ _LT_EOF
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -4902,8 +5294,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4915,7 +5307,7 @@ _LT_EOF
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -4930,9 +5322,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -4949,15 +5341,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
     esac
 
-    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+    if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
       runpath_var=
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
       _LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4973,7 +5365,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4981,34 +5373,57 @@ _LT_EOF
       ;;
 
     aix[[4-9]]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -5027,13 +5442,21 @@ _LT_EOF
       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+      _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[[012]]|aix4.[[012]].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -5052,62 +5475,80 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       _LT_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
         _LT_SYS_MODULE_PATH_AIX([$1])
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
 	 _LT_SYS_MODULE_PATH_AIX([$1])
-	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  fi
 	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 3 [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -5116,7 +5557,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -5146,16 +5587,17 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -5164,18 +5606,18 @@ _LT_EOF
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -5184,7 +5626,7 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -5234,33 +5676,33 @@ _LT_EOF
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_direct, $1)=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5268,25 +5710,25 @@ _LT_EOF
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 	m4_if($1, [], [
@@ -5294,14 +5736,14 @@ _LT_EOF
 	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 	  _LT_LINKER_OPTION([if $CC understands -b],
 	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
 	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	case $host_cpu in
@@ -5312,7 +5754,7 @@ _LT_EOF
 	*)
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -5323,16 +5765,16 @@ _LT_EOF
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
 	# This should be the same for all languages, so no per-tag cache variable.
 	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
 	  [lt_cv_irix_exported_symbol],
-	  [save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	  [save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   AC_LINK_IFELSE(
 	     [AC_LANG_SOURCE(
 	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
@@ -5345,21 +5787,32 @@ _LT_EOF
       end]])])],
 	      [lt_cv_irix_exported_symbol=yes],
 	      [lt_cv_irix_exported_symbol=no])
-           LDFLAGS="$save_LDFLAGS"])
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+           LDFLAGS=$save_LDFLAGS])
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
+	_LT_TAGVAR(link_all_deplibs, $1)=no
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(inherit_rpath, $1)=yes
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
     netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -5374,7 +5827,7 @@ _LT_EOF
     newsos6)
       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
@@ -5382,27 +5835,19 @@ _LT_EOF
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	     ;;
-	   *)
-	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	fi
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5413,33 +5858,53 @@ _LT_EOF
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5450,24 +5915,24 @@ _LT_EOF
 
     solaris*)
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -5477,11 +5942,11 @@ _LT_EOF
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	fi
@@ -5491,10 +5956,10 @@ _LT_EOF
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -5543,43 +6008,43 @@ _LT_EOF
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -5594,17 +6059,17 @@ _LT_EOF
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
 	;;
       esac
     fi
   fi
 ])
 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
 
@@ -5621,7 +6086,7 @@ x|xyes)
   # Assume -lc should be added
   _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $_LT_TAGVAR(archive_cmds, $1) in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -5701,12 +6166,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
     [Whether we need a single "-rpath" flag with a separated argument])
 _LT_TAGDECL([], [hardcode_direct], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary])
 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary and the resulting library dependency is
-    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    "absolute", i.e impossible to change by setting $shlibpath_var if the
     library is relocated])
 _LT_TAGDECL([], [hardcode_minus_L], [0],
     [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5747,10 +6212,10 @@ dnl    [Compiler flag to generate thread safe objects])
 # ------------------------
 # Ensure that the configuration variables for a C compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_C_CONFIG],
 [m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
 AC_LANG_PUSH(C)
 
 # Source file extension for C test sources.
@@ -5790,18 +6255,18 @@ if test -n "$compiler"; then
   LT_SYS_DLOPEN_SELF
   _LT_CMD_STRIPLIB
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   AC_MSG_CHECKING([if libtool supports shared libraries])
   AC_MSG_RESULT([$can_build_shared])
 
   AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -5809,8 +6274,12 @@ if test -n "$compiler"; then
     ;;
 
   aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -5818,13 +6287,13 @@ if test -n "$compiler"; then
 
   AC_MSG_CHECKING([whether to build static libraries])
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   AC_MSG_RESULT([$enable_static])
 
   _LT_CONFIG($1)
 fi
 AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
 ])# _LT_LANG_C_CONFIG
 
 
@@ -5832,14 +6301,14 @@ CC="$lt_save_CC"
 # --------------------------
 # Ensure that the configuration variables for a C++ compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_CXX_CONFIG],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
 m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   AC_PROG_CXXCPP
 else
   _lt_caught_CXX_error=yes
@@ -5881,7 +6350,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -5923,35 +6392,35 @@ if test "$_lt_caught_CXX_error" != yes; then
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
     else
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
       LT_PATH_LD
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           _LT_TAGVAR(whole_archive_flag_spec, $1)=
         fi
@@ -5987,18 +6456,30 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
       aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -6008,6 +6489,13 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -6026,13 +6514,21 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+        _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          _LT_TAGVAR(hardcode_direct, $1)=no
+          _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[[012]]|aix4.[[012]].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -6050,64 +6546,84 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
           _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
 	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	    fi
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -6117,7 +6633,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  _LT_TAGVAR(ld_shlibs, $1)=no
 	fi
@@ -6145,57 +6661,58 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 	  # Don't use ranlib
 	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  _LT_TAGVAR(always_export_symbols, $1)=no
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -6206,6 +6723,34 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_DARWIN_LINKER_FEATURES($1)
 	;;
 
+      os2*)
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	shrext_cmds=.dll
+	_LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -6241,14 +6786,14 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
         ;;
 
       hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
         _LT_TAGVAR(hardcode_direct, $1)=yes
         _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
 				             # but as the default
@@ -6260,7 +6805,7 @@ if test "$_lt_caught_CXX_error" != yes; then
             _LT_TAGVAR(ld_shlibs, $1)=no
             ;;
           aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -6269,11 +6814,11 @@ if test "$_lt_caught_CXX_error" != yes; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               _LT_TAGVAR(ld_shlibs, $1)=no
@@ -6283,15 +6828,15 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
               ;;
           esac
         fi
@@ -6317,13 +6862,13 @@ if test "$_lt_caught_CXX_error" != yes; then
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -6334,20 +6879,20 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -6362,22 +6907,22 @@ if test "$_lt_caught_CXX_error" != yes; then
       interix[[3-9]]*)
 	_LT_TAGVAR(hardcode_direct, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -6386,17 +6931,17 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    _LT_TAGVAR(link_all_deplibs, $1)=yes
 	    ;;
         esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         _LT_TAGVAR(inherit_rpath, $1)=yes
         ;;
@@ -6409,8 +6954,8 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -6419,10 +6964,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -6436,59 +6981,59 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
 	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6502,18 +7047,18 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -6521,10 +7066,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      _LT_TAGVAR(compiler_needs_object, $1)=yes
 
 	      # Not sure whether something based on
@@ -6582,22 +7127,17 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -6613,9 +7153,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	    # Archives containing C++ object files must be created using
@@ -6633,17 +7173,17 @@ if test "$_lt_caught_CXX_error" != yes; then
           cxx*)
 	    case $host in
 	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
 		;;
 	    esac
@@ -6658,21 +7198,21 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -6718,9 +7258,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # Sun C++ 4.2, 5.x and Centerline C++
             _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
 	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6728,7 +7268,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -6745,30 +7285,30 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -6776,11 +7316,11 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -6789,52 +7329,52 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
 	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
 	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
+              '"$_LT_TAGVAR(old_archive_cmds, $1)"
 	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
+              '"$_LT_TAGVAR(reload_cmds, $1)"
 	    ;;
 	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -6865,10 +7405,10 @@ if test "$_lt_caught_CXX_error" != yes; then
     esac
 
     AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+    test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
-    _LT_TAGVAR(GCC, $1)="$GXX"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$GXX
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -6895,7 +7435,7 @@ if test "$_lt_caught_CXX_error" != yes; then
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 AC_LANG_POP
 ])# _LT_LANG_CXX_CONFIG
@@ -6917,13 +7457,14 @@ AC_REQUIRE([_LT_DECL_SED])
 AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case @S|@2 in
+  .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
   esac
 } # func_stripname_cnf
 ])# _LT_FUNC_STRIPNAME_CNF
 
+
 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
 # ---------------------------------
 # Figure out "hidden" library dependencies from verbose
@@ -7007,13 +7548,13 @@ if AC_TRY_EVAL(ac_compile); then
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -7029,16 +7570,16 @@ if AC_TRY_EVAL(ac_compile); then
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
 	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -7046,9 +7587,9 @@ if AC_TRY_EVAL(ac_compile); then
 	 esac
        else
 	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)=$prev$p
 	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
 	 fi
        fi
        prev=
@@ -7063,15 +7604,15 @@ if AC_TRY_EVAL(ac_compile); then
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
+	   _LT_TAGVAR(predep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
 	 fi
        else
 	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	   _LT_TAGVAR(postdep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
 	 fi
@@ -7102,51 +7643,6 @@ interix[[3-9]]*)
   _LT_TAGVAR(postdep_objects,$1)=
   _LT_TAGVAR(postdeps,$1)=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 ])
 
@@ -7155,7 +7651,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in
 esac
  _LT_TAGVAR(compiler_lib_search_dirs, $1)=
 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
     [The directories searched by this compiler when creating a shared library])
@@ -7175,10 +7671,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1],
 # --------------------------
 # Ensure that the configuration variables for a Fortran 77 compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_F77_CONFIG],
 [AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
+if test -z "$F77" || test no = "$F77"; then
   _lt_disable_F77=yes
 fi
 
@@ -7215,7 +7711,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the F77 compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7237,7 +7733,7 @@ if test "$_lt_disable_F77" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${F77-"f77"}
@@ -7251,21 +7747,25 @@ if test "$_lt_disable_F77" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7273,11 +7773,11 @@ if test "$_lt_disable_F77" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$G77
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7294,9 +7794,9 @@ if test "$_lt_disable_F77" != yes; then
   fi # test -n "$compiler"
 
   GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
 
 AC_LANG_POP
 ])# _LT_LANG_F77_CONFIG
@@ -7306,11 +7806,11 @@ AC_LANG_POP
 # -------------------------
 # Ensure that the configuration variables for a Fortran compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_FC_CONFIG],
 [AC_LANG_PUSH(Fortran)
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
+if test -z "$FC" || test no = "$FC"; then
   _lt_disable_FC=yes
 fi
 
@@ -7347,7 +7847,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the FC compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7369,7 +7869,7 @@ if test "$_lt_disable_FC" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${FC-"f95"}
@@ -7385,21 +7885,25 @@ if test "$_lt_disable_FC" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7407,11 +7911,11 @@ if test "$_lt_disable_FC" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7431,7 +7935,7 @@ if test "$_lt_disable_FC" != yes; then
   GCC=$lt_save_GCC
   CC=$lt_save_CC
   CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+fi # test yes != "$_lt_disable_FC"
 
 AC_LANG_POP
 ])# _LT_LANG_FC_CONFIG
@@ -7441,7 +7945,7 @@ AC_LANG_POP
 # --------------------------
 # Ensure that the configuration variables for the GNU Java Compiler compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GCJ_CONFIG],
 [AC_REQUIRE([LT_PROG_GCJ])dnl
 AC_LANG_SAVE
@@ -7475,7 +7979,7 @@ CC=${GCJ-"gcj"}
 CFLAGS=$GCJFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
@@ -7512,7 +8016,7 @@ CFLAGS=$lt_save_CFLAGS
 # --------------------------
 # Ensure that the configuration variables for the GNU Go compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GO_CONFIG],
 [AC_REQUIRE([LT_PROG_GO])dnl
 AC_LANG_SAVE
@@ -7546,7 +8050,7 @@ CC=${GOC-"gccgo"}
 CFLAGS=$GOFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # Go did not exist at the time GCC didn't implicitly link libc in.
@@ -7583,7 +8087,7 @@ CFLAGS=$lt_save_CFLAGS
 # -------------------------
 # Ensure that the configuration variables for the Windows resource compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_RC_CONFIG],
 [AC_REQUIRE([LT_PROG_RC])dnl
 AC_LANG_SAVE
@@ -7599,7 +8103,7 @@ _LT_TAGVAR(objext, $1)=$objext
 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
 
 # Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
@@ -7609,7 +8113,7 @@ _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
 # Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
 lt_save_GCC=$GCC
 GCC=
@@ -7638,7 +8142,7 @@ AC_DEFUN([LT_PROG_GCJ],
 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
   [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
     [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
       AC_SUBST(GCJFLAGS)])])[]dnl
 ])
 
@@ -7749,7 +8253,7 @@ lt_ac_count=0
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f "$lt_ac_sed" && continue
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7766,9 +8270,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
     $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
     cmp -s conftest.out conftest.nl || break
     # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
+    test 10 -lt "$lt_ac_count" && break
     lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
+    if test "$lt_ac_count" -gt "$lt_ac_max"; then
       lt_ac_max=$lt_ac_count
       lt_cv_path_SED=$lt_ac_sed
     fi
@@ -7792,27 +8296,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], [])
 # Find out whether the shell is Bourne or XSI compatible,
 # or has some other useful features.
 m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
   lt_unset=false
@@ -7836,102 +8320,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
 ])# _LT_CHECK_SHELL_FEATURES
 
 
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
-
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
-
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
 # _LT_PATH_CONVERSION_FUNCTIONS
 # -----------------------------
-# Determine which file name conversion functions should be used by
+# Determine what file name conversion functions should be used by
 # func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
 # for certain cross-compile configurations and native mingw.
 m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
index 5d9acd8..94b0829 100644
--- a/m4/ltoptions.m4
+++ b/m4/ltoptions.m4
@@ -1,14 +1,14 @@
 # Helper functions for option handling.                    -*- Autoconf -*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
+#   Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 7 ltoptions.m4
+# serial 8 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
+    [m4_warning([Unknown $1 option '$2'])])[]dnl
 ])
 
 
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
   dnl
   dnl If no reference was made to various pairs of opposing options, then
   dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
   dnl archives by default:
   _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
   _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
+		   [_LT_ENABLE_FAST_INSTALL])
+  _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+		   [_LT_WITH_AIX_SONAME([aix])])
   ])
 ])# _LT_SET_OPTIONS
 
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
 [_LT_SET_OPTION([LT_INIT], [dlopen])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 _LT_SET_OPTION([LT_INIT], [win32-dll])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
 # _LT_ENABLE_SHARED([DEFAULT])
 # ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_SHARED],
 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([shared],
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
 # _LT_ENABLE_STATIC([DEFAULT])
 # ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_STATIC],
 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([static],
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
 # ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_FAST_INSTALL],
 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([fast-install],
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
 ])
 
 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
 
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'.  If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+  AC_MSG_CHECKING([which variant of shared library versioning to provide])
+  AC_ARG_WITH([aix-soname],
+    [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+      [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+    [case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname],
+    [AC_CACHE_VAL([lt_cv_with_aix_soname],
+      [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+    with_aix_soname=$lt_cv_with_aix_soname])
+  AC_MSG_RESULT([$with_aix_soname])
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+    [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'.  If omitted, it defaults to 'both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
     [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+    [pic_mode=m4_default([$1], [default])])
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
 [_LT_SET_OPTION([LT_INIT], [pic-only])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
index 9000a05..48bc934 100644
--- a/m4/ltsugar.m4
+++ b/m4/ltsugar.m4
@@ -1,6 +1,7 @@
 # ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
 #
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
 # Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -33,7 +34,7 @@ m4_define([_lt_join],
 # ------------
 # Manipulate m4 lists.
 # These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
 m4_define([lt_car], [[$1]])
 m4_define([lt_cdr],
 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
 
 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
 # ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
 # Note that neither SEPARATOR nor STRING are expanded; they are appended
 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
index 07a8602..fa04b52 100644
--- a/m4/ltversion.m4
+++ b/m4/ltversion.m4
@@ -1,6 +1,6 @@
 # ltversion.m4 -- version numbers			-*- Autoconf -*-
 #
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
 #   Written by Scott James Remnant, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -9,15 +9,15 @@
 
 # @configure_input@
 
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
index c573da9..c6b26f8 100644
--- a/m4/lt~obsolete.m4
+++ b/m4/lt~obsolete.m4
@@ -1,6 +1,7 @@
 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
@@ -11,7 +12,7 @@
 
 # These exist entirely to fool aclocal when bootstrapping libtool.
 #
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
 # which have later been changed to m4_define as they aren't part of the
 # exported API, or moved to Autoconf or Automake where they belong.
 #
@@ -25,7 +26,7 @@
 # included after everything else.  This provides aclocal with the
 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
 # because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
 #
 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
 # Yes, that means every name once taken will need to remain here until
diff --git a/m4/pkg.m4 b/m4/pkg.m4
index 9a71878..4688002 100644
--- a/m4/pkg.m4
+++ b/m4/pkg.m4
@@ -1,29 +1,60 @@
-# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-# 
-# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
+dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+dnl serial 11 (pkg-config-0.29)
+dnl
+dnl Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists at gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
 AC_DEFUN([PKG_PROG_PKG_CONFIG],
 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -45,18 +76,19 @@ if test -n "$PKG_CONFIG"; then
 		PKG_CONFIG=""
 	fi
 fi[]dnl
-])# PKG_PROG_PKG_CONFIG
-
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# Check to see whether a particular set of modules exists.  Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-#
-# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
-# it's called might be skipped (such as if it is within an "if", you
-# have to call PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
 AC_DEFUN([PKG_CHECK_EXISTS],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 if test -n "$PKG_CONFIG" && \
@@ -66,8 +98,10 @@ m4_ifvaln([$3], [else
   $3])dnl
 fi])
 
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
 m4_define([_PKG_CONFIG],
 [if test -n "$$1"; then
     pkg_cv_[]$1="$$1"
@@ -79,10 +113,11 @@ m4_define([_PKG_CONFIG],
  else
     pkg_failed=untried
 fi[]dnl
-])# _PKG_CONFIG
+])dnl _PKG_CONFIG
 
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -90,19 +125,17 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
 else
         _pkg_short_errors_supported=no
 fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
-
-
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
-#
-#
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-#
-#
-# --------------------------------------------------------------
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
 AC_DEFUN([PKG_CHECK_MODULES],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
@@ -156,4 +189,87 @@ else
         AC_MSG_RESULT([yes])
 	$3
 fi[]dnl
-])# PKG_CHECK_MODULES
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
diff --git a/man/Makefile.in b/man/Makefile.in
index f4568cb..648e8c5 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -78,9 +88,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/Makefile-client.am \
-	$(srcdir)/Makefile-server.am $(srcdir)/Makefile.in \
-	$(srcdir)/Makefile.am $(dist_man_MANS)
 @ENABLE_CLIENT_TRUE@@WITH_MAN_PAGES_TRUE at am__append_1 = \
 @ENABLE_CLIENT_TRUE@@WITH_MAN_PAGES_TRUE@	ceph-syn.8 \
 @ENABLE_CLIENT_TRUE@@WITH_MAN_PAGES_TRUE@	ceph-conf.8 \
@@ -157,6 +164,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/acconfig.h
 CONFIG_CLEAN_FILES =
@@ -212,6 +220,8 @@ am__installdirs = "$(DESTDIR)$(man8dir)"
 NROFF = nroff
 MANS = $(dist_man_MANS)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile-client.am \
+	$(srcdir)/Makefile-server.am $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -302,6 +312,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -398,6 +409,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -436,7 +448,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/Makefile-client.am $(src
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu man/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -445,7 +456,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/Makefile-client.am $(srcdir)/Makefile-server.am:
+$(srcdir)/Makefile-client.am $(srcdir)/Makefile-server.am $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -663,6 +674,8 @@ uninstall-man: uninstall-man8
 	ps ps-am tags-am uninstall uninstall-am uninstall-man \
 	uninstall-man8
 
+.PRECIOUS: Makefile
+
 
 # prevent `make` from running in parallel, sphinx runs better in batch mode.
 @WITH_MAN_PAGES_TRUE at .PHONY: sphinx-build.stamp
diff --git a/man/ceph-authtool.8 b/man/ceph-authtool.8
index 90b1a42..47451cb 100644
--- a/man/ceph-authtool.8
+++ b/man/ceph-authtool.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-AUTHTOOL" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-AUTHTOOL" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-authtool \- ceph keyring manipulation tool
 .
diff --git a/man/ceph-clsinfo.8 b/man/ceph-clsinfo.8
index feb5fa3..3cf58a4 100644
--- a/man/ceph-clsinfo.8
+++ b/man/ceph-clsinfo.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-CLSINFO" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-CLSINFO" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-clsinfo \- show class object information
 .
diff --git a/man/ceph-conf.8 b/man/ceph-conf.8
index ad73e90..948e43f 100644
--- a/man/ceph-conf.8
+++ b/man/ceph-conf.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-CONF" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-CONF" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-conf \- ceph conf file tool
 .
diff --git a/man/ceph-create-keys.8 b/man/ceph-create-keys.8
index a2a03b6..530c258 100644
--- a/man/ceph-create-keys.8
+++ b/man/ceph-create-keys.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-CREATE-KEYS" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-CREATE-KEYS" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-create-keys \- ceph keyring generate tool
 .
diff --git a/man/ceph-debugpack.8 b/man/ceph-debugpack.8
index 741ecf8..9f1aa42 100644
--- a/man/ceph-debugpack.8
+++ b/man/ceph-debugpack.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-DEBUGPACK" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-DEBUGPACK" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-debugpack \- ceph debug packer utility
 .
diff --git a/man/ceph-dencoder.8 b/man/ceph-dencoder.8
index 0db2fe8..8fe95f0 100644
--- a/man/ceph-dencoder.8
+++ b/man/ceph-dencoder.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-DENCODER" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-DENCODER" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-dencoder \- ceph encoder/decoder utility
 .
diff --git a/man/ceph-deploy.8 b/man/ceph-deploy.8
index be37a19..f9fee42 100644
--- a/man/ceph-deploy.8
+++ b/man/ceph-deploy.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-DEPLOY" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-DEPLOY" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-deploy \- Ceph deployment tool
 .
@@ -233,7 +233,7 @@ were created then a concatenated keyring is used for deployment of monitors. In
 this process a keyring parser is used which looks for \fB[entity]\fP sections in
 monitor keyrings and returns a list of those sections. A helper is then used to
 collect all keyrings into a single blob that will be used to inject it to monitors
-with \fI\-\-mkfs\fP on remote nodes. All keyring files are concatenated to be
+with \fB\-\-mkfs\fP on remote nodes. All keyring files are concatenated to be
 in a directory ending with \fB\&.keyring\fP\&. During this process the helper uses list
 of sections returned by keyring parser to check if an entity is already present
 in a keyring and if not, adds it. The concatenated keyring is used for deployment
diff --git a/man/ceph-detect-init.8 b/man/ceph-detect-init.8
index cba555f..fbff1de 100644
--- a/man/ceph-detect-init.8
+++ b/man/ceph-detect-init.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-DETECT-INIT" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-DETECT-INIT" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-detect-init \- display the init system Ceph should use
 .
diff --git a/man/ceph-disk.8 b/man/ceph-disk.8
index cac4ef2..f882a19 100644
--- a/man/ceph-disk.8
+++ b/man/ceph-disk.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-DISK" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-DISK" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-disk \- Ceph disk utility for OSD
 .
@@ -123,7 +123,7 @@ ceph\-disk activate [PATH]
 .sp
 Here, [PATH] is path to a block device or a directory.
 .sp
-An additional option \fI\-\-activate\-key\fP has to be used with this
+An additional option \fB\-\-activate\-key\fP has to be used with this
 subcommand when a copy of \fB/var/lib/ceph/bootstrap\-osd/{cluster}.keyring\fP
 isn\(aqt present in the OSD node.
 .sp
@@ -139,7 +139,7 @@ ceph\-disk activate [PATH] [\-\-activate\-key PATH]
 .UNINDENT
 .UNINDENT
 .sp
-Another option \fI\-\-mark\-init\fP can also be used with this
+Another option \fB\-\-mark\-init\fP can also be used with this
 subcommand.  \fB\-\-mark\-init\fP provides init system to manage the OSD
 directory. It defaults to \fBauto\fP which detects the init system
 suitable for ceph (either \fBsysvinit\fP, \fBsystemd\fP or
@@ -162,10 +162,10 @@ ceph\-disk activate [PATH] [\-\-mark\-init *sysvinit|upstart|systemd|auto|none*]
 .UNINDENT
 .UNINDENT
 .sp
-If the option \fI\-\-no\-start\-daemon\fP is given, the activation
+If the option \fB\-\-no\-start\-daemon\fP is given, the activation
 steps are performed but the OSD daemon is not started.
 .sp
-The latest option \fI\-\-reactivate\fP can re\-activate the OSD which has been
+The latest option \fB\-\-reactivate\fP can re\-activate the OSD which has been
 deactivated with the \fBdeactivate\fP subcommand.
 .sp
 Usage:
@@ -198,7 +198,7 @@ ceph\-disk activate\-journal [DEV]
 .sp
 Here, [DEV] is the path to a journal block device.
 .sp
-Others options like \fI\-\-activate\-key\fP and \fI\-\-mark\-init\fP can also
+Others options like \fB\-\-activate\-key\fP and \fB\-\-mark\-init\fP can also
 be used with this subcommand.
 .sp
 \fB\-\-mark\-init\fP provides init system to manage the OSD directory.
@@ -233,7 +233,7 @@ ceph\-disk activate\-all
 .UNINDENT
 .UNINDENT
 .sp
-Others options like \fI\-\-activate\-key\fP and \fI\-\-mark\-init\fP can
+Others options like \fB\-\-activate\-key\fP and \fB\-\-mark\-init\fP can
 also be used with this subcommand.
 .sp
 \fB\-\-mark\-init\fP provides init system to manage the OSD directory.
@@ -312,7 +312,7 @@ files are removed (so that it is not automatically re\-activated by the \fBudev\
 rules) and the file deactive is created to remember the OSD is deactivated.
 If the OSD is dmcrypt, remove the data dmcrypt map. When deactivate finishes,
 the OSD is \fBdown\fP\&. A deactivated OSD can later be re\-activated using the
-\fI\-\-reactivate\fP option of the \fBactivate\fP subcommand.
+\fB\-\-reactivate\fP option of the \fBactivate\fP subcommand.
 .sp
 Usage:
 .INDENT 0.0
@@ -328,11 +328,11 @@ ceph\-disk deactivate [PATH]
 .sp
 Here, [PATH] is a path to a block device or a directory.
 .sp
-Another option \fI\-\-mark\-out\fP can also be used with this subcommand.
+Another option \fB\-\-mark\-out\fP can also be used with this subcommand.
 \fB\-\-mark\-out\fP marks the OSD out. The objects it contains will be remapped.
 If you are not sure you will destroy OSD, do not use this option.
 .sp
-You can also use \fBosd\-id\fP to deactivate an OSD with the option \fI\-\-deactivate\-by\-id\fP\&.
+You can also use \fBosd\-id\fP to deactivate an OSD with the option \fB\-\-deactivate\-by\-id\fP\&.
 .sp
 Usage:
 .INDENT 0.0
@@ -364,7 +364,7 @@ ceph\-disk destroy [PATH]
 .sp
 Here, [PATH] is a path to a block device or a directory.
 .sp
-Another option \fI\-\-zap\fP can also be used with this subcommand.
+Another option \fB\-\-zap\fP can also be used with this subcommand.
 \fB\-\-zap\fP will destroy the partition table and content of the disk.
 .sp
 Usage:
@@ -380,7 +380,7 @@ ceph\-disk destroy [PATH] [\-\-zap]
 .UNINDENT
 .sp
 You can also use the id of an OSD instead of the path with the option
-\fI\-\-destroy\-by\-id\fP\&.
+\fB\-\-destroy\-by\-id\fP\&.
 .sp
 Usage:
 .INDENT 0.0
diff --git a/man/ceph-fuse.8 b/man/ceph-fuse.8
index db7aa5f..ab15785 100644
--- a/man/ceph-fuse.8
+++ b/man/ceph-fuse.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-FUSE" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-FUSE" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-fuse \- FUSE-based client for ceph
 .
diff --git a/man/ceph-mds.8 b/man/ceph-mds.8
index 3409071..7886f3a 100644
--- a/man/ceph-mds.8
+++ b/man/ceph-mds.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-MDS" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-MDS" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-mds \- ceph metadata server daemon
 .
diff --git a/man/ceph-mon.8 b/man/ceph-mon.8
index 96db1d5..49ca773 100644
--- a/man/ceph-mon.8
+++ b/man/ceph-mon.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-MON" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-MON" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-mon \- ceph monitor daemon
 .
diff --git a/man/ceph-osd.8 b/man/ceph-osd.8
index b71217e..e2f9502 100644
--- a/man/ceph-osd.8
+++ b/man/ceph-osd.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-OSD" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-OSD" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-osd \- ceph object storage daemon
 .
diff --git a/man/ceph-post-file.8 b/man/ceph-post-file.8
index b96c348..760d6b6 100644
--- a/man/ceph-post-file.8
+++ b/man/ceph-post-file.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-POST-FILE" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-POST-FILE" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-post-file \- post files for ceph developers
 .
diff --git a/man/ceph-rbdnamer.8 b/man/ceph-rbdnamer.8
index 6f4e507..05d15a3 100644
--- a/man/ceph-rbdnamer.8
+++ b/man/ceph-rbdnamer.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-RBDNAMER" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-RBDNAMER" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-rbdnamer \- udev helper to name RBD devices
 .
diff --git a/man/ceph-rest-api.8 b/man/ceph-rest-api.8
index 04483b7..4ae0ef7 100644
--- a/man/ceph-rest-api.8
+++ b/man/ceph-rest-api.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-REST-API" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-REST-API" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-rest-api \- ceph RESTlike administration server
 .
diff --git a/man/ceph-run.8 b/man/ceph-run.8
index 9d08f59..d9a475b 100644
--- a/man/ceph-run.8
+++ b/man/ceph-run.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-RUN" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-RUN" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-run \- restart daemon on core dump
 .
diff --git a/man/ceph-syn.8 b/man/ceph-syn.8
index c544864..acc7760 100644
--- a/man/ceph-syn.8
+++ b/man/ceph-syn.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH-SYN" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH-SYN" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph-syn \- ceph synthetic workload generator
 .
diff --git a/man/ceph.8 b/man/ceph.8
index 09b14a7..d75ca14 100644
--- a/man/ceph.8
+++ b/man/ceph.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPH" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPH" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 ceph \- ceph administration tool
 .
diff --git a/man/cephfs.8 b/man/cephfs.8
index 36c14d7..2e41859 100644
--- a/man/cephfs.8
+++ b/man/cephfs.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CEPHFS" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CEPHFS" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 cephfs \- ceph file system options utility
 .
diff --git a/man/crushtool.8 b/man/crushtool.8
index 9544c49..c3e3155 100644
--- a/man/crushtool.8
+++ b/man/crushtool.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "CRUSHTOOL" "8" "January 13, 2016" "dev" "Ceph"
+.TH "CRUSHTOOL" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 crushtool \- CRUSH map manipulation tool
 .
diff --git a/man/librados-config.8 b/man/librados-config.8
index c016749..65c5ebc 100644
--- a/man/librados-config.8
+++ b/man/librados-config.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "LIBRADOS-CONFIG" "8" "January 13, 2016" "dev" "Ceph"
+.TH "LIBRADOS-CONFIG" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 librados-config \- display information about librados
 .
diff --git a/man/monmaptool.8 b/man/monmaptool.8
index 36bf3e4..3d06cae 100644
--- a/man/monmaptool.8
+++ b/man/monmaptool.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "MONMAPTOOL" "8" "January 13, 2016" "dev" "Ceph"
+.TH "MONMAPTOOL" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 monmaptool \- ceph monitor cluster map manipulation tool
 .
diff --git a/man/mount.ceph.8 b/man/mount.ceph.8
index c31ec9a..a91af66 100644
--- a/man/mount.ceph.8
+++ b/man/mount.ceph.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "MOUNT.CEPH" "8" "January 13, 2016" "dev" "Ceph"
+.TH "MOUNT.CEPH" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 mount.ceph \- mount a ceph file system
 .
diff --git a/man/osdmaptool.8 b/man/osdmaptool.8
index 0c866e2..99b6cfb 100644
--- a/man/osdmaptool.8
+++ b/man/osdmaptool.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "OSDMAPTOOL" "8" "January 13, 2016" "dev" "Ceph"
+.TH "OSDMAPTOOL" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 osdmaptool \- ceph osd cluster map manipulation tool
 .
diff --git a/man/rados.8 b/man/rados.8
index cdf3ec0..60747c5 100644
--- a/man/rados.8
+++ b/man/rados.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RADOS" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RADOS" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rados \- rados object storage utility
 .
@@ -116,6 +116,9 @@ Write object name to the cluster with contents from infile.
 .B \fBrm\fP \fIname\fP
 Remove object name.
 .TP
+.B \fBlistwatchers\fP \fIname\fP
+List the watchers of object name.
+.TP
 .B \fBls\fP \fIoutfile\fP
 List objects in given pool and write to outfile.
 .TP
@@ -137,7 +140,9 @@ Benchmark for \fIseconds\fP\&. The mode can be \fIwrite\fP, \fIseq\fP, or
 sequential or random. Before running one of the reading benchmarks,
 run a write benchmark with the \fI\-\-no\-cleanup\fP option. The default
 object size is 4 MB, and the default number of simulated threads
-(parallel writes) is 16.
+(parallel writes) is 16. The \fI\-\-run\-name <label>\fP option is useful
+for benchmarking a workload test from multiple clients. The \fI<label>\fP
+is an arbitrary object name.
 Note: \-b \fIobjsize\fP option is valid only in \fIwrite\fP mode.
 .UNINDENT
 .sp
diff --git a/man/radosgw-admin.8 b/man/radosgw-admin.8
index a9d2dcf..98215ed 100644
--- a/man/radosgw-admin.8
+++ b/man/radosgw-admin.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RADOSGW-ADMIN" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RADOSGW-ADMIN" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 radosgw-admin \- rados REST gateway user administration utility
 .
@@ -168,6 +168,7 @@ List log objects.
 .TP
 .B \fBlog show\fP
 Dump a log from specific object or (bucket + date + bucket\-id).
+(NOTE: required to specify formatting of date to "YYYY\-MM\-DD\-hh")
 .TP
 .B \fBlog rm\fP
 Remove log object.
@@ -522,7 +523,7 @@ Show the logs of a bucket from April 1st, 2012:
 .sp
 .nf
 .ft C
-$ radosgw\-admin log show \-\-bucket=foo \-\-date=2012\-04\-01
+$ radosgw\-admin log show \-\-bucket=foo \-\-date=2012\-04\-01\-01 \-\-bucket\-id=default.14193.1
 .ft P
 .fi
 .UNINDENT
diff --git a/man/radosgw.8 b/man/radosgw.8
index b7763cd..7c288a7 100644
--- a/man/radosgw.8
+++ b/man/radosgw.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RADOSGW" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RADOSGW" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 radosgw \- rados REST gateway
 .
diff --git a/man/rbd-fuse.8 b/man/rbd-fuse.8
index 142c1f4..38858bc 100644
--- a/man/rbd-fuse.8
+++ b/man/rbd-fuse.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RBD-FUSE" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RBD-FUSE" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rbd-fuse \- expose rbd images as files
 .
diff --git a/man/rbd-nbd.8 b/man/rbd-nbd.8
index b87e75f..c9f8f28 100644
--- a/man/rbd-nbd.8
+++ b/man/rbd-nbd.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RBD-NBD" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RBD-NBD" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rbd-nbd \- map rbd images to nbd device
 .
diff --git a/man/rbd-replay-many.8 b/man/rbd-replay-many.8
index 7a8cf40..c851542 100644
--- a/man/rbd-replay-many.8
+++ b/man/rbd-replay-many.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RBD-REPLAY-MANY" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RBD-REPLAY-MANY" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rbd-replay-many \- replay a rados block device (RBD) workload on several clients
 .
diff --git a/man/rbd-replay-prep.8 b/man/rbd-replay-prep.8
index 46bab70..231a5a0 100644
--- a/man/rbd-replay-prep.8
+++ b/man/rbd-replay-prep.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RBD-REPLAY-PREP" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RBD-REPLAY-PREP" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rbd-replay-prep \- prepare captured rados block device (RBD) workloads for replay
 .
diff --git a/man/rbd-replay.8 b/man/rbd-replay.8
index 64b17dc..29674df 100644
--- a/man/rbd-replay.8
+++ b/man/rbd-replay.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RBD-REPLAY" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RBD-REPLAY" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rbd-replay \- replay rados block device (RBD) workloads
 .
diff --git a/man/rbd.8 b/man/rbd.8
index 7b3d9c4..4388a8d 100644
--- a/man/rbd.8
+++ b/man/rbd.8
@@ -1,6 +1,6 @@
 .\" Man page generated from reStructuredText.
 .
-.TH "RBD" "8" "January 13, 2016" "dev" "Ceph"
+.TH "RBD" "8" "February 24, 2016" "dev" "Ceph"
 .SH NAME
 rbd \- manage rados block device (RBD) images
 .
diff --git a/missing b/missing
index db98974..f62bbae 100755
--- a/missing
+++ b/missing
@@ -3,7 +3,7 @@
 
 scriptversion=2013-10-28.13; # UTC
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
diff --git a/py-compile b/py-compile
index 46ea866..bc20391 100755
--- a/py-compile
+++ b/py-compile
@@ -3,7 +3,7 @@
 
 scriptversion=2011-06-08.12; # UTC
 
-# Copyright (C) 2000-2013 Free Software Foundation, Inc.
+# Copyright (C) 2000-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/selinux/Makefile.in b/selinux/Makefile.in
index e628a89..482ac30 100644
--- a/selinux/Makefile.in
+++ b/selinux/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -79,7 +89,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = selinux
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/ac_prog_jar.m4 \
@@ -98,6 +107,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/acconfig.h
 CONFIG_CLEAN_FILES =
@@ -122,6 +132,7 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -212,6 +223,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -308,6 +320,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -345,7 +358,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign selinux/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign selinux/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -525,6 +537,8 @@ uninstall-am:
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags-am uninstall uninstall-am
 
+.PRECIOUS: Makefile
+
 
 ceph.pp: ceph.te ceph.fc ceph.if
 	$(MAKE) -j1 -f $(datadir)/selinux/devel/Makefile ceph.pp
diff --git a/src/.git_version b/src/.git_version
index 3cc1b6c..b76b127 100644
--- a/src/.git_version
+++ b/src/.git_version
@@ -1,2 +1,2 @@
-86764eaebe1eda943c59d7d784b893ec8b0c6ff9
-v10.0.2
+efc8134f669743f4946297eac89aa0fd46a19dae
+v10.0.3
diff --git a/src/Makefile-client.am b/src/Makefile-client.am
index aff21ae..6babaf6 100644
--- a/src/Makefile-client.am
+++ b/src/Makefile-client.am
@@ -80,6 +80,7 @@ cephfs_LDADD = $(LIBCOMMON)
 bin_PROGRAMS += cephfs
 
 python_PYTHON += pybind/cephfs.py
+python_PYTHON += pybind/ceph_volume_client.py
 
 # libcephfs (this should go somewhere else in the future)
 
diff --git a/src/Makefile-env.am b/src/Makefile-env.am
index 3d8a252..7dd3967 100644
--- a/src/Makefile-env.am
+++ b/src/Makefile-env.am
@@ -201,7 +201,7 @@ LIBPERFGLUE = libperfglue.la
 LIBAUTH = libauth.la
 LIBMSG = libmsg.la
 LIBCRUSH = libcrush.la
-LIBCOMPRESSOR = libcompressor.la -lsnappy
+LIBCOMPRESSOR = libcompressor.la
 LIBJSON_SPIRIT = libjson_spirit.la
 LIBKV = libkv.a
 LIBLOG = liblog.la
@@ -266,8 +266,14 @@ LIBOSD += $(LIBOSD_TYPES) $(LIBOS_TYPES)
 # libkv/libos linking order is ornery
 if WITH_SLIBROCKSDB
 LIBKV += rocksdb/librocksdb.a
+if HAVE_BZLIB
+LIBKV += -lbz2
 endif
-LIBKV += -lbz2 -lz -lleveldb -lsnappy
+if HAVE_LZ4
+LIBKV += -llz4
+endif
+endif # WITH_SLIBROCKSDB
+LIBKV += -lz -lleveldb -lsnappy
 LIBOS += $(LIBOS_TYPES) $(LIBKV)
 
 LIBMON += $(LIBMON_TYPES)
diff --git a/src/Makefile-rocksdb.am b/src/Makefile-rocksdb.am
index 677829d..0b8bc1b 100644
--- a/src/Makefile-rocksdb.am
+++ b/src/Makefile-rocksdb.am
@@ -1,110 +1,149 @@
 EXTRA_DIST += \
-  rocksdb/.arcconfig \
-  rocksdb/PATENTS \
-  rocksdb/.clang-format \
-  rocksdb/AUTHORS \
-  rocksdb/CONTRIBUTING.md \
-  rocksdb/LICENSE \
-  rocksdb/README.md \
-  rocksdb/Vagrantfile \
-  rocksdb/arcanist_util/__phutil_library_init__.php \
+  rocksdb/appveyor.yml \
   rocksdb/arcanist_util/config/FacebookArcanistConfiguration.php \
   rocksdb/arcanist_util/cpp_linter/ArcanistCpplintLinter.php \
-  rocksdb/arcanist_util/cpp_linter/cpplint.py \
   rocksdb/arcanist_util/cpp_linter/BaseDirectoryScopedFormatLinter.php \
+  rocksdb/arcanist_util/cpp_linter/cpplint.py \
   rocksdb/arcanist_util/cpp_linter/FacebookHowtoevenLinter.php \
   rocksdb/arcanist_util/cpp_linter/FbcodeClangFormatLinter.php \
   rocksdb/arcanist_util/cpp_linter/FbcodeCppLinter.php \
   rocksdb/arcanist_util/lint_engine/FacebookFbcodeLintEngine.php \
   rocksdb/arcanist_util/lint_engine/FacebookHowtoevenLintEngine.php \
-  rocksdb/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php \
+  rocksdb/arcanist_util/__phutil_library_init__.php \
   rocksdb/arcanist_util/__phutil_library_map__.php \
-  rocksdb/build_tools/make_new_version.sh \
-  rocksdb/build_tools/make_package.sh \
-  rocksdb/build_tools/regression_build_test.sh \
-  rocksdb/build_tools/version.sh \
+  rocksdb/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php \
+  rocksdb/.arcconfig \
+  rocksdb/AUTHORS \
   rocksdb/build_tools/amalgamate.py \
   rocksdb/build_tools/build_detect_platform \
   rocksdb/build_tools/dockerbuild.sh \
-  rocksdb/build_tools/fb_compile_mongo.sh \
-  rocksdb/build_tools/fbcode_config.sh \
   rocksdb/build_tools/fbcode_config4.8.1.sh \
+  rocksdb/build_tools/fbcode_config.sh \
+  rocksdb/build_tools/fb_compile_mongo.sh \
   rocksdb/build_tools/format-diff.sh \
+  rocksdb/build_tools/make_new_version.sh \
+  rocksdb/build_tools/make_package.sh \
+  rocksdb/build_tools/regression_build_test.sh \
   rocksdb/build_tools/rocksdb-lego-determinator \
   rocksdb/build_tools/run_ci_db_test.ps1 \
+  rocksdb/build_tools/version.sh \
+  rocksdb/.clang-format \
+  rocksdb/CMakeLists.txt \
+  rocksdb/CONTRIBUTING.md \
   rocksdb/coverage/coverage_test.sh \
   rocksdb/coverage/parse_gcov_output.py \
+  rocksdb/db/builder.cc \
+  rocksdb/db/builder.h \
+  rocksdb/db/c.cc \
+  rocksdb/db/column_family.cc \
+  rocksdb/db/column_family.h \
+  rocksdb/db/column_family_test.cc \
+  rocksdb/db/compacted_db_impl.cc \
+  rocksdb/db/compacted_db_impl.h \
+  rocksdb/db/compact_files_test.cc \
+  rocksdb/db/compaction.cc \
+  rocksdb/db/compaction.h \
+  rocksdb/db/compaction_iterator.cc \
+  rocksdb/db/compaction_iterator.h \
+  rocksdb/db/compaction_iterator_test.cc \
+  rocksdb/db/compaction_job.cc \
+  rocksdb/db/compaction_job.h \
+  rocksdb/db/compaction_job_stats_test.cc \
+  rocksdb/db/compaction_job_test.cc \
+  rocksdb/db/compaction_picker.cc \
   rocksdb/db/compaction_picker.h \
   rocksdb/db/compaction_picker_test.cc \
   rocksdb/db/comparator_db_test.cc \
   rocksdb/db/convenience.cc \
+  rocksdb/db/corruption_test.cc \
+  rocksdb/db/c_test.c \
   rocksdb/db/cuckoo_table_db_test.cc \
   rocksdb/db/db_bench.cc \
+  rocksdb/db/db_compaction_filter_test.cc \
+  rocksdb/db/db_compaction_test.cc \
+  rocksdb/db/db_dynamic_level_test.cc \
   rocksdb/db/db_filesnapshot.cc \
+  rocksdb/db/dbformat.cc \
+  rocksdb/db/dbformat.h \
+  rocksdb/db/dbformat_test.cc \
   rocksdb/db/db_impl.cc \
-  rocksdb/db/db_impl.h \
   rocksdb/db/db_impl_debug.cc \
+  rocksdb/db/db_impl_experimental.cc \
+  rocksdb/db/db_impl.h \
   rocksdb/db/db_impl_readonly.cc \
   rocksdb/db/db_impl_readonly.h \
+  rocksdb/db/db_inplace_update_test.cc \
   rocksdb/db/db_iter.cc \
+  rocksdb/db/db_iter.h \
   rocksdb/db/db_iter_test.cc \
   rocksdb/db/db_log_iter_test.cc \
-  rocksdb/db/dbformat.cc \
-  rocksdb/db/dbformat_test.cc \
-  rocksdb/db/deletefile_test.cc \
-  rocksdb/db/filename.cc \
-  rocksdb/db/log_reader.h \
-  rocksdb/db/file_indexer.h \
-  rocksdb/db/flush_job_test.cc \
-  rocksdb/db/plain_table_db_test.cc \
+  rocksdb/db/db_table_properties_test.cc \
+  rocksdb/db/db_tailing_iter_test.cc \
   rocksdb/db/db_test.cc \
-  rocksdb/db/db_iter.h \
+  rocksdb/db/db_test_util.cc \
+  rocksdb/db/db_test_util.h \
+  rocksdb/db/db_universal_compaction_test.cc \
+  rocksdb/db/db_wal_test.cc \
+  rocksdb/db/deletefile_test.cc \
+  rocksdb/db/event_helpers.cc \
+  rocksdb/db/event_helpers.h \
+  rocksdb/db/experimental.cc \
   rocksdb/db/fault_injection_test.cc \
-  rocksdb/db/filename.h \
-  rocksdb/db/forward_iterator.cc \
-  rocksdb/db/forward_iterator.h \
-  rocksdb/db/job_context.h \
-  rocksdb/db/compaction_job.h \
-  rocksdb/db/memtable.cc \
   rocksdb/db/file_indexer.cc \
-  rocksdb/db/flush_job.cc \
+  rocksdb/db/file_indexer.h \
   rocksdb/db/file_indexer_test.cc \
-  rocksdb/db/log_reader.cc \
-  rocksdb/db/table_cache.h \
+  rocksdb/db/filename.cc \
+  rocksdb/db/filename.h \
   rocksdb/db/filename_test.cc \
-  rocksdb/db/memtable_list_test.cc \
-  rocksdb/db/merge_helper.cc \
+  rocksdb/db/flush_job.cc \
+  rocksdb/db/flush_job.h \
+  rocksdb/db/flush_job_test.cc \
   rocksdb/db/flush_scheduler.cc \
   rocksdb/db/flush_scheduler.h \
+  rocksdb/db/forward_iterator_bench.cc \
+  rocksdb/db/forward_iterator.cc \
+  rocksdb/db/forward_iterator.h \
+  rocksdb/db/inlineskiplist.h \
+  rocksdb/db/inlineskiplist_test.cc \
+  rocksdb/db/internal_stats.cc \
   rocksdb/db/internal_stats.h \
+  rocksdb/db/job_context.h \
   rocksdb/db/listener_test.cc \
+  rocksdb/db/log_format.h \
+  rocksdb/db/log_reader.cc \
+  rocksdb/db/log_reader.h \
+  rocksdb/db/log_test.cc \
   rocksdb/db/log_writer.cc \
   rocksdb/db/log_writer.h \
-  rocksdb/db/merge_helper.h \
-  rocksdb/db/merge_operator.cc \
-  rocksdb/db/merge_test.cc \
-  rocksdb/db/version_set.h \
-  rocksdb/db/log_format.h \
-  rocksdb/db/memtable.h \
-  rocksdb/db/memtable_list.cc \
-  rocksdb/db/skiplist.h \
-  rocksdb/db/c_test.c \
+  rocksdb/db/managed_iterator.cc \
   rocksdb/db/managed_iterator.h \
-  rocksdb/db/wal_manager_test.cc \
+  rocksdb/db/manual_compaction_test.cc \
   rocksdb/db/memtable_allocator.cc \
   rocksdb/db/memtable_allocator.h \
+  rocksdb/db/memtable.cc \
+  rocksdb/db/memtable.h \
+  rocksdb/db/memtable_list.cc \
+  rocksdb/db/memtable_list.h \
+  rocksdb/db/memtable_list_test.cc \
   rocksdb/db/memtablerep_bench.cc \
-  rocksdb/db/repair.cc \
-  rocksdb/db/internal_stats.cc \
   rocksdb/db/merge_context.h \
-  rocksdb/db/managed_iterator.cc \
-  rocksdb/db/compacted_db_impl.h \
-  rocksdb/db/memtable_list.h \
+  rocksdb/db/merge_helper.cc \
+  rocksdb/db/merge_helper.h \
+  rocksdb/db/merge_helper_test.cc \
+  rocksdb/db/merge_operator.cc \
+  rocksdb/db/merge_test.cc \
+  rocksdb/db/options_file_test.cc \
   rocksdb/db/perf_context_test.cc \
-  rocksdb/db/table_cache.cc \
-  rocksdb/db/db_impl_experimental.cc \
+  rocksdb/db/plain_table_db_test.cc \
+  rocksdb/db/prefix_test.cc \
+  rocksdb/db/repair.cc \
+  rocksdb/db/skiplist.h \
   rocksdb/db/skiplist_test.cc \
   rocksdb/db/slice.cc \
+  rocksdb/db/snapshot_impl.cc \
+  rocksdb/db/snapshot_impl.h \
+  rocksdb/db/table_cache.cc \
+  rocksdb/db/table_cache.h \
   rocksdb/db/table_properties_collector.cc \
   rocksdb/db/table_properties_collector.h \
   rocksdb/db/table_properties_collector_test.cc \
@@ -117,155 +156,141 @@ EXTRA_DIST += \
   rocksdb/db/version_edit.h \
   rocksdb/db/version_edit_test.cc \
   rocksdb/db/version_set.cc \
+  rocksdb/db/version_set.h \
   rocksdb/db/version_set_test.cc \
   rocksdb/db/wal_manager.cc \
-  rocksdb/db/write_batch.cc \
-  rocksdb/db/write_batch_base.cc \
   rocksdb/db/wal_manager.h \
+  rocksdb/db/wal_manager_test.cc \
+  rocksdb/db/write_batch_base.cc \
+  rocksdb/db/write_batch.cc \
   rocksdb/db/write_batch_internal.h \
   rocksdb/db/write_batch_test.cc \
+  rocksdb/db/writebuffer.h \
   rocksdb/db/write_callback.h \
+  rocksdb/db/write_callback_test.cc \
   rocksdb/db/write_controller.cc \
   rocksdb/db/write_controller.h \
   rocksdb/db/write_controller_test.cc \
   rocksdb/db/write_thread.cc \
   rocksdb/db/write_thread.h \
-  rocksdb/db/builder.cc \
-  rocksdb/db/c.cc \
-  rocksdb/db/writebuffer.h \
-  rocksdb/db/compaction_iterator.h \
-  rocksdb/db/experimental.cc \
-  rocksdb/db/column_family.h \
-  rocksdb/db/column_family_test.cc \
-  rocksdb/db/compact_files_test.cc \
-  rocksdb/db/compaction.cc \
-  rocksdb/db/compaction.h \
-  rocksdb/db/compaction_job.cc \
-  rocksdb/db/compaction_job_test.cc \
-  rocksdb/db/compaction_picker.cc \
-  rocksdb/db/column_family.cc \
-  rocksdb/db/dbformat.h \
-  rocksdb/db/builder.h \
-  rocksdb/db/compacted_db_impl.cc \
-  rocksdb/db/flush_job.h \
-  rocksdb/db/log_test.cc \
-  rocksdb/db/prefix_test.cc \
-  rocksdb/db/corruption_test.cc \
-  rocksdb/db/db_compaction_test.cc \
-  rocksdb/db/compaction_iterator.cc \
-  rocksdb/db/compaction_iterator_test.cc \
-  rocksdb/db/compaction_job_stats_test.cc \
-  rocksdb/db/db_compaction_filter_test.cc \
-  rocksdb/db/db_dynamic_level_test.cc \
-  rocksdb/db/db_inplace_update_test.cc \
-  rocksdb/db/db_tailing_iter_test.cc \
-  rocksdb/db/db_universal_compaction_test.cc \
-  rocksdb/db/db_wal_test.cc \
-  rocksdb/db/event_helpers.cc \
-  rocksdb/db/event_helpers.h \
-  rocksdb/db/merge_helper_test.cc \
-  rocksdb/db/snapshot_impl.cc \
-  rocksdb/db/snapshot_impl.h \
-  rocksdb/db/write_callback_test.cc \
   rocksdb/doc/doc.css \
   rocksdb/doc/index.html \
   rocksdb/doc/log_format.txt \
   rocksdb/doc/rockslogo.jpg \
   rocksdb/doc/rockslogo.png \
-  rocksdb/examples/README.md \
+  rocksdb/DUMP_FORMAT.md \
   rocksdb/examples/column_families_example.cc \
-  rocksdb/examples/simple_example.cc \
-  rocksdb/examples/.gitignore \
-  rocksdb/examples/Makefile \
-  rocksdb/examples/c_simple_example.c \
   rocksdb/examples/compact_files_example.cc \
   rocksdb/examples/compaction_filter_example.cc \
+  rocksdb/examples/c_simple_example.c \
+  rocksdb/examples/.gitignore \
+  rocksdb/examples/Makefile \
   rocksdb/examples/optimistic_transaction_example.cc \
+  rocksdb/examples/options_file_example.cc \
+  rocksdb/examples/README.md \
   rocksdb/examples/rocksdb_option_file_example.ini \
+  rocksdb/examples/simple_example.cc \
   rocksdb/examples/transaction_example.cc \
+  rocksdb/.gitignore \
+  rocksdb/hdfs/env_hdfs.h \
   rocksdb/hdfs/README \
   rocksdb/hdfs/setup.sh \
-  rocksdb/hdfs/env_hdfs.h \
+  rocksdb/HISTORY.md \
+  rocksdb/include/rocksdb/cache.h \
+  rocksdb/include/rocksdb/c.h \
+  rocksdb/include/rocksdb/compaction_filter.h \
+  rocksdb/include/rocksdb/compaction_job_stats.h \
+  rocksdb/include/rocksdb/comparator.h \
+  rocksdb/include/rocksdb/convenience.h \
+  rocksdb/include/rocksdb/db_dump_tool.h \
+  rocksdb/include/rocksdb/db.h \
+  rocksdb/include/rocksdb/delete_scheduler.h \
+  rocksdb/include/rocksdb/env.h \
+  rocksdb/include/rocksdb/experimental.h \
   rocksdb/include/rocksdb/filter_policy.h \
   rocksdb/include/rocksdb/flush_block_policy.h \
+  rocksdb/include/rocksdb/immutable_options.h \
+  rocksdb/include/rocksdb/iostats_context.h \
   rocksdb/include/rocksdb/iterator.h \
   rocksdb/include/rocksdb/ldb_tool.h \
+  rocksdb/include/rocksdb/listener.h \
+  rocksdb/include/rocksdb/memtablerep.h \
+  rocksdb/include/rocksdb/merge_operator.h \
+  rocksdb/include/rocksdb/metadata.h \
+  rocksdb/include/rocksdb/options.h \
+  rocksdb/include/rocksdb/perf_context.h \
+  rocksdb/include/rocksdb/perf_level.h \
+  rocksdb/include/rocksdb/rate_limiter.h \
+  rocksdb/include/rocksdb/slice.h \
   rocksdb/include/rocksdb/slice_transform.h \
+  rocksdb/include/rocksdb/snapshot.h \
   rocksdb/include/rocksdb/sst_dump_tool.h \
+  rocksdb/include/rocksdb/sst_file_writer.h \
+  rocksdb/include/rocksdb/statistics.h \
+  rocksdb/include/rocksdb/status.h \
+  rocksdb/include/rocksdb/table.h \
+  rocksdb/include/rocksdb/table_properties.h \
+  rocksdb/include/rocksdb/thread_status.h \
+  rocksdb/include/rocksdb/transaction_log.h \
   rocksdb/include/rocksdb/types.h \
+  rocksdb/include/rocksdb/universal_compaction.h \
+  rocksdb/include/rocksdb/utilities/backupable_db.h \
+  rocksdb/include/rocksdb/utilities/checkpoint.h \
+  rocksdb/include/rocksdb/utilities/convenience.h \
   rocksdb/include/rocksdb/utilities/db_ttl.h \
   rocksdb/include/rocksdb/utilities/document_db.h \
+  rocksdb/include/rocksdb/utilities/env_mirror.h \
+  rocksdb/include/rocksdb/utilities/flashcache.h \
   rocksdb/include/rocksdb/utilities/geo_db.h \
+  rocksdb/include/rocksdb/utilities/info_log_finder.h \
   rocksdb/include/rocksdb/utilities/json_document.h \
   rocksdb/include/rocksdb/utilities/leveldb_options.h \
-  rocksdb/include/rocksdb/utilities/flashcache.h \
-  rocksdb/include/rocksdb/utilities/backupable_db.h \
-  rocksdb/include/rocksdb/utilities/checkpoint.h \
-  rocksdb/include/rocksdb/utilities/convenience.h \
-  rocksdb/include/rocksdb/utilities/info_log_finder.h \
+  rocksdb/include/rocksdb/utilities/memory_util.h \
   rocksdb/include/rocksdb/utilities/optimistic_transaction_db.h \
+  rocksdb/include/rocksdb/utilities/options_util.h \
   rocksdb/include/rocksdb/utilities/spatial_db.h \
   rocksdb/include/rocksdb/utilities/stackable_db.h \
   rocksdb/include/rocksdb/utilities/table_properties_collectors.h \
-  rocksdb/include/rocksdb/utilities/transaction.h \
   rocksdb/include/rocksdb/utilities/transaction_db.h \
   rocksdb/include/rocksdb/utilities/transaction_db_mutex.h \
+  rocksdb/include/rocksdb/utilities/transaction.h \
   rocksdb/include/rocksdb/utilities/utility_db.h \
   rocksdb/include/rocksdb/utilities/write_batch_with_index.h \
-  rocksdb/include/rocksdb/experimental.h \
-  rocksdb/include/rocksdb/convenience.h \
-  rocksdb/include/rocksdb/db_dump_tool.h \
-  rocksdb/include/rocksdb/immutable_options.h \
-  rocksdb/include/rocksdb/iostats_context.h \
-  rocksdb/include/rocksdb/listener.h \
-  rocksdb/include/rocksdb/memtablerep.h \
-  rocksdb/include/rocksdb/merge_operator.h \
-  rocksdb/include/rocksdb/metadata.h \
-  rocksdb/include/rocksdb/perf_context.h \
-  rocksdb/include/rocksdb/perf_level.h \
-  rocksdb/include/rocksdb/slice.h \
-  rocksdb/include/rocksdb/status.h \
-  rocksdb/include/rocksdb/table_properties.h \
-  rocksdb/include/rocksdb/transaction_log.h \
   rocksdb/include/rocksdb/version.h \
+  rocksdb/include/rocksdb/wal_filter.h \
   rocksdb/include/rocksdb/write_batch_base.h \
-  rocksdb/include/rocksdb/c.h \
-  rocksdb/include/rocksdb/compaction_filter.h \
-  rocksdb/include/rocksdb/comparator.h \
-  rocksdb/include/rocksdb/db.h \
-  rocksdb/include/rocksdb/env.h \
-  rocksdb/include/rocksdb/options.h \
-  rocksdb/include/rocksdb/rate_limiter.h \
-  rocksdb/include/rocksdb/snapshot.h \
-  rocksdb/include/rocksdb/statistics.h \
-  rocksdb/include/rocksdb/table.h \
-  rocksdb/include/rocksdb/thread_status.h \
-  rocksdb/include/rocksdb/universal_compaction.h \
   rocksdb/include/rocksdb/write_batch.h \
-  rocksdb/include/rocksdb/cache.h \
-  rocksdb/include/rocksdb/compaction_job_stats.h \
-  rocksdb/include/rocksdb/delete_scheduler.h \
-  rocksdb/include/rocksdb/sst_file_writer.h \
-  rocksdb/java/RELEASE.md \
+  rocksdb/INSTALL.md \
   rocksdb/java/benchmark/src/main/java/org/rocksdb/benchmark/DbBenchmark.java \
+  rocksdb/java/crossbuild/build-linux-centos.sh \
   rocksdb/java/crossbuild/build-linux.sh \
   rocksdb/java/crossbuild/Vagrantfile \
-  rocksdb/java/crossbuild/build-linux-centos.sh \
+  rocksdb/java/HISTORY-JAVA.md \
   rocksdb/java/jdb_bench.sh \
-  rocksdb/java/rocksjni.pom \
+  rocksdb/java/Makefile \
+  rocksdb/java/RELEASE.md \
   rocksdb/java/rocksjni/backupablejni.cc \
+  rocksdb/java/rocksjni/backupenginejni.cc \
   rocksdb/java/rocksjni/checkpoint.cc \
   rocksdb/java/rocksjni/columnfamilyhandle.cc \
+  rocksdb/java/rocksjni/compaction_filter.cc \
   rocksdb/java/rocksjni/comparator.cc \
+  rocksdb/java/rocksjni/comparatorjnicallback.cc \
   rocksdb/java/rocksjni/comparatorjnicallback.h \
   rocksdb/java/rocksjni/env.cc \
   rocksdb/java/rocksjni/filter.cc \
   rocksdb/java/rocksjni/iterator.cc \
+  rocksdb/java/rocksjni/loggerjnicallback.cc \
   rocksdb/java/rocksjni/loggerjnicallback.h \
   rocksdb/java/rocksjni/memtablejni.cc \
   rocksdb/java/rocksjni/merge_operator.cc \
+  rocksdb/java/rocksjni/options.cc \
+  rocksdb/java/rocksjni.pom \
+  rocksdb/java/rocksjni/portal.h \
   rocksdb/java/rocksjni/ratelimiterjni.cc \
+  rocksdb/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc \
   rocksdb/java/rocksjni/restorejni.cc \
+  rocksdb/java/rocksjni/rocksjni.cc \
   rocksdb/java/rocksjni/slice.cc \
   rocksdb/java/rocksjni/snapshot.cc \
   rocksdb/java/rocksjni/statistics.cc \
@@ -275,24 +300,19 @@ EXTRA_DIST += \
   rocksdb/java/rocksjni/write_batch.cc \
   rocksdb/java/rocksjni/writebatchhandlerjnicallback.cc \
   rocksdb/java/rocksjni/writebatchhandlerjnicallback.h \
-  rocksdb/java/rocksjni/backupenginejni.cc \
-  rocksdb/java/rocksjni/compaction_filter.cc \
-  rocksdb/java/rocksjni/comparatorjnicallback.cc \
-  rocksdb/java/rocksjni/loggerjnicallback.cc \
-  rocksdb/java/rocksjni/options.cc \
-  rocksdb/java/rocksjni/portal.h \
-  rocksdb/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc \
-  rocksdb/java/rocksjni/rocksjni.cc \
   rocksdb/java/rocksjni/write_batch_test.cc \
   rocksdb/java/rocksjni/write_batch_with_index.cc \
   rocksdb/java/samples/src/main/java/RocksDBColumnFamilySample.java \
   rocksdb/java/samples/src/main/java/RocksDBSample.java \
+  rocksdb/java/src/main/java/org/rocksdb/AbstractCompactionFilter.java \
   rocksdb/java/src/main/java/org/rocksdb/AbstractComparator.java \
   rocksdb/java/src/main/java/org/rocksdb/AbstractRocksIterator.java \
+  rocksdb/java/src/main/java/org/rocksdb/AbstractSlice.java \
   rocksdb/java/src/main/java/org/rocksdb/AbstractWriteBatch.java \
-  rocksdb/java/src/main/java/org/rocksdb/BackupInfo.java \
   rocksdb/java/src/main/java/org/rocksdb/BackupableDB.java \
   rocksdb/java/src/main/java/org/rocksdb/BackupableDBOptions.java \
+  rocksdb/java/src/main/java/org/rocksdb/BackupEngine.java \
+  rocksdb/java/src/main/java/org/rocksdb/BackupInfo.java \
   rocksdb/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java \
   rocksdb/java/src/main/java/org/rocksdb/BloomFilter.java \
   rocksdb/java/src/main/java/org/rocksdb/BuiltinComparator.java \
@@ -300,15 +320,18 @@ EXTRA_DIST += \
   rocksdb/java/src/main/java/org/rocksdb/ChecksumType.java \
   rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyDescriptor.java \
   rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyHandle.java \
+  rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java \
+  rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java \
   rocksdb/java/src/main/java/org/rocksdb/CompactionStyle.java \
   rocksdb/java/src/main/java/org/rocksdb/Comparator.java \
   rocksdb/java/src/main/java/org/rocksdb/ComparatorOptions.java \
   rocksdb/java/src/main/java/org/rocksdb/CompressionType.java \
-  rocksdb/java/src/main/java/org/rocksdb/DBOptions.java \
   rocksdb/java/src/main/java/org/rocksdb/DBOptionsInterface.java \
+  rocksdb/java/src/main/java/org/rocksdb/DBOptions.java \
   rocksdb/java/src/main/java/org/rocksdb/DirectComparator.java \
   rocksdb/java/src/main/java/org/rocksdb/DirectSlice.java \
   rocksdb/java/src/main/java/org/rocksdb/EncodingType.java \
+  rocksdb/java/src/main/java/org/rocksdb/Env.java \
   rocksdb/java/src/main/java/org/rocksdb/Filter.java \
   rocksdb/java/src/main/java/org/rocksdb/FlushOptions.java \
   rocksdb/java/src/main/java/org/rocksdb/GenericRateLimiterConfig.java \
@@ -322,51 +345,47 @@ EXTRA_DIST += \
   rocksdb/java/src/main/java/org/rocksdb/MemTableConfig.java \
   rocksdb/java/src/main/java/org/rocksdb/MergeOperator.java \
   rocksdb/java/src/main/java/org/rocksdb/NativeLibraryLoader.java \
+  rocksdb/java/src/main/java/org/rocksdb/Options.java \
   rocksdb/java/src/main/java/org/rocksdb/PlainTableConfig.java \
   rocksdb/java/src/main/java/org/rocksdb/RateLimiterConfig.java \
   rocksdb/java/src/main/java/org/rocksdb/ReadOptions.java \
+  rocksdb/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java \
   rocksdb/java/src/main/java/org/rocksdb/RestoreBackupableDB.java \
   rocksdb/java/src/main/java/org/rocksdb/RestoreOptions.java \
-  rocksdb/java/src/main/java/org/rocksdb/RocksDB.java \
   rocksdb/java/src/main/java/org/rocksdb/RocksDBException.java \
+  rocksdb/java/src/main/java/org/rocksdb/RocksDB.java \
   rocksdb/java/src/main/java/org/rocksdb/RocksEnv.java \
-  rocksdb/java/src/main/java/org/rocksdb/RocksIterator.java \
   rocksdb/java/src/main/java/org/rocksdb/RocksIteratorInterface.java \
+  rocksdb/java/src/main/java/org/rocksdb/RocksIterator.java \
+  rocksdb/java/src/main/java/org/rocksdb/RocksMemEnv.java \
   rocksdb/java/src/main/java/org/rocksdb/RocksObject.java \
   rocksdb/java/src/main/java/org/rocksdb/SkipListMemTableConfig.java \
   rocksdb/java/src/main/java/org/rocksdb/Slice.java \
   rocksdb/java/src/main/java/org/rocksdb/Snapshot.java \
-  rocksdb/java/src/main/java/org/rocksdb/Statistics.java \
-  rocksdb/java/src/main/java/org/rocksdb/StatisticsCollector.java \
   rocksdb/java/src/main/java/org/rocksdb/StatisticsCollectorCallback.java \
+  rocksdb/java/src/main/java/org/rocksdb/StatisticsCollector.java \
+  rocksdb/java/src/main/java/org/rocksdb/Statistics.java \
   rocksdb/java/src/main/java/org/rocksdb/StatsCollectorInput.java \
   rocksdb/java/src/main/java/org/rocksdb/StringAppendOperator.java \
   rocksdb/java/src/main/java/org/rocksdb/TableFormatConfig.java \
   rocksdb/java/src/main/java/org/rocksdb/TickerType.java \
   rocksdb/java/src/main/java/org/rocksdb/TransactionLogIterator.java \
   rocksdb/java/src/main/java/org/rocksdb/TtlDB.java \
+  rocksdb/java/src/main/java/org/rocksdb/util/Environment.java \
+  rocksdb/java/src/main/java/org/rocksdb/util/SizeUnit.java \
   rocksdb/java/src/main/java/org/rocksdb/VectorMemTableConfig.java \
-  rocksdb/java/src/main/java/org/rocksdb/WriteBatch.java \
+  rocksdb/java/src/main/java/org/rocksdb/WBWIRocksIterator.java \
   rocksdb/java/src/main/java/org/rocksdb/WriteBatchInterface.java \
+  rocksdb/java/src/main/java/org/rocksdb/WriteBatch.java \
   rocksdb/java/src/main/java/org/rocksdb/WriteBatchWithIndex.java \
   rocksdb/java/src/main/java/org/rocksdb/WriteOptions.java \
-  rocksdb/java/src/main/java/org/rocksdb/util/Environment.java \
-  rocksdb/java/src/main/java/org/rocksdb/util/SizeUnit.java \
-  rocksdb/java/src/main/java/org/rocksdb/Env.java \
-  rocksdb/java/src/main/java/org/rocksdb/RocksMemEnv.java \
-  rocksdb/java/src/main/java/org/rocksdb/AbstractCompactionFilter.java \
-  rocksdb/java/src/main/java/org/rocksdb/AbstractSlice.java \
-  rocksdb/java/src/main/java/org/rocksdb/BackupEngine.java \
-  rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java \
-  rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java \
-  rocksdb/java/src/main/java/org/rocksdb/Options.java \
-  rocksdb/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java \
-  rocksdb/java/src/main/java/org/rocksdb/WBWIRocksIterator.java \
   rocksdb/java/src/test/java/org/rocksdb/AbstractComparatorTest.java \
   rocksdb/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java \
   rocksdb/java/src/test/java/org/rocksdb/BackupableDBTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/BackupEngineTest.java \
   rocksdb/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java \
   rocksdb/java/src/test/java/org/rocksdb/CheckPointTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java \
   rocksdb/java/src/test/java/org/rocksdb/ColumnFamilyTest.java \
   rocksdb/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java \
   rocksdb/java/src/test/java/org/rocksdb/ComparatorTest.java \
@@ -376,50 +395,56 @@ EXTRA_DIST += \
   rocksdb/java/src/test/java/org/rocksdb/DirectSliceTest.java \
   rocksdb/java/src/test/java/org/rocksdb/FilterTest.java \
   rocksdb/java/src/test/java/org/rocksdb/FlushTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/InfoLogLevelTest.java \
   rocksdb/java/src/test/java/org/rocksdb/KeyMayExistTest.java \
   rocksdb/java/src/test/java/org/rocksdb/LoggerTest.java \
   rocksdb/java/src/test/java/org/rocksdb/MemTableTest.java \
   rocksdb/java/src/test/java/org/rocksdb/MergeTest.java \
   rocksdb/java/src/test/java/org/rocksdb/MixedOptionsTest.java \
   rocksdb/java/src/test/java/org/rocksdb/NativeLibraryLoaderTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/OptionsTest.java \
   rocksdb/java/src/test/java/org/rocksdb/PlainTableConfigTest.java \
   rocksdb/java/src/test/java/org/rocksdb/PlatformRandomHelper.java \
   rocksdb/java/src/test/java/org/rocksdb/ReadOnlyTest.java \
   rocksdb/java/src/test/java/org/rocksdb/ReadOptionsTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/RocksDBTest.java \
   rocksdb/java/src/test/java/org/rocksdb/RocksEnvTest.java \
   rocksdb/java/src/test/java/org/rocksdb/RocksIteratorTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/RocksMemEnvTest.java \
   rocksdb/java/src/test/java/org/rocksdb/RocksMemoryResource.java \
+  rocksdb/java/src/test/java/org/rocksdb/SliceTest.java \
   rocksdb/java/src/test/java/org/rocksdb/SnapshotTest.java \
   rocksdb/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java \
   rocksdb/java/src/test/java/org/rocksdb/StatsCallbackMock.java \
+  rocksdb/java/src/test/java/org/rocksdb/test/RocksJunitRunner.java \
   rocksdb/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/TtlDBTest.java \
   rocksdb/java/src/test/java/org/rocksdb/Types.java \
-  rocksdb/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/WriteBatchTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/WriteOptionsTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/test/RocksJunitRunner.java \
   rocksdb/java/src/test/java/org/rocksdb/util/EnvironmentTest.java \
   rocksdb/java/src/test/java/org/rocksdb/util/SizeUnitTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/RocksMemEnvTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/SliceTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/TtlDBTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java \
+  rocksdb/java/src/test/java/org/rocksdb/WriteBatchTest.java \
   rocksdb/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/BackupEngineTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/InfoLogLevelTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/OptionsTest.java \
-  rocksdb/java/src/test/java/org/rocksdb/RocksDBTest.java \
-  rocksdb/java/HISTORY-JAVA.md \
-  rocksdb/java/Makefile \
-  rocksdb/port/stack_trace.cc \
-  rocksdb/port/README \
+  rocksdb/java/src/test/java/org/rocksdb/WriteOptionsTest.java \
+  rocksdb/LICENSE \
+  rocksdb/Makefile \
+  rocksdb/memtable/hash_cuckoo_rep.cc \
+  rocksdb/memtable/hash_cuckoo_rep.h \
+  rocksdb/memtable/hash_linklist_rep.cc \
+  rocksdb/memtable/hash_linklist_rep.h \
+  rocksdb/memtable/hash_skiplist_rep.cc \
+  rocksdb/memtable/hash_skiplist_rep.h \
+  rocksdb/memtable/stl_wrappers.h \
+  rocksdb/PATENTS \
+  rocksdb/port/dirent.h \
   rocksdb/port/likely.h \
   rocksdb/port/port_example.h \
-  rocksdb/port/stack_trace.h \
-  rocksdb/port/dirent.h \
   rocksdb/port/port.h \
   rocksdb/port/port_posix.cc \
   rocksdb/port/port_posix.h \
+  rocksdb/port/README \
+  rocksdb/port/stack_trace.cc \
+  rocksdb/port/stack_trace.h \
   rocksdb/port/sys_time.h \
   rocksdb/port/util_logger.h \
   rocksdb/port/win/env_win.cc \
@@ -427,54 +452,32 @@ EXTRA_DIST += \
   rocksdb/port/win/port_win.h \
   rocksdb/port/win/win_logger.cc \
   rocksdb/port/win/win_logger.h \
+  rocksdb/README.md \
+  rocksdb/ROCKSDB_LITE.md \
+  rocksdb/src.mk \
+  rocksdb/table/adaptive_table_factory.cc \
+  rocksdb/table/adaptive_table_factory.h \
   rocksdb/table/block_based_filter_block.cc \
-  rocksdb/table/mock_table.cc \
-  rocksdb/table/plain_table_builder.cc \
-  rocksdb/table/plain_table_factory.cc \
-  rocksdb/table/plain_table_key_coding.h \
-  rocksdb/table/table_builder.h \
-  rocksdb/table/two_level_iterator.cc \
-  rocksdb/table/two_level_iterator.h \
-  rocksdb/table/full_filter_block.cc \
   rocksdb/table/block_based_filter_block.h \
   rocksdb/table/block_based_filter_block_test.cc \
-  rocksdb/table/block.cc \
-  rocksdb/table/block_builder.cc \
-  rocksdb/table/block_builder.h \
-  rocksdb/table/block_hash_index.h \
-  rocksdb/table/block_hash_index_test.cc \
-  rocksdb/table/block_prefix_index.cc \
-  rocksdb/table/block_test.cc \
-  rocksdb/table/bloom_block.cc \
-  rocksdb/table/bloom_block.h \
-  rocksdb/table/table_reader_bench.cc \
-  rocksdb/table/table_test.cc \
-  rocksdb/table/meta_blocks.h \
-  rocksdb/table/plain_table_factory.h \
-  rocksdb/table/filter_block.h \
-  rocksdb/table/flush_block_policy.cc \
-  rocksdb/table/get_context.cc \
-  rocksdb/table/get_context.h \
-  rocksdb/table/sst_file_writer.cc \
-  rocksdb/table/full_filter_block.h \
-  rocksdb/table/full_filter_block_test.cc \
-  rocksdb/table/merger.cc \
-  rocksdb/table/iterator.cc \
-  rocksdb/table/iterator_wrapper.h \
-  rocksdb/table/merger.h \
-  rocksdb/table/block.h \
-  rocksdb/table/plain_table_index.h \
-  rocksdb/table/plain_table_key_coding.cc \
-  rocksdb/table/table_properties_internal.h \
-  rocksdb/table/table_reader.h \
   rocksdb/table/block_based_table_builder.cc \
   rocksdb/table/block_based_table_builder.h \
   rocksdb/table/block_based_table_factory.cc \
   rocksdb/table/block_based_table_factory.h \
   rocksdb/table/block_based_table_reader.cc \
   rocksdb/table/block_based_table_reader.h \
+  rocksdb/table/block_builder.cc \
+  rocksdb/table/block_builder.h \
+  rocksdb/table/block.cc \
+  rocksdb/table/block.h \
   rocksdb/table/block_hash_index.cc \
+  rocksdb/table/block_hash_index.h \
+  rocksdb/table/block_hash_index_test.cc \
+  rocksdb/table/block_prefix_index.cc \
   rocksdb/table/block_prefix_index.h \
+  rocksdb/table/block_test.cc \
+  rocksdb/table/bloom_block.cc \
+  rocksdb/table/bloom_block.h \
   rocksdb/table/cuckoo_table_builder.cc \
   rocksdb/table/cuckoo_table_builder.h \
   rocksdb/table/cuckoo_table_builder_test.cc \
@@ -483,272 +486,295 @@ EXTRA_DIST += \
   rocksdb/table/cuckoo_table_reader.cc \
   rocksdb/table/cuckoo_table_reader.h \
   rocksdb/table/cuckoo_table_reader_test.cc \
+  rocksdb/table/filter_block.h \
+  rocksdb/table/flush_block_policy.cc \
   rocksdb/table/format.cc \
   rocksdb/table/format.h \
+  rocksdb/table/full_filter_block.cc \
+  rocksdb/table/full_filter_block.h \
+  rocksdb/table/full_filter_block_test.cc \
+  rocksdb/table/get_context.cc \
+  rocksdb/table/get_context.h \
+  rocksdb/table/internal_iterator.h \
+  rocksdb/table/iterator.cc \
+  rocksdb/table/iterator_wrapper.h \
   rocksdb/table/iter_heap.h \
+  rocksdb/table/merger.cc \
+  rocksdb/table/merger.h \
   rocksdb/table/merger_test.cc \
   rocksdb/table/meta_blocks.cc \
+  rocksdb/table/meta_blocks.h \
+  rocksdb/table/mock_table.cc \
   rocksdb/table/mock_table.h \
+  rocksdb/table/plain_table_builder.cc \
   rocksdb/table/plain_table_builder.h \
+  rocksdb/table/plain_table_factory.cc \
+  rocksdb/table/plain_table_factory.h \
   rocksdb/table/plain_table_index.cc \
+  rocksdb/table/plain_table_index.h \
+  rocksdb/table/plain_table_key_coding.cc \
+  rocksdb/table/plain_table_key_coding.h \
   rocksdb/table/plain_table_reader.cc \
   rocksdb/table/plain_table_reader.h \
+  rocksdb/table/scoped_arena_iterator.h \
+  rocksdb/table/sst_file_writer.cc \
+  rocksdb/table/table_builder.h \
   rocksdb/table/table_properties.cc \
-  rocksdb/table/adaptive_table_factory.h \
-  rocksdb/table/adaptive_table_factory.cc \
-  rocksdb/third-party/fbson/FbsonJsonParser.h \
-  rocksdb/third-party/fbson/FbsonUtil.h \
-  rocksdb/third-party/fbson/FbsonWriter.h \
+  rocksdb/table/table_properties_internal.h \
+  rocksdb/table/table_reader_bench.cc \
+  rocksdb/table/table_reader.h \
+  rocksdb/table/table_test.cc \
+  rocksdb/table/two_level_iterator.cc \
+  rocksdb/table/two_level_iterator.h \
   rocksdb/third-party/fbson/COMMIT.md \
   rocksdb/third-party/fbson/FbsonDocument.h \
+  rocksdb/third-party/fbson/FbsonJsonParser.h \
   rocksdb/third-party/fbson/FbsonStream.h \
+  rocksdb/third-party/fbson/FbsonUtil.h \
+  rocksdb/third-party/fbson/FbsonWriter.h \
+  rocksdb/third-party/flashcache/flashcache_ioctl.h \
+  rocksdb/third-party/gtest-1.7.0/fused-src/gtest/CMakeLists.txt \
   rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc \
   rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest.h \
-  rocksdb/third-party/gtest-1.7.0/fused-src/gtest/CMakeLists.txt \
-  rocksdb/third-party/flashcache/flashcache_ioctl.h \
+  rocksdb/thirdparty.inc \
   rocksdb/tools/auto_sanity_test.sh \
   rocksdb/tools/benchmark_leveldb.sh \
-  rocksdb/tools/check_format_compatible.sh \
-  rocksdb/tools/generate_random_db.sh \
-  rocksdb/tools/run_leveldb.sh \
-  rocksdb/tools/verify_random_db.sh \
-  rocksdb/tools/dbench_monitor \
-  rocksdb/tools/ldb.cc \
-  rocksdb/tools/pflag \
-  rocksdb/tools/sst_dump.cc \
-  rocksdb/tools/dump/db_dump_tool.cc \
-  rocksdb/tools/dump/rocksdb_dump.cc \
-  rocksdb/tools/dump/rocksdb_undump.cc \
-  rocksdb/tools/Dockerfile \
   rocksdb/tools/benchmark.sh \
+  rocksdb/tools/check_format_compatible.sh \
   rocksdb/tools/db_crashtest.py \
-  rocksdb/tools/db_crashtest2.py \
+  rocksdb/tools/dbench_monitor \
   rocksdb/tools/db_repl_stress.cc \
   rocksdb/tools/db_sanity_test.cc \
   rocksdb/tools/db_stress.cc \
+  rocksdb/tools/Dockerfile \
+  rocksdb/tools/dump/db_dump_tool.cc \
+  rocksdb/tools/dump/rocksdb_dump.cc \
+  rocksdb/tools/dump/rocksdb_undump.cc \
+  rocksdb/tools/generate_random_db.sh \
+  rocksdb/tools/ldb.cc \
+  rocksdb/tools/ldb_cmd.cc \
+  rocksdb/tools/ldb_cmd_execute_result.h \
+  rocksdb/tools/ldb_cmd.h \
+  rocksdb/tools/ldb_cmd_test.cc \
   rocksdb/tools/ldb_test.py \
+  rocksdb/tools/ldb_tool.cc \
+  rocksdb/tools/pflag \
   rocksdb/tools/reduce_levels_test.cc \
   rocksdb/tools/rocksdb_dump_test.sh \
   rocksdb/tools/run_flash_bench.sh \
+  rocksdb/tools/run_leveldb.sh \
   rocksdb/tools/sample-dump.dmp \
-  rocksdb/util/ldb_cmd_execute_result.h \
-  rocksdb/util/bloom.cc \
+  rocksdb/tools/sst_dump.cc \
+  rocksdb/tools/sst_dump_test.cc \
+  rocksdb/tools/sst_dump_tool.cc \
+  rocksdb/tools/sst_dump_tool_imp.h \
+  rocksdb/tools/verify_random_db.sh \
+  rocksdb/tools/write_stress.cc \
+  rocksdb/tools/write_stress_runner.py \
+  rocksdb/.travis.yml \
+  rocksdb/USERS.md \
+  rocksdb/util/aligned_buffer.h \
   rocksdb/util/allocator.h \
-  rocksdb/util/crc32c.h \
-  rocksdb/util/db_info_dumper.cc \
-  rocksdb/util/dynamic_bloom.h \
-  rocksdb/util/env_hdfs.cc \
-  rocksdb/util/env_posix.cc \
-  rocksdb/util/env_test.cc \
-  rocksdb/util/event_logger.cc \
-  rocksdb/util/file_util.cc \
-  rocksdb/util/file_util.h \
-  rocksdb/util/heap.h \
-  rocksdb/util/ldb_cmd.h \
-  rocksdb/util/mutable_cf_options.h \
+  rocksdb/util/arena.cc \
+  rocksdb/util/arena.h \
+  rocksdb/util/arena_test.cc \
+  rocksdb/util/auto_roll_logger.cc \
+  rocksdb/util/auto_roll_logger.h \
+  rocksdb/util/auto_roll_logger_test.cc \
+  rocksdb/util/autovector.h \
+  rocksdb/util/autovector_test.cc \
+  rocksdb/util/bloom.cc \
+  rocksdb/util/bloom_test.cc \
   rocksdb/util/build_version.h \
-  rocksdb/util/env.cc \
   rocksdb/util/cache_bench.cc \
-  rocksdb/util/options.cc \
+  rocksdb/util/cache.cc \
+  rocksdb/util/cache_test.cc \
+  rocksdb/util/channel.h \
   rocksdb/util/coding.cc \
   rocksdb/util/coding.h \
   rocksdb/util/coding_test.cc \
-  rocksdb/util/event_logger.h \
-  rocksdb/util/log_buffer.cc \
-  rocksdb/util/log_buffer.h \
-  rocksdb/util/memenv.cc \
+  rocksdb/util/compaction_job_stats_impl.cc \
+  rocksdb/util/comparator.cc \
+  rocksdb/util/compression.h \
+  rocksdb/util/crc32c.cc \
+  rocksdb/util/crc32c.h \
   rocksdb/util/crc32c_test.cc \
-  rocksdb/util/options_helper.cc \
+  rocksdb/util/db_info_dumper.cc \
   rocksdb/util/db_info_dumper.h \
+  rocksdb/util/delete_scheduler_impl.cc \
+  rocksdb/util/delete_scheduler_impl.h \
+  rocksdb/util/delete_scheduler_test.cc \
   rocksdb/util/dynamic_bloom.cc \
-  rocksdb/util/hash_cuckoo_rep.cc \
-  rocksdb/util/options_helper.h \
-  rocksdb/util/histogram.cc \
-  rocksdb/util/histogram_test.cc \
-  rocksdb/util/mock_env.cc \
-  rocksdb/util/logging.cc \
-  rocksdb/util/logging.h \
-  rocksdb/util/statistics.cc \
+  rocksdb/util/dynamic_bloom.h \
+  rocksdb/util/dynamic_bloom_test.cc \
+  rocksdb/util/env.cc \
+  rocksdb/util/env_hdfs.cc \
+  rocksdb/util/env_posix.cc \
+  rocksdb/util/env_test.cc \
+  rocksdb/util/event_logger.cc \
+  rocksdb/util/event_logger.h \
   rocksdb/util/event_logger_test.cc \
-  rocksdb/util/perf_level.cc \
-  rocksdb/util/status.cc \
   rocksdb/util/filelock_test.cc \
+  rocksdb/util/file_reader_writer.cc \
+  rocksdb/util/file_reader_writer.h \
+  rocksdb/util/file_reader_writer_test.cc \
+  rocksdb/util/file_util.cc \
+  rocksdb/util/file_util.h \
   rocksdb/util/filter_policy.cc \
   rocksdb/util/hash.cc \
   rocksdb/util/hash.h \
-  rocksdb/util/arena.h \
-  rocksdb/util/hash_cuckoo_rep.h \
-  rocksdb/util/perf_context_imp.h \
-  rocksdb/util/hash_linklist_rep.h \
-  rocksdb/util/hash_skiplist_rep.cc \
-  rocksdb/util/hash_skiplist_rep.h \
-  rocksdb/util/mock_env_test.cc \
-  rocksdb/util/mutable_cf_options.cc \
-  rocksdb/util/instrumented_mutex.cc \
-  rocksdb/util/instrumented_mutex.h \
-  rocksdb/util/ldb_cmd.cc \
-  rocksdb/util/autovector.h \
-  rocksdb/util/skiplistrep.cc \
-  rocksdb/util/manual_compaction_test.cc \
-  rocksdb/util/sync_point.cc \
-  rocksdb/util/ldb_tool.cc \
-  rocksdb/util/statistics.h \
-  rocksdb/util/xfunc.cc \
-  rocksdb/util/log_write_bench.cc \
-  rocksdb/util/xfunc.h \
-  rocksdb/util/memenv_test.cc \
-  rocksdb/util/mock_env.h \
-  rocksdb/util/options_test.cc \
-  rocksdb/util/perf_context.cc \
-  rocksdb/util/posix_logger.h \
-  rocksdb/util/rate_limiter.cc \
-  rocksdb/util/rate_limiter.h \
-  rocksdb/util/murmurhash.cc \
-  rocksdb/util/murmurhash.h \
-  rocksdb/util/sst_dump_test.cc \
-  rocksdb/util/sst_dump_tool.cc \
-  rocksdb/util/mutexlock.h \
-  rocksdb/util/sst_dump_tool_imp.h \
-  rocksdb/util/options_builder.cc \
-  rocksdb/util/testutil.cc \
-  rocksdb/util/thread_local.cc \
-  rocksdb/util/thread_operation.h \
-  rocksdb/util/thread_status_impl.cc \
-  rocksdb/util/arena_test.cc \
-  rocksdb/util/random.h \
-  rocksdb/util/slice.cc \
-  rocksdb/util/thread_status_util.cc \
-  rocksdb/util/rate_limiter_test.cc \
-  rocksdb/util/scoped_arena_iterator.h \
-  rocksdb/util/thread_status_util.h \
-  rocksdb/util/channel.h \
-  rocksdb/util/slice_transform_test.cc \
-  rocksdb/util/thread_status_updater.cc \
-  rocksdb/util/thread_status_updater.h \
-  rocksdb/util/stl_wrappers.h \
-  rocksdb/util/stop_watch.h \
-  rocksdb/util/sync_point.h \
-  rocksdb/util/compression.h \
-  rocksdb/util/string_util.h \
-  rocksdb/util/string_util.cc \
-  rocksdb/util/vectorrep.cc \
-  rocksdb/util/thread_status_util_debug.cc \
-  rocksdb/util/testharness.cc \
-  rocksdb/util/testharness.h \
+  rocksdb/util/heap.h \
   rocksdb/util/heap_test.cc \
-  rocksdb/util/thread_list_test.cc \
-  rocksdb/util/thread_local.h \
-  rocksdb/util/thread_local_test.cc \
+  rocksdb/util/histogram.cc \
   rocksdb/util/histogram.h \
-  rocksdb/util/cache_test.cc \
-  rocksdb/util/thread_status_updater_debug.cc \
-  rocksdb/util/xxhash.cc \
-  rocksdb/util/xxhash.h \
-  rocksdb/util/auto_roll_logger.cc \
-  rocksdb/util/auto_roll_logger.h \
-  rocksdb/util/auto_roll_logger_test.cc \
-  rocksdb/util/autovector_test.cc \
-  rocksdb/util/bloom_test.cc \
-  rocksdb/util/cache.cc \
-  rocksdb/util/comparator.cc \
-  rocksdb/util/crc32c.cc \
-  rocksdb/util/dynamic_bloom_test.cc \
+  rocksdb/util/histogram_test.cc \
+  rocksdb/util/instrumented_mutex.cc \
+  rocksdb/util/instrumented_mutex.h \
+  rocksdb/util/io_posix.cc \
+  rocksdb/util/io_posix.h \
   rocksdb/util/iostats_context.cc \
   rocksdb/util/iostats_context_imp.h \
-  rocksdb/util/hash_linklist_rep.cc \
-  rocksdb/util/testutil.h \
-  rocksdb/util/arena.cc \
-  rocksdb/util/aligned_buffer.h \
-  rocksdb/util/db_test_util.cc \
-  rocksdb/util/delete_scheduler_impl.h \
-  rocksdb/util/file_reader_writer.h \
-  rocksdb/util/options_parser.cc \
-  rocksdb/util/perf_step_timer.h \
-  rocksdb/util/db_test_util.h \
-  rocksdb/util/delete_scheduler_test.cc \
-  rocksdb/util/file_reader_writer_test.cc \
-  rocksdb/util/options_parser.h \
-  rocksdb/util/status_message.cc \
-  rocksdb/util/compaction_job_stats_impl.cc \
-  rocksdb/util/delete_scheduler_impl.cc \
-  rocksdb/util/file_reader_writer.cc \
-  rocksdb/util/ldb_cmd_test.cc \
-  rocksdb/util/perf_level_imp.h \
   rocksdb/utilities/backupable/backupable_db.cc \
   rocksdb/utilities/backupable/backupable_db_test.cc \
+  rocksdb/utilities/backupable/backupable_db_testutil.h \
   rocksdb/utilities/checkpoint/checkpoint.cc \
   rocksdb/utilities/checkpoint/checkpoint_test.cc \
+  rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc \
+  rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.h \
+  rocksdb/utilities/convenience/info_log_finder.cc \
   rocksdb/utilities/document/document_db.cc \
-  rocksdb/utilities/document/json_document_builder.cc \
   rocksdb/utilities/document/document_db_test.cc \
+  rocksdb/utilities/document/json_document_builder.cc \
   rocksdb/utilities/document/json_document.cc \
   rocksdb/utilities/document/json_document_test.cc \
+  rocksdb/utilities/env_mirror.cc \
+  rocksdb/utilities/env_mirror_test.cc \
+  rocksdb/utilities/flashcache/flashcache.cc \
+  rocksdb/utilities/flashcache/flashcache.h \
   rocksdb/utilities/geodb/geodb_impl.cc \
   rocksdb/utilities/geodb/geodb_impl.h \
   rocksdb/utilities/geodb/geodb_test.cc \
   rocksdb/utilities/leveldb_options/leveldb_options.cc \
+  rocksdb/utilities/memory/memory_test.cc \
+  rocksdb/utilities/memory/memory_util.cc \
   rocksdb/utilities/merge_operators.h \
   rocksdb/utilities/merge_operators/put.cc \
+  rocksdb/utilities/merge_operators/string_append/stringappend2.cc \
+  rocksdb/utilities/merge_operators/string_append/stringappend2.h \
   rocksdb/utilities/merge_operators/string_append/stringappend.cc \
   rocksdb/utilities/merge_operators/string_append/stringappend.h \
-  rocksdb/utilities/merge_operators/string_append/stringappend2.h \
-  rocksdb/utilities/merge_operators/string_append/stringappend2.cc \
   rocksdb/utilities/merge_operators/string_append/stringappend_test.cc \
   rocksdb/utilities/merge_operators/uint64add.cc \
+  rocksdb/utilities/options/options_util.cc \
+  rocksdb/utilities/options/options_util_test.cc \
   rocksdb/utilities/redis/README \
   rocksdb/utilities/redis/redis_list_exception.h \
   rocksdb/utilities/redis/redis_list_iterator.h \
   rocksdb/utilities/redis/redis_lists.cc \
   rocksdb/utilities/redis/redis_lists.h \
   rocksdb/utilities/redis/redis_lists_test.cc \
-  rocksdb/utilities/spatialdb/utils.h \
   rocksdb/utilities/spatialdb/spatial_db.cc \
   rocksdb/utilities/spatialdb/spatial_db_test.cc \
-  rocksdb/utilities/ttl/db_ttl_impl.cc \
-  rocksdb/utilities/ttl/db_ttl_impl.h \
-  rocksdb/utilities/ttl/ttl_test.cc \
-  rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc \
-  rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc \
-  rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h \
-  rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc \
-  rocksdb/utilities/flashcache/flashcache.cc \
-  rocksdb/utilities/flashcache/flashcache.h \
-  rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc \
-  rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.h \
-  rocksdb/utilities/convenience/info_log_finder.cc \
+  rocksdb/utilities/spatialdb/utils.h \
   rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc \
   rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h \
   rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc \
   rocksdb/utilities/transactions/optimistic_transaction_db_impl.cc \
   rocksdb/utilities/transactions/optimistic_transaction_db_impl.h \
   rocksdb/utilities/transactions/optimistic_transaction_impl.cc \
-  rocksdb/utilities/transactions/optimistic_transaction_test.cc \
-  rocksdb/utilities/transactions/transaction_base.h \
-  rocksdb/utilities/transactions/transaction_db_impl.h \
-  rocksdb/utilities/transactions/transaction_db_mutex_impl.h \
-  rocksdb/utilities/transactions/transaction_impl.h \
-  rocksdb/utilities/transactions/transaction_lock_mgr.h \
-  rocksdb/utilities/transactions/transaction_util.cc \
   rocksdb/utilities/transactions/optimistic_transaction_impl.h \
+  rocksdb/utilities/transactions/optimistic_transaction_test.cc \
   rocksdb/utilities/transactions/transaction_base.cc \
+  rocksdb/utilities/transactions/transaction_base.h \
   rocksdb/utilities/transactions/transaction_db_impl.cc \
+  rocksdb/utilities/transactions/transaction_db_impl.h \
   rocksdb/utilities/transactions/transaction_db_mutex_impl.cc \
+  rocksdb/utilities/transactions/transaction_db_mutex_impl.h \
   rocksdb/utilities/transactions/transaction_impl.cc \
+  rocksdb/utilities/transactions/transaction_impl.h \
   rocksdb/utilities/transactions/transaction_lock_mgr.cc \
+  rocksdb/utilities/transactions/transaction_lock_mgr.h \
   rocksdb/utilities/transactions/transaction_test.cc \
+  rocksdb/utilities/transactions/transaction_util.cc \
   rocksdb/utilities/transactions/transaction_util.h \
-  rocksdb/.gitignore \
-  rocksdb/CMakeLists.txt \
-  rocksdb/HISTORY.md \
-  rocksdb/Makefile \
-  rocksdb/USERS.md \
-  rocksdb/appveyor.yml \
-  rocksdb/src.mk \
-  rocksdb/thirdparty.inc \
-  rocksdb/.travis.yml \
-  rocksdb/DUMP_FORMAT.md \
-  rocksdb/INSTALL.md \
-  rocksdb/ROCKSDB_LITE.md \
+  rocksdb/utilities/ttl/db_ttl_impl.cc \
+  rocksdb/utilities/ttl/db_ttl_impl.h \
+  rocksdb/utilities/ttl/ttl_test.cc \
+  rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc \
+  rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc \
+  rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h \
+  rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc \
+  rocksdb/util/kv_map.h \
+  rocksdb/util/log_buffer.cc \
+  rocksdb/util/log_buffer.h \
+  rocksdb/util/logging.cc \
+  rocksdb/util/logging.h \
+  rocksdb/util/log_write_bench.cc \
+  rocksdb/util/memenv.cc \
+  rocksdb/util/memenv_test.cc \
+  rocksdb/util/mock_env.cc \
+  rocksdb/util/mock_env.h \
+  rocksdb/util/mock_env_test.cc \
+  rocksdb/util/murmurhash.cc \
+  rocksdb/util/murmurhash.h \
+  rocksdb/util/mutable_cf_options.cc \
+  rocksdb/util/mutable_cf_options.h \
+  rocksdb/util/mutexlock.h \
+  rocksdb/util/options_builder.cc \
+  rocksdb/util/options.cc \
+  rocksdb/util/options_helper.cc \
+  rocksdb/util/options_helper.h \
+  rocksdb/util/options_parser.cc \
+  rocksdb/util/options_parser.h \
+  rocksdb/util/options_sanity_check.cc \
+  rocksdb/util/options_sanity_check.h \
+  rocksdb/util/options_test.cc \
+  rocksdb/util/perf_context.cc \
+  rocksdb/util/perf_context_imp.h \
+  rocksdb/util/perf_level.cc \
+  rocksdb/util/perf_level_imp.h \
+  rocksdb/util/perf_step_timer.h \
+  rocksdb/util/posix_logger.h \
+  rocksdb/util/random.cc \
+  rocksdb/util/random.h \
+  rocksdb/util/rate_limiter.cc \
+  rocksdb/util/rate_limiter.h \
+  rocksdb/util/rate_limiter_test.cc \
+  rocksdb/util/skiplistrep.cc \
+  rocksdb/util/slice.cc \
+  rocksdb/util/slice_transform_test.cc \
+  rocksdb/util/statistics.cc \
+  rocksdb/util/statistics.h \
+  rocksdb/util/status.cc \
+  rocksdb/util/status_message.cc \
+  rocksdb/util/stop_watch.h \
+  rocksdb/util/string_util.cc \
+  rocksdb/util/string_util.h \
+  rocksdb/util/sync_point.cc \
+  rocksdb/util/sync_point.h \
+  rocksdb/util/testharness.cc \
+  rocksdb/util/testharness.h \
+  rocksdb/util/testutil.cc \
+  rocksdb/util/testutil.h \
+  rocksdb/util/thread_list_test.cc \
+  rocksdb/util/thread_local.cc \
+  rocksdb/util/thread_local.h \
+  rocksdb/util/thread_local_test.cc \
+  rocksdb/util/thread_operation.h \
+  rocksdb/util/thread_posix.cc \
+  rocksdb/util/thread_posix.h \
+  rocksdb/util/thread_status_impl.cc \
+  rocksdb/util/thread_status_updater.cc \
+  rocksdb/util/thread_status_updater_debug.cc \
+  rocksdb/util/thread_status_updater.h \
+  rocksdb/util/thread_status_util.cc \
+  rocksdb/util/thread_status_util_debug.cc \
+  rocksdb/util/thread_status_util.h \
+  rocksdb/util/vectorrep.cc \
+  rocksdb/util/xfunc.cc \
+  rocksdb/util/xfunc.h \
+  rocksdb/util/xxhash.cc \
+  rocksdb/util/xxhash.h \
+  rocksdb/Vagrantfile \
   rocksdb/WINDOWS_PORT.md \
-  rocksdb/appveyordailytests.yml \
   rocksdb/AUTHORS
diff --git a/src/Makefile.am b/src/Makefile.am
index cd24915..1b651c1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,7 @@ include mds/Makefile.am
 include os/Makefile.am
 include osd/Makefile.am
 include erasure-code/Makefile.am
+include compressor/Makefile.am
 include osdc/Makefile.am
 include client/Makefile.am
 include global/Makefile.am
@@ -46,7 +47,6 @@ include rbd_replay/Makefile.am
 include test/Makefile.am
 include tools/Makefile.am
 include Makefile-rocksdb.am
-include compressor/Makefile.am
 include tracing/Makefile.am
 include pybind/Makefile.am
 
diff --git a/src/Makefile.in b/src/Makefile.in
index 0f0ab7e..8671178 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,17 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -84,58 +94,18 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-DIST_COMMON = $(srcdir)/Makefile-env.am $(srcdir)/arch/Makefile.am \
-	$(srcdir)/auth/Makefile.am $(srcdir)/brag/Makefile.am \
-	$(srcdir)/ceph-detect-init/Makefile.am \
-	$(srcdir)/crush/Makefile.am $(srcdir)/kv/Makefile.am \
-	$(srcdir)/mon/Makefile.am $(srcdir)/mds/Makefile.am \
-	$(srcdir)/mds/Makefile-client.am \
-	$(srcdir)/mds/Makefile-server.am $(srcdir)/os/Makefile.am \
-	$(srcdir)/osd/Makefile.am $(srcdir)/erasure-code/Makefile.am \
-	$(srcdir)/erasure-code/jerasure/Makefile.am \
-	$(srcdir)/erasure-code/lrc/Makefile.am \
-	$(srcdir)/erasure-code/shec/Makefile.am \
-	$(srcdir)/erasure-code/isa/Makefile.am \
-	$(srcdir)/osdc/Makefile.am $(srcdir)/client/Makefile.am \
-	$(srcdir)/global/Makefile.am $(srcdir)/json_spirit/Makefile.am \
-	$(srcdir)/log/Makefile.am $(srcdir)/perfglue/Makefile.am \
-	$(srcdir)/common/Makefile.am $(srcdir)/msg/Makefile.am \
-	$(srcdir)/messages/Makefile.am $(srcdir)/include/Makefile.am \
-	$(srcdir)/librados/Makefile.am \
-	$(srcdir)/libradosstriper/Makefile.am \
-	$(srcdir)/journal/Makefile.am $(srcdir)/librbd/Makefile.am \
-	$(srcdir)/rgw/Makefile.am $(srcdir)/cls/Makefile.am \
-	$(srcdir)/cls/Makefile-client.am \
-	$(srcdir)/cls/Makefile-server.am \
-	$(srcdir)/key_value_store/Makefile.am \
-	$(srcdir)/rbd_replay/Makefile.am $(srcdir)/test/Makefile.am \
-	$(srcdir)/test/erasure-code/Makefile.am \
-	$(srcdir)/test/messenger/Makefile.am \
-	$(srcdir)/test/Makefile-client.am \
-	$(srcdir)/test/Makefile-server.am $(srcdir)/tools/Makefile.am \
-	$(srcdir)/tools/Makefile-client.am \
-	$(srcdir)/tools/Makefile-server.am \
-	$(srcdir)/Makefile-rocksdb.am $(srcdir)/compressor/Makefile.am \
-	$(srcdir)/tracing/Makefile.am $(srcdir)/pybind/Makefile.am \
-	$(srcdir)/Makefile-client.am $(srcdir)/Makefile-server.am \
-	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(srcdir)/acconfig.h.in $(dist_bin_SCRIPTS) \
-	$(top_srcdir)/depcomp $(am__python_PYTHON_DIST) \
-	$(top_srcdir)/py-compile $(dist_noinst_DATA) \
-	$(am__noinst_HEADERS_DIST) $(top_srcdir)/test-driver README \
-	TODO
 bin_PROGRAMS = $(am__EXEEXT_28) $(am__EXEEXT_29) $(am__EXEEXT_30) \
 	$(am__EXEEXT_31) $(am__EXEEXT_32) $(am__EXEEXT_33) \
 	$(am__EXEEXT_34) $(am__EXEEXT_35) $(am__EXEEXT_36) \
-	monmaptool$(EXEEXT) crushtool$(EXEEXT) osdmaptool$(EXEEXT) \
-	ceph-conf$(EXEEXT) ceph-authtool$(EXEEXT) $(am__EXEEXT_37) \
+	$(am__EXEEXT_37) monmaptool$(EXEEXT) crushtool$(EXEEXT) \
+	osdmaptool$(EXEEXT) ceph-conf$(EXEEXT) ceph-authtool$(EXEEXT) \
 	$(am__EXEEXT_38) $(am__EXEEXT_39) $(am__EXEEXT_40) \
 	$(am__EXEEXT_41) $(am__EXEEXT_42) $(am__EXEEXT_43) \
-	$(am__EXEEXT_44)
-noinst_PROGRAMS = $(am__EXEEXT_60) $(am__EXEEXT_61) $(am__EXEEXT_62)
+	$(am__EXEEXT_44) $(am__EXEEXT_45)
+noinst_PROGRAMS = $(am__EXEEXT_62) $(am__EXEEXT_63) $(am__EXEEXT_64)
 sbin_PROGRAMS =
-su_sbin_PROGRAMS = $(am__EXEEXT_63)
-check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
+su_sbin_PROGRAMS = $(am__EXEEXT_65)
+check_PROGRAMS = $(am__EXEEXT_60) $(am__EXEEXT_61) \
 	unittest_subprocess$(EXEEXT) \
 	unittest_async_compressor$(EXEEXT)
 
@@ -177,27 +147,29 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 
 # libkv/libos linking order is ornery
 @WITH_SLIBROCKSDB_TRUE at am__append_26 = rocksdb/librocksdb.a
- at ENABLE_CLIENT_TRUE@am__append_27 = brag/client/ceph-brag ceph \
+ at HAVE_BZLIB_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_27 = -lbz2
+ at HAVE_LZ4_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_28 = -llz4
+ at ENABLE_CLIENT_TRUE@am__append_29 = brag/client/ceph-brag ceph \
 @ENABLE_CLIENT_TRUE@	ceph-post-file
- at ENABLE_CLIENT_TRUE@am__append_28 = brag/server brag/README.md brag/client
- at ENABLE_SERVER_TRUE@am__append_29 = libkv.a
- at ENABLE_SERVER_TRUE@am__append_30 = \
+ at ENABLE_CLIENT_TRUE@am__append_30 = brag/server brag/README.md brag/client
+ at ENABLE_SERVER_TRUE@am__append_31 = libkv.a
+ at ENABLE_SERVER_TRUE@am__append_32 = \
 @ENABLE_SERVER_TRUE@	kv/KeyValueDB.h \
 @ENABLE_SERVER_TRUE@	kv/LevelDBStore.h
 
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_31 = -I rocksdb/include -fPIC
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_32 = kv/RocksDBStore.cc
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_33 = rocksdb/librocksdb.a
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_34 = kv/RocksDBStore.h
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_35 = kv/RocksDBStore.cc
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_36 = -lrocksdb
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_37 = kv/RocksDBStore.h
- at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_38 = kv/KineticStore.cc
- at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_39 = -std=gnu++11
- at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_40 = -lkinetic_client -lprotobuf -lglog -lgflags libcrypto.a
- at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_41 = kv/KineticStore.h
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_42 = libmon.a
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_43 = \
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_33 = -I rocksdb/include -fPIC
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_34 = kv/RocksDBStore.cc
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_35 = rocksdb/librocksdb.a
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_36 = kv/RocksDBStore.h
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_37 = kv/RocksDBStore.cc
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_38 = -lrocksdb
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_39 = kv/RocksDBStore.h
+ at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_40 = kv/KineticStore.cc
+ at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_41 = -std=gnu++11
+ at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_42 = -lkinetic_client -lprotobuf -lglog -lgflags libcrypto.a
+ at ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__append_43 = kv/KineticStore.h
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_44 = libmon.a
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_45 = \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	mon/AuthMonitor.h \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	mon/DataHealthService.h \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	mon/Elector.h \
@@ -226,10 +198,10 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 
 
 # There are no libmds_types so use the full mds library for dencoder for now
- at ENABLE_CLIENT_TRUE@am__append_44 = $(LIBMDS_SOURCES)
- at ENABLE_CLIENT_TRUE@am__append_45 = $(LIBMDS_DEPS)
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_46 = libmds.la
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_47 =  \
+ at ENABLE_CLIENT_TRUE@am__append_46 = $(LIBMDS_SOURCES)
+ at ENABLE_CLIENT_TRUE@am__append_47 = $(LIBMDS_DEPS)
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_48 = libmds.la
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_49 =  \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	mds/inode_backtrace.h \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	mds/flock.h mds/locks.c \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	mds/locks.h mds/CDentry.h \
@@ -283,50 +255,76 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	mds/events/ETableClient.h \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	mds/events/ETableServer.h \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	mds/events/EUpdate.h
- at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_48 = os/BtrfsFileStoreBackend.cc
- at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__append_49 = os/newstore/newstore_types.cc
- at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__append_50 = os/newstore/NewStore.cc
- at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE at am__append_51 = \
- at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@    os/fs/XFS.cc \
- at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@    os/XfsFileStoreBackend.cc
-
- at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__append_52 = os/ZFSFileStoreBackend.cc
- at ENABLE_SERVER_TRUE@@WITH_LTTNG_TRUE at am__append_53 = $(LIBOS_TP)
- at ENABLE_SERVER_TRUE@am__append_54 = libos.a
- at ENABLE_SERVER_TRUE@am__append_55 = \
- at ENABLE_SERVER_TRUE@	os/btrfs_ioctl.h \
- at ENABLE_SERVER_TRUE@	os/chain_xattr.h \
- at ENABLE_SERVER_TRUE@	os/newstore/newstore_types.h \
- at ENABLE_SERVER_TRUE@	os/newstore/NewStore.h \
- at ENABLE_SERVER_TRUE@	os/BtrfsFileStoreBackend.h \
- at ENABLE_SERVER_TRUE@	os/CollectionIndex.h \
- at ENABLE_SERVER_TRUE@	os/DBObjectMap.h \
- at ENABLE_SERVER_TRUE@	os/GenericObjectMap.h \
- at ENABLE_SERVER_TRUE@	os/FileJournal.h \
- at ENABLE_SERVER_TRUE@	os/FileStore.h \
- at ENABLE_SERVER_TRUE@	os/FDCache.h \
+ at WITH_LIBAIO_TRUE@am__append_50 = \
+ at WITH_LIBAIO_TRUE@	os/bluestore/bluestore_types.cc \
+ at WITH_LIBAIO_TRUE@	os/bluestore/bluefs_types.cc
+
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__append_51 = \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/kv.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/Allocator.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlockDevice.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlueFS.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlueRocksEnv.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlueStore.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/FreelistManager.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/StupidAllocator.cc
+
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_52 = os/filestore/BtrfsFileStoreBackend.cc
+ at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE at am__append_53 = \
+ at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@    os/filestore/XfsFileStoreBackend.cc \
+ at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@    os/fs/XFS.cc
+
+ at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__append_54 = os/filestore/ZFSFileStoreBackend.cc
+ at ENABLE_SERVER_TRUE@am__append_55 = libos.a
+ at ENABLE_SERVER_TRUE@@WITH_LTTNG_TRUE at am__append_56 = $(LIBOS_TP)
+ at ENABLE_SERVER_TRUE@am__append_57 = \
+ at ENABLE_SERVER_TRUE@	os/filestore/chain_xattr.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/BtrfsFileStoreBackend.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/CollectionIndex.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/DBObjectMap.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/FileJournal.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/FileStore.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/FDCache.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/GenericFileStoreBackend.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/HashIndex.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/IndexManager.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/Journal.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/JournalingObjectStore.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/LFNIndex.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/SequencerPosition.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/WBThrottle.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/XfsFileStoreBackend.h \
+ at ENABLE_SERVER_TRUE@	os/filestore/ZFSFileStoreBackend.h \
+ at ENABLE_SERVER_TRUE@	os/fs/btrfs_ioctl.h \
 @ENABLE_SERVER_TRUE@	os/fs/FS.h \
 @ENABLE_SERVER_TRUE@	os/fs/XFS.h \
- at ENABLE_SERVER_TRUE@	os/GenericFileStoreBackend.h \
- at ENABLE_SERVER_TRUE@	os/HashIndex.h \
- at ENABLE_SERVER_TRUE@	os/IndexManager.h \
- at ENABLE_SERVER_TRUE@	os/Journal.h \
- at ENABLE_SERVER_TRUE@	os/JournalingObjectStore.h \
- at ENABLE_SERVER_TRUE@	os/LFNIndex.h \
- at ENABLE_SERVER_TRUE@	os/MemStore.h \
- at ENABLE_SERVER_TRUE@	os/KeyValueStore.h \
+ at ENABLE_SERVER_TRUE@	os/keyvaluestore/GenericObjectMap.h \
+ at ENABLE_SERVER_TRUE@	os/keyvaluestore/KeyValueStore.h \
+ at ENABLE_SERVER_TRUE@	os/kstore/kstore_types.h \
+ at ENABLE_SERVER_TRUE@	os/kstore/KStore.h \
+ at ENABLE_SERVER_TRUE@	os/kstore/kv.h \
+ at ENABLE_SERVER_TRUE@	os/memstore/MemStore.h \
+ at ENABLE_SERVER_TRUE@	os/memstore/PageSet.h \
 @ENABLE_SERVER_TRUE@	os/ObjectMap.h \
- at ENABLE_SERVER_TRUE@	os/ObjectStore.h \
- at ENABLE_SERVER_TRUE@	os/PageSet.h \
- at ENABLE_SERVER_TRUE@	os/SequencerPosition.h \
- at ENABLE_SERVER_TRUE@	os/WBThrottle.h \
- at ENABLE_SERVER_TRUE@	os/XfsFileStoreBackend.h \
- at ENABLE_SERVER_TRUE@	os/ZFSFileStoreBackend.h
-
- at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__append_56 = libos_zfs.a
- at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__append_57 = os/ZFS.h
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_58 = libosd.a
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_59 = \
+ at ENABLE_SERVER_TRUE@	os/ObjectStore.h
+
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__append_58 = \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/bluefs_types.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/bluestore_types.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/kv.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/Allocator.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlockDevice.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlueFS.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlueRocksEnv.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/BlueStore.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/FreelistManager.h \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/StupidAllocator.h
+
+ at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__append_59 = libos_zfs.a
+ at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__append_60 = os/fs/ZFS.h
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__append_61 = ceph-bluefs-tool
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_62 = libosd.a
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_63 = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	osd/ClassHandler.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	osd/HitSet.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	osd/OSD.h \
@@ -348,26 +346,26 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	osd/Watch.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	osd/osd_types.h
 
- at LINUX_TRUE@am__append_60 = -export-symbols-regex '.*__erasure_code_.*'
- at LINUX_TRUE@am__append_61 = -export-symbols-regex '.*__erasure_code_.*'
- at HAVE_NEON_TRUE@am__append_62 = libec_jerasure_neon.la
- at LINUX_TRUE@am__append_63 = -export-symbols-regex '.*__erasure_code_.*'
- at HAVE_SSSE3_TRUE@am__append_64 = libec_jerasure_sse3.la
+ at LINUX_TRUE@am__append_64 = -export-symbols-regex '.*__erasure_code_.*'
 @LINUX_TRUE at am__append_65 = -export-symbols-regex '.*__erasure_code_.*'
- at HAVE_SSE4_PCLMUL_TRUE@am__append_66 = libec_jerasure_sse4.la
+ at HAVE_NEON_TRUE@am__append_66 = libec_jerasure_neon.la
 @LINUX_TRUE at am__append_67 = -export-symbols-regex '.*__erasure_code_.*'
- at LINUX_TRUE@am__append_68 = -export-symbols-regex '.*__erasure_code_.*'
+ at HAVE_SSSE3_TRUE@am__append_68 = libec_jerasure_sse3.la
 @LINUX_TRUE at am__append_69 = -export-symbols-regex '.*__erasure_code_.*'
- at LINUX_TRUE@am__append_70 = -export-symbols-regex '.*__erasure_code_.*'
- at HAVE_NEON_TRUE@am__append_71 = libec_shec_neon.la
+ at HAVE_SSE4_PCLMUL_TRUE@am__append_70 = libec_jerasure_sse4.la
+ at LINUX_TRUE@am__append_71 = -export-symbols-regex '.*__erasure_code_.*'
 @LINUX_TRUE at am__append_72 = -export-symbols-regex '.*__erasure_code_.*'
- at HAVE_SSSE3_TRUE@am__append_73 = libec_shec_sse3.la
+ at LINUX_TRUE@am__append_73 = -export-symbols-regex '.*__erasure_code_.*'
 @LINUX_TRUE at am__append_74 = -export-symbols-regex '.*__erasure_code_.*'
- at HAVE_SSE4_PCLMUL_TRUE@am__append_75 = libec_shec_sse4.la
+ at HAVE_NEON_TRUE@am__append_75 = libec_shec_neon.la
 @LINUX_TRUE at am__append_76 = -export-symbols-regex '.*__erasure_code_.*'
+ at HAVE_SSSE3_TRUE@am__append_77 = libec_shec_sse3.la
+ at LINUX_TRUE@am__append_78 = -export-symbols-regex '.*__erasure_code_.*'
+ at HAVE_SSE4_PCLMUL_TRUE@am__append_79 = libec_shec_sse4.la
+ at LINUX_TRUE@am__append_80 = -export-symbols-regex '.*__erasure_code_.*'
 
 # ISA
- at WITH_BETTER_YASM_ELF64_TRUE@am__append_77 = \
+ at WITH_BETTER_YASM_ELF64_TRUE@am__append_81 = \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/ErasureCodeIsa.h \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/ErasureCodeIsaTableCache.h \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/xor_op.h \
@@ -378,10 +376,11 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/isa-l/include/gf_vect_mul.h \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/isa-l/include/types.h
 
- at LINUX_TRUE@@WITH_BETTER_YASM_ELF64_TRUE at am__append_78 = -export-symbols-regex '.*__erasure_code_.*'
- at WITH_BETTER_YASM_ELF64_TRUE@am__append_79 = libec_isa.la
- at ENABLE_CLIENT_TRUE@am__append_80 = libclient.la
- at ENABLE_CLIENT_TRUE@am__append_81 = \
+ at LINUX_TRUE@@WITH_BETTER_YASM_ELF64_TRUE at am__append_82 = -export-symbols-regex '.*__erasure_code_.*'
+ at WITH_BETTER_YASM_ELF64_TRUE@am__append_83 = libec_isa.la
+ at LINUX_TRUE@am__append_84 = -export-symbols-regex '.*__compressor_.*'
+ at ENABLE_CLIENT_TRUE@am__append_85 = libclient.la
+ at ENABLE_CLIENT_TRUE@am__append_86 = \
 @ENABLE_CLIENT_TRUE@	client/Client.h \
 @ENABLE_CLIENT_TRUE@	client/Dentry.h \
 @ENABLE_CLIENT_TRUE@	client/Dir.h \
@@ -394,59 +393,61 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@	client/SyntheticClient.h \
 @ENABLE_CLIENT_TRUE@	client/Trace.h \
 @ENABLE_CLIENT_TRUE@	client/ioctl.h \
- at ENABLE_CLIENT_TRUE@	client/ObjecterWriteback.h
-
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE at am__append_82 = libclient_fuse.la
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE at am__append_83 = client/fuse_ll.h
- at ENABLE_CLIENT_TRUE@am__append_84 = ceph_test_ioctls
- at WITH_TCMALLOC_TRUE@am__append_85 = perfglue/heap_profiler.cc
- at WITH_TCMALLOC_TRUE@am__append_86 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
- at WITH_TCMALLOC_TRUE@am__append_87 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
- at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__append_88 = perfglue/heap_profiler.cc
- at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__append_89 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
- at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__append_90 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
- at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_FALSE at am__append_91 = perfglue/disabled_heap_profiler.cc
- at WITH_PROFILER_TRUE@am__append_92 = perfglue/cpu_profiler.cc
- at WITH_PROFILER_FALSE@am__append_93 = perfglue/disabled_stubs.cc
- at ENABLE_SERVER_TRUE@am__append_94 = \
+ at ENABLE_CLIENT_TRUE@	client/ObjecterWriteback.h \
+ at ENABLE_CLIENT_TRUE@	client/posix_acl.h \
+ at ENABLE_CLIENT_TRUE@	client/UserGroups.h
+
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE at am__append_87 = libclient_fuse.la
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE at am__append_88 = client/fuse_ll.h
+ at ENABLE_CLIENT_TRUE@am__append_89 = ceph_test_ioctls
+ at WITH_TCMALLOC_TRUE@am__append_90 = perfglue/heap_profiler.cc
+ at WITH_TCMALLOC_TRUE@am__append_91 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+ at WITH_TCMALLOC_TRUE@am__append_92 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+ at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__append_93 = perfglue/heap_profiler.cc
+ at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__append_94 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+ at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__append_95 = -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
+ at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_FALSE at am__append_96 = perfglue/disabled_heap_profiler.cc
+ at WITH_PROFILER_TRUE@am__append_97 = perfglue/cpu_profiler.cc
+ at WITH_PROFILER_FALSE@am__append_98 = perfglue/disabled_stubs.cc
+ at ENABLE_SERVER_TRUE@am__append_99 = \
 @ENABLE_SERVER_TRUE@	common/xattr.c \
 @ENABLE_SERVER_TRUE@	common/ipaddr.cc \
 @ENABLE_SERVER_TRUE@	common/ceph_json.cc \
 @ENABLE_SERVER_TRUE@	common/util.cc \
 @ENABLE_SERVER_TRUE@	common/pick_address.cc
 
- at LINUX_TRUE@am__append_95 = \
+ at LINUX_TRUE@am__append_100 = \
 @LINUX_TRUE@	common/linux_version.c 
 
- at SOLARIS_TRUE@am__append_96 = \
+ at SOLARIS_TRUE@am__append_101 = \
 @SOLARIS_TRUE@        common/solaris_errno.cc
 
- at AIX_TRUE@am__append_97 = \
+ at AIX_TRUE@am__append_102 = \
 @AIX_TRUE@        common/aix_errno.cc
 
 
 # used by RBD and FileStore
- at LINUX_TRUE@am__append_98 = \
+ at LINUX_TRUE@am__append_103 = \
 @LINUX_TRUE@	common/blkdev.cc
 
- at ENABLE_XIO_TRUE@am__append_99 = \
+ at ENABLE_XIO_TRUE@am__append_104 = \
 @ENABLE_XIO_TRUE@	common/address_helper.cc
 
- at WITH_GOOD_YASM_ELF64_TRUE@am__append_100 = common/crc32c_intel_fast_asm.S common/crc32c_intel_fast_zero_asm.S
- at HAVE_ARMV8_CRC_TRUE@am__append_101 = libcommon_crc_aarch64.la
- at HAVE_ARMV8_CRC_TRUE@am__append_102 = libcommon_crc_aarch64.la
- at LINUX_TRUE@am__append_103 = -lrt -lblkid
- at ENABLE_XIO_TRUE@am__append_104 = \
+ at WITH_GOOD_YASM_ELF64_TRUE@am__append_105 = common/crc32c_intel_fast_asm.S common/crc32c_intel_fast_zero_asm.S
+ at HAVE_ARMV8_CRC_TRUE@am__append_106 = libcommon_crc_aarch64.la
+ at HAVE_ARMV8_CRC_TRUE@am__append_107 = libcommon_crc_aarch64.la
+ at LINUX_TRUE@am__append_108 = -lrt -lblkid
+ at ENABLE_XIO_TRUE@am__append_109 = \
 @ENABLE_XIO_TRUE@	common/address_helper.h
 
- at LINUX_TRUE@am__append_105 = libsecret.la
- at LINUX_TRUE@am__append_106 = msg/async/EventEpoll.cc
- at DARWIN_TRUE@am__append_107 = msg/async/EventKqueue.cc
- at FREEBSD_TRUE@am__append_108 = msg/async/EventKqueue.cc
- at LINUX_TRUE@am__append_109 = msg/async/EventEpoll.h
- at DARWIN_TRUE@am__append_110 = msg/async/EventKqueue.h
- at FREEBSD_TRUE@am__append_111 = msg/async/EventKqueue.h
- at ENABLE_XIO_TRUE@am__append_112 = \
+ at LINUX_TRUE@am__append_110 = libsecret.la
+ at LINUX_TRUE@am__append_111 = msg/async/EventEpoll.cc
+ at DARWIN_TRUE@am__append_112 = msg/async/EventKqueue.cc
+ at FREEBSD_TRUE@am__append_113 = msg/async/EventKqueue.cc
+ at LINUX_TRUE@am__append_114 = msg/async/EventEpoll.h
+ at DARWIN_TRUE@am__append_115 = msg/async/EventKqueue.h
+ at FREEBSD_TRUE@am__append_116 = msg/async/EventKqueue.h
+ at ENABLE_XIO_TRUE@am__append_117 = \
 @ENABLE_XIO_TRUE@	msg/xio/QueueStrategy.cc \
 @ENABLE_XIO_TRUE@	msg/xio/XioConnection.cc \
 @ENABLE_XIO_TRUE@	msg/xio/XioMessenger.cc \
@@ -454,7 +455,7 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_XIO_TRUE@	msg/xio/XioPortal.cc \
 @ENABLE_XIO_TRUE@	msg/xio/XioPool.cc
 
- at ENABLE_XIO_TRUE@am__append_113 = \
+ at ENABLE_XIO_TRUE@am__append_118 = \
 @ENABLE_XIO_TRUE@	msg/xio/DispatchStrategy.h \
 @ENABLE_XIO_TRUE@	msg/xio/FastStrategy.h \
 @ENABLE_XIO_TRUE@	msg/xio/QueueStrategy.h \
@@ -466,18 +467,18 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_XIO_TRUE@	msg/xio/XioPortal.h \
 @ENABLE_XIO_TRUE@	msg/xio/XioSubmit.h
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_114 =  \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_119 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_internal.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_api.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libjournal.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_115 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_120 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_internal.la libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBOSDC) $(LIBCOMMON_DEPS)
 
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at am__append_116 = -fvisibility=hidden -fvisibility-inlines-hidden
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at am__append_117 = -Xcompiler -Xlinker -Xcompiler '--exclude-libs=ALL'
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_118 = librados.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_119 = \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at am__append_121 = -fvisibility=hidden -fvisibility-inlines-hidden
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at am__append_122 = -Xcompiler -Xlinker -Xcompiler '--exclude-libs=ALL'
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_123 = librados.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_124 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados/snap_set_diff.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados/AioCompletionImpl.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados/IoCtxImpl.h \
@@ -486,13 +487,13 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados/RadosXattrIter.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados/ListObjectImpl.h
 
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_120 = -export-symbols-regex '^radosstriper_.*'
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_121 = libradosstriper.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_122 = \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_125 = -export-symbols-regex '^radosstriper_.*'
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_126 = libradosstriper.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_127 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	libradosstriper/RadosStriperImpl.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	libradosstriper/MultiAioCompletionImpl.h
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_123 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_128 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/AsyncOpTracker.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/Entry.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/Future.h \
@@ -508,12 +509,12 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/ReplayHandler.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/Utils.h
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_124 = libjournal.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_125 = librbd_internal.la \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_129 = libjournal.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_130 = librbd_internal.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_api.la
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_126 = -Xcompiler -Xlinker -Xcompiler '--exclude-libs=ALL'
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_127 = librbd.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_128 = \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_131 = -Xcompiler -Xlinker -Xcompiler '--exclude-libs=ALL'
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_132 = librbd.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_133 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/AioCompletion.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/AioImageRequest.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/AioImageRequestWQ.h \
@@ -529,11 +530,10 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/ImageWatcher.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/internal.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Journal.h \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/JournalReplay.h \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/JournalTypes.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/LibrbdAdminSocketHook.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/LibrbdWriteback.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/ObjectMap.h \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Operations.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/parent_types.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/SnapInfo.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/TaskFinisher.h \
@@ -546,6 +546,8 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/RefreshParentRequest.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/RefreshRequest.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/SetSnapRequest.h \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/journal/Replay.h \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/journal/Entries.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/InvalidateRequest.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/LockRequest.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/Request.h \
@@ -571,7 +573,7 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 
 
 # inject rgw stuff in the decoder testcase
- at ENABLE_CLIENT_TRUE@am__append_129 = \
+ at ENABLE_CLIENT_TRUE@am__append_134 = \
 @ENABLE_CLIENT_TRUE@	rgw/rgw_dencoder.cc \
 @ENABLE_CLIENT_TRUE@	rgw/rgw_acl.cc \
 @ENABLE_CLIENT_TRUE@	rgw/rgw_basic_types.cc \
@@ -579,9 +581,9 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@	rgw/rgw_env.cc \
 @ENABLE_CLIENT_TRUE@	rgw/rgw_json_enc.cc
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_130 = librgw.la \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_135 = librgw.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcivetweb.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_131 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_136 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_rgw_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_log_client.a \
@@ -598,12 +600,12 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	-lfcgi \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	-ldl
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_132 = radosgw \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_137 = radosgw \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	radosgw-admin \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	radosgw-object-expirer
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_133 = ceph_rgw_multiparser \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_138 = ceph_rgw_multiparser \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_rgw_jsonparser
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_134 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_139 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_acl.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_acl_s3.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_acl_swift.h \
@@ -663,26 +665,26 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	civetweb/include/civetweb_conf.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	civetweb/src/md5.h
 
- at ENABLE_CLIENT_TRUE@am__append_135 = libcls_lock_client.la \
+ at ENABLE_CLIENT_TRUE@am__append_140 = libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_refcount_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_rgw_client.la libcls_rbd_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_cephfs_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_numops_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_journal_client.la
- at ENABLE_CLIENT_TRUE@am__append_136 = libcls_lock_client.la \
+ at ENABLE_CLIENT_TRUE@am__append_141 = libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_refcount_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_replica_log_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_rgw_client.la libcls_rbd_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_user_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_numops_client.la \
 @ENABLE_CLIENT_TRUE@	libcls_journal_client.la
- at ENABLE_CLIENT_TRUE@am__append_137 = libcls_version_client.a \
+ at ENABLE_CLIENT_TRUE@am__append_142 = libcls_version_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_log_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_statelog_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_timeindex_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_replica_log_client.a \
 @ENABLE_CLIENT_TRUE@	libcls_user_client.a
- at ENABLE_CLIENT_TRUE@am__append_138 = \
+ at ENABLE_CLIENT_TRUE@am__append_143 = \
 @ENABLE_CLIENT_TRUE@	cls/lock/cls_lock_types.h \
 @ENABLE_CLIENT_TRUE@	cls/lock/cls_lock_ops.h \
 @ENABLE_CLIENT_TRUE@	cls/lock/cls_lock_client.h \
@@ -718,7 +720,7 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@	cls/journal/cls_journal_client.h \
 @ENABLE_CLIENT_TRUE@	cls/journal/cls_journal_types.h
 
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_139 = libcls_hello.la \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_144 = libcls_hello.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libcls_numops.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libcls_rbd.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libcls_lock.la \
@@ -732,13 +734,13 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libcls_rgw.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libcls_cephfs.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libcls_journal.la
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_140 = libcls_kvs.la
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_141 = \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_145 = libcls_kvs.la
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_146 = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	key_value_store/key_value_structure.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	key_value_store/kv_flat_btree_async.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	key_value_store/kvs_arg_types.h
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_142 = rbd_replay/ActionTypes.h \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_147 = rbd_replay/ActionTypes.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd_replay/actions.hpp \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd_replay/BoundedBuffer.hpp \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd_replay/BufferReader.h \
@@ -748,26 +750,26 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd_replay/rbd_loc.hpp \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd_replay/rbd_replay_debug.hpp \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd_replay/Replayer.hpp
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_143 = librbd_replay_types.la \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_148 = librbd_replay_types.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay_ios.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_144 = librbd_replay_types.la
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_145 = rbd-replay
- at ENABLE_CLIENT_TRUE@@WITH_BABELTRACE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_146 = rbd-replay-prep
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_147 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_149 = librbd_replay_types.la
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_150 = rbd-replay
+ at ENABLE_CLIENT_TRUE@@WITH_BABELTRACE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_151 = rbd-replay-prep
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_152 = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/test-erasure-code.sh \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/test-erasure-eio.sh
 
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_148 = test/erasure-code/ceph_erasure_code_benchmark.h \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_153 = test/erasure-code/ceph_erasure_code_benchmark.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/ceph_erasure_code_benchmark.h \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/ErasureCodeExample.h
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_149 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_150 = ceph_erasure_code_benchmark \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_154 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_155 = ceph_erasure_code_benchmark \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	ceph_erasure_code
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_151 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_152 = ceph_erasure_code_non_regression
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_153 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_154 = libec_example.la \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_156 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_157 = ceph_erasure_code_non_regression
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_158 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_159 = libec_example.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libec_missing_entry_point.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libec_missing_version.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libec_hangs.la \
@@ -781,19 +783,19 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libec_test_shec_sse4.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libec_test_shec_sse3.la \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	libec_test_shec_generic.la
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_155 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_156 = unittest_erasure_code_plugin \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_160 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_161 = unittest_erasure_code_plugin \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_jerasure \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_jerasure
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_157 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_158 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__append_159 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__append_160 = unittest_erasure_code_isa \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_isa
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__append_161 = -ldl
 @ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_162 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_163 =  \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_163 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__append_164 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__append_165 = unittest_erasure_code_isa \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_isa
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__append_166 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_167 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_168 =  \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_lrc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_lrc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec \
@@ -801,45 +803,55 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec_thread \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec_arguments \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_shec \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_example
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_164 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_165 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_166 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_167 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_168 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_example \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_compression_plugin \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_compression_snappy \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_compression_plugin_snappy
 @ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_169 = -ldl
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at am__append_170 = test/messenger/message_helper.h \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_170 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_171 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_172 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_173 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_174 = -ldl
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at am__append_175 = test/messenger/message_helper.h \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/simple_dispatcher.h \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_dispatcher.h
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_171 = -ldl
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_172 = -ldl
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at am__append_173 = simple_server \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_176 = -ldl
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_177 = -ldl
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at am__append_178 = simple_server \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	simple_client xio_server \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	xio_client
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_174 = -ldl
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_175 = -ldl
- at COMPILER_HAS_VTA_TRUE@@ENABLE_CLIENT_TRUE at am__append_176 = -fno-var-tracking-assignments
- at COMPILER_HAS_VTA_TRUE@@ENABLE_CLIENT_TRUE at am__append_177 = -fno-var-tracking-assignments
- at ENABLE_CLIENT_TRUE@am__append_178 = ceph-dencoder
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_179 = libradostest.la \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_179 = -ldl
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@@LINUX_TRUE at am__append_180 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_181 = test/compressor/compressor_example.h
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_182 = libceph_example.la
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_183 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_184 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_185 = -ldl
+ at COMPILER_HAS_VTA_TRUE@@ENABLE_CLIENT_TRUE at am__append_186 = -fno-var-tracking-assignments
+ at COMPILER_HAS_VTA_TRUE@@ENABLE_CLIENT_TRUE at am__append_187 = -fno-var-tracking-assignments
+ at ENABLE_CLIENT_TRUE@@WITH_RBD_TRUE at am__append_188 = -DWITH_RBD
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE at am__append_189 = -DWITH_RADOSGW
+ at ENABLE_CLIENT_TRUE@am__append_190 = ceph-dencoder
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_191 = libradostest.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_test_stub.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_180 = ceph_test_rados \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_192 = ceph_test_rados \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_test_mutate
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE at am__append_181 = test_build_librados
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_182 =  \
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE at am__append_193 = test_build_librados
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_194 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_smalliobench \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_omapbench \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_objectstore_bench
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at am__append_183 = ceph_kvstorebench \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at am__append_195 = ceph_kvstorebench \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_list_parallel \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_open_pools_parallel \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_delete_pools_parallel \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_watch_notify
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_184 =  \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_196 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	unittest_librados \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	unittest_librados_config \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	unittest_journal
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_185 =  \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_197 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_multi_stress_watch \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_rbd \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_refcount \
@@ -867,7 +879,7 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_api_tier \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_api_lock \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_test_stress_watch
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_186 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_198 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados_test_stub/LibradosTestStub.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados_test_stub/MockTestMemIoCtxImpl.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados_test_stub/MockTestMemRadosClient.h \
@@ -878,14 +890,14 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados_test_stub/TestMemIoCtxImpl.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados_test_stub/TestIoCtxImpl.h
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_187 = ceph_smalliobenchrbd \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_199 = ceph_smalliobenchrbd \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	ceph_test_librbd \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	ceph_test_librbd_api
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_188 = unittest_rbd_replay
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_189 = librbd_test.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_190 = unittest_librbd
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_191 = test/run-rbd-unit-tests.sh
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_192 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_200 = unittest_rbd_replay
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_201 = librbd_test.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_202 = unittest_librbd
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_203 = test/run-rbd-unit-tests.sh
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_204 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_fixture.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_mock_fixture.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_support.h \
@@ -896,44 +908,47 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/mock/MockImageWatcher.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/mock/MockJournal.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/mock/MockObjectMap.h \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/mock/MockOperations.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/mock/MockReadahead.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/mock/MockInvalidateRequest.h
 
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_193 = ceph_test_librbd_fsx
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_194 = libradosstripertest.la
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_195 = ceph_test_rados_striper_api_io \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_205 = ceph_test_librbd_fsx
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_206 = libradosstripertest.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am__append_207 = ceph_test_rados_striper_api_io \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_striper_api_aio \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	ceph_test_rados_striper_api_striping
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_196 = test_build_libcephfs
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_197 = unittest_encoding \
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_208 = test_build_libcephfs
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_209 = unittest_encoding \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_base64 \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_run_cmd \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_simple_spin \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_libcephfs_config
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_198 = test/libcephfs/flock.cc
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_199 = ceph_test_libcephfs \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_210 = test/libcephfs/flock.cc
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_211 = ceph_test_libcephfs \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	ceph_test_c_headers
- at CLANG_FALSE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_200 = -Werror -Wold-style-declaration
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_201 = test_build_librgw
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_202 = ceph_test_cors \
+ at CLANG_FALSE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_212 = -Werror -Wold-style-declaration
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_213 = test_build_librgw
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__append_214 = ceph_test_cors \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_rgw_manifest \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_rgw_obj \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_rgw_meta \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_rgw_log \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_rgw_opstate \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_rgw
- at ENABLE_SERVER_TRUE@am__append_203 = ceph_test_async_driver \
- at ENABLE_SERVER_TRUE@	ceph_test_msgr ceph_streamtest \
- at ENABLE_SERVER_TRUE@	ceph_test_trans ceph_test_mon_workloadgen \
+ at ENABLE_SERVER_TRUE@am__append_215 = ceph_test_async_driver \
+ at ENABLE_SERVER_TRUE@	ceph_test_msgr ceph_test_trans \
+ at ENABLE_SERVER_TRUE@	ceph_test_mon_workloadgen \
 @ENABLE_SERVER_TRUE@	ceph_test_mon_msg ceph_perf_objectstore \
 @ENABLE_SERVER_TRUE@	ceph_perf_local ceph_perf_msgr_server \
 @ENABLE_SERVER_TRUE@	ceph_perf_msgr_client
- at ENABLE_SERVER_TRUE@am__append_204 = test/perf_helper.h
- at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_205 =  \
+ at ENABLE_SERVER_TRUE@am__append_216 = test/perf_helper.h
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_217 =  \
 @ENABLE_SERVER_TRUE@@LINUX_TRUE@	ceph_test_objectstore \
 @ENABLE_SERVER_TRUE@@LINUX_TRUE@	ceph_test_keyvaluedb \
 @ENABLE_SERVER_TRUE@@LINUX_TRUE@	ceph_test_filestore
- at ENABLE_SERVER_TRUE@am__append_206 =  \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_218 = unittest_bluefs \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	unittest_bluestore_types
+ at ENABLE_SERVER_TRUE@am__append_219 =  \
 @ENABLE_SERVER_TRUE@	ceph_test_objectstore_workloadgen \
 @ENABLE_SERVER_TRUE@	ceph_test_filestore_idempotent \
 @ENABLE_SERVER_TRUE@	ceph_test_filestore_idempotent_sequence \
@@ -941,65 +956,65 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @ENABLE_SERVER_TRUE@	ceph_test_object_map \
 @ENABLE_SERVER_TRUE@	ceph_test_keyvaluedb_atomicity \
 @ENABLE_SERVER_TRUE@	ceph_test_keyvaluedb_iterators
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE at am__append_207 = ceph_smalliobenchfs \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE at am__append_220 = ceph_smalliobenchfs \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	ceph_smalliobenchdumb \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	ceph_tpbench
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_208 = ceph_test_keys
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_209 = get_command_descriptions
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_210 =  \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_221 = ceph_test_keys
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_222 = get_command_descriptions
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_223 =  \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	unittest_mon_moncap \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	unittest_mon_pgmap
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_211 =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_224 =  \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_ecbackend \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_osdscrub \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_pglog \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_hitset \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_osd_osdcap \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_pageset
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_212 = -ldl
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_213 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_214 = ceph_test_snap_mapper
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_215 = unittest_rocksdb_option_static
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_216 = unittest_rocksdb_option
- at ENABLE_SERVER_TRUE@am__append_217 = unittest_chain_xattr \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_225 = -ldl
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_226 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_227 = ceph_test_snap_mapper
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__append_228 = unittest_rocksdb_option_static
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__append_229 = unittest_rocksdb_option
+ at ENABLE_SERVER_TRUE@am__append_230 = unittest_chain_xattr \
 @ENABLE_SERVER_TRUE@	unittest_lfnindex
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_218 = unittest_mds_authcap
- at WITH_BUILD_TESTS_TRUE@am__append_219 = test_build_libcommon
- at LINUX_TRUE@am__append_220 = libsystest.la
- at SOLARIS_TRUE@am__append_221 = \
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_231 = unittest_mds_authcap
+ at WITH_BUILD_TESTS_TRUE@am__append_232 = test_build_libcommon
+ at LINUX_TRUE@am__append_233 = libsystest.la
+ at SOLARIS_TRUE@am__append_234 = \
 @SOLARIS_TRUE@	-lsocket -lnsl
 
- at LINUX_TRUE@am__append_222 = unittest_blkdev
- at LINUX_TRUE@am__append_223 = ceph_test_get_blkdev_size
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_224 =  \
+ at LINUX_TRUE@am__append_235 = unittest_blkdev
+ at LINUX_TRUE@am__append_236 = ceph_test_get_blkdev_size
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_237 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_scratchtool \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_scratchtoolpp \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	ceph_radosacl
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_225 = rados
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_226 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_238 = rados
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_239 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	tools/rbd/ArgumentTypes.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	tools/rbd/IndentStream.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	tools/rbd/OptionPrinter.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	tools/rbd/Shell.h \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	tools/rbd/Utils.h
 
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_227 = rbd \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_240 = rbd \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd-nbd
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_228 = ceph-client-debug
- at ENABLE_SERVER_TRUE@am__append_229 = ceph-osdomap-tool \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_241 = ceph-client-debug
+ at ENABLE_SERVER_TRUE@am__append_242 = ceph-osdomap-tool \
 @ENABLE_SERVER_TRUE@	ceph-monstore-tool ceph-kvstore-tool
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_230 = -ldl
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_231 = ceph-objectstore-tool
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at am__append_232 = cephfs-journal-tool \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@@WITH_OSD_TRUE at am__append_243 = -ldl
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_244 = ceph-objectstore-tool
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at am__append_245 = cephfs-journal-tool \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	cephfs-table-tool \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	cephfs-data-scan
- at WITH_LTTNG_TRUE@am__append_233 = \
+ at WITH_LTTNG_TRUE@am__append_246 = \
 @WITH_LTTNG_TRUE@	libosd_tp.la \
 @WITH_LTTNG_TRUE@	libos_tp.la \
 @WITH_LTTNG_TRUE@	librados_tp.la \
 @WITH_LTTNG_TRUE@	librbd_tp.la
 
- at WITH_LTTNG_TRUE@am__append_234 = \
+ at WITH_LTTNG_TRUE@am__append_247 = \
 @WITH_LTTNG_TRUE@	tracing/librados.h \
 @WITH_LTTNG_TRUE@	tracing/librbd.h \
 @WITH_LTTNG_TRUE@	tracing/objectstore.h \
@@ -1007,56 +1022,57 @@ check_PROGRAMS = $(am__EXEEXT_58) $(am__EXEEXT_59) \
 @WITH_LTTNG_TRUE@	tracing/osd.h \
 @WITH_LTTNG_TRUE@	tracing/pg.h
 
- at ENABLE_CLIENT_TRUE@@WITH_CYTHON_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_235 = pybind-all
- at ENABLE_CLIENT_TRUE@@WITH_CYTHON_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_236 = pybind-clean
- at ENABLE_CLIENT_TRUE@@WITH_CYTHON_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_237 = pybind-install-exec
-TESTS = $(am__EXEEXT_58) $(check_SCRIPTS)
- at ENABLE_CLIENT_TRUE@am__append_238 = \
+ at ENABLE_CLIENT_TRUE@@WITH_CYTHON_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_248 = pybind-all
+ at ENABLE_CLIENT_TRUE@@WITH_CYTHON_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_249 = pybind-clean
+ at ENABLE_CLIENT_TRUE@@WITH_CYTHON_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_250 = pybind-install-exec
+TESTS = $(am__EXEEXT_60) $(check_SCRIPTS)
+ at ENABLE_CLIENT_TRUE@am__append_251 = \
 @ENABLE_CLIENT_TRUE@	pybind/ceph_argparse.py \
 @ENABLE_CLIENT_TRUE@	pybind/ceph_daemon.py
 
- at ENABLE_CLIENT_TRUE@am__append_239 = ceph-syn
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_240 = \
+ at ENABLE_CLIENT_TRUE@am__append_252 = ceph-syn
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_253 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(srcdir)/bash_completion/rados \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(srcdir)/bash_completion/radosgw-admin
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_241 = pybind/rados.py
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_242 = librados-config
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_243 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_254 = pybind/rados.py
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__append_255 = librados-config
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_256 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(srcdir)/bash_completion/rbd
 
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_244 = \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_257 = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	ceph-rbdnamer \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd-replay-many \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@        rbdmap
 
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_245 = libkrbd.la
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE at am__append_246 = ceph-fuse
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_247 = rbd-fuse
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_248 = cephfs
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_249 = pybind/cephfs.py
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_250 = -Xcompiler -Xlinker -Xcompiler '--exclude-libs=libcommon.a'
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_251 = libcephfs.la
- at ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_252 = libcephfs_jni.la
- at ENABLE_SERVER_TRUE@am__append_253 = ceph-run ceph-rest-api \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_258 = libkrbd.la
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE at am__append_259 = ceph-fuse
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__append_260 = rbd-fuse
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_261 = cephfs
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_262 = pybind/cephfs.py \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	pybind/ceph_volume_client.py
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_263 = -Xcompiler -Xlinker -Xcompiler '--exclude-libs=libcommon.a'
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_264 = libcephfs.la
+ at ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_265 = libcephfs_jni.la
+ at ENABLE_SERVER_TRUE@am__append_266 = ceph-run ceph-rest-api \
 @ENABLE_SERVER_TRUE@	ceph-debugpack ceph-crush-location \
 @ENABLE_SERVER_TRUE@	ceph-coverage
- at ENABLE_SERVER_TRUE@am__append_254 = pybind/ceph_rest_api.py
- at ENABLE_SERVER_TRUE@am__append_255 = ceph-coverage init-ceph
- at ENABLE_SERVER_TRUE@am__append_256 = init-ceph
- at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_257 = mount.ceph
- at ENABLE_SERVER_TRUE@am__append_258 = mount.fuse.ceph
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_259 = ceph-mon
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_260 = \
+ at ENABLE_SERVER_TRUE@am__append_267 = pybind/ceph_rest_api.py
+ at ENABLE_SERVER_TRUE@am__append_268 = ceph-coverage init-ceph
+ at ENABLE_SERVER_TRUE@am__append_269 = init-ceph
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__append_270 = mount.ceph
+ at ENABLE_SERVER_TRUE@am__append_271 = mount.fuse.ceph
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__append_272 = ceph-mon
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_273 = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	ceph-disk \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	ceph-disk-udev
 
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_261 = \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_274 = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	ceph-clsinfo
 
- at ENABLE_SERVER_TRUE@@WITH_LTTNG_TRUE@@WITH_OSD_TRUE at am__append_262 = $(LIBOSD_TP)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_263 = ceph-osd
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_264 = ceph-mds
+ at ENABLE_SERVER_TRUE@@WITH_LTTNG_TRUE@@WITH_OSD_TRUE at am__append_275 = $(LIBOSD_TP)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__append_276 = ceph-osd
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__append_277 = ceph-mds
 subdir = src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
@@ -1076,6 +1092,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(dist_bin_SCRIPTS) \
+	$(am__python_PYTHON_DIST) $(dist_noinst_DATA) \
+	$(am__noinst_HEADERS_DIST) $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = acconfig.h
 CONFIG_CLEAN_FILES =
@@ -1141,7 +1160,7 @@ libkv_a_AR = $(AR) $(ARFLAGS)
 am__DEPENDENCIES_1 =
 @ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE at am__DEPENDENCIES_2 =  \
 @ENABLE_SERVER_TRUE@@WITH_KINETIC_TRUE@	libcrypto.a
- at ENABLE_SERVER_TRUE@libkv_a_DEPENDENCIES = $(am__append_33) \
+ at ENABLE_SERVER_TRUE@libkv_a_DEPENDENCIES = $(am__append_35) \
 @ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_2)
 am__libkv_a_SOURCES_DIST = kv/KeyValueDB.cc kv/LevelDBStore.cc \
@@ -1180,50 +1199,71 @@ libmon_a_OBJECTS = $(am_libmon_a_OBJECTS)
 libos_a_AR = $(AR) $(ARFLAGS)
 @ENABLE_SERVER_TRUE at libos_a_DEPENDENCIES = libos_types.a libkv.a \
 @ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_1)
-am__libos_a_SOURCES_DIST = os/chain_xattr.cc os/fs/FS.cc \
-	os/DBObjectMap.cc os/GenericObjectMap.cc os/FileJournal.cc \
-	os/FileStore.cc os/GenericFileStoreBackend.cc os/HashIndex.cc \
-	os/IndexManager.cc os/JournalingObjectStore.cc os/LFNIndex.cc \
-	os/MemStore.cc os/KeyValueStore.cc os/ObjectStore.cc \
-	os/WBThrottle.cc os/BtrfsFileStoreBackend.cc \
-	os/newstore/NewStore.cc os/fs/XFS.cc os/XfsFileStoreBackend.cc \
-	os/ZFSFileStoreBackend.cc
- at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__objects_4 = os/BtrfsFileStoreBackend.$(OBJEXT)
- at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__objects_5 = os/newstore/NewStore.$(OBJEXT)
- at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE at am__objects_6 =  \
- at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@	os/fs/XFS.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@	os/XfsFileStoreBackend.$(OBJEXT)
- at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__objects_7 = os/ZFSFileStoreBackend.$(OBJEXT)
- at ENABLE_SERVER_TRUE@am_libos_a_OBJECTS = os/chain_xattr.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/fs/FS.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/DBObjectMap.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/GenericObjectMap.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/FileJournal.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/FileStore.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/GenericFileStoreBackend.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/HashIndex.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/IndexManager.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/JournalingObjectStore.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/LFNIndex.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/MemStore.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/KeyValueStore.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/ObjectStore.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@	os/WBThrottle.$(OBJEXT) $(am__objects_4) \
- at ENABLE_SERVER_TRUE@	$(am__objects_5) $(am__objects_6) \
- at ENABLE_SERVER_TRUE@	$(am__objects_7)
+am__libos_a_SOURCES_DIST = os/filestore/chain_xattr.cc \
+	os/filestore/DBObjectMap.cc os/filestore/FileJournal.cc \
+	os/filestore/FileStore.cc \
+	os/filestore/GenericFileStoreBackend.cc \
+	os/filestore/HashIndex.cc os/filestore/IndexManager.cc \
+	os/filestore/JournalingObjectStore.cc os/filestore/LFNIndex.cc \
+	os/filestore/WBThrottle.cc os/fs/FS.cc \
+	os/keyvaluestore/GenericObjectMap.cc \
+	os/keyvaluestore/KeyValueStore.cc os/kstore/kv.cc \
+	os/kstore/KStore.cc os/memstore/MemStore.cc os/ObjectStore.cc \
+	os/bluestore/kv.cc os/bluestore/Allocator.cc \
+	os/bluestore/BlockDevice.cc os/bluestore/BlueFS.cc \
+	os/bluestore/BlueRocksEnv.cc os/bluestore/BlueStore.cc \
+	os/bluestore/FreelistManager.cc \
+	os/bluestore/StupidAllocator.cc \
+	os/filestore/BtrfsFileStoreBackend.cc \
+	os/filestore/XfsFileStoreBackend.cc os/fs/XFS.cc \
+	os/filestore/ZFSFileStoreBackend.cc
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__objects_4 = os/bluestore/libos_a-kv.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-Allocator.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-BlockDevice.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-BlueFS.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-BlueRocksEnv.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-BlueStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-FreelistManager.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	os/bluestore/libos_a-StupidAllocator.$(OBJEXT)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__objects_5 = os/filestore/libos_a-BtrfsFileStoreBackend.$(OBJEXT)
+ at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE at am__objects_6 = os/filestore/libos_a-XfsFileStoreBackend.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBXFS_TRUE@	os/fs/libos_a-XFS.$(OBJEXT)
+ at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am__objects_7 = os/filestore/libos_a-ZFSFileStoreBackend.$(OBJEXT)
+ at ENABLE_SERVER_TRUE@am_libos_a_OBJECTS = os/filestore/libos_a-chain_xattr.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-DBObjectMap.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-FileJournal.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-FileStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-GenericFileStoreBackend.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-HashIndex.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-IndexManager.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-JournalingObjectStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-LFNIndex.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/filestore/libos_a-WBThrottle.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/fs/libos_a-FS.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/keyvaluestore/libos_a-GenericObjectMap.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/keyvaluestore/libos_a-KeyValueStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/kstore/libos_a-kv.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/kstore/libos_a-KStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/memstore/libos_a-MemStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	os/libos_a-ObjectStore.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@	$(am__objects_4) $(am__objects_5) \
+ at ENABLE_SERVER_TRUE@	$(am__objects_6) $(am__objects_7)
 libos_a_OBJECTS = $(am_libos_a_OBJECTS)
 libos_types_a_AR = $(AR) $(ARFLAGS)
 libos_types_a_LIBADD =
-am__libos_types_a_SOURCES_DIST = os/Transaction.cc \
-	os/newstore/newstore_types.cc
- at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__objects_8 = os/newstore/libos_types_a-newstore_types.$(OBJEXT)
-am_libos_types_a_OBJECTS = os/libos_types_a-Transaction.$(OBJEXT) \
-	$(am__objects_8)
+am__libos_types_a_SOURCES_DIST = os/kstore/kstore_types.cc \
+	os/Transaction.cc os/bluestore/bluestore_types.cc \
+	os/bluestore/bluefs_types.cc
+ at WITH_LIBAIO_TRUE@am__objects_8 = os/bluestore/libos_types_a-bluestore_types.$(OBJEXT) \
+ at WITH_LIBAIO_TRUE@	os/bluestore/libos_types_a-bluefs_types.$(OBJEXT)
+am_libos_types_a_OBJECTS =  \
+	os/kstore/libos_types_a-kstore_types.$(OBJEXT) \
+	os/libos_types_a-Transaction.$(OBJEXT) $(am__objects_8)
 libos_types_a_OBJECTS = $(am_libos_types_a_OBJECTS)
 libos_zfs_a_AR = $(AR) $(ARFLAGS)
 libos_zfs_a_LIBADD =
-am__libos_zfs_a_SOURCES_DIST = os/ZFS.cc
- at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am_libos_zfs_a_OBJECTS = os/libos_zfs_a-ZFS.$(OBJEXT)
+am__libos_zfs_a_SOURCES_DIST = os/fs/ZFS.cc
+ at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at am_libos_zfs_a_OBJECTS = os/fs/libos_zfs_a-ZFS.$(OBJEXT)
 libos_zfs_a_OBJECTS = $(am_libos_zfs_a_OBJECTS)
 libosd_a_AR = $(AR) $(ARFLAGS)
 libosd_a_DEPENDENCIES =
@@ -1276,11 +1316,11 @@ am__uninstall_files_from_dir = { \
     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
          $(am__cd) "$$dir" && rm -f $$files; }; \
   }
-am__installdirs = "$(DESTDIR)$(erasure_codelibdir)" \
-	"$(DESTDIR)$(libdir)" "$(DESTDIR)$(radoslibdir)" \
-	"$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" \
-	"$(DESTDIR)$(su_sbindir)" "$(DESTDIR)$(bindir)" \
-	"$(DESTDIR)$(ceph_libexecdir)" \
+am__installdirs = "$(DESTDIR)$(compressorlibdir)" \
+	"$(DESTDIR)$(erasure_codelibdir)" "$(DESTDIR)$(libdir)" \
+	"$(DESTDIR)$(radoslibdir)" "$(DESTDIR)$(bindir)" \
+	"$(DESTDIR)$(sbindir)" "$(DESTDIR)$(su_sbindir)" \
+	"$(DESTDIR)$(bindir)" "$(DESTDIR)$(ceph_libexecdir)" \
 	"$(DESTDIR)$(ceph_monstore_update_crushdir)" \
 	"$(DESTDIR)$(ceph_sbindir)" "$(DESTDIR)$(bindir)" \
 	"$(DESTDIR)$(sbindir)" "$(DESTDIR)$(shell_commondir)" \
@@ -1290,7 +1330,8 @@ am__installdirs = "$(DESTDIR)$(erasure_codelibdir)" \
 	"$(DESTDIR)$(librbd_includedir)" \
 	"$(DESTDIR)$(rados_includedir)" \
 	"$(DESTDIR)$(radosstriper_includedir)"
-LTLIBRARIES = $(erasure_codelib_LTLIBRARIES) $(lib_LTLIBRARIES) \
+LTLIBRARIES = $(compressorlib_LTLIBRARIES) \
+	$(erasure_codelib_LTLIBRARIES) $(lib_LTLIBRARIES) \
 	$(noinst_LTLIBRARIES) $(radoslib_LTLIBRARIES)
 libarch_la_LIBADD =
 am_libarch_la_OBJECTS = arch/intel.lo arch/arm.lo arch/probe.lo
@@ -1313,6 +1354,31 @@ am_libauth_la_OBJECTS = auth/AuthAuthorizeHandler.lo \
 libauth_la_OBJECTS = $(am_libauth_la_OBJECTS)
 am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libceph_example_la_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCRUSH) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_3)
+am__libceph_example_la_SOURCES_DIST = compressor/Compressor.cc \
+	test/compressor/compressor_plugin_example.cc
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_libceph_example_la_OBJECTS = compressor/libceph_example_la-Compressor.lo \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/compressor/libceph_example_la-compressor_plugin_example.lo
+libceph_example_la_OBJECTS = $(am_libceph_example_la_OBJECTS)
+libceph_example_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(libceph_example_la_CXXFLAGS) $(CXXFLAGS) \
+	$(libceph_example_la_LDFLAGS) $(LDFLAGS) -o $@
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_libceph_example_la_rpath =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	-rpath $(compressorlibdir)
+libceph_snappy_la_DEPENDENCIES = $(LIBCRUSH) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_3)
+am__objects_9 = compressor/libceph_snappy_la-Compressor.lo \
+	compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo
+am_libceph_snappy_la_OBJECTS = $(am__objects_9)
+libceph_snappy_la_OBJECTS = $(am_libceph_snappy_la_OBJECTS)
+libceph_snappy_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(libceph_snappy_la_CXXFLAGS) $(CXXFLAGS) \
+	$(libceph_snappy_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at libcephfs_la_DEPENDENCIES = $(LIBCLIENT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
@@ -1359,12 +1425,13 @@ libcivetweb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am__libclient_la_SOURCES_DIST = client/Client.cc client/Inode.cc \
 	client/Dentry.cc client/MetaRequest.cc \
 	client/ClientSnapRealm.cc client/MetaSession.cc \
-	client/Trace.cc
+	client/Trace.cc client/posix_acl.cc
 @ENABLE_CLIENT_TRUE at am_libclient_la_OBJECTS = client/Client.lo \
 @ENABLE_CLIENT_TRUE@	client/Inode.lo client/Dentry.lo \
 @ENABLE_CLIENT_TRUE@	client/MetaRequest.lo \
 @ENABLE_CLIENT_TRUE@	client/ClientSnapRealm.lo \
- at ENABLE_CLIENT_TRUE@	client/MetaSession.lo client/Trace.lo
+ at ENABLE_CLIENT_TRUE@	client/MetaSession.lo client/Trace.lo \
+ at ENABLE_CLIENT_TRUE@	client/posix_acl.lo
 libclient_la_OBJECTS = $(am_libclient_la_OBJECTS)
 @ENABLE_CLIENT_TRUE at am_libclient_la_rpath =
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE at libclient_fuse_la_DEPENDENCIES =  \
@@ -1644,9 +1711,9 @@ libcls_version_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_libcls_version_la_rpath =  \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	-rpath $(radoslibdir)
 am__DEPENDENCIES_4 = libcommon_internal.la libcommon_crc.la \
-	$(am__append_101) $(LIBERASURE_CODE) $(LIBMSG) $(LIBAUTH) \
-	$(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+	$(am__append_106) $(LIBERASURE_CODE) $(LIBCOMPRESSOR) \
+	$(LIBMSG) $(LIBAUTH) $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) \
+	$(LIBARCH) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 libcommon_la_DEPENDENCIES = $(am__DEPENDENCIES_4)
 am_libcommon_la_OBJECTS = common/buffer.lo
 libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
@@ -1655,12 +1722,12 @@ am__libcommon_crc_la_SOURCES_DIST = common/sctp_crc32.c \
 	common/crc32c.cc common/crc32c_intel_baseline.c \
 	common/crc32c_intel_fast.c common/crc32c_intel_fast_asm.S \
 	common/crc32c_intel_fast_zero_asm.S
- at WITH_GOOD_YASM_ELF64_TRUE@am__objects_9 = common/libcommon_crc_la-crc32c_intel_fast_asm.lo \
+ at WITH_GOOD_YASM_ELF64_TRUE@am__objects_10 = common/libcommon_crc_la-crc32c_intel_fast_asm.lo \
 @WITH_GOOD_YASM_ELF64_TRUE@	common/libcommon_crc_la-crc32c_intel_fast_zero_asm.lo
 am_libcommon_crc_la_OBJECTS = common/libcommon_crc_la-sctp_crc32.lo \
 	common/libcommon_crc_la-crc32c.lo \
 	common/libcommon_crc_la-crc32c_intel_baseline.lo \
-	common/libcommon_crc_la-crc32c_intel_fast.lo $(am__objects_9)
+	common/libcommon_crc_la-crc32c_intel_fast.lo $(am__objects_10)
 libcommon_crc_la_OBJECTS = $(am_libcommon_crc_la_OBJECTS)
 libcommon_crc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(libcommon_crc_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -1683,20 +1750,21 @@ am__libcommon_internal_la_SOURCES_DIST = ceph_ver.c \
 	common/BackTrace.cc common/perf_counters.cc common/Mutex.cc \
 	common/OutputDataSocket.cc common/admin_socket.cc \
 	common/admin_socket_client.cc common/cmdparse.cc \
-	common/escape.c common/io_priority.cc common/Clock.cc \
-	common/Throttle.cc common/Timer.cc common/Finisher.cc \
-	common/environment.cc common/assert.cc common/run_cmd.cc \
-	common/WorkQueue.cc common/ConfUtils.cc common/MemoryModel.cc \
-	common/armor.c common/fd.cc common/safe_io.c \
-	common/snap_types.cc common/str_list.cc common/str_map.cc \
-	common/errno.cc common/RefCountedObj.cc common/common_init.cc \
-	common/pipe.c common/ceph_argparse.cc common/ceph_context.cc \
-	common/types.cc common/code_environment.cc common/dout.cc \
-	common/histogram.cc common/signal.cc common/simple_spin.cc \
-	common/Thread.cc common/Formatter.cc common/HeartbeatMap.cc \
-	common/config.cc common/utf8.c common/mime.c common/strtol.cc \
-	common/page.cc common/lockdep.cc common/version.cc \
-	common/hex.cc common/entity_name.cc common/ceph_crypto.cc \
+	common/escape.c common/io_priority.cc common/ceph_time.cc \
+	common/Clock.cc common/Throttle.cc common/Timer.cc \
+	common/Finisher.cc common/environment.cc common/assert.cc \
+	common/run_cmd.cc common/WorkQueue.cc common/ConfUtils.cc \
+	common/MemoryModel.cc common/armor.c common/fd.cc \
+	common/safe_io.c common/snap_types.cc common/str_list.cc \
+	common/str_map.cc common/errno.cc common/RefCountedObj.cc \
+	common/common_init.cc common/pipe.c common/ceph_argparse.cc \
+	common/ceph_context.cc common/types.cc \
+	common/code_environment.cc common/dout.cc common/histogram.cc \
+	common/signal.cc common/simple_spin.cc common/Thread.cc \
+	common/Formatter.cc common/HeartbeatMap.cc common/config.cc \
+	common/utf8.c common/mime.c common/strtol.cc common/page.cc \
+	common/lockdep.cc common/version.cc common/hex.cc \
+	common/entity_name.cc common/ceph_crypto.cc \
 	common/ceph_crypto_cms.cc common/TextTable.cc \
 	common/ceph_fs.cc common/ceph_hash.cc common/ceph_strings.cc \
 	common/ceph_frag.cc common/addr_parsing.c common/hobject.cc \
@@ -1710,48 +1778,47 @@ am__libcommon_internal_la_SOURCES_DIST = ceph_ver.c \
 	mon/MonMap.cc osd/OSDMap.cc osd/osd_types.cc osd/ECMsgTypes.cc \
 	osd/HitSet.cc mds/MDSMap.cc mds/inode_backtrace.cc \
 	mds/mdstypes.cc mds/flock.cc
- at ENABLE_SERVER_TRUE@am__objects_10 = common/xattr.lo common/ipaddr.lo \
+ at ENABLE_SERVER_TRUE@am__objects_11 = common/xattr.lo common/ipaddr.lo \
 @ENABLE_SERVER_TRUE@	common/ceph_json.lo common/util.lo \
 @ENABLE_SERVER_TRUE@	common/pick_address.lo
- at LINUX_TRUE@am__objects_11 = common/linux_version.lo
- at SOLARIS_TRUE@am__objects_12 = common/solaris_errno.lo
- at AIX_TRUE@am__objects_13 = common/aix_errno.lo
- at LINUX_TRUE@am__objects_14 = common/blkdev.lo
- at ENABLE_XIO_TRUE@am__objects_15 = common/address_helper.lo
+ at LINUX_TRUE@am__objects_12 = common/linux_version.lo
+ at SOLARIS_TRUE@am__objects_13 = common/solaris_errno.lo
+ at AIX_TRUE@am__objects_14 = common/aix_errno.lo
+ at LINUX_TRUE@am__objects_15 = common/blkdev.lo
+ at ENABLE_XIO_TRUE@am__objects_16 = common/address_helper.lo
 am_libcommon_internal_la_OBJECTS = ceph_ver.lo common/DecayCounter.lo \
 	common/LogClient.lo common/LogEntry.lo \
 	common/PrebufferedStreambuf.lo common/SloppyCRCMap.lo \
 	common/BackTrace.lo common/perf_counters.lo common/Mutex.lo \
 	common/OutputDataSocket.lo common/admin_socket.lo \
 	common/admin_socket_client.lo common/cmdparse.lo \
-	common/escape.lo common/io_priority.lo common/Clock.lo \
-	common/Throttle.lo common/Timer.lo common/Finisher.lo \
-	common/environment.lo common/assert.lo common/run_cmd.lo \
-	common/WorkQueue.lo common/ConfUtils.lo common/MemoryModel.lo \
-	common/armor.lo common/fd.lo common/safe_io.lo \
-	common/snap_types.lo common/str_list.lo common/str_map.lo \
-	common/errno.lo common/RefCountedObj.lo common/common_init.lo \
-	common/pipe.lo common/ceph_argparse.lo common/ceph_context.lo \
-	common/types.lo common/code_environment.lo common/dout.lo \
-	common/histogram.lo common/signal.lo common/simple_spin.lo \
-	common/Thread.lo common/Formatter.lo common/HeartbeatMap.lo \
-	common/config.lo common/utf8.lo common/mime.lo \
-	common/strtol.lo common/page.lo common/lockdep.lo \
-	common/version.lo common/hex.lo common/entity_name.lo \
-	common/ceph_crypto.lo common/ceph_crypto_cms.lo \
-	common/TextTable.lo common/ceph_fs.lo common/ceph_hash.lo \
-	common/ceph_strings.lo common/ceph_frag.lo \
-	common/addr_parsing.lo common/hobject.lo \
+	common/escape.lo common/io_priority.lo common/ceph_time.lo \
+	common/Clock.lo common/Throttle.lo common/Timer.lo \
+	common/Finisher.lo common/environment.lo common/assert.lo \
+	common/run_cmd.lo common/WorkQueue.lo common/ConfUtils.lo \
+	common/MemoryModel.lo common/armor.lo common/fd.lo \
+	common/safe_io.lo common/snap_types.lo common/str_list.lo \
+	common/str_map.lo common/errno.lo common/RefCountedObj.lo \
+	common/common_init.lo common/pipe.lo common/ceph_argparse.lo \
+	common/ceph_context.lo common/types.lo \
+	common/code_environment.lo common/dout.lo common/histogram.lo \
+	common/signal.lo common/simple_spin.lo common/Thread.lo \
+	common/Formatter.lo common/HeartbeatMap.lo common/config.lo \
+	common/utf8.lo common/mime.lo common/strtol.lo common/page.lo \
+	common/lockdep.lo common/version.lo common/hex.lo \
+	common/entity_name.lo common/ceph_crypto.lo \
+	common/ceph_crypto_cms.lo common/TextTable.lo \
+	common/ceph_fs.lo common/ceph_hash.lo common/ceph_strings.lo \
+	common/ceph_frag.lo common/addr_parsing.lo common/hobject.lo \
 	common/bloom_filter.lo common/module.lo common/Readahead.lo \
 	common/Cycles.lo common/ContextCompletion.lo \
 	common/TracepointProvider.lo common/PluginRegistry.lo \
-	$(am__objects_10) $(am__objects_11) $(am__objects_12) \
-	$(am__objects_13) $(am__objects_14) $(am__objects_15) \
+	$(am__objects_11) $(am__objects_12) $(am__objects_13) \
+	$(am__objects_14) $(am__objects_15) $(am__objects_16) \
 	mon/MonCap.lo mon/MonClient.lo mon/MonMap.lo osd/OSDMap.lo \
 	osd/osd_types.lo osd/ECMsgTypes.lo osd/HitSet.lo mds/MDSMap.lo \
 	mds/inode_backtrace.lo mds/mdstypes.lo mds/flock.lo
 libcommon_internal_la_OBJECTS = $(am_libcommon_internal_la_OBJECTS)
-libcompressor_la_DEPENDENCIES = $(LIBCOMMON)
 am_libcompressor_la_OBJECTS = compressor/Compressor.lo \
 	compressor/AsyncCompressor.lo
 libcompressor_la_OBJECTS = $(am_libcompressor_la_OBJECTS)
@@ -1867,7 +1934,7 @@ am__libec_isa_la_SOURCES_DIST = erasure-code/ErasureCode.cc \
 	erasure-code/isa/ErasureCodeIsaTableCache.cc \
 	erasure-code/isa/ErasureCodePluginIsa.cc \
 	erasure-code/isa/xor_op.cc
- at WITH_BETTER_YASM_ELF64_TRUE@am__objects_16 = erasure-code/libec_isa_la-ErasureCode.lo \
+ at WITH_BETTER_YASM_ELF64_TRUE@am__objects_17 = erasure-code/libec_isa_la-ErasureCode.lo \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/isa-l/erasure_code/libec_isa_la-ec_base.lo \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/isa-l/erasure_code/libec_isa_la-ec_highlevel_func.lo \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/isa-l/erasure_code/libec_isa_la-ec_multibinary.asm.lo \
@@ -1914,7 +1981,7 @@ am__libec_isa_la_SOURCES_DIST = erasure-code/ErasureCode.cc \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/libec_isa_la-ErasureCodePluginIsa.lo \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/libec_isa_la-xor_op.lo
 @WITH_BETTER_YASM_ELF64_TRUE at am_libec_isa_la_OBJECTS =  \
- at WITH_BETTER_YASM_ELF64_TRUE@	$(am__objects_16)
+ at WITH_BETTER_YASM_ELF64_TRUE@	$(am__objects_17)
 libec_isa_la_OBJECTS = $(am_libec_isa_la_OBJECTS)
 libec_isa_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(libec_isa_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -1932,7 +1999,7 @@ libec_jerasure_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(libec_jerasure_la_LDFLAGS) $(LDFLAGS) -o $@
 libec_jerasure_generic_la_DEPENDENCIES = $(LIBCRUSH) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
-am__objects_17 =  \
+am__objects_18 =  \
 	erasure-code/libec_jerasure_generic_la-ErasureCode.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_generic_la-cauchy.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_generic_la-galois.lo \
@@ -1952,7 +2019,7 @@ am__objects_17 =  \
 	erasure-code/jerasure/gf-complete/src/libec_jerasure_generic_la-gf_w8.lo \
 	erasure-code/jerasure/libec_jerasure_generic_la-ErasureCodePluginJerasure.lo \
 	erasure-code/jerasure/libec_jerasure_generic_la-ErasureCodeJerasure.lo
-am_libec_jerasure_generic_la_OBJECTS = $(am__objects_17)
+am_libec_jerasure_generic_la_OBJECTS = $(am__objects_18)
 libec_jerasure_generic_la_OBJECTS =  \
 	$(am_libec_jerasure_generic_la_OBJECTS)
 libec_jerasure_generic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
@@ -1961,7 +2028,7 @@ libec_jerasure_generic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(libec_jerasure_generic_la_LDFLAGS) $(LDFLAGS) -o $@
 libec_jerasure_neon_la_DEPENDENCIES = $(LIBCRUSH) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
-am__objects_18 = erasure-code/libec_jerasure_neon_la-ErasureCode.lo \
+am__objects_19 = erasure-code/libec_jerasure_neon_la-ErasureCode.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_neon_la-cauchy.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_neon_la-galois.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_neon_la-jerasure.lo \
@@ -1980,7 +2047,7 @@ am__objects_18 = erasure-code/libec_jerasure_neon_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_jerasure_neon_la-gf_w8.lo \
 	erasure-code/jerasure/libec_jerasure_neon_la-ErasureCodePluginJerasure.lo \
 	erasure-code/jerasure/libec_jerasure_neon_la-ErasureCodeJerasure.lo
-am_libec_jerasure_neon_la_OBJECTS = $(am__objects_18) \
+am_libec_jerasure_neon_la_OBJECTS = $(am__objects_19) \
 	erasure-code/jerasure/gf-complete/src/neon/libec_jerasure_neon_la-gf_w4_neon.lo \
 	erasure-code/jerasure/gf-complete/src/neon/libec_jerasure_neon_la-gf_w8_neon.lo \
 	erasure-code/jerasure/gf-complete/src/neon/libec_jerasure_neon_la-gf_w16_neon.lo \
@@ -1995,7 +2062,7 @@ libec_jerasure_neon_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 @HAVE_NEON_TRUE@	$(erasure_codelibdir)
 libec_jerasure_sse3_la_DEPENDENCIES = $(LIBCRUSH) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
-am__objects_19 = erasure-code/libec_jerasure_sse3_la-ErasureCode.lo \
+am__objects_20 = erasure-code/libec_jerasure_sse3_la-ErasureCode.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_sse3_la-cauchy.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_sse3_la-galois.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_sse3_la-jerasure.lo \
@@ -2014,7 +2081,7 @@ am__objects_19 = erasure-code/libec_jerasure_sse3_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_jerasure_sse3_la-gf_w8.lo \
 	erasure-code/jerasure/libec_jerasure_sse3_la-ErasureCodePluginJerasure.lo \
 	erasure-code/jerasure/libec_jerasure_sse3_la-ErasureCodeJerasure.lo
-am_libec_jerasure_sse3_la_OBJECTS = $(am__objects_19)
+am_libec_jerasure_sse3_la_OBJECTS = $(am__objects_20)
 libec_jerasure_sse3_la_OBJECTS = $(am_libec_jerasure_sse3_la_OBJECTS)
 libec_jerasure_sse3_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -2024,7 +2091,7 @@ libec_jerasure_sse3_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 @HAVE_SSSE3_TRUE@	$(erasure_codelibdir)
 libec_jerasure_sse4_la_DEPENDENCIES = $(LIBCRUSH) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
-am__objects_20 = erasure-code/libec_jerasure_sse4_la-ErasureCode.lo \
+am__objects_21 = erasure-code/libec_jerasure_sse4_la-ErasureCode.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_sse4_la-cauchy.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_sse4_la-galois.lo \
 	erasure-code/jerasure/jerasure/src/libec_jerasure_sse4_la-jerasure.lo \
@@ -2043,7 +2110,7 @@ am__objects_20 = erasure-code/libec_jerasure_sse4_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_jerasure_sse4_la-gf_w8.lo \
 	erasure-code/jerasure/libec_jerasure_sse4_la-ErasureCodePluginJerasure.lo \
 	erasure-code/jerasure/libec_jerasure_sse4_la-ErasureCodeJerasure.lo
-am_libec_jerasure_sse4_la_OBJECTS = $(am__objects_20)
+am_libec_jerasure_sse4_la_OBJECTS = $(am__objects_21)
 libec_jerasure_sse4_la_OBJECTS = $(am_libec_jerasure_sse4_la_OBJECTS)
 libec_jerasure_sse4_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -2053,10 +2120,10 @@ libec_jerasure_sse4_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 @HAVE_SSE4_PCLMUL_TRUE@	$(erasure_codelibdir)
 libec_lrc_la_DEPENDENCIES = $(LIBCRUSH) $(am__DEPENDENCIES_1) \
 	$(LIBJSON_SPIRIT)
-am__objects_21 = erasure-code/libec_lrc_la-ErasureCode.lo \
+am__objects_22 = erasure-code/libec_lrc_la-ErasureCode.lo \
 	erasure-code/lrc/libec_lrc_la-ErasureCodePluginLrc.lo \
 	erasure-code/lrc/libec_lrc_la-ErasureCodeLrc.lo
-am_libec_lrc_la_OBJECTS = $(am__objects_21) \
+am_libec_lrc_la_OBJECTS = $(am__objects_22) \
 	common/libec_lrc_la-str_map.lo
 libec_lrc_la_OBJECTS = $(am_libec_lrc_la_OBJECTS)
 libec_lrc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -2102,7 +2169,7 @@ libec_shec_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(LDFLAGS) -o $@
 libec_shec_generic_la_DEPENDENCIES = $(LIBCRUSH) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_3)
-am__objects_22 = erasure-code/libec_shec_generic_la-ErasureCode.lo \
+am__objects_23 = erasure-code/libec_shec_generic_la-ErasureCode.lo \
 	erasure-code/shec/libec_shec_generic_la-ErasureCodePluginShec.lo \
 	erasure-code/shec/libec_shec_generic_la-ErasureCodeShec.lo \
 	erasure-code/shec/libec_shec_generic_la-ErasureCodeShecTableCache.lo \
@@ -2123,7 +2190,7 @@ am__objects_22 = erasure-code/libec_shec_generic_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_generic_la-gf_w4.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_generic_la-gf_rand.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_generic_la-gf_w8.lo
-am_libec_shec_generic_la_OBJECTS = $(am__objects_22)
+am_libec_shec_generic_la_OBJECTS = $(am__objects_23)
 libec_shec_generic_la_OBJECTS = $(am_libec_shec_generic_la_OBJECTS)
 libec_shec_generic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -2131,7 +2198,7 @@ libec_shec_generic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(libec_shec_generic_la_LDFLAGS) $(LDFLAGS) -o $@
 libec_shec_neon_la_DEPENDENCIES = $(LIBCRUSH) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_3)
-am__objects_23 = erasure-code/libec_shec_neon_la-ErasureCode.lo \
+am__objects_24 = erasure-code/libec_shec_neon_la-ErasureCode.lo \
 	erasure-code/shec/libec_shec_neon_la-ErasureCodePluginShec.lo \
 	erasure-code/shec/libec_shec_neon_la-ErasureCodeShec.lo \
 	erasure-code/shec/libec_shec_neon_la-ErasureCodeShecTableCache.lo \
@@ -2152,7 +2219,7 @@ am__objects_23 = erasure-code/libec_shec_neon_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_neon_la-gf_w4.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_neon_la-gf_rand.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_neon_la-gf_w8.lo
-am_libec_shec_neon_la_OBJECTS = $(am__objects_23) \
+am_libec_shec_neon_la_OBJECTS = $(am__objects_24) \
 	erasure-code/jerasure/gf-complete/src/neon/libec_shec_neon_la-gf_w4_neon.lo \
 	erasure-code/jerasure/gf-complete/src/neon/libec_shec_neon_la-gf_w8_neon.lo \
 	erasure-code/jerasure/gf-complete/src/neon/libec_shec_neon_la-gf_w16_neon.lo \
@@ -2167,7 +2234,7 @@ libec_shec_neon_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 @HAVE_NEON_TRUE@	$(erasure_codelibdir)
 libec_shec_sse3_la_DEPENDENCIES = $(LIBCRUSH) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_3)
-am__objects_24 = erasure-code/libec_shec_sse3_la-ErasureCode.lo \
+am__objects_25 = erasure-code/libec_shec_sse3_la-ErasureCode.lo \
 	erasure-code/shec/libec_shec_sse3_la-ErasureCodePluginShec.lo \
 	erasure-code/shec/libec_shec_sse3_la-ErasureCodeShec.lo \
 	erasure-code/shec/libec_shec_sse3_la-ErasureCodeShecTableCache.lo \
@@ -2188,7 +2255,7 @@ am__objects_24 = erasure-code/libec_shec_sse3_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_sse3_la-gf_w4.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_sse3_la-gf_rand.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_sse3_la-gf_w8.lo
-am_libec_shec_sse3_la_OBJECTS = $(am__objects_24)
+am_libec_shec_sse3_la_OBJECTS = $(am__objects_25)
 libec_shec_sse3_la_OBJECTS = $(am_libec_shec_sse3_la_OBJECTS)
 libec_shec_sse3_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -2198,7 +2265,7 @@ libec_shec_sse3_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 @HAVE_SSSE3_TRUE@	$(erasure_codelibdir)
 libec_shec_sse4_la_DEPENDENCIES = $(LIBCRUSH) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_3)
-am__objects_25 = erasure-code/libec_shec_sse4_la-ErasureCode.lo \
+am__objects_26 = erasure-code/libec_shec_sse4_la-ErasureCode.lo \
 	erasure-code/shec/libec_shec_sse4_la-ErasureCodePluginShec.lo \
 	erasure-code/shec/libec_shec_sse4_la-ErasureCodeShec.lo \
 	erasure-code/shec/libec_shec_sse4_la-ErasureCodeShecTableCache.lo \
@@ -2219,7 +2286,7 @@ am__objects_25 = erasure-code/libec_shec_sse4_la-ErasureCode.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_sse4_la-gf_w4.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_sse4_la-gf_rand.lo \
 	erasure-code/jerasure/gf-complete/src/libec_shec_sse4_la-gf_w8.lo
-am_libec_shec_sse4_la_OBJECTS = $(am__objects_25)
+am_libec_shec_sse4_la_OBJECTS = $(am__objects_26)
 libec_shec_sse4_la_OBJECTS = $(am_libec_shec_sse4_la_OBJECTS)
 libec_shec_sse4_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -2402,7 +2469,7 @@ am__libmds_la_SOURCES_DIST = mds/Capability.cc mds/MDSDaemon.cc \
 	mds/SnapRealm.cc mds/SnapServer.cc mds/snap.cc \
 	mds/SessionMap.cc mds/MDSContext.cc mds/MDSAuthCaps.cc \
 	mds/MDLog.cc
-am__objects_26 = mds/Capability.lo mds/MDSDaemon.lo mds/MDSRank.lo \
+am__objects_27 = mds/Capability.lo mds/MDSDaemon.lo mds/MDSRank.lo \
 	mds/Beacon.lo mds/locks.lo mds/journal.lo mds/Server.lo \
 	mds/Mutation.lo mds/MDCache.lo mds/RecoveryQueue.lo \
 	mds/StrayManager.lo mds/Locker.lo mds/Migrator.lo \
@@ -2414,7 +2481,7 @@ am__objects_26 = mds/Capability.lo mds/MDSDaemon.lo mds/MDSRank.lo \
 	mds/SessionMap.lo mds/MDSContext.lo mds/MDSAuthCaps.lo \
 	mds/MDLog.lo
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am_libmds_la_OBJECTS =  \
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__objects_26)
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__objects_27)
 libmds_la_OBJECTS = $(am_libmds_la_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am_libmds_la_rpath =
 libmon_types_la_LIBADD =
@@ -2432,11 +2499,11 @@ am__libmsg_la_SOURCES_DIST = msg/Message.cc msg/Messenger.cc \
 	msg/async/EventKqueue.h msg/xio/QueueStrategy.cc \
 	msg/xio/XioConnection.cc msg/xio/XioMessenger.cc \
 	msg/xio/XioMsg.cc msg/xio/XioPortal.cc msg/xio/XioPool.cc
- at LINUX_TRUE@am__objects_27 = msg/async/EventEpoll.lo
- at DARWIN_TRUE@am__objects_28 = msg/async/EventKqueue.lo
- at FREEBSD_TRUE@am__objects_29 = msg/async/EventKqueue.lo
-am__objects_30 =
- at ENABLE_XIO_TRUE@am__objects_31 = msg/xio/QueueStrategy.lo \
+ at LINUX_TRUE@am__objects_28 = msg/async/EventEpoll.lo
+ at DARWIN_TRUE@am__objects_29 = msg/async/EventKqueue.lo
+ at FREEBSD_TRUE@am__objects_30 = msg/async/EventKqueue.lo
+am__objects_31 =
+ at ENABLE_XIO_TRUE@am__objects_32 = msg/xio/QueueStrategy.lo \
 @ENABLE_XIO_TRUE@	msg/xio/XioConnection.lo \
 @ENABLE_XIO_TRUE@	msg/xio/XioMessenger.lo msg/xio/XioMsg.lo \
 @ENABLE_XIO_TRUE@	msg/xio/XioPortal.lo msg/xio/XioPool.lo
@@ -2446,9 +2513,9 @@ am_libmsg_la_OBJECTS = msg/Message.lo msg/Messenger.lo \
 	msg/simple/PipeConnection.lo msg/simple/SimpleMessenger.lo \
 	msg/async/AsyncConnection.lo msg/async/AsyncMessenger.lo \
 	msg/async/Event.lo msg/async/net_handler.lo \
-	msg/async/EventSelect.lo $(am__objects_27) $(am__objects_28) \
-	$(am__objects_29) $(am__objects_30) $(am__objects_30) \
-	$(am__objects_30) $(am__objects_31)
+	msg/async/EventSelect.lo $(am__objects_28) $(am__objects_29) \
+	$(am__objects_30) $(am__objects_31) $(am__objects_31) \
+	$(am__objects_31) $(am__objects_32)
 libmsg_la_OBJECTS = $(am_libmsg_la_OBJECTS)
 libos_tp_la_DEPENDENCIES =
 am__libos_tp_la_SOURCES_DIST = tracing/objectstore.c
@@ -2491,13 +2558,13 @@ libperfglue_la_DEPENDENCIES =
 am__libperfglue_la_SOURCES_DIST = perfglue/heap_profiler.cc \
 	perfglue/disabled_heap_profiler.cc perfglue/cpu_profiler.cc \
 	perfglue/disabled_stubs.cc
- at WITH_TCMALLOC_TRUE@am__objects_32 = perfglue/heap_profiler.lo
- at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__objects_33 = perfglue/heap_profiler.lo
- at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_FALSE at am__objects_34 = perfglue/disabled_heap_profiler.lo
- at WITH_PROFILER_TRUE@am__objects_35 = perfglue/cpu_profiler.lo
- at WITH_PROFILER_FALSE@am__objects_36 = perfglue/disabled_stubs.lo
-am_libperfglue_la_OBJECTS = $(am__objects_32) $(am__objects_33) \
-	$(am__objects_34) $(am__objects_35) $(am__objects_36)
+ at WITH_TCMALLOC_TRUE@am__objects_33 = perfglue/heap_profiler.lo
+ at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at am__objects_34 = perfglue/heap_profiler.lo
+ at WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_FALSE at am__objects_35 = perfglue/disabled_heap_profiler.lo
+ at WITH_PROFILER_TRUE@am__objects_36 = perfglue/cpu_profiler.lo
+ at WITH_PROFILER_FALSE@am__objects_37 = perfglue/disabled_stubs.lo
+am_libperfglue_la_OBJECTS = $(am__objects_33) $(am__objects_34) \
+	$(am__objects_35) $(am__objects_36) $(am__objects_37)
 libperfglue_la_OBJECTS = $(am_libperfglue_la_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__DEPENDENCIES_5 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_internal.la \
@@ -2591,7 +2658,11 @@ libradosstriper_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(libradosstriper_la_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am_libradosstriper_la_rpath = -rpath \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(libdir)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at libradosstripertest_la_DEPENDENCIES = $(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__DEPENDENCIES_8 =  \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libradostest.la \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at libradosstripertest_la_DEPENDENCIES = $(am__DEPENDENCIES_8)
 am__libradosstripertest_la_SOURCES_DIST =  \
 	test/libradosstriper/TestCase.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at am_libradosstripertest_la_OBJECTS = test/libradosstriper/libradosstripertest_la-TestCase.lo
@@ -2646,14 +2717,15 @@ am__librbd_internal_la_SOURCES_DIST = librbd/AioCompletion.cc \
 	librbd/CopyupRequest.cc librbd/DiffIterate.cc \
 	librbd/ExclusiveLock.cc librbd/ImageCtx.cc \
 	librbd/ImageState.cc librbd/ImageWatcher.cc librbd/internal.cc \
-	librbd/Journal.cc librbd/JournalReplay.cc \
-	librbd/LibrbdAdminSocketHook.cc librbd/LibrbdWriteback.cc \
-	librbd/ObjectMap.cc librbd/Utils.cc \
+	librbd/Journal.cc librbd/LibrbdAdminSocketHook.cc \
+	librbd/LibrbdWriteback.cc librbd/ObjectMap.cc \
+	librbd/Operations.cc librbd/Utils.cc \
 	librbd/exclusive_lock/AcquireRequest.cc \
 	librbd/exclusive_lock/ReleaseRequest.cc \
 	librbd/image/CloseRequest.cc librbd/image/OpenRequest.cc \
 	librbd/image/RefreshParentRequest.cc \
 	librbd/image/RefreshRequest.cc librbd/image/SetSnapRequest.cc \
+	librbd/journal/Replay.cc \
 	librbd/object_map/InvalidateRequest.cc \
 	librbd/object_map/LockRequest.cc librbd/object_map/Request.cc \
 	librbd/object_map/RefreshRequest.cc \
@@ -2689,10 +2761,10 @@ am__librbd_internal_la_SOURCES_DIST = librbd/AioCompletion.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/ImageWatcher.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/internal.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Journal.lo \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/JournalReplay.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/LibrbdAdminSocketHook.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/LibrbdWriteback.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/ObjectMap.lo \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Operations.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Utils.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/exclusive_lock/AcquireRequest.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/exclusive_lock/ReleaseRequest.lo \
@@ -2701,6 +2773,7 @@ am__librbd_internal_la_SOURCES_DIST = librbd/AioCompletion.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/RefreshParentRequest.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/RefreshRequest.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/SetSnapRequest.lo \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/journal/Replay.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/InvalidateRequest.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/LockRequest.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/Request.lo \
@@ -2725,12 +2798,12 @@ am__librbd_internal_la_SOURCES_DIST = librbd/AioCompletion.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/operation/TrimRequest.lo
 librbd_internal_la_OBJECTS = $(am_librbd_internal_la_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am_librbd_internal_la_rpath =
-am__DEPENDENCIES_8 = $(LIBGLOBAL) $(LIBCOMMON) $(am__DEPENDENCIES_1) \
+am__DEPENDENCIES_9 = $(LIBGLOBAL) $(LIBCOMMON) $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at librbd_replay_la_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9)
 am__librbd_replay_la_SOURCES_DIST = rbd_replay/actions.cc \
 	rbd_replay/BufferReader.cc rbd_replay/ImageNameMap.cc \
 	rbd_replay/PendingIO.cc rbd_replay/rbd_loc.cc \
@@ -2746,7 +2819,7 @@ librbd_replay_la_OBJECTS = $(am_librbd_replay_la_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at librbd_replay_ios_la_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay.la
 am__librbd_replay_ios_la_SOURCES_DIST = rbd_replay/ios.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am_librbd_replay_ios_la_OBJECTS = rbd_replay/ios.lo
@@ -2761,17 +2834,17 @@ librbd_test_la_LIBADD =
 am__librbd_test_la_SOURCES_DIST = test/librbd/test_fixture.cc \
 	test/librbd/test_support.cc test/librbd/test_librbd.cc \
 	test/librbd/test_ImageWatcher.cc test/librbd/test_internal.cc \
-	test/librbd/test_JournalEntries.cc \
-	test/librbd/test_JournalReplay.cc \
-	test/librbd/test_ObjectMap.cc
+	test/librbd/test_ObjectMap.cc \
+	test/librbd/journal/test_Entries.cc \
+	test/librbd/journal/test_Replay.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am_librbd_test_la_OBJECTS = test/librbd/librbd_test_la-test_fixture.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_support.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_librbd.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_ImageWatcher.lo \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_internal.lo \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_JournalEntries.lo \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_JournalReplay.lo \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_ObjectMap.lo
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/librbd_test_la-test_ObjectMap.lo \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/journal/librbd_test_la-test_Entries.lo \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/journal/librbd_test_la-test_Replay.lo
 librbd_test_la_OBJECTS = $(am_librbd_test_la_OBJECTS)
 librbd_test_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -2790,7 +2863,7 @@ librbd_tp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(CFLAGS) $(librbd_tp_la_LDFLAGS) $(LDFLAGS) -o $@
 @WITH_LTTNG_TRUE at am_librbd_tp_la_rpath = -rpath $(libdir)
 librbd_types_la_LIBADD =
-am_librbd_types_la_OBJECTS = librbd/JournalTypes.lo \
+am_librbd_types_la_OBJECTS = librbd/journal/Entries.lo \
 	librbd/WatchNotifyTypes.lo
 librbd_types_la_OBJECTS = $(am_librbd_types_la_OBJECTS)
 librgw_la_LIBADD =
@@ -2852,7 +2925,7 @@ libsecret_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
 am_libsecret_la_OBJECTS = common/secret.lo
 libsecret_la_OBJECTS = $(am_libsecret_la_OBJECTS)
 @LINUX_TRUE at am_libsecret_la_rpath =
- at LINUX_TRUE@libsystest_la_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ at LINUX_TRUE@libsystest_la_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__libsystest_la_SOURCES_DIST = test/system/cross_process_sem.cc \
 	test/system/systest_runnable.cc \
 	test/system/systest_settings.cc
@@ -2926,7 +2999,6 @@ libsystest_la_OBJECTS = $(am_libsystest_la_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	ceph_test_cls_rgw$(EXEEXT)
 @ENABLE_SERVER_TRUE at am__EXEEXT_16 = ceph_test_async_driver$(EXEEXT) \
 @ENABLE_SERVER_TRUE@	ceph_test_msgr$(EXEEXT) \
- at ENABLE_SERVER_TRUE@	ceph_streamtest$(EXEEXT) \
 @ENABLE_SERVER_TRUE@	ceph_test_trans$(EXEEXT) \
 @ENABLE_SERVER_TRUE@	ceph_test_mon_workloadgen$(EXEEXT) \
 @ENABLE_SERVER_TRUE@	ceph_test_mon_msg$(EXEEXT) \
@@ -2975,78 +3047,85 @@ am__EXEEXT_27 = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
 	$(am__EXEEXT_24) $(am__EXEEXT_25) $(am__EXEEXT_26) \
 	ceph_psim$(EXEEXT)
 @WITH_DEBUG_TRUE at am__EXEEXT_28 = $(am__EXEEXT_27)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_29 = radosgw$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am__EXEEXT_29 = ceph-bluefs-tool$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_30 = radosgw$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	radosgw-admin$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	radosgw-object-expirer$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_30 = rbd-replay$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_BABELTRACE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_31 = rbd-replay-prep$(EXEEXT)
- at ENABLE_CLIENT_TRUE@am__EXEEXT_32 = ceph-dencoder$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_33 = rados$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_34 = rbd$(EXEEXT) \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_31 = rbd-replay$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_BABELTRACE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_32 = rbd-replay-prep$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@am__EXEEXT_33 = ceph-dencoder$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_34 = rados$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_35 = rbd$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	rbd-nbd$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_35 = ceph-objectstore-tool$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_36 = cephfs-journal-tool$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_36 = ceph-objectstore-tool$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_37 = cephfs-journal-tool$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	cephfs-table-tool$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	cephfs-data-scan$(EXEEXT)
- at ENABLE_CLIENT_TRUE@am__EXEEXT_37 = ceph-syn$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_38 =  \
+ at ENABLE_CLIENT_TRUE@am__EXEEXT_38 = ceph-syn$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_39 =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados-config$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_39 = ceph-fuse$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_40 = rbd-fuse$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_41 = cephfs$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__EXEEXT_42 = ceph-mon$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_43 = ceph-osd$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__EXEEXT_44 = ceph-mds$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_45 = unittest_erasure_code_plugin$(EXEEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_40 = ceph-fuse$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_41 = rbd-fuse$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_42 = cephfs$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__EXEEXT_43 = ceph-mon$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_44 = ceph-osd$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__EXEEXT_45 = ceph-mds$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_46 = unittest_erasure_code_plugin$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_jerasure$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_jerasure$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__EXEEXT_46 = unittest_erasure_code_isa$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at am__EXEEXT_47 = unittest_erasure_code_isa$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_isa$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_47 = unittest_erasure_code_lrc$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_48 = unittest_erasure_code_lrc$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_lrc$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec_all$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec_thread$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_shec_arguments$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_plugin_shec$(EXEEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_example$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_48 = unittest_librados$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_erasure_code_example$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_compression_plugin$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_compression_snappy$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_compression_plugin_snappy$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_49 = unittest_librados$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	unittest_librados_config$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	unittest_journal$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_49 = unittest_rbd_replay$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_50 = unittest_encoding$(EXEEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_50 = unittest_rbd_replay$(EXEEXT)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__EXEEXT_51 = unittest_encoding$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_base64$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_run_cmd$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_simple_spin$(EXEEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	unittest_libcephfs_config$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__EXEEXT_51 = unittest_mon_moncap$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__EXEEXT_52 =  \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	unittest_bluefs$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	unittest_bluestore_types$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__EXEEXT_53 = unittest_mon_moncap$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	unittest_mon_pgmap$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_52 = unittest_ecbackend$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_54 = unittest_ecbackend$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_osdscrub$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_pglog$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_hitset$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_osd_osdcap$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	unittest_pageset$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__EXEEXT_53 = unittest_rocksdb_option_static$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__EXEEXT_54 = unittest_rocksdb_option$(EXEEXT)
- at ENABLE_SERVER_TRUE@am__EXEEXT_55 = unittest_chain_xattr$(EXEEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am__EXEEXT_55 = unittest_rocksdb_option_static$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am__EXEEXT_56 = unittest_rocksdb_option$(EXEEXT)
+ at ENABLE_SERVER_TRUE@am__EXEEXT_57 = unittest_chain_xattr$(EXEEXT) \
 @ENABLE_SERVER_TRUE@	unittest_lfnindex$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__EXEEXT_56 = unittest_mds_authcap$(EXEEXT)
- at LINUX_TRUE@am__EXEEXT_57 = unittest_blkdev$(EXEEXT)
-am__EXEEXT_58 = $(am__EXEEXT_45) $(am__EXEEXT_46) $(am__EXEEXT_47) \
-	$(am__EXEEXT_48) $(am__EXEEXT_49) $(am__EXEEXT_50) \
-	$(am__EXEEXT_51) $(am__EXEEXT_52) $(am__EXEEXT_53) \
-	$(am__EXEEXT_54) $(am__EXEEXT_55) $(am__EXEEXT_56) \
-	unittest_addrs$(EXEEXT) $(am__EXEEXT_57) \
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am__EXEEXT_58 = unittest_mds_authcap$(EXEEXT)
+ at LINUX_TRUE@am__EXEEXT_59 = unittest_blkdev$(EXEEXT)
+am__EXEEXT_60 = $(am__EXEEXT_46) $(am__EXEEXT_47) $(am__EXEEXT_48) \
+	$(am__EXEEXT_49) $(am__EXEEXT_50) $(am__EXEEXT_51) \
+	$(am__EXEEXT_52) $(am__EXEEXT_53) $(am__EXEEXT_54) \
+	$(am__EXEEXT_55) $(am__EXEEXT_56) $(am__EXEEXT_57) \
+	$(am__EXEEXT_58) unittest_addrs$(EXEEXT) $(am__EXEEXT_59) \
 	unittest_bloom_filter$(EXEEXT) unittest_histogram$(EXEEXT) \
 	unittest_prioritized_queue$(EXEEXT) unittest_str_map$(EXEEXT) \
 	unittest_sharedptr_registry$(EXEEXT) \
 	unittest_shared_cache$(EXEEXT) \
-	unittest_sloppy_crc_map$(EXEEXT) unittest_util$(EXEEXT) \
-	unittest_crush_wrapper$(EXEEXT) unittest_crush$(EXEEXT) \
-	unittest_osdmap$(EXEEXT) unittest_workqueue$(EXEEXT) \
-	unittest_striper$(EXEEXT) \
+	unittest_sloppy_crc_map$(EXEEXT) unittest_time$(EXEEXT) \
+	unittest_util$(EXEEXT) unittest_crush_wrapper$(EXEEXT) \
+	unittest_crush$(EXEEXT) unittest_osdmap$(EXEEXT) \
+	unittest_workqueue$(EXEEXT) unittest_striper$(EXEEXT) \
 	unittest_prebufferedstreambuf$(EXEEXT) \
 	unittest_str_list$(EXEEXT) unittest_log$(EXEEXT) \
 	unittest_throttle$(EXEEXT) unittest_ceph_argparse$(EXEEXT) \
@@ -3067,30 +3146,41 @@ am__EXEEXT_58 = $(am__EXEEXT_45) $(am__EXEEXT_46) $(am__EXEEXT_47) \
 	unittest_texttable$(EXEEXT) unittest_on_exit$(EXEEXT) \
 	unittest_readahead$(EXEEXT) unittest_tableformatter$(EXEEXT) \
 	unittest_bit_vector$(EXEEXT)
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_59 = unittest_librbd$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_60 = ceph_erasure_code_non_regression$(EXEEXT)
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at am__EXEEXT_61 =  \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am__EXEEXT_61 = unittest_librbd$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am__EXEEXT_62 = ceph_erasure_code_non_regression$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at am__EXEEXT_63 =  \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	simple_server$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	simple_client$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	xio_server$(EXEEXT) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	xio_client$(EXEEXT)
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__EXEEXT_62 = get_command_descriptions$(EXEEXT)
- at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__EXEEXT_63 = mount.ceph$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am__EXEEXT_64 = get_command_descriptions$(EXEEXT)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am__EXEEXT_65 = mount.ceph$(EXEEXT)
 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(sbin_PROGRAMS) \
 	$(su_sbin_PROGRAMS)
 am_ceph_authtool_OBJECTS = tools/ceph_authtool.$(OBJEXT)
 ceph_authtool_OBJECTS = $(am_ceph_authtool_OBJECTS)
-ceph_authtool_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_authtool_DEPENDENCIES = $(am__DEPENDENCIES_9)
+am__ceph_bluefs_tool_SOURCES_DIST = os/bluestore/bluefs_tool.cc
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at am_ceph_bluefs_tool_OBJECTS = os/bluestore/bluefs_tool.$(OBJEXT)
+ceph_bluefs_tool_OBJECTS = $(am_ceph_bluefs_tool_OBJECTS)
+ at WITH_LIBZFS_TRUE@am__DEPENDENCIES_10 = libos_zfs.a
+am__DEPENDENCIES_11 = libkv.a $(am__append_26) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am__DEPENDENCIES_12 = libos.a $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_10) $(LIBOS_TYPES) $(am__DEPENDENCIES_11)
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at ceph_bluefs_tool_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_client_debug_SOURCES_DIST = tools/ceph-client-debug.cc
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am_ceph_client_debug_OBJECTS = tools/ceph-client-debug.$(OBJEXT)
 ceph_client_debug_OBJECTS = $(am_ceph_client_debug_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at ceph_client_debug_DEPENDENCIES = $(LIBCEPHFS) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(LIBCLIENT) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON)
 am_ceph_conf_OBJECTS = tools/ceph_conf.$(OBJEXT)
 ceph_conf_OBJECTS = $(am_ceph_conf_OBJECTS)
-ceph_conf_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_conf_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__ceph_dencoder_SOURCES_DIST = test/encoding/ceph_dencoder.cc \
 	mds/Capability.cc mds/MDSDaemon.cc mds/MDSRank.cc \
 	mds/Beacon.cc mds/locks.c mds/journal.cc mds/Server.cc \
@@ -3106,7 +3196,7 @@ am__ceph_dencoder_SOURCES_DIST = test/encoding/ceph_dencoder.cc \
 	perfglue/disabled_stubs.cc rgw/rgw_dencoder.cc rgw/rgw_acl.cc \
 	rgw/rgw_basic_types.cc rgw/rgw_common.cc rgw/rgw_env.cc \
 	rgw/rgw_json_enc.cc
-am__objects_37 = mds/ceph_dencoder-Capability.$(OBJEXT) \
+am__objects_38 = mds/ceph_dencoder-Capability.$(OBJEXT) \
 	mds/ceph_dencoder-MDSDaemon.$(OBJEXT) \
 	mds/ceph_dencoder-MDSRank.$(OBJEXT) \
 	mds/ceph_dencoder-Beacon.$(OBJEXT) \
@@ -3138,25 +3228,25 @@ am__objects_37 = mds/ceph_dencoder-Capability.$(OBJEXT) \
 	mds/ceph_dencoder-MDSContext.$(OBJEXT) \
 	mds/ceph_dencoder-MDSAuthCaps.$(OBJEXT) \
 	mds/ceph_dencoder-MDLog.$(OBJEXT)
- at ENABLE_CLIENT_TRUE@am__objects_38 = $(am__objects_37)
- at ENABLE_CLIENT_TRUE@am__objects_39 =  \
+ at ENABLE_CLIENT_TRUE@am__objects_39 = $(am__objects_38)
+ at ENABLE_CLIENT_TRUE@am__objects_40 =  \
 @ENABLE_CLIENT_TRUE@	rgw/ceph_dencoder-rgw_dencoder.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@	rgw/ceph_dencoder-rgw_acl.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@	rgw/ceph_dencoder-rgw_basic_types.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@	rgw/ceph_dencoder-rgw_common.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@	rgw/ceph_dencoder-rgw_env.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@	rgw/ceph_dencoder-rgw_json_enc.$(OBJEXT)
-am__objects_40 = $(am__objects_38) \
+am__objects_41 = $(am__objects_39) \
 	perfglue/ceph_dencoder-disabled_heap_profiler.$(OBJEXT) \
 	perfglue/ceph_dencoder-disabled_stubs.$(OBJEXT) \
-	$(am__objects_39)
+	$(am__objects_40)
 @ENABLE_CLIENT_TRUE at am_ceph_dencoder_OBJECTS = test/encoding/ceph_dencoder-ceph_dencoder.$(OBJEXT) \
- at ENABLE_CLIENT_TRUE@	$(am__objects_40)
+ at ENABLE_CLIENT_TRUE@	$(am__objects_41)
 ceph_dencoder_OBJECTS = $(am_ceph_dencoder_OBJECTS)
 @ENABLE_CLIENT_TRUE at ceph_dencoder_DEPENDENCIES = $(LIBRBD_TYPES) \
 @ENABLE_CLIENT_TRUE@	$(LIBOSD_TYPES) $(LIBOS_TYPES) \
 @ENABLE_CLIENT_TRUE@	$(LIBMON_TYPES) $(DENCODER_DEPS) \
- at ENABLE_CLIENT_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@	$(am__DEPENDENCIES_9)
 ceph_dencoder_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_dencoder_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
@@ -3165,17 +3255,13 @@ am__ceph_fuse_SOURCES_DIST = ceph_fuse.cc
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE at am_ceph_fuse_OBJECTS = ceph_fuse.$(OBJEXT)
 ceph_fuse_OBJECTS = $(am_ceph_fuse_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE at ceph_fuse_DEPENDENCIES = $(LIBCLIENT_FUSE) \
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_kvstore_tool_SOURCES_DIST = tools/ceph_kvstore_tool.cc
 @ENABLE_SERVER_TRUE at am_ceph_kvstore_tool_OBJECTS = tools/ceph_kvstore_tool-ceph_kvstore_tool.$(OBJEXT)
 ceph_kvstore_tool_OBJECTS = $(am_ceph_kvstore_tool_OBJECTS)
- at WITH_LIBZFS_TRUE@am__DEPENDENCIES_9 = libos_zfs.a
-am__DEPENDENCIES_10 = libkv.a $(am__append_26)
-am__DEPENDENCIES_11 = libos.a $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_9) $(LIBOS_TYPES) $(am__DEPENDENCIES_10)
 @ENABLE_SERVER_TRUE at ceph_kvstore_tool_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_kvstore_tool_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_kvstore_tool_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3184,25 +3270,25 @@ am__ceph_mds_SOURCES_DIST = ceph_mds.cc
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am_ceph_mds_OBJECTS =  \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	ceph_mds.$(OBJEXT)
 ceph_mds_OBJECTS = $(am_ceph_mds_OBJECTS)
-am__DEPENDENCIES_12 = libperfglue.la $(am__DEPENDENCIES_1) \
+am__DEPENDENCIES_13 = libperfglue.la $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1)
-am__DEPENDENCIES_13 = libmds.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_12)
+am__DEPENDENCIES_14 = libmds.la $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_13)
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at ceph_mds_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_13) \
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_14) \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(LIBOSDC) \
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(LIBCOMMON)
 am__ceph_mon_SOURCES_DIST = ceph_mon.cc
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am_ceph_mon_OBJECTS =  \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	ceph_mon.$(OBJEXT)
 ceph_mon_OBJECTS = $(am_ceph_mon_OBJECTS)
-am__DEPENDENCIES_14 = libmon.a $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_12) $(LIBMON_TYPES)
+am__DEPENDENCIES_15 = libmon.a $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_13) $(LIBMON_TYPES)
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at ceph_mon_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_14) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(LIBCOMMON) $(LIBAUTH) \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(LIBMON_TYPES)
@@ -3211,21 +3297,21 @@ am__ceph_monstore_tool_SOURCES_DIST = tools/ceph_monstore_tool.cc
 @ENABLE_SERVER_TRUE@	tools/ceph_monstore_tool.$(OBJEXT)
 ceph_monstore_tool_OBJECTS = $(am_ceph_monstore_tool_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_monstore_tool_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_objectstore_tool_SOURCES_DIST =  \
 	tools/ceph_objectstore_tool.cc tools/RadosDump.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_ceph_objectstore_tool_OBJECTS = tools/ceph_objectstore_tool.$(OBJEXT) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	tools/RadosDump.$(OBJEXT)
 ceph_objectstore_tool_OBJECTS = $(am_ceph_objectstore_tool_OBJECTS)
-am__DEPENDENCIES_15 = libosd.a $(am__DEPENDENCIES_1) $(LIBOSDC) \
-	$(am__DEPENDENCIES_11) $(am__DEPENDENCIES_12) $(LIBOSD_TYPES) \
+am__DEPENDENCIES_16 = libosd.a $(am__DEPENDENCIES_1) $(LIBOSDC) \
+	$(am__DEPENDENCIES_12) $(am__DEPENDENCIES_13) $(LIBOSD_TYPES) \
 	$(LIBOS_TYPES)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_objectstore_tool_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_osd_SOURCES_DIST = ceph_osd.cc
@@ -3233,11 +3319,11 @@ am__ceph_osd_SOURCES_DIST = ceph_osd.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	ceph_osd.$(OBJEXT)
 ceph_osd_OBJECTS = $(am_ceph_osd_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_osd_DEPENDENCIES = $(LIBOSDC) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD_TYPES) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOS_TYPES) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_osdomap_tool_SOURCES_DIST = tools/ceph_osdomap_tool.cc
@@ -3245,27 +3331,27 @@ am__ceph_osdomap_tool_SOURCES_DIST = tools/ceph_osdomap_tool.cc
 @ENABLE_SERVER_TRUE@	tools/ceph_osdomap_tool.$(OBJEXT)
 ceph_osdomap_tool_OBJECTS = $(am_ceph_osdomap_tool_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_osdomap_tool_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_syn_SOURCES_DIST = ceph_syn.cc client/SyntheticClient.cc
 @ENABLE_CLIENT_TRUE at am_ceph_syn_OBJECTS = ceph_syn.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@	client/SyntheticClient.$(OBJEXT)
 ceph_syn_OBJECTS = $(am_ceph_syn_OBJECTS)
 @ENABLE_CLIENT_TRUE at ceph_syn_DEPENDENCIES = $(LIBCLIENT) \
- at ENABLE_CLIENT_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@	$(am__DEPENDENCIES_9)
 am_ceph_bench_log_OBJECTS = test/bench_log.$(OBJEXT)
 ceph_bench_log_OBJECTS = $(am_ceph_bench_log_OBJECTS)
-ceph_bench_log_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_bench_log_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__ceph_erasure_code_SOURCES_DIST =  \
 	test/erasure-code/ceph_erasure_code.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_ceph_erasure_code_OBJECTS = test/erasure-code/ceph_erasure_code.$(OBJEXT)
 ceph_erasure_code_OBJECTS = $(am_ceph_erasure_code_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_erasure_code_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_erasure_code_benchmark_SOURCES_DIST =  \
 	erasure-code/ErasureCode.cc \
@@ -3275,10 +3361,10 @@ am__ceph_erasure_code_benchmark_SOURCES_DIST =  \
 ceph_erasure_code_benchmark_OBJECTS =  \
 	$(am_ceph_erasure_code_benchmark_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_erasure_code_benchmark_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_erasure_code_non_regression_SOURCES_DIST =  \
 	test/erasure-code/ceph_erasure_code_non_regression.cc
@@ -3286,10 +3372,10 @@ am__ceph_erasure_code_non_regression_SOURCES_DIST =  \
 ceph_erasure_code_non_regression_OBJECTS =  \
 	$(am_ceph_erasure_code_non_regression_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_erasure_code_non_regression_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 am__ceph_kvstorebench_SOURCES_DIST = test/kv_store_bench.cc \
 	key_value_store/kv_flat_btree_async.cc
@@ -3298,27 +3384,27 @@ am__ceph_kvstorebench_SOURCES_DIST = test/kv_store_bench.cc \
 ceph_kvstorebench_OBJECTS = $(am_ceph_kvstorebench_OBJECTS)
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE at ceph_kvstorebench_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_multi_stress_watch_SOURCES_DIST = test/multi_stress_watch.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_multi_stress_watch_OBJECTS = test/multi_stress_watch.$(OBJEXT)
 ceph_multi_stress_watch_OBJECTS =  \
 	$(am_ceph_multi_stress_watch_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_multi_stress_watch_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 am__ceph_objectstore_bench_SOURCES_DIST = test/objectstore_bench.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_objectstore_bench_OBJECTS = test/objectstore_bench.$(OBJEXT)
 ceph_objectstore_bench_OBJECTS = $(am_ceph_objectstore_bench_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_objectstore_bench_DEPENDENCIES =  \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_omapbench_SOURCES_DIST = test/omap_bench.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_omapbench_OBJECTS = test/omap_bench.$(OBJEXT)
 ceph_omapbench_OBJECTS = $(am_ceph_omapbench_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_omapbench_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_perf_local_SOURCES_DIST = test/perf_local.cc \
 	test/perf_helper.cc
 @ENABLE_SERVER_TRUE at am_ceph_perf_local_OBJECTS =  \
@@ -3326,8 +3412,8 @@ am__ceph_perf_local_SOURCES_DIST = test/perf_local.cc \
 @ENABLE_SERVER_TRUE@	test/ceph_perf_local-perf_helper.$(OBJEXT)
 ceph_perf_local_OBJECTS = $(am_ceph_perf_local_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_perf_local_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_perf_local_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_perf_local_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3336,14 +3422,14 @@ am__ceph_perf_msgr_client_SOURCES_DIST =  \
 	test/msgr/perf_msgr_client.cc
 @ENABLE_SERVER_TRUE at am_ceph_perf_msgr_client_OBJECTS = test/msgr/ceph_perf_msgr_client-perf_msgr_client.$(OBJEXT)
 ceph_perf_msgr_client_OBJECTS = $(am_ceph_perf_msgr_client_OBJECTS)
-am__DEPENDENCIES_16 = $(top_builddir)/src/gmock/lib/libgmock_main.la \
+am__DEPENDENCIES_17 = $(top_builddir)/src/gmock/lib/libgmock_main.la \
 	$(top_builddir)/src/gmock/lib/libgmock.la \
 	$(top_builddir)/src/gmock/gtest/lib/libgtest.la \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 @ENABLE_SERVER_TRUE at ceph_perf_msgr_client_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_perf_msgr_client_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_perf_msgr_client_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3353,9 +3439,9 @@ am__ceph_perf_msgr_server_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE at am_ceph_perf_msgr_server_OBJECTS = test/msgr/ceph_perf_msgr_server-perf_msgr_server.$(OBJEXT)
 ceph_perf_msgr_server_OBJECTS = $(am_ceph_perf_msgr_server_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_perf_msgr_server_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_perf_msgr_server_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_perf_msgr_server_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3365,23 +3451,23 @@ am__ceph_perf_objectstore_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE at am_ceph_perf_objectstore_OBJECTS = test/objectstore/ceph_perf_objectstore-ObjectStoreTransactionBenchmark.$(OBJEXT)
 ceph_perf_objectstore_OBJECTS = $(am_ceph_perf_objectstore_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_perf_objectstore_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_perf_objectstore_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_perf_objectstore_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_ceph_psim_OBJECTS = tools/psim.$(OBJEXT)
 ceph_psim_OBJECTS = $(am_ceph_psim_OBJECTS)
-ceph_psim_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_psim_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__ceph_radosacl_SOURCES_DIST = tools/radosacl.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_radosacl_OBJECTS =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	tools/radosacl.$(OBJEXT)
 ceph_radosacl_OBJECTS = $(am_ceph_radosacl_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_radosacl_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_rgw_jsonparser_SOURCES_DIST = rgw/rgw_jsonparser.cc \
 	rgw/rgw_common.cc rgw/rgw_env.cc rgw/rgw_json_enc.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_rgw_jsonparser_OBJECTS = rgw/rgw_jsonparser.$(OBJEXT) \
@@ -3389,8 +3475,8 @@ am__ceph_rgw_jsonparser_SOURCES_DIST = rgw/rgw_jsonparser.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_env.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_json_enc.$(OBJEXT)
 ceph_rgw_jsonparser_OBJECTS = $(am_ceph_rgw_jsonparser_OBJECTS)
-am__DEPENDENCIES_17 = librgw.la $(am__DEPENDENCIES_1)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__DEPENDENCIES_18 = $(LIBRADOS) \
+am__DEPENDENCIES_18 = librgw.la $(am__DEPENDENCIES_1)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__DEPENDENCIES_19 = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_rgw_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_log_client.a \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_statelog_client.a \
@@ -3400,28 +3486,28 @@ am__DEPENDENCIES_17 = librgw.la $(am__DEPENDENCIES_1)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_refcount_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_version_client.a
-am__DEPENDENCIES_19 = $(am__DEPENDENCIES_18)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_rgw_jsonparser_DEPENDENCIES = $(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+am__DEPENDENCIES_20 = $(am__DEPENDENCIES_19)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_rgw_jsonparser_DEPENDENCIES = $(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_rgw_multiparser_SOURCES_DIST = rgw/rgw_multiparser.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_rgw_multiparser_OBJECTS = rgw/rgw_multiparser.$(OBJEXT)
 ceph_rgw_multiparser_OBJECTS = $(am_ceph_rgw_multiparser_OBJECTS)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_rgw_multiparser_DEPENDENCIES = $(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_rgw_multiparser_DEPENDENCIES = $(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_scratchtool_SOURCES_DIST = tools/scratchtool.c
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_scratchtool_OBJECTS = tools/scratchtool.$(OBJEXT)
 ceph_scratchtool_OBJECTS = $(am_ceph_scratchtool_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_scratchtool_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_scratchtoolpp_SOURCES_DIST = tools/scratchtoolpp.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_scratchtoolpp_OBJECTS = tools/scratchtoolpp.$(OBJEXT)
 ceph_scratchtoolpp_OBJECTS = $(am_ceph_scratchtoolpp_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_scratchtoolpp_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_smalliobench_SOURCES_DIST = test/bench/small_io_bench.cc \
 	test/bench/rados_backend.cc \
 	test/bench/detailed_stat_collector.cc test/bench/bencher.cc
@@ -3433,7 +3519,7 @@ ceph_smalliobench_OBJECTS = $(am_ceph_smalliobench_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_smalliobench_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_smalliobenchdumb_SOURCES_DIST =  \
 	test/bench/small_io_bench_dumb.cc test/bench/dumb_backend.cc \
 	test/bench/detailed_stat_collector.cc test/bench/bencher.cc
@@ -3444,8 +3530,8 @@ am__ceph_smalliobenchdumb_SOURCES_DIST =  \
 ceph_smalliobenchdumb_OBJECTS = $(am_ceph_smalliobenchdumb_OBJECTS)
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE at ceph_smalliobenchdumb_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_smalliobenchfs_SOURCES_DIST =  \
 	test/bench/small_io_bench_fs.cc \
 	test/bench/testfilestore_backend.cc \
@@ -3457,8 +3543,8 @@ am__ceph_smalliobenchfs_SOURCES_DIST =  \
 ceph_smalliobenchfs_OBJECTS = $(am_ceph_smalliobenchfs_OBJECTS)
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE at ceph_smalliobenchfs_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_smalliobenchrbd_SOURCES_DIST =  \
 	test/bench/small_io_bench_rbd.cc test/bench/rbd_backend.cc \
 	test/bench/detailed_stat_collector.cc test/bench/bencher.cc
@@ -3471,22 +3557,15 @@ ceph_smalliobenchrbd_OBJECTS = $(am_ceph_smalliobenchrbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8)
-am__ceph_streamtest_SOURCES_DIST = test/streamtest.cc
- at ENABLE_SERVER_TRUE@am_ceph_streamtest_OBJECTS =  \
- at ENABLE_SERVER_TRUE@	test/streamtest.$(OBJEXT)
-ceph_streamtest_OBJECTS = $(am_ceph_streamtest_OBJECTS)
- at ENABLE_SERVER_TRUE@ceph_streamtest_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_async_driver_SOURCES_DIST =  \
 	test/msgr/test_async_driver.cc
 @ENABLE_SERVER_TRUE at am_ceph_test_async_driver_OBJECTS = test/msgr/ceph_test_async_driver-test_async_driver.$(OBJEXT)
 ceph_test_async_driver_OBJECTS = $(am_ceph_test_async_driver_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_async_driver_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_async_driver_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_async_driver_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3512,9 +3591,9 @@ ceph_test_cls_hello_OBJECTS = $(am_ceph_test_cls_hello_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_hello_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_hello_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_hello_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3527,8 +3606,8 @@ ceph_test_cls_journal_OBJECTS = $(am_ceph_test_cls_journal_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_journal_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) $(LIBCOMMON) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_journal_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_journal_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3540,8 +3619,8 @@ ceph_test_cls_lock_OBJECTS = $(am_ceph_test_cls_lock_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_lock_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_lock_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3552,9 +3631,9 @@ ceph_test_cls_log_OBJECTS = $(am_ceph_test_cls_log_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_log_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_log_client.a \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_log_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_log_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3566,9 +3645,9 @@ ceph_test_cls_numops_OBJECTS = $(am_ceph_test_cls_numops_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_numops_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_numops_client.la \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_numops_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_numops_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3581,8 +3660,8 @@ ceph_test_cls_rbd_OBJECTS = $(am_ceph_test_cls_rbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_rbd_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_3)
 ceph_test_cls_rbd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
@@ -3596,8 +3675,8 @@ ceph_test_cls_refcount_OBJECTS = $(am_ceph_test_cls_refcount_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_refcount_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_refcount_client.la \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_refcount_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_refcount_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3610,9 +3689,9 @@ ceph_test_cls_replica_log_OBJECTS =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_replica_log_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_replica_log_client.a \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_replica_log_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_replica_log_CXXFLAGS) $(CXXFLAGS) \
@@ -3624,9 +3703,9 @@ ceph_test_cls_rgw_OBJECTS = $(am_ceph_test_cls_rgw_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_rgw_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_rgw_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_rgw_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3635,9 +3714,9 @@ am__ceph_test_cls_rgw_log_SOURCES_DIST = test/test_rgw_admin_log.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_test_cls_rgw_log_OBJECTS = test/ceph_test_cls_rgw_log-test_rgw_admin_log.$(OBJEXT)
 ceph_test_cls_rgw_log_OBJECTS = $(am_ceph_test_cls_rgw_log_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_rgw_log_DEPENDENCIES = $(LIBRADOS) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_version_client.a \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_log_client.a \
@@ -3654,9 +3733,9 @@ am__ceph_test_cls_rgw_meta_SOURCES_DIST = test/test_rgw_admin_meta.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_test_cls_rgw_meta_OBJECTS = test/ceph_test_cls_rgw_meta-test_rgw_admin_meta.$(OBJEXT)
 ceph_test_cls_rgw_meta_OBJECTS = $(am_ceph_test_cls_rgw_meta_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_rgw_meta_DEPENDENCIES = $(LIBRADOS) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_version_client.a \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_log_client.a \
@@ -3675,9 +3754,9 @@ am__ceph_test_cls_rgw_opstate_SOURCES_DIST =  \
 ceph_test_cls_rgw_opstate_OBJECTS =  \
 	$(am_ceph_test_cls_rgw_opstate_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_rgw_opstate_DEPENDENCIES = $(LIBRADOS) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_version_client.a \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	libcls_log_client.a \
@@ -3699,9 +3778,9 @@ ceph_test_cls_statelog_OBJECTS = $(am_ceph_test_cls_statelog_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_statelog_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_statelog_client.a \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_statelog_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_statelog_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3713,8 +3792,8 @@ ceph_test_cls_version_OBJECTS = $(am_ceph_test_cls_version_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_cls_version_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_version_client.a \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_cls_version_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cls_version_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3723,23 +3802,23 @@ am__ceph_test_cors_SOURCES_DIST = test/test_cors.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_test_cors_OBJECTS = test/ceph_test_cors-test_cors.$(OBJEXT)
 ceph_test_cors_OBJECTS = $(am_ceph_test_cors_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_test_cors_DEPENDENCIES = $(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 ceph_test_cors_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_cors_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_ceph_test_crypto_OBJECTS = test/testcrypto.$(OBJEXT)
 ceph_test_crypto_OBJECTS = $(am_ceph_test_crypto_OBJECTS)
-ceph_test_crypto_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_test_crypto_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__ceph_test_filejournal_SOURCES_DIST = test/test_filejournal.cc
 @ENABLE_SERVER_TRUE at am_ceph_test_filejournal_OBJECTS = test/ceph_test_filejournal-test_filejournal.$(OBJEXT)
 ceph_test_filejournal_OBJECTS = $(am_ceph_test_filejournal_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_filejournal_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_filejournal_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_filejournal_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3749,9 +3828,9 @@ am__ceph_test_filestore_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at am_ceph_test_filestore_OBJECTS = test/filestore/ceph_test_filestore-TestFileStore.$(OBJEXT)
 ceph_test_filestore_OBJECTS = $(am_ceph_test_filestore_OBJECTS)
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at ceph_test_filestore_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_filestore_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_filestore_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3766,8 +3845,8 @@ am__ceph_test_filestore_idempotent_SOURCES_DIST =  \
 ceph_test_filestore_idempotent_OBJECTS =  \
 	$(am_ceph_test_filestore_idempotent_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_filestore_idempotent_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_filestore_idempotent_sequence_SOURCES_DIST =  \
 	test/objectstore/test_idempotent_sequence.cc \
 	test/objectstore/DeterministicOpSequence.cc \
@@ -3780,8 +3859,8 @@ am__ceph_test_filestore_idempotent_sequence_SOURCES_DIST =  \
 ceph_test_filestore_idempotent_sequence_OBJECTS =  \
 	$(am_ceph_test_filestore_idempotent_sequence_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_filestore_idempotent_sequence_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_get_blkdev_size_SOURCES_DIST =  \
 	test/test_get_blkdev_size.cc
 @LINUX_TRUE at am_ceph_test_get_blkdev_size_OBJECTS =  \
@@ -3799,15 +3878,15 @@ am__ceph_test_keys_SOURCES_DIST = test/testkeys.cc
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	test/testkeys.$(OBJEXT)
 ceph_test_keys_OBJECTS = $(am_ceph_test_keys_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at ceph_test_keys_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_14) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_keyvaluedb_SOURCES_DIST = test/objectstore/test_kv.cc
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at am_ceph_test_keyvaluedb_OBJECTS = test/objectstore/ceph_test_keyvaluedb-test_kv.$(OBJEXT)
 ceph_test_keyvaluedb_OBJECTS = $(am_ceph_test_keyvaluedb_OBJECTS)
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at ceph_test_keyvaluedb_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_keyvaluedb_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_keyvaluedb_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3818,9 +3897,9 @@ am__ceph_test_keyvaluedb_atomicity_SOURCES_DIST =  \
 ceph_test_keyvaluedb_atomicity_OBJECTS =  \
 	$(am_ceph_test_keyvaluedb_atomicity_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_keyvaluedb_atomicity_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_keyvaluedb_atomicity_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_keyvaluedb_atomicity_CXXFLAGS) $(CXXFLAGS) \
@@ -3833,9 +3912,9 @@ am__ceph_test_keyvaluedb_iterators_SOURCES_DIST =  \
 ceph_test_keyvaluedb_iterators_OBJECTS =  \
 	$(am_ceph_test_keyvaluedb_iterators_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_keyvaluedb_iterators_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_keyvaluedb_iterators_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_keyvaluedb_iterators_CXXFLAGS) $(CXXFLAGS) \
@@ -3843,19 +3922,20 @@ ceph_test_keyvaluedb_iterators_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am__ceph_test_libcephfs_SOURCES_DIST = test/libcephfs/test.cc \
 	test/libcephfs/readdir_r_cb.cc test/libcephfs/caps.cc \
 	test/libcephfs/multiclient.cc test/libcephfs/access.cc \
-	test/libcephfs/flock.cc
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__objects_41 = test/libcephfs/ceph_test_libcephfs-flock.$(OBJEXT)
+	test/libcephfs/acl.cc test/libcephfs/flock.cc
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__objects_42 = test/libcephfs/ceph_test_libcephfs-flock.$(OBJEXT)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am_ceph_test_libcephfs_OBJECTS = test/libcephfs/ceph_test_libcephfs-test.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/ceph_test_libcephfs-readdir_r_cb.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/ceph_test_libcephfs-caps.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/ceph_test_libcephfs-multiclient.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/ceph_test_libcephfs-access.$(OBJEXT) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__objects_41)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/ceph_test_libcephfs-acl.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__objects_42)
 ceph_test_libcephfs_OBJECTS = $(am_ceph_test_libcephfs_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at ceph_test_libcephfs_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(LIBCEPHFS) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 ceph_test_libcephfs_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3873,9 +3953,9 @@ ceph_test_librbd_OBJECTS = $(am_ceph_test_librbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	libcls_journal_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librados_api.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_6) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_librbd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_librbd_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3890,8 +3970,8 @@ ceph_test_librbd_api_OBJECTS = $(am_ceph_test_librbd_api_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_librbd_api_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_librbd_api_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3912,9 +3992,9 @@ am__ceph_test_mon_msg_SOURCES_DIST = test/mon/test-mon-msg.cc
 @ENABLE_SERVER_TRUE at am_ceph_test_mon_msg_OBJECTS = test/mon/ceph_test_mon_msg-test-mon-msg.$(OBJEXT)
 ceph_test_mon_msg_OBJECTS = $(am_ceph_test_mon_msg_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_mon_msg_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) $(LIBOSDC) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) $(LIBOSDC) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17)
 ceph_test_mon_msg_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_mon_msg_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3926,15 +4006,15 @@ am__ceph_test_mon_workloadgen_SOURCES_DIST =  \
 ceph_test_mon_workloadgen_OBJECTS =  \
 	$(am_ceph_test_mon_workloadgen_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_mon_workloadgen_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) $(LIBOSDC) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) $(LIBOSDC) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_msgr_SOURCES_DIST = test/msgr/test_msgr.cc
 @ENABLE_SERVER_TRUE at am_ceph_test_msgr_OBJECTS = test/msgr/ceph_test_msgr-test_msgr.$(OBJEXT)
 ceph_test_msgr_OBJECTS = $(am_ceph_test_msgr_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_msgr_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_msgr_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_msgr_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3944,7 +4024,7 @@ am__ceph_test_mutate_SOURCES_DIST = test/test_mutate.cc
 ceph_test_mutate_OBJECTS = $(am_ceph_test_mutate_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_mutate_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_object_map_SOURCES_DIST =  \
 	test/ObjectMap/test_object_map.cc \
 	test/ObjectMap/KeyValueDBMemory.cc
@@ -3952,9 +4032,9 @@ am__ceph_test_object_map_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE@	test/ObjectMap/ceph_test_object_map-KeyValueDBMemory.$(OBJEXT)
 ceph_test_object_map_OBJECTS = $(am_ceph_test_object_map_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_object_map_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_object_map_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_object_map_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3965,15 +4045,15 @@ am_ceph_test_objectcacher_stress_OBJECTS =  \
 ceph_test_objectcacher_stress_OBJECTS =  \
 	$(am_ceph_test_objectcacher_stress_OBJECTS)
 ceph_test_objectcacher_stress_DEPENDENCIES = $(LIBOSDC) \
-	$(am__DEPENDENCIES_8)
+	$(am__DEPENDENCIES_9)
 am__ceph_test_objectstore_SOURCES_DIST =  \
 	test/objectstore/store_test.cc
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at am_ceph_test_objectstore_OBJECTS = test/objectstore/ceph_test_objectstore-store_test.$(OBJEXT)
 ceph_test_objectstore_OBJECTS = $(am_ceph_test_objectstore_OBJECTS)
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at ceph_test_objectstore_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_objectstore_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_objectstore_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -3986,8 +4066,8 @@ am__ceph_test_objectstore_workloadgen_SOURCES_DIST =  \
 ceph_test_objectstore_workloadgen_OBJECTS =  \
 	$(am_ceph_test_objectstore_workloadgen_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_objectstore_workloadgen_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_rados_SOURCES_DIST = test/osd/TestRados.cc \
 	test/osd/TestOpStat.cc test/osd/Object.cc \
 	test/osd/RadosModel.cc
@@ -3998,15 +4078,15 @@ am__ceph_test_rados_SOURCES_DIST = test/osd/TestRados.cc \
 ceph_test_rados_OBJECTS = $(am_ceph_test_rados_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_test_rados_api_aio_SOURCES_DIST = test/librados/aio.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_ceph_test_rados_api_aio_OBJECTS = test/librados/ceph_test_rados_api_aio-aio.$(OBJEXT)
 ceph_test_rados_api_aio_OBJECTS =  \
 	$(am_ceph_test_rados_api_aio_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_aio_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) $(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_aio_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_aio_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4018,8 +4098,8 @@ ceph_test_rados_api_c_read_operations_OBJECTS =  \
 	$(am_ceph_test_rados_api_c_read_operations_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_c_read_operations_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_c_read_operations_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
 	$(CXXLD) $(ceph_test_rados_api_c_read_operations_CXXFLAGS) \
@@ -4031,8 +4111,8 @@ ceph_test_rados_api_c_write_operations_OBJECTS =  \
 	$(am_ceph_test_rados_api_c_write_operations_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_c_write_operations_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_c_write_operations_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
 	$(CXXLD) $(ceph_test_rados_api_c_write_operations_CXXFLAGS) \
@@ -4043,8 +4123,8 @@ ceph_test_rados_api_cls_OBJECTS =  \
 	$(am_ceph_test_rados_api_cls_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_cls_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_cls_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_cls_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4056,8 +4136,8 @@ ceph_test_rados_api_cmd_OBJECTS =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_cmd_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_cmd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_cmd_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4067,8 +4147,8 @@ am__ceph_test_rados_api_io_SOURCES_DIST = test/librados/io.cc
 ceph_test_rados_api_io_OBJECTS = $(am_ceph_test_rados_api_io_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_io_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_io_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_io_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4079,8 +4159,8 @@ ceph_test_rados_api_list_OBJECTS =  \
 	$(am_ceph_test_rados_api_list_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_list_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_list_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_list_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4091,8 +4171,8 @@ ceph_test_rados_api_lock_OBJECTS =  \
 	$(am_ceph_test_rados_api_lock_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_lock_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_lock_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_lock_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4103,9 +4183,9 @@ ceph_test_rados_api_misc_OBJECTS =  \
 	$(am_ceph_test_rados_api_misc_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_misc_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_misc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_misc_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4116,8 +4196,8 @@ ceph_test_rados_api_nlist_OBJECTS =  \
 	$(am_ceph_test_rados_api_nlist_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_nlist_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_nlist_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_nlist_CXXFLAGS) $(CXXFLAGS) \
@@ -4128,8 +4208,8 @@ ceph_test_rados_api_pool_OBJECTS =  \
 	$(am_ceph_test_rados_api_pool_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_pool_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_pool_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_pool_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4141,8 +4221,8 @@ ceph_test_rados_api_snapshots_OBJECTS =  \
 	$(am_ceph_test_rados_api_snapshots_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_snapshots_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_snapshots_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_snapshots_CXXFLAGS) $(CXXFLAGS) \
@@ -4153,8 +4233,8 @@ ceph_test_rados_api_stat_OBJECTS =  \
 	$(am_ceph_test_rados_api_stat_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_stat_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_stat_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_stat_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4167,9 +4247,9 @@ ceph_test_rados_api_tier_OBJECTS =  \
 	$(am_ceph_test_rados_api_tier_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_tier_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_tier_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_rados_api_tier_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4181,8 +4261,8 @@ ceph_test_rados_api_watch_notify_OBJECTS =  \
 	$(am_ceph_test_rados_api_watch_notify_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_api_watch_notify_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_rados_api_watch_notify_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
 	$(CXXLD) $(ceph_test_rados_api_watch_notify_CXXFLAGS) \
@@ -4233,7 +4313,7 @@ ceph_test_rados_striper_api_aio_OBJECTS =  \
 	$(am_ceph_test_rados_striper_api_aio_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_striper_api_aio_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOSSTRIPER) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(RADOS_STRIPER_TEST_LDADD)
 ceph_test_rados_striper_api_aio_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -4247,7 +4327,7 @@ ceph_test_rados_striper_api_io_OBJECTS =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_striper_api_io_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOSSTRIPER) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(RADOS_STRIPER_TEST_LDADD)
 ceph_test_rados_striper_api_io_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -4260,7 +4340,7 @@ ceph_test_rados_striper_api_striping_OBJECTS =  \
 	$(am_ceph_test_rados_striper_api_striping_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_striper_api_striping_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOSSTRIPER) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(RADOS_STRIPER_TEST_LDADD)
 ceph_test_rados_striper_api_striping_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -4296,10 +4376,10 @@ am__ceph_test_rgw_manifest_SOURCES_DIST =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_test_rgw_manifest_OBJECTS = test/rgw/ceph_test_rgw_manifest-test_rgw_manifest.$(OBJEXT)
 ceph_test_rgw_manifest_OBJECTS = $(am_ceph_test_rgw_manifest_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_test_rgw_manifest_DEPENDENCIES = $(LIBRADOS) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1)
 ceph_test_rgw_manifest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -4309,10 +4389,10 @@ am__ceph_test_rgw_obj_SOURCES_DIST = test/rgw/test_rgw_obj.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_ceph_test_rgw_obj_OBJECTS = test/rgw/ceph_test_rgw_obj-test_rgw_obj.$(OBJEXT)
 ceph_test_rgw_obj_OBJECTS = $(am_ceph_test_rgw_obj_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at ceph_test_rgw_obj_DEPENDENCIES = $(LIBRADOS) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1)
 ceph_test_rgw_obj_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -4322,14 +4402,14 @@ am_ceph_test_signal_handlers_OBJECTS =  \
 	test/TestSignalHandlers.$(OBJEXT)
 ceph_test_signal_handlers_OBJECTS =  \
 	$(am_ceph_test_signal_handlers_OBJECTS)
-ceph_test_signal_handlers_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_test_signal_handlers_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__ceph_test_snap_mapper_SOURCES_DIST = test/test_snap_mapper.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_ceph_test_snap_mapper_OBJECTS = test/ceph_test_snap_mapper-test_snap_mapper.$(OBJEXT)
 ceph_test_snap_mapper_OBJECTS = $(am_ceph_test_snap_mapper_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_test_snap_mapper_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9)
 ceph_test_snap_mapper_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_snap_mapper_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4339,22 +4419,22 @@ am__ceph_test_stress_watch_SOURCES_DIST = test/test_stress_watch.cc
 ceph_test_stress_watch_OBJECTS = $(am_ceph_test_stress_watch_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_stress_watch_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) $(LIBCOMMON) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
 ceph_test_stress_watch_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_test_stress_watch_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_ceph_test_timers_OBJECTS = test/TestTimers.$(OBJEXT)
 ceph_test_timers_OBJECTS = $(am_ceph_test_timers_OBJECTS)
-ceph_test_timers_DEPENDENCIES = $(am__DEPENDENCIES_8)
+ceph_test_timers_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__ceph_test_trans_SOURCES_DIST = test/test_trans.cc
 @ENABLE_SERVER_TRUE at am_ceph_test_trans_OBJECTS =  \
 @ENABLE_SERVER_TRUE@	test/test_trans.$(OBJEXT)
 ceph_test_trans_OBJECTS = $(am_ceph_test_trans_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_test_trans_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_tpbench_SOURCES_DIST = test/bench/tp_bench.cc \
 	test/bench/detailed_stat_collector.cc
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE at am_ceph_tpbench_OBJECTS = test/bench/tp_bench.$(OBJEXT) \
@@ -4362,15 +4442,15 @@ am__ceph_tpbench_SOURCES_DIST = test/bench/tp_bench.cc \
 ceph_tpbench_OBJECTS = $(am_ceph_tpbench_OBJECTS)
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE at ceph_tpbench_DEPENDENCIES = $(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__ceph_xattr_bench_SOURCES_DIST = test/xattr_bench.cc
 @ENABLE_SERVER_TRUE at am_ceph_xattr_bench_OBJECTS = test/ceph_xattr_bench-xattr_bench.$(OBJEXT)
 ceph_xattr_bench_OBJECTS = $(am_ceph_xattr_bench_OBJECTS)
 @ENABLE_SERVER_TRUE at ceph_xattr_bench_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 ceph_xattr_bench_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(ceph_xattr_bench_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4385,10 +4465,10 @@ am__cephfs_data_scan_SOURCES_DIST = tools/cephfs/cephfs-data-scan.cc \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/DataScan.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/MDSUtility.$(OBJEXT)
 cephfs_data_scan_OBJECTS = $(am_cephfs_data_scan_OBJECTS)
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_data_scan_DEPENDENCIES = $(am__DEPENDENCIES_13) \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_data_scan_DEPENDENCIES = $(am__DEPENDENCIES_14) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	libcls_cephfs_client.la \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__cephfs_journal_tool_SOURCES_DIST =  \
 	tools/cephfs/cephfs-journal-tool.cc \
 	tools/cephfs/JournalTool.cc tools/cephfs/JournalFilter.cc \
@@ -4404,9 +4484,9 @@ am__cephfs_journal_tool_SOURCES_DIST =  \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/Resetter.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/MDSUtility.$(OBJEXT)
 cephfs_journal_tool_OBJECTS = $(am_cephfs_journal_tool_OBJECTS)
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_journal_tool_DEPENDENCIES = $(am__DEPENDENCIES_13) \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_journal_tool_DEPENDENCIES = $(am__DEPENDENCIES_14) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__cephfs_table_tool_SOURCES_DIST =  \
 	tools/cephfs/cephfs-table-tool.cc tools/cephfs/TableTool.cc \
 	tools/cephfs/MDSUtility.cc
@@ -4414,32 +4494,32 @@ am__cephfs_table_tool_SOURCES_DIST =  \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/TableTool.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/MDSUtility.$(OBJEXT)
 cephfs_table_tool_OBJECTS = $(am_cephfs_table_tool_OBJECTS)
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_table_tool_DEPENDENCIES = $(am__DEPENDENCIES_13) \
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_table_tool_DEPENDENCIES = $(am__DEPENDENCIES_14) \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am_crushtool_OBJECTS = tools/crushtool.$(OBJEXT)
 crushtool_OBJECTS = $(am_crushtool_OBJECTS)
-crushtool_DEPENDENCIES = $(am__DEPENDENCIES_8)
+crushtool_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__get_command_descriptions_SOURCES_DIST =  \
 	test/common/get_command_descriptions.cc
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am_get_command_descriptions_OBJECTS = test/common/get_command_descriptions.$(OBJEXT)
 get_command_descriptions_OBJECTS =  \
 	$(am_get_command_descriptions_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at get_command_descriptions_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_14) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(LIBMON_TYPES) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_11) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_12) \
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(LIBCOMMON) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_9)
 am__librados_config_SOURCES_DIST = librados-config.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am_librados_config_OBJECTS = librados-config.$(OBJEXT)
 librados_config_OBJECTS = $(am_librados_config_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at librados_config_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am_monmaptool_OBJECTS = tools/monmaptool.$(OBJEXT)
 monmaptool_OBJECTS = $(am_monmaptool_OBJECTS)
-monmaptool_DEPENDENCIES = $(am__DEPENDENCIES_8)
+monmaptool_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__mount_ceph_SOURCES_DIST = mount/mount.ceph.c
 @ENABLE_SERVER_TRUE at am_mount_ceph_OBJECTS =  \
 @ENABLE_SERVER_TRUE@	mount/mount.ceph.$(OBJEXT)
@@ -4448,7 +4528,7 @@ mount_ceph_OBJECTS = $(am_mount_ceph_OBJECTS)
 @ENABLE_SERVER_TRUE@	$(LIBCOMMON)
 am_osdmaptool_OBJECTS = tools/osdmaptool.$(OBJEXT)
 osdmaptool_OBJECTS = $(am_osdmaptool_OBJECTS)
-osdmaptool_DEPENDENCIES = $(am__DEPENDENCIES_8)
+osdmaptool_DEPENDENCIES = $(am__DEPENDENCIES_9)
 am__rados_SOURCES_DIST = tools/rados/rados.cc tools/RadosDump.cc \
 	tools/rados/RadosImport.cc tools/rados/PoolDump.cc \
 	common/obj_bencher.cc
@@ -4462,7 +4542,7 @@ rados_OBJECTS = $(am_rados_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOSSTRIPER) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__radosgw_SOURCES_DIST = rgw/rgw_resolve.cc rgw/rgw_rest.cc \
 	rgw/rgw_rest_swift.cc rgw/rgw_rest_s3.cc rgw/rgw_rest_usage.cc \
 	rgw/rgw_rest_user.cc rgw/rgw_rest_bucket.cc \
@@ -4490,24 +4570,24 @@ am__radosgw_SOURCES_DIST = rgw/rgw_resolve.cc rgw/rgw_rest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_loadgen.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_main.$(OBJEXT)
 radosgw_OBJECTS = $(am_radosgw_OBJECTS)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at radosgw_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at radosgw_DEPENDENCIES = $(am__DEPENDENCIES_18) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(LIBCIVETWEB) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__radosgw_admin_SOURCES_DIST = rgw/rgw_admin.cc rgw/rgw_orphan.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_radosgw_admin_OBJECTS = rgw/rgw_admin.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/rgw_orphan.$(OBJEXT)
 radosgw_admin_OBJECTS = $(am_radosgw_admin_OBJECTS)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at radosgw_admin_DEPENDENCIES = $(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at radosgw_admin_DEPENDENCIES = $(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__radosgw_object_expirer_SOURCES_DIST = rgw/rgw_object_expirer.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_radosgw_object_expirer_OBJECTS = rgw/rgw_object_expirer.$(OBJEXT)
 radosgw_object_expirer_OBJECTS = $(am_radosgw_object_expirer_OBJECTS)
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at radosgw_object_expirer_DEPENDENCIES = $(am__DEPENDENCIES_17) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_19) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at radosgw_object_expirer_DEPENDENCIES = $(am__DEPENDENCIES_18) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_20) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 am__rbd_SOURCES_DIST = tools/rbd/rbd.cc tools/rbd/ArgumentTypes.cc \
 	tools/rbd/IndentStream.cc tools/rbd/OptionPrinter.cc \
 	tools/rbd/Shell.cc tools/rbd/Utils.cc \
@@ -4568,7 +4648,7 @@ rbd_OBJECTS = $(am_rbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD_TYPES) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_1)
 am__rbd_fuse_SOURCES_DIST = rbd_fuse/rbd-fuse.cc
@@ -4577,7 +4657,7 @@ rbd_fuse_OBJECTS = $(am_rbd_fuse_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at rbd_fuse_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9)
 rbd_fuse_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(rbd_fuse_CXXFLAGS) \
 	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@@ -4586,7 +4666,7 @@ am__rbd_nbd_SOURCES_DIST = tools/rbd_nbd/rbd-nbd.cc
 rbd_nbd_OBJECTS = $(am_rbd_nbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at rbd_nbd_DEPENDENCIES = $(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_1)
 rbd_nbd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(rbd_nbd_CXXFLAGS) \
@@ -4598,7 +4678,7 @@ rbd_replay_OBJECTS = $(am_rbd_replay_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay_types.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBCOMMON)
 am__rbd_replay_prep_SOURCES_DIST = rbd_replay/rbd-replay-prep.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am_rbd_replay_prep_OBJECTS = rbd_replay/rbd-replay-prep.$(OBJEXT)
@@ -4608,7 +4688,7 @@ rbd_replay_prep_OBJECTS = $(am_rbd_replay_prep_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay_types.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBCOMMON)
 am__simple_client_SOURCES_DIST = test/messenger/simple_client.cc \
 	test/messenger/simple_dispatcher.cc
@@ -4616,9 +4696,9 @@ am__simple_client_SOURCES_DIST = test/messenger/simple_client.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/simple_client-simple_dispatcher.$(OBJEXT)
 simple_client_OBJECTS = $(am_simple_client_OBJECTS)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at simple_client_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_11) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_12) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(LIBCOMMON) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_3) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_1)
@@ -4632,9 +4712,9 @@ am__simple_server_SOURCES_DIST = test/messenger/simple_server.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/simple_server-simple_dispatcher.$(OBJEXT)
 simple_server_OBJECTS = $(am_simple_server_OBJECTS)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at simple_server_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_11) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_12) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(LIBCOMMON) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_3) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_1)
@@ -4645,13 +4725,13 @@ simple_server_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am__test_build_libcephfs_SOURCES_DIST = test/buildtest_skeleton.cc \
 	osdc/Objecter.cc osdc/ObjectCacher.cc osdc/Filer.cc \
 	osdc/Striper.cc osdc/Journaler.cc
-am__objects_42 = osdc/test_build_libcephfs-Objecter.$(OBJEXT) \
+am__objects_43 = osdc/test_build_libcephfs-Objecter.$(OBJEXT) \
 	osdc/test_build_libcephfs-ObjectCacher.$(OBJEXT) \
 	osdc/test_build_libcephfs-Filer.$(OBJEXT) \
 	osdc/test_build_libcephfs-Striper.$(OBJEXT) \
 	osdc/test_build_libcephfs-Journaler.$(OBJEXT)
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am_test_build_libcephfs_OBJECTS = test/test_build_libcephfs-buildtest_skeleton.$(OBJEXT) \
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__objects_42)
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__objects_43)
 test_build_libcephfs_OBJECTS = $(am_test_build_libcephfs_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at test_build_libcephfs_DEPENDENCIES = $(LIBCEPHFS) \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
@@ -4663,9 +4743,9 @@ test_build_libcephfs_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(test_build_libcephfs_LDFLAGS) $(LDFLAGS) -o $@
 am__test_build_libcommon_SOURCES_DIST = test/buildtest_skeleton.cc \
 	common/buffer.cc
-am__objects_43 = common/test_build_libcommon-buffer.$(OBJEXT)
+am__objects_44 = common/test_build_libcommon-buffer.$(OBJEXT)
 @WITH_BUILD_TESTS_TRUE at am_test_build_libcommon_OBJECTS = test/test_build_libcommon-buildtest_skeleton.$(OBJEXT) \
- at WITH_BUILD_TESTS_TRUE@	$(am__objects_43)
+ at WITH_BUILD_TESTS_TRUE@	$(am__objects_44)
 test_build_libcommon_OBJECTS = $(am_test_build_libcommon_OBJECTS)
 @WITH_BUILD_TESTS_TRUE at test_build_libcommon_DEPENDENCIES =  \
 @WITH_BUILD_TESTS_TRUE@	$(am__DEPENDENCIES_4) \
@@ -4678,10 +4758,10 @@ test_build_libcommon_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(test_build_libcommon_LDFLAGS) $(LDFLAGS) -o $@
 am__test_build_librados_SOURCES_DIST = test/buildtest_skeleton.cc \
 	common/buffer.cc librados/librados.cc
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__objects_44 = common/test_build_librados-buffer.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at am__objects_45 = common/test_build_librados-buffer.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados/test_build_librados-librados.$(OBJEXT)
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE at am_test_build_librados_OBJECTS = test/test_build_librados-buildtest_skeleton.$(OBJEXT) \
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE@	$(am__objects_44)
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE@	$(am__objects_45)
 test_build_librados_OBJECTS = $(am_test_build_librados_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE at test_build_librados_DEPENDENCIES = $(am__DEPENDENCIES_6) \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
@@ -4705,7 +4785,7 @@ am__test_build_librgw_SOURCES_DIST = test/buildtest_skeleton.cc \
 	rgw/rgw_metadata.cc rgw/rgw_replica_log.cc rgw/rgw_keystone.cc \
 	rgw/rgw_quota.cc rgw/rgw_dencoder.cc \
 	rgw/rgw_object_expirer_core.cc
- at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__objects_45 = rgw/test_build_librgw-librgw.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am__objects_46 = rgw/test_build_librgw-librgw.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/test_build_librgw-rgw_acl.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/test_build_librgw-rgw_acl_s3.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/test_build_librgw-rgw_acl_swift.$(OBJEXT) \
@@ -4742,21 +4822,21 @@ am__test_build_librgw_SOURCES_DIST = test/buildtest_skeleton.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/test_build_librgw-rgw_dencoder.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/test_build_librgw-rgw_object_expirer_core.$(OBJEXT)
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at am_test_build_librgw_OBJECTS = test/test_build_librgw-buildtest_skeleton.$(OBJEXT) \
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__objects_45)
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__objects_46)
 test_build_librgw_OBJECTS = $(am_test_build_librgw_OBJECTS)
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at test_build_librgw_DEPENDENCIES = $(am__DEPENDENCIES_19) \
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at test_build_librgw_DEPENDENCIES = $(am__DEPENDENCIES_20) \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_3) \
- at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9)
 test_build_librgw_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(test_build_librgw_CXXFLAGS) $(CXXFLAGS) \
 	$(test_build_librgw_LDFLAGS) $(LDFLAGS) -o $@
 am_unittest_addrs_OBJECTS = test/unittest_addrs-test_addrs.$(OBJEXT)
 unittest_addrs_OBJECTS = $(am_unittest_addrs_OBJECTS)
-unittest_addrs_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_addrs_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_addrs_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_addrs_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4764,16 +4844,16 @@ unittest_addrs_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_admin_socket_OBJECTS =  \
 	test/unittest_admin_socket-admin_socket.$(OBJEXT)
 unittest_admin_socket_OBJECTS = $(am_unittest_admin_socket_OBJECTS)
-unittest_admin_socket_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_admin_socket_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_admin_socket_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_admin_socket_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_arch_OBJECTS = test/unittest_arch-test_arch.$(OBJEXT)
 unittest_arch_OBJECTS = $(am_unittest_arch_OBJECTS)
-unittest_arch_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_arch_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_arch_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_arch_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
@@ -4781,9 +4861,8 @@ unittest_arch_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_async_compressor_OBJECTS = test/common/unittest_async_compressor-test_async_compressor.$(OBJEXT)
 unittest_async_compressor_OBJECTS =  \
 	$(am_unittest_async_compressor_OBJECTS)
-am__DEPENDENCIES_20 = libcompressor.la
-unittest_async_compressor_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8) $(am__DEPENDENCIES_20)
+unittest_async_compressor_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9) $(LIBCOMPRESSOR) $(LIBCOMMON)
 unittest_async_compressor_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_async_compressor_CXXFLAGS) $(CXXFLAGS) \
@@ -4792,8 +4871,8 @@ am__unittest_base64_SOURCES_DIST = test/base64.cc
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am_unittest_base64_OBJECTS = test/unittest_base64-base64.$(OBJEXT)
 unittest_base64_OBJECTS = $(am_unittest_base64_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at unittest_base64_DEPENDENCIES = $(LIBCEPHFS) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_base64_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_base64_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4801,8 +4880,8 @@ unittest_base64_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_bit_vector_OBJECTS =  \
 	test/common/unittest_bit_vector-test_bit_vector.$(OBJEXT)
 unittest_bit_vector_OBJECTS = $(am_unittest_bit_vector_OBJECTS)
-unittest_bit_vector_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_bit_vector_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_bit_vector_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_bit_vector_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4810,8 +4889,8 @@ unittest_bit_vector_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_blkdev_OBJECTS =  \
 	test/common/unittest_blkdev-test_blkdev.$(OBJEXT)
 unittest_blkdev_OBJECTS = $(am_unittest_blkdev_OBJECTS)
-unittest_blkdev_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_blkdev_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_blkdev_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_blkdev_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4819,17 +4898,41 @@ unittest_blkdev_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_bloom_filter_OBJECTS =  \
 	test/common/unittest_bloom_filter-test_bloom_filter.$(OBJEXT)
 unittest_bloom_filter_OBJECTS = $(am_unittest_bloom_filter_OBJECTS)
-unittest_bloom_filter_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_bloom_filter_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_bloom_filter_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_bloom_filter_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
+am__unittest_bluefs_SOURCES_DIST = test/objectstore/test_bluefs.cc
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am_unittest_bluefs_OBJECTS = test/objectstore/unittest_bluefs-test_bluefs.$(OBJEXT)
+unittest_bluefs_OBJECTS = $(am_unittest_bluefs_OBJECTS)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluefs_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_9)
+unittest_bluefs_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(unittest_bluefs_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
+am__unittest_bluestore_types_SOURCES_DIST =  \
+	test/objectstore/test_bluestore_types.cc
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at am_unittest_bluestore_types_OBJECTS = test/objectstore/unittest_bluestore_types-test_bluestore_types.$(OBJEXT)
+unittest_bluestore_types_OBJECTS =  \
+	$(am_unittest_bluestore_types_OBJECTS)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluestore_types_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE@	$(am__DEPENDENCIES_9)
+unittest_bluestore_types_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(unittest_bluestore_types_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
 am_unittest_bufferlist_OBJECTS =  \
 	test/unittest_bufferlist-bufferlist.$(OBJEXT)
 unittest_bufferlist_OBJECTS = $(am_unittest_bufferlist_OBJECTS)
-unittest_bufferlist_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_bufferlist_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_bufferlist_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_bufferlist_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4837,8 +4940,8 @@ unittest_bufferlist_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_ceph_argparse_OBJECTS =  \
 	test/unittest_ceph_argparse-ceph_argparse.$(OBJEXT)
 unittest_ceph_argparse_OBJECTS = $(am_unittest_ceph_argparse_OBJECTS)
-unittest_ceph_argparse_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_ceph_argparse_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_ceph_argparse_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_ceph_argparse_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4847,8 +4950,8 @@ am_unittest_ceph_compatset_OBJECTS =  \
 	test/unittest_ceph_compatset-ceph_compatset.$(OBJEXT)
 unittest_ceph_compatset_OBJECTS =  \
 	$(am_unittest_ceph_compatset_OBJECTS)
-unittest_ceph_compatset_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_ceph_compatset_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_ceph_compatset_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_ceph_compatset_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4856,8 +4959,8 @@ unittest_ceph_compatset_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_ceph_crypto_OBJECTS =  \
 	test/unittest_ceph_crypto-ceph_crypto.$(OBJEXT)
 unittest_ceph_crypto_OBJECTS = $(am_unittest_ceph_crypto_OBJECTS)
-unittest_ceph_crypto_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_ceph_crypto_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_ceph_crypto_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_ceph_crypto_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4867,18 +4970,78 @@ am__unittest_chain_xattr_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE at am_unittest_chain_xattr_OBJECTS = test/objectstore/unittest_chain_xattr-chain_xattr.$(OBJEXT)
 unittest_chain_xattr_OBJECTS = $(am_unittest_chain_xattr_OBJECTS)
 @ENABLE_SERVER_TRUE at unittest_chain_xattr_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 unittest_chain_xattr_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_chain_xattr_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
+am__unittest_compression_plugin_SOURCES_DIST =  \
+	compressor/Compressor.cc \
+	test/compressor/test_compression_plugin.cc
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_compression_plugin_OBJECTS = compressor/unittest_compression_plugin-Compressor.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/compressor/unittest_compression_plugin-test_compression_plugin.$(OBJEXT)
+unittest_compression_plugin_OBJECTS =  \
+	$(am_unittest_compression_plugin_OBJECTS)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
+unittest_compression_plugin_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+am__unittest_compression_plugin_snappy_SOURCES_DIST =  \
+	test/compressor/test_compression_plugin_snappy.cc \
+	compressor/Compressor.cc \
+	compressor/snappy/CompressionPluginSnappy.cc
+am__objects_47 = compressor/unittest_compression_plugin_snappy-Compressor.$(OBJEXT) \
+	compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.$(OBJEXT)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_compression_plugin_snappy_OBJECTS = test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_47)
+unittest_compression_plugin_snappy_OBJECTS =  \
+	$(am_unittest_compression_plugin_snappy_OBJECTS)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_snappy_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMPRESSOR) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
+unittest_compression_plugin_snappy_LINK = $(LIBTOOL) $(AM_V_lt) \
+	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CXXLD) $(unittest_compression_plugin_snappy_CXXFLAGS) \
+	$(CXXFLAGS) $(unittest_compression_plugin_snappy_LDFLAGS) \
+	$(LDFLAGS) -o $@
+am__unittest_compression_snappy_SOURCES_DIST =  \
+	test/compressor/test_compression_snappy.cc \
+	compressor/Compressor.cc \
+	compressor/snappy/CompressionPluginSnappy.cc
+am__objects_48 =  \
+	compressor/unittest_compression_snappy-Compressor.$(OBJEXT) \
+	compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.$(OBJEXT)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_compression_snappy_OBJECTS = test/compressor/unittest_compression_snappy-test_compression_snappy.$(OBJEXT) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_48)
+unittest_compression_snappy_OBJECTS =  \
+	$(am_unittest_compression_snappy_OBJECTS)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_snappy_DEPENDENCIES =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
+unittest_compression_snappy_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) \
+	$(unittest_compression_snappy_LDFLAGS) $(LDFLAGS) -o $@
 am_unittest_config_OBJECTS =  \
 	test/common/unittest_config-test_config.$(OBJEXT)
 unittest_config_OBJECTS = $(am_unittest_config_OBJECTS)
-unittest_config_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_config_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_config_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_config_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4886,8 +5049,8 @@ unittest_config_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_confutils_OBJECTS =  \
 	test/unittest_confutils-confutils.$(OBJEXT)
 unittest_confutils_OBJECTS = $(am_unittest_confutils_OBJECTS)
-unittest_confutils_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_confutils_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_confutils_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_confutils_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4895,8 +5058,8 @@ unittest_confutils_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_context_OBJECTS =  \
 	test/common/unittest_context-test_context.$(OBJEXT)
 unittest_context_OBJECTS = $(am_unittest_context_OBJECTS)
-unittest_context_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_context_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_context_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_context_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4904,16 +5067,16 @@ unittest_context_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_crc32c_OBJECTS =  \
 	test/common/unittest_crc32c-test_crc32c.$(OBJEXT)
 unittest_crc32c_OBJECTS = $(am_unittest_crc32c_OBJECTS)
-unittest_crc32c_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_crc32c_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_crc32c_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_crc32c_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_crush_OBJECTS = test/crush/unittest_crush-crush.$(OBJEXT)
 unittest_crush_OBJECTS = $(am_unittest_crush_OBJECTS)
-unittest_crush_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_8)
+unittest_crush_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_9)
 unittest_crush_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_crush_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4921,16 +5084,16 @@ unittest_crush_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_crush_wrapper_OBJECTS =  \
 	test/crush/unittest_crush_wrapper-CrushWrapper.$(OBJEXT)
 unittest_crush_wrapper_OBJECTS = $(am_unittest_crush_wrapper_OBJECTS)
-unittest_crush_wrapper_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8) $(LIBCRUSH)
+unittest_crush_wrapper_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9) $(LIBCRUSH)
 unittest_crush_wrapper_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_crush_wrapper_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_crypto_OBJECTS = test/unittest_crypto-crypto.$(OBJEXT)
 unittest_crypto_OBJECTS = $(am_unittest_crypto_OBJECTS)
-unittest_crypto_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_crypto_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_crypto_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_crypto_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4938,8 +5101,8 @@ unittest_crypto_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_crypto_init_OBJECTS =  \
 	test/unittest_crypto_init-crypto_init.$(OBJEXT)
 unittest_crypto_init_OBJECTS = $(am_unittest_crypto_init_OBJECTS)
-unittest_crypto_init_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_crypto_init_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_crypto_init_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_crypto_init_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4947,8 +5110,8 @@ unittest_crypto_init_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_daemon_config_OBJECTS =  \
 	test/unittest_daemon_config-daemon_config.$(OBJEXT)
 unittest_daemon_config_OBJECTS = $(am_unittest_daemon_config_OBJECTS)
-unittest_daemon_config_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_daemon_config_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_daemon_config_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_daemon_config_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4957,9 +5120,9 @@ am__unittest_ecbackend_SOURCES_DIST = test/osd/TestECBackend.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_ecbackend_OBJECTS = test/osd/unittest_ecbackend-TestECBackend.$(OBJEXT)
 unittest_ecbackend_OBJECTS = $(am_unittest_ecbackend_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_ecbackend_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9)
 unittest_ecbackend_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_ecbackend_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4969,8 +5132,8 @@ am__unittest_encoding_SOURCES_DIST = test/encoding.cc
 unittest_encoding_OBJECTS = $(am_unittest_encoding_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at unittest_encoding_DEPENDENCIES = $(LIBCEPHFS) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_encoding_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_encoding_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4981,10 +5144,10 @@ am__unittest_erasure_code_SOURCES_DIST = erasure-code/ErasureCode.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/unittest_erasure_code-TestErasureCode.$(OBJEXT)
 unittest_erasure_code_OBJECTS = $(am_unittest_erasure_code_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9)
 unittest_erasure_code_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_erasure_code_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -4997,10 +5160,10 @@ am__unittest_erasure_code_example_SOURCES_DIST =  \
 unittest_erasure_code_example_OBJECTS =  \
 	$(am_unittest_erasure_code_example_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_example_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9)
 unittest_erasure_code_example_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_erasure_code_example_CXXFLAGS) $(CXXFLAGS) \
@@ -5012,10 +5175,10 @@ am__unittest_erasure_code_isa_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	test/erasure-code/unittest_erasure_code_isa-TestErasureCodeIsa.$(OBJEXT)
 unittest_erasure_code_isa_OBJECTS =  \
 	$(am_unittest_erasure_code_isa_OBJECTS)
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_isa_DEPENDENCIES = $(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_isa_DEPENDENCIES = $(am__DEPENDENCIES_16) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	.libs/libec_isa.la \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(LIBERASURE_CODE) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
@@ -5044,7 +5207,7 @@ am__unittest_erasure_code_jerasure_SOURCES_DIST =  \
 	erasure-code/jerasure/gf-complete/src/gf_w8.c \
 	erasure-code/jerasure/ErasureCodePluginJerasure.cc \
 	erasure-code/jerasure/ErasureCodeJerasure.cc
-am__objects_46 = erasure-code/unittest_erasure_code_jerasure-ErasureCode.$(OBJEXT) \
+am__objects_49 = erasure-code/unittest_erasure_code_jerasure-ErasureCode.$(OBJEXT) \
 	erasure-code/jerasure/jerasure/src/unittest_erasure_code_jerasure-cauchy.$(OBJEXT) \
 	erasure-code/jerasure/jerasure/src/unittest_erasure_code_jerasure-galois.$(OBJEXT) \
 	erasure-code/jerasure/jerasure/src/unittest_erasure_code_jerasure-jerasure.$(OBJEXT) \
@@ -5064,14 +5227,14 @@ am__objects_46 = erasure-code/unittest_erasure_code_jerasure-ErasureCode.$(OBJEX
 	erasure-code/jerasure/unittest_erasure_code_jerasure-ErasureCodePluginJerasure.$(OBJEXT) \
 	erasure-code/jerasure/unittest_erasure_code_jerasure-ErasureCodeJerasure.$(OBJEXT)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_erasure_code_jerasure_OBJECTS = test/erasure-code/unittest_erasure_code_jerasure-TestErasureCodeJerasure.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_46)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_49)
 unittest_erasure_code_jerasure_OBJECTS =  \
 	$(am_unittest_erasure_code_jerasure_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_jerasure_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_jerasure_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5082,19 +5245,19 @@ am__unittest_erasure_code_lrc_SOURCES_DIST =  \
 	erasure-code/ErasureCode.cc \
 	erasure-code/lrc/ErasureCodePluginLrc.cc \
 	erasure-code/lrc/ErasureCodeLrc.cc
-am__objects_47 =  \
+am__objects_50 =  \
 	erasure-code/unittest_erasure_code_lrc-ErasureCode.$(OBJEXT) \
 	erasure-code/lrc/unittest_erasure_code_lrc-ErasureCodePluginLrc.$(OBJEXT) \
 	erasure-code/lrc/unittest_erasure_code_lrc-ErasureCodeLrc.$(OBJEXT)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_erasure_code_lrc_OBJECTS = test/erasure-code/unittest_erasure_code_lrc-TestErasureCodeLrc.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_47)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_50)
 unittest_erasure_code_lrc_OBJECTS =  \
 	$(am_unittest_erasure_code_lrc_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_lrc_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_lrc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5108,10 +5271,10 @@ am__unittest_erasure_code_plugin_SOURCES_DIST =  \
 unittest_erasure_code_plugin_OBJECTS =  \
 	$(am_unittest_erasure_code_plugin_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_plugin_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5124,10 +5287,10 @@ am__unittest_erasure_code_plugin_isa_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	test/erasure-code/unittest_erasure_code_plugin_isa-TestErasureCodePluginIsa.$(OBJEXT)
 unittest_erasure_code_plugin_isa_OBJECTS =  \
 	$(am_unittest_erasure_code_plugin_isa_OBJECTS)
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_isa_DEPENDENCIES = $(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_isa_DEPENDENCIES = $(am__DEPENDENCIES_16) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	.libs/libec_isa.la \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(LIBERASURE_CODE) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
@@ -5141,10 +5304,10 @@ am__unittest_erasure_code_plugin_jerasure_SOURCES_DIST =  \
 unittest_erasure_code_plugin_jerasure_OBJECTS =  \
 	$(am_unittest_erasure_code_plugin_jerasure_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_jerasure_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_plugin_jerasure_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -5156,10 +5319,10 @@ am__unittest_erasure_code_plugin_lrc_SOURCES_DIST =  \
 unittest_erasure_code_plugin_lrc_OBJECTS =  \
 	$(am_unittest_erasure_code_plugin_lrc_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_lrc_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_plugin_lrc_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -5171,10 +5334,10 @@ am__unittest_erasure_code_plugin_shec_SOURCES_DIST =  \
 unittest_erasure_code_plugin_shec_OBJECTS =  \
 	$(am_unittest_erasure_code_plugin_shec_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_shec_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_plugin_shec_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -5203,7 +5366,7 @@ am__unittest_erasure_code_shec_SOURCES_DIST =  \
 	erasure-code/jerasure/gf-complete/src/gf_w4.c \
 	erasure-code/jerasure/gf-complete/src/gf_rand.c \
 	erasure-code/jerasure/gf-complete/src/gf_w8.c
-am__objects_48 =  \
+am__objects_51 =  \
 	erasure-code/unittest_erasure_code_shec-ErasureCode.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec-ErasureCodePluginShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec-ErasureCodeShec.$(OBJEXT) \
@@ -5226,14 +5389,14 @@ am__objects_48 =  \
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec-gf_rand.$(OBJEXT) \
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec-gf_w8.$(OBJEXT)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_erasure_code_shec_OBJECTS = test/erasure-code/unittest_erasure_code_shec-TestErasureCodeShec.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_48)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_51)
 unittest_erasure_code_shec_OBJECTS =  \
 	$(am_unittest_erasure_code_shec_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_shec_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5262,7 +5425,7 @@ am__unittest_erasure_code_shec_all_SOURCES_DIST =  \
 	erasure-code/jerasure/gf-complete/src/gf_w4.c \
 	erasure-code/jerasure/gf-complete/src/gf_rand.c \
 	erasure-code/jerasure/gf-complete/src/gf_w8.c
-am__objects_49 = erasure-code/unittest_erasure_code_shec_all-ErasureCode.$(OBJEXT) \
+am__objects_52 = erasure-code/unittest_erasure_code_shec_all-ErasureCode.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_all-ErasureCodePluginShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_all-ErasureCodeShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_all-ErasureCodeShecTableCache.$(OBJEXT) \
@@ -5284,14 +5447,14 @@ am__objects_49 = erasure-code/unittest_erasure_code_shec_all-ErasureCode.$(OBJEX
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec_all-gf_rand.$(OBJEXT) \
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec_all-gf_w8.$(OBJEXT)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_erasure_code_shec_all_OBJECTS = test/erasure-code/unittest_erasure_code_shec_all-TestErasureCodeShec_all.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_49)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_52)
 unittest_erasure_code_shec_all_OBJECTS =  \
 	$(am_unittest_erasure_code_shec_all_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_all_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_shec_all_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5320,7 +5483,7 @@ am__unittest_erasure_code_shec_arguments_SOURCES_DIST =  \
 	erasure-code/jerasure/gf-complete/src/gf_w4.c \
 	erasure-code/jerasure/gf-complete/src/gf_rand.c \
 	erasure-code/jerasure/gf-complete/src/gf_w8.c
-am__objects_50 = erasure-code/unittest_erasure_code_shec_arguments-ErasureCode.$(OBJEXT) \
+am__objects_53 = erasure-code/unittest_erasure_code_shec_arguments-ErasureCode.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_arguments-ErasureCodePluginShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_arguments-ErasureCodeShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_arguments-ErasureCodeShecTableCache.$(OBJEXT) \
@@ -5342,14 +5505,14 @@ am__objects_50 = erasure-code/unittest_erasure_code_shec_arguments-ErasureCode.$
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec_arguments-gf_rand.$(OBJEXT) \
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec_arguments-gf_w8.$(OBJEXT)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_erasure_code_shec_arguments_OBJECTS = test/erasure-code/unittest_erasure_code_shec_arguments-TestErasureCodeShec_arguments.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_50)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_53)
 unittest_erasure_code_shec_arguments_OBJECTS =  \
 	$(am_unittest_erasure_code_shec_arguments_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_arguments_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_shec_arguments_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -5378,7 +5541,7 @@ am__unittest_erasure_code_shec_thread_SOURCES_DIST =  \
 	erasure-code/jerasure/gf-complete/src/gf_w4.c \
 	erasure-code/jerasure/gf-complete/src/gf_rand.c \
 	erasure-code/jerasure/gf-complete/src/gf_w8.c
-am__objects_51 = erasure-code/unittest_erasure_code_shec_thread-ErasureCode.$(OBJEXT) \
+am__objects_54 = erasure-code/unittest_erasure_code_shec_thread-ErasureCode.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_thread-ErasureCodePluginShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_thread-ErasureCodeShec.$(OBJEXT) \
 	erasure-code/shec/unittest_erasure_code_shec_thread-ErasureCodeShecTableCache.$(OBJEXT) \
@@ -5400,14 +5563,14 @@ am__objects_51 = erasure-code/unittest_erasure_code_shec_thread-ErasureCode.$(OB
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec_thread-gf_rand.$(OBJEXT) \
 	erasure-code/jerasure/gf-complete/src/unittest_erasure_code_shec_thread-gf_w8.$(OBJEXT)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_erasure_code_shec_thread_OBJECTS = test/erasure-code/unittest_erasure_code_shec_thread-TestErasureCodeShec_thread.$(OBJEXT) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_51)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__objects_54)
 unittest_erasure_code_shec_thread_OBJECTS =  \
 	$(am_unittest_erasure_code_shec_thread_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_thread_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_erasure_code_shec_thread_LINK = $(LIBTOOL) $(AM_V_lt) \
 	--tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
@@ -5415,8 +5578,8 @@ unittest_erasure_code_shec_thread_LINK = $(LIBTOOL) $(AM_V_lt) \
 	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_unittest_escape_OBJECTS = test/unittest_escape-escape.$(OBJEXT)
 unittest_escape_OBJECTS = $(am_unittest_escape_OBJECTS)
-unittest_escape_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_escape_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_escape_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_escape_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5425,16 +5588,16 @@ am_unittest_formatter_OBJECTS =  \
 	test/unittest_formatter-formatter.$(OBJEXT) \
 	rgw/unittest_formatter-rgw_formats.$(OBJEXT)
 unittest_formatter_OBJECTS = $(am_unittest_formatter_OBJECTS)
-unittest_formatter_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_formatter_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_formatter_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_formatter_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_gather_OBJECTS = test/unittest_gather-gather.$(OBJEXT)
 unittest_gather_OBJECTS = $(am_unittest_gather_OBJECTS)
-unittest_gather_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_gather_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_gather_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_gather_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5443,7 +5606,7 @@ am_unittest_heartbeatmap_OBJECTS =  \
 	test/unittest_heartbeatmap-heartbeat_map.$(OBJEXT)
 unittest_heartbeatmap_OBJECTS = $(am_unittest_heartbeatmap_OBJECTS)
 unittest_heartbeatmap_DEPENDENCIES = $(LIBCOMMON) \
-	$(am__DEPENDENCIES_16) $(am__DEPENDENCIES_8)
+	$(am__DEPENDENCIES_17) $(am__DEPENDENCIES_9)
 unittest_heartbeatmap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_heartbeatmap_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5451,8 +5614,8 @@ unittest_heartbeatmap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_histogram_OBJECTS =  \
 	test/common/unittest_histogram-histogram.$(OBJEXT)
 unittest_histogram_OBJECTS = $(am_unittest_histogram_OBJECTS)
-unittest_histogram_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_histogram_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_histogram_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_histogram_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5461,9 +5624,9 @@ am__unittest_hitset_SOURCES_DIST = test/osd/hitset.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_hitset_OBJECTS = test/osd/unittest_hitset-hitset.$(OBJEXT)
 unittest_hitset_OBJECTS = $(am_unittest_hitset_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_hitset_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9)
 unittest_hitset_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_hitset_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5471,8 +5634,8 @@ unittest_hitset_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_io_priority_OBJECTS =  \
 	test/common/unittest_io_priority-test_io_priority.$(OBJEXT)
 unittest_io_priority_OBJECTS = $(am_unittest_io_priority_OBJECTS)
-unittest_io_priority_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_io_priority_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_io_priority_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_io_priority_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5480,8 +5643,8 @@ unittest_io_priority_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_ipaddr_OBJECTS =  \
 	test/unittest_ipaddr-test_ipaddr.$(OBJEXT)
 unittest_ipaddr_OBJECTS = $(am_unittest_ipaddr_OBJECTS)
-unittest_ipaddr_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_ipaddr_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_ipaddr_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_ipaddr_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5513,9 +5676,10 @@ unittest_journal_OBJECTS = $(am_unittest_journal_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libcls_journal_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_test_stub.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_internal.la \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS)
 unittest_journal_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_journal_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5524,9 +5688,9 @@ am__unittest_lfnindex_SOURCES_DIST = test/os/TestLFNIndex.cc
 @ENABLE_SERVER_TRUE at am_unittest_lfnindex_OBJECTS = test/os/unittest_lfnindex-TestLFNIndex.$(OBJEXT)
 unittest_lfnindex_OBJECTS = $(am_unittest_lfnindex_OBJECTS)
 @ENABLE_SERVER_TRUE at unittest_lfnindex_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@	$(am__DEPENDENCIES_9)
 unittest_lfnindex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_lfnindex_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5536,8 +5700,8 @@ am__unittest_libcephfs_config_SOURCES_DIST = test/libcephfs_config.cc
 unittest_libcephfs_config_OBJECTS =  \
 	$(am_unittest_libcephfs_config_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at unittest_libcephfs_config_DEPENDENCIES = $(LIBCEPHFS) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_libcephfs_config_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_libcephfs_config_CXXFLAGS) $(CXXFLAGS) \
@@ -5547,8 +5711,8 @@ am__unittest_librados_SOURCES_DIST = test/librados/librados.cc
 unittest_librados_OBJECTS = $(am_unittest_librados_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at unittest_librados_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_librados_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_librados_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5560,8 +5724,8 @@ unittest_librados_config_OBJECTS =  \
 	$(am_unittest_librados_config_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at unittest_librados_config_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_librados_config_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_librados_config_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5569,8 +5733,10 @@ unittest_librados_config_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am__unittest_librbd_SOURCES_DIST = test/librbd/test_main.cc \
 	test/librbd/test_mock_fixture.cc \
 	test/librbd/test_mock_ExclusiveLock.cc \
+	test/librbd/test_mock_Journal.cc \
 	test/librbd/exclusive_lock/test_mock_AcquireRequest.cc \
 	test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc \
+	test/librbd/journal/test_mock_Replay.cc \
 	test/librbd/object_map/test_mock_InvalidateRequest.cc \
 	test/librbd/object_map/test_mock_LockRequest.cc \
 	test/librbd/object_map/test_mock_RefreshRequest.cc \
@@ -5580,15 +5746,19 @@ am__unittest_librbd_SOURCES_DIST = test/librbd/test_main.cc \
 	test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc \
 	test/librbd/object_map/test_mock_UnlockRequest.cc \
 	test/librbd/object_map/test_mock_UpdateRequest.cc \
+	test/librbd/operation/test_mock_ResizeRequest.cc \
 	test/librbd/operation/test_mock_SnapshotCreateRequest.cc \
 	test/librbd/operation/test_mock_SnapshotProtectRequest.cc \
 	test/librbd/operation/test_mock_SnapshotRemoveRequest.cc \
+	test/librbd/operation/test_mock_SnapshotRollbackRequest.cc \
 	test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at am_unittest_librbd_OBJECTS = test/librbd/unittest_librbd-test_main.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/unittest_librbd-test_mock_fixture.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/unittest_librbd-test_mock_ExclusiveLock.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/unittest_librbd-test_mock_Journal.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/exclusive_lock/unittest_librbd-test_mock_AcquireRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/exclusive_lock/unittest_librbd-test_mock_ReleaseRequest.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/journal/unittest_librbd-test_mock_Replay.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/unittest_librbd-test_mock_InvalidateRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/unittest_librbd-test_mock_LockRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/unittest_librbd-test_mock_RefreshRequest.$(OBJEXT) \
@@ -5598,9 +5768,11 @@ am__unittest_librbd_SOURCES_DIST = test/librbd/test_main.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/unittest_librbd-test_mock_SnapshotRollbackRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/unittest_librbd-test_mock_UnlockRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/unittest_librbd-test_mock_UpdateRequest.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/unittest_librbd-test_mock_SnapshotCreateRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/unittest_librbd-test_mock_SnapshotProtectRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/unittest_librbd-test_mock_SnapshotRemoveRequest.$(OBJEXT) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.$(OBJEXT) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/unittest_librbd-test_mock_SnapshotUnprotectRequest.$(OBJEXT)
 unittest_librbd_OBJECTS = $(am_unittest_librbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at unittest_librbd_DEPENDENCIES = librbd_test.la \
@@ -5613,24 +5785,25 @@ unittest_librbd_OBJECTS = $(am_unittest_librbd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	libcls_journal_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librados_test_stub.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librados_internal.la \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBOSDC) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8)
 unittest_librbd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_librbd_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_log_OBJECTS = log/unittest_log-test.$(OBJEXT)
 unittest_log_OBJECTS = $(am_unittest_log_OBJECTS)
-unittest_log_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_16)
+unittest_log_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_17)
 unittest_log_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(unittest_log_CXXFLAGS) \
 	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_unittest_lru_OBJECTS = test/common/unittest_lru-test_lru.$(OBJEXT)
 unittest_lru_OBJECTS = $(am_unittest_lru_OBJECTS)
-unittest_lru_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_lru_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_lru_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(unittest_lru_CXXFLAGS) \
 	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@@ -5638,9 +5811,9 @@ am__unittest_mds_authcap_SOURCES_DIST = test/mds/TestMDSAuthCaps.cc
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at am_unittest_mds_authcap_OBJECTS = test/mds/unittest_mds_authcap-TestMDSAuthCaps.$(OBJEXT)
 unittest_mds_authcap_OBJECTS = $(am_unittest_mds_authcap_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at unittest_mds_authcap_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_13) \
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_14) \
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@	$(am__DEPENDENCIES_9)
 unittest_mds_authcap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_mds_authcap_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5648,16 +5821,16 @@ unittest_mds_authcap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_mds_types_OBJECTS =  \
 	test/fs/unittest_mds_types-mds_types.$(OBJEXT)
 unittest_mds_types_OBJECTS = $(am_unittest_mds_types_OBJECTS)
-unittest_mds_types_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_mds_types_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_mds_types_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_mds_types_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_mime_OBJECTS = test/unittest_mime-mime.$(OBJEXT)
 unittest_mime_OBJECTS = $(am_unittest_mime_OBJECTS)
-unittest_mime_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_mime_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_mime_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_mime_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
@@ -5666,9 +5839,9 @@ am__unittest_mon_moncap_SOURCES_DIST = test/mon/moncap.cc
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am_unittest_mon_moncap_OBJECTS = test/mon/unittest_mon_moncap-moncap.$(OBJEXT)
 unittest_mon_moncap_OBJECTS = $(am_unittest_mon_moncap_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at unittest_mon_moncap_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_14) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_9)
 unittest_mon_moncap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_mon_moncap_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5677,9 +5850,9 @@ am__unittest_mon_pgmap_SOURCES_DIST = test/mon/PGMap.cc
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at am_unittest_mon_pgmap_OBJECTS = test/mon/unittest_mon_pgmap-PGMap.$(OBJEXT)
 unittest_mon_pgmap_OBJECTS = $(am_unittest_mon_pgmap_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at unittest_mon_pgmap_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_14) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_15) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_MON_TRUE@	$(am__DEPENDENCIES_9)
 unittest_mon_pgmap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_mon_pgmap_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5691,9 +5864,9 @@ am__unittest_osd_osdcap_SOURCES_DIST = test/osd/osdcap.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_osd_osdcap_OBJECTS = test/osd/unittest_osd_osdcap-osdcap.$(OBJEXT)
 unittest_osd_osdcap_OBJECTS = $(am_unittest_osd_osdcap_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_osd_osdcap_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9)
 unittest_osd_osdcap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_osd_osdcap_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5701,8 +5874,8 @@ unittest_osd_osdcap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_osd_types_OBJECTS =  \
 	test/osd/unittest_osd_types-types.$(OBJEXT)
 unittest_osd_types_OBJECTS = $(am_unittest_osd_types_OBJECTS)
-unittest_osd_types_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_osd_types_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_osd_types_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_osd_types_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5710,8 +5883,8 @@ unittest_osd_types_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_osdmap_OBJECTS =  \
 	test/osd/unittest_osdmap-TestOSDMap.$(OBJEXT)
 unittest_osdmap_OBJECTS = $(am_unittest_osdmap_OBJECTS)
-unittest_osdmap_DEPENDENCIES = $(am__DEPENDENCIES_16) $(LIBCOMMON) \
-	$(am__DEPENDENCIES_8)
+unittest_osdmap_DEPENDENCIES = $(am__DEPENDENCIES_17) $(LIBCOMMON) \
+	$(am__DEPENDENCIES_9)
 unittest_osdmap_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_osdmap_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5720,9 +5893,9 @@ am__unittest_osdscrub_SOURCES_DIST = test/osd/TestOSDScrub.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_osdscrub_OBJECTS = test/osd/unittest_osdscrub-TestOSDScrub.$(OBJEXT)
 unittest_osdscrub_OBJECTS = $(am_unittest_osdscrub_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_osdscrub_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_osdscrub_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5732,7 +5905,7 @@ am__unittest_pageset_SOURCES_DIST = test/test_pageset.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_pageset_OBJECTS = test/unittest_pageset-test_pageset.$(OBJEXT)
 unittest_pageset_OBJECTS = $(am_unittest_pageset_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_pageset_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17)
 unittest_pageset_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_pageset_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5740,8 +5913,8 @@ unittest_pageset_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_perf_counters_OBJECTS =  \
 	test/unittest_perf_counters-perf_counters.$(OBJEXT)
 unittest_perf_counters_OBJECTS = $(am_unittest_perf_counters_OBJECTS)
-unittest_perf_counters_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_perf_counters_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_perf_counters_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_perf_counters_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5750,9 +5923,9 @@ am__unittest_pglog_SOURCES_DIST = test/osd/TestPGLog.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at am_unittest_pglog_OBJECTS = test/osd/unittest_pglog-TestPGLog.$(OBJEXT)
 unittest_pglog_OBJECTS = $(am_unittest_pglog_OBJECTS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_pglog_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_15) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__DEPENDENCIES_1)
 unittest_pglog_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5762,7 +5935,7 @@ am_unittest_prebufferedstreambuf_OBJECTS = test/unittest_prebufferedstreambuf-te
 unittest_prebufferedstreambuf_OBJECTS =  \
 	$(am_unittest_prebufferedstreambuf_OBJECTS)
 unittest_prebufferedstreambuf_DEPENDENCIES = $(LIBCOMMON) \
-	$(am__DEPENDENCIES_16) $(am__DEPENDENCIES_3)
+	$(am__DEPENDENCIES_17) $(am__DEPENDENCIES_3)
 unittest_prebufferedstreambuf_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_prebufferedstreambuf_CXXFLAGS) $(CXXFLAGS) \
@@ -5770,8 +5943,8 @@ unittest_prebufferedstreambuf_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_prioritized_queue_OBJECTS = test/common/unittest_prioritized_queue-test_prioritized_queue.$(OBJEXT)
 unittest_prioritized_queue_OBJECTS =  \
 	$(am_unittest_prioritized_queue_OBJECTS)
-unittest_prioritized_queue_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_prioritized_queue_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_prioritized_queue_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_prioritized_queue_CXXFLAGS) $(CXXFLAGS) \
@@ -5782,10 +5955,10 @@ unittest_rbd_replay_OBJECTS = $(am_unittest_rbd_replay_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at unittest_rbd_replay_DEPENDENCIES =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRBD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd_replay_ios.la \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__DEPENDENCIES_17)
 unittest_rbd_replay_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_rbd_replay_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5793,8 +5966,8 @@ unittest_rbd_replay_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_readahead_OBJECTS =  \
 	test/common/unittest_readahead-Readahead.$(OBJEXT)
 unittest_readahead_OBJECTS = $(am_unittest_readahead_OBJECTS)
-unittest_readahead_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_readahead_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_readahead_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_readahead_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5804,9 +5977,9 @@ am__unittest_rocksdb_option_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at am_unittest_rocksdb_option_OBJECTS = test/objectstore/unittest_rocksdb_option-TestRocksdbOptionParse.$(OBJEXT)
 unittest_rocksdb_option_OBJECTS =  \
 	$(am_unittest_rocksdb_option_OBJECTS)
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at unittest_rocksdb_option_DEPENDENCIES = $(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE at unittest_rocksdb_option_DEPENDENCIES = $(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_DLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_9)
 unittest_rocksdb_option_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_rocksdb_option_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5816,9 +5989,9 @@ am__unittest_rocksdb_option_static_SOURCES_DIST =  \
 @ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at am_unittest_rocksdb_option_static_OBJECTS = test/objectstore/unittest_rocksdb_option_static-TestRocksdbOptionParse.$(OBJEXT)
 unittest_rocksdb_option_static_OBJECTS =  \
 	$(am_unittest_rocksdb_option_static_OBJECTS)
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at unittest_rocksdb_option_static_DEPENDENCIES = $(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_16) \
- at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_8)
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE at unittest_rocksdb_option_static_DEPENDENCIES = $(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_17) \
+ at ENABLE_SERVER_TRUE@@WITH_SLIBROCKSDB_TRUE@	$(am__DEPENDENCIES_9)
 unittest_rocksdb_option_static_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_rocksdb_option_static_CXXFLAGS) $(CXXFLAGS) \
@@ -5827,8 +6000,8 @@ am__unittest_run_cmd_SOURCES_DIST = test/run_cmd.cc
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am_unittest_run_cmd_OBJECTS = test/unittest_run_cmd-run_cmd.$(OBJEXT)
 unittest_run_cmd_OBJECTS = $(am_unittest_run_cmd_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at unittest_run_cmd_DEPENDENCIES = $(LIBCEPHFS) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_run_cmd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_run_cmd_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5836,8 +6009,8 @@ unittest_run_cmd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_safe_io_OBJECTS =  \
 	test/common/unittest_safe_io-test_safe_io.$(OBJEXT)
 unittest_safe_io_OBJECTS = $(am_unittest_safe_io_OBJECTS)
-unittest_safe_io_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_safe_io_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_safe_io_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_safe_io_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5845,8 +6018,8 @@ unittest_safe_io_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_shared_cache_OBJECTS =  \
 	test/common/unittest_shared_cache-test_shared_cache.$(OBJEXT)
 unittest_shared_cache_OBJECTS = $(am_unittest_shared_cache_OBJECTS)
-unittest_shared_cache_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_shared_cache_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_shared_cache_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_shared_cache_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5854,16 +6027,16 @@ unittest_shared_cache_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_sharedptr_registry_OBJECTS = test/common/unittest_sharedptr_registry-test_sharedptr_registry.$(OBJEXT)
 unittest_sharedptr_registry_OBJECTS =  \
 	$(am_unittest_sharedptr_registry_OBJECTS)
-unittest_sharedptr_registry_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_sharedptr_registry_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_sharedptr_registry_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_sharedptr_registry_CXXFLAGS) $(CXXFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
 am_unittest_signals_OBJECTS = test/unittest_signals-signals.$(OBJEXT)
 unittest_signals_OBJECTS = $(am_unittest_signals_OBJECTS)
-unittest_signals_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_signals_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_signals_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_signals_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5872,8 +6045,8 @@ am__unittest_simple_spin_SOURCES_DIST = test/simple_spin.cc
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am_unittest_simple_spin_OBJECTS = test/unittest_simple_spin-simple_spin.$(OBJEXT)
 unittest_simple_spin_OBJECTS = $(am_unittest_simple_spin_OBJECTS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at unittest_simple_spin_DEPENDENCIES = $(LIBCEPHFS) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_8) \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_16)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_9) \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__DEPENDENCIES_17)
 unittest_simple_spin_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_simple_spin_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5881,8 +6054,8 @@ unittest_simple_spin_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_sloppy_crc_map_OBJECTS = test/common/unittest_sloppy_crc_map-test_sloppy_crc_map.$(OBJEXT)
 unittest_sloppy_crc_map_OBJECTS =  \
 	$(am_unittest_sloppy_crc_map_OBJECTS)
-unittest_sloppy_crc_map_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_sloppy_crc_map_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_sloppy_crc_map_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_sloppy_crc_map_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5890,8 +6063,8 @@ unittest_sloppy_crc_map_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_str_list_OBJECTS =  \
 	test/unittest_str_list-test_str_list.$(OBJEXT)
 unittest_str_list_OBJECTS = $(am_unittest_str_list_OBJECTS)
-unittest_str_list_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_str_list_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_str_list_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_str_list_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5899,8 +6072,8 @@ unittest_str_list_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_str_map_OBJECTS =  \
 	test/common/unittest_str_map-test_str_map.$(OBJEXT)
 unittest_str_map_OBJECTS = $(am_unittest_str_map_OBJECTS)
-unittest_str_map_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_str_map_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_str_map_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_str_map_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5908,16 +6081,16 @@ unittest_str_map_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_striper_OBJECTS =  \
 	test/unittest_striper-test_striper.$(OBJEXT)
 unittest_striper_OBJECTS = $(am_unittest_striper_OBJECTS)
-unittest_striper_DEPENDENCIES = $(LIBOSDC) $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_striper_DEPENDENCIES = $(LIBOSDC) $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_striper_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_striper_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_strtol_OBJECTS = test/unittest_strtol-strtol.$(OBJEXT)
 unittest_strtol_OBJECTS = $(am_unittest_strtol_OBJECTS)
-unittest_strtol_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_strtol_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_strtol_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_strtol_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5925,7 +6098,7 @@ unittest_strtol_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_subprocess_OBJECTS =  \
 	test/unittest_subprocess-test_subprocess.$(OBJEXT)
 unittest_subprocess_OBJECTS = $(am_unittest_subprocess_OBJECTS)
-unittest_subprocess_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_16)
+unittest_subprocess_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_17)
 unittest_subprocess_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_subprocess_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5933,8 +6106,8 @@ unittest_subprocess_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_tableformatter_OBJECTS = test/common/unittest_tableformatter-test_tableformatter.$(OBJEXT)
 unittest_tableformatter_OBJECTS =  \
 	$(am_unittest_tableformatter_OBJECTS)
-unittest_tableformatter_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_tableformatter_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_tableformatter_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_tableformatter_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5942,7 +6115,7 @@ unittest_tableformatter_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_texttable_OBJECTS =  \
 	test/unittest_texttable-test_texttable.$(OBJEXT)
 unittest_texttable_OBJECTS = $(am_unittest_texttable_OBJECTS)
-unittest_texttable_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_16)
+unittest_texttable_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_17)
 unittest_texttable_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_texttable_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5950,16 +6123,25 @@ unittest_texttable_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_throttle_OBJECTS =  \
 	test/common/unittest_throttle-Throttle.$(OBJEXT)
 unittest_throttle_OBJECTS = $(am_unittest_throttle_OBJECTS)
-unittest_throttle_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_throttle_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_throttle_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_throttle_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
+am_unittest_time_OBJECTS =  \
+	test/common/unittest_time-test_time.$(OBJEXT)
+unittest_time_OBJECTS = $(am_unittest_time_OBJECTS)
+unittest_time_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
+unittest_time_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(unittest_time_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+	-o $@
 am_unittest_utf8_OBJECTS = test/unittest_utf8-utf8.$(OBJEXT)
 unittest_utf8_OBJECTS = $(am_unittest_utf8_OBJECTS)
-unittest_utf8_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_utf8_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_utf8_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_utf8_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
@@ -5967,7 +6149,7 @@ unittest_utf8_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_util_OBJECTS =  \
 	test/common/unittest_util-test_util.$(OBJEXT)
 unittest_util_OBJECTS = $(am_unittest_util_OBJECTS)
-unittest_util_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_16) \
+unittest_util_DEPENDENCIES = $(LIBCOMMON) $(am__DEPENDENCIES_17) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_3)
 unittest_util_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -5976,15 +6158,15 @@ unittest_util_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 am_unittest_workqueue_OBJECTS =  \
 	test/unittest_workqueue-test_workqueue.$(OBJEXT)
 unittest_workqueue_OBJECTS = $(am_unittest_workqueue_OBJECTS)
-unittest_workqueue_DEPENDENCIES = $(am__DEPENDENCIES_16) \
-	$(am__DEPENDENCIES_8)
+unittest_workqueue_DEPENDENCIES = $(am__DEPENDENCIES_17) \
+	$(am__DEPENDENCIES_9)
 unittest_workqueue_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_workqueue_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 am_unittest_xlist_OBJECTS = test/unittest_xlist-test_xlist.$(OBJEXT)
 unittest_xlist_OBJECTS = $(am_unittest_xlist_OBJECTS)
-unittest_xlist_DEPENDENCIES = $(am__DEPENDENCIES_16) $(LIBCOMMON)
+unittest_xlist_DEPENDENCIES = $(am__DEPENDENCIES_17) $(LIBCOMMON)
 unittest_xlist_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
 	$(unittest_xlist_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
@@ -5995,8 +6177,8 @@ am__xio_client_SOURCES_DIST = test/messenger/xio_client.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_client-xio_dispatcher.$(OBJEXT)
 xio_client_OBJECTS = $(am_xio_client_OBJECTS)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at xio_client_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_3) \
@@ -6010,8 +6192,8 @@ am__xio_server_SOURCES_DIST = test/messenger/xio_server.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_server-xio_dispatcher.$(OBJEXT)
 xio_server_OBJECTS = $(am_xio_server_OBJECTS)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at xio_server_DEPENDENCIES =  \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_11) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_8) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_12) \
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_9) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_1) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__DEPENDENCIES_3) \
@@ -6102,7 +6284,8 @@ SOURCES = $(libcls_log_client_a_SOURCES) \
 	$(libmon_a_SOURCES) $(libos_a_SOURCES) \
 	$(libos_types_a_SOURCES) $(libos_zfs_a_SOURCES) \
 	$(libosd_a_SOURCES) $(libarch_la_SOURCES) \
-	$(libauth_la_SOURCES) $(libcephfs_la_SOURCES) \
+	$(libauth_la_SOURCES) $(libceph_example_la_SOURCES) \
+	$(libceph_snappy_la_SOURCES) $(libcephfs_la_SOURCES) \
 	$(libcephfs_jni_la_SOURCES) $(libcivetweb_la_SOURCES) \
 	$(libclient_la_SOURCES) $(libclient_fuse_la_SOURCES) \
 	$(libcls_cephfs_la_SOURCES) $(libcls_cephfs_client_la_SOURCES) \
@@ -6160,14 +6343,14 @@ SOURCES = $(libcls_log_client_a_SOURCES) \
 	$(librbd_tp_la_SOURCES) $(nodist_librbd_tp_la_SOURCES) \
 	$(librbd_types_la_SOURCES) $(librgw_la_SOURCES) \
 	$(libsecret_la_SOURCES) $(libsystest_la_SOURCES) \
-	$(ceph_authtool_SOURCES) $(ceph_client_debug_SOURCES) \
-	$(ceph_conf_SOURCES) $(ceph_dencoder_SOURCES) \
-	$(ceph_fuse_SOURCES) $(ceph_kvstore_tool_SOURCES) \
-	$(ceph_mds_SOURCES) $(ceph_mon_SOURCES) \
-	$(ceph_monstore_tool_SOURCES) $(ceph_objectstore_tool_SOURCES) \
-	$(ceph_osd_SOURCES) $(ceph_osdomap_tool_SOURCES) \
-	$(ceph_syn_SOURCES) $(ceph_bench_log_SOURCES) \
-	$(ceph_erasure_code_SOURCES) \
+	$(ceph_authtool_SOURCES) $(ceph_bluefs_tool_SOURCES) \
+	$(ceph_client_debug_SOURCES) $(ceph_conf_SOURCES) \
+	$(ceph_dencoder_SOURCES) $(ceph_fuse_SOURCES) \
+	$(ceph_kvstore_tool_SOURCES) $(ceph_mds_SOURCES) \
+	$(ceph_mon_SOURCES) $(ceph_monstore_tool_SOURCES) \
+	$(ceph_objectstore_tool_SOURCES) $(ceph_osd_SOURCES) \
+	$(ceph_osdomap_tool_SOURCES) $(ceph_syn_SOURCES) \
+	$(ceph_bench_log_SOURCES) $(ceph_erasure_code_SOURCES) \
 	$(ceph_erasure_code_benchmark_SOURCES) \
 	$(ceph_erasure_code_non_regression_SOURCES) \
 	$(ceph_kvstorebench_SOURCES) \
@@ -6181,7 +6364,7 @@ SOURCES = $(libcls_log_client_a_SOURCES) \
 	$(ceph_scratchtoolpp_SOURCES) $(ceph_smalliobench_SOURCES) \
 	$(ceph_smalliobenchdumb_SOURCES) \
 	$(ceph_smalliobenchfs_SOURCES) $(ceph_smalliobenchrbd_SOURCES) \
-	$(ceph_streamtest_SOURCES) $(ceph_test_async_driver_SOURCES) \
+	$(ceph_test_async_driver_SOURCES) \
 	$(ceph_test_c_headers_SOURCES) \
 	$(ceph_test_cfuse_cache_invalidate_SOURCES) \
 	$(ceph_test_cls_hello_SOURCES) \
@@ -6256,15 +6439,19 @@ SOURCES = $(libcls_log_client_a_SOURCES) \
 	$(unittest_async_compressor_SOURCES) \
 	$(unittest_base64_SOURCES) $(unittest_bit_vector_SOURCES) \
 	$(unittest_blkdev_SOURCES) $(unittest_bloom_filter_SOURCES) \
+	$(unittest_bluefs_SOURCES) $(unittest_bluestore_types_SOURCES) \
 	$(unittest_bufferlist_SOURCES) \
 	$(unittest_ceph_argparse_SOURCES) \
 	$(unittest_ceph_compatset_SOURCES) \
 	$(unittest_ceph_crypto_SOURCES) \
-	$(unittest_chain_xattr_SOURCES) $(unittest_config_SOURCES) \
-	$(unittest_confutils_SOURCES) $(unittest_context_SOURCES) \
-	$(unittest_crc32c_SOURCES) $(unittest_crush_SOURCES) \
-	$(unittest_crush_wrapper_SOURCES) $(unittest_crypto_SOURCES) \
-	$(unittest_crypto_init_SOURCES) \
+	$(unittest_chain_xattr_SOURCES) \
+	$(unittest_compression_plugin_SOURCES) \
+	$(unittest_compression_plugin_snappy_SOURCES) \
+	$(unittest_compression_snappy_SOURCES) \
+	$(unittest_config_SOURCES) $(unittest_confutils_SOURCES) \
+	$(unittest_context_SOURCES) $(unittest_crc32c_SOURCES) \
+	$(unittest_crush_SOURCES) $(unittest_crush_wrapper_SOURCES) \
+	$(unittest_crypto_SOURCES) $(unittest_crypto_init_SOURCES) \
 	$(unittest_daemon_config_SOURCES) \
 	$(unittest_ecbackend_SOURCES) $(unittest_encoding_SOURCES) \
 	$(unittest_erasure_code_SOURCES) \
@@ -6312,9 +6499,10 @@ SOURCES = $(libcls_log_client_a_SOURCES) \
 	$(unittest_subprocess_SOURCES) \
 	$(unittest_tableformatter_SOURCES) \
 	$(unittest_texttable_SOURCES) $(unittest_throttle_SOURCES) \
-	$(unittest_utf8_SOURCES) $(unittest_util_SOURCES) \
-	$(unittest_workqueue_SOURCES) $(unittest_xlist_SOURCES) \
-	$(xio_client_SOURCES) $(xio_server_SOURCES)
+	$(unittest_time_SOURCES) $(unittest_utf8_SOURCES) \
+	$(unittest_util_SOURCES) $(unittest_workqueue_SOURCES) \
+	$(unittest_xlist_SOURCES) $(xio_client_SOURCES) \
+	$(xio_server_SOURCES)
 DIST_SOURCES = $(am__libcls_log_client_a_SOURCES_DIST) \
 	$(am__libcls_replica_log_client_a_SOURCES_DIST) \
 	$(am__libcls_statelog_client_a_SOURCES_DIST) \
@@ -6325,7 +6513,8 @@ DIST_SOURCES = $(am__libcls_log_client_a_SOURCES_DIST) \
 	$(am__libos_a_SOURCES_DIST) $(am__libos_types_a_SOURCES_DIST) \
 	$(am__libos_zfs_a_SOURCES_DIST) $(am__libosd_a_SOURCES_DIST) \
 	$(libarch_la_SOURCES) $(libauth_la_SOURCES) \
-	$(am__libcephfs_la_SOURCES_DIST) \
+	$(am__libceph_example_la_SOURCES_DIST) \
+	$(libceph_snappy_la_SOURCES) $(am__libcephfs_la_SOURCES_DIST) \
 	$(am__libcephfs_jni_la_SOURCES_DIST) \
 	$(am__libcivetweb_la_SOURCES_DIST) \
 	$(am__libclient_la_SOURCES_DIST) \
@@ -6403,6 +6592,7 @@ DIST_SOURCES = $(am__libcls_log_client_a_SOURCES_DIST) \
 	$(am__librbd_tp_la_SOURCES_DIST) $(librbd_types_la_SOURCES) \
 	$(am__librgw_la_SOURCES_DIST) $(libsecret_la_SOURCES) \
 	$(am__libsystest_la_SOURCES_DIST) $(ceph_authtool_SOURCES) \
+	$(am__ceph_bluefs_tool_SOURCES_DIST) \
 	$(am__ceph_client_debug_SOURCES_DIST) $(ceph_conf_SOURCES) \
 	$(am__ceph_dencoder_SOURCES_DIST) \
 	$(am__ceph_fuse_SOURCES_DIST) \
@@ -6433,7 +6623,6 @@ DIST_SOURCES = $(am__libcls_log_client_a_SOURCES_DIST) \
 	$(am__ceph_smalliobenchdumb_SOURCES_DIST) \
 	$(am__ceph_smalliobenchfs_SOURCES_DIST) \
 	$(am__ceph_smalliobenchrbd_SOURCES_DIST) \
-	$(am__ceph_streamtest_SOURCES_DIST) \
 	$(am__ceph_test_async_driver_SOURCES_DIST) \
 	$(am__ceph_test_c_headers_SOURCES_DIST) \
 	$(ceph_test_cfuse_cache_invalidate_SOURCES) \
@@ -6531,11 +6720,16 @@ DIST_SOURCES = $(am__libcls_log_client_a_SOURCES_DIST) \
 	$(am__unittest_base64_SOURCES_DIST) \
 	$(unittest_bit_vector_SOURCES) $(unittest_blkdev_SOURCES) \
 	$(unittest_bloom_filter_SOURCES) \
+	$(am__unittest_bluefs_SOURCES_DIST) \
+	$(am__unittest_bluestore_types_SOURCES_DIST) \
 	$(unittest_bufferlist_SOURCES) \
 	$(unittest_ceph_argparse_SOURCES) \
 	$(unittest_ceph_compatset_SOURCES) \
 	$(unittest_ceph_crypto_SOURCES) \
 	$(am__unittest_chain_xattr_SOURCES_DIST) \
+	$(am__unittest_compression_plugin_SOURCES_DIST) \
+	$(am__unittest_compression_plugin_snappy_SOURCES_DIST) \
+	$(am__unittest_compression_snappy_SOURCES_DIST) \
 	$(unittest_config_SOURCES) $(unittest_confutils_SOURCES) \
 	$(unittest_context_SOURCES) $(unittest_crc32c_SOURCES) \
 	$(unittest_crush_SOURCES) $(unittest_crush_wrapper_SOURCES) \
@@ -6597,9 +6791,10 @@ DIST_SOURCES = $(am__libcls_log_client_a_SOURCES_DIST) \
 	$(unittest_subprocess_SOURCES) \
 	$(unittest_tableformatter_SOURCES) \
 	$(unittest_texttable_SOURCES) $(unittest_throttle_SOURCES) \
-	$(unittest_utf8_SOURCES) $(unittest_util_SOURCES) \
-	$(unittest_workqueue_SOURCES) $(unittest_xlist_SOURCES) \
-	$(am__xio_client_SOURCES_DIST) $(am__xio_server_SOURCES_DIST)
+	$(unittest_time_SOURCES) $(unittest_utf8_SOURCES) \
+	$(unittest_util_SOURCES) $(unittest_workqueue_SOURCES) \
+	$(unittest_xlist_SOURCES) $(am__xio_client_SOURCES_DIST) \
+	$(am__xio_server_SOURCES_DIST)
 RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
 	ctags-recursive dvi-recursive html-recursive info-recursive \
 	install-data-recursive install-dvi-recursive \
@@ -6614,7 +6809,8 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__python_PYTHON_DIST = pybind/ceph_argparse.py pybind/ceph_daemon.py \
-	pybind/rados.py pybind/cephfs.py pybind/ceph_rest_api.py
+	pybind/rados.py pybind/cephfs.py pybind/ceph_volume_client.py \
+	pybind/ceph_rest_api.py
 am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile)
 am__pep3147_tweak = \
   sed -e 's|\.py$$||' -e 's|[^/]*$$|__pycache__/&.*.py|'
@@ -6675,21 +6871,31 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	mds/events/ESessions.h mds/events/ESlaveUpdate.h \
 	mds/events/ESubtreeMap.h mds/events/ETableClient.h \
 	mds/events/ETableServer.h mds/events/EUpdate.h \
-	os/btrfs_ioctl.h os/chain_xattr.h os/newstore/newstore_types.h \
-	os/newstore/NewStore.h os/BtrfsFileStoreBackend.h \
-	os/CollectionIndex.h os/DBObjectMap.h os/GenericObjectMap.h \
-	os/FileJournal.h os/FileStore.h os/FDCache.h os/fs/FS.h \
-	os/fs/XFS.h os/GenericFileStoreBackend.h os/HashIndex.h \
-	os/IndexManager.h os/Journal.h os/JournalingObjectStore.h \
-	os/LFNIndex.h os/MemStore.h os/KeyValueStore.h os/ObjectMap.h \
-	os/ObjectStore.h os/PageSet.h os/SequencerPosition.h \
-	os/WBThrottle.h os/XfsFileStoreBackend.h \
-	os/ZFSFileStoreBackend.h os/ZFS.h osd/ClassHandler.h \
-	osd/HitSet.h osd/OSD.h osd/OSDCap.h osd/OSDMap.h \
-	osd/ObjectVersioner.h osd/OpRequest.h osd/SnapMapper.h \
-	osd/PG.h osd/PGLog.h osd/ReplicatedPG.h osd/PGBackend.h \
-	osd/ReplicatedBackend.h osd/TierAgentState.h osd/ECBackend.h \
-	osd/ECUtil.h osd/ECMsgTypes.h osd/ECTransaction.h osd/Watch.h \
+	os/filestore/chain_xattr.h \
+	os/filestore/BtrfsFileStoreBackend.h \
+	os/filestore/CollectionIndex.h os/filestore/DBObjectMap.h \
+	os/filestore/FileJournal.h os/filestore/FileStore.h \
+	os/filestore/FDCache.h os/filestore/GenericFileStoreBackend.h \
+	os/filestore/HashIndex.h os/filestore/IndexManager.h \
+	os/filestore/Journal.h os/filestore/JournalingObjectStore.h \
+	os/filestore/LFNIndex.h os/filestore/SequencerPosition.h \
+	os/filestore/WBThrottle.h os/filestore/XfsFileStoreBackend.h \
+	os/filestore/ZFSFileStoreBackend.h os/fs/btrfs_ioctl.h \
+	os/fs/FS.h os/fs/XFS.h os/keyvaluestore/GenericObjectMap.h \
+	os/keyvaluestore/KeyValueStore.h os/kstore/kstore_types.h \
+	os/kstore/KStore.h os/kstore/kv.h os/memstore/MemStore.h \
+	os/memstore/PageSet.h os/ObjectMap.h os/ObjectStore.h \
+	os/bluestore/bluefs_types.h os/bluestore/bluestore_types.h \
+	os/bluestore/kv.h os/bluestore/Allocator.h \
+	os/bluestore/BlockDevice.h os/bluestore/BlueFS.h \
+	os/bluestore/BlueRocksEnv.h os/bluestore/BlueStore.h \
+	os/bluestore/FreelistManager.h os/bluestore/StupidAllocator.h \
+	os/fs/ZFS.h osd/ClassHandler.h osd/HitSet.h osd/OSD.h \
+	osd/OSDCap.h osd/OSDMap.h osd/ObjectVersioner.h \
+	osd/OpRequest.h osd/SnapMapper.h osd/PG.h osd/PGLog.h \
+	osd/ReplicatedPG.h osd/PGBackend.h osd/ReplicatedBackend.h \
+	osd/TierAgentState.h osd/ECBackend.h osd/ECUtil.h \
+	osd/ECMsgTypes.h osd/ECTransaction.h osd/Watch.h \
 	osd/osd_types.h \
 	erasure-code/jerasure/gf-complete/include/gf_complete.h \
 	erasure-code/jerasure/gf-complete/include/gf_general.h \
@@ -6719,16 +6925,19 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	erasure-code/isa/isa-l/include/gf_vect_mul.h \
 	erasure-code/isa/isa-l/include/types.h \
 	erasure-code/ErasureCode.h erasure-code/ErasureCodeInterface.h \
-	erasure-code/ErasureCodePlugin.h osdc/Filer.h osdc/Journaler.h \
-	osdc/ObjectCacher.h osdc/Objecter.h osdc/Striper.h \
-	osdc/WritebackHandler.h client/Client.h client/Dentry.h \
-	client/Dir.h client/Fh.h client/Inode.h client/InodeRef.h \
-	client/MetaRequest.h client/MetaSession.h \
-	client/ClientSnapRealm.h client/SyntheticClient.h \
-	client/Trace.h client/ioctl.h client/ObjecterWriteback.h \
-	client/fuse_ll.h global/pidfile.h global/global_init.h \
-	global/global_context.h global/signal_handler.h \
-	json_spirit/json_spirit.h \
+	erasure-code/ErasureCodePlugin.h \
+	compressor/snappy/SnappyCompressor.h compressor/Compressor.h \
+	compressor/AsyncCompressor.h compressor/CompressionPlugin.h \
+	osdc/Filer.h osdc/Journaler.h osdc/ObjectCacher.h \
+	osdc/Objecter.h osdc/Striper.h osdc/WritebackHandler.h \
+	client/Client.h client/Dentry.h client/Dir.h client/Fh.h \
+	client/Inode.h client/InodeRef.h client/MetaRequest.h \
+	client/MetaSession.h client/ClientSnapRealm.h \
+	client/SyntheticClient.h client/Trace.h client/ioctl.h \
+	client/ObjecterWriteback.h client/posix_acl.h \
+	client/UserGroups.h client/fuse_ll.h global/pidfile.h \
+	global/global_init.h global/global_context.h \
+	global/signal_handler.h json_spirit/json_spirit.h \
 	json_spirit/json_spirit_error_position.h \
 	json_spirit/json_spirit_reader.h \
 	json_spirit/json_spirit_reader_template.h \
@@ -6777,20 +6986,21 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	common/ContextCompletion.h common/bit_vector.hpp \
 	common/SubProcess.h common/valgrind.h \
 	common/TracepointProvider.h common/event_socket.h \
-	common/PluginRegistry.h common/address_helper.h \
-	common/secret.h msg/Connection.h msg/Dispatcher.h \
-	msg/Message.h msg/Messenger.h msg/SimplePolicyMessenger.h \
-	msg/msg_types.h msg/simple/Accepter.h \
-	msg/simple/DispatchQueue.h msg/simple/Pipe.h \
-	msg/simple/PipeConnection.h msg/simple/SimpleMessenger.h \
-	msg/async/AsyncConnection.h msg/async/AsyncMessenger.h \
-	msg/async/Event.h msg/async/EventEpoll.h \
-	msg/async/EventSelect.h msg/async/net_handler.h \
-	msg/xio/DispatchStrategy.h msg/xio/FastStrategy.h \
-	msg/xio/QueueStrategy.h msg/xio/XioConnection.h \
-	msg/xio/XioInSeq.h msg/xio/XioMessenger.h msg/xio/XioMsg.h \
-	msg/xio/XioPool.h msg/xio/XioPortal.h msg/xio/XioSubmit.h \
-	messages/MAuth.h messages/MAuthReply.h messages/MCacheExpire.h \
+	common/PluginRegistry.h common/ceph_time.h common/ceph_timer.h \
+	common/address_helper.h common/secret.h msg/Connection.h \
+	msg/Dispatcher.h msg/Message.h msg/Messenger.h \
+	msg/SimplePolicyMessenger.h msg/msg_types.h \
+	msg/simple/Accepter.h msg/simple/DispatchQueue.h \
+	msg/simple/Pipe.h msg/simple/PipeConnection.h \
+	msg/simple/SimpleMessenger.h msg/async/AsyncConnection.h \
+	msg/async/AsyncMessenger.h msg/async/Event.h \
+	msg/async/EventEpoll.h msg/async/EventSelect.h \
+	msg/async/net_handler.h msg/xio/DispatchStrategy.h \
+	msg/xio/FastStrategy.h msg/xio/QueueStrategy.h \
+	msg/xio/XioConnection.h msg/xio/XioInSeq.h \
+	msg/xio/XioMessenger.h msg/xio/XioMsg.h msg/xio/XioPool.h \
+	msg/xio/XioPortal.h msg/xio/XioSubmit.h messages/MAuth.h \
+	messages/MAuthReply.h messages/MCacheExpire.h \
 	messages/MClientCaps.h messages/MClientCapRelease.h \
 	messages/MClientLease.h messages/MClientReconnect.h \
 	messages/MClientReply.h messages/MClientRequest.h \
@@ -6895,15 +7105,16 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	librbd/AsyncRequest.h librbd/CopyupRequest.h \
 	librbd/DiffIterate.h librbd/ExclusiveLock.h librbd/ImageCtx.h \
 	librbd/ImageState.h librbd/ImageWatcher.h librbd/internal.h \
-	librbd/Journal.h librbd/JournalReplay.h librbd/JournalTypes.h \
-	librbd/LibrbdAdminSocketHook.h librbd/LibrbdWriteback.h \
-	librbd/ObjectMap.h librbd/parent_types.h librbd/SnapInfo.h \
+	librbd/Journal.h librbd/LibrbdAdminSocketHook.h \
+	librbd/LibrbdWriteback.h librbd/ObjectMap.h \
+	librbd/Operations.h librbd/parent_types.h librbd/SnapInfo.h \
 	librbd/TaskFinisher.h librbd/Utils.h librbd/WatchNotifyTypes.h \
 	librbd/exclusive_lock/AcquireRequest.h \
 	librbd/exclusive_lock/ReleaseRequest.h \
 	librbd/image/CloseRequest.h librbd/image/OpenRequest.h \
 	librbd/image/RefreshParentRequest.h \
 	librbd/image/RefreshRequest.h librbd/image/SetSnapRequest.h \
+	librbd/journal/Replay.h librbd/journal/Entries.h \
 	librbd/object_map/InvalidateRequest.h \
 	librbd/object_map/LockRequest.h librbd/object_map/Request.h \
 	librbd/object_map/RefreshRequest.h \
@@ -6981,6 +7192,7 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	test/messenger/message_helper.h \
 	test/messenger/simple_dispatcher.h \
 	test/messenger/xio_dispatcher.h \
+	test/compressor/compressor_example.h \
 	test/librados_test_stub/LibradosTestStub.h \
 	test/librados_test_stub/MockTestMemIoCtxImpl.h \
 	test/librados_test_stub/MockTestMemRadosClient.h \
@@ -6999,6 +7211,7 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	test/librbd/mock/MockImageWatcher.h \
 	test/librbd/mock/MockJournal.h \
 	test/librbd/mock/MockObjectMap.h \
+	test/librbd/mock/MockOperations.h \
 	test/librbd/mock/MockReadahead.h \
 	test/librbd/object_map/mock/MockInvalidateRequest.h \
 	test/perf_helper.h test/bench/backend.h test/bench/bencher.h \
@@ -7033,12 +7246,11 @@ am__noinst_HEADERS_DIST = arch/intel.h arch/arm.h arch/probe.h \
 	tools/cephfs/TableTool.h tools/cephfs/MDSUtility.h \
 	tools/RadosDump.h tools/rados/RadosImport.h \
 	tools/ceph_objectstore_tool.h tools/rados/PoolDump.h \
-	tools/cephfs/DataScan.h compressor/Compressor.h \
-	compressor/AsyncCompressor.h compressor/SnappyCompressor.h \
-	cls_acl.cc cls_crypto.cc fetch_config logrotate.conf \
-	sample.ceph.conf bash_completion/ceph bash_completion/rados \
-	bash_completion/rbd bash_completion/radosgw-admin \
-	mount/canonicalize.c mount/mtab.c objclass/objclass.h
+	tools/cephfs/DataScan.h cls_acl.cc cls_crypto.cc fetch_config \
+	logrotate.conf sample.ceph.conf bash_completion/ceph \
+	bash_completion/rados bash_completion/rbd \
+	bash_completion/radosgw-admin mount/canonicalize.c \
+	mount/mtab.c objclass/objclass.h
 HEADERS = $(noinst_HEADERS)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
@@ -7244,6 +7456,44 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log)
 TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
 	$(TEST_LOG_FLAGS)
+am__DIST_COMMON = $(srcdir)/Makefile-client.am \
+	$(srcdir)/Makefile-env.am $(srcdir)/Makefile-rocksdb.am \
+	$(srcdir)/Makefile-server.am $(srcdir)/Makefile.in \
+	$(srcdir)/acconfig.h.in $(srcdir)/arch/Makefile.am \
+	$(srcdir)/auth/Makefile.am $(srcdir)/brag/Makefile.am \
+	$(srcdir)/ceph-detect-init/Makefile.am \
+	$(srcdir)/client/Makefile.am $(srcdir)/cls/Makefile-client.am \
+	$(srcdir)/cls/Makefile-server.am $(srcdir)/cls/Makefile.am \
+	$(srcdir)/common/Makefile.am $(srcdir)/compressor/Makefile.am \
+	$(srcdir)/compressor/snappy/Makefile.am \
+	$(srcdir)/crush/Makefile.am $(srcdir)/erasure-code/Makefile.am \
+	$(srcdir)/erasure-code/isa/Makefile.am \
+	$(srcdir)/erasure-code/jerasure/Makefile.am \
+	$(srcdir)/erasure-code/lrc/Makefile.am \
+	$(srcdir)/erasure-code/shec/Makefile.am \
+	$(srcdir)/global/Makefile.am $(srcdir)/include/Makefile.am \
+	$(srcdir)/journal/Makefile.am \
+	$(srcdir)/json_spirit/Makefile.am \
+	$(srcdir)/key_value_store/Makefile.am $(srcdir)/kv/Makefile.am \
+	$(srcdir)/librados/Makefile.am \
+	$(srcdir)/libradosstriper/Makefile.am \
+	$(srcdir)/librbd/Makefile.am $(srcdir)/log/Makefile.am \
+	$(srcdir)/mds/Makefile-client.am \
+	$(srcdir)/mds/Makefile-server.am $(srcdir)/mds/Makefile.am \
+	$(srcdir)/messages/Makefile.am $(srcdir)/mon/Makefile.am \
+	$(srcdir)/msg/Makefile.am $(srcdir)/os/Makefile.am \
+	$(srcdir)/osd/Makefile.am $(srcdir)/osdc/Makefile.am \
+	$(srcdir)/perfglue/Makefile.am $(srcdir)/pybind/Makefile.am \
+	$(srcdir)/rbd_replay/Makefile.am $(srcdir)/rgw/Makefile.am \
+	$(srcdir)/test/Makefile-client.am \
+	$(srcdir)/test/Makefile-server.am $(srcdir)/test/Makefile.am \
+	$(srcdir)/test/compressor/Makefile.am \
+	$(srcdir)/test/erasure-code/Makefile.am \
+	$(srcdir)/test/messenger/Makefile.am \
+	$(srcdir)/tools/Makefile-client.am \
+	$(srcdir)/tools/Makefile-server.am $(srcdir)/tools/Makefile.am \
+	$(srcdir)/tracing/Makefile.am $(top_srcdir)/depcomp \
+	$(top_srcdir)/py-compile $(top_srcdir)/test-driver README TODO
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 am__relativize = \
   dir0=`pwd`; \
@@ -7274,8 +7524,8 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = @AM_CXXFLAGS@ $(AM_COMMON_CFLAGS) -ftemplate-depth-1024 \
 	-Wnon-virtual-dtor -Wno-invalid-offsetof $(am__append_7) \
-	$(am__append_10) $(am__append_13) $(am__append_87) \
-	$(am__append_90)
+	$(am__append_10) $(am__append_13) $(am__append_92) \
+	$(am__append_95)
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 ARM_CRC_FLAGS = @ARM_CRC_FLAGS@
@@ -7362,6 +7612,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -7458,6 +7709,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -7477,10 +7729,10 @@ user_rgw = @user_rgw@
 AUTOMAKE_OPTIONS = gnu subdir-objects
 SUBDIRS = ocf java
 DIST_SUBDIRS = gmock ocf java
-BUILT_SOURCES = $(am__append_234) $(am__append_256)
+BUILT_SOURCES = $(am__append_247) $(am__append_269)
 
 # extra bits
-EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
+EXTRA_DIST = $(am__append_30) ceph-detect-init/AUTHORS.rst \
 	ceph-detect-init/ceph_detect_init/centos/__init__.py \
 	ceph-detect-init/ceph_detect_init/exc.py \
 	ceph-detect-init/ceph_detect_init/main.py \
@@ -7535,75 +7787,100 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	$(srcdir)/test/opensuse-13.2/install-deps.sh \
 	$(srcdir)/test/opensuse-13.2/ceph.spec.in \
 	$(srcdir)/test/coverage.sh $(patsubst \
-	%,$(srcdir)/%,$(check_SCRIPTS)) rocksdb/.arcconfig \
-	rocksdb/PATENTS rocksdb/.clang-format rocksdb/AUTHORS \
-	rocksdb/CONTRIBUTING.md rocksdb/LICENSE rocksdb/README.md \
-	rocksdb/Vagrantfile \
-	rocksdb/arcanist_util/__phutil_library_init__.php \
+	%,$(srcdir)/%,$(check_SCRIPTS)) rocksdb/appveyor.yml \
 	rocksdb/arcanist_util/config/FacebookArcanistConfiguration.php \
 	rocksdb/arcanist_util/cpp_linter/ArcanistCpplintLinter.php \
-	rocksdb/arcanist_util/cpp_linter/cpplint.py \
 	rocksdb/arcanist_util/cpp_linter/BaseDirectoryScopedFormatLinter.php \
+	rocksdb/arcanist_util/cpp_linter/cpplint.py \
 	rocksdb/arcanist_util/cpp_linter/FacebookHowtoevenLinter.php \
 	rocksdb/arcanist_util/cpp_linter/FbcodeClangFormatLinter.php \
 	rocksdb/arcanist_util/cpp_linter/FbcodeCppLinter.php \
 	rocksdb/arcanist_util/lint_engine/FacebookFbcodeLintEngine.php \
 	rocksdb/arcanist_util/lint_engine/FacebookHowtoevenLintEngine.php \
-	rocksdb/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php \
+	rocksdb/arcanist_util/__phutil_library_init__.php \
 	rocksdb/arcanist_util/__phutil_library_map__.php \
-	rocksdb/build_tools/make_new_version.sh \
-	rocksdb/build_tools/make_package.sh \
-	rocksdb/build_tools/regression_build_test.sh \
-	rocksdb/build_tools/version.sh \
+	rocksdb/arcanist_util/unit_engine/FacebookFbcodeUnitTestEngine.php \
+	rocksdb/.arcconfig rocksdb/AUTHORS \
 	rocksdb/build_tools/amalgamate.py \
 	rocksdb/build_tools/build_detect_platform \
 	rocksdb/build_tools/dockerbuild.sh \
-	rocksdb/build_tools/fb_compile_mongo.sh \
-	rocksdb/build_tools/fbcode_config.sh \
 	rocksdb/build_tools/fbcode_config4.8.1.sh \
+	rocksdb/build_tools/fbcode_config.sh \
+	rocksdb/build_tools/fb_compile_mongo.sh \
 	rocksdb/build_tools/format-diff.sh \
+	rocksdb/build_tools/make_new_version.sh \
+	rocksdb/build_tools/make_package.sh \
+	rocksdb/build_tools/regression_build_test.sh \
 	rocksdb/build_tools/rocksdb-lego-determinator \
 	rocksdb/build_tools/run_ci_db_test.ps1 \
+	rocksdb/build_tools/version.sh rocksdb/.clang-format \
+	rocksdb/CMakeLists.txt rocksdb/CONTRIBUTING.md \
 	rocksdb/coverage/coverage_test.sh \
-	rocksdb/coverage/parse_gcov_output.py \
-	rocksdb/db/compaction_picker.h \
+	rocksdb/coverage/parse_gcov_output.py rocksdb/db/builder.cc \
+	rocksdb/db/builder.h rocksdb/db/c.cc \
+	rocksdb/db/column_family.cc rocksdb/db/column_family.h \
+	rocksdb/db/column_family_test.cc \
+	rocksdb/db/compacted_db_impl.cc rocksdb/db/compacted_db_impl.h \
+	rocksdb/db/compact_files_test.cc rocksdb/db/compaction.cc \
+	rocksdb/db/compaction.h rocksdb/db/compaction_iterator.cc \
+	rocksdb/db/compaction_iterator.h \
+	rocksdb/db/compaction_iterator_test.cc \
+	rocksdb/db/compaction_job.cc rocksdb/db/compaction_job.h \
+	rocksdb/db/compaction_job_stats_test.cc \
+	rocksdb/db/compaction_job_test.cc \
+	rocksdb/db/compaction_picker.cc rocksdb/db/compaction_picker.h \
 	rocksdb/db/compaction_picker_test.cc \
 	rocksdb/db/comparator_db_test.cc rocksdb/db/convenience.cc \
+	rocksdb/db/corruption_test.cc rocksdb/db/c_test.c \
 	rocksdb/db/cuckoo_table_db_test.cc rocksdb/db/db_bench.cc \
-	rocksdb/db/db_filesnapshot.cc rocksdb/db/db_impl.cc \
-	rocksdb/db/db_impl.h rocksdb/db/db_impl_debug.cc \
+	rocksdb/db/db_compaction_filter_test.cc \
+	rocksdb/db/db_compaction_test.cc \
+	rocksdb/db/db_dynamic_level_test.cc \
+	rocksdb/db/db_filesnapshot.cc rocksdb/db/dbformat.cc \
+	rocksdb/db/dbformat.h rocksdb/db/dbformat_test.cc \
+	rocksdb/db/db_impl.cc rocksdb/db/db_impl_debug.cc \
+	rocksdb/db/db_impl_experimental.cc rocksdb/db/db_impl.h \
 	rocksdb/db/db_impl_readonly.cc rocksdb/db/db_impl_readonly.h \
-	rocksdb/db/db_iter.cc rocksdb/db/db_iter_test.cc \
-	rocksdb/db/db_log_iter_test.cc rocksdb/db/dbformat.cc \
-	rocksdb/db/dbformat_test.cc rocksdb/db/deletefile_test.cc \
-	rocksdb/db/filename.cc rocksdb/db/log_reader.h \
-	rocksdb/db/file_indexer.h rocksdb/db/flush_job_test.cc \
-	rocksdb/db/plain_table_db_test.cc rocksdb/db/db_test.cc \
-	rocksdb/db/db_iter.h rocksdb/db/fault_injection_test.cc \
-	rocksdb/db/filename.h rocksdb/db/forward_iterator.cc \
-	rocksdb/db/forward_iterator.h rocksdb/db/job_context.h \
-	rocksdb/db/compaction_job.h rocksdb/db/memtable.cc \
-	rocksdb/db/file_indexer.cc rocksdb/db/flush_job.cc \
-	rocksdb/db/file_indexer_test.cc rocksdb/db/log_reader.cc \
-	rocksdb/db/table_cache.h rocksdb/db/filename_test.cc \
-	rocksdb/db/memtable_list_test.cc rocksdb/db/merge_helper.cc \
-	rocksdb/db/flush_scheduler.cc rocksdb/db/flush_scheduler.h \
-	rocksdb/db/internal_stats.h rocksdb/db/listener_test.cc \
+	rocksdb/db/db_inplace_update_test.cc rocksdb/db/db_iter.cc \
+	rocksdb/db/db_iter.h rocksdb/db/db_iter_test.cc \
+	rocksdb/db/db_log_iter_test.cc \
+	rocksdb/db/db_table_properties_test.cc \
+	rocksdb/db/db_tailing_iter_test.cc rocksdb/db/db_test.cc \
+	rocksdb/db/db_test_util.cc rocksdb/db/db_test_util.h \
+	rocksdb/db/db_universal_compaction_test.cc \
+	rocksdb/db/db_wal_test.cc rocksdb/db/deletefile_test.cc \
+	rocksdb/db/event_helpers.cc rocksdb/db/event_helpers.h \
+	rocksdb/db/experimental.cc rocksdb/db/fault_injection_test.cc \
+	rocksdb/db/file_indexer.cc rocksdb/db/file_indexer.h \
+	rocksdb/db/file_indexer_test.cc rocksdb/db/filename.cc \
+	rocksdb/db/filename.h rocksdb/db/filename_test.cc \
+	rocksdb/db/flush_job.cc rocksdb/db/flush_job.h \
+	rocksdb/db/flush_job_test.cc rocksdb/db/flush_scheduler.cc \
+	rocksdb/db/flush_scheduler.h \
+	rocksdb/db/forward_iterator_bench.cc \
+	rocksdb/db/forward_iterator.cc rocksdb/db/forward_iterator.h \
+	rocksdb/db/inlineskiplist.h rocksdb/db/inlineskiplist_test.cc \
+	rocksdb/db/internal_stats.cc rocksdb/db/internal_stats.h \
+	rocksdb/db/job_context.h rocksdb/db/listener_test.cc \
+	rocksdb/db/log_format.h rocksdb/db/log_reader.cc \
+	rocksdb/db/log_reader.h rocksdb/db/log_test.cc \
 	rocksdb/db/log_writer.cc rocksdb/db/log_writer.h \
-	rocksdb/db/merge_helper.h rocksdb/db/merge_operator.cc \
-	rocksdb/db/merge_test.cc rocksdb/db/version_set.h \
-	rocksdb/db/log_format.h rocksdb/db/memtable.h \
-	rocksdb/db/memtable_list.cc rocksdb/db/skiplist.h \
-	rocksdb/db/c_test.c rocksdb/db/managed_iterator.h \
-	rocksdb/db/wal_manager_test.cc \
+	rocksdb/db/managed_iterator.cc rocksdb/db/managed_iterator.h \
+	rocksdb/db/manual_compaction_test.cc \
 	rocksdb/db/memtable_allocator.cc \
-	rocksdb/db/memtable_allocator.h \
-	rocksdb/db/memtablerep_bench.cc rocksdb/db/repair.cc \
-	rocksdb/db/internal_stats.cc rocksdb/db/merge_context.h \
-	rocksdb/db/managed_iterator.cc rocksdb/db/compacted_db_impl.h \
-	rocksdb/db/memtable_list.h rocksdb/db/perf_context_test.cc \
-	rocksdb/db/table_cache.cc rocksdb/db/db_impl_experimental.cc \
+	rocksdb/db/memtable_allocator.h rocksdb/db/memtable.cc \
+	rocksdb/db/memtable.h rocksdb/db/memtable_list.cc \
+	rocksdb/db/memtable_list.h rocksdb/db/memtable_list_test.cc \
+	rocksdb/db/memtablerep_bench.cc rocksdb/db/merge_context.h \
+	rocksdb/db/merge_helper.cc rocksdb/db/merge_helper.h \
+	rocksdb/db/merge_helper_test.cc rocksdb/db/merge_operator.cc \
+	rocksdb/db/merge_test.cc rocksdb/db/options_file_test.cc \
+	rocksdb/db/perf_context_test.cc \
+	rocksdb/db/plain_table_db_test.cc rocksdb/db/prefix_test.cc \
+	rocksdb/db/repair.cc rocksdb/db/skiplist.h \
 	rocksdb/db/skiplist_test.cc rocksdb/db/slice.cc \
+	rocksdb/db/snapshot_impl.cc rocksdb/db/snapshot_impl.h \
+	rocksdb/db/table_cache.cc rocksdb/db/table_cache.h \
 	rocksdb/db/table_properties_collector.cc \
 	rocksdb/db/table_properties_collector.h \
 	rocksdb/db/table_properties_collector_test.cc \
@@ -7612,126 +7889,121 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	rocksdb/db/version_builder.cc rocksdb/db/version_builder.h \
 	rocksdb/db/version_builder_test.cc rocksdb/db/version_edit.cc \
 	rocksdb/db/version_edit.h rocksdb/db/version_edit_test.cc \
-	rocksdb/db/version_set.cc rocksdb/db/version_set_test.cc \
-	rocksdb/db/wal_manager.cc rocksdb/db/write_batch.cc \
-	rocksdb/db/write_batch_base.cc rocksdb/db/wal_manager.h \
+	rocksdb/db/version_set.cc rocksdb/db/version_set.h \
+	rocksdb/db/version_set_test.cc rocksdb/db/wal_manager.cc \
+	rocksdb/db/wal_manager.h rocksdb/db/wal_manager_test.cc \
+	rocksdb/db/write_batch_base.cc rocksdb/db/write_batch.cc \
 	rocksdb/db/write_batch_internal.h \
-	rocksdb/db/write_batch_test.cc rocksdb/db/write_callback.h \
+	rocksdb/db/write_batch_test.cc rocksdb/db/writebuffer.h \
+	rocksdb/db/write_callback.h rocksdb/db/write_callback_test.cc \
 	rocksdb/db/write_controller.cc rocksdb/db/write_controller.h \
 	rocksdb/db/write_controller_test.cc rocksdb/db/write_thread.cc \
-	rocksdb/db/write_thread.h rocksdb/db/builder.cc \
-	rocksdb/db/c.cc rocksdb/db/writebuffer.h \
-	rocksdb/db/compaction_iterator.h rocksdb/db/experimental.cc \
-	rocksdb/db/column_family.h rocksdb/db/column_family_test.cc \
-	rocksdb/db/compact_files_test.cc rocksdb/db/compaction.cc \
-	rocksdb/db/compaction.h rocksdb/db/compaction_job.cc \
-	rocksdb/db/compaction_job_test.cc \
-	rocksdb/db/compaction_picker.cc rocksdb/db/column_family.cc \
-	rocksdb/db/dbformat.h rocksdb/db/builder.h \
-	rocksdb/db/compacted_db_impl.cc rocksdb/db/flush_job.h \
-	rocksdb/db/log_test.cc rocksdb/db/prefix_test.cc \
-	rocksdb/db/corruption_test.cc rocksdb/db/db_compaction_test.cc \
-	rocksdb/db/compaction_iterator.cc \
-	rocksdb/db/compaction_iterator_test.cc \
-	rocksdb/db/compaction_job_stats_test.cc \
-	rocksdb/db/db_compaction_filter_test.cc \
-	rocksdb/db/db_dynamic_level_test.cc \
-	rocksdb/db/db_inplace_update_test.cc \
-	rocksdb/db/db_tailing_iter_test.cc \
-	rocksdb/db/db_universal_compaction_test.cc \
-	rocksdb/db/db_wal_test.cc rocksdb/db/event_helpers.cc \
-	rocksdb/db/event_helpers.h rocksdb/db/merge_helper_test.cc \
-	rocksdb/db/snapshot_impl.cc rocksdb/db/snapshot_impl.h \
-	rocksdb/db/write_callback_test.cc rocksdb/doc/doc.css \
+	rocksdb/db/write_thread.h rocksdb/doc/doc.css \
 	rocksdb/doc/index.html rocksdb/doc/log_format.txt \
 	rocksdb/doc/rockslogo.jpg rocksdb/doc/rockslogo.png \
-	rocksdb/examples/README.md \
+	rocksdb/DUMP_FORMAT.md \
 	rocksdb/examples/column_families_example.cc \
-	rocksdb/examples/simple_example.cc rocksdb/examples/.gitignore \
-	rocksdb/examples/Makefile rocksdb/examples/c_simple_example.c \
 	rocksdb/examples/compact_files_example.cc \
 	rocksdb/examples/compaction_filter_example.cc \
+	rocksdb/examples/c_simple_example.c \
+	rocksdb/examples/.gitignore rocksdb/examples/Makefile \
 	rocksdb/examples/optimistic_transaction_example.cc \
+	rocksdb/examples/options_file_example.cc \
+	rocksdb/examples/README.md \
 	rocksdb/examples/rocksdb_option_file_example.ini \
-	rocksdb/examples/transaction_example.cc rocksdb/hdfs/README \
-	rocksdb/hdfs/setup.sh rocksdb/hdfs/env_hdfs.h \
+	rocksdb/examples/simple_example.cc \
+	rocksdb/examples/transaction_example.cc rocksdb/.gitignore \
+	rocksdb/hdfs/env_hdfs.h rocksdb/hdfs/README \
+	rocksdb/hdfs/setup.sh rocksdb/HISTORY.md \
+	rocksdb/include/rocksdb/cache.h rocksdb/include/rocksdb/c.h \
+	rocksdb/include/rocksdb/compaction_filter.h \
+	rocksdb/include/rocksdb/compaction_job_stats.h \
+	rocksdb/include/rocksdb/comparator.h \
+	rocksdb/include/rocksdb/convenience.h \
+	rocksdb/include/rocksdb/db_dump_tool.h \
+	rocksdb/include/rocksdb/db.h \
+	rocksdb/include/rocksdb/delete_scheduler.h \
+	rocksdb/include/rocksdb/env.h \
+	rocksdb/include/rocksdb/experimental.h \
 	rocksdb/include/rocksdb/filter_policy.h \
 	rocksdb/include/rocksdb/flush_block_policy.h \
+	rocksdb/include/rocksdb/immutable_options.h \
+	rocksdb/include/rocksdb/iostats_context.h \
 	rocksdb/include/rocksdb/iterator.h \
 	rocksdb/include/rocksdb/ldb_tool.h \
+	rocksdb/include/rocksdb/listener.h \
+	rocksdb/include/rocksdb/memtablerep.h \
+	rocksdb/include/rocksdb/merge_operator.h \
+	rocksdb/include/rocksdb/metadata.h \
+	rocksdb/include/rocksdb/options.h \
+	rocksdb/include/rocksdb/perf_context.h \
+	rocksdb/include/rocksdb/perf_level.h \
+	rocksdb/include/rocksdb/rate_limiter.h \
+	rocksdb/include/rocksdb/slice.h \
 	rocksdb/include/rocksdb/slice_transform.h \
+	rocksdb/include/rocksdb/snapshot.h \
 	rocksdb/include/rocksdb/sst_dump_tool.h \
+	rocksdb/include/rocksdb/sst_file_writer.h \
+	rocksdb/include/rocksdb/statistics.h \
+	rocksdb/include/rocksdb/status.h \
+	rocksdb/include/rocksdb/table.h \
+	rocksdb/include/rocksdb/table_properties.h \
+	rocksdb/include/rocksdb/thread_status.h \
+	rocksdb/include/rocksdb/transaction_log.h \
 	rocksdb/include/rocksdb/types.h \
+	rocksdb/include/rocksdb/universal_compaction.h \
+	rocksdb/include/rocksdb/utilities/backupable_db.h \
+	rocksdb/include/rocksdb/utilities/checkpoint.h \
+	rocksdb/include/rocksdb/utilities/convenience.h \
 	rocksdb/include/rocksdb/utilities/db_ttl.h \
 	rocksdb/include/rocksdb/utilities/document_db.h \
+	rocksdb/include/rocksdb/utilities/env_mirror.h \
+	rocksdb/include/rocksdb/utilities/flashcache.h \
 	rocksdb/include/rocksdb/utilities/geo_db.h \
+	rocksdb/include/rocksdb/utilities/info_log_finder.h \
 	rocksdb/include/rocksdb/utilities/json_document.h \
 	rocksdb/include/rocksdb/utilities/leveldb_options.h \
-	rocksdb/include/rocksdb/utilities/flashcache.h \
-	rocksdb/include/rocksdb/utilities/backupable_db.h \
-	rocksdb/include/rocksdb/utilities/checkpoint.h \
-	rocksdb/include/rocksdb/utilities/convenience.h \
-	rocksdb/include/rocksdb/utilities/info_log_finder.h \
+	rocksdb/include/rocksdb/utilities/memory_util.h \
 	rocksdb/include/rocksdb/utilities/optimistic_transaction_db.h \
+	rocksdb/include/rocksdb/utilities/options_util.h \
 	rocksdb/include/rocksdb/utilities/spatial_db.h \
 	rocksdb/include/rocksdb/utilities/stackable_db.h \
 	rocksdb/include/rocksdb/utilities/table_properties_collectors.h \
-	rocksdb/include/rocksdb/utilities/transaction.h \
 	rocksdb/include/rocksdb/utilities/transaction_db.h \
 	rocksdb/include/rocksdb/utilities/transaction_db_mutex.h \
+	rocksdb/include/rocksdb/utilities/transaction.h \
 	rocksdb/include/rocksdb/utilities/utility_db.h \
 	rocksdb/include/rocksdb/utilities/write_batch_with_index.h \
-	rocksdb/include/rocksdb/experimental.h \
-	rocksdb/include/rocksdb/convenience.h \
-	rocksdb/include/rocksdb/db_dump_tool.h \
-	rocksdb/include/rocksdb/immutable_options.h \
-	rocksdb/include/rocksdb/iostats_context.h \
-	rocksdb/include/rocksdb/listener.h \
-	rocksdb/include/rocksdb/memtablerep.h \
-	rocksdb/include/rocksdb/merge_operator.h \
-	rocksdb/include/rocksdb/metadata.h \
-	rocksdb/include/rocksdb/perf_context.h \
-	rocksdb/include/rocksdb/perf_level.h \
-	rocksdb/include/rocksdb/slice.h \
-	rocksdb/include/rocksdb/status.h \
-	rocksdb/include/rocksdb/table_properties.h \
-	rocksdb/include/rocksdb/transaction_log.h \
 	rocksdb/include/rocksdb/version.h \
+	rocksdb/include/rocksdb/wal_filter.h \
 	rocksdb/include/rocksdb/write_batch_base.h \
-	rocksdb/include/rocksdb/c.h \
-	rocksdb/include/rocksdb/compaction_filter.h \
-	rocksdb/include/rocksdb/comparator.h \
-	rocksdb/include/rocksdb/db.h rocksdb/include/rocksdb/env.h \
-	rocksdb/include/rocksdb/options.h \
-	rocksdb/include/rocksdb/rate_limiter.h \
-	rocksdb/include/rocksdb/snapshot.h \
-	rocksdb/include/rocksdb/statistics.h \
-	rocksdb/include/rocksdb/table.h \
-	rocksdb/include/rocksdb/thread_status.h \
-	rocksdb/include/rocksdb/universal_compaction.h \
-	rocksdb/include/rocksdb/write_batch.h \
-	rocksdb/include/rocksdb/cache.h \
-	rocksdb/include/rocksdb/compaction_job_stats.h \
-	rocksdb/include/rocksdb/delete_scheduler.h \
-	rocksdb/include/rocksdb/sst_file_writer.h \
-	rocksdb/java/RELEASE.md \
+	rocksdb/include/rocksdb/write_batch.h rocksdb/INSTALL.md \
 	rocksdb/java/benchmark/src/main/java/org/rocksdb/benchmark/DbBenchmark.java \
+	rocksdb/java/crossbuild/build-linux-centos.sh \
 	rocksdb/java/crossbuild/build-linux.sh \
 	rocksdb/java/crossbuild/Vagrantfile \
-	rocksdb/java/crossbuild/build-linux-centos.sh \
-	rocksdb/java/jdb_bench.sh rocksdb/java/rocksjni.pom \
+	rocksdb/java/HISTORY-JAVA.md rocksdb/java/jdb_bench.sh \
+	rocksdb/java/Makefile rocksdb/java/RELEASE.md \
 	rocksdb/java/rocksjni/backupablejni.cc \
+	rocksdb/java/rocksjni/backupenginejni.cc \
 	rocksdb/java/rocksjni/checkpoint.cc \
 	rocksdb/java/rocksjni/columnfamilyhandle.cc \
+	rocksdb/java/rocksjni/compaction_filter.cc \
 	rocksdb/java/rocksjni/comparator.cc \
+	rocksdb/java/rocksjni/comparatorjnicallback.cc \
 	rocksdb/java/rocksjni/comparatorjnicallback.h \
 	rocksdb/java/rocksjni/env.cc rocksdb/java/rocksjni/filter.cc \
 	rocksdb/java/rocksjni/iterator.cc \
+	rocksdb/java/rocksjni/loggerjnicallback.cc \
 	rocksdb/java/rocksjni/loggerjnicallback.h \
 	rocksdb/java/rocksjni/memtablejni.cc \
 	rocksdb/java/rocksjni/merge_operator.cc \
+	rocksdb/java/rocksjni/options.cc rocksdb/java/rocksjni.pom \
+	rocksdb/java/rocksjni/portal.h \
 	rocksdb/java/rocksjni/ratelimiterjni.cc \
+	rocksdb/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc \
 	rocksdb/java/rocksjni/restorejni.cc \
+	rocksdb/java/rocksjni/rocksjni.cc \
 	rocksdb/java/rocksjni/slice.cc \
 	rocksdb/java/rocksjni/snapshot.cc \
 	rocksdb/java/rocksjni/statistics.cc \
@@ -7741,24 +8013,19 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	rocksdb/java/rocksjni/write_batch.cc \
 	rocksdb/java/rocksjni/writebatchhandlerjnicallback.cc \
 	rocksdb/java/rocksjni/writebatchhandlerjnicallback.h \
-	rocksdb/java/rocksjni/backupenginejni.cc \
-	rocksdb/java/rocksjni/compaction_filter.cc \
-	rocksdb/java/rocksjni/comparatorjnicallback.cc \
-	rocksdb/java/rocksjni/loggerjnicallback.cc \
-	rocksdb/java/rocksjni/options.cc \
-	rocksdb/java/rocksjni/portal.h \
-	rocksdb/java/rocksjni/remove_emptyvalue_compactionfilterjni.cc \
-	rocksdb/java/rocksjni/rocksjni.cc \
 	rocksdb/java/rocksjni/write_batch_test.cc \
 	rocksdb/java/rocksjni/write_batch_with_index.cc \
 	rocksdb/java/samples/src/main/java/RocksDBColumnFamilySample.java \
 	rocksdb/java/samples/src/main/java/RocksDBSample.java \
+	rocksdb/java/src/main/java/org/rocksdb/AbstractCompactionFilter.java \
 	rocksdb/java/src/main/java/org/rocksdb/AbstractComparator.java \
 	rocksdb/java/src/main/java/org/rocksdb/AbstractRocksIterator.java \
+	rocksdb/java/src/main/java/org/rocksdb/AbstractSlice.java \
 	rocksdb/java/src/main/java/org/rocksdb/AbstractWriteBatch.java \
-	rocksdb/java/src/main/java/org/rocksdb/BackupInfo.java \
 	rocksdb/java/src/main/java/org/rocksdb/BackupableDB.java \
 	rocksdb/java/src/main/java/org/rocksdb/BackupableDBOptions.java \
+	rocksdb/java/src/main/java/org/rocksdb/BackupEngine.java \
+	rocksdb/java/src/main/java/org/rocksdb/BackupInfo.java \
 	rocksdb/java/src/main/java/org/rocksdb/BlockBasedTableConfig.java \
 	rocksdb/java/src/main/java/org/rocksdb/BloomFilter.java \
 	rocksdb/java/src/main/java/org/rocksdb/BuiltinComparator.java \
@@ -7766,15 +8033,18 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	rocksdb/java/src/main/java/org/rocksdb/ChecksumType.java \
 	rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyDescriptor.java \
 	rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyHandle.java \
+	rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java \
+	rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java \
 	rocksdb/java/src/main/java/org/rocksdb/CompactionStyle.java \
 	rocksdb/java/src/main/java/org/rocksdb/Comparator.java \
 	rocksdb/java/src/main/java/org/rocksdb/ComparatorOptions.java \
 	rocksdb/java/src/main/java/org/rocksdb/CompressionType.java \
-	rocksdb/java/src/main/java/org/rocksdb/DBOptions.java \
 	rocksdb/java/src/main/java/org/rocksdb/DBOptionsInterface.java \
+	rocksdb/java/src/main/java/org/rocksdb/DBOptions.java \
 	rocksdb/java/src/main/java/org/rocksdb/DirectComparator.java \
 	rocksdb/java/src/main/java/org/rocksdb/DirectSlice.java \
 	rocksdb/java/src/main/java/org/rocksdb/EncodingType.java \
+	rocksdb/java/src/main/java/org/rocksdb/Env.java \
 	rocksdb/java/src/main/java/org/rocksdb/Filter.java \
 	rocksdb/java/src/main/java/org/rocksdb/FlushOptions.java \
 	rocksdb/java/src/main/java/org/rocksdb/GenericRateLimiterConfig.java \
@@ -7788,51 +8058,47 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	rocksdb/java/src/main/java/org/rocksdb/MemTableConfig.java \
 	rocksdb/java/src/main/java/org/rocksdb/MergeOperator.java \
 	rocksdb/java/src/main/java/org/rocksdb/NativeLibraryLoader.java \
+	rocksdb/java/src/main/java/org/rocksdb/Options.java \
 	rocksdb/java/src/main/java/org/rocksdb/PlainTableConfig.java \
 	rocksdb/java/src/main/java/org/rocksdb/RateLimiterConfig.java \
 	rocksdb/java/src/main/java/org/rocksdb/ReadOptions.java \
+	rocksdb/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java \
 	rocksdb/java/src/main/java/org/rocksdb/RestoreBackupableDB.java \
 	rocksdb/java/src/main/java/org/rocksdb/RestoreOptions.java \
-	rocksdb/java/src/main/java/org/rocksdb/RocksDB.java \
 	rocksdb/java/src/main/java/org/rocksdb/RocksDBException.java \
+	rocksdb/java/src/main/java/org/rocksdb/RocksDB.java \
 	rocksdb/java/src/main/java/org/rocksdb/RocksEnv.java \
-	rocksdb/java/src/main/java/org/rocksdb/RocksIterator.java \
 	rocksdb/java/src/main/java/org/rocksdb/RocksIteratorInterface.java \
+	rocksdb/java/src/main/java/org/rocksdb/RocksIterator.java \
+	rocksdb/java/src/main/java/org/rocksdb/RocksMemEnv.java \
 	rocksdb/java/src/main/java/org/rocksdb/RocksObject.java \
 	rocksdb/java/src/main/java/org/rocksdb/SkipListMemTableConfig.java \
 	rocksdb/java/src/main/java/org/rocksdb/Slice.java \
 	rocksdb/java/src/main/java/org/rocksdb/Snapshot.java \
-	rocksdb/java/src/main/java/org/rocksdb/Statistics.java \
-	rocksdb/java/src/main/java/org/rocksdb/StatisticsCollector.java \
 	rocksdb/java/src/main/java/org/rocksdb/StatisticsCollectorCallback.java \
+	rocksdb/java/src/main/java/org/rocksdb/StatisticsCollector.java \
+	rocksdb/java/src/main/java/org/rocksdb/Statistics.java \
 	rocksdb/java/src/main/java/org/rocksdb/StatsCollectorInput.java \
 	rocksdb/java/src/main/java/org/rocksdb/StringAppendOperator.java \
 	rocksdb/java/src/main/java/org/rocksdb/TableFormatConfig.java \
 	rocksdb/java/src/main/java/org/rocksdb/TickerType.java \
 	rocksdb/java/src/main/java/org/rocksdb/TransactionLogIterator.java \
 	rocksdb/java/src/main/java/org/rocksdb/TtlDB.java \
+	rocksdb/java/src/main/java/org/rocksdb/util/Environment.java \
+	rocksdb/java/src/main/java/org/rocksdb/util/SizeUnit.java \
 	rocksdb/java/src/main/java/org/rocksdb/VectorMemTableConfig.java \
-	rocksdb/java/src/main/java/org/rocksdb/WriteBatch.java \
+	rocksdb/java/src/main/java/org/rocksdb/WBWIRocksIterator.java \
 	rocksdb/java/src/main/java/org/rocksdb/WriteBatchInterface.java \
+	rocksdb/java/src/main/java/org/rocksdb/WriteBatch.java \
 	rocksdb/java/src/main/java/org/rocksdb/WriteBatchWithIndex.java \
 	rocksdb/java/src/main/java/org/rocksdb/WriteOptions.java \
-	rocksdb/java/src/main/java/org/rocksdb/util/Environment.java \
-	rocksdb/java/src/main/java/org/rocksdb/util/SizeUnit.java \
-	rocksdb/java/src/main/java/org/rocksdb/Env.java \
-	rocksdb/java/src/main/java/org/rocksdb/RocksMemEnv.java \
-	rocksdb/java/src/main/java/org/rocksdb/AbstractCompactionFilter.java \
-	rocksdb/java/src/main/java/org/rocksdb/AbstractSlice.java \
-	rocksdb/java/src/main/java/org/rocksdb/BackupEngine.java \
-	rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptions.java \
-	rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java \
-	rocksdb/java/src/main/java/org/rocksdb/Options.java \
-	rocksdb/java/src/main/java/org/rocksdb/RemoveEmptyValueCompactionFilter.java \
-	rocksdb/java/src/main/java/org/rocksdb/WBWIRocksIterator.java \
 	rocksdb/java/src/test/java/org/rocksdb/AbstractComparatorTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/BackupableDBOptionsTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/BackupableDBTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/BackupEngineTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/CheckPointTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/ColumnFamilyTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/ComparatorOptionsTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/ComparatorTest.java \
@@ -7842,88 +8108,73 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	rocksdb/java/src/test/java/org/rocksdb/DirectSliceTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/FilterTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/FlushTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/InfoLogLevelTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/KeyMayExistTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/LoggerTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/MemTableTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/MergeTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/MixedOptionsTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/NativeLibraryLoaderTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/OptionsTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/PlainTableConfigTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/PlatformRandomHelper.java \
 	rocksdb/java/src/test/java/org/rocksdb/ReadOnlyTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/ReadOptionsTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/RocksDBTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/RocksEnvTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/RocksIteratorTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/RocksMemEnvTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/RocksMemoryResource.java \
+	rocksdb/java/src/test/java/org/rocksdb/SliceTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/SnapshotTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/StatisticsCollectorTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/StatsCallbackMock.java \
+	rocksdb/java/src/test/java/org/rocksdb/test/RocksJunitRunner.java \
 	rocksdb/java/src/test/java/org/rocksdb/TransactionLogIteratorTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/TtlDBTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/Types.java \
-	rocksdb/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/WriteBatchTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/WriteOptionsTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/test/RocksJunitRunner.java \
 	rocksdb/java/src/test/java/org/rocksdb/util/EnvironmentTest.java \
 	rocksdb/java/src/test/java/org/rocksdb/util/SizeUnitTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/RocksMemEnvTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/SliceTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/TtlDBTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/BackupEngineTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/ColumnFamilyOptionsTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/InfoLogLevelTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/OptionsTest.java \
-	rocksdb/java/src/test/java/org/rocksdb/RocksDBTest.java \
-	rocksdb/java/HISTORY-JAVA.md rocksdb/java/Makefile \
-	rocksdb/port/stack_trace.cc rocksdb/port/README \
-	rocksdb/port/likely.h rocksdb/port/port_example.h \
-	rocksdb/port/stack_trace.h rocksdb/port/dirent.h \
-	rocksdb/port/port.h rocksdb/port/port_posix.cc \
-	rocksdb/port/port_posix.h rocksdb/port/sys_time.h \
+	rocksdb/java/src/test/java/org/rocksdb/WriteBatchHandlerTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/WriteBatchTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/WriteBatchWithIndexTest.java \
+	rocksdb/java/src/test/java/org/rocksdb/WriteOptionsTest.java \
+	rocksdb/LICENSE rocksdb/Makefile \
+	rocksdb/memtable/hash_cuckoo_rep.cc \
+	rocksdb/memtable/hash_cuckoo_rep.h \
+	rocksdb/memtable/hash_linklist_rep.cc \
+	rocksdb/memtable/hash_linklist_rep.h \
+	rocksdb/memtable/hash_skiplist_rep.cc \
+	rocksdb/memtable/hash_skiplist_rep.h \
+	rocksdb/memtable/stl_wrappers.h rocksdb/PATENTS \
+	rocksdb/port/dirent.h rocksdb/port/likely.h \
+	rocksdb/port/port_example.h rocksdb/port/port.h \
+	rocksdb/port/port_posix.cc rocksdb/port/port_posix.h \
+	rocksdb/port/README rocksdb/port/stack_trace.cc \
+	rocksdb/port/stack_trace.h rocksdb/port/sys_time.h \
 	rocksdb/port/util_logger.h rocksdb/port/win/env_win.cc \
 	rocksdb/port/win/port_win.cc rocksdb/port/win/port_win.h \
 	rocksdb/port/win/win_logger.cc rocksdb/port/win/win_logger.h \
+	rocksdb/README.md rocksdb/ROCKSDB_LITE.md rocksdb/src.mk \
+	rocksdb/table/adaptive_table_factory.cc \
+	rocksdb/table/adaptive_table_factory.h \
 	rocksdb/table/block_based_filter_block.cc \
-	rocksdb/table/mock_table.cc \
-	rocksdb/table/plain_table_builder.cc \
-	rocksdb/table/plain_table_factory.cc \
-	rocksdb/table/plain_table_key_coding.h \
-	rocksdb/table/table_builder.h \
-	rocksdb/table/two_level_iterator.cc \
-	rocksdb/table/two_level_iterator.h \
-	rocksdb/table/full_filter_block.cc \
 	rocksdb/table/block_based_filter_block.h \
 	rocksdb/table/block_based_filter_block_test.cc \
-	rocksdb/table/block.cc rocksdb/table/block_builder.cc \
-	rocksdb/table/block_builder.h rocksdb/table/block_hash_index.h \
-	rocksdb/table/block_hash_index_test.cc \
-	rocksdb/table/block_prefix_index.cc \
-	rocksdb/table/block_test.cc rocksdb/table/bloom_block.cc \
-	rocksdb/table/bloom_block.h \
-	rocksdb/table/table_reader_bench.cc \
-	rocksdb/table/table_test.cc rocksdb/table/meta_blocks.h \
-	rocksdb/table/plain_table_factory.h \
-	rocksdb/table/filter_block.h \
-	rocksdb/table/flush_block_policy.cc \
-	rocksdb/table/get_context.cc rocksdb/table/get_context.h \
-	rocksdb/table/sst_file_writer.cc \
-	rocksdb/table/full_filter_block.h \
-	rocksdb/table/full_filter_block_test.cc \
-	rocksdb/table/merger.cc rocksdb/table/iterator.cc \
-	rocksdb/table/iterator_wrapper.h rocksdb/table/merger.h \
-	rocksdb/table/block.h rocksdb/table/plain_table_index.h \
-	rocksdb/table/plain_table_key_coding.cc \
-	rocksdb/table/table_properties_internal.h \
-	rocksdb/table/table_reader.h \
 	rocksdb/table/block_based_table_builder.cc \
 	rocksdb/table/block_based_table_builder.h \
 	rocksdb/table/block_based_table_factory.cc \
 	rocksdb/table/block_based_table_factory.h \
 	rocksdb/table/block_based_table_reader.cc \
 	rocksdb/table/block_based_table_reader.h \
+	rocksdb/table/block_builder.cc rocksdb/table/block_builder.h \
+	rocksdb/table/block.cc rocksdb/table/block.h \
 	rocksdb/table/block_hash_index.cc \
-	rocksdb/table/block_prefix_index.h \
+	rocksdb/table/block_hash_index.h \
+	rocksdb/table/block_hash_index_test.cc \
+	rocksdb/table/block_prefix_index.cc \
+	rocksdb/table/block_prefix_index.h rocksdb/table/block_test.cc \
+	rocksdb/table/bloom_block.cc rocksdb/table/bloom_block.h \
 	rocksdb/table/cuckoo_table_builder.cc \
 	rocksdb/table/cuckoo_table_builder.h \
 	rocksdb/table/cuckoo_table_builder_test.cc \
@@ -7932,197 +8183,218 @@ EXTRA_DIST = $(am__append_28) ceph-detect-init/AUTHORS.rst \
 	rocksdb/table/cuckoo_table_reader.cc \
 	rocksdb/table/cuckoo_table_reader.h \
 	rocksdb/table/cuckoo_table_reader_test.cc \
-	rocksdb/table/format.cc rocksdb/table/format.h \
-	rocksdb/table/iter_heap.h rocksdb/table/merger_test.cc \
-	rocksdb/table/meta_blocks.cc rocksdb/table/mock_table.h \
+	rocksdb/table/filter_block.h \
+	rocksdb/table/flush_block_policy.cc rocksdb/table/format.cc \
+	rocksdb/table/format.h rocksdb/table/full_filter_block.cc \
+	rocksdb/table/full_filter_block.h \
+	rocksdb/table/full_filter_block_test.cc \
+	rocksdb/table/get_context.cc rocksdb/table/get_context.h \
+	rocksdb/table/internal_iterator.h rocksdb/table/iterator.cc \
+	rocksdb/table/iterator_wrapper.h rocksdb/table/iter_heap.h \
+	rocksdb/table/merger.cc rocksdb/table/merger.h \
+	rocksdb/table/merger_test.cc rocksdb/table/meta_blocks.cc \
+	rocksdb/table/meta_blocks.h rocksdb/table/mock_table.cc \
+	rocksdb/table/mock_table.h \
+	rocksdb/table/plain_table_builder.cc \
 	rocksdb/table/plain_table_builder.h \
+	rocksdb/table/plain_table_factory.cc \
+	rocksdb/table/plain_table_factory.h \
 	rocksdb/table/plain_table_index.cc \
+	rocksdb/table/plain_table_index.h \
+	rocksdb/table/plain_table_key_coding.cc \
+	rocksdb/table/plain_table_key_coding.h \
 	rocksdb/table/plain_table_reader.cc \
 	rocksdb/table/plain_table_reader.h \
+	rocksdb/table/scoped_arena_iterator.h \
+	rocksdb/table/sst_file_writer.cc rocksdb/table/table_builder.h \
 	rocksdb/table/table_properties.cc \
-	rocksdb/table/adaptive_table_factory.h \
-	rocksdb/table/adaptive_table_factory.cc \
-	rocksdb/third-party/fbson/FbsonJsonParser.h \
-	rocksdb/third-party/fbson/FbsonUtil.h \
-	rocksdb/third-party/fbson/FbsonWriter.h \
+	rocksdb/table/table_properties_internal.h \
+	rocksdb/table/table_reader_bench.cc \
+	rocksdb/table/table_reader.h rocksdb/table/table_test.cc \
+	rocksdb/table/two_level_iterator.cc \
+	rocksdb/table/two_level_iterator.h \
 	rocksdb/third-party/fbson/COMMIT.md \
 	rocksdb/third-party/fbson/FbsonDocument.h \
+	rocksdb/third-party/fbson/FbsonJsonParser.h \
 	rocksdb/third-party/fbson/FbsonStream.h \
+	rocksdb/third-party/fbson/FbsonUtil.h \
+	rocksdb/third-party/fbson/FbsonWriter.h \
+	rocksdb/third-party/flashcache/flashcache_ioctl.h \
+	rocksdb/third-party/gtest-1.7.0/fused-src/gtest/CMakeLists.txt \
 	rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc \
 	rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest.h \
-	rocksdb/third-party/gtest-1.7.0/fused-src/gtest/CMakeLists.txt \
-	rocksdb/third-party/flashcache/flashcache_ioctl.h \
-	rocksdb/tools/auto_sanity_test.sh \
-	rocksdb/tools/benchmark_leveldb.sh \
+	rocksdb/thirdparty.inc rocksdb/tools/auto_sanity_test.sh \
+	rocksdb/tools/benchmark_leveldb.sh rocksdb/tools/benchmark.sh \
 	rocksdb/tools/check_format_compatible.sh \
-	rocksdb/tools/generate_random_db.sh \
-	rocksdb/tools/run_leveldb.sh rocksdb/tools/verify_random_db.sh \
-	rocksdb/tools/dbench_monitor rocksdb/tools/ldb.cc \
-	rocksdb/tools/pflag rocksdb/tools/sst_dump.cc \
-	rocksdb/tools/dump/db_dump_tool.cc \
-	rocksdb/tools/dump/rocksdb_dump.cc \
-	rocksdb/tools/dump/rocksdb_undump.cc rocksdb/tools/Dockerfile \
-	rocksdb/tools/benchmark.sh rocksdb/tools/db_crashtest.py \
-	rocksdb/tools/db_crashtest2.py rocksdb/tools/db_repl_stress.cc \
+	rocksdb/tools/db_crashtest.py rocksdb/tools/dbench_monitor \
+	rocksdb/tools/db_repl_stress.cc \
 	rocksdb/tools/db_sanity_test.cc rocksdb/tools/db_stress.cc \
-	rocksdb/tools/ldb_test.py rocksdb/tools/reduce_levels_test.cc \
+	rocksdb/tools/Dockerfile rocksdb/tools/dump/db_dump_tool.cc \
+	rocksdb/tools/dump/rocksdb_dump.cc \
+	rocksdb/tools/dump/rocksdb_undump.cc \
+	rocksdb/tools/generate_random_db.sh rocksdb/tools/ldb.cc \
+	rocksdb/tools/ldb_cmd.cc \
+	rocksdb/tools/ldb_cmd_execute_result.h rocksdb/tools/ldb_cmd.h \
+	rocksdb/tools/ldb_cmd_test.cc rocksdb/tools/ldb_test.py \
+	rocksdb/tools/ldb_tool.cc rocksdb/tools/pflag \
+	rocksdb/tools/reduce_levels_test.cc \
 	rocksdb/tools/rocksdb_dump_test.sh \
-	rocksdb/tools/run_flash_bench.sh rocksdb/tools/sample-dump.dmp \
-	rocksdb/util/ldb_cmd_execute_result.h rocksdb/util/bloom.cc \
-	rocksdb/util/allocator.h rocksdb/util/crc32c.h \
-	rocksdb/util/db_info_dumper.cc rocksdb/util/dynamic_bloom.h \
-	rocksdb/util/env_hdfs.cc rocksdb/util/env_posix.cc \
-	rocksdb/util/env_test.cc rocksdb/util/event_logger.cc \
-	rocksdb/util/file_util.cc rocksdb/util/file_util.h \
-	rocksdb/util/heap.h rocksdb/util/ldb_cmd.h \
-	rocksdb/util/mutable_cf_options.h rocksdb/util/build_version.h \
-	rocksdb/util/env.cc rocksdb/util/cache_bench.cc \
-	rocksdb/util/options.cc rocksdb/util/coding.cc \
-	rocksdb/util/coding.h rocksdb/util/coding_test.cc \
-	rocksdb/util/event_logger.h rocksdb/util/log_buffer.cc \
-	rocksdb/util/log_buffer.h rocksdb/util/memenv.cc \
-	rocksdb/util/crc32c_test.cc rocksdb/util/options_helper.cc \
-	rocksdb/util/db_info_dumper.h rocksdb/util/dynamic_bloom.cc \
-	rocksdb/util/hash_cuckoo_rep.cc rocksdb/util/options_helper.h \
-	rocksdb/util/histogram.cc rocksdb/util/histogram_test.cc \
-	rocksdb/util/mock_env.cc rocksdb/util/logging.cc \
-	rocksdb/util/logging.h rocksdb/util/statistics.cc \
-	rocksdb/util/event_logger_test.cc rocksdb/util/perf_level.cc \
-	rocksdb/util/status.cc rocksdb/util/filelock_test.cc \
-	rocksdb/util/filter_policy.cc rocksdb/util/hash.cc \
-	rocksdb/util/hash.h rocksdb/util/arena.h \
-	rocksdb/util/hash_cuckoo_rep.h rocksdb/util/perf_context_imp.h \
-	rocksdb/util/hash_linklist_rep.h \
-	rocksdb/util/hash_skiplist_rep.cc \
-	rocksdb/util/hash_skiplist_rep.h rocksdb/util/mock_env_test.cc \
-	rocksdb/util/mutable_cf_options.cc \
-	rocksdb/util/instrumented_mutex.cc \
-	rocksdb/util/instrumented_mutex.h rocksdb/util/ldb_cmd.cc \
-	rocksdb/util/autovector.h rocksdb/util/skiplistrep.cc \
-	rocksdb/util/manual_compaction_test.cc \
-	rocksdb/util/sync_point.cc rocksdb/util/ldb_tool.cc \
-	rocksdb/util/statistics.h rocksdb/util/xfunc.cc \
-	rocksdb/util/log_write_bench.cc rocksdb/util/xfunc.h \
-	rocksdb/util/memenv_test.cc rocksdb/util/mock_env.h \
-	rocksdb/util/options_test.cc rocksdb/util/perf_context.cc \
-	rocksdb/util/posix_logger.h rocksdb/util/rate_limiter.cc \
-	rocksdb/util/rate_limiter.h rocksdb/util/murmurhash.cc \
-	rocksdb/util/murmurhash.h rocksdb/util/sst_dump_test.cc \
-	rocksdb/util/sst_dump_tool.cc rocksdb/util/mutexlock.h \
-	rocksdb/util/sst_dump_tool_imp.h \
-	rocksdb/util/options_builder.cc rocksdb/util/testutil.cc \
-	rocksdb/util/thread_local.cc rocksdb/util/thread_operation.h \
-	rocksdb/util/thread_status_impl.cc rocksdb/util/arena_test.cc \
-	rocksdb/util/random.h rocksdb/util/slice.cc \
-	rocksdb/util/thread_status_util.cc \
-	rocksdb/util/rate_limiter_test.cc \
-	rocksdb/util/scoped_arena_iterator.h \
-	rocksdb/util/thread_status_util.h rocksdb/util/channel.h \
-	rocksdb/util/slice_transform_test.cc \
-	rocksdb/util/thread_status_updater.cc \
-	rocksdb/util/thread_status_updater.h \
-	rocksdb/util/stl_wrappers.h rocksdb/util/stop_watch.h \
-	rocksdb/util/sync_point.h rocksdb/util/compression.h \
-	rocksdb/util/string_util.h rocksdb/util/string_util.cc \
-	rocksdb/util/vectorrep.cc \
-	rocksdb/util/thread_status_util_debug.cc \
-	rocksdb/util/testharness.cc rocksdb/util/testharness.h \
-	rocksdb/util/heap_test.cc rocksdb/util/thread_list_test.cc \
-	rocksdb/util/thread_local.h rocksdb/util/thread_local_test.cc \
-	rocksdb/util/histogram.h rocksdb/util/cache_test.cc \
-	rocksdb/util/thread_status_updater_debug.cc \
-	rocksdb/util/xxhash.cc rocksdb/util/xxhash.h \
+	rocksdb/tools/run_flash_bench.sh rocksdb/tools/run_leveldb.sh \
+	rocksdb/tools/sample-dump.dmp rocksdb/tools/sst_dump.cc \
+	rocksdb/tools/sst_dump_test.cc rocksdb/tools/sst_dump_tool.cc \
+	rocksdb/tools/sst_dump_tool_imp.h \
+	rocksdb/tools/verify_random_db.sh \
+	rocksdb/tools/write_stress.cc \
+	rocksdb/tools/write_stress_runner.py rocksdb/.travis.yml \
+	rocksdb/USERS.md rocksdb/util/aligned_buffer.h \
+	rocksdb/util/allocator.h rocksdb/util/arena.cc \
+	rocksdb/util/arena.h rocksdb/util/arena_test.cc \
 	rocksdb/util/auto_roll_logger.cc \
 	rocksdb/util/auto_roll_logger.h \
 	rocksdb/util/auto_roll_logger_test.cc \
-	rocksdb/util/autovector_test.cc rocksdb/util/bloom_test.cc \
-	rocksdb/util/cache.cc rocksdb/util/comparator.cc \
-	rocksdb/util/crc32c.cc rocksdb/util/dynamic_bloom_test.cc \
-	rocksdb/util/iostats_context.cc \
-	rocksdb/util/iostats_context_imp.h \
-	rocksdb/util/hash_linklist_rep.cc rocksdb/util/testutil.h \
-	rocksdb/util/arena.cc rocksdb/util/aligned_buffer.h \
-	rocksdb/util/db_test_util.cc \
-	rocksdb/util/delete_scheduler_impl.h \
-	rocksdb/util/file_reader_writer.h \
-	rocksdb/util/options_parser.cc rocksdb/util/perf_step_timer.h \
-	rocksdb/util/db_test_util.h \
-	rocksdb/util/delete_scheduler_test.cc \
-	rocksdb/util/file_reader_writer_test.cc \
-	rocksdb/util/options_parser.h rocksdb/util/status_message.cc \
+	rocksdb/util/autovector.h rocksdb/util/autovector_test.cc \
+	rocksdb/util/bloom.cc rocksdb/util/bloom_test.cc \
+	rocksdb/util/build_version.h rocksdb/util/cache_bench.cc \
+	rocksdb/util/cache.cc rocksdb/util/cache_test.cc \
+	rocksdb/util/channel.h rocksdb/util/coding.cc \
+	rocksdb/util/coding.h rocksdb/util/coding_test.cc \
 	rocksdb/util/compaction_job_stats_impl.cc \
+	rocksdb/util/comparator.cc rocksdb/util/compression.h \
+	rocksdb/util/crc32c.cc rocksdb/util/crc32c.h \
+	rocksdb/util/crc32c_test.cc rocksdb/util/db_info_dumper.cc \
+	rocksdb/util/db_info_dumper.h \
 	rocksdb/util/delete_scheduler_impl.cc \
+	rocksdb/util/delete_scheduler_impl.h \
+	rocksdb/util/delete_scheduler_test.cc \
+	rocksdb/util/dynamic_bloom.cc rocksdb/util/dynamic_bloom.h \
+	rocksdb/util/dynamic_bloom_test.cc rocksdb/util/env.cc \
+	rocksdb/util/env_hdfs.cc rocksdb/util/env_posix.cc \
+	rocksdb/util/env_test.cc rocksdb/util/event_logger.cc \
+	rocksdb/util/event_logger.h rocksdb/util/event_logger_test.cc \
+	rocksdb/util/filelock_test.cc \
 	rocksdb/util/file_reader_writer.cc \
-	rocksdb/util/ldb_cmd_test.cc rocksdb/util/perf_level_imp.h \
+	rocksdb/util/file_reader_writer.h \
+	rocksdb/util/file_reader_writer_test.cc \
+	rocksdb/util/file_util.cc rocksdb/util/file_util.h \
+	rocksdb/util/filter_policy.cc rocksdb/util/hash.cc \
+	rocksdb/util/hash.h rocksdb/util/heap.h \
+	rocksdb/util/heap_test.cc rocksdb/util/histogram.cc \
+	rocksdb/util/histogram.h rocksdb/util/histogram_test.cc \
+	rocksdb/util/instrumented_mutex.cc \
+	rocksdb/util/instrumented_mutex.h rocksdb/util/io_posix.cc \
+	rocksdb/util/io_posix.h rocksdb/util/iostats_context.cc \
+	rocksdb/util/iostats_context_imp.h \
 	rocksdb/utilities/backupable/backupable_db.cc \
 	rocksdb/utilities/backupable/backupable_db_test.cc \
+	rocksdb/utilities/backupable/backupable_db_testutil.h \
 	rocksdb/utilities/checkpoint/checkpoint.cc \
 	rocksdb/utilities/checkpoint/checkpoint_test.cc \
+	rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc \
+	rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.h \
+	rocksdb/utilities/convenience/info_log_finder.cc \
 	rocksdb/utilities/document/document_db.cc \
-	rocksdb/utilities/document/json_document_builder.cc \
 	rocksdb/utilities/document/document_db_test.cc \
+	rocksdb/utilities/document/json_document_builder.cc \
 	rocksdb/utilities/document/json_document.cc \
 	rocksdb/utilities/document/json_document_test.cc \
+	rocksdb/utilities/env_mirror.cc \
+	rocksdb/utilities/env_mirror_test.cc \
+	rocksdb/utilities/flashcache/flashcache.cc \
+	rocksdb/utilities/flashcache/flashcache.h \
 	rocksdb/utilities/geodb/geodb_impl.cc \
 	rocksdb/utilities/geodb/geodb_impl.h \
 	rocksdb/utilities/geodb/geodb_test.cc \
 	rocksdb/utilities/leveldb_options/leveldb_options.cc \
+	rocksdb/utilities/memory/memory_test.cc \
+	rocksdb/utilities/memory/memory_util.cc \
 	rocksdb/utilities/merge_operators.h \
 	rocksdb/utilities/merge_operators/put.cc \
+	rocksdb/utilities/merge_operators/string_append/stringappend2.cc \
+	rocksdb/utilities/merge_operators/string_append/stringappend2.h \
 	rocksdb/utilities/merge_operators/string_append/stringappend.cc \
 	rocksdb/utilities/merge_operators/string_append/stringappend.h \
-	rocksdb/utilities/merge_operators/string_append/stringappend2.h \
-	rocksdb/utilities/merge_operators/string_append/stringappend2.cc \
 	rocksdb/utilities/merge_operators/string_append/stringappend_test.cc \
 	rocksdb/utilities/merge_operators/uint64add.cc \
+	rocksdb/utilities/options/options_util.cc \
+	rocksdb/utilities/options/options_util_test.cc \
 	rocksdb/utilities/redis/README \
 	rocksdb/utilities/redis/redis_list_exception.h \
 	rocksdb/utilities/redis/redis_list_iterator.h \
 	rocksdb/utilities/redis/redis_lists.cc \
 	rocksdb/utilities/redis/redis_lists.h \
 	rocksdb/utilities/redis/redis_lists_test.cc \
-	rocksdb/utilities/spatialdb/utils.h \
 	rocksdb/utilities/spatialdb/spatial_db.cc \
 	rocksdb/utilities/spatialdb/spatial_db_test.cc \
-	rocksdb/utilities/ttl/db_ttl_impl.cc \
-	rocksdb/utilities/ttl/db_ttl_impl.h \
-	rocksdb/utilities/ttl/ttl_test.cc \
-	rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc \
-	rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc \
-	rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h \
-	rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc \
-	rocksdb/utilities/flashcache/flashcache.cc \
-	rocksdb/utilities/flashcache/flashcache.h \
-	rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc \
-	rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.h \
-	rocksdb/utilities/convenience/info_log_finder.cc \
+	rocksdb/utilities/spatialdb/utils.h \
 	rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc \
 	rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h \
 	rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc \
 	rocksdb/utilities/transactions/optimistic_transaction_db_impl.cc \
 	rocksdb/utilities/transactions/optimistic_transaction_db_impl.h \
 	rocksdb/utilities/transactions/optimistic_transaction_impl.cc \
-	rocksdb/utilities/transactions/optimistic_transaction_test.cc \
-	rocksdb/utilities/transactions/transaction_base.h \
-	rocksdb/utilities/transactions/transaction_db_impl.h \
-	rocksdb/utilities/transactions/transaction_db_mutex_impl.h \
-	rocksdb/utilities/transactions/transaction_impl.h \
-	rocksdb/utilities/transactions/transaction_lock_mgr.h \
-	rocksdb/utilities/transactions/transaction_util.cc \
 	rocksdb/utilities/transactions/optimistic_transaction_impl.h \
+	rocksdb/utilities/transactions/optimistic_transaction_test.cc \
 	rocksdb/utilities/transactions/transaction_base.cc \
+	rocksdb/utilities/transactions/transaction_base.h \
 	rocksdb/utilities/transactions/transaction_db_impl.cc \
+	rocksdb/utilities/transactions/transaction_db_impl.h \
 	rocksdb/utilities/transactions/transaction_db_mutex_impl.cc \
+	rocksdb/utilities/transactions/transaction_db_mutex_impl.h \
 	rocksdb/utilities/transactions/transaction_impl.cc \
+	rocksdb/utilities/transactions/transaction_impl.h \
 	rocksdb/utilities/transactions/transaction_lock_mgr.cc \
+	rocksdb/utilities/transactions/transaction_lock_mgr.h \
 	rocksdb/utilities/transactions/transaction_test.cc \
+	rocksdb/utilities/transactions/transaction_util.cc \
 	rocksdb/utilities/transactions/transaction_util.h \
-	rocksdb/.gitignore rocksdb/CMakeLists.txt rocksdb/HISTORY.md \
-	rocksdb/Makefile rocksdb/USERS.md rocksdb/appveyor.yml \
-	rocksdb/src.mk rocksdb/thirdparty.inc rocksdb/.travis.yml \
-	rocksdb/DUMP_FORMAT.md rocksdb/INSTALL.md \
-	rocksdb/ROCKSDB_LITE.md rocksdb/WINDOWS_PORT.md \
-	rocksdb/appveyordailytests.yml rocksdb/AUTHORS \
+	rocksdb/utilities/ttl/db_ttl_impl.cc \
+	rocksdb/utilities/ttl/db_ttl_impl.h \
+	rocksdb/utilities/ttl/ttl_test.cc \
+	rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc \
+	rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc \
+	rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h \
+	rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc \
+	rocksdb/util/kv_map.h rocksdb/util/log_buffer.cc \
+	rocksdb/util/log_buffer.h rocksdb/util/logging.cc \
+	rocksdb/util/logging.h rocksdb/util/log_write_bench.cc \
+	rocksdb/util/memenv.cc rocksdb/util/memenv_test.cc \
+	rocksdb/util/mock_env.cc rocksdb/util/mock_env.h \
+	rocksdb/util/mock_env_test.cc rocksdb/util/murmurhash.cc \
+	rocksdb/util/murmurhash.h rocksdb/util/mutable_cf_options.cc \
+	rocksdb/util/mutable_cf_options.h rocksdb/util/mutexlock.h \
+	rocksdb/util/options_builder.cc rocksdb/util/options.cc \
+	rocksdb/util/options_helper.cc rocksdb/util/options_helper.h \
+	rocksdb/util/options_parser.cc rocksdb/util/options_parser.h \
+	rocksdb/util/options_sanity_check.cc \
+	rocksdb/util/options_sanity_check.h \
+	rocksdb/util/options_test.cc rocksdb/util/perf_context.cc \
+	rocksdb/util/perf_context_imp.h rocksdb/util/perf_level.cc \
+	rocksdb/util/perf_level_imp.h rocksdb/util/perf_step_timer.h \
+	rocksdb/util/posix_logger.h rocksdb/util/random.cc \
+	rocksdb/util/random.h rocksdb/util/rate_limiter.cc \
+	rocksdb/util/rate_limiter.h rocksdb/util/rate_limiter_test.cc \
+	rocksdb/util/skiplistrep.cc rocksdb/util/slice.cc \
+	rocksdb/util/slice_transform_test.cc \
+	rocksdb/util/statistics.cc rocksdb/util/statistics.h \
+	rocksdb/util/status.cc rocksdb/util/status_message.cc \
+	rocksdb/util/stop_watch.h rocksdb/util/string_util.cc \
+	rocksdb/util/string_util.h rocksdb/util/sync_point.cc \
+	rocksdb/util/sync_point.h rocksdb/util/testharness.cc \
+	rocksdb/util/testharness.h rocksdb/util/testutil.cc \
+	rocksdb/util/testutil.h rocksdb/util/thread_list_test.cc \
+	rocksdb/util/thread_local.cc rocksdb/util/thread_local.h \
+	rocksdb/util/thread_local_test.cc \
+	rocksdb/util/thread_operation.h rocksdb/util/thread_posix.cc \
+	rocksdb/util/thread_posix.h rocksdb/util/thread_status_impl.cc \
+	rocksdb/util/thread_status_updater.cc \
+	rocksdb/util/thread_status_updater_debug.cc \
+	rocksdb/util/thread_status_updater.h \
+	rocksdb/util/thread_status_util.cc \
+	rocksdb/util/thread_status_util_debug.cc \
+	rocksdb/util/thread_status_util.h rocksdb/util/vectorrep.cc \
+	rocksdb/util/xfunc.cc rocksdb/util/xfunc.h \
+	rocksdb/util/xxhash.cc rocksdb/util/xxhash.h \
+	rocksdb/Vagrantfile rocksdb/WINDOWS_PORT.md rocksdb/AUTHORS \
 	tracing/tracing-common.h $(srcdir)/pybind/setup.py \
 	$(srcdir)/pybind/rbd.pyx $(srcdir)/$(shell_scripts:%=%.in) \
 	$(srcdir)/vstart.sh $(srcdir)/stop.sh ceph-run \
@@ -8160,6 +8432,8 @@ dist_noinst_DATA = tracing/librados.tp tracing/librbd.tp \
 
 # lrc plugin
 
+# snappy plugin
+
 # everything else we want to include in a 'make dist'
 noinst_HEADERS = arch/intel.h arch/arm.h arch/probe.h \
 	auth/cephx/CephxAuthorizeHandler.h auth/cephx/CephxKeyServer.h \
@@ -8184,10 +8458,10 @@ noinst_HEADERS = arch/intel.h arch/arm.h arch/probe.h \
 	crush/CrushWrapper.h crush/CrushWrapper.i crush/builder.h \
 	crush/crush.h crush/crush_compat.h crush/crush_ln_table.h \
 	crush/grammar.h crush/hash.h crush/mapper.h crush/sample.txt \
-	crush/types.h $(am__append_30) $(am__append_34) \
-	$(am__append_37) $(am__append_41) $(am__append_43) \
-	$(am__append_47) $(am__append_55) $(am__append_57) \
-	$(am__append_59) \
+	crush/types.h $(am__append_32) $(am__append_36) \
+	$(am__append_39) $(am__append_43) $(am__append_45) \
+	$(am__append_49) $(am__append_57) $(am__append_58) \
+	$(am__append_60) $(am__append_63) \
 	erasure-code/jerasure/gf-complete/include/gf_complete.h \
 	erasure-code/jerasure/gf-complete/include/gf_general.h \
 	erasure-code/jerasure/gf-complete/include/gf_int.h \
@@ -8217,12 +8491,15 @@ noinst_HEADERS = arch/intel.h arch/arm.h arch/probe.h \
 	erasure-code/jerasure/gf-complete/include/gf_rand.h \
 	erasure-code/jerasure/gf-complete/include/gf_method.h \
 	erasure-code/jerasure/gf-complete/include/gf_general.h \
-	$(am__append_77) erasure-code/ErasureCode.h \
+	$(am__append_81) erasure-code/ErasureCode.h \
 	erasure-code/ErasureCodeInterface.h \
-	erasure-code/ErasureCodePlugin.h osdc/Filer.h osdc/Journaler.h \
-	osdc/ObjectCacher.h osdc/Objecter.h osdc/Striper.h \
-	osdc/WritebackHandler.h $(am__append_81) $(am__append_83) \
-	global/pidfile.h global/global_init.h global/global_context.h \
+	erasure-code/ErasureCodePlugin.h \
+	compressor/snappy/SnappyCompressor.h compressor/Compressor.h \
+	compressor/AsyncCompressor.h compressor/CompressionPlugin.h \
+	osdc/Filer.h osdc/Journaler.h osdc/ObjectCacher.h \
+	osdc/Objecter.h osdc/Striper.h osdc/WritebackHandler.h \
+	$(am__append_86) $(am__append_88) global/pidfile.h \
+	global/global_init.h global/global_context.h \
 	global/signal_handler.h json_spirit/json_spirit.h \
 	json_spirit/json_spirit_error_position.h \
 	json_spirit/json_spirit_reader.h \
@@ -8272,15 +8549,16 @@ noinst_HEADERS = arch/intel.h arch/arm.h arch/probe.h \
 	common/ContextCompletion.h common/bit_vector.hpp \
 	common/SubProcess.h common/valgrind.h \
 	common/TracepointProvider.h common/event_socket.h \
-	common/PluginRegistry.h $(am__append_104) common/secret.h \
-	msg/Connection.h msg/Dispatcher.h msg/Message.h \
-	msg/Messenger.h msg/SimplePolicyMessenger.h msg/msg_types.h \
+	common/PluginRegistry.h common/ceph_time.h common/ceph_timer.h \
+	$(am__append_109) common/secret.h msg/Connection.h \
+	msg/Dispatcher.h msg/Message.h msg/Messenger.h \
+	msg/SimplePolicyMessenger.h msg/msg_types.h \
 	msg/simple/Accepter.h msg/simple/DispatchQueue.h \
 	msg/simple/Pipe.h msg/simple/PipeConnection.h \
 	msg/simple/SimpleMessenger.h msg/async/AsyncConnection.h \
 	msg/async/AsyncMessenger.h msg/async/Event.h \
 	msg/async/EventEpoll.h msg/async/EventSelect.h \
-	msg/async/net_handler.h $(am__append_113) messages/MAuth.h \
+	msg/async/net_handler.h $(am__append_118) messages/MAuth.h \
 	messages/MAuthReply.h messages/MCacheExpire.h \
 	messages/MClientCaps.h messages/MClientCapRelease.h \
 	messages/MClientLease.h messages/MClientReconnect.h \
@@ -8368,12 +8646,12 @@ noinst_HEADERS = arch/intel.h arch/arm.h arch/probe.h \
 	include/util.h include/stat.h include/on_exit.h \
 	include/memory.h include/rados/memory.h \
 	include/unordered_set.h include/unordered_map.h \
-	include/timegm.h include/event_type.h $(am__append_119) \
-	$(am__append_122) $(am__append_123) $(am__append_128) \
-	$(am__append_134) $(am__append_138) $(am__append_141) \
-	$(am__append_142) $(am__append_148) $(am__append_170) \
-	$(am__append_186) $(am__append_192) $(am__append_204) \
-	test/bench/backend.h test/bench/bencher.h \
+	include/timegm.h include/event_type.h $(am__append_124) \
+	$(am__append_127) $(am__append_128) $(am__append_133) \
+	$(am__append_139) $(am__append_143) $(am__append_146) \
+	$(am__append_147) $(am__append_153) $(am__append_175) \
+	$(am__append_181) $(am__append_198) $(am__append_204) \
+	$(am__append_216) test/bench/backend.h test/bench/bencher.h \
 	test/bench/detailed_stat_collector.h test/bench/distribution.h \
 	test/bench/dumb_backend.h test/bench/rados_backend.h \
 	test/bench/rbd_backend.h test/bench/stat_collector.h \
@@ -8396,55 +8674,54 @@ noinst_HEADERS = arch/intel.h arch/arm.h arch/probe.h \
 	test/system/st_rados_list_objects.h \
 	test/system/st_rados_notify.h test/system/st_rados_watch.h \
 	test/system/systest_runnable.h test/system/systest_settings.h \
-	test/unit.h test/journal/RadosTestFixture.h $(am__append_226) \
+	test/unit.h test/journal/RadosTestFixture.h $(am__append_239) \
 	tools/cephfs/JournalTool.h tools/cephfs/JournalScanner.h \
 	tools/cephfs/JournalFilter.h tools/cephfs/EventOutput.h \
 	tools/cephfs/Resetter.h tools/cephfs/Dumper.h \
 	tools/cephfs/TableTool.h tools/cephfs/MDSUtility.h \
 	tools/RadosDump.h tools/rados/RadosImport.h \
 	tools/ceph_objectstore_tool.h tools/rados/PoolDump.h \
-	tools/cephfs/DataScan.h compressor/Compressor.h \
-	compressor/AsyncCompressor.h compressor/SnappyCompressor.h \
-	cls_acl.cc cls_crypto.cc fetch_config logrotate.conf \
-	sample.ceph.conf bash_completion/ceph bash_completion/rados \
-	bash_completion/rbd bash_completion/radosgw-admin \
-	mount/canonicalize.c mount/mtab.c objclass/objclass.h
-bin_SCRIPTS = $(am__append_27) $(am__append_244) $(am__append_253) \
-	$(am__append_261)
+	tools/cephfs/DataScan.h cls_acl.cc cls_crypto.cc fetch_config \
+	logrotate.conf sample.ceph.conf bash_completion/ceph \
+	bash_completion/rados bash_completion/rbd \
+	bash_completion/radosgw-admin mount/canonicalize.c \
+	mount/mtab.c objclass/objclass.h
+bin_SCRIPTS = $(am__append_29) $(am__append_257) $(am__append_266) \
+	$(am__append_274)
 sbin_SCRIPTS = 
-su_sbin_SCRIPTS = $(am__append_258)
+su_sbin_SCRIPTS = $(am__append_271)
 dist_bin_SCRIPTS = 
-lib_LTLIBRARIES = $(am__append_118) $(am__append_121) \
-	$(am__append_127) $(am__append_233) $(am__append_251) \
-	$(am__append_252)
+lib_LTLIBRARIES = $(am__append_123) $(am__append_126) \
+	$(am__append_132) $(am__append_246) $(am__append_264) \
+	$(am__append_265)
 noinst_LTLIBRARIES = libarch.la libauth.la libcrush.la libmon_types.la \
-	$(am__append_46) libosd_types.la liberasure_code.la libosdc.la \
-	$(am__append_80) $(am__append_82) libglobal.la \
-	libjson_spirit.la liblog.la libperfglue.la \
-	libcommon_internal.la libcommon_crc.la $(am__append_102) \
-	libcommon.la $(am__append_105) libmsg.la $(am__append_114) \
-	librbd_types.la $(am__append_125) $(am__append_130) \
-	$(am__append_135) $(am__append_143) $(am__append_179) \
-	$(am__append_189) $(am__append_194) $(am__append_220) \
-	libcompressor.la $(am__append_245)
-noinst_LIBRARIES = $(am__append_29) $(am__append_42) libos_types.a \
-	$(am__append_54) $(am__append_56) $(am__append_58) \
-	$(am__append_137)
-radoslib_LTLIBRARIES = $(am__append_139) $(am__append_140)
+	$(am__append_48) libosd_types.la liberasure_code.la \
+	libcompressor.la libosdc.la $(am__append_85) $(am__append_87) \
+	libglobal.la libjson_spirit.la liblog.la libperfglue.la \
+	libcommon_internal.la libcommon_crc.la $(am__append_107) \
+	libcommon.la $(am__append_110) libmsg.la $(am__append_119) \
+	librbd_types.la $(am__append_130) $(am__append_135) \
+	$(am__append_140) $(am__append_148) $(am__append_191) \
+	$(am__append_201) $(am__append_206) $(am__append_233) \
+	$(am__append_258)
+noinst_LIBRARIES = $(am__append_31) $(am__append_44) libos_types.a \
+	$(am__append_55) $(am__append_59) $(am__append_62) \
+	$(am__append_142)
+radoslib_LTLIBRARIES = $(am__append_144) $(am__append_145)
 
 # like bin_PROGRAMS, but these targets are only built for debug builds
-bin_DEBUGPROGRAMS = $(am__append_84) $(am__append_133) \
-	$(am__append_150) $(am__append_180) $(am__append_181) \
-	$(am__append_182) $(am__append_183) $(am__append_185) \
-	$(am__append_187) $(am__append_193) $(am__append_195) \
-	$(am__append_196) $(am__append_199) $(am__append_201) \
-	$(am__append_202) $(am__append_203) $(am__append_205) \
-	$(am__append_206) $(am__append_207) $(am__append_208) \
-	$(am__append_214) ceph_test_timers ceph_test_signal_handlers \
-	ceph_test_rewrite_latency ceph_test_crypto $(am__append_219) \
+bin_DEBUGPROGRAMS = $(am__append_89) $(am__append_138) \
+	$(am__append_155) $(am__append_192) $(am__append_193) \
+	$(am__append_194) $(am__append_195) $(am__append_197) \
+	$(am__append_199) $(am__append_205) $(am__append_207) \
+	$(am__append_208) $(am__append_211) $(am__append_213) \
+	$(am__append_214) $(am__append_215) $(am__append_217) \
+	$(am__append_219) $(am__append_220) $(am__append_221) \
+	$(am__append_227) ceph_test_timers ceph_test_signal_handlers \
+	ceph_test_rewrite_latency ceph_test_crypto $(am__append_232) \
 	ceph_bench_log ceph_test_objectcacher_stress \
-	ceph_test_cfuse_cache_invalidate $(am__append_223) \
-	$(am__append_224) $(am__append_228) $(am__append_229) \
+	ceph_test_cfuse_cache_invalidate $(am__append_236) \
+	$(am__append_237) $(am__append_241) $(am__append_242) \
 	ceph_psim
 
 # like sbin_SCRIPTS but can be used to install to e.g. /usr/sbin
@@ -8454,28 +8731,28 @@ ceph_sbindir = $(sbindir)
 su_sbindir = /sbin
 
 # C/C++ tests to build and executed will be appended to this
-check_TESTPROGRAMS = $(am__append_156) $(am__append_160) \
-	$(am__append_163) $(am__append_184) $(am__append_188) \
-	$(am__append_197) $(am__append_210) $(am__append_211) \
-	$(am__append_215) $(am__append_216) $(am__append_217) \
-	$(am__append_218) unittest_addrs $(am__append_222) \
-	unittest_bloom_filter unittest_histogram \
+check_TESTPROGRAMS = $(am__append_161) $(am__append_165) \
+	$(am__append_168) $(am__append_196) $(am__append_200) \
+	$(am__append_209) $(am__append_218) $(am__append_223) \
+	$(am__append_224) $(am__append_228) $(am__append_229) \
+	$(am__append_230) $(am__append_231) unittest_addrs \
+	$(am__append_235) unittest_bloom_filter unittest_histogram \
 	unittest_prioritized_queue unittest_str_map \
 	unittest_sharedptr_registry unittest_shared_cache \
-	unittest_sloppy_crc_map unittest_util unittest_crush_wrapper \
-	unittest_crush unittest_osdmap unittest_workqueue \
-	unittest_striper unittest_prebufferedstreambuf \
-	unittest_str_list unittest_log unittest_throttle \
-	unittest_ceph_argparse unittest_ceph_compatset \
-	unittest_mds_types unittest_osd_types unittest_lru \
-	unittest_io_priority unittest_gather unittest_signals \
-	unittest_bufferlist unittest_xlist unittest_crc32c \
-	unittest_arch unittest_crypto unittest_crypto_init \
-	unittest_perf_counters unittest_admin_socket \
-	unittest_ceph_crypto unittest_utf8 unittest_mime \
-	unittest_escape unittest_strtol unittest_confutils \
-	unittest_config unittest_context unittest_safe_io \
-	unittest_heartbeatmap unittest_formatter \
+	unittest_sloppy_crc_map unittest_time unittest_util \
+	unittest_crush_wrapper unittest_crush unittest_osdmap \
+	unittest_workqueue unittest_striper \
+	unittest_prebufferedstreambuf unittest_str_list unittest_log \
+	unittest_throttle unittest_ceph_argparse \
+	unittest_ceph_compatset unittest_mds_types unittest_osd_types \
+	unittest_lru unittest_io_priority unittest_gather \
+	unittest_signals unittest_bufferlist unittest_xlist \
+	unittest_crc32c unittest_arch unittest_crypto \
+	unittest_crypto_init unittest_perf_counters \
+	unittest_admin_socket unittest_ceph_crypto unittest_utf8 \
+	unittest_mime unittest_escape unittest_strtol \
+	unittest_confutils unittest_config unittest_context \
+	unittest_safe_io unittest_heartbeatmap unittest_formatter \
 	unittest_daemon_config unittest_ipaddr unittest_texttable \
 	unittest_on_exit unittest_readahead unittest_tableformatter \
 	unittest_bit_vector
@@ -8502,8 +8779,8 @@ check_TESTPROGRAMS = $(am__append_156) $(am__append_160) \
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see `<http://www.gnu.org/licenses/>`.
 #
-check_SCRIPTS = ceph-detect-init/run-tox.sh $(am__append_147) \
-	$(am__append_191) test/ceph_objectstore_tool.py \
+check_SCRIPTS = ceph-detect-init/run-tox.sh $(am__append_152) \
+	$(am__append_203) test/ceph_objectstore_tool.py \
 	test/test-ceph-helpers.sh test/cephtool-test-osd.sh \
 	test/cephtool-test-mon.sh test/cephtool-test-mds.sh \
 	test/cephtool-test-rados.sh unittest_bufferlist.sh \
@@ -8512,8 +8789,9 @@ check_SCRIPTS = ceph-detect-init/run-tox.sh $(am__append_147) \
 	test/mon/osd-erasure-code-profile.sh test/mon/mkfs.sh \
 	test/mon/mon-scrub.sh test/osd/osd-scrub-repair.sh \
 	test/osd/osd-scrub-snaps.sh test/osd/osd-config.sh \
-	test/osd/osd-bench.sh test/osd/osd-reactivate.sh \
-	test/osd/osd-copy-from.sh test/mon/mon-handle-forward.sh \
+	test/osd/osd-reuse-id.sh test/osd/osd-bench.sh \
+	test/osd/osd-reactivate.sh test/osd/osd-copy-from.sh \
+	test/osd/osd-markdown.sh test/mon/mon-handle-forward.sh \
 	test/libradosstriper/rados-striper.sh \
 	test/test_objectstore_memstore.sh test/ceph-disk.sh \
 	test/pybind/test_ceph_argparse.py \
@@ -8555,7 +8833,7 @@ AM_COMMON_CFLAGS = \
 	-fsigned-char
 
 AM_CFLAGS = $(AM_COMMON_CFLAGS) $(am__append_6) $(am__append_12) \
-	$(am__append_86) $(am__append_89)
+	$(am__append_91) $(am__append_94)
 AM_CPPFLAGS = $(AM_COMMON_CPPFLAGS)
 
 # note: this is position dependant, it affects the -l options that
@@ -8580,9 +8858,10 @@ LIBPERFGLUE = libperfglue.la $(am__append_19) $(am__append_20)
 LIBAUTH = libauth.la
 LIBMSG = libmsg.la
 LIBCRUSH = libcrush.la
-LIBCOMPRESSOR = libcompressor.la -lsnappy
+LIBCOMPRESSOR = libcompressor.la
 LIBJSON_SPIRIT = libjson_spirit.la
-LIBKV = libkv.a $(am__append_26) -lbz2 -lz -lleveldb -lsnappy
+LIBKV = libkv.a $(am__append_26) $(am__append_27) $(am__append_28) -lz \
+	-lleveldb -lsnappy
 LIBLOG = liblog.la
 LIBOS = libos.a $(am__append_17) $(am__append_18) $(LIBOS_TYPES) \
 	$(LIBKV)
@@ -8619,26 +8898,26 @@ CEPH_GLOBAL = $(LIBGLOBAL) $(LIBCOMMON) $(PTHREAD_LIBS) -lm $(CRYPTO_LIBS) $(EXT
 
 # important; libmsg before libauth!
 LIBCOMMON_DEPS = libcommon_internal.la libcommon_crc.la \
-	$(am__append_101) $(LIBERASURE_CODE) $(LIBMSG) $(LIBAUTH) \
-	$(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
-	$(BOOST_RANDOM_LIBS) $(am__append_103)
-LIBRADOS_DEPS = $(am__append_115)
-LIBRGW_DEPS = $(am__append_131)
+	$(am__append_106) $(LIBERASURE_CODE) $(LIBCOMPRESSOR) \
+	$(LIBMSG) $(LIBAUTH) $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) \
+	$(LIBARCH) $(BOOST_RANDOM_LIBS) $(am__append_108)
+LIBRADOS_DEPS = $(am__append_120)
+LIBRGW_DEPS = $(am__append_136)
 
 # This is used by the dencoder test
 
 # Do not use TCMALLOC with dencoder
-DENCODER_SOURCES = $(am__append_44) perfglue/disabled_heap_profiler.cc \
-	perfglue/disabled_stubs.cc $(am__append_129)
-DENCODER_DEPS = $(am__append_45) $(am__append_124) $(am__append_136) \
-	$(am__append_144)
+DENCODER_SOURCES = $(am__append_46) perfglue/disabled_heap_profiler.cc \
+	perfglue/disabled_stubs.cc $(am__append_134)
+DENCODER_DEPS = $(am__append_47) $(am__append_129) $(am__append_141) \
+	$(am__append_149)
 radoslibdir = $(libdir)/rados-classes
-LOCAL_ALL = ceph-detect-init-all $(am__append_235)
-LOCAL_CLEAN = ceph-detect-init-clean $(am__append_236) \
+LOCAL_ALL = ceph-detect-init-all $(am__append_248)
+LOCAL_CLEAN = ceph-detect-init-clean $(am__append_249) \
 	base-clean-local
 LOCAL_INSTALLDATA = ceph-detect-init-install-data \
 	base-install-data-local
-LOCAL_INSTALLEXEC = $(am__append_237)
+LOCAL_INSTALLEXEC = $(am__append_250)
 libarch_la_SOURCES = \
 	arch/intel.c \
 	arch/arm.c \
@@ -8672,13 +8951,12 @@ libcrush_la_SOURCES = \
 	crush/CrushTester.cc
 
 @ENABLE_SERVER_TRUE at libkv_a_SOURCES = kv/KeyValueDB.cc \
- at ENABLE_SERVER_TRUE@	kv/LevelDBStore.cc $(am__append_32) \
- at ENABLE_SERVER_TRUE@	$(am__append_35) $(am__append_38)
- at ENABLE_SERVER_TRUE@libkv_a_CXXFLAGS = ${AM_CXXFLAGS} -I \
- at ENABLE_SERVER_TRUE@	rocksdb/include $(am__append_31) \
- at ENABLE_SERVER_TRUE@	$(am__append_39)
- at ENABLE_SERVER_TRUE@libkv_a_LIBADD = $(am__append_33) $(am__append_36) \
- at ENABLE_SERVER_TRUE@	$(am__append_40)
+ at ENABLE_SERVER_TRUE@	kv/LevelDBStore.cc $(am__append_34) \
+ at ENABLE_SERVER_TRUE@	$(am__append_37) $(am__append_40)
+ at ENABLE_SERVER_TRUE@libkv_a_CXXFLAGS = ${AM_CXXFLAGS} $(am__append_33) \
+ at ENABLE_SERVER_TRUE@	$(am__append_41)
+ at ENABLE_SERVER_TRUE@libkv_a_LIBADD = $(am__append_35) $(am__append_38) \
+ at ENABLE_SERVER_TRUE@	$(am__append_42)
 libmon_types_la_SOURCES = \
 	mon/PGMap.cc
 
@@ -8735,22 +9013,32 @@ LIBMDS_SOURCES = \
 LIBMDS_DEPS = $(LIBOSDC)
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at libmds_la_SOURCES = $(LIBMDS_SOURCES)
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at libmds_la_LIBADD = $(LIBMDS_DEPS)
-libos_types_a_SOURCES = os/Transaction.cc $(am__append_49)
+libos_types_a_SOURCES = os/kstore/kstore_types.cc os/Transaction.cc \
+	$(am__append_50)
 libos_types_a_CXXFLAGS = ${AM_CXXFLAGS}
- at ENABLE_SERVER_TRUE@libos_a_SOURCES = os/chain_xattr.cc os/fs/FS.cc \
- at ENABLE_SERVER_TRUE@	os/DBObjectMap.cc os/GenericObjectMap.cc \
- at ENABLE_SERVER_TRUE@	os/FileJournal.cc os/FileStore.cc \
- at ENABLE_SERVER_TRUE@	os/GenericFileStoreBackend.cc \
- at ENABLE_SERVER_TRUE@	os/HashIndex.cc os/IndexManager.cc \
- at ENABLE_SERVER_TRUE@	os/JournalingObjectStore.cc os/LFNIndex.cc \
- at ENABLE_SERVER_TRUE@	os/MemStore.cc os/KeyValueStore.cc \
- at ENABLE_SERVER_TRUE@	os/ObjectStore.cc os/WBThrottle.cc \
- at ENABLE_SERVER_TRUE@	$(am__append_48) $(am__append_50) \
- at ENABLE_SERVER_TRUE@	$(am__append_51) $(am__append_52)
+ at ENABLE_SERVER_TRUE@libos_a_SOURCES = os/filestore/chain_xattr.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/DBObjectMap.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/FileJournal.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/FileStore.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/GenericFileStoreBackend.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/HashIndex.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/IndexManager.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/JournalingObjectStore.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/LFNIndex.cc \
+ at ENABLE_SERVER_TRUE@	os/filestore/WBThrottle.cc os/fs/FS.cc \
+ at ENABLE_SERVER_TRUE@	os/keyvaluestore/GenericObjectMap.cc \
+ at ENABLE_SERVER_TRUE@	os/keyvaluestore/KeyValueStore.cc \
+ at ENABLE_SERVER_TRUE@	os/kstore/kv.cc os/kstore/KStore.cc \
+ at ENABLE_SERVER_TRUE@	os/memstore/MemStore.cc os/ObjectStore.cc \
+ at ENABLE_SERVER_TRUE@	$(am__append_51) $(am__append_52) \
+ at ENABLE_SERVER_TRUE@	$(am__append_53) $(am__append_54)
+ at ENABLE_SERVER_TRUE@libos_a_CXXFLAGS = ${AM_CXXFLAGS} -I rocksdb/include -fPIC
 @ENABLE_SERVER_TRUE at libos_a_LIBADD = libos_types.a libkv.a \
- at ENABLE_SERVER_TRUE@	$(am__append_53)
- at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at libos_zfs_a_SOURCES = os/ZFS.cc
+ at ENABLE_SERVER_TRUE@	$(am__append_56)
+ at ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at libos_zfs_a_SOURCES = os/fs/ZFS.cc
 @ENABLE_SERVER_TRUE@@WITH_LIBZFS_TRUE at libos_zfs_a_CXXFLAGS = ${AM_CXXFLAGS} ${LIBZFS_CFLAGS}
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at ceph_bluefs_tool_SOURCES = os/bluestore/bluefs_tool.cc
+ at ENABLE_SERVER_TRUE@@WITH_LIBAIO_TRUE at ceph_bluefs_tool_LDADD = $(LIBOS) $(CEPH_GLOBAL)
 libosd_types_la_SOURCES = \
 	osd/PGLog.cc \
 	osd/osd_types.cc \
@@ -8778,10 +9066,10 @@ libosd_types_la_CXXFLAGS = ${AM_CXXFLAGS}
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libosd_a_LIBADD = 
 erasure_codelibdir = $(pkglibdir)/erasure-code
 erasure_codelib_LTLIBRARIES = libec_jerasure_generic.la \
-	$(am__append_62) $(am__append_64) $(am__append_66) \
+	$(am__append_66) $(am__append_68) $(am__append_70) \
 	libec_jerasure.la libec_lrc.la libec_shec_generic.la \
-	$(am__append_71) $(am__append_73) $(am__append_75) \
-	libec_shec.la $(am__append_79) $(am__append_154)
+	$(am__append_75) $(am__append_77) $(am__append_79) \
+	libec_shec.la $(am__append_83) $(am__append_159)
 jerasure_sources = \
   erasure-code/ErasureCode.cc \
   erasure-code/jerasure/jerasure/src/cauchy.c \
@@ -8814,7 +9102,7 @@ libec_jerasure_generic_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_jerasure_generic_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_generic_la_LDFLAGS = ${AM_LDFLAGS} -module \
-	-avoid-version -shared $(am__append_60)
+	-avoid-version -shared $(am__append_64)
 libec_jerasure_neon_la_SOURCES = ${jerasure_sources}                                       \
                                   erasure-code/jerasure/gf-complete/src/neon/gf_w4_neon.c  \
                                   erasure-code/jerasure/gf-complete/src/neon/gf_w8_neon.c  \
@@ -8834,7 +9122,7 @@ libec_jerasure_neon_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_jerasure_neon_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_neon_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_61)
+	-shared $(am__append_65)
 libec_jerasure_sse3_la_SOURCES = ${jerasure_sources}
 libec_jerasure_sse3_la_CFLAGS = ${AM_CFLAGS}  \
 	${INTEL_SSE_FLAGS} \
@@ -8854,7 +9142,7 @@ libec_jerasure_sse3_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_jerasure_sse3_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_sse3_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_63)
+	-shared $(am__append_67)
 libec_jerasure_sse4_la_SOURCES = ${jerasure_sources}
 libec_jerasure_sse4_la_CFLAGS = ${AM_CFLAGS}  \
 	${INTEL_SSE_FLAGS} \
@@ -8878,7 +9166,7 @@ libec_jerasure_sse4_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_jerasure_sse4_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_sse4_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_65)
+	-shared $(am__append_69)
 libec_jerasure_la_SOURCES = \
 	erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc
 
@@ -8886,7 +9174,7 @@ libec_jerasure_la_CFLAGS = ${AM_CFLAGS}
 libec_jerasure_la_CXXFLAGS = ${AM_CXXFLAGS}
 libec_jerasure_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_67)
+	-shared $(am__append_71)
 lrc_sources = \
   erasure-code/ErasureCode.cc \
   erasure-code/lrc/ErasureCodePluginLrc.cc \
@@ -8897,7 +9185,7 @@ libec_lrc_la_CFLAGS = ${AM_CFLAGS}
 libec_lrc_la_CXXFLAGS = ${AM_CXXFLAGS}
 libec_lrc_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(LIBJSON_SPIRIT)
 libec_lrc_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version -shared \
-	$(am__append_68)
+	$(am__append_72)
 
 # SHEC plugin
 shec_sources = \
@@ -8938,7 +9226,7 @@ libec_shec_generic_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_shec_generic_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_shec_generic_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_69)
+	-shared $(am__append_73)
 libec_shec_neon_la_SOURCES = ${shec_sources} \
 	erasure-code/jerasure/gf-complete/src/neon/gf_w4_neon.c \
 	erasure-code/jerasure/gf-complete/src/neon/gf_w8_neon.c \
@@ -8962,7 +9250,7 @@ libec_shec_neon_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_shec_neon_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_shec_neon_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_70)
+	-shared $(am__append_74)
 libec_shec_sse3_la_SOURCES = ${shec_sources}
 libec_shec_sse3_la_CFLAGS = ${AM_CFLAGS}  \
 	${INTEL_SSE_FLAGS} \
@@ -8986,7 +9274,7 @@ libec_shec_sse3_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_shec_sse3_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_shec_sse3_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_72)
+	-shared $(am__append_76)
 libec_shec_sse4_la_SOURCES = ${shec_sources}
 libec_shec_sse4_la_CFLAGS = ${AM_CFLAGS}  \
 	${INTEL_SSE_FLAGS} \
@@ -9014,7 +9302,7 @@ libec_shec_sse4_la_CXXFLAGS = ${AM_CXXFLAGS} \
 
 libec_shec_sse4_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_shec_sse4_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version \
-	-shared $(am__append_74)
+	-shared $(am__append_78)
 libec_shec_la_SOURCES = \
 	erasure-code/shec/ErasureCodePluginSelectShec.cc
 
@@ -9022,7 +9310,7 @@ libec_shec_la_CFLAGS = ${AM_CFLAGS}
 libec_shec_la_CXXFLAGS = ${AM_CXXFLAGS}
 libec_shec_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_shec_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version -shared \
-	$(am__append_76)
+	$(am__append_80)
 @WITH_BETTER_YASM_ELF64_TRUE at isa_sources = \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/ErasureCode.cc \
 @WITH_BETTER_YASM_ELF64_TRUE@	erasure-code/isa/isa-l/erasure_code/ec_base.c \
@@ -9078,13 +9366,35 @@ libec_shec_la_LDFLAGS = ${AM_LDFLAGS} -module -avoid-version -shared \
 @WITH_BETTER_YASM_ELF64_TRUE at libec_isa_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 @WITH_BETTER_YASM_ELF64_TRUE at libec_isa_la_LDFLAGS = ${AM_LDFLAGS} \
 @WITH_BETTER_YASM_ELF64_TRUE@	-module -avoid-version -shared \
- at WITH_BETTER_YASM_ELF64_TRUE@	$(am__append_78)
+ at WITH_BETTER_YASM_ELF64_TRUE@	$(am__append_82)
 @WITH_BETTER_YASM_ELF64_TRUE at libec_isa_la_LIBTOOLFLAGS = --tag=CC
 liberasure_code_la_SOURCES = \
 	erasure-code/ErasureCodePlugin.cc
 
 liberasure_code_la_DEPENDENCIES = $(erasure_codelib_LTLIBRARIES)
 @LINUX_TRUE at liberasure_code_la_LIBADD = -ldl
+compressorlibdir = $(pkglibdir)/compressor
+compressorlib_LTLIBRARIES = libceph_snappy.la $(am__append_182)
+snappy_sources = \
+  compressor/Compressor.cc \
+  compressor/snappy/CompressionPluginSnappy.cc
+
+libceph_snappy_la_SOURCES = ${snappy_sources}
+libceph_snappy_la_CFLAGS = ${AM_CFLAGS}  \
+  -I$(srcdir)/compressor/snappy/snappy-1.2.8
+
+libceph_snappy_la_CXXFLAGS = ${AM_CXXFLAGS} \
+  -I$(srcdir)/compressor/snappy/snappy-1.2.8
+
+libceph_snappy_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+libceph_snappy_la_LDFLAGS = ${AM_LDFLAGS} -lsnappy -version-info 2:0:0 \
+	$(am__append_84)
+libcompressor_la_SOURCES = \
+	compressor/Compressor.cc \
+	compressor/AsyncCompressor.cc
+
+libcompressor_la_DEPENDENCIES = $(compressorlib_LTLIBRARIES)
+ at LINUX_TRUE@libcompressor_la_LIBADD = -ldl
 libosdc_la_SOURCES = \
 	osdc/Objecter.cc \
 	osdc/ObjectCacher.cc \
@@ -9099,7 +9409,8 @@ libosdc_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@	client/MetaRequest.cc \
 @ENABLE_CLIENT_TRUE@	client/ClientSnapRealm.cc \
 @ENABLE_CLIENT_TRUE@	client/MetaSession.cc \
- at ENABLE_CLIENT_TRUE@	client/Trace.cc
+ at ENABLE_CLIENT_TRUE@	client/Trace.cc \
+ at ENABLE_CLIENT_TRUE@	client/posix_acl.cc
 
 @ENABLE_CLIENT_TRUE at libclient_la_LIBADD = $(LIBOSDC) $(LIBEDIT_LIBS)
 @ENABLE_CLIENT_TRUE@@WITH_FUSE_TRUE at libclient_fuse_la_SOURCES = client/fuse_ll.cc
@@ -9123,8 +9434,8 @@ liblog_la_SOURCES = \
 	log/Log.cc \
 	log/SubsystemMap.cc
 
-libperfglue_la_SOURCES = $(am__append_85) $(am__append_88) \
-	$(am__append_91) $(am__append_92) $(am__append_93)
+libperfglue_la_SOURCES = $(am__append_90) $(am__append_93) \
+	$(am__append_96) $(am__append_97) $(am__append_98)
 @WITH_TCMALLOC_FALSE@@WITH_TCMALLOC_MINIMAL_TRUE at libperfglue_la_LIBADD = -ltcmalloc_minimal
 @WITH_TCMALLOC_TRUE at libperfglue_la_LIBADD = -ltcmalloc
 
@@ -9135,28 +9446,29 @@ libcommon_internal_la_SOURCES = ceph_ver.c common/DecayCounter.cc \
 	common/BackTrace.cc common/perf_counters.cc common/Mutex.cc \
 	common/OutputDataSocket.cc common/admin_socket.cc \
 	common/admin_socket_client.cc common/cmdparse.cc \
-	common/escape.c common/io_priority.cc common/Clock.cc \
-	common/Throttle.cc common/Timer.cc common/Finisher.cc \
-	common/environment.cc common/assert.cc common/run_cmd.cc \
-	common/WorkQueue.cc common/ConfUtils.cc common/MemoryModel.cc \
-	common/armor.c common/fd.cc common/safe_io.c \
-	common/snap_types.cc common/str_list.cc common/str_map.cc \
-	common/errno.cc common/RefCountedObj.cc common/common_init.cc \
-	common/pipe.c common/ceph_argparse.cc common/ceph_context.cc \
-	common/types.cc common/code_environment.cc common/dout.cc \
-	common/histogram.cc common/signal.cc common/simple_spin.cc \
-	common/Thread.cc common/Formatter.cc common/HeartbeatMap.cc \
-	common/config.cc common/utf8.c common/mime.c common/strtol.cc \
-	common/page.cc common/lockdep.cc common/version.cc \
-	common/hex.cc common/entity_name.cc common/ceph_crypto.cc \
+	common/escape.c common/io_priority.cc common/ceph_time.cc \
+	common/Clock.cc common/Throttle.cc common/Timer.cc \
+	common/Finisher.cc common/environment.cc common/assert.cc \
+	common/run_cmd.cc common/WorkQueue.cc common/ConfUtils.cc \
+	common/MemoryModel.cc common/armor.c common/fd.cc \
+	common/safe_io.c common/snap_types.cc common/str_list.cc \
+	common/str_map.cc common/errno.cc common/RefCountedObj.cc \
+	common/common_init.cc common/pipe.c common/ceph_argparse.cc \
+	common/ceph_context.cc common/types.cc \
+	common/code_environment.cc common/dout.cc common/histogram.cc \
+	common/signal.cc common/simple_spin.cc common/Thread.cc \
+	common/Formatter.cc common/HeartbeatMap.cc common/config.cc \
+	common/utf8.c common/mime.c common/strtol.cc common/page.cc \
+	common/lockdep.cc common/version.cc common/hex.cc \
+	common/entity_name.cc common/ceph_crypto.cc \
 	common/ceph_crypto_cms.cc common/TextTable.cc \
 	common/ceph_fs.cc common/ceph_hash.cc common/ceph_strings.cc \
 	common/ceph_frag.cc common/addr_parsing.c common/hobject.cc \
 	common/bloom_filter.cc common/module.c common/Readahead.cc \
 	common/Cycles.cc common/ContextCompletion.cc \
 	common/TracepointProvider.cc common/PluginRegistry.cc \
-	$(am__append_94) $(am__append_95) $(am__append_96) \
-	$(am__append_97) $(am__append_98) $(am__append_99) \
+	$(am__append_99) $(am__append_100) $(am__append_101) \
+	$(am__append_102) $(am__append_103) $(am__append_104) \
 	mon/MonCap.cc mon/MonClient.cc mon/MonMap.cc osd/OSDMap.cc \
 	osd/osd_types.cc osd/ECMsgTypes.cc osd/HitSet.cc mds/MDSMap.cc \
 	mds/inode_backtrace.cc mds/mdstypes.cc mds/flock.cc
@@ -9164,7 +9476,7 @@ libcommon_internal_la_SOURCES = ceph_ver.c common/DecayCounter.cc \
 # inject crc in common
 libcommon_crc_la_SOURCES = common/sctp_crc32.c common/crc32c.cc \
 	common/crc32c_intel_baseline.c common/crc32c_intel_fast.c \
-	$(am__append_100)
+	$(am__append_105)
 @WITH_GOOD_YASM_ELF64_TRUE at libcommon_crc_la_LIBTOOLFLAGS = --tag=CC
 @HAVE_ARMV8_CRC_TRUE at libcommon_crc_aarch64_la_SOURCES = common/crc32c_aarch64.c
 @HAVE_ARMV8_CRC_TRUE at libcommon_crc_aarch64_la_CFLAGS = $(AM_CFLAGS) $(ARM_CRC_FLAGS)
@@ -9178,9 +9490,9 @@ libmsg_la_SOURCES = msg/Message.cc msg/Messenger.cc msg/msg_types.cc \
 	msg/simple/SimpleMessenger.cc msg/async/AsyncConnection.cc \
 	msg/async/AsyncMessenger.cc msg/async/Event.cc \
 	msg/async/net_handler.cc msg/async/EventSelect.cc \
-	$(am__append_106) $(am__append_107) $(am__append_108) \
-	$(am__append_109) $(am__append_110) $(am__append_111) \
-	$(am__append_112)
+	$(am__append_111) $(am__append_112) $(am__append_113) \
+	$(am__append_114) $(am__append_115) $(am__append_116) \
+	$(am__append_117)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at rados_includedir = $(includedir)/rados
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at rados_include_DATA = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(srcdir)/include/rados/librados.h \
@@ -9224,12 +9536,12 @@ libmsg_la_SOURCES = msg/Message.cc msg/Messenger.cc msg/msg_types.cc \
 # We need this to avoid basename conflicts with the librados build tests in test/Makefile.am
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at librados_la_CXXFLAGS =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	${AM_CXXFLAGS} \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__append_116)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__append_121)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at librados_la_LIBADD = $(LIBRADOS_DEPS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(EXTRALIBS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at librados_la_LDFLAGS =  \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	${AM_LDFLAGS} \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	-version-info 2:0:0 \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__append_117)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(am__append_122)
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at libradosstriper_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	libradosstriper/libradosstriper.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	libradosstriper/RadosStriperImpl.cc \
@@ -9243,7 +9555,7 @@ libmsg_la_SOURCES = msg/Message.cc msg/Messenger.cc msg/msg_types.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE at libradosstriper_la_LDFLAGS = ${AM_LDFLAGS} \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	-version-info \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	1:0:0 \
- at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__append_120)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOSSTRIPER_TRUE@@WITH_RADOS_TRUE@	$(am__append_125)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at libjournal_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/AsyncOpTracker.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/Entry.cc \
@@ -9259,7 +9571,7 @@ libmsg_la_SOURCES = msg/Message.cc msg/Messenger.cc msg/msg_types.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	journal/Utils.cc
 
 librbd_types_la_SOURCES = \
-	librbd/JournalTypes.cc \
+	librbd/journal/Entries.cc \
 	librbd/WatchNotifyTypes.cc
 
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at librbd_internal_la_SOURCES = \
@@ -9278,10 +9590,10 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/ImageWatcher.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/internal.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Journal.cc \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/JournalReplay.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/LibrbdAdminSocketHook.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/LibrbdWriteback.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/ObjectMap.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Operations.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/Utils.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/exclusive_lock/AcquireRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/exclusive_lock/ReleaseRequest.cc \
@@ -9290,6 +9602,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/RefreshParentRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/RefreshRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/image/SetSnapRequest.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/journal/Replay.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/InvalidateRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/LockRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librbd/object_map/Request.cc \
@@ -9331,7 +9644,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at librbd_la_LDFLAGS = ${AM_LDFLAGS} \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	-version-info \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	1:0:0 \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__append_126)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(am__append_131)
 @ENABLE_CLIENT_TRUE@@LINUX_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at librbd_la_CXXFLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at librgw_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	rgw/librgw.cc \
@@ -9572,7 +9885,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(BOOST_PROGRAM_OPTIONS_LIBS) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_149)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_154)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_erasure_code_non_regression_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/ceph_erasure_code_non_regression.cc
 
@@ -9580,7 +9893,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(BOOST_PROGRAM_OPTIONS_LIBS) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_151)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_156)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at ceph_erasure_code_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/ceph_erasure_code.cc
 
@@ -9588,7 +9901,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(BOOST_PROGRAM_OPTIONS_LIBS) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_153)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_158)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libec_example_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	erasure-code/ErasureCode.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/ErasureCodePluginExample.cc
@@ -9651,7 +9964,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_155)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_160)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	erasure-code/ErasureCode.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCode.cc
@@ -9674,7 +9987,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_157)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_162)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_jerasure_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodePluginJerasure.cc
 
@@ -9683,7 +9996,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_158)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_163)
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_isa_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	erasure-code/ErasureCode.cc \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodeIsa.cc
@@ -9695,7 +10008,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	.libs/libec_isa.la \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(LIBERASURE_CODE) \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__append_159)
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__append_164)
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_isa_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	erasure-code/ErasureCode.cc \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodePluginIsa.cc
@@ -9707,7 +10020,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	.libs/libec_isa.la \
 @ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(LIBERASURE_CODE) \
- at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__append_161)
+ at ENABLE_SERVER_TRUE@@WITH_BETTER_YASM_ELF64_TRUE@@WITH_OSD_TRUE@	$(am__append_166)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_lrc_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodeLrc.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${lrc_sources}
@@ -9717,7 +10030,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_162)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_167)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_lrc_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodePluginLrc.cc
 
@@ -9726,7 +10039,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_164)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_169)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodeShec.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${shec_sources}
@@ -9747,7 +10060,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_165)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_170)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_all_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodeShec_all.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${shec_sources}
@@ -9768,7 +10081,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_166)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_171)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_thread_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodeShec_thread.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${shec_sources}
@@ -9789,7 +10102,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_167)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_172)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_shec_arguments_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/erasure-code/TestErasureCodeShec_arguments.cc \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${shec_sources}
@@ -9810,7 +10123,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_168)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_173)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_erasure_code_plugin_shec_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@        test/erasure-code/TestErasureCodePluginShec.cc
 
@@ -9819,7 +10132,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_169)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_174)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libec_test_shec_neon_la_SOURCES = test/erasure-code/TestShecPluginNEON.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libec_test_shec_neon_la_CFLAGS = ${AM_CFLAGS}
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libec_test_shec_neon_la_CXXFLAGS = ${AM_CXXFLAGS}
@@ -9857,7 +10170,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(CEPH_GLOBAL) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(PTHREAD_LIBS) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(EXTRALIBS) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_171)
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_176)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at simple_client_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/simple_client.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/simple_dispatcher.cc
@@ -9869,7 +10182,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(CEPH_GLOBAL) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(PTHREAD_LIBS) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(EXTRALIBS) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_172)
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_177)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at xio_server_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_server.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_dispatcher.cc
@@ -9881,7 +10194,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(PTHREAD_LIBS) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(EXTRALIBS) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_174)
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_179)
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE at xio_client_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_client.cc \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	test/messenger/xio_dispatcher.cc
@@ -9893,7 +10206,48 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(LIBCOMMON) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(PTHREAD_LIBS) \
 @ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(EXTRALIBS) \
- at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_175)
+ at ENABLE_SERVER_TRUE@@ENABLE_XIO_TRUE@	$(am__append_180)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libceph_example_la_SOURCES = \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	compressor/Compressor.cc \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/compressor/compressor_plugin_example.cc
+
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libceph_example_la_CFLAGS = ${AM_CFLAGS}
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libceph_example_la_CXXFLAGS = ${AM_CXXFLAGS}
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libceph_example_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at libceph_example_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__compression_.*'
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_SOURCES = \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	compressor/Compressor.cc \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/compressor/test_compression_plugin.cc 
+
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_LDADD =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_183)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_snappy_SOURCES = \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/compressor/test_compression_snappy.cc \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${snappy_sources}
+
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_snappy_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_snappy_LDADD =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_184)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_snappy_LDFLAGS = -lsnappy
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_snappy_SOURCES = \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	test/compressor/test_compression_plugin_snappy.cc \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	${snappy_sources}
+
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_snappy_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_snappy_LDADD =  \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBCOMMON) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBCOMPRESSOR) \
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_185)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_compression_plugin_snappy_LDFLAGS = -lsnappy
 
 # This should use LIBMDS_TYPES once it exists
 @ENABLE_CLIENT_TRUE at ceph_dencoder_SOURCES = \
@@ -9911,15 +10265,16 @@ librbd_types_la_SOURCES = \
 
 # These should always use explicit _CFLAGS/_CXXFLAGS so avoid basename conflicts
 @ENABLE_CLIENT_TRUE at ceph_dencoder_CFLAGS = ${AM_CFLAGS} \
- at ENABLE_CLIENT_TRUE@	$(am__append_176)
+ at ENABLE_CLIENT_TRUE@	$(am__append_186)
 @ENABLE_CLIENT_TRUE at ceph_dencoder_CXXFLAGS = ${AM_CXXFLAGS} \
- at ENABLE_CLIENT_TRUE@	$(am__append_177)
+ at ENABLE_CLIENT_TRUE@	$(am__append_187) $(am__append_188) \
+ at ENABLE_CLIENT_TRUE@	$(am__append_189)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at libradostest_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados/test.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/librados/TestCase.cc
 
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at libradostest_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at RADOS_TEST_LDADD = libradostest.la
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at RADOS_TEST_LDADD = libradostest.la $(LIBCOMMON) $(CRYPTO_LIBS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at ceph_test_rados_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/osd/TestRados.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	test/osd/TestOpStat.cc \
@@ -10128,7 +10483,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE at unittest_journal_LDADD = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	libjournal.la libcls_journal_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	librados_test_stub.la librados_internal.la \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD) $(LIBRADOS)
 
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at ceph_smalliobenchrbd_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/bench/small_io_bench_rbd.cc \
@@ -10152,17 +10507,19 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_librbd.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_ImageWatcher.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_internal.cc \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_JournalEntries.cc \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_JournalReplay.cc \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_ObjectMap.cc
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_ObjectMap.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/journal/test_Entries.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/journal/test_Replay.cc
 
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at librbd_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at unittest_librbd_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@        test/librbd/test_main.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_mock_fixture.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_mock_ExclusiveLock.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/test_mock_Journal.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/exclusive_lock/test_mock_AcquireRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/journal/test_mock_Replay.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/test_mock_InvalidateRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/test_mock_LockRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/test_mock_RefreshRequest.cc \
@@ -10172,9 +10529,11 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/test_mock_UnlockRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/object_map/test_mock_UpdateRequest.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/test_mock_ResizeRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/test_mock_SnapshotCreateRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/test_mock_SnapshotProtectRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/test_mock_SnapshotRemoveRequest.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/test_mock_SnapshotRollbackRequest.cc \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
 
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at unittest_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
@@ -10183,7 +10542,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	libcls_rbd_client.la libcls_lock_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	libjournal.la libcls_journal_client.la \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	librados_test_stub.la librados_internal.la \
- at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBOSDC) $(UNITTEST_LDADD) \
+ at ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(LIBRADOS) $(LIBOSDC) $(UNITTEST_LDADD) \
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE@	$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
 
 @ENABLE_CLIENT_TRUE@@WITH_RADOS_TRUE@@WITH_RBD_TRUE at ceph_test_librbd_SOURCES = \
@@ -10260,7 +10619,8 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/caps.cc \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/multiclient.cc \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/access.cc \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__append_198)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	test/libcephfs/acl.cc \
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__append_210)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at ceph_test_libcephfs_LDADD = $(LIBRADOS) $(LIBCEPHFS) $(LIBCOMMON) $(UNITTEST_LDADD)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at ceph_test_libcephfs_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at unittest_encoding_SOURCES = test/encoding.cc
@@ -10283,7 +10643,7 @@ librbd_types_la_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	-Wignored-qualifiers \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	-Wold-style-definition \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	-Wtype-limits \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__append_200)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__append_212)
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE at test_build_librgw_SOURCES = \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	test/buildtest_skeleton.cc \
 @ENABLE_CLIENT_TRUE@@WITH_BUILD_TESTS_TRUE@@WITH_RADOSGW_TRUE@@WITH_RADOS_TRUE@	$(librgw_la_SOURCES)
@@ -10372,8 +10732,6 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE at ceph_test_msgr_SOURCES = test/msgr/test_msgr.cc
 @ENABLE_SERVER_TRUE at ceph_test_msgr_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 @ENABLE_SERVER_TRUE at ceph_test_msgr_CXXFLAGS = $(UNITTEST_CXXFLAGS)
- at ENABLE_SERVER_TRUE@ceph_streamtest_SOURCES = test/streamtest.cc
- at ENABLE_SERVER_TRUE@ceph_streamtest_LDADD = $(LIBOS) $(CEPH_GLOBAL)
 @ENABLE_SERVER_TRUE at ceph_test_trans_SOURCES = test/test_trans.cc
 @ENABLE_SERVER_TRUE at ceph_test_trans_LDADD = $(LIBOS) $(CEPH_GLOBAL)
 @ENABLE_SERVER_TRUE at ceph_test_mon_workloadgen_SOURCES = test/mon/test_mon_workloadgen.cc
@@ -10405,6 +10763,12 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at ceph_test_filestore_SOURCES = test/filestore/TestFileStore.cc
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at ceph_test_filestore_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 @ENABLE_SERVER_TRUE@@LINUX_TRUE at ceph_test_filestore_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluefs_SOURCES = test/objectstore/test_bluefs.cc
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluefs_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluefs_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluestore_types_SOURCES = test/objectstore/test_bluestore_types.cc
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluestore_types_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+ at ENABLE_SERVER_TRUE@@LINUX_TRUE at unittest_bluestore_types_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 @ENABLE_SERVER_TRUE at ceph_test_objectstore_workloadgen_SOURCES = \
 @ENABLE_SERVER_TRUE@	test/objectstore/workload_generator.cc \
 @ENABLE_SERVER_TRUE@	test/objectstore/TestObjectStoreState.cc
@@ -10481,13 +10845,13 @@ librbd_types_la_SOURCES = \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_osdscrub_LDADD =  \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_212)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_225)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_pglog_SOURCES = test/osd/TestPGLog.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_pglog_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_pglog_LDADD = $(LIBOSD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(UNITTEST_LDADD) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_213)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_226)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_hitset_SOURCES = test/osd/hitset.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_hitset_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at unittest_hitset_LDADD = $(LIBOSD) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
@@ -10554,7 +10918,7 @@ UNITTEST_CXXFLAGS = \
 UNITTEST_LDADD = $(top_builddir)/src/gmock/lib/libgmock_main.la \
 	$(top_builddir)/src/gmock/lib/libgmock.la \
 	$(top_builddir)/src/gmock/gtest/lib/libgtest.la \
-	$(PTHREAD_LIBS) $(am__append_221)
+	$(PTHREAD_LIBS) $(am__append_234)
 unittest_addrs_SOURCES = test/test_addrs.cc
 unittest_addrs_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_addrs_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL)
@@ -10582,6 +10946,9 @@ unittest_shared_cache_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 unittest_sloppy_crc_map_SOURCES = test/common/test_sloppy_crc_map.cc
 unittest_sloppy_crc_map_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_sloppy_crc_map_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+unittest_time_SOURCES = test/common/test_time.cc
+unittest_time_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+unittest_time_LDADD = $(LIBCOMMON) -lm $(UNITTEST_LDADD) $(CRYPTO_LIBS) $(EXTRALIBS)
 unittest_util_SOURCES = test/common/test_util.cc
 unittest_util_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_util_LDADD = $(LIBCOMMON) -lm $(UNITTEST_LDADD) $(CRYPTO_LIBS) $(EXTRALIBS)
@@ -10723,7 +11090,7 @@ unittest_subprocess_LDADD = $(LIBCOMMON) $(UNITTEST_LDADD)
 unittest_subprocess_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_async_compressor_SOURCES = test/common/test_async_compressor.cc
 unittest_async_compressor_CXXFLAGS = $(UNITTEST_CXXFLAGS)
-unittest_async_compressor_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(LIBCOMPRESSOR)
+unittest_async_compressor_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(LIBCOMPRESSOR) $(LIBCOMMON)
 ceph_test_objectcacher_stress_SOURCES = \
 	test/osdc/object_cacher_stress.cc \
 	test/osdc/FakeWriteback.cc
@@ -10808,7 +11175,7 @@ ceph_test_cfuse_cache_invalidate_SOURCES = test/test_cfuse_cache_invalidate.cc
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBOS) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(BOOST_PROGRAM_OPTIONS_LIBS) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_230)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_243)
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE at cephfs_journal_tool_SOURCES = \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/cephfs-journal-tool.cc \
 @ENABLE_CLIENT_TRUE@@ENABLE_SERVER_TRUE@@WITH_MDS_TRUE@@WITH_RADOS_TRUE@	tools/cephfs/JournalTool.cc \
@@ -10844,11 +11211,6 @@ ceph_conf_SOURCES = tools/ceph_conf.cc
 ceph_conf_LDADD = $(CEPH_GLOBAL)
 ceph_authtool_SOURCES = tools/ceph_authtool.cc
 ceph_authtool_LDADD = $(CEPH_GLOBAL)
-libcompressor_la_SOURCES = \
-	compressor/Compressor.cc \
-	compressor/AsyncCompressor.cc
-
-libcompressor_la_LIBADD = $(LIBCOMMON)
 @WITH_LTTNG_TRUE at libosd_tp_la_SOURCES = \
 @WITH_LTTNG_TRUE@	tracing/oprequest.c \
 @WITH_LTTNG_TRUE@	tracing/osd.c \
@@ -10910,7 +11272,7 @@ editpaths = sed \
 	-e 's|@@GCOV_PREFIX_STRIP[@][@]|$(GCOV_PREFIX_STRIP)|g'
 
 shell_scripts = ceph-debugpack ceph-post-file ceph-crush-location \
-	$(am__append_255)
+	$(am__append_268)
 doc_DATA = $(srcdir)/sample.ceph.conf sample.fetch_config
 
 # various scripts
@@ -10925,12 +11287,12 @@ ceph_libexec_SCRIPTS = ceph-osd-prestart.sh
 @WITH_LTTNG_TRUE at TESTS_ENVIRONMENT = LD_PRELOAD=liblttng-ust-fork.so; export LD_PRELOAD; echo "LD_PRELOAD=$${LD_PRELOAD}";
 
 # pybind
-python_PYTHON = $(am__append_238) $(am__append_241) $(am__append_249) \
-	$(am__append_254)
+python_PYTHON = $(am__append_251) $(am__append_254) $(am__append_262) \
+	$(am__append_267)
 @ENABLE_CLIENT_TRUE at bash_completiondir = $(sysconfdir)/bash_completion.d
 @ENABLE_CLIENT_TRUE at bash_completion_DATA =  \
 @ENABLE_CLIENT_TRUE@	$(srcdir)/bash_completion/ceph \
- at ENABLE_CLIENT_TRUE@	$(am__append_240) $(am__append_243)
+ at ENABLE_CLIENT_TRUE@	$(am__append_253) $(am__append_256)
 @ENABLE_CLIENT_TRUE at ceph_syn_SOURCES = ceph_syn.cc \
 @ENABLE_CLIENT_TRUE@	client/SyntheticClient.cc # uses g_conf.. \
 @ENABLE_CLIENT_TRUE@	needs cleanup
@@ -10957,7 +11319,7 @@ python_PYTHON = $(am__append_238) $(am__append_241) $(am__append_249) \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	1:0:0 \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	-export-symbols-regex \
 @ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	'^ceph_.*' \
- at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__append_250)
+ at ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE@	$(am__append_263)
 
 # jni library (java source is in src/java)
 @ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at libcephfs_jni_la_SOURCES = \
@@ -10970,7 +11332,7 @@ python_PYTHON = $(am__append_238) $(am__append_241) $(am__append_249) \
 @ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at libcephfs_jni_la_CPPFLAGS = $(JDK_CPPFLAGS) $(AM_CPPFLAGS)
 @ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at libcephfs_jni_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0
 @ENABLE_SERVER_TRUE at ceph_sbin_SCRIPTS = ceph-create-keys \
- at ENABLE_SERVER_TRUE@	$(am__append_260)
+ at ENABLE_SERVER_TRUE@	$(am__append_273)
 @ENABLE_SERVER_TRUE at mount_ceph_SOURCES = mount/mount.ceph.c
 @ENABLE_SERVER_TRUE at mount_ceph_LDADD = $(LIBSECRET) $(LIBCOMMON)
 @ENABLE_SERVER_TRUE@@WITH_MON_TRUE at ceph_mon_SOURCES = ceph_mon.cc
@@ -10980,7 +11342,7 @@ python_PYTHON = $(am__append_238) $(am__append_241) $(am__append_249) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOSD) $(LIBOSD_TYPES) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(LIBOS_TYPES) $(LIBOS) \
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(CEPH_GLOBAL) $(LIBCOMMON) \
- at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_262)
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE@	$(am__append_275)
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at ceph_mds_SOURCES = ceph_mds.cc
 @ENABLE_SERVER_TRUE@@WITH_MDS_TRUE at ceph_mds_LDADD = $(LIBMDS) $(LIBOSDC) $(CEPH_GLOBAL) $(LIBCOMMON)
 @ENABLE_COVERAGE_TRUE@@ENABLE_SERVER_TRUE at COV_DIR = $(DESTDIR)$(libdir)/ceph/coverage
@@ -10991,7 +11353,7 @@ all: $(BUILT_SOURCES) acconfig.h
 
 .SUFFIXES:
 .SUFFIXES: .S .c .cc .cpp .lo .log .o .obj .s .test .test$(EXEEXT) .trs
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/Makefile-env.am $(srcdir)/arch/Makefile.am $(srcdir)/auth/Makefile.am $(srcdir)/brag/Makefile.am $(srcdir)/ceph-detect-init/Makefile.am $(srcdir)/crush/Makefile.am $(srcdir)/kv/Makefile.am $(srcdir)/mon/Makefile.am $(srcdir)/mds/Makefile.am $(srcdir)/mds/Makefile-client.am $(srcdir)/mds/Makefile-server.am $(srcdir)/os/Makefile.am $(srcdir)/osd/Makefile.am $(srcdir)/erasure-code/Makefile.am $(srcdir)/erasure-code/jerasure/Makefile.am [...]
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/Makefile-env.am $(srcdir)/arch/Makefile.am $(srcdir)/auth/Makefile.am $(srcdir)/brag/Makefile.am $(srcdir)/ceph-detect-init/Makefile.am $(srcdir)/crush/Makefile.am $(srcdir)/kv/Makefile.am $(srcdir)/mon/Makefile.am $(srcdir)/mds/Makefile.am $(srcdir)/mds/Makefile-client.am $(srcdir)/mds/Makefile-server.am $(srcdir)/os/Makefile.am $(srcdir)/osd/Makefile.am $(srcdir)/erasure-code/Makefile.am $(srcdir)/erasure-code/jerasure/Makefile.am [...]
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -11003,7 +11365,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/Makefile-env.am $(srcdir
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --gnu src/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -11012,7 +11373,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
-$(srcdir)/Makefile-env.am $(srcdir)/arch/Makefile.am $(srcdir)/auth/Makefile.am $(srcdir)/brag/Makefile.am $(srcdir)/ceph-detect-init/Makefile.am $(srcdir)/crush/Makefile.am $(srcdir)/kv/Makefile.am $(srcdir)/mon/Makefile.am $(srcdir)/mds/Makefile.am $(srcdir)/mds/Makefile-client.am $(srcdir)/mds/Makefile-server.am $(srcdir)/os/Makefile.am $(srcdir)/osd/Makefile.am $(srcdir)/erasure-code/Makefile.am $(srcdir)/erasure-code/jerasure/Makefile.am $(srcdir)/erasure-code/lrc/Makefile.am $(srcd [...]
+$(srcdir)/Makefile-env.am $(srcdir)/arch/Makefile.am $(srcdir)/auth/Makefile.am $(srcdir)/brag/Makefile.am $(srcdir)/ceph-detect-init/Makefile.am $(srcdir)/crush/Makefile.am $(srcdir)/kv/Makefile.am $(srcdir)/mon/Makefile.am $(srcdir)/mds/Makefile.am $(srcdir)/mds/Makefile-client.am $(srcdir)/mds/Makefile-server.am $(srcdir)/os/Makefile.am $(srcdir)/osd/Makefile.am $(srcdir)/erasure-code/Makefile.am $(srcdir)/erasure-code/jerasure/Makefile.am $(srcdir)/erasure-code/lrc/Makefile.am $(srcd [...]
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@@ -11188,79 +11549,148 @@ libmon.a: $(libmon_a_OBJECTS) $(libmon_a_DEPENDENCIES) $(EXTRA_libmon_a_DEPENDEN
 	$(AM_V_at)-rm -f libmon.a
 	$(AM_V_AR)$(libmon_a_AR) libmon.a $(libmon_a_OBJECTS) $(libmon_a_LIBADD)
 	$(AM_V_at)$(RANLIB) libmon.a
-os/$(am__dirstamp):
-	@$(MKDIR_P) os
-	@: > os/$(am__dirstamp)
-os/$(DEPDIR)/$(am__dirstamp):
-	@$(MKDIR_P) os/$(DEPDIR)
-	@: > os/$(DEPDIR)/$(am__dirstamp)
-os/chain_xattr.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
+os/filestore/$(am__dirstamp):
+	@$(MKDIR_P) os/filestore
+	@: > os/filestore/$(am__dirstamp)
+os/filestore/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) os/filestore/$(DEPDIR)
+	@: > os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-chain_xattr.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-DBObjectMap.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-FileJournal.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-FileStore.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-GenericFileStoreBackend.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-HashIndex.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-IndexManager.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-JournalingObjectStore.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-LFNIndex.$(OBJEXT): os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-WBThrottle.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
 os/fs/$(am__dirstamp):
 	@$(MKDIR_P) os/fs
 	@: > os/fs/$(am__dirstamp)
 os/fs/$(DEPDIR)/$(am__dirstamp):
 	@$(MKDIR_P) os/fs/$(DEPDIR)
 	@: > os/fs/$(DEPDIR)/$(am__dirstamp)
-os/fs/FS.$(OBJEXT): os/fs/$(am__dirstamp) \
+os/fs/libos_a-FS.$(OBJEXT): os/fs/$(am__dirstamp) \
 	os/fs/$(DEPDIR)/$(am__dirstamp)
-os/DBObjectMap.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/GenericObjectMap.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/FileJournal.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/FileStore.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/GenericFileStoreBackend.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/HashIndex.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/IndexManager.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/JournalingObjectStore.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/LFNIndex.$(OBJEXT): os/$(am__dirstamp) os/$(DEPDIR)/$(am__dirstamp)
-os/MemStore.$(OBJEXT): os/$(am__dirstamp) os/$(DEPDIR)/$(am__dirstamp)
-os/KeyValueStore.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/ObjectStore.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/WBThrottle.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/BtrfsFileStoreBackend.$(OBJEXT): os/$(am__dirstamp) \
+os/keyvaluestore/$(am__dirstamp):
+	@$(MKDIR_P) os/keyvaluestore
+	@: > os/keyvaluestore/$(am__dirstamp)
+os/keyvaluestore/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) os/keyvaluestore/$(DEPDIR)
+	@: > os/keyvaluestore/$(DEPDIR)/$(am__dirstamp)
+os/keyvaluestore/libos_a-GenericObjectMap.$(OBJEXT):  \
+	os/keyvaluestore/$(am__dirstamp) \
+	os/keyvaluestore/$(DEPDIR)/$(am__dirstamp)
+os/keyvaluestore/libos_a-KeyValueStore.$(OBJEXT):  \
+	os/keyvaluestore/$(am__dirstamp) \
+	os/keyvaluestore/$(DEPDIR)/$(am__dirstamp)
+os/kstore/$(am__dirstamp):
+	@$(MKDIR_P) os/kstore
+	@: > os/kstore/$(am__dirstamp)
+os/kstore/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) os/kstore/$(DEPDIR)
+	@: > os/kstore/$(DEPDIR)/$(am__dirstamp)
+os/kstore/libos_a-kv.$(OBJEXT): os/kstore/$(am__dirstamp) \
+	os/kstore/$(DEPDIR)/$(am__dirstamp)
+os/kstore/libos_a-KStore.$(OBJEXT): os/kstore/$(am__dirstamp) \
+	os/kstore/$(DEPDIR)/$(am__dirstamp)
+os/memstore/$(am__dirstamp):
+	@$(MKDIR_P) os/memstore
+	@: > os/memstore/$(am__dirstamp)
+os/memstore/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) os/memstore/$(DEPDIR)
+	@: > os/memstore/$(DEPDIR)/$(am__dirstamp)
+os/memstore/libos_a-MemStore.$(OBJEXT): os/memstore/$(am__dirstamp) \
+	os/memstore/$(DEPDIR)/$(am__dirstamp)
+os/$(am__dirstamp):
+	@$(MKDIR_P) os
+	@: > os/$(am__dirstamp)
+os/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) os/$(DEPDIR)
+	@: > os/$(DEPDIR)/$(am__dirstamp)
+os/libos_a-ObjectStore.$(OBJEXT): os/$(am__dirstamp) \
 	os/$(DEPDIR)/$(am__dirstamp)
-os/newstore/$(am__dirstamp):
-	@$(MKDIR_P) os/newstore
-	@: > os/newstore/$(am__dirstamp)
-os/newstore/$(DEPDIR)/$(am__dirstamp):
-	@$(MKDIR_P) os/newstore/$(DEPDIR)
-	@: > os/newstore/$(DEPDIR)/$(am__dirstamp)
-os/newstore/NewStore.$(OBJEXT): os/newstore/$(am__dirstamp) \
-	os/newstore/$(DEPDIR)/$(am__dirstamp)
-os/fs/XFS.$(OBJEXT): os/fs/$(am__dirstamp) \
+os/bluestore/$(am__dirstamp):
+	@$(MKDIR_P) os/bluestore
+	@: > os/bluestore/$(am__dirstamp)
+os/bluestore/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) os/bluestore/$(DEPDIR)
+	@: > os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-kv.$(OBJEXT): os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-Allocator.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-BlockDevice.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-BlueFS.$(OBJEXT): os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-BlueRocksEnv.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-BlueStore.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-FreelistManager.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_a-StupidAllocator.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-BtrfsFileStoreBackend.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-XfsFileStoreBackend.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
+os/fs/libos_a-XFS.$(OBJEXT): os/fs/$(am__dirstamp) \
 	os/fs/$(DEPDIR)/$(am__dirstamp)
-os/XfsFileStoreBackend.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
-os/ZFSFileStoreBackend.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
+os/filestore/libos_a-ZFSFileStoreBackend.$(OBJEXT):  \
+	os/filestore/$(am__dirstamp) \
+	os/filestore/$(DEPDIR)/$(am__dirstamp)
 
 libos.a: $(libos_a_OBJECTS) $(libos_a_DEPENDENCIES) $(EXTRA_libos_a_DEPENDENCIES) 
 	$(AM_V_at)-rm -f libos.a
 	$(AM_V_AR)$(libos_a_AR) libos.a $(libos_a_OBJECTS) $(libos_a_LIBADD)
 	$(AM_V_at)$(RANLIB) libos.a
+os/kstore/libos_types_a-kstore_types.$(OBJEXT):  \
+	os/kstore/$(am__dirstamp) os/kstore/$(DEPDIR)/$(am__dirstamp)
 os/libos_types_a-Transaction.$(OBJEXT): os/$(am__dirstamp) \
 	os/$(DEPDIR)/$(am__dirstamp)
-os/newstore/libos_types_a-newstore_types.$(OBJEXT):  \
-	os/newstore/$(am__dirstamp) \
-	os/newstore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_types_a-bluestore_types.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+os/bluestore/libos_types_a-bluefs_types.$(OBJEXT):  \
+	os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
 
 libos_types.a: $(libos_types_a_OBJECTS) $(libos_types_a_DEPENDENCIES) $(EXTRA_libos_types_a_DEPENDENCIES) 
 	$(AM_V_at)-rm -f libos_types.a
 	$(AM_V_AR)$(libos_types_a_AR) libos_types.a $(libos_types_a_OBJECTS) $(libos_types_a_LIBADD)
 	$(AM_V_at)$(RANLIB) libos_types.a
-os/libos_zfs_a-ZFS.$(OBJEXT): os/$(am__dirstamp) \
-	os/$(DEPDIR)/$(am__dirstamp)
+os/fs/libos_zfs_a-ZFS.$(OBJEXT): os/fs/$(am__dirstamp) \
+	os/fs/$(DEPDIR)/$(am__dirstamp)
 
 libos_zfs.a: $(libos_zfs_a_OBJECTS) $(libos_zfs_a_DEPENDENCIES) $(EXTRA_libos_zfs_a_DEPENDENCIES) 
 	$(AM_V_at)-rm -f libos_zfs.a
@@ -11314,6 +11744,41 @@ libosd.a: $(libosd_a_OBJECTS) $(libosd_a_DEPENDENCIES) $(EXTRA_libosd_a_DEPENDEN
 	$(AM_V_AR)$(libosd_a_AR) libosd.a $(libosd_a_OBJECTS) $(libosd_a_LIBADD)
 	$(AM_V_at)$(RANLIB) libosd.a
 
+install-compressorlibLTLIBRARIES: $(compressorlib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(compressorlib_LTLIBRARIES)'; test -n "$(compressorlibdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(compressorlibdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(compressorlibdir)" || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(compressorlibdir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(compressorlibdir)"; \
+	}
+
+uninstall-compressorlibLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(compressorlib_LTLIBRARIES)'; test -n "$(compressorlibdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(compressorlibdir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(compressorlibdir)/$$f"; \
+	done
+
+clean-compressorlibLTLIBRARIES:
+	-test -z "$(compressorlib_LTLIBRARIES)" || rm -f $(compressorlib_LTLIBRARIES)
+	@list='$(compressorlib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 install-erasure_codelibLTLIBRARIES: $(erasure_codelib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	@list='$(erasure_codelib_LTLIBRARIES)'; test -n "$(erasure_codelibdir)" || list=; \
@@ -11499,6 +11964,42 @@ auth/RotatingKeyRing.lo: auth/$(am__dirstamp) \
 
 libauth.la: $(libauth_la_OBJECTS) $(libauth_la_DEPENDENCIES) $(EXTRA_libauth_la_DEPENDENCIES) 
 	$(AM_V_CXXLD)$(CXXLINK)  $(libauth_la_OBJECTS) $(libauth_la_LIBADD) $(LIBS)
+compressor/$(am__dirstamp):
+	@$(MKDIR_P) compressor
+	@: > compressor/$(am__dirstamp)
+compressor/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) compressor/$(DEPDIR)
+	@: > compressor/$(DEPDIR)/$(am__dirstamp)
+compressor/libceph_example_la-Compressor.lo:  \
+	compressor/$(am__dirstamp) \
+	compressor/$(DEPDIR)/$(am__dirstamp)
+test/compressor/$(am__dirstamp):
+	@$(MKDIR_P) test/compressor
+	@: > test/compressor/$(am__dirstamp)
+test/compressor/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) test/compressor/$(DEPDIR)
+	@: > test/compressor/$(DEPDIR)/$(am__dirstamp)
+test/compressor/libceph_example_la-compressor_plugin_example.lo:  \
+	test/compressor/$(am__dirstamp) \
+	test/compressor/$(DEPDIR)/$(am__dirstamp)
+
+libceph_example.la: $(libceph_example_la_OBJECTS) $(libceph_example_la_DEPENDENCIES) $(EXTRA_libceph_example_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libceph_example_la_LINK) $(am_libceph_example_la_rpath) $(libceph_example_la_OBJECTS) $(libceph_example_la_LIBADD) $(LIBS)
+compressor/libceph_snappy_la-Compressor.lo:  \
+	compressor/$(am__dirstamp) \
+	compressor/$(DEPDIR)/$(am__dirstamp)
+compressor/snappy/$(am__dirstamp):
+	@$(MKDIR_P) compressor/snappy
+	@: > compressor/snappy/$(am__dirstamp)
+compressor/snappy/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) compressor/snappy/$(DEPDIR)
+	@: > compressor/snappy/$(DEPDIR)/$(am__dirstamp)
+compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo:  \
+	compressor/snappy/$(am__dirstamp) \
+	compressor/snappy/$(DEPDIR)/$(am__dirstamp)
+
+libceph_snappy.la: $(libceph_snappy_la_OBJECTS) $(libceph_snappy_la_DEPENDENCIES) $(EXTRA_libceph_snappy_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libceph_snappy_la_LINK) -rpath $(compressorlibdir) $(libceph_snappy_la_OBJECTS) $(libceph_snappy_la_LIBADD) $(LIBS)
 
 libcephfs.la: $(libcephfs_la_OBJECTS) $(libcephfs_la_DEPENDENCIES) $(EXTRA_libcephfs_la_DEPENDENCIES) 
 	$(AM_V_CXXLD)$(libcephfs_la_LINK) $(am_libcephfs_la_rpath) $(libcephfs_la_OBJECTS) $(libcephfs_la_LIBADD) $(LIBS)
@@ -11558,6 +12059,8 @@ client/MetaSession.lo: client/$(am__dirstamp) \
 	client/$(DEPDIR)/$(am__dirstamp)
 client/Trace.lo: client/$(am__dirstamp) \
 	client/$(DEPDIR)/$(am__dirstamp)
+client/posix_acl.lo: client/$(am__dirstamp) \
+	client/$(DEPDIR)/$(am__dirstamp)
 
 libclient.la: $(libclient_la_OBJECTS) $(libclient_la_DEPENDENCIES) $(EXTRA_libclient_la_DEPENDENCIES) 
 	$(AM_V_CXXLD)$(CXXLINK) $(am_libclient_la_rpath) $(libclient_la_OBJECTS) $(libclient_la_LIBADD) $(LIBS)
@@ -11805,6 +12308,8 @@ common/escape.lo: common/$(am__dirstamp) \
 	common/$(DEPDIR)/$(am__dirstamp)
 common/io_priority.lo: common/$(am__dirstamp) \
 	common/$(DEPDIR)/$(am__dirstamp)
+common/ceph_time.lo: common/$(am__dirstamp) \
+	common/$(DEPDIR)/$(am__dirstamp)
 common/Clock.lo: common/$(am__dirstamp) \
 	common/$(DEPDIR)/$(am__dirstamp)
 common/Throttle.lo: common/$(am__dirstamp) \
@@ -11954,12 +12459,6 @@ mds/flock.lo: mds/$(am__dirstamp) mds/$(DEPDIR)/$(am__dirstamp)
 
 libcommon_internal.la: $(libcommon_internal_la_OBJECTS) $(libcommon_internal_la_DEPENDENCIES) $(EXTRA_libcommon_internal_la_DEPENDENCIES) 
 	$(AM_V_CXXLD)$(CXXLINK)  $(libcommon_internal_la_OBJECTS) $(libcommon_internal_la_LIBADD) $(LIBS)
-compressor/$(am__dirstamp):
-	@$(MKDIR_P) compressor
-	@: > compressor/$(am__dirstamp)
-compressor/$(DEPDIR)/$(am__dirstamp):
-	@$(MKDIR_P) compressor/$(DEPDIR)
-	@: > compressor/$(DEPDIR)/$(am__dirstamp)
 compressor/Compressor.lo: compressor/$(am__dirstamp) \
 	compressor/$(DEPDIR)/$(am__dirstamp)
 compressor/AsyncCompressor.lo: compressor/$(am__dirstamp) \
@@ -13243,14 +13742,14 @@ librbd/internal.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
 librbd/Journal.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
-librbd/JournalReplay.lo: librbd/$(am__dirstamp) \
-	librbd/$(DEPDIR)/$(am__dirstamp)
 librbd/LibrbdAdminSocketHook.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
 librbd/LibrbdWriteback.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
 librbd/ObjectMap.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
+librbd/Operations.lo: librbd/$(am__dirstamp) \
+	librbd/$(DEPDIR)/$(am__dirstamp)
 librbd/Utils.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
 librbd/exclusive_lock/$(am__dirstamp):
@@ -13281,6 +13780,14 @@ librbd/image/RefreshRequest.lo: librbd/image/$(am__dirstamp) \
 	librbd/image/$(DEPDIR)/$(am__dirstamp)
 librbd/image/SetSnapRequest.lo: librbd/image/$(am__dirstamp) \
 	librbd/image/$(DEPDIR)/$(am__dirstamp)
+librbd/journal/$(am__dirstamp):
+	@$(MKDIR_P) librbd/journal
+	@: > librbd/journal/$(am__dirstamp)
+librbd/journal/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) librbd/journal/$(DEPDIR)
+	@: > librbd/journal/$(DEPDIR)/$(am__dirstamp)
+librbd/journal/Replay.lo: librbd/journal/$(am__dirstamp) \
+	librbd/journal/$(DEPDIR)/$(am__dirstamp)
 librbd/object_map/$(am__dirstamp):
 	@$(MKDIR_P) librbd/object_map
 	@: > librbd/object_map/$(am__dirstamp)
@@ -13404,15 +13911,21 @@ test/librbd/librbd_test_la-test_ImageWatcher.lo:  \
 test/librbd/librbd_test_la-test_internal.lo:  \
 	test/librbd/$(am__dirstamp) \
 	test/librbd/$(DEPDIR)/$(am__dirstamp)
-test/librbd/librbd_test_la-test_JournalEntries.lo:  \
-	test/librbd/$(am__dirstamp) \
-	test/librbd/$(DEPDIR)/$(am__dirstamp)
-test/librbd/librbd_test_la-test_JournalReplay.lo:  \
-	test/librbd/$(am__dirstamp) \
-	test/librbd/$(DEPDIR)/$(am__dirstamp)
 test/librbd/librbd_test_la-test_ObjectMap.lo:  \
 	test/librbd/$(am__dirstamp) \
 	test/librbd/$(DEPDIR)/$(am__dirstamp)
+test/librbd/journal/$(am__dirstamp):
+	@$(MKDIR_P) test/librbd/journal
+	@: > test/librbd/journal/$(am__dirstamp)
+test/librbd/journal/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) test/librbd/journal/$(DEPDIR)
+	@: > test/librbd/journal/$(DEPDIR)/$(am__dirstamp)
+test/librbd/journal/librbd_test_la-test_Entries.lo:  \
+	test/librbd/journal/$(am__dirstamp) \
+	test/librbd/journal/$(DEPDIR)/$(am__dirstamp)
+test/librbd/journal/librbd_test_la-test_Replay.lo:  \
+	test/librbd/journal/$(am__dirstamp) \
+	test/librbd/journal/$(DEPDIR)/$(am__dirstamp)
 
 librbd_test.la: $(librbd_test_la_OBJECTS) $(librbd_test_la_DEPENDENCIES) $(EXTRA_librbd_test_la_DEPENDENCIES) 
 	$(AM_V_CXXLD)$(librbd_test_la_LINK) $(am_librbd_test_la_rpath) $(librbd_test_la_OBJECTS) $(librbd_test_la_LIBADD) $(LIBS)
@@ -13421,8 +13934,8 @@ tracing/librbd_tp_la-librbd.lo: tracing/$(am__dirstamp) \
 
 librbd_tp.la: $(librbd_tp_la_OBJECTS) $(librbd_tp_la_DEPENDENCIES) $(EXTRA_librbd_tp_la_DEPENDENCIES) 
 	$(AM_V_CCLD)$(librbd_tp_la_LINK) $(am_librbd_tp_la_rpath) $(librbd_tp_la_OBJECTS) $(librbd_tp_la_LIBADD) $(LIBS)
-librbd/JournalTypes.lo: librbd/$(am__dirstamp) \
-	librbd/$(DEPDIR)/$(am__dirstamp)
+librbd/journal/Entries.lo: librbd/journal/$(am__dirstamp) \
+	librbd/journal/$(DEPDIR)/$(am__dirstamp)
 librbd/WatchNotifyTypes.lo: librbd/$(am__dirstamp) \
 	librbd/$(DEPDIR)/$(am__dirstamp)
 
@@ -13700,6 +14213,12 @@ tools/ceph_authtool.$(OBJEXT): tools/$(am__dirstamp) \
 ceph-authtool$(EXEEXT): $(ceph_authtool_OBJECTS) $(ceph_authtool_DEPENDENCIES) $(EXTRA_ceph_authtool_DEPENDENCIES) 
 	@rm -f ceph-authtool$(EXEEXT)
 	$(AM_V_CXXLD)$(CXXLINK) $(ceph_authtool_OBJECTS) $(ceph_authtool_LDADD) $(LIBS)
+os/bluestore/bluefs_tool.$(OBJEXT): os/bluestore/$(am__dirstamp) \
+	os/bluestore/$(DEPDIR)/$(am__dirstamp)
+
+ceph-bluefs-tool$(EXEEXT): $(ceph_bluefs_tool_OBJECTS) $(ceph_bluefs_tool_DEPENDENCIES) $(EXTRA_ceph_bluefs_tool_DEPENDENCIES) 
+	@rm -f ceph-bluefs-tool$(EXEEXT)
+	$(AM_V_CXXLD)$(CXXLINK) $(ceph_bluefs_tool_OBJECTS) $(ceph_bluefs_tool_LDADD) $(LIBS)
 tools/ceph-client-debug.$(OBJEXT): tools/$(am__dirstamp) \
 	tools/$(DEPDIR)/$(am__dirstamp)
 
@@ -14040,12 +14559,6 @@ test/bench/rbd_backend.$(OBJEXT): test/bench/$(am__dirstamp) \
 ceph_smalliobenchrbd$(EXEEXT): $(ceph_smalliobenchrbd_OBJECTS) $(ceph_smalliobenchrbd_DEPENDENCIES) $(EXTRA_ceph_smalliobenchrbd_DEPENDENCIES) 
 	@rm -f ceph_smalliobenchrbd$(EXEEXT)
 	$(AM_V_CXXLD)$(CXXLINK) $(ceph_smalliobenchrbd_OBJECTS) $(ceph_smalliobenchrbd_LDADD) $(LIBS)
-test/streamtest.$(OBJEXT): test/$(am__dirstamp) \
-	test/$(DEPDIR)/$(am__dirstamp)
-
-ceph_streamtest$(EXEEXT): $(ceph_streamtest_OBJECTS) $(ceph_streamtest_DEPENDENCIES) $(EXTRA_ceph_streamtest_DEPENDENCIES) 
-	@rm -f ceph_streamtest$(EXEEXT)
-	$(AM_V_CXXLD)$(CXXLINK) $(ceph_streamtest_OBJECTS) $(ceph_streamtest_LDADD) $(LIBS)
 test/msgr/ceph_test_async_driver-test_async_driver.$(OBJEXT):  \
 	test/msgr/$(am__dirstamp) test/msgr/$(DEPDIR)/$(am__dirstamp)
 
@@ -14359,6 +14872,9 @@ test/libcephfs/ceph_test_libcephfs-multiclient.$(OBJEXT):  \
 test/libcephfs/ceph_test_libcephfs-access.$(OBJEXT):  \
 	test/libcephfs/$(am__dirstamp) \
 	test/libcephfs/$(DEPDIR)/$(am__dirstamp)
+test/libcephfs/ceph_test_libcephfs-acl.$(OBJEXT):  \
+	test/libcephfs/$(am__dirstamp) \
+	test/libcephfs/$(DEPDIR)/$(am__dirstamp)
 test/libcephfs/ceph_test_libcephfs-flock.$(OBJEXT):  \
 	test/libcephfs/$(am__dirstamp) \
 	test/libcephfs/$(DEPDIR)/$(am__dirstamp)
@@ -15198,6 +15714,20 @@ test/common/unittest_bloom_filter-test_bloom_filter.$(OBJEXT):  \
 unittest_bloom_filter$(EXEEXT): $(unittest_bloom_filter_OBJECTS) $(unittest_bloom_filter_DEPENDENCIES) $(EXTRA_unittest_bloom_filter_DEPENDENCIES) 
 	@rm -f unittest_bloom_filter$(EXEEXT)
 	$(AM_V_CXXLD)$(unittest_bloom_filter_LINK) $(unittest_bloom_filter_OBJECTS) $(unittest_bloom_filter_LDADD) $(LIBS)
+test/objectstore/unittest_bluefs-test_bluefs.$(OBJEXT):  \
+	test/objectstore/$(am__dirstamp) \
+	test/objectstore/$(DEPDIR)/$(am__dirstamp)
+
+unittest_bluefs$(EXEEXT): $(unittest_bluefs_OBJECTS) $(unittest_bluefs_DEPENDENCIES) $(EXTRA_unittest_bluefs_DEPENDENCIES) 
+	@rm -f unittest_bluefs$(EXEEXT)
+	$(AM_V_CXXLD)$(unittest_bluefs_LINK) $(unittest_bluefs_OBJECTS) $(unittest_bluefs_LDADD) $(LIBS)
+test/objectstore/unittest_bluestore_types-test_bluestore_types.$(OBJEXT):  \
+	test/objectstore/$(am__dirstamp) \
+	test/objectstore/$(DEPDIR)/$(am__dirstamp)
+
+unittest_bluestore_types$(EXEEXT): $(unittest_bluestore_types_OBJECTS) $(unittest_bluestore_types_DEPENDENCIES) $(EXTRA_unittest_bluestore_types_DEPENDENCIES) 
+	@rm -f unittest_bluestore_types$(EXEEXT)
+	$(AM_V_CXXLD)$(unittest_bluestore_types_LINK) $(unittest_bluestore_types_OBJECTS) $(unittest_bluestore_types_LDADD) $(LIBS)
 test/unittest_bufferlist-bufferlist.$(OBJEXT): test/$(am__dirstamp) \
 	test/$(DEPDIR)/$(am__dirstamp)
 
@@ -15229,6 +15759,42 @@ test/objectstore/unittest_chain_xattr-chain_xattr.$(OBJEXT):  \
 unittest_chain_xattr$(EXEEXT): $(unittest_chain_xattr_OBJECTS) $(unittest_chain_xattr_DEPENDENCIES) $(EXTRA_unittest_chain_xattr_DEPENDENCIES) 
 	@rm -f unittest_chain_xattr$(EXEEXT)
 	$(AM_V_CXXLD)$(unittest_chain_xattr_LINK) $(unittest_chain_xattr_OBJECTS) $(unittest_chain_xattr_LDADD) $(LIBS)
+compressor/unittest_compression_plugin-Compressor.$(OBJEXT):  \
+	compressor/$(am__dirstamp) \
+	compressor/$(DEPDIR)/$(am__dirstamp)
+test/compressor/unittest_compression_plugin-test_compression_plugin.$(OBJEXT):  \
+	test/compressor/$(am__dirstamp) \
+	test/compressor/$(DEPDIR)/$(am__dirstamp)
+
+unittest_compression_plugin$(EXEEXT): $(unittest_compression_plugin_OBJECTS) $(unittest_compression_plugin_DEPENDENCIES) $(EXTRA_unittest_compression_plugin_DEPENDENCIES) 
+	@rm -f unittest_compression_plugin$(EXEEXT)
+	$(AM_V_CXXLD)$(unittest_compression_plugin_LINK) $(unittest_compression_plugin_OBJECTS) $(unittest_compression_plugin_LDADD) $(LIBS)
+test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.$(OBJEXT):  \
+	test/compressor/$(am__dirstamp) \
+	test/compressor/$(DEPDIR)/$(am__dirstamp)
+compressor/unittest_compression_plugin_snappy-Compressor.$(OBJEXT):  \
+	compressor/$(am__dirstamp) \
+	compressor/$(DEPDIR)/$(am__dirstamp)
+compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.$(OBJEXT):  \
+	compressor/snappy/$(am__dirstamp) \
+	compressor/snappy/$(DEPDIR)/$(am__dirstamp)
+
+unittest_compression_plugin_snappy$(EXEEXT): $(unittest_compression_plugin_snappy_OBJECTS) $(unittest_compression_plugin_snappy_DEPENDENCIES) $(EXTRA_unittest_compression_plugin_snappy_DEPENDENCIES) 
+	@rm -f unittest_compression_plugin_snappy$(EXEEXT)
+	$(AM_V_CXXLD)$(unittest_compression_plugin_snappy_LINK) $(unittest_compression_plugin_snappy_OBJECTS) $(unittest_compression_plugin_snappy_LDADD) $(LIBS)
+test/compressor/unittest_compression_snappy-test_compression_snappy.$(OBJEXT):  \
+	test/compressor/$(am__dirstamp) \
+	test/compressor/$(DEPDIR)/$(am__dirstamp)
+compressor/unittest_compression_snappy-Compressor.$(OBJEXT):  \
+	compressor/$(am__dirstamp) \
+	compressor/$(DEPDIR)/$(am__dirstamp)
+compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.$(OBJEXT):  \
+	compressor/snappy/$(am__dirstamp) \
+	compressor/snappy/$(DEPDIR)/$(am__dirstamp)
+
+unittest_compression_snappy$(EXEEXT): $(unittest_compression_snappy_OBJECTS) $(unittest_compression_snappy_DEPENDENCIES) $(EXTRA_unittest_compression_snappy_DEPENDENCIES) 
+	@rm -f unittest_compression_snappy$(EXEEXT)
+	$(AM_V_CXXLD)$(unittest_compression_snappy_LINK) $(unittest_compression_snappy_OBJECTS) $(unittest_compression_snappy_LDADD) $(LIBS)
 test/common/unittest_config-test_config.$(OBJEXT):  \
 	test/common/$(am__dirstamp) \
 	test/common/$(DEPDIR)/$(am__dirstamp)
@@ -15872,6 +16438,9 @@ test/librbd/unittest_librbd-test_mock_fixture.$(OBJEXT):  \
 test/librbd/unittest_librbd-test_mock_ExclusiveLock.$(OBJEXT):  \
 	test/librbd/$(am__dirstamp) \
 	test/librbd/$(DEPDIR)/$(am__dirstamp)
+test/librbd/unittest_librbd-test_mock_Journal.$(OBJEXT):  \
+	test/librbd/$(am__dirstamp) \
+	test/librbd/$(DEPDIR)/$(am__dirstamp)
 test/librbd/exclusive_lock/$(am__dirstamp):
 	@$(MKDIR_P) test/librbd/exclusive_lock
 	@: > test/librbd/exclusive_lock/$(am__dirstamp)
@@ -15884,6 +16453,9 @@ test/librbd/exclusive_lock/unittest_librbd-test_mock_AcquireRequest.$(OBJEXT):
 test/librbd/exclusive_lock/unittest_librbd-test_mock_ReleaseRequest.$(OBJEXT):  \
 	test/librbd/exclusive_lock/$(am__dirstamp) \
 	test/librbd/exclusive_lock/$(DEPDIR)/$(am__dirstamp)
+test/librbd/journal/unittest_librbd-test_mock_Replay.$(OBJEXT):  \
+	test/librbd/journal/$(am__dirstamp) \
+	test/librbd/journal/$(DEPDIR)/$(am__dirstamp)
 test/librbd/object_map/$(am__dirstamp):
 	@$(MKDIR_P) test/librbd/object_map
 	@: > test/librbd/object_map/$(am__dirstamp)
@@ -15923,6 +16495,9 @@ test/librbd/operation/$(am__dirstamp):
 test/librbd/operation/$(DEPDIR)/$(am__dirstamp):
 	@$(MKDIR_P) test/librbd/operation/$(DEPDIR)
 	@: > test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
+test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.$(OBJEXT):  \
+	test/librbd/operation/$(am__dirstamp) \
+	test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
 test/librbd/operation/unittest_librbd-test_mock_SnapshotCreateRequest.$(OBJEXT):  \
 	test/librbd/operation/$(am__dirstamp) \
 	test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
@@ -15932,6 +16507,9 @@ test/librbd/operation/unittest_librbd-test_mock_SnapshotProtectRequest.$(OBJEXT)
 test/librbd/operation/unittest_librbd-test_mock_SnapshotRemoveRequest.$(OBJEXT):  \
 	test/librbd/operation/$(am__dirstamp) \
 	test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
+test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.$(OBJEXT):  \
+	test/librbd/operation/$(am__dirstamp) \
+	test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
 test/librbd/operation/unittest_librbd-test_mock_SnapshotUnprotectRequest.$(OBJEXT):  \
 	test/librbd/operation/$(am__dirstamp) \
 	test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
@@ -16179,6 +16757,13 @@ test/common/unittest_throttle-Throttle.$(OBJEXT):  \
 unittest_throttle$(EXEEXT): $(unittest_throttle_OBJECTS) $(unittest_throttle_DEPENDENCIES) $(EXTRA_unittest_throttle_DEPENDENCIES) 
 	@rm -f unittest_throttle$(EXEEXT)
 	$(AM_V_CXXLD)$(unittest_throttle_LINK) $(unittest_throttle_OBJECTS) $(unittest_throttle_LDADD) $(LIBS)
+test/common/unittest_time-test_time.$(OBJEXT):  \
+	test/common/$(am__dirstamp) \
+	test/common/$(DEPDIR)/$(am__dirstamp)
+
+unittest_time$(EXEEXT): $(unittest_time_OBJECTS) $(unittest_time_DEPENDENCIES) $(EXTRA_unittest_time_DEPENDENCIES) 
+	@rm -f unittest_time$(EXEEXT)
+	$(AM_V_CXXLD)$(unittest_time_LINK) $(unittest_time_OBJECTS) $(unittest_time_LDADD) $(LIBS)
 test/unittest_utf8-utf8.$(OBJEXT): test/$(am__dirstamp) \
 	test/$(DEPDIR)/$(am__dirstamp)
 
@@ -16553,6 +17138,8 @@ mostlyclean-compile:
 	-rm -f common/*.lo
 	-rm -f compressor/*.$(OBJEXT)
 	-rm -f compressor/*.lo
+	-rm -f compressor/snappy/*.$(OBJEXT)
+	-rm -f compressor/snappy/*.lo
 	-rm -f crush/*.$(OBJEXT)
 	-rm -f crush/*.lo
 	-rm -f erasure-code/*.$(OBJEXT)
@@ -16594,6 +17181,8 @@ mostlyclean-compile:
 	-rm -f librbd/exclusive_lock/*.lo
 	-rm -f librbd/image/*.$(OBJEXT)
 	-rm -f librbd/image/*.lo
+	-rm -f librbd/journal/*.$(OBJEXT)
+	-rm -f librbd/journal/*.lo
 	-rm -f librbd/object_map/*.$(OBJEXT)
 	-rm -f librbd/object_map/*.lo
 	-rm -f librbd/operation/*.$(OBJEXT)
@@ -16615,8 +17204,12 @@ mostlyclean-compile:
 	-rm -f msg/xio/*.lo
 	-rm -f objclass/*.$(OBJEXT)
 	-rm -f os/*.$(OBJEXT)
+	-rm -f os/bluestore/*.$(OBJEXT)
+	-rm -f os/filestore/*.$(OBJEXT)
 	-rm -f os/fs/*.$(OBJEXT)
-	-rm -f os/newstore/*.$(OBJEXT)
+	-rm -f os/keyvaluestore/*.$(OBJEXT)
+	-rm -f os/kstore/*.$(OBJEXT)
+	-rm -f os/memstore/*.$(OBJEXT)
 	-rm -f osd/*.$(OBJEXT)
 	-rm -f osd/*.lo
 	-rm -f osdc/*.$(OBJEXT)
@@ -16643,6 +17236,8 @@ mostlyclean-compile:
 	-rm -f test/cls_statelog/*.$(OBJEXT)
 	-rm -f test/cls_version/*.$(OBJEXT)
 	-rm -f test/common/*.$(OBJEXT)
+	-rm -f test/compressor/*.$(OBJEXT)
+	-rm -f test/compressor/*.lo
 	-rm -f test/crush/*.$(OBJEXT)
 	-rm -f test/encoding/*.$(OBJEXT)
 	-rm -f test/erasure-code/*.$(OBJEXT)
@@ -16660,6 +17255,8 @@ mostlyclean-compile:
 	-rm -f test/librbd/*.$(OBJEXT)
 	-rm -f test/librbd/*.lo
 	-rm -f test/librbd/exclusive_lock/*.$(OBJEXT)
+	-rm -f test/librbd/journal/*.$(OBJEXT)
+	-rm -f test/librbd/journal/*.lo
 	-rm -f test/librbd/object_map/*.$(OBJEXT)
 	-rm -f test/librbd/operation/*.$(OBJEXT)
 	-rm -f test/mds/*.$(OBJEXT)
@@ -16724,6 +17321,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at client/$(DEPDIR)/SyntheticClient.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at client/$(DEPDIR)/Trace.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at client/$(DEPDIR)/libclient_fuse_la-fuse_ll.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at client/$(DEPDIR)/posix_acl.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at client/$(DEPDIR)/test_ioctls.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at cls/cephfs/$(DEPDIR)/cls_cephfs.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at cls/cephfs/$(DEPDIR)/cls_cephfs_client.Plo at am__quote@
@@ -16809,6 +17407,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/ceph_hash.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/ceph_json.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/ceph_strings.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/ceph_time.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/cmdparse.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/code_environment.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/common_init.Plo at am__quote@
@@ -16861,6 +17460,14 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/xattr.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/AsyncCompressor.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/Compressor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/libceph_example_la-Compressor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/libceph_snappy_la-Compressor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/snappy/$(DEPDIR)/libceph_snappy_la-CompressionPluginSnappy.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at crush/$(DEPDIR)/CrushCompiler.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at crush/$(DEPDIR)/CrushTester.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at crush/$(DEPDIR)/CrushWrapper.Plo at am__quote@
@@ -17214,11 +17821,10 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/ImageState.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/ImageWatcher.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/Journal.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/JournalReplay.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/JournalTypes.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/LibrbdAdminSocketHook.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/LibrbdWriteback.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/ObjectMap.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/Operations.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/Utils.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/WatchNotifyTypes.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/$(DEPDIR)/internal.Plo at am__quote@
@@ -17231,6 +17837,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/image/$(DEPDIR)/RefreshParentRequest.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/image/$(DEPDIR)/RefreshRequest.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/image/$(DEPDIR)/SetSnapRequest.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at librbd/journal/$(DEPDIR)/Entries.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at librbd/journal/$(DEPDIR)/Replay.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/object_map/$(DEPDIR)/InvalidateRequest.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/object_map/$(DEPDIR)/LockRequest.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at librbd/object_map/$(DEPDIR)/RefreshRequest.Plo at am__quote@
@@ -17364,29 +17972,41 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at msg/xio/$(DEPDIR)/XioPool.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at msg/xio/$(DEPDIR)/XioPortal.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at objclass/$(DEPDIR)/libosd_a-class_api.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/BtrfsFileStoreBackend.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/DBObjectMap.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/FileJournal.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/FileStore.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/GenericFileStoreBackend.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/GenericObjectMap.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/HashIndex.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/IndexManager.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/JournalingObjectStore.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/KeyValueStore.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/LFNIndex.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/MemStore.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/ObjectStore.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/WBThrottle.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/XfsFileStoreBackend.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/ZFSFileStoreBackend.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/chain_xattr.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/libos_a-ObjectStore.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/libos_types_a-Transaction.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/$(DEPDIR)/libos_zfs_a-ZFS.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/fs/$(DEPDIR)/FS.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/fs/$(DEPDIR)/XFS.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/newstore/$(DEPDIR)/NewStore.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/bluefs_tool.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-Allocator.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-BlueFS.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-BlueStore.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_a-kv.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-FileJournal.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-FileStore.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-HashIndex.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-IndexManager.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-LFNIndex.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-WBThrottle.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/filestore/$(DEPDIR)/libos_a-chain_xattr.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/fs/$(DEPDIR)/libos_a-FS.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/fs/$(DEPDIR)/libos_a-XFS.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/kstore/$(DEPDIR)/libos_a-KStore.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/kstore/$(DEPDIR)/libos_a-kv.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at os/memstore/$(DEPDIR)/libos_a-MemStore.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at osd/$(DEPDIR)/ECMsgTypes.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at osd/$(DEPDIR)/HitSet.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at osd/$(DEPDIR)/OSDMap.Plo at am__quote@
@@ -17562,7 +18182,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/objectstore_bench.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/omap_bench.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/on_exit.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/streamtest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/test_build_libcephfs-buildtest_skeleton.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/test_build_libcommon-buildtest_skeleton.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/$(DEPDIR)/test_build_librados-buildtest_skeleton.Po at am__quote@
@@ -17657,7 +18276,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/common/$(DEPDIR)/unittest_str_map-test_str_map.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/common/$(DEPDIR)/unittest_tableformatter-test_tableformatter.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/common/$(DEPDIR)/unittest_throttle-Throttle.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/common/$(DEPDIR)/unittest_time-test_time.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/common/$(DEPDIR)/unittest_util-test_util.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/compressor/$(DEPDIR)/libceph_example_la-compressor_plugin_example.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/crush/$(DEPDIR)/unittest_crush-crush.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/crush/$(DEPDIR)/unittest_crush_wrapper-CrushWrapper.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/encoding/$(DEPDIR)/ceph_dencoder-ceph_dencoder.Po at am__quote@
@@ -17706,6 +18330,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/journal/$(DEPDIR)/unittest_journal-test_ObjectRecorder.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/journal/$(DEPDIR)/unittest_journal-test_main.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-access.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-caps.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-flock.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-multiclient.Po at am__quote@
@@ -17747,8 +18372,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/ceph_test_librbd_api-test_support.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/ceph_test_librbd_fsx-fsx.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_ImageWatcher.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_JournalEntries.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_JournalReplay.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_ObjectMap.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_fixture.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_internal.Plo at am__quote@
@@ -17756,9 +18379,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/librbd_test_la-test_support.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/unittest_librbd-test_main.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/unittest_librbd-test_mock_ExclusiveLock.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/$(DEPDIR)/unittest_librbd-test_mock_fixture.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/exclusive_lock/$(DEPDIR)/unittest_librbd-test_mock_AcquireRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/exclusive_lock/$(DEPDIR)/unittest_librbd-test_mock_ReleaseRequest.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Entries.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Replay.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_InvalidateRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_LockRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_RefreshRequest.Po at am__quote@
@@ -17768,9 +18395,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_UnlockRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_UpdateRequest.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotCreateRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotProtectRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRemoveRequest.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotUnprotectRequest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/mds/$(DEPDIR)/unittest_mds_authcap-TestMDSAuthCaps.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/messenger/$(DEPDIR)/simple_client-simple_client.Po at am__quote@
@@ -17798,6 +18427,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/ceph_test_objectstore-store_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/test_idempotent.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/test_idempotent_sequence.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/unittest_chain_xattr-chain_xattr.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/unittest_rocksdb_option-TestRocksdbOptionParse.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at test/objectstore/$(DEPDIR)/unittest_rocksdb_option_static-TestRocksdbOptionParse.Po at am__quote@
@@ -20335,6 +20966,426 @@ kv/libkv_a-KineticStore.obj: kv/KineticStore.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libkv_a_CXXFLAGS) $(CXXFLAGS) -c -o kv/libkv_a-KineticStore.obj `if test -f 'kv/KineticStore.cc'; then $(CYGPATH_W) 'kv/KineticStore.cc'; else $(CYGPATH_W) '$(srcdir)/kv/KineticStore.cc'; fi`
 
+os/filestore/libos_a-chain_xattr.o: os/filestore/chain_xattr.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-chain_xattr.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-chain_xattr.Tpo -c -o os/filestore/libos_a-chain_xattr.o `test -f 'os/filestore/chain_xattr.cc' || echo '$(srcdir)/'`os/filestore/chain_xattr.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-chain_xattr.Tpo os/filestore/$(DEPDIR)/libos_a-chain_xattr.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/chain_xattr.cc' object='os/filestore/libos_a-chain_xattr.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-chain_xattr.o `test -f 'os/filestore/chain_xattr.cc' || echo '$(srcdir)/'`os/filestore/chain_xattr.cc
+
+os/filestore/libos_a-chain_xattr.obj: os/filestore/chain_xattr.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-chain_xattr.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-chain_xattr.Tpo -c -o os/filestore/libos_a-chain_xattr.obj `if test -f 'os/filestore/chain_xattr.cc'; then $(CYGPATH_W) 'os/filestore/chain_xattr.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/chain_xattr.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-chain_xattr.Tpo os/filestore/$(DEPDIR)/libos_a-chain_xattr.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/chain_xattr.cc' object='os/filestore/libos_a-chain_xattr.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-chain_xattr.obj `if test -f 'os/filestore/chain_xattr.cc'; then $(CYGPATH_W) 'os/filestore/chain_xattr.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/chain_xattr.cc'; fi`
+
+os/filestore/libos_a-DBObjectMap.o: os/filestore/DBObjectMap.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-DBObjectMap.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Tpo -c -o os/filestore/libos_a-DBObjectMap.o `test -f 'os/filestore/DBObjectMap.cc' || echo '$(srcdir)/'`os/filestore/DBObjectMap.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Tpo os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/DBObjectMap.cc' object='os/filestore/libos_a-DBObjectMap.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-DBObjectMap.o `test -f 'os/filestore/DBObjectMap.cc' || echo '$(srcdir)/'`os/filestore/DBObjectMap.cc
+
+os/filestore/libos_a-DBObjectMap.obj: os/filestore/DBObjectMap.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-DBObjectMap.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Tpo -c -o os/filestore/libos_a-DBObjectMap.obj `if test -f 'os/filestore/DBObjectMap.cc'; then $(CYGPATH_W) 'os/filestore/DBObjectMap.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/DBObjectMap.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Tpo os/filestore/$(DEPDIR)/libos_a-DBObjectMap.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/DBObjectMap.cc' object='os/filestore/libos_a-DBObjectMap.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-DBObjectMap.obj `if test -f 'os/filestore/DBObjectMap.cc'; then $(CYGPATH_W) 'os/filestore/DBObjectMap.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/DBObjectMap.cc'; fi`
+
+os/filestore/libos_a-FileJournal.o: os/filestore/FileJournal.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-FileJournal.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-FileJournal.Tpo -c -o os/filestore/libos_a-FileJournal.o `test -f 'os/filestore/FileJournal.cc' || echo '$(srcdir)/'`os/filestore/FileJournal.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-FileJournal.Tpo os/filestore/$(DEPDIR)/libos_a-FileJournal.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/FileJournal.cc' object='os/filestore/libos_a-FileJournal.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-FileJournal.o `test -f 'os/filestore/FileJournal.cc' || echo '$(srcdir)/'`os/filestore/FileJournal.cc
+
+os/filestore/libos_a-FileJournal.obj: os/filestore/FileJournal.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-FileJournal.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-FileJournal.Tpo -c -o os/filestore/libos_a-FileJournal.obj `if test -f 'os/filestore/FileJournal.cc'; then $(CYGPATH_W) 'os/filestore/FileJournal.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/FileJournal.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-FileJournal.Tpo os/filestore/$(DEPDIR)/libos_a-FileJournal.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/FileJournal.cc' object='os/filestore/libos_a-FileJournal.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-FileJournal.obj `if test -f 'os/filestore/FileJournal.cc'; then $(CYGPATH_W) 'os/filestore/FileJournal.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/FileJournal.cc'; fi`
+
+os/filestore/libos_a-FileStore.o: os/filestore/FileStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-FileStore.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-FileStore.Tpo -c -o os/filestore/libos_a-FileStore.o `test -f 'os/filestore/FileStore.cc' || echo '$(srcdir)/'`os/filestore/FileStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-FileStore.Tpo os/filestore/$(DEPDIR)/libos_a-FileStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/FileStore.cc' object='os/filestore/libos_a-FileStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-FileStore.o `test -f 'os/filestore/FileStore.cc' || echo '$(srcdir)/'`os/filestore/FileStore.cc
+
+os/filestore/libos_a-FileStore.obj: os/filestore/FileStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-FileStore.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-FileStore.Tpo -c -o os/filestore/libos_a-FileStore.obj `if test -f 'os/filestore/FileStore.cc'; then $(CYGPATH_W) 'os/filestore/FileStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/FileStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-FileStore.Tpo os/filestore/$(DEPDIR)/libos_a-FileStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/FileStore.cc' object='os/filestore/libos_a-FileStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-FileStore.obj `if test -f 'os/filestore/FileStore.cc'; then $(CYGPATH_W) 'os/filestore/FileStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/FileStore.cc'; fi`
+
+os/filestore/libos_a-GenericFileStoreBackend.o: os/filestore/GenericFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-GenericFileStoreBackend.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Tpo -c -o os/filestore/libos_a-GenericFileStoreBackend.o `test -f 'os/filestore/GenericFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/GenericFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/GenericFileStoreBackend.cc' object='os/filestore/libos_a-GenericFileStoreBackend.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-GenericFileStoreBackend.o `test -f 'os/filestore/GenericFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/GenericFileStoreBackend.cc
+
+os/filestore/libos_a-GenericFileStoreBackend.obj: os/filestore/GenericFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-GenericFileStoreBackend.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Tpo -c -o os/filestore/libos_a-GenericFileStoreBackend.obj `if test -f 'os/filestore/GenericFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/GenericFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/GenericFileStore [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-GenericFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/GenericFileStoreBackend.cc' object='os/filestore/libos_a-GenericFileStoreBackend.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-GenericFileStoreBackend.obj `if test -f 'os/filestore/GenericFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/GenericFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/GenericFileStoreBackend.cc'; fi`
+
+os/filestore/libos_a-HashIndex.o: os/filestore/HashIndex.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-HashIndex.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-HashIndex.Tpo -c -o os/filestore/libos_a-HashIndex.o `test -f 'os/filestore/HashIndex.cc' || echo '$(srcdir)/'`os/filestore/HashIndex.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-HashIndex.Tpo os/filestore/$(DEPDIR)/libos_a-HashIndex.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/HashIndex.cc' object='os/filestore/libos_a-HashIndex.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-HashIndex.o `test -f 'os/filestore/HashIndex.cc' || echo '$(srcdir)/'`os/filestore/HashIndex.cc
+
+os/filestore/libos_a-HashIndex.obj: os/filestore/HashIndex.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-HashIndex.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-HashIndex.Tpo -c -o os/filestore/libos_a-HashIndex.obj `if test -f 'os/filestore/HashIndex.cc'; then $(CYGPATH_W) 'os/filestore/HashIndex.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/HashIndex.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-HashIndex.Tpo os/filestore/$(DEPDIR)/libos_a-HashIndex.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/HashIndex.cc' object='os/filestore/libos_a-HashIndex.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-HashIndex.obj `if test -f 'os/filestore/HashIndex.cc'; then $(CYGPATH_W) 'os/filestore/HashIndex.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/HashIndex.cc'; fi`
+
+os/filestore/libos_a-IndexManager.o: os/filestore/IndexManager.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-IndexManager.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-IndexManager.Tpo -c -o os/filestore/libos_a-IndexManager.o `test -f 'os/filestore/IndexManager.cc' || echo '$(srcdir)/'`os/filestore/IndexManager.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-IndexManager.Tpo os/filestore/$(DEPDIR)/libos_a-IndexManager.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/IndexManager.cc' object='os/filestore/libos_a-IndexManager.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-IndexManager.o `test -f 'os/filestore/IndexManager.cc' || echo '$(srcdir)/'`os/filestore/IndexManager.cc
+
+os/filestore/libos_a-IndexManager.obj: os/filestore/IndexManager.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-IndexManager.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-IndexManager.Tpo -c -o os/filestore/libos_a-IndexManager.obj `if test -f 'os/filestore/IndexManager.cc'; then $(CYGPATH_W) 'os/filestore/IndexManager.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/IndexManager.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-IndexManager.Tpo os/filestore/$(DEPDIR)/libos_a-IndexManager.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/IndexManager.cc' object='os/filestore/libos_a-IndexManager.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-IndexManager.obj `if test -f 'os/filestore/IndexManager.cc'; then $(CYGPATH_W) 'os/filestore/IndexManager.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/IndexManager.cc'; fi`
+
+os/filestore/libos_a-JournalingObjectStore.o: os/filestore/JournalingObjectStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-JournalingObjectStore.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Tpo -c -o os/filestore/libos_a-JournalingObjectStore.o `test -f 'os/filestore/JournalingObjectStore.cc' || echo '$(srcdir)/'`os/filestore/JournalingObjectStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Tpo os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/JournalingObjectStore.cc' object='os/filestore/libos_a-JournalingObjectStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-JournalingObjectStore.o `test -f 'os/filestore/JournalingObjectStore.cc' || echo '$(srcdir)/'`os/filestore/JournalingObjectStore.cc
+
+os/filestore/libos_a-JournalingObjectStore.obj: os/filestore/JournalingObjectStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-JournalingObjectStore.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Tpo -c -o os/filestore/libos_a-JournalingObjectStore.obj `if test -f 'os/filestore/JournalingObjectStore.cc'; then $(CYGPATH_W) 'os/filestore/JournalingObjectStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/JournalingObjectStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Tpo os/filestore/$(DEPDIR)/libos_a-JournalingObjectStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/JournalingObjectStore.cc' object='os/filestore/libos_a-JournalingObjectStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-JournalingObjectStore.obj `if test -f 'os/filestore/JournalingObjectStore.cc'; then $(CYGPATH_W) 'os/filestore/JournalingObjectStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/JournalingObjectStore.cc'; fi`
+
+os/filestore/libos_a-LFNIndex.o: os/filestore/LFNIndex.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-LFNIndex.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-LFNIndex.Tpo -c -o os/filestore/libos_a-LFNIndex.o `test -f 'os/filestore/LFNIndex.cc' || echo '$(srcdir)/'`os/filestore/LFNIndex.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-LFNIndex.Tpo os/filestore/$(DEPDIR)/libos_a-LFNIndex.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/LFNIndex.cc' object='os/filestore/libos_a-LFNIndex.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-LFNIndex.o `test -f 'os/filestore/LFNIndex.cc' || echo '$(srcdir)/'`os/filestore/LFNIndex.cc
+
+os/filestore/libos_a-LFNIndex.obj: os/filestore/LFNIndex.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-LFNIndex.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-LFNIndex.Tpo -c -o os/filestore/libos_a-LFNIndex.obj `if test -f 'os/filestore/LFNIndex.cc'; then $(CYGPATH_W) 'os/filestore/LFNIndex.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/LFNIndex.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-LFNIndex.Tpo os/filestore/$(DEPDIR)/libos_a-LFNIndex.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/LFNIndex.cc' object='os/filestore/libos_a-LFNIndex.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-LFNIndex.obj `if test -f 'os/filestore/LFNIndex.cc'; then $(CYGPATH_W) 'os/filestore/LFNIndex.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/LFNIndex.cc'; fi`
+
+os/filestore/libos_a-WBThrottle.o: os/filestore/WBThrottle.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-WBThrottle.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-WBThrottle.Tpo -c -o os/filestore/libos_a-WBThrottle.o `test -f 'os/filestore/WBThrottle.cc' || echo '$(srcdir)/'`os/filestore/WBThrottle.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-WBThrottle.Tpo os/filestore/$(DEPDIR)/libos_a-WBThrottle.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/WBThrottle.cc' object='os/filestore/libos_a-WBThrottle.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-WBThrottle.o `test -f 'os/filestore/WBThrottle.cc' || echo '$(srcdir)/'`os/filestore/WBThrottle.cc
+
+os/filestore/libos_a-WBThrottle.obj: os/filestore/WBThrottle.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-WBThrottle.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-WBThrottle.Tpo -c -o os/filestore/libos_a-WBThrottle.obj `if test -f 'os/filestore/WBThrottle.cc'; then $(CYGPATH_W) 'os/filestore/WBThrottle.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/WBThrottle.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-WBThrottle.Tpo os/filestore/$(DEPDIR)/libos_a-WBThrottle.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/WBThrottle.cc' object='os/filestore/libos_a-WBThrottle.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-WBThrottle.obj `if test -f 'os/filestore/WBThrottle.cc'; then $(CYGPATH_W) 'os/filestore/WBThrottle.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/WBThrottle.cc'; fi`
+
+os/fs/libos_a-FS.o: os/fs/FS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/fs/libos_a-FS.o -MD -MP -MF os/fs/$(DEPDIR)/libos_a-FS.Tpo -c -o os/fs/libos_a-FS.o `test -f 'os/fs/FS.cc' || echo '$(srcdir)/'`os/fs/FS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/fs/$(DEPDIR)/libos_a-FS.Tpo os/fs/$(DEPDIR)/libos_a-FS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/fs/FS.cc' object='os/fs/libos_a-FS.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/fs/libos_a-FS.o `test -f 'os/fs/FS.cc' || echo '$(srcdir)/'`os/fs/FS.cc
+
+os/fs/libos_a-FS.obj: os/fs/FS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/fs/libos_a-FS.obj -MD -MP -MF os/fs/$(DEPDIR)/libos_a-FS.Tpo -c -o os/fs/libos_a-FS.obj `if test -f 'os/fs/FS.cc'; then $(CYGPATH_W) 'os/fs/FS.cc'; else $(CYGPATH_W) '$(srcdir)/os/fs/FS.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/fs/$(DEPDIR)/libos_a-FS.Tpo os/fs/$(DEPDIR)/libos_a-FS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/fs/FS.cc' object='os/fs/libos_a-FS.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/fs/libos_a-FS.obj `if test -f 'os/fs/FS.cc'; then $(CYGPATH_W) 'os/fs/FS.cc'; else $(CYGPATH_W) '$(srcdir)/os/fs/FS.cc'; fi`
+
+os/keyvaluestore/libos_a-GenericObjectMap.o: os/keyvaluestore/GenericObjectMap.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/keyvaluestore/libos_a-GenericObjectMap.o -MD -MP -MF os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Tpo -c -o os/keyvaluestore/libos_a-GenericObjectMap.o `test -f 'os/keyvaluestore/GenericObjectMap.cc' || echo '$(srcdir)/'`os/keyvaluestore/GenericObjectMap.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Tpo os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/keyvaluestore/GenericObjectMap.cc' object='os/keyvaluestore/libos_a-GenericObjectMap.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/keyvaluestore/libos_a-GenericObjectMap.o `test -f 'os/keyvaluestore/GenericObjectMap.cc' || echo '$(srcdir)/'`os/keyvaluestore/GenericObjectMap.cc
+
+os/keyvaluestore/libos_a-GenericObjectMap.obj: os/keyvaluestore/GenericObjectMap.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/keyvaluestore/libos_a-GenericObjectMap.obj -MD -MP -MF os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Tpo -c -o os/keyvaluestore/libos_a-GenericObjectMap.obj `if test -f 'os/keyvaluestore/GenericObjectMap.cc'; then $(CYGPATH_W) 'os/keyvaluestore/GenericObjectMap.cc'; else $(CYGPATH_W) '$(srcdir)/os/keyvaluestore/GenericObjectMap.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Tpo os/keyvaluestore/$(DEPDIR)/libos_a-GenericObjectMap.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/keyvaluestore/GenericObjectMap.cc' object='os/keyvaluestore/libos_a-GenericObjectMap.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/keyvaluestore/libos_a-GenericObjectMap.obj `if test -f 'os/keyvaluestore/GenericObjectMap.cc'; then $(CYGPATH_W) 'os/keyvaluestore/GenericObjectMap.cc'; else $(CYGPATH_W) '$(srcdir)/os/keyvaluestore/GenericObjectMap.cc'; fi`
+
+os/keyvaluestore/libos_a-KeyValueStore.o: os/keyvaluestore/KeyValueStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/keyvaluestore/libos_a-KeyValueStore.o -MD -MP -MF os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Tpo -c -o os/keyvaluestore/libos_a-KeyValueStore.o `test -f 'os/keyvaluestore/KeyValueStore.cc' || echo '$(srcdir)/'`os/keyvaluestore/KeyValueStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Tpo os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/keyvaluestore/KeyValueStore.cc' object='os/keyvaluestore/libos_a-KeyValueStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/keyvaluestore/libos_a-KeyValueStore.o `test -f 'os/keyvaluestore/KeyValueStore.cc' || echo '$(srcdir)/'`os/keyvaluestore/KeyValueStore.cc
+
+os/keyvaluestore/libos_a-KeyValueStore.obj: os/keyvaluestore/KeyValueStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/keyvaluestore/libos_a-KeyValueStore.obj -MD -MP -MF os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Tpo -c -o os/keyvaluestore/libos_a-KeyValueStore.obj `if test -f 'os/keyvaluestore/KeyValueStore.cc'; then $(CYGPATH_W) 'os/keyvaluestore/KeyValueStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/keyvaluestore/KeyValueStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Tpo os/keyvaluestore/$(DEPDIR)/libos_a-KeyValueStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/keyvaluestore/KeyValueStore.cc' object='os/keyvaluestore/libos_a-KeyValueStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/keyvaluestore/libos_a-KeyValueStore.obj `if test -f 'os/keyvaluestore/KeyValueStore.cc'; then $(CYGPATH_W) 'os/keyvaluestore/KeyValueStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/keyvaluestore/KeyValueStore.cc'; fi`
+
+os/kstore/libos_a-kv.o: os/kstore/kv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/kstore/libos_a-kv.o -MD -MP -MF os/kstore/$(DEPDIR)/libos_a-kv.Tpo -c -o os/kstore/libos_a-kv.o `test -f 'os/kstore/kv.cc' || echo '$(srcdir)/'`os/kstore/kv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/kstore/$(DEPDIR)/libos_a-kv.Tpo os/kstore/$(DEPDIR)/libos_a-kv.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/kstore/kv.cc' object='os/kstore/libos_a-kv.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/kstore/libos_a-kv.o `test -f 'os/kstore/kv.cc' || echo '$(srcdir)/'`os/kstore/kv.cc
+
+os/kstore/libos_a-kv.obj: os/kstore/kv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/kstore/libos_a-kv.obj -MD -MP -MF os/kstore/$(DEPDIR)/libos_a-kv.Tpo -c -o os/kstore/libos_a-kv.obj `if test -f 'os/kstore/kv.cc'; then $(CYGPATH_W) 'os/kstore/kv.cc'; else $(CYGPATH_W) '$(srcdir)/os/kstore/kv.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/kstore/$(DEPDIR)/libos_a-kv.Tpo os/kstore/$(DEPDIR)/libos_a-kv.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/kstore/kv.cc' object='os/kstore/libos_a-kv.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/kstore/libos_a-kv.obj `if test -f 'os/kstore/kv.cc'; then $(CYGPATH_W) 'os/kstore/kv.cc'; else $(CYGPATH_W) '$(srcdir)/os/kstore/kv.cc'; fi`
+
+os/kstore/libos_a-KStore.o: os/kstore/KStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/kstore/libos_a-KStore.o -MD -MP -MF os/kstore/$(DEPDIR)/libos_a-KStore.Tpo -c -o os/kstore/libos_a-KStore.o `test -f 'os/kstore/KStore.cc' || echo '$(srcdir)/'`os/kstore/KStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/kstore/$(DEPDIR)/libos_a-KStore.Tpo os/kstore/$(DEPDIR)/libos_a-KStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/kstore/KStore.cc' object='os/kstore/libos_a-KStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/kstore/libos_a-KStore.o `test -f 'os/kstore/KStore.cc' || echo '$(srcdir)/'`os/kstore/KStore.cc
+
+os/kstore/libos_a-KStore.obj: os/kstore/KStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/kstore/libos_a-KStore.obj -MD -MP -MF os/kstore/$(DEPDIR)/libos_a-KStore.Tpo -c -o os/kstore/libos_a-KStore.obj `if test -f 'os/kstore/KStore.cc'; then $(CYGPATH_W) 'os/kstore/KStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/kstore/KStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/kstore/$(DEPDIR)/libos_a-KStore.Tpo os/kstore/$(DEPDIR)/libos_a-KStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/kstore/KStore.cc' object='os/kstore/libos_a-KStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/kstore/libos_a-KStore.obj `if test -f 'os/kstore/KStore.cc'; then $(CYGPATH_W) 'os/kstore/KStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/kstore/KStore.cc'; fi`
+
+os/memstore/libos_a-MemStore.o: os/memstore/MemStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/memstore/libos_a-MemStore.o -MD -MP -MF os/memstore/$(DEPDIR)/libos_a-MemStore.Tpo -c -o os/memstore/libos_a-MemStore.o `test -f 'os/memstore/MemStore.cc' || echo '$(srcdir)/'`os/memstore/MemStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/memstore/$(DEPDIR)/libos_a-MemStore.Tpo os/memstore/$(DEPDIR)/libos_a-MemStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/memstore/MemStore.cc' object='os/memstore/libos_a-MemStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/memstore/libos_a-MemStore.o `test -f 'os/memstore/MemStore.cc' || echo '$(srcdir)/'`os/memstore/MemStore.cc
+
+os/memstore/libos_a-MemStore.obj: os/memstore/MemStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/memstore/libos_a-MemStore.obj -MD -MP -MF os/memstore/$(DEPDIR)/libos_a-MemStore.Tpo -c -o os/memstore/libos_a-MemStore.obj `if test -f 'os/memstore/MemStore.cc'; then $(CYGPATH_W) 'os/memstore/MemStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/memstore/MemStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/memstore/$(DEPDIR)/libos_a-MemStore.Tpo os/memstore/$(DEPDIR)/libos_a-MemStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/memstore/MemStore.cc' object='os/memstore/libos_a-MemStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/memstore/libos_a-MemStore.obj `if test -f 'os/memstore/MemStore.cc'; then $(CYGPATH_W) 'os/memstore/MemStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/memstore/MemStore.cc'; fi`
+
+os/libos_a-ObjectStore.o: os/ObjectStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/libos_a-ObjectStore.o -MD -MP -MF os/$(DEPDIR)/libos_a-ObjectStore.Tpo -c -o os/libos_a-ObjectStore.o `test -f 'os/ObjectStore.cc' || echo '$(srcdir)/'`os/ObjectStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/$(DEPDIR)/libos_a-ObjectStore.Tpo os/$(DEPDIR)/libos_a-ObjectStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/ObjectStore.cc' object='os/libos_a-ObjectStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/libos_a-ObjectStore.o `test -f 'os/ObjectStore.cc' || echo '$(srcdir)/'`os/ObjectStore.cc
+
+os/libos_a-ObjectStore.obj: os/ObjectStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/libos_a-ObjectStore.obj -MD -MP -MF os/$(DEPDIR)/libos_a-ObjectStore.Tpo -c -o os/libos_a-ObjectStore.obj `if test -f 'os/ObjectStore.cc'; then $(CYGPATH_W) 'os/ObjectStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/ObjectStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/$(DEPDIR)/libos_a-ObjectStore.Tpo os/$(DEPDIR)/libos_a-ObjectStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/ObjectStore.cc' object='os/libos_a-ObjectStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/libos_a-ObjectStore.obj `if test -f 'os/ObjectStore.cc'; then $(CYGPATH_W) 'os/ObjectStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/ObjectStore.cc'; fi`
+
+os/bluestore/libos_a-kv.o: os/bluestore/kv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-kv.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-kv.Tpo -c -o os/bluestore/libos_a-kv.o `test -f 'os/bluestore/kv.cc' || echo '$(srcdir)/'`os/bluestore/kv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-kv.Tpo os/bluestore/$(DEPDIR)/libos_a-kv.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/kv.cc' object='os/bluestore/libos_a-kv.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-kv.o `test -f 'os/bluestore/kv.cc' || echo '$(srcdir)/'`os/bluestore/kv.cc
+
+os/bluestore/libos_a-kv.obj: os/bluestore/kv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-kv.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-kv.Tpo -c -o os/bluestore/libos_a-kv.obj `if test -f 'os/bluestore/kv.cc'; then $(CYGPATH_W) 'os/bluestore/kv.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/kv.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-kv.Tpo os/bluestore/$(DEPDIR)/libos_a-kv.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/kv.cc' object='os/bluestore/libos_a-kv.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-kv.obj `if test -f 'os/bluestore/kv.cc'; then $(CYGPATH_W) 'os/bluestore/kv.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/kv.cc'; fi`
+
+os/bluestore/libos_a-Allocator.o: os/bluestore/Allocator.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-Allocator.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-Allocator.Tpo -c -o os/bluestore/libos_a-Allocator.o `test -f 'os/bluestore/Allocator.cc' || echo '$(srcdir)/'`os/bluestore/Allocator.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-Allocator.Tpo os/bluestore/$(DEPDIR)/libos_a-Allocator.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/Allocator.cc' object='os/bluestore/libos_a-Allocator.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-Allocator.o `test -f 'os/bluestore/Allocator.cc' || echo '$(srcdir)/'`os/bluestore/Allocator.cc
+
+os/bluestore/libos_a-Allocator.obj: os/bluestore/Allocator.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-Allocator.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-Allocator.Tpo -c -o os/bluestore/libos_a-Allocator.obj `if test -f 'os/bluestore/Allocator.cc'; then $(CYGPATH_W) 'os/bluestore/Allocator.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/Allocator.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-Allocator.Tpo os/bluestore/$(DEPDIR)/libos_a-Allocator.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/Allocator.cc' object='os/bluestore/libos_a-Allocator.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-Allocator.obj `if test -f 'os/bluestore/Allocator.cc'; then $(CYGPATH_W) 'os/bluestore/Allocator.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/Allocator.cc'; fi`
+
+os/bluestore/libos_a-BlockDevice.o: os/bluestore/BlockDevice.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlockDevice.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Tpo -c -o os/bluestore/libos_a-BlockDevice.o `test -f 'os/bluestore/BlockDevice.cc' || echo '$(srcdir)/'`os/bluestore/BlockDevice.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Tpo os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlockDevice.cc' object='os/bluestore/libos_a-BlockDevice.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlockDevice.o `test -f 'os/bluestore/BlockDevice.cc' || echo '$(srcdir)/'`os/bluestore/BlockDevice.cc
+
+os/bluestore/libos_a-BlockDevice.obj: os/bluestore/BlockDevice.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlockDevice.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Tpo -c -o os/bluestore/libos_a-BlockDevice.obj `if test -f 'os/bluestore/BlockDevice.cc'; then $(CYGPATH_W) 'os/bluestore/BlockDevice.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlockDevice.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Tpo os/bluestore/$(DEPDIR)/libos_a-BlockDevice.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlockDevice.cc' object='os/bluestore/libos_a-BlockDevice.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlockDevice.obj `if test -f 'os/bluestore/BlockDevice.cc'; then $(CYGPATH_W) 'os/bluestore/BlockDevice.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlockDevice.cc'; fi`
+
+os/bluestore/libos_a-BlueFS.o: os/bluestore/BlueFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlueFS.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlueFS.Tpo -c -o os/bluestore/libos_a-BlueFS.o `test -f 'os/bluestore/BlueFS.cc' || echo '$(srcdir)/'`os/bluestore/BlueFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlueFS.Tpo os/bluestore/$(DEPDIR)/libos_a-BlueFS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlueFS.cc' object='os/bluestore/libos_a-BlueFS.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlueFS.o `test -f 'os/bluestore/BlueFS.cc' || echo '$(srcdir)/'`os/bluestore/BlueFS.cc
+
+os/bluestore/libos_a-BlueFS.obj: os/bluestore/BlueFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlueFS.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlueFS.Tpo -c -o os/bluestore/libos_a-BlueFS.obj `if test -f 'os/bluestore/BlueFS.cc'; then $(CYGPATH_W) 'os/bluestore/BlueFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlueFS.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlueFS.Tpo os/bluestore/$(DEPDIR)/libos_a-BlueFS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlueFS.cc' object='os/bluestore/libos_a-BlueFS.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlueFS.obj `if test -f 'os/bluestore/BlueFS.cc'; then $(CYGPATH_W) 'os/bluestore/BlueFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlueFS.cc'; fi`
+
+os/bluestore/libos_a-BlueRocksEnv.o: os/bluestore/BlueRocksEnv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlueRocksEnv.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Tpo -c -o os/bluestore/libos_a-BlueRocksEnv.o `test -f 'os/bluestore/BlueRocksEnv.cc' || echo '$(srcdir)/'`os/bluestore/BlueRocksEnv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Tpo os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlueRocksEnv.cc' object='os/bluestore/libos_a-BlueRocksEnv.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlueRocksEnv.o `test -f 'os/bluestore/BlueRocksEnv.cc' || echo '$(srcdir)/'`os/bluestore/BlueRocksEnv.cc
+
+os/bluestore/libos_a-BlueRocksEnv.obj: os/bluestore/BlueRocksEnv.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlueRocksEnv.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Tpo -c -o os/bluestore/libos_a-BlueRocksEnv.obj `if test -f 'os/bluestore/BlueRocksEnv.cc'; then $(CYGPATH_W) 'os/bluestore/BlueRocksEnv.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlueRocksEnv.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Tpo os/bluestore/$(DEPDIR)/libos_a-BlueRocksEnv.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlueRocksEnv.cc' object='os/bluestore/libos_a-BlueRocksEnv.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlueRocksEnv.obj `if test -f 'os/bluestore/BlueRocksEnv.cc'; then $(CYGPATH_W) 'os/bluestore/BlueRocksEnv.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlueRocksEnv.cc'; fi`
+
+os/bluestore/libos_a-BlueStore.o: os/bluestore/BlueStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlueStore.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlueStore.Tpo -c -o os/bluestore/libos_a-BlueStore.o `test -f 'os/bluestore/BlueStore.cc' || echo '$(srcdir)/'`os/bluestore/BlueStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlueStore.Tpo os/bluestore/$(DEPDIR)/libos_a-BlueStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlueStore.cc' object='os/bluestore/libos_a-BlueStore.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlueStore.o `test -f 'os/bluestore/BlueStore.cc' || echo '$(srcdir)/'`os/bluestore/BlueStore.cc
+
+os/bluestore/libos_a-BlueStore.obj: os/bluestore/BlueStore.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-BlueStore.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-BlueStore.Tpo -c -o os/bluestore/libos_a-BlueStore.obj `if test -f 'os/bluestore/BlueStore.cc'; then $(CYGPATH_W) 'os/bluestore/BlueStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlueStore.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-BlueStore.Tpo os/bluestore/$(DEPDIR)/libos_a-BlueStore.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/BlueStore.cc' object='os/bluestore/libos_a-BlueStore.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-BlueStore.obj `if test -f 'os/bluestore/BlueStore.cc'; then $(CYGPATH_W) 'os/bluestore/BlueStore.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/BlueStore.cc'; fi`
+
+os/bluestore/libos_a-FreelistManager.o: os/bluestore/FreelistManager.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-FreelistManager.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Tpo -c -o os/bluestore/libos_a-FreelistManager.o `test -f 'os/bluestore/FreelistManager.cc' || echo '$(srcdir)/'`os/bluestore/FreelistManager.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Tpo os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/FreelistManager.cc' object='os/bluestore/libos_a-FreelistManager.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-FreelistManager.o `test -f 'os/bluestore/FreelistManager.cc' || echo '$(srcdir)/'`os/bluestore/FreelistManager.cc
+
+os/bluestore/libos_a-FreelistManager.obj: os/bluestore/FreelistManager.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-FreelistManager.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Tpo -c -o os/bluestore/libos_a-FreelistManager.obj `if test -f 'os/bluestore/FreelistManager.cc'; then $(CYGPATH_W) 'os/bluestore/FreelistManager.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/FreelistManager.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Tpo os/bluestore/$(DEPDIR)/libos_a-FreelistManager.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/FreelistManager.cc' object='os/bluestore/libos_a-FreelistManager.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-FreelistManager.obj `if test -f 'os/bluestore/FreelistManager.cc'; then $(CYGPATH_W) 'os/bluestore/FreelistManager.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/FreelistManager.cc'; fi`
+
+os/bluestore/libos_a-StupidAllocator.o: os/bluestore/StupidAllocator.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-StupidAllocator.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Tpo -c -o os/bluestore/libos_a-StupidAllocator.o `test -f 'os/bluestore/StupidAllocator.cc' || echo '$(srcdir)/'`os/bluestore/StupidAllocator.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Tpo os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/StupidAllocator.cc' object='os/bluestore/libos_a-StupidAllocator.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-StupidAllocator.o `test -f 'os/bluestore/StupidAllocator.cc' || echo '$(srcdir)/'`os/bluestore/StupidAllocator.cc
+
+os/bluestore/libos_a-StupidAllocator.obj: os/bluestore/StupidAllocator.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_a-StupidAllocator.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Tpo -c -o os/bluestore/libos_a-StupidAllocator.obj `if test -f 'os/bluestore/StupidAllocator.cc'; then $(CYGPATH_W) 'os/bluestore/StupidAllocator.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/StupidAllocator.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Tpo os/bluestore/$(DEPDIR)/libos_a-StupidAllocator.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/StupidAllocator.cc' object='os/bluestore/libos_a-StupidAllocator.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_a-StupidAllocator.obj `if test -f 'os/bluestore/StupidAllocator.cc'; then $(CYGPATH_W) 'os/bluestore/StupidAllocator.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/StupidAllocator.cc'; fi`
+
+os/filestore/libos_a-BtrfsFileStoreBackend.o: os/filestore/BtrfsFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-BtrfsFileStoreBackend.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Tpo -c -o os/filestore/libos_a-BtrfsFileStoreBackend.o `test -f 'os/filestore/BtrfsFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/BtrfsFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/BtrfsFileStoreBackend.cc' object='os/filestore/libos_a-BtrfsFileStoreBackend.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-BtrfsFileStoreBackend.o `test -f 'os/filestore/BtrfsFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/BtrfsFileStoreBackend.cc
+
+os/filestore/libos_a-BtrfsFileStoreBackend.obj: os/filestore/BtrfsFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-BtrfsFileStoreBackend.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Tpo -c -o os/filestore/libos_a-BtrfsFileStoreBackend.obj `if test -f 'os/filestore/BtrfsFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/BtrfsFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/BtrfsFileStoreBackend.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-BtrfsFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/BtrfsFileStoreBackend.cc' object='os/filestore/libos_a-BtrfsFileStoreBackend.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-BtrfsFileStoreBackend.obj `if test -f 'os/filestore/BtrfsFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/BtrfsFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/BtrfsFileStoreBackend.cc'; fi`
+
+os/filestore/libos_a-XfsFileStoreBackend.o: os/filestore/XfsFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-XfsFileStoreBackend.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Tpo -c -o os/filestore/libos_a-XfsFileStoreBackend.o `test -f 'os/filestore/XfsFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/XfsFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/XfsFileStoreBackend.cc' object='os/filestore/libos_a-XfsFileStoreBackend.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-XfsFileStoreBackend.o `test -f 'os/filestore/XfsFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/XfsFileStoreBackend.cc
+
+os/filestore/libos_a-XfsFileStoreBackend.obj: os/filestore/XfsFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-XfsFileStoreBackend.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Tpo -c -o os/filestore/libos_a-XfsFileStoreBackend.obj `if test -f 'os/filestore/XfsFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/XfsFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/XfsFileStoreBackend.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-XfsFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/XfsFileStoreBackend.cc' object='os/filestore/libos_a-XfsFileStoreBackend.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-XfsFileStoreBackend.obj `if test -f 'os/filestore/XfsFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/XfsFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/XfsFileStoreBackend.cc'; fi`
+
+os/fs/libos_a-XFS.o: os/fs/XFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/fs/libos_a-XFS.o -MD -MP -MF os/fs/$(DEPDIR)/libos_a-XFS.Tpo -c -o os/fs/libos_a-XFS.o `test -f 'os/fs/XFS.cc' || echo '$(srcdir)/'`os/fs/XFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/fs/$(DEPDIR)/libos_a-XFS.Tpo os/fs/$(DEPDIR)/libos_a-XFS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/fs/XFS.cc' object='os/fs/libos_a-XFS.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/fs/libos_a-XFS.o `test -f 'os/fs/XFS.cc' || echo '$(srcdir)/'`os/fs/XFS.cc
+
+os/fs/libos_a-XFS.obj: os/fs/XFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/fs/libos_a-XFS.obj -MD -MP -MF os/fs/$(DEPDIR)/libos_a-XFS.Tpo -c -o os/fs/libos_a-XFS.obj `if test -f 'os/fs/XFS.cc'; then $(CYGPATH_W) 'os/fs/XFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/fs/XFS.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/fs/$(DEPDIR)/libos_a-XFS.Tpo os/fs/$(DEPDIR)/libos_a-XFS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/fs/XFS.cc' object='os/fs/libos_a-XFS.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/fs/libos_a-XFS.obj `if test -f 'os/fs/XFS.cc'; then $(CYGPATH_W) 'os/fs/XFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/fs/XFS.cc'; fi`
+
+os/filestore/libos_a-ZFSFileStoreBackend.o: os/filestore/ZFSFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-ZFSFileStoreBackend.o -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Tpo -c -o os/filestore/libos_a-ZFSFileStoreBackend.o `test -f 'os/filestore/ZFSFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/ZFSFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/ZFSFileStoreBackend.cc' object='os/filestore/libos_a-ZFSFileStoreBackend.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-ZFSFileStoreBackend.o `test -f 'os/filestore/ZFSFileStoreBackend.cc' || echo '$(srcdir)/'`os/filestore/ZFSFileStoreBackend.cc
+
+os/filestore/libos_a-ZFSFileStoreBackend.obj: os/filestore/ZFSFileStoreBackend.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -MT os/filestore/libos_a-ZFSFileStoreBackend.obj -MD -MP -MF os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Tpo -c -o os/filestore/libos_a-ZFSFileStoreBackend.obj `if test -f 'os/filestore/ZFSFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/ZFSFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/ZFSFileStoreBackend.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Tpo os/filestore/$(DEPDIR)/libos_a-ZFSFileStoreBackend.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/filestore/ZFSFileStoreBackend.cc' object='os/filestore/libos_a-ZFSFileStoreBackend.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_a_CXXFLAGS) $(CXXFLAGS) -c -o os/filestore/libos_a-ZFSFileStoreBackend.obj `if test -f 'os/filestore/ZFSFileStoreBackend.cc'; then $(CYGPATH_W) 'os/filestore/ZFSFileStoreBackend.cc'; else $(CYGPATH_W) '$(srcdir)/os/filestore/ZFSFileStoreBackend.cc'; fi`
+
+os/kstore/libos_types_a-kstore_types.o: os/kstore/kstore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/kstore/libos_types_a-kstore_types.o -MD -MP -MF os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Tpo -c -o os/kstore/libos_types_a-kstore_types.o `test -f 'os/kstore/kstore_types.cc' || echo '$(srcdir)/'`os/kstore/kstore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Tpo os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/kstore/kstore_types.cc' object='os/kstore/libos_types_a-kstore_types.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/kstore/libos_types_a-kstore_types.o `test -f 'os/kstore/kstore_types.cc' || echo '$(srcdir)/'`os/kstore/kstore_types.cc
+
+os/kstore/libos_types_a-kstore_types.obj: os/kstore/kstore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/kstore/libos_types_a-kstore_types.obj -MD -MP -MF os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Tpo -c -o os/kstore/libos_types_a-kstore_types.obj `if test -f 'os/kstore/kstore_types.cc'; then $(CYGPATH_W) 'os/kstore/kstore_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/kstore/kstore_types.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Tpo os/kstore/$(DEPDIR)/libos_types_a-kstore_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/kstore/kstore_types.cc' object='os/kstore/libos_types_a-kstore_types.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/kstore/libos_types_a-kstore_types.obj `if test -f 'os/kstore/kstore_types.cc'; then $(CYGPATH_W) 'os/kstore/kstore_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/kstore/kstore_types.cc'; fi`
+
 os/libos_types_a-Transaction.o: os/Transaction.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/libos_types_a-Transaction.o -MD -MP -MF os/$(DEPDIR)/libos_types_a-Transaction.Tpo -c -o os/libos_types_a-Transaction.o `test -f 'os/Transaction.cc' || echo '$(srcdir)/'`os/Transaction.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/$(DEPDIR)/libos_types_a-Transaction.Tpo os/$(DEPDIR)/libos_types_a-Transaction.Po
@@ -20349,33 +21400,47 @@ os/libos_types_a-Transaction.obj: os/Transaction.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/libos_types_a-Transaction.obj `if test -f 'os/Transaction.cc'; then $(CYGPATH_W) 'os/Transaction.cc'; else $(CYGPATH_W) '$(srcdir)/os/Transaction.cc'; fi`
 
-os/newstore/libos_types_a-newstore_types.o: os/newstore/newstore_types.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/newstore/libos_types_a-newstore_types.o -MD -MP -MF os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Tpo -c -o os/newstore/libos_types_a-newstore_types.o `test -f 'os/newstore/newstore_types.cc' || echo '$(srcdir)/'`os/newstore/newstore_types.cc
- at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Tpo os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/newstore/newstore_types.cc' object='os/newstore/libos_types_a-newstore_types.o' libtool=no @AMDEPBACKSLASH@
+os/bluestore/libos_types_a-bluestore_types.o: os/bluestore/bluestore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_types_a-bluestore_types.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Tpo -c -o os/bluestore/libos_types_a-bluestore_types.o `test -f 'os/bluestore/bluestore_types.cc' || echo '$(srcdir)/'`os/bluestore/bluestore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Tpo os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/bluestore_types.cc' object='os/bluestore/libos_types_a-bluestore_types.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_types_a-bluestore_types.o `test -f 'os/bluestore/bluestore_types.cc' || echo '$(srcdir)/'`os/bluestore/bluestore_types.cc
+
+os/bluestore/libos_types_a-bluestore_types.obj: os/bluestore/bluestore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_types_a-bluestore_types.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Tpo -c -o os/bluestore/libos_types_a-bluestore_types.obj `if test -f 'os/bluestore/bluestore_types.cc'; then $(CYGPATH_W) 'os/bluestore/bluestore_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/bluestore_types.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Tpo os/bluestore/$(DEPDIR)/libos_types_a-bluestore_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/bluestore_types.cc' object='os/bluestore/libos_types_a-bluestore_types.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/newstore/libos_types_a-newstore_types.o `test -f 'os/newstore/newstore_types.cc' || echo '$(srcdir)/'`os/newstore/newstore_types.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_types_a-bluestore_types.obj `if test -f 'os/bluestore/bluestore_types.cc'; then $(CYGPATH_W) 'os/bluestore/bluestore_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/bluestore_types.cc'; fi`
 
-os/newstore/libos_types_a-newstore_types.obj: os/newstore/newstore_types.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/newstore/libos_types_a-newstore_types.obj -MD -MP -MF os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Tpo -c -o os/newstore/libos_types_a-newstore_types.obj `if test -f 'os/newstore/newstore_types.cc'; then $(CYGPATH_W) 'os/newstore/newstore_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/newstore/newstore_types.cc'; fi`
- at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Tpo os/newstore/$(DEPDIR)/libos_types_a-newstore_types.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/newstore/newstore_types.cc' object='os/newstore/libos_types_a-newstore_types.obj' libtool=no @AMDEPBACKSLASH@
+os/bluestore/libos_types_a-bluefs_types.o: os/bluestore/bluefs_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_types_a-bluefs_types.o -MD -MP -MF os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Tpo -c -o os/bluestore/libos_types_a-bluefs_types.o `test -f 'os/bluestore/bluefs_types.cc' || echo '$(srcdir)/'`os/bluestore/bluefs_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Tpo os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/bluefs_types.cc' object='os/bluestore/libos_types_a-bluefs_types.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/newstore/libos_types_a-newstore_types.obj `if test -f 'os/newstore/newstore_types.cc'; then $(CYGPATH_W) 'os/newstore/newstore_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/newstore/newstore_types.cc'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_types_a-bluefs_types.o `test -f 'os/bluestore/bluefs_types.cc' || echo '$(srcdir)/'`os/bluestore/bluefs_types.cc
 
-os/libos_zfs_a-ZFS.o: os/ZFS.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -MT os/libos_zfs_a-ZFS.o -MD -MP -MF os/$(DEPDIR)/libos_zfs_a-ZFS.Tpo -c -o os/libos_zfs_a-ZFS.o `test -f 'os/ZFS.cc' || echo '$(srcdir)/'`os/ZFS.cc
- at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/$(DEPDIR)/libos_zfs_a-ZFS.Tpo os/$(DEPDIR)/libos_zfs_a-ZFS.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/ZFS.cc' object='os/libos_zfs_a-ZFS.o' libtool=no @AMDEPBACKSLASH@
+os/bluestore/libos_types_a-bluefs_types.obj: os/bluestore/bluefs_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -MT os/bluestore/libos_types_a-bluefs_types.obj -MD -MP -MF os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Tpo -c -o os/bluestore/libos_types_a-bluefs_types.obj `if test -f 'os/bluestore/bluefs_types.cc'; then $(CYGPATH_W) 'os/bluestore/bluefs_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/bluefs_types.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Tpo os/bluestore/$(DEPDIR)/libos_types_a-bluefs_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/bluestore/bluefs_types.cc' object='os/bluestore/libos_types_a-bluefs_types.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -c -o os/libos_zfs_a-ZFS.o `test -f 'os/ZFS.cc' || echo '$(srcdir)/'`os/ZFS.cc
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_types_a_CXXFLAGS) $(CXXFLAGS) -c -o os/bluestore/libos_types_a-bluefs_types.obj `if test -f 'os/bluestore/bluefs_types.cc'; then $(CYGPATH_W) 'os/bluestore/bluefs_types.cc'; else $(CYGPATH_W) '$(srcdir)/os/bluestore/bluefs_types.cc'; fi`
 
-os/libos_zfs_a-ZFS.obj: os/ZFS.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -MT os/libos_zfs_a-ZFS.obj -MD -MP -MF os/$(DEPDIR)/libos_zfs_a-ZFS.Tpo -c -o os/libos_zfs_a-ZFS.obj `if test -f 'os/ZFS.cc'; then $(CYGPATH_W) 'os/ZFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/ZFS.cc'; fi`
- at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/$(DEPDIR)/libos_zfs_a-ZFS.Tpo os/$(DEPDIR)/libos_zfs_a-ZFS.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/ZFS.cc' object='os/libos_zfs_a-ZFS.obj' libtool=no @AMDEPBACKSLASH@
+os/fs/libos_zfs_a-ZFS.o: os/fs/ZFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -MT os/fs/libos_zfs_a-ZFS.o -MD -MP -MF os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Tpo -c -o os/fs/libos_zfs_a-ZFS.o `test -f 'os/fs/ZFS.cc' || echo '$(srcdir)/'`os/fs/ZFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Tpo os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/fs/ZFS.cc' object='os/fs/libos_zfs_a-ZFS.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -c -o os/libos_zfs_a-ZFS.obj `if test -f 'os/ZFS.cc'; then $(CYGPATH_W) 'os/ZFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/ZFS.cc'; fi`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -c -o os/fs/libos_zfs_a-ZFS.o `test -f 'os/fs/ZFS.cc' || echo '$(srcdir)/'`os/fs/ZFS.cc
+
+os/fs/libos_zfs_a-ZFS.obj: os/fs/ZFS.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -MT os/fs/libos_zfs_a-ZFS.obj -MD -MP -MF os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Tpo -c -o os/fs/libos_zfs_a-ZFS.obj `if test -f 'os/fs/ZFS.cc'; then $(CYGPATH_W) 'os/fs/ZFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/fs/ZFS.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Tpo os/fs/$(DEPDIR)/libos_zfs_a-ZFS.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='os/fs/ZFS.cc' object='os/fs/libos_zfs_a-ZFS.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libos_zfs_a_CXXFLAGS) $(CXXFLAGS) -c -o os/fs/libos_zfs_a-ZFS.obj `if test -f 'os/fs/ZFS.cc'; then $(CYGPATH_W) 'os/fs/ZFS.cc'; else $(CYGPATH_W) '$(srcdir)/os/fs/ZFS.cc'; fi`
 
 osd/libosd_a-PG.o: osd/PG.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libosd_a_CXXFLAGS) $(CXXFLAGS) -MT osd/libosd_a-PG.o -MD -MP -MF osd/$(DEPDIR)/libosd_a-PG.Tpo -c -o osd/libosd_a-PG.o `test -f 'osd/PG.cc' || echo '$(srcdir)/'`osd/PG.cc
@@ -20587,6 +21652,34 @@ objclass/libosd_a-class_api.obj: objclass/class_api.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libosd_a_CXXFLAGS) $(CXXFLAGS) -c -o objclass/libosd_a-class_api.obj `if test -f 'objclass/class_api.cc'; then $(CYGPATH_W) 'objclass/class_api.cc'; else $(CYGPATH_W) '$(srcdir)/objclass/class_api.cc'; fi`
 
+compressor/libceph_example_la-Compressor.lo: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_example_la_CXXFLAGS) $(CXXFLAGS) -MT compressor/libceph_example_la-Compressor.lo -MD -MP -MF compressor/$(DEPDIR)/libceph_example_la-Compressor.Tpo -c -o compressor/libceph_example_la-Compressor.lo `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/libceph_example_la-Compressor.Tpo compressor/$(DEPDIR)/libceph_example_la-Compressor.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/libceph_example_la-Compressor.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_example_la_CXXFLAGS) $(CXXFLAGS) -c -o compressor/libceph_example_la-Compressor.lo `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+
+test/compressor/libceph_example_la-compressor_plugin_example.lo: test/compressor/compressor_plugin_example.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_example_la_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/libceph_example_la-compressor_plugin_example.lo -MD -MP -MF test/compressor/$(DEPDIR)/libceph_example_la-compressor_plugin_example.Tpo -c -o test/compressor/libceph_example_la-compressor_plugin_example.lo `test -f 'test/compressor/compresso [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/libceph_example_la-compressor_plugin_example.Tpo test/compressor/$(DEPDIR)/libceph_example_la-compressor_plugin_example.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/compressor_plugin_example.cc' object='test/compressor/libceph_example_la-compressor_plugin_example.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_example_la_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/libceph_example_la-compressor_plugin_example.lo `test -f 'test/compressor/compressor_plugin_example.cc' || echo '$(srcdir)/'`test/compressor/compressor_plugin_example.cc
+
+compressor/libceph_snappy_la-Compressor.lo: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_snappy_la_CXXFLAGS) $(CXXFLAGS) -MT compressor/libceph_snappy_la-Compressor.lo -MD -MP -MF compressor/$(DEPDIR)/libceph_snappy_la-Compressor.Tpo -c -o compressor/libceph_snappy_la-Compressor.lo `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/libceph_snappy_la-Compressor.Tpo compressor/$(DEPDIR)/libceph_snappy_la-Compressor.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/libceph_snappy_la-Compressor.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_snappy_la_CXXFLAGS) $(CXXFLAGS) -c -o compressor/libceph_snappy_la-Compressor.lo `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+
+compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo: compressor/snappy/CompressionPluginSnappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_snappy_la_CXXFLAGS) $(CXXFLAGS) -MT compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo -MD -MP -MF compressor/snappy/$(DEPDIR)/libceph_snappy_la-CompressionPluginSnappy.Tpo -c -o compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo `test -f 'compressor/snappy/Compression [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/snappy/$(DEPDIR)/libceph_snappy_la-CompressionPluginSnappy.Tpo compressor/snappy/$(DEPDIR)/libceph_snappy_la-CompressionPluginSnappy.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/snappy/CompressionPluginSnappy.cc' object='compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libceph_snappy_la_CXXFLAGS) $(CXXFLAGS) -c -o compressor/snappy/libceph_snappy_la-CompressionPluginSnappy.lo `test -f 'compressor/snappy/CompressionPluginSnappy.cc' || echo '$(srcdir)/'`compressor/snappy/CompressionPluginSnappy.cc
+
 java/native/libcephfs_jni_la-libcephfs_jni.lo: java/native/libcephfs_jni.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcephfs_jni_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT java/native/libcephfs_jni_la-libcephfs_jni.lo -MD -MP -MF java/native/$(DEPDIR)/libcephfs_jni_la-libcephfs_jni.Tpo -c -o java/native/libcephfs_jni_la-libcephfs_jni.lo `test -f 'java/native/libcephfs_jni.cc' || echo '$(srcdir)/'`java/native/libcephfs_jni.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) java/native/$(DEPDIR)/libcephfs_jni_la-libcephfs_jni.Tpo java/native/$(DEPDIR)/libcephfs_jni_la-libcephfs_jni.Plo
@@ -21126,20 +22219,6 @@ test/librbd/librbd_test_la-test_internal.lo: test/librbd/test_internal.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/librbd_test_la-test_internal.lo `test -f 'test/librbd/test_internal.cc' || echo '$(srcdir)/'`test/librbd/test_internal.cc
 
-test/librbd/librbd_test_la-test_JournalEntries.lo: test/librbd/test_JournalEntries.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/librbd_test_la-test_JournalEntries.lo -MD -MP -MF test/librbd/$(DEPDIR)/librbd_test_la-test_JournalEntries.Tpo -c -o test/librbd/librbd_test_la-test_JournalEntries.lo `test -f 'test/librbd/test_JournalEntries.cc' || echo '$(srcdir)/'`test/librbd/te [...]
- at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/$(DEPDIR)/librbd_test_la-test_JournalEntries.Tpo test/librbd/$(DEPDIR)/librbd_test_la-test_JournalEntries.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/test_JournalEntries.cc' object='test/librbd/librbd_test_la-test_JournalEntries.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/librbd_test_la-test_JournalEntries.lo `test -f 'test/librbd/test_JournalEntries.cc' || echo '$(srcdir)/'`test/librbd/test_JournalEntries.cc
-
-test/librbd/librbd_test_la-test_JournalReplay.lo: test/librbd/test_JournalReplay.cc
- at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/librbd_test_la-test_JournalReplay.lo -MD -MP -MF test/librbd/$(DEPDIR)/librbd_test_la-test_JournalReplay.Tpo -c -o test/librbd/librbd_test_la-test_JournalReplay.lo `test -f 'test/librbd/test_JournalReplay.cc' || echo '$(srcdir)/'`test/librbd/test_J [...]
- at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/$(DEPDIR)/librbd_test_la-test_JournalReplay.Tpo test/librbd/$(DEPDIR)/librbd_test_la-test_JournalReplay.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/test_JournalReplay.cc' object='test/librbd/librbd_test_la-test_JournalReplay.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/librbd_test_la-test_JournalReplay.lo `test -f 'test/librbd/test_JournalReplay.cc' || echo '$(srcdir)/'`test/librbd/test_JournalReplay.cc
-
 test/librbd/librbd_test_la-test_ObjectMap.lo: test/librbd/test_ObjectMap.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/librbd_test_la-test_ObjectMap.lo -MD -MP -MF test/librbd/$(DEPDIR)/librbd_test_la-test_ObjectMap.Tpo -c -o test/librbd/librbd_test_la-test_ObjectMap.lo `test -f 'test/librbd/test_ObjectMap.cc' || echo '$(srcdir)/'`test/librbd/test_ObjectMap.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/$(DEPDIR)/librbd_test_la-test_ObjectMap.Tpo test/librbd/$(DEPDIR)/librbd_test_la-test_ObjectMap.Plo
@@ -21147,6 +22226,20 @@ test/librbd/librbd_test_la-test_ObjectMap.lo: test/librbd/test_ObjectMap.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/librbd_test_la-test_ObjectMap.lo `test -f 'test/librbd/test_ObjectMap.cc' || echo '$(srcdir)/'`test/librbd/test_ObjectMap.cc
 
+test/librbd/journal/librbd_test_la-test_Entries.lo: test/librbd/journal/test_Entries.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/journal/librbd_test_la-test_Entries.lo -MD -MP -MF test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Entries.Tpo -c -o test/librbd/journal/librbd_test_la-test_Entries.lo `test -f 'test/librbd/journal/test_Entries.cc' || echo '$(srcdir)/'`test/librb [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Entries.Tpo test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Entries.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/journal/test_Entries.cc' object='test/librbd/journal/librbd_test_la-test_Entries.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/journal/librbd_test_la-test_Entries.lo `test -f 'test/librbd/journal/test_Entries.cc' || echo '$(srcdir)/'`test/librbd/journal/test_Entries.cc
+
+test/librbd/journal/librbd_test_la-test_Replay.lo: test/librbd/journal/test_Replay.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/journal/librbd_test_la-test_Replay.lo -MD -MP -MF test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Replay.Tpo -c -o test/librbd/journal/librbd_test_la-test_Replay.lo `test -f 'test/librbd/journal/test_Replay.cc' || echo '$(srcdir)/'`test/librbd/jo [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Replay.Tpo test/librbd/journal/$(DEPDIR)/librbd_test_la-test_Replay.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/journal/test_Replay.cc' object='test/librbd/journal/librbd_test_la-test_Replay.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librbd_test_la_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/journal/librbd_test_la-test_Replay.lo `test -f 'test/librbd/journal/test_Replay.cc' || echo '$(srcdir)/'`test/librbd/journal/test_Replay.cc
+
 rgw/librgw_la-librgw.lo: rgw/librgw.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librgw_la_CXXFLAGS) $(CXXFLAGS) -MT rgw/librgw_la-librgw.lo -MD -MP -MF rgw/$(DEPDIR)/librgw_la-librgw.Tpo -c -o rgw/librgw_la-librgw.lo `test -f 'rgw/librgw.cc' || echo '$(srcdir)/'`rgw/librgw.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) rgw/$(DEPDIR)/librgw_la-librgw.Tpo rgw/$(DEPDIR)/librgw_la-librgw.Plo
@@ -22421,6 +23514,20 @@ test/libcephfs/ceph_test_libcephfs-access.obj: test/libcephfs/access.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) -c -o test/libcephfs/ceph_test_libcephfs-access.obj `if test -f 'test/libcephfs/access.cc'; then $(CYGPATH_W) 'test/libcephfs/access.cc'; else $(CYGPATH_W) '$(srcdir)/test/libcephfs/access.cc'; fi`
 
+test/libcephfs/ceph_test_libcephfs-acl.o: test/libcephfs/acl.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) -MT test/libcephfs/ceph_test_libcephfs-acl.o -MD -MP -MF test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Tpo -c -o test/libcephfs/ceph_test_libcephfs-acl.o `test -f 'test/libcephfs/acl.cc' || echo '$(srcdir)/'`test/libcephfs/acl.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Tpo test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/libcephfs/acl.cc' object='test/libcephfs/ceph_test_libcephfs-acl.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) -c -o test/libcephfs/ceph_test_libcephfs-acl.o `test -f 'test/libcephfs/acl.cc' || echo '$(srcdir)/'`test/libcephfs/acl.cc
+
+test/libcephfs/ceph_test_libcephfs-acl.obj: test/libcephfs/acl.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) -MT test/libcephfs/ceph_test_libcephfs-acl.obj -MD -MP -MF test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Tpo -c -o test/libcephfs/ceph_test_libcephfs-acl.obj `if test -f 'test/libcephfs/acl.cc'; then $(CYGPATH_W) 'test/libcephfs/acl.cc'; else $(CYGPATH_W) '$(srcdir)/test/libcephfs/acl.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Tpo test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-acl.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/libcephfs/acl.cc' object='test/libcephfs/ceph_test_libcephfs-acl.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) -c -o test/libcephfs/ceph_test_libcephfs-acl.obj `if test -f 'test/libcephfs/acl.cc'; then $(CYGPATH_W) 'test/libcephfs/acl.cc'; else $(CYGPATH_W) '$(srcdir)/test/libcephfs/acl.cc'; fi`
+
 test/libcephfs/ceph_test_libcephfs-flock.o: test/libcephfs/flock.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ceph_test_libcephfs_CXXFLAGS) $(CXXFLAGS) -MT test/libcephfs/ceph_test_libcephfs-flock.o -MD -MP -MF test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-flock.Tpo -c -o test/libcephfs/ceph_test_libcephfs-flock.o `test -f 'test/libcephfs/flock.cc' || echo '$(srcdir)/'`test/libcephfs/flock.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-flock.Tpo test/libcephfs/$(DEPDIR)/ceph_test_libcephfs-flock.Po
@@ -23779,6 +24886,34 @@ test/common/unittest_bloom_filter-test_bloom_filter.obj: test/common/test_bloom_
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bloom_filter_CXXFLAGS) $(CXXFLAGS) -c -o test/common/unittest_bloom_filter-test_bloom_filter.obj `if test -f 'test/common/test_bloom_filter.cc'; then $(CYGPATH_W) 'test/common/test_bloom_filter.cc'; else $(CYGPATH_W) '$(srcdir)/test/common/test_bloom_filter.cc'; fi`
 
+test/objectstore/unittest_bluefs-test_bluefs.o: test/objectstore/test_bluefs.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluefs_CXXFLAGS) $(CXXFLAGS) -MT test/objectstore/unittest_bluefs-test_bluefs.o -MD -MP -MF test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Tpo -c -o test/objectstore/unittest_bluefs-test_bluefs.o `test -f 'test/objectstore/test_bluefs.cc' || echo '$(srcdir)/'`test/objectstore/test_bluefs.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Tpo test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/objectstore/test_bluefs.cc' object='test/objectstore/unittest_bluefs-test_bluefs.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluefs_CXXFLAGS) $(CXXFLAGS) -c -o test/objectstore/unittest_bluefs-test_bluefs.o `test -f 'test/objectstore/test_bluefs.cc' || echo '$(srcdir)/'`test/objectstore/test_bluefs.cc
+
+test/objectstore/unittest_bluefs-test_bluefs.obj: test/objectstore/test_bluefs.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluefs_CXXFLAGS) $(CXXFLAGS) -MT test/objectstore/unittest_bluefs-test_bluefs.obj -MD -MP -MF test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Tpo -c -o test/objectstore/unittest_bluefs-test_bluefs.obj `if test -f 'test/objectstore/test_bluefs.cc'; then $(CYGPATH_W) 'test/objectstore/test_bluefs.cc'; else $(CYGPATH_W) '$(srcdir)/test/objectstore/test_bluefs.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Tpo test/objectstore/$(DEPDIR)/unittest_bluefs-test_bluefs.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/objectstore/test_bluefs.cc' object='test/objectstore/unittest_bluefs-test_bluefs.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluefs_CXXFLAGS) $(CXXFLAGS) -c -o test/objectstore/unittest_bluefs-test_bluefs.obj `if test -f 'test/objectstore/test_bluefs.cc'; then $(CYGPATH_W) 'test/objectstore/test_bluefs.cc'; else $(CYGPATH_W) '$(srcdir)/test/objectstore/test_bluefs.cc'; fi`
+
+test/objectstore/unittest_bluestore_types-test_bluestore_types.o: test/objectstore/test_bluestore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluestore_types_CXXFLAGS) $(CXXFLAGS) -MT test/objectstore/unittest_bluestore_types-test_bluestore_types.o -MD -MP -MF test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Tpo -c -o test/objectstore/unittest_bluestore_types-test_bluestore_types.o `test -f 'test/objectstore/test_bluestore_types.cc' || echo '$(srcdir)/'`test/objectstore/test_bluestore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Tpo test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/objectstore/test_bluestore_types.cc' object='test/objectstore/unittest_bluestore_types-test_bluestore_types.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluestore_types_CXXFLAGS) $(CXXFLAGS) -c -o test/objectstore/unittest_bluestore_types-test_bluestore_types.o `test -f 'test/objectstore/test_bluestore_types.cc' || echo '$(srcdir)/'`test/objectstore/test_bluestore_types.cc
+
+test/objectstore/unittest_bluestore_types-test_bluestore_types.obj: test/objectstore/test_bluestore_types.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluestore_types_CXXFLAGS) $(CXXFLAGS) -MT test/objectstore/unittest_bluestore_types-test_bluestore_types.obj -MD -MP -MF test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Tpo -c -o test/objectstore/unittest_bluestore_types-test_bluestore_types.obj `if test -f 'test/objectstore/test_bluestore_types.cc'; then $(CYGPATH_W) 'test/objectstore/test_bluest [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Tpo test/objectstore/$(DEPDIR)/unittest_bluestore_types-test_bluestore_types.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/objectstore/test_bluestore_types.cc' object='test/objectstore/unittest_bluestore_types-test_bluestore_types.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bluestore_types_CXXFLAGS) $(CXXFLAGS) -c -o test/objectstore/unittest_bluestore_types-test_bluestore_types.obj `if test -f 'test/objectstore/test_bluestore_types.cc'; then $(CYGPATH_W) 'test/objectstore/test_bluestore_types.cc'; else $(CYGPATH_W) '$(srcdir)/test/objectstore/test_bluestore_types.cc'; fi`
+
 test/unittest_bufferlist-bufferlist.o: test/bufferlist.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_bufferlist_CXXFLAGS) $(CXXFLAGS) -MT test/unittest_bufferlist-bufferlist.o -MD -MP -MF test/$(DEPDIR)/unittest_bufferlist-bufferlist.Tpo -c -o test/unittest_bufferlist-bufferlist.o `test -f 'test/bufferlist.cc' || echo '$(srcdir)/'`test/bufferlist.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/$(DEPDIR)/unittest_bufferlist-bufferlist.Tpo test/$(DEPDIR)/unittest_bufferlist-bufferlist.Po
@@ -23849,6 +24984,118 @@ test/objectstore/unittest_chain_xattr-chain_xattr.obj: test/objectstore/chain_xa
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_chain_xattr_CXXFLAGS) $(CXXFLAGS) -c -o test/objectstore/unittest_chain_xattr-chain_xattr.obj `if test -f 'test/objectstore/chain_xattr.cc'; then $(CYGPATH_W) 'test/objectstore/chain_xattr.cc'; else $(CYGPATH_W) '$(srcdir)/test/objectstore/chain_xattr.cc'; fi`
 
+compressor/unittest_compression_plugin-Compressor.o: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -MT compressor/unittest_compression_plugin-Compressor.o -MD -MP -MF compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Tpo -c -o compressor/unittest_compression_plugin-Compressor.o `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Tpo compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/unittest_compression_plugin-Compressor.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -c -o compressor/unittest_compression_plugin-Compressor.o `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+
+compressor/unittest_compression_plugin-Compressor.obj: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -MT compressor/unittest_compression_plugin-Compressor.obj -MD -MP -MF compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Tpo -c -o compressor/unittest_compression_plugin-Compressor.obj `if test -f 'compressor/Compressor.cc'; then $(CYGPATH_W) 'compressor/Compressor.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/Compressor.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Tpo compressor/$(DEPDIR)/unittest_compression_plugin-Compressor.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/unittest_compression_plugin-Compressor.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -c -o compressor/unittest_compression_plugin-Compressor.obj `if test -f 'compressor/Compressor.cc'; then $(CYGPATH_W) 'compressor/Compressor.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/Compressor.cc'; fi`
+
+test/compressor/unittest_compression_plugin-test_compression_plugin.o: test/compressor/test_compression_plugin.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/unittest_compression_plugin-test_compression_plugin.o -MD -MP -MF test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Tpo -c -o test/compressor/unittest_compression_plugin-test_compression_plugin.o `test -f 'test/compressor/test_compression_plugin.cc' || echo '$(srcdir)/'`test/compresso [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Tpo test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/test_compression_plugin.cc' object='test/compressor/unittest_compression_plugin-test_compression_plugin.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/unittest_compression_plugin-test_compression_plugin.o `test -f 'test/compressor/test_compression_plugin.cc' || echo '$(srcdir)/'`test/compressor/test_compression_plugin.cc
+
+test/compressor/unittest_compression_plugin-test_compression_plugin.obj: test/compressor/test_compression_plugin.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/unittest_compression_plugin-test_compression_plugin.obj -MD -MP -MF test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Tpo -c -o test/compressor/unittest_compression_plugin-test_compression_plugin.obj `if test -f 'test/compressor/test_compression_plugin.cc'; then $(CYGPATH_W) 'test/com [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Tpo test/compressor/$(DEPDIR)/unittest_compression_plugin-test_compression_plugin.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/test_compression_plugin.cc' object='test/compressor/unittest_compression_plugin-test_compression_plugin.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/unittest_compression_plugin-test_compression_plugin.obj `if test -f 'test/compressor/test_compression_plugin.cc'; then $(CYGPATH_W) 'test/compressor/test_compression_plugin.cc'; else $(CYGPATH_W) '$(srcdir)/test/compressor/test_compression_plugin.cc'; fi`
+
+test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.o: test/compressor/test_compression_plugin_snappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.o -MD -MP -MF test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Tpo -c -o test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.o `test -f 'test/compressor/test_compressi [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Tpo test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/test_compression_plugin_snappy.cc' object='test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.o `test -f 'test/compressor/test_compression_plugin_snappy.cc' || echo '$(srcdir)/'`test/compressor/test_compression_plugin_snappy.cc
+
+test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.obj: test/compressor/test_compression_plugin_snappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.obj -MD -MP -MF test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Tpo -c -o test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.obj `if test -f 'test/compressor/test_co [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Tpo test/compressor/$(DEPDIR)/unittest_compression_plugin_snappy-test_compression_plugin_snappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/test_compression_plugin_snappy.cc' object='test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/unittest_compression_plugin_snappy-test_compression_plugin_snappy.obj `if test -f 'test/compressor/test_compression_plugin_snappy.cc'; then $(CYGPATH_W) 'test/compressor/test_compression_plugin_snappy.cc'; else $(CYGPATH_W) '$(srcdir)/test/compressor/test_compression_plugin_snappy.cc'; fi`
+
+compressor/unittest_compression_plugin_snappy-Compressor.o: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/unittest_compression_plugin_snappy-Compressor.o -MD -MP -MF compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Tpo -c -o compressor/unittest_compression_plugin_snappy-Compressor.o `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Tpo compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/unittest_compression_plugin_snappy-Compressor.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/unittest_compression_plugin_snappy-Compressor.o `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+
+compressor/unittest_compression_plugin_snappy-Compressor.obj: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/unittest_compression_plugin_snappy-Compressor.obj -MD -MP -MF compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Tpo -c -o compressor/unittest_compression_plugin_snappy-Compressor.obj `if test -f 'compressor/Compressor.cc'; then $(CYGPATH_W) 'compressor/Compressor.cc'; else $(CYGPATH_W) '$(srcd [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Tpo compressor/$(DEPDIR)/unittest_compression_plugin_snappy-Compressor.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/unittest_compression_plugin_snappy-Compressor.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/unittest_compression_plugin_snappy-Compressor.obj `if test -f 'compressor/Compressor.cc'; then $(CYGPATH_W) 'compressor/Compressor.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/Compressor.cc'; fi`
+
+compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.o: compressor/snappy/CompressionPluginSnappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.o -MD -MP -MF compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Tpo -c -o compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.o `test -f 'compressor/snappy/CompressionPluginSnappy.cc' [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Tpo compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/snappy/CompressionPluginSnappy.cc' object='compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.o `test -f 'compressor/snappy/CompressionPluginSnappy.cc' || echo '$(srcdir)/'`compressor/snappy/CompressionPluginSnappy.cc
+
+compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.obj: compressor/snappy/CompressionPluginSnappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.obj -MD -MP -MF compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Tpo -c -o compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.obj `if test -f 'compressor/snappy/CompressionPluginSna [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Tpo compressor/snappy/$(DEPDIR)/unittest_compression_plugin_snappy-CompressionPluginSnappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/snappy/CompressionPluginSnappy.cc' object='compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_plugin_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/snappy/unittest_compression_plugin_snappy-CompressionPluginSnappy.obj `if test -f 'compressor/snappy/CompressionPluginSnappy.cc'; then $(CYGPATH_W) 'compressor/snappy/CompressionPluginSnappy.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/snappy/CompressionPluginSnappy.cc'; fi`
+
+test/compressor/unittest_compression_snappy-test_compression_snappy.o: test/compressor/test_compression_snappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/unittest_compression_snappy-test_compression_snappy.o -MD -MP -MF test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Tpo -c -o test/compressor/unittest_compression_snappy-test_compression_snappy.o `test -f 'test/compressor/test_compression_snappy.cc' || echo '$(srcdir)/'`test/compresso [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Tpo test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/test_compression_snappy.cc' object='test/compressor/unittest_compression_snappy-test_compression_snappy.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/unittest_compression_snappy-test_compression_snappy.o `test -f 'test/compressor/test_compression_snappy.cc' || echo '$(srcdir)/'`test/compressor/test_compression_snappy.cc
+
+test/compressor/unittest_compression_snappy-test_compression_snappy.obj: test/compressor/test_compression_snappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -MT test/compressor/unittest_compression_snappy-test_compression_snappy.obj -MD -MP -MF test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Tpo -c -o test/compressor/unittest_compression_snappy-test_compression_snappy.obj `if test -f 'test/compressor/test_compression_snappy.cc'; then $(CYGPATH_W) 'test/com [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Tpo test/compressor/$(DEPDIR)/unittest_compression_snappy-test_compression_snappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/compressor/test_compression_snappy.cc' object='test/compressor/unittest_compression_snappy-test_compression_snappy.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -c -o test/compressor/unittest_compression_snappy-test_compression_snappy.obj `if test -f 'test/compressor/test_compression_snappy.cc'; then $(CYGPATH_W) 'test/compressor/test_compression_snappy.cc'; else $(CYGPATH_W) '$(srcdir)/test/compressor/test_compression_snappy.cc'; fi`
+
+compressor/unittest_compression_snappy-Compressor.o: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/unittest_compression_snappy-Compressor.o -MD -MP -MF compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Tpo -c -o compressor/unittest_compression_snappy-Compressor.o `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Tpo compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/unittest_compression_snappy-Compressor.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/unittest_compression_snappy-Compressor.o `test -f 'compressor/Compressor.cc' || echo '$(srcdir)/'`compressor/Compressor.cc
+
+compressor/unittest_compression_snappy-Compressor.obj: compressor/Compressor.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/unittest_compression_snappy-Compressor.obj -MD -MP -MF compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Tpo -c -o compressor/unittest_compression_snappy-Compressor.obj `if test -f 'compressor/Compressor.cc'; then $(CYGPATH_W) 'compressor/Compressor.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/Compressor.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Tpo compressor/$(DEPDIR)/unittest_compression_snappy-Compressor.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/Compressor.cc' object='compressor/unittest_compression_snappy-Compressor.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/unittest_compression_snappy-Compressor.obj `if test -f 'compressor/Compressor.cc'; then $(CYGPATH_W) 'compressor/Compressor.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/Compressor.cc'; fi`
+
+compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.o: compressor/snappy/CompressionPluginSnappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.o -MD -MP -MF compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Tpo -c -o compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.o `test -f 'compressor/snappy/CompressionPluginSnappy.cc' || echo '$(srcdir)/'`compre [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Tpo compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/snappy/CompressionPluginSnappy.cc' object='compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.o `test -f 'compressor/snappy/CompressionPluginSnappy.cc' || echo '$(srcdir)/'`compressor/snappy/CompressionPluginSnappy.cc
+
+compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.obj: compressor/snappy/CompressionPluginSnappy.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -MT compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.obj -MD -MP -MF compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Tpo -c -o compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.obj `if test -f 'compressor/snappy/CompressionPluginSnappy.cc'; then $(CYGPATH_W) ' [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Tpo compressor/snappy/$(DEPDIR)/unittest_compression_snappy-CompressionPluginSnappy.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='compressor/snappy/CompressionPluginSnappy.cc' object='compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_compression_snappy_CXXFLAGS) $(CXXFLAGS) -c -o compressor/snappy/unittest_compression_snappy-CompressionPluginSnappy.obj `if test -f 'compressor/snappy/CompressionPluginSnappy.cc'; then $(CYGPATH_W) 'compressor/snappy/CompressionPluginSnappy.cc'; else $(CYGPATH_W) '$(srcdir)/compressor/snappy/CompressionPluginSnappy.cc'; fi`
+
 test/common/unittest_config-test_config.o: test/common/test_config.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_config_CXXFLAGS) $(CXXFLAGS) -MT test/common/unittest_config-test_config.o -MD -MP -MF test/common/$(DEPDIR)/unittest_config-test_config.Tpo -c -o test/common/unittest_config-test_config.o `test -f 'test/common/test_config.cc' || echo '$(srcdir)/'`test/common/test_config.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/common/$(DEPDIR)/unittest_config-test_config.Tpo test/common/$(DEPDIR)/unittest_config-test_config.Po
@@ -24955,6 +26202,20 @@ test/librbd/unittest_librbd-test_mock_ExclusiveLock.obj: test/librbd/test_mock_E
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/unittest_librbd-test_mock_ExclusiveLock.obj `if test -f 'test/librbd/test_mock_ExclusiveLock.cc'; then $(CYGPATH_W) 'test/librbd/test_mock_ExclusiveLock.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/test_mock_ExclusiveLock.cc'; fi`
 
+test/librbd/unittest_librbd-test_mock_Journal.o: test/librbd/test_mock_Journal.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/unittest_librbd-test_mock_Journal.o -MD -MP -MF test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Tpo -c -o test/librbd/unittest_librbd-test_mock_Journal.o `test -f 'test/librbd/test_mock_Journal.cc' || echo '$(srcdir)/'`test/librbd/test_mock_Journal.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Tpo test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/test_mock_Journal.cc' object='test/librbd/unittest_librbd-test_mock_Journal.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/unittest_librbd-test_mock_Journal.o `test -f 'test/librbd/test_mock_Journal.cc' || echo '$(srcdir)/'`test/librbd/test_mock_Journal.cc
+
+test/librbd/unittest_librbd-test_mock_Journal.obj: test/librbd/test_mock_Journal.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/unittest_librbd-test_mock_Journal.obj -MD -MP -MF test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Tpo -c -o test/librbd/unittest_librbd-test_mock_Journal.obj `if test -f 'test/librbd/test_mock_Journal.cc'; then $(CYGPATH_W) 'test/librbd/test_mock_Journal.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/test_mock_Journal.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Tpo test/librbd/$(DEPDIR)/unittest_librbd-test_mock_Journal.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/test_mock_Journal.cc' object='test/librbd/unittest_librbd-test_mock_Journal.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/unittest_librbd-test_mock_Journal.obj `if test -f 'test/librbd/test_mock_Journal.cc'; then $(CYGPATH_W) 'test/librbd/test_mock_Journal.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/test_mock_Journal.cc'; fi`
+
 test/librbd/exclusive_lock/unittest_librbd-test_mock_AcquireRequest.o: test/librbd/exclusive_lock/test_mock_AcquireRequest.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/exclusive_lock/unittest_librbd-test_mock_AcquireRequest.o -MD -MP -MF test/librbd/exclusive_lock/$(DEPDIR)/unittest_librbd-test_mock_AcquireRequest.Tpo -c -o test/librbd/exclusive_lock/unittest_librbd-test_mock_AcquireRequest.o `test -f 'test/librbd/exclusive_lock/test_mock_AcquireRequest.cc' || echo '$(srcdir)/'`test/librbd/ex [...]
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/exclusive_lock/$(DEPDIR)/unittest_librbd-test_mock_AcquireRequest.Tpo test/librbd/exclusive_lock/$(DEPDIR)/unittest_librbd-test_mock_AcquireRequest.Po
@@ -24983,6 +26244,20 @@ test/librbd/exclusive_lock/unittest_librbd-test_mock_ReleaseRequest.obj: test/li
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/exclusive_lock/unittest_librbd-test_mock_ReleaseRequest.obj `if test -f 'test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc'; then $(CYGPATH_W) 'test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc'; fi`
 
+test/librbd/journal/unittest_librbd-test_mock_Replay.o: test/librbd/journal/test_mock_Replay.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/journal/unittest_librbd-test_mock_Replay.o -MD -MP -MF test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Tpo -c -o test/librbd/journal/unittest_librbd-test_mock_Replay.o `test -f 'test/librbd/journal/test_mock_Replay.cc' || echo '$(srcdir)/'`test/librbd/journal/test_mock_Replay.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Tpo test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/journal/test_mock_Replay.cc' object='test/librbd/journal/unittest_librbd-test_mock_Replay.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/journal/unittest_librbd-test_mock_Replay.o `test -f 'test/librbd/journal/test_mock_Replay.cc' || echo '$(srcdir)/'`test/librbd/journal/test_mock_Replay.cc
+
+test/librbd/journal/unittest_librbd-test_mock_Replay.obj: test/librbd/journal/test_mock_Replay.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/journal/unittest_librbd-test_mock_Replay.obj -MD -MP -MF test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Tpo -c -o test/librbd/journal/unittest_librbd-test_mock_Replay.obj `if test -f 'test/librbd/journal/test_mock_Replay.cc'; then $(CYGPATH_W) 'test/librbd/journal/test_mock_Replay.cc'; else $(CYGPATH_W) '$(srcdi [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Tpo test/librbd/journal/$(DEPDIR)/unittest_librbd-test_mock_Replay.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/journal/test_mock_Replay.cc' object='test/librbd/journal/unittest_librbd-test_mock_Replay.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/journal/unittest_librbd-test_mock_Replay.obj `if test -f 'test/librbd/journal/test_mock_Replay.cc'; then $(CYGPATH_W) 'test/librbd/journal/test_mock_Replay.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/journal/test_mock_Replay.cc'; fi`
+
 test/librbd/object_map/unittest_librbd-test_mock_InvalidateRequest.o: test/librbd/object_map/test_mock_InvalidateRequest.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/object_map/unittest_librbd-test_mock_InvalidateRequest.o -MD -MP -MF test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_InvalidateRequest.Tpo -c -o test/librbd/object_map/unittest_librbd-test_mock_InvalidateRequest.o `test -f 'test/librbd/object_map/test_mock_InvalidateRequest.cc' || echo '$(srcdir)/'`test/librbd/object [...]
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_InvalidateRequest.Tpo test/librbd/object_map/$(DEPDIR)/unittest_librbd-test_mock_InvalidateRequest.Po
@@ -25109,6 +26384,20 @@ test/librbd/object_map/unittest_librbd-test_mock_UpdateRequest.obj: test/librbd/
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/object_map/unittest_librbd-test_mock_UpdateRequest.obj `if test -f 'test/librbd/object_map/test_mock_UpdateRequest.cc'; then $(CYGPATH_W) 'test/librbd/object_map/test_mock_UpdateRequest.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/object_map/test_mock_UpdateRequest.cc'; fi`
 
+test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.o: test/librbd/operation/test_mock_ResizeRequest.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.o -MD -MP -MF test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Tpo -c -o test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.o `test -f 'test/librbd/operation/test_mock_ResizeRequest.cc' || echo '$(srcdir)/'`test/librbd/operation/test_mock_Resize [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Tpo test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/operation/test_mock_ResizeRequest.cc' object='test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.o `test -f 'test/librbd/operation/test_mock_ResizeRequest.cc' || echo '$(srcdir)/'`test/librbd/operation/test_mock_ResizeRequest.cc
+
+test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.obj: test/librbd/operation/test_mock_ResizeRequest.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.obj -MD -MP -MF test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Tpo -c -o test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.obj `if test -f 'test/librbd/operation/test_mock_ResizeRequest.cc'; then $(CYGPATH_W) 'test/librbd/operation/test_mock_ [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Tpo test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_ResizeRequest.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/operation/test_mock_ResizeRequest.cc' object='test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/operation/unittest_librbd-test_mock_ResizeRequest.obj `if test -f 'test/librbd/operation/test_mock_ResizeRequest.cc'; then $(CYGPATH_W) 'test/librbd/operation/test_mock_ResizeRequest.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/operation/test_mock_ResizeRequest.cc'; fi`
+
 test/librbd/operation/unittest_librbd-test_mock_SnapshotCreateRequest.o: test/librbd/operation/test_mock_SnapshotCreateRequest.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/operation/unittest_librbd-test_mock_SnapshotCreateRequest.o -MD -MP -MF test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotCreateRequest.Tpo -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotCreateRequest.o `test -f 'test/librbd/operation/test_mock_SnapshotCreateRequest.cc' || echo '$(srcdir)/'`test/l [...]
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotCreateRequest.Tpo test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotCreateRequest.Po
@@ -25151,6 +26440,20 @@ test/librbd/operation/unittest_librbd-test_mock_SnapshotRemoveRequest.obj: test/
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotRemoveRequest.obj `if test -f 'test/librbd/operation/test_mock_SnapshotRemoveRequest.cc'; then $(CYGPATH_W) 'test/librbd/operation/test_mock_SnapshotRemoveRequest.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc'; fi`
 
+test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.o: test/librbd/operation/test_mock_SnapshotRollbackRequest.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.o -MD -MP -MF test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Tpo -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.o `test -f 'test/librbd/operation/test_mock_SnapshotRollbackRequest.cc' || echo '$(srcdir)/ [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Tpo test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/operation/test_mock_SnapshotRollbackRequest.cc' object='test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.o `test -f 'test/librbd/operation/test_mock_SnapshotRollbackRequest.cc' || echo '$(srcdir)/'`test/librbd/operation/test_mock_SnapshotRollbackRequest.cc
+
+test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.obj: test/librbd/operation/test_mock_SnapshotRollbackRequest.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.obj -MD -MP -MF test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Tpo -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.obj `if test -f 'test/librbd/operation/test_mock_SnapshotRollbackRequest.cc'; then $(CYGP [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Tpo test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotRollbackRequest.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/librbd/operation/test_mock_SnapshotRollbackRequest.cc' object='test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotRollbackRequest.obj `if test -f 'test/librbd/operation/test_mock_SnapshotRollbackRequest.cc'; then $(CYGPATH_W) 'test/librbd/operation/test_mock_SnapshotRollbackRequest.cc'; else $(CYGPATH_W) '$(srcdir)/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc'; fi`
+
 test/librbd/operation/unittest_librbd-test_mock_SnapshotUnprotectRequest.o: test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_librbd_CXXFLAGS) $(CXXFLAGS) -MT test/librbd/operation/unittest_librbd-test_mock_SnapshotUnprotectRequest.o -MD -MP -MF test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotUnprotectRequest.Tpo -c -o test/librbd/operation/unittest_librbd-test_mock_SnapshotUnprotectRequest.o `test -f 'test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc' || echo '$(srcd [...]
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotUnprotectRequest.Tpo test/librbd/operation/$(DEPDIR)/unittest_librbd-test_mock_SnapshotUnprotectRequest.Po
@@ -25655,6 +26958,20 @@ test/common/unittest_throttle-Throttle.obj: test/common/Throttle.cc
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_throttle_CXXFLAGS) $(CXXFLAGS) -c -o test/common/unittest_throttle-Throttle.obj `if test -f 'test/common/Throttle.cc'; then $(CYGPATH_W) 'test/common/Throttle.cc'; else $(CYGPATH_W) '$(srcdir)/test/common/Throttle.cc'; fi`
 
+test/common/unittest_time-test_time.o: test/common/test_time.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_time_CXXFLAGS) $(CXXFLAGS) -MT test/common/unittest_time-test_time.o -MD -MP -MF test/common/$(DEPDIR)/unittest_time-test_time.Tpo -c -o test/common/unittest_time-test_time.o `test -f 'test/common/test_time.cc' || echo '$(srcdir)/'`test/common/test_time.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/common/$(DEPDIR)/unittest_time-test_time.Tpo test/common/$(DEPDIR)/unittest_time-test_time.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/common/test_time.cc' object='test/common/unittest_time-test_time.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_time_CXXFLAGS) $(CXXFLAGS) -c -o test/common/unittest_time-test_time.o `test -f 'test/common/test_time.cc' || echo '$(srcdir)/'`test/common/test_time.cc
+
+test/common/unittest_time-test_time.obj: test/common/test_time.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_time_CXXFLAGS) $(CXXFLAGS) -MT test/common/unittest_time-test_time.obj -MD -MP -MF test/common/$(DEPDIR)/unittest_time-test_time.Tpo -c -o test/common/unittest_time-test_time.obj `if test -f 'test/common/test_time.cc'; then $(CYGPATH_W) 'test/common/test_time.cc'; else $(CYGPATH_W) '$(srcdir)/test/common/test_time.cc'; fi`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/common/$(DEPDIR)/unittest_time-test_time.Tpo test/common/$(DEPDIR)/unittest_time-test_time.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='test/common/test_time.cc' object='test/common/unittest_time-test_time.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_time_CXXFLAGS) $(CXXFLAGS) -c -o test/common/unittest_time-test_time.obj `if test -f 'test/common/test_time.cc'; then $(CYGPATH_W) 'test/common/test_time.cc'; else $(CYGPATH_W) '$(srcdir)/test/common/test_time.cc'; fi`
+
 test/unittest_utf8-utf8.o: test/utf8.cc
 @am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_utf8_CXXFLAGS) $(CXXFLAGS) -MT test/unittest_utf8-utf8.o -MD -MP -MF test/$(DEPDIR)/unittest_utf8-utf8.Tpo -c -o test/unittest_utf8-utf8.o `test -f 'test/utf8.cc' || echo '$(srcdir)/'`test/utf8.cc
 @am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) test/$(DEPDIR)/unittest_utf8-utf8.Tpo test/$(DEPDIR)/unittest_utf8-utf8.Po
@@ -25945,6 +27262,7 @@ clean-libtool:
 	-rm -rf cls/version/.libs cls/version/_libs
 	-rm -rf common/.libs common/_libs
 	-rm -rf compressor/.libs compressor/_libs
+	-rm -rf compressor/snappy/.libs compressor/snappy/_libs
 	-rm -rf crush/.libs crush/_libs
 	-rm -rf erasure-code/.libs erasure-code/_libs
 	-rm -rf erasure-code/isa/.libs erasure-code/isa/_libs
@@ -25965,6 +27283,7 @@ clean-libtool:
 	-rm -rf librbd/.libs librbd/_libs
 	-rm -rf librbd/exclusive_lock/.libs librbd/exclusive_lock/_libs
 	-rm -rf librbd/image/.libs librbd/image/_libs
+	-rm -rf librbd/journal/.libs librbd/journal/_libs
 	-rm -rf librbd/object_map/.libs librbd/object_map/_libs
 	-rm -rf librbd/operation/.libs librbd/operation/_libs
 	-rm -rf log/.libs log/_libs
@@ -25979,11 +27298,13 @@ clean-libtool:
 	-rm -rf perfglue/.libs perfglue/_libs
 	-rm -rf rbd_replay/.libs rbd_replay/_libs
 	-rm -rf rgw/.libs rgw/_libs
+	-rm -rf test/compressor/.libs test/compressor/_libs
 	-rm -rf test/erasure-code/.libs test/erasure-code/_libs
 	-rm -rf test/librados/.libs test/librados/_libs
 	-rm -rf test/librados_test_stub/.libs test/librados_test_stub/_libs
 	-rm -rf test/libradosstriper/.libs test/libradosstriper/_libs
 	-rm -rf test/librbd/.libs test/librbd/_libs
+	-rm -rf test/librbd/journal/.libs test/librbd/journal/_libs
 	-rm -rf test/system/.libs test/system/_libs
 	-rm -rf tracing/.libs tracing/_libs
 install-pythonPYTHON: $(python_PYTHON)
@@ -26290,7 +27611,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 	if test -n "$$am__remaking_logs"; then \
 	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
 	       "recursion detected" >&2; \
-	else \
+	elif test -n "$$redo_logs"; then \
 	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
 	fi; \
 	if $(am__make_dryrun); then :; else \
@@ -26499,6 +27820,27 @@ unittest_erasure_code_example.log: unittest_erasure_code_example$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+unittest_compression_plugin.log: unittest_compression_plugin$(EXEEXT)
+	@p='unittest_compression_plugin$(EXEEXT)'; \
+	b='unittest_compression_plugin'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+unittest_compression_snappy.log: unittest_compression_snappy$(EXEEXT)
+	@p='unittest_compression_snappy$(EXEEXT)'; \
+	b='unittest_compression_snappy'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+unittest_compression_plugin_snappy.log: unittest_compression_plugin_snappy$(EXEEXT)
+	@p='unittest_compression_plugin_snappy$(EXEEXT)'; \
+	b='unittest_compression_plugin_snappy'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 unittest_librados.log: unittest_librados$(EXEEXT)
 	@p='unittest_librados$(EXEEXT)'; \
 	b='unittest_librados'; \
@@ -26562,6 +27904,20 @@ unittest_libcephfs_config.log: unittest_libcephfs_config$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+unittest_bluefs.log: unittest_bluefs$(EXEEXT)
+	@p='unittest_bluefs$(EXEEXT)'; \
+	b='unittest_bluefs'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+unittest_bluestore_types.log: unittest_bluestore_types$(EXEEXT)
+	@p='unittest_bluestore_types$(EXEEXT)'; \
+	b='unittest_bluestore_types'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 unittest_mon_moncap.log: unittest_mon_moncap$(EXEEXT)
 	@p='unittest_mon_moncap$(EXEEXT)'; \
 	b='unittest_mon_moncap'; \
@@ -26716,6 +28072,13 @@ unittest_sloppy_crc_map.log: unittest_sloppy_crc_map$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+unittest_time.log: unittest_time$(EXEEXT)
+	@p='unittest_time$(EXEEXT)'; \
+	b='unittest_time'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 unittest_util.log: unittest_util$(EXEEXT)
 	@p='unittest_util$(EXEEXT)'; \
 	b='unittest_util'; \
@@ -27178,6 +28541,13 @@ test/osd/osd-config.sh.log: test/osd/osd-config.sh
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test/osd/osd-reuse-id.sh.log: test/osd/osd-reuse-id.sh
+	@p='test/osd/osd-reuse-id.sh'; \
+	b='test/osd/osd-reuse-id.sh'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 test/osd/osd-bench.sh.log: test/osd/osd-bench.sh
 	@p='test/osd/osd-bench.sh'; \
 	b='test/osd/osd-bench.sh'; \
@@ -27199,6 +28569,13 @@ test/osd/osd-copy-from.sh.log: test/osd/osd-copy-from.sh
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
+test/osd/osd-markdown.sh.log: test/osd/osd-markdown.sh
+	@p='test/osd/osd-markdown.sh'; \
+	b='test/osd/osd-markdown.sh'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 test/mon/mon-handle-forward.sh.log: test/mon/mon-handle-forward.sh
 	@p='test/mon/mon-handle-forward.sh'; \
 	b='test/mon/mon-handle-forward.sh'; \
@@ -27339,7 +28716,7 @@ install-binPROGRAMS: install-libLTLIBRARIES
 
 installdirs: installdirs-recursive
 installdirs-am:
-	for dir in "$(DESTDIR)$(erasure_codelibdir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(radoslibdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(su_sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(ceph_libexecdir)" "$(DESTDIR)$(ceph_monstore_update_crushdir)" "$(DESTDIR)$(ceph_sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(shell_commondir)" "$(DESTDIR)$(su_sbindir)" "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(bash_completiondir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(libc [...]
+	for dir in "$(DESTDIR)$(compressorlibdir)" "$(DESTDIR)$(erasure_codelibdir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(radoslibdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(su_sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(ceph_libexecdir)" "$(DESTDIR)$(ceph_monstore_update_crushdir)" "$(DESTDIR)$(ceph_sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(shell_commondir)" "$(DESTDIR)$(su_sbindir)" "$(DESTDIR)$(pythondir)" "$(DESTDIR)$(bash_completiondir)" "$(DEST [...]
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: $(BUILT_SOURCES)
@@ -27419,6 +28796,8 @@ distclean-generic:
 	-rm -f common/$(am__dirstamp)
 	-rm -f compressor/$(DEPDIR)/$(am__dirstamp)
 	-rm -f compressor/$(am__dirstamp)
+	-rm -f compressor/snappy/$(DEPDIR)/$(am__dirstamp)
+	-rm -f compressor/snappy/$(am__dirstamp)
 	-rm -f crush/$(DEPDIR)/$(am__dirstamp)
 	-rm -f crush/$(am__dirstamp)
 	-rm -f erasure-code/$(DEPDIR)/$(am__dirstamp)
@@ -27461,6 +28840,8 @@ distclean-generic:
 	-rm -f librbd/exclusive_lock/$(am__dirstamp)
 	-rm -f librbd/image/$(DEPDIR)/$(am__dirstamp)
 	-rm -f librbd/image/$(am__dirstamp)
+	-rm -f librbd/journal/$(DEPDIR)/$(am__dirstamp)
+	-rm -f librbd/journal/$(am__dirstamp)
 	-rm -f librbd/object_map/$(DEPDIR)/$(am__dirstamp)
 	-rm -f librbd/object_map/$(am__dirstamp)
 	-rm -f librbd/operation/$(DEPDIR)/$(am__dirstamp)
@@ -27485,10 +28866,18 @@ distclean-generic:
 	-rm -f objclass/$(am__dirstamp)
 	-rm -f os/$(DEPDIR)/$(am__dirstamp)
 	-rm -f os/$(am__dirstamp)
+	-rm -f os/bluestore/$(DEPDIR)/$(am__dirstamp)
+	-rm -f os/bluestore/$(am__dirstamp)
+	-rm -f os/filestore/$(DEPDIR)/$(am__dirstamp)
+	-rm -f os/filestore/$(am__dirstamp)
 	-rm -f os/fs/$(DEPDIR)/$(am__dirstamp)
 	-rm -f os/fs/$(am__dirstamp)
-	-rm -f os/newstore/$(DEPDIR)/$(am__dirstamp)
-	-rm -f os/newstore/$(am__dirstamp)
+	-rm -f os/keyvaluestore/$(DEPDIR)/$(am__dirstamp)
+	-rm -f os/keyvaluestore/$(am__dirstamp)
+	-rm -f os/kstore/$(DEPDIR)/$(am__dirstamp)
+	-rm -f os/kstore/$(am__dirstamp)
+	-rm -f os/memstore/$(DEPDIR)/$(am__dirstamp)
+	-rm -f os/memstore/$(am__dirstamp)
 	-rm -f osd/$(DEPDIR)/$(am__dirstamp)
 	-rm -f osd/$(am__dirstamp)
 	-rm -f osdc/$(DEPDIR)/$(am__dirstamp)
@@ -27531,6 +28920,8 @@ distclean-generic:
 	-rm -f test/cls_version/$(am__dirstamp)
 	-rm -f test/common/$(DEPDIR)/$(am__dirstamp)
 	-rm -f test/common/$(am__dirstamp)
+	-rm -f test/compressor/$(DEPDIR)/$(am__dirstamp)
+	-rm -f test/compressor/$(am__dirstamp)
 	-rm -f test/crush/$(DEPDIR)/$(am__dirstamp)
 	-rm -f test/crush/$(am__dirstamp)
 	-rm -f test/encoding/$(DEPDIR)/$(am__dirstamp)
@@ -27555,6 +28946,8 @@ distclean-generic:
 	-rm -f test/librbd/$(am__dirstamp)
 	-rm -f test/librbd/exclusive_lock/$(DEPDIR)/$(am__dirstamp)
 	-rm -f test/librbd/exclusive_lock/$(am__dirstamp)
+	-rm -f test/librbd/journal/$(DEPDIR)/$(am__dirstamp)
+	-rm -f test/librbd/journal/$(am__dirstamp)
 	-rm -f test/librbd/object_map/$(DEPDIR)/$(am__dirstamp)
 	-rm -f test/librbd/object_map/$(am__dirstamp)
 	-rm -f test/librbd/operation/$(DEPDIR)/$(am__dirstamp)
@@ -27601,6 +28994,7 @@ maintainer-clean-generic:
 clean: clean-recursive
 
 clean-am: clean-binPROGRAMS clean-checkPROGRAMS \
+	clean-compressorlibLTLIBRARIES \
 	clean-erasure_codelibLTLIBRARIES clean-generic \
 	clean-libLTLIBRARIES clean-libtool clean-local \
 	clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
@@ -27608,7 +29002,7 @@ clean-am: clean-binPROGRAMS clean-checkPROGRAMS \
 	clean-sbinPROGRAMS clean-su_sbinPROGRAMS mostlyclean-am
 
 distclean: distclean-recursive
-	-rm -rf ./$(DEPDIR) arch/$(DEPDIR) auth/$(DEPDIR) auth/cephx/$(DEPDIR) auth/none/$(DEPDIR) auth/unknown/$(DEPDIR) civetweb/src/$(DEPDIR) client/$(DEPDIR) cls/cephfs/$(DEPDIR) cls/hello/$(DEPDIR) cls/journal/$(DEPDIR) cls/lock/$(DEPDIR) cls/log/$(DEPDIR) cls/numops/$(DEPDIR) cls/rbd/$(DEPDIR) cls/refcount/$(DEPDIR) cls/replica_log/$(DEPDIR) cls/rgw/$(DEPDIR) cls/statelog/$(DEPDIR) cls/timeindex/$(DEPDIR) cls/user/$(DEPDIR) cls/version/$(DEPDIR) common/$(DEPDIR) compressor/$(DEPDIR) crush [...]
+	-rm -rf ./$(DEPDIR) arch/$(DEPDIR) auth/$(DEPDIR) auth/cephx/$(DEPDIR) auth/none/$(DEPDIR) auth/unknown/$(DEPDIR) civetweb/src/$(DEPDIR) client/$(DEPDIR) cls/cephfs/$(DEPDIR) cls/hello/$(DEPDIR) cls/journal/$(DEPDIR) cls/lock/$(DEPDIR) cls/log/$(DEPDIR) cls/numops/$(DEPDIR) cls/rbd/$(DEPDIR) cls/refcount/$(DEPDIR) cls/replica_log/$(DEPDIR) cls/rgw/$(DEPDIR) cls/statelog/$(DEPDIR) cls/timeindex/$(DEPDIR) cls/user/$(DEPDIR) cls/version/$(DEPDIR) common/$(DEPDIR) compressor/$(DEPDIR) compr [...]
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-hdr distclean-tags
@@ -27627,7 +29021,8 @@ info-am:
 
 install-data-am: install-bash_completionDATA \
 	install-ceph_monstore_update_crushSCRIPTS \
-	install-ceph_sbinSCRIPTS install-data-local install-docDATA \
+	install-ceph_sbinSCRIPTS install-compressorlibLTLIBRARIES \
+	install-data-local install-docDATA \
 	install-erasure_codelibLTLIBRARIES \
 	install-libcephfs_includeDATA install-librbd_includeDATA \
 	install-pythonPYTHON install-rados_includeDATA \
@@ -27665,7 +29060,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-recursive
-	-rm -rf ./$(DEPDIR) arch/$(DEPDIR) auth/$(DEPDIR) auth/cephx/$(DEPDIR) auth/none/$(DEPDIR) auth/unknown/$(DEPDIR) civetweb/src/$(DEPDIR) client/$(DEPDIR) cls/cephfs/$(DEPDIR) cls/hello/$(DEPDIR) cls/journal/$(DEPDIR) cls/lock/$(DEPDIR) cls/log/$(DEPDIR) cls/numops/$(DEPDIR) cls/rbd/$(DEPDIR) cls/refcount/$(DEPDIR) cls/replica_log/$(DEPDIR) cls/rgw/$(DEPDIR) cls/statelog/$(DEPDIR) cls/timeindex/$(DEPDIR) cls/user/$(DEPDIR) cls/version/$(DEPDIR) common/$(DEPDIR) compressor/$(DEPDIR) crush [...]
+	-rm -rf ./$(DEPDIR) arch/$(DEPDIR) auth/$(DEPDIR) auth/cephx/$(DEPDIR) auth/none/$(DEPDIR) auth/unknown/$(DEPDIR) civetweb/src/$(DEPDIR) client/$(DEPDIR) cls/cephfs/$(DEPDIR) cls/hello/$(DEPDIR) cls/journal/$(DEPDIR) cls/lock/$(DEPDIR) cls/log/$(DEPDIR) cls/numops/$(DEPDIR) cls/rbd/$(DEPDIR) cls/refcount/$(DEPDIR) cls/replica_log/$(DEPDIR) cls/rgw/$(DEPDIR) cls/statelog/$(DEPDIR) cls/timeindex/$(DEPDIR) cls/user/$(DEPDIR) cls/version/$(DEPDIR) common/$(DEPDIR) compressor/$(DEPDIR) compr [...]
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -27685,12 +29080,12 @@ ps-am:
 uninstall-am: uninstall-bash_completionDATA uninstall-binPROGRAMS \
 	uninstall-binSCRIPTS uninstall-ceph_libexecSCRIPTS \
 	uninstall-ceph_monstore_update_crushSCRIPTS \
-	uninstall-ceph_sbinSCRIPTS uninstall-dist_binSCRIPTS \
-	uninstall-docDATA uninstall-erasure_codelibLTLIBRARIES \
-	uninstall-libLTLIBRARIES uninstall-libcephfs_includeDATA \
-	uninstall-librbd_includeDATA uninstall-local \
-	uninstall-pythonPYTHON uninstall-rados_includeDATA \
-	uninstall-radoslibLTLIBRARIES \
+	uninstall-ceph_sbinSCRIPTS uninstall-compressorlibLTLIBRARIES \
+	uninstall-dist_binSCRIPTS uninstall-docDATA \
+	uninstall-erasure_codelibLTLIBRARIES uninstall-libLTLIBRARIES \
+	uninstall-libcephfs_includeDATA uninstall-librbd_includeDATA \
+	uninstall-local uninstall-pythonPYTHON \
+	uninstall-rados_includeDATA uninstall-radoslibLTLIBRARIES \
 	uninstall-radosstriper_includeDATA uninstall-sbinPROGRAMS \
 	uninstall-sbinSCRIPTS uninstall-shell_commonSCRIPTS \
 	uninstall-su_sbinPROGRAMS uninstall-su_sbinSCRIPTS
@@ -27700,8 +29095,9 @@ uninstall-am: uninstall-bash_completionDATA uninstall-binPROGRAMS \
 
 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am all-local \
 	check check-TESTS check-am clean clean-binPROGRAMS \
-	clean-checkPROGRAMS clean-erasure_codelibLTLIBRARIES \
-	clean-generic clean-libLTLIBRARIES clean-libtool clean-local \
+	clean-checkPROGRAMS clean-compressorlibLTLIBRARIES \
+	clean-erasure_codelibLTLIBRARIES clean-generic \
+	clean-libLTLIBRARIES clean-libtool clean-local \
 	clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
 	clean-noinstPROGRAMS clean-radoslibLTLIBRARIES \
 	clean-sbinPROGRAMS clean-su_sbinPROGRAMS cscopelist-am ctags \
@@ -27712,10 +29108,11 @@ uninstall-am: uninstall-bash_completionDATA uninstall-binPROGRAMS \
 	install-binPROGRAMS install-binSCRIPTS \
 	install-ceph_libexecSCRIPTS \
 	install-ceph_monstore_update_crushSCRIPTS \
-	install-ceph_sbinSCRIPTS install-data install-data-am \
-	install-data-local install-dist_binSCRIPTS install-docDATA \
-	install-dvi install-dvi-am install-erasure_codelibLTLIBRARIES \
-	install-exec install-exec-am install-exec-local install-html \
+	install-ceph_sbinSCRIPTS install-compressorlibLTLIBRARIES \
+	install-data install-data-am install-data-local \
+	install-dist_binSCRIPTS install-docDATA install-dvi \
+	install-dvi-am install-erasure_codelibLTLIBRARIES install-exec \
+	install-exec-am install-exec-local install-html \
 	install-html-am install-info install-info-am \
 	install-libLTLIBRARIES install-libcephfs_includeDATA \
 	install-librbd_includeDATA install-man install-pdf \
@@ -27731,16 +29128,18 @@ uninstall-am: uninstall-bash_completionDATA uninstall-binPROGRAMS \
 	uninstall-bash_completionDATA uninstall-binPROGRAMS \
 	uninstall-binSCRIPTS uninstall-ceph_libexecSCRIPTS \
 	uninstall-ceph_monstore_update_crushSCRIPTS \
-	uninstall-ceph_sbinSCRIPTS uninstall-dist_binSCRIPTS \
-	uninstall-docDATA uninstall-erasure_codelibLTLIBRARIES \
-	uninstall-libLTLIBRARIES uninstall-libcephfs_includeDATA \
-	uninstall-librbd_includeDATA uninstall-local \
-	uninstall-pythonPYTHON uninstall-rados_includeDATA \
-	uninstall-radoslibLTLIBRARIES \
+	uninstall-ceph_sbinSCRIPTS uninstall-compressorlibLTLIBRARIES \
+	uninstall-dist_binSCRIPTS uninstall-docDATA \
+	uninstall-erasure_codelibLTLIBRARIES uninstall-libLTLIBRARIES \
+	uninstall-libcephfs_includeDATA uninstall-librbd_includeDATA \
+	uninstall-local uninstall-pythonPYTHON \
+	uninstall-rados_includeDATA uninstall-radoslibLTLIBRARIES \
 	uninstall-radosstriper_includeDATA uninstall-sbinPROGRAMS \
 	uninstall-sbinSCRIPTS uninstall-shell_commonSCRIPTS \
 	uninstall-su_sbinPROGRAMS uninstall-su_sbinSCRIPTS
 
+.PRECIOUS: Makefile
+
 
 # display the output of failed check_SCRIPTS after a failed make check
 export VERBOSE = true
@@ -27803,6 +29202,9 @@ erasure-code/shec/ErasureCodePluginSelectShec.cc: ./ceph_ver.h
 @WITH_BETTER_YASM_ELF64_TRUE at erasure-code/isa/ErasureCodePluginIsa.cc: ./ceph_ver.h
 erasure-code/ErasureCodePlugin.cc: ./ceph_ver.h
 
+compressor/snappy/CompressionPluginSnappy.cc: ./ceph_ver.h
+compressor/CompressionPlugin.cc: ./ceph_ver.h
+
 common/PluginRegistry.cc: ./ceph_ver.h
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at test/erasure-code/ErasureCodePluginExample.cc: ./ceph_ver.h
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at test/erasure-code/ErasureCodePluginMissingEntryPoint.cc: ./ceph_ver.h
@@ -27817,6 +29219,7 @@ common/PluginRegistry.cc: ./ceph_ver.h
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at test/erasure-code/TestShecPluginSSE4.cc: ./ceph_ver.h
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at test/erasure-code/TestShecPluginSSE3.cc: ./ceph_ver.h
 @ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at test/erasure-code/TestShecPluginGeneric.cc: ./ceph_ver.h
+ at ENABLE_SERVER_TRUE@@WITH_OSD_TRUE at test/compressor/compressor_plugin_example.cc: ./ceph_ver.h
 
 # target to build but not run the unit tests
 unittests:: $(check_PROGRAMS)
diff --git a/src/acconfig.h.in b/src/acconfig.h.in
index fd61271..25af9b5 100644
--- a/src/acconfig.h.in
+++ b/src/acconfig.h.in
@@ -417,8 +417,7 @@
 /* Define to 1 if the system has the type `__u8'. */
 #undef HAVE___U8
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Defined if you do not have atomic_ops */
diff --git a/src/ceph-detect-init/tests/test_all.py b/src/ceph-detect-init/tests/test_all.py
index 4c408f9..f444eeb 100644
--- a/src/ceph-detect-init/tests/test_all.py
+++ b/src/ceph-detect-init/tests/test_all.py
@@ -44,15 +44,18 @@ class TestCephDetectInit(testtools.TestCase):
         self.assertEqual('sysvinit', centos.choose_init())
 
     def test_debian(self):
-        with mock.patch('ceph_detect_init.debian.distro',
-                        'debian'):
+        with mock.patch.multiple('ceph_detect_init.debian',
+                                 distro='debian',
+                                 codename='wheezy'):
             self.assertEqual('sysvinit', debian.choose_init())
-        with mock.patch('ceph_detect_init.debian.distro',
-                        'ubuntu'):
+        with mock.patch.multiple('ceph_detect_init.debian',
+                                 distro='ubuntu',
+                                 codename='trusty'):
             self.assertEqual('upstart', debian.choose_init())
-            with mock.patch('ceph_detect_init.debian.codename',
-                            'vivid'):
-                self.assertEqual('systemd', debian.choose_init())
+        with mock.patch.multiple('ceph_detect_init.debian',
+                                 distro='ubuntu',
+                                 codename='vivid'):
+            self.assertEqual('systemd', debian.choose_init())
 
     def test_fedora(self):
         with mock.patch('ceph_detect_init.fedora.release',
diff --git a/src/ceph-disk b/src/ceph-disk
index 0a91fa9..4c9de91 100755
--- a/src/ceph-disk
+++ b/src/ceph-disk
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 #
+# Copyright (C) 2015 Red Hat <contact at redhat.com>
 # Copyright (C) 2014 Inktank <info at inktank.com>
 # Copyright (C) 2014 Cloudwatt <libre.licensing at cloudwatt.com>
 # Copyright (C) 2014 Catalyst.net Ltd
@@ -23,7 +24,6 @@ import fcntl
 import json
 import logging
 import os
-import os.path
 import platform
 import re
 import subprocess
@@ -87,7 +87,7 @@ links.
 udev triggers 'ceph-disk activate <dev>' or 'ceph-disk
 activate-journal <dev>' based on the partition type.
 
-On old distros (e.g., RHEL6), the blkid installed does not recognized
+On old distros (e.g., RHEL6), the blkid installed does not recognize
 GPT partition metadata and the /dev/disk/by-partuuid etc. links aren't
 present.  We have a horrible hack in the form of ceph-disk-udev that
 parses gparted output to create the symlinks above and triggers the
@@ -134,6 +134,8 @@ MOUNT_OPTIONS = dict(
 
 MKFS_ARGS = dict(
     btrfs=[
+        # btrfs requires -f, for the same reason as xfs (see comment below)
+        '-f',
         '-m', 'single',
         '-l', '32768',
         '-n', '32768',
@@ -272,7 +274,7 @@ def is_upstart():
     """
     Detect whether upstart is running
     """
-    (out, _) = command(['init', '--version'])
+    (out, err, _) = command(['init', '--version'])
     if 'upstart' in out:
         return True
     return False
@@ -355,9 +357,10 @@ def command(arguments, **kwargs):
     process = subprocess.Popen(
         arguments,
         stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
         **kwargs)
-    out, _ = process.communicate()
-    return out, process.returncode
+    out, err = process.communicate()
+    return out, err, process.returncode
 
 
 def command_check_call(arguments):
@@ -554,21 +557,17 @@ def get_partition_dev(dev, pnum):
         raise Error('partition %d for %s does not appear to exist' % (pnum, dev))
 
 
-def list_all_partitions(names):
+def list_all_partitions():
     """
     Return a list of devices and partitions
     """
-    if names:
-        names = map(lambda x: re.sub('^/dev/', '', x), names)
-    else:
-        names = os.listdir('/sys/block')
+    names = os.listdir('/sys/block')
     dev_part_list = {}
     for name in names:
-        LOG.debug("list_all_partitions: " + name)
         # /dev/fd0 may hang http://tracker.ceph.com/issues/6827
         if re.match(r'^fd\d$', name):
             continue
-        dev_part_list[name] = list_partitions(os.path.join('/dev', name))
+        dev_part_list[name] = list_partitions(get_dev_path(name))
     return dev_part_list
 
 def list_partitions(dev):
@@ -596,7 +595,7 @@ def list_partitions_device(dev):
     Return a list of partitions on the given device name
     """
     partitions = []
-    basename = os.path.basename(dev)
+    basename = get_dev_name(dev)
     for name in os.listdir(block_path(dev)):
         if name.startswith(basename):
             partitions.append(name)
@@ -617,7 +616,7 @@ def get_partition_base(dev):
     # find the base
     for basename in os.listdir('/sys/block'):
         if os.path.exists(os.path.join('/sys/block', basename, name)):
-            return '/dev/' + basename
+            return get_dev_path(basename)
     raise Error('no parent device for partition', dev)
 
 def is_partition_mpath(dev):
@@ -894,11 +893,11 @@ def path_set_context(path):
            )
 
 def _check_output(args=None, **kwargs):
-    out, ret = command(args, **kwargs)
+    out, err, ret = command(args, **kwargs)
     if ret:
         cmd = args[0]
         error = subprocess.CalledProcessError(ret, cmd)
-        error.output = out
+        error.output = out + err
         raise error
     return out
 
@@ -912,7 +911,7 @@ def get_conf(cluster, variable):
     :return: The variable value or None.
     """
     try:
-        out, ret = command(
+        out, err, ret = command(
             [
                 'ceph-conf',
                 '--cluster={cluster}'.format(
@@ -925,7 +924,7 @@ def get_conf(cluster, variable):
             close_fds=True,
             )
     except OSError as e:
-        raise Error('error executing ceph-conf', e)
+        raise Error('error executing ceph-conf', e, err)
     if ret == 1:
         # config entry not found
         return None
@@ -1028,7 +1027,7 @@ def get_or_create_dmcrypt_key(
         raise Error('unable to read or create dm-crypt key', path)
 
 
-def dmcrypt_map(
+def _dmcrypt_map(
     rawdev,
     keypath,
     _uuid,
@@ -1091,17 +1090,17 @@ def dmcrypt_unmap(
     """
     Removes the dmcrypt device with the given UUID.
     """
-    args = [
-        'cryptsetup',
-        'remove',
-        _uuid
-    ]
-
-    try:
-        command_check_call(args)
-
-    except subprocess.CalledProcessError as e:
-        raise Error('unable to unmap device', _uuid, e)
+    retries = 0
+    while True:
+        try:
+            command_check_call(['cryptsetup', 'remove', _uuid])
+            break
+        except subprocess.CalledProcessError as e:
+            if retries == 10:
+                raise Error('unable to unmap device', _uuid, e)
+            else:
+                time.sleep(0.5 + retries * 1.0)
+                retries += 1
 
 
 def mount(
@@ -1215,6 +1214,7 @@ def get_free_partition_index(dev):
 
     if not lines:
         raise Error('parted failed to output anything')
+    LOG.debug('get_free_partition_index: analyzing ' + lines)
     if ('CHS;' not in lines and
         'CYL;' not in lines and
         'BYT;' not in lines):
@@ -1243,14 +1243,30 @@ def update_partition(dev, description):
     group changes etc. are complete.
     """
     LOG.debug('Calling partprobe on %s device %s', description, dev)
-    command_check_call(['udevadm', 'settle'])
-    command_check_call(['partprobe', dev])
-    command_check_call(['udevadm', 'settle'])
+    partprobe_ok = False
+    error = 'unknown error'
+    for i in (1, 2, 3, 4, 5):
+        command_check_call(['udevadm', 'settle', '--timeout=600'])
+        try:
+            _check_output(['partprobe', dev])
+            partprobe_ok = True
+            break
+        except subprocess.CalledProcessError as e:
+            error = e.output
+            if ('unable to inform the kernel' not in error and
+                'Device or resource busy' not in error):
+                raise
+            LOG.debug('partprobe %s failed : %s (ignored, waiting 60s)' % (dev, error))
+            time.sleep(60)
+    if not partprobe_ok:
+        raise Error('partprobe %s failed : %s' % (dev, error))
+    command_check_call(['udevadm', 'settle', '--timeout=600'])
 
 def zap(dev):
     """
     Destroy the partition table and content of a given disk.
     """
+    dev = os.path.realpath(dev)
     dmode = os.stat(dev).st_mode
     if not stat.S_ISBLK(dmode) or is_partition(dev):
         raise Error('not full block device; cannot zap', dev)
@@ -1599,6 +1615,11 @@ def prepare_dev(
     if is_partition(data):
         LOG.debug('OSD data device %s is a partition', data)
         rawdev = data
+
+        ptype = get_partition_type(rawdev)
+        if ptype != ptype_osd:
+                LOG.warning('incorrect partition UUID: %s, expected %s'
+                            % (ptype, ptype_osd))
     else:
         LOG.debug('Creating osd partition on %s', data)
         try:
@@ -1623,7 +1644,7 @@ def prepare_dev(
 
     dev = None
     if osd_dm_keypath:
-        dev = dmcrypt_map(
+        dev = _dmcrypt_map(
                 rawdev=rawdev,
                 keypath=osd_dm_keypath,
                 _uuid=osd_uuid,
@@ -1697,17 +1718,17 @@ def prepare_dev(
                             os.path.basename(rawdev)])
 
 def check_journal_reqs(args):
-    _, allows_journal = command([
+    _, _, allows_journal = command([
         'ceph-osd', '--check-allows-journal',
         '-i', '0',
         '--cluster', args.cluster,
     ])
-    _, wants_journal = command([
+    _, _, wants_journal = command([
         'ceph-osd', '--check-wants-journal',
         '-i', '0',
         '--cluster', args.cluster,
     ])
-    _, needs_journal = command([
+    _, _, needs_journal = command([
         'ceph-osd', '--check-needs-journal',
         '-i', '0',
         '--cluster', args.cluster,
@@ -2205,6 +2226,27 @@ def detect_fstype(
     fstype = must_be_one_line(fstype)
     return fstype
 
+def dmcrypt_map(dev, dmcrypt_key_dir):
+    ptype = get_partition_type(dev)
+    if ptype in [DMCRYPT_OSD_UUID, DMCRYPT_JOURNAL_UUID]:
+        luks = False
+        cryptsetup_parameters = ['--key-size', '256']
+    elif ptype in [DMCRYPT_LUKS_OSD_UUID, DMCRYPT_LUKS_JOURNAL_UUID]:
+        luks = True
+        cryptsetup_parameters = []
+    else:
+        raise Error('--dmcrypt called for dev %s with invalid ptype %s'
+                    % (dev, ptype))
+    part_uuid = get_partition_uuid(dev)
+    dmcrypt_key_path = get_dmcrypt_key_path(part_uuid, dmcrypt_key_dir, luks)
+    return _dmcrypt_map(
+        rawdev=dev,
+        keypath=dmcrypt_key_path,
+        _uuid=part_uuid,
+        cryptsetup_parameters=cryptsetup_parameters,
+        luks=luks,
+        format_dev=False,
+    )
 
 def mount_activate(
     dev,
@@ -2216,29 +2258,8 @@ def mount_activate(
     ):
 
     if dmcrypt:
-            # dev corresponds to a dmcrypt cyphertext device - map it before
-            # proceeding.
-            rawdev = dev
-            ptype = get_partition_type(rawdev)
-            if ptype in [DMCRYPT_OSD_UUID]:
-                luks = False
-                cryptsetup_parameters = ['--key-size', '256']
-            elif ptype in [DMCRYPT_LUKS_OSD_UUID]:
-                luks = True
-                cryptsetup_parameters = []
-            else:
-                raise Error('activate --dmcrypt called for invalid dev %s' % (dev))
-            part_uuid = get_partition_uuid(rawdev)
-            dmcrypt_key_path = get_dmcrypt_key_path(part_uuid, dmcrypt_key_dir, luks)
-            dev = dmcrypt_map(
-                    rawdev=rawdev,
-                    keypath=dmcrypt_key_path,
-                    _uuid=part_uuid,
-                    cryptsetup_parameters=cryptsetup_parameters,
-                    luks=luks,
-                    format_dev=False,
-                    )
-
+        part_uuid = get_partition_uuid(dev)
+        dev = dmcrypt_map(dev, dmcrypt_key_dir)
     try:
         fstype = detect_fstype(dev=dev)
     except (subprocess.CalledProcessError,
@@ -2590,7 +2611,7 @@ def _check_osd_status(cluster, osd_id):
     LOG.info("Checking osd id: %s ..." % osd_id)
     found = False
     status_code = 0
-    out, ret = command(
+    out, err, ret = command(
             [
                 'ceph',
                 'osd',
@@ -2646,11 +2667,18 @@ def _remove_osd_directory_files(mounted_path, cluster):
 
 
 def main_deactivate(args):
+    activate_lock.acquire()  # noqa
+    try:
+        main_deactivate_locked(args)
+    finally:
+        activate_lock.release()  # noqa
+
+def main_deactivate_locked(args):
     osd_id = args.deactivate_by_id
     path = args.path
     target_dev = None
     dmcrypt = False
-    devices = list_devices([])
+    devices = list_devices()
 
     # list all devices and found we need
     for device in devices:
@@ -2671,7 +2699,6 @@ def main_deactivate(args):
     osd_id = target_dev['whoami']
     part_type = target_dev['ptype']
     mounted_path = target_dev['mount']
-    part_uuid = target_dev['uuid']
     if part_type == DMCRYPT_OSD_UUID or \
        part_type == DMCRYPT_LUKS_OSD_UUID:
         dmcrypt = True
@@ -2703,11 +2730,10 @@ def main_deactivate(args):
     unmount(mounted_path)
     LOG.info("Umount `%s` successfully.", mounted_path)
 
-    # we remove the crypt map and device mapper (if dmcrypt is True)
     if dmcrypt:
-        dmcrypt_unmap(part_uuid)
-
-    return
+        dmcrypt_unmap(target_dev['uuid'])
+        if 'journal_uuid' in target_dev:
+            dmcrypt_unmap(target_dev['journal_uuid'])
 
 ###########################
 
@@ -2745,6 +2771,19 @@ def _deallocate_osd_id(cluster, osd_id):
                 ],
             )
 
+def destroy_lookup_device(args, predicate, description):
+    devices = list_devices()
+    for device in devices:
+        for partition in device.get('partitions', []):
+            if partition['dmcrypt']:
+                dmcrypt_path = dmcrypt_map(partition['path'],
+                                           args.dmcrypt_key_dir)
+                list_dev_osd(dmcrypt_path, {}, partition)
+                dmcrypt_unmap(partition['uuid'])
+            if predicate(partition):
+                return partition
+    raise Error('found no device matching ', description)
+
 def main_destroy(args):
     osd_id = args.destroy_by_id
     path = args.path
@@ -2752,66 +2791,20 @@ def main_destroy(args):
     dmcrypt = False
     target_dev = None
 
-    if path and not is_partition(path):
-        raise Error("It should input the partition dev!!")
+    if path:
+        if not is_partition(path):
+            raise Error(path + " must be a partition device")
+        path = os.path.realpath(path)
+
+    if path:
+        target_dev = destroy_lookup_device(
+            args, lambda x: x.get('path') == path,
+            path)
+    elif osd_id:
+        target_dev = destroy_lookup_device(
+            args, lambda x: x.get('whoami') == osd_id,
+            'osd id ' + str(osd_id))
 
-    devices = list_devices([])
-    for device in devices:
-        if 'partitions' in device:
-            for dev_part in device.get('partitions'):
-                """
-                re-map the unmapped device for check device information
-                we need more overhead if user pass the osd_id
-
-                the reason is we must re-map the dmcrypt map that we can
-                confirm the osd_id match with whoami
-                """
-                if path and 'path' in dev_part and \
-                   dev_part['path'] != path:
-                    continue
-                elif osd_id and 'whoami' in dev_part and \
-                     dev_part['whoami'] != osd_id:
-                    continue
-                elif path and dev_part['path'] == path and \
-                   not dev_part['dmcrypt']:
-                    target_dev = dev_part
-                    break
-                elif osd_id and 'whoami' in dev_part and \
-                     dev_part['whoami'] == osd_id and not dev_part['dmcrypt']:
-                    target_dev = dev_part
-                    break
-                elif dev_part['dmcrypt'] and \
-                     not dev_part['dmcrypt']['holders']:
-                    rawdev = dev_part['path']
-                    ptype = dev_part['ptype']
-                    if ptype in [DMCRYPT_OSD_UUID]:
-                        luks = False
-                        cryptsetup_parameters = ['--key-size', '256']
-                    elif ptype in [DMCRYPT_LUKS_OSD_UUID]:
-                        luks = True
-                        cryptsetup_parameters = []
-                    else:
-                        raise Error('Cannot identify the device partiton type!!!')
-                    part_uuid = dev_part['uuid']
-                    dmcrypt_key_path = get_dmcrypt_key_path(part_uuid, dmcrypt_key_dir, luks)
-                    dev_path = dmcrypt_map(
-                            rawdev=rawdev,
-                            keypath=dmcrypt_key_path,
-                            _uuid=part_uuid,
-                            cryptsetup_parameters=cryptsetup_parameters,
-                            luks=luks,
-                            format_dev=False,
-                            )
-                    devices = list_devices([rawdev])
-                    for dev in devices:
-                        if (path and 'path' in dev and dev['path'] == path) or \
-                           (osd_id and 'whoami' in dev and dev['whoami'] == osd_id):
-                            dmcrypt = True
-                            target_dev = dev
-                            break
-                    dmcrypt_unmap(part_uuid)
-    if not target_dev:
-        raise Error('Cannot find any match device!!')
     osd_id = target_dev['whoami']
     dev_path = target_dev['path']
     journal_part_uuid = target_dev['journal_uuid']
@@ -2844,7 +2837,7 @@ def main_destroy(args):
     # Check zap flag. If we found zap flag, we need to find device for
     # destroy this osd data.
     if args.zap is True:
-        # earse the osd data
+        # erase the osd data
         LOG.info("Prepare to zap the device %s" % base_dev)
         zap(base_dev)
 
@@ -2896,28 +2889,7 @@ def main_activate_journal(args):
     activate_lock.acquire()  # noqa
     try:
         if args.dmcrypt:
-            # journal dev corresponds to a dmcrypt cyphertext device - map
-            # it before proceeding.
-            rawdev = args.dev
-            ptype = get_partition_type(rawdev)
-            if ptype in [DMCRYPT_JOURNAL_UUID]:
-                luks = False
-                cryptsetup_parameters = ['--key-size', '256']
-            elif ptype in [DMCRYPT_LUKS_JOURNAL_UUID]:
-                luks = True
-                cryptsetup_parameters = []
-            else:
-                raise Error('activate-journal --dmcrypt called for invalid dev %s' % (rawdev))
-            part_uuid = get_partition_uuid(rawdev)
-            dmcrypt_key_path = get_dmcrypt_key_path(part_uuid, args.dmcrypt_key_dir, luks)
-            dev = dmcrypt_map(
-                    rawdev=rawdev,
-                    keypath=dmcrypt_key_path,
-                    _uuid=part_uuid,
-                    cryptsetup_parameters=cryptsetup_parameters,
-                    luks=luks,
-                    format_dev=False,
-                    )
+            dev = dmcrypt_map(args.dev, args.dmcrypt_key_dir)
         else:
             dev = args.dev
 
@@ -2937,6 +2909,7 @@ def main_activate_journal(args):
             init=args.mark_init,
             dmcrypt=args.dmcrypt,
             dmcrypt_key_dir=args.dmcrypt_key_dir,
+            reactivate=args.reactivate,
             )
 
         start_daemon(
@@ -3031,7 +3004,7 @@ def get_oneliner(base, name):
 
 
 def get_dev_fs(dev):
-    fscheck, _ = command(
+    fscheck, _, _ = command(
         [
             'blkid',
             '-s',
@@ -3056,19 +3029,29 @@ def split_dev_base_partnum(dev):
     return (base, partnum)
 
 def get_partition_type(part):
-    return get_sgdisk_partition_info(part, 'Partition GUID code: (\S+)')
+    return get_blkid_partition_info(part, 'ID_PART_ENTRY_TYPE')
 
 def get_partition_uuid(part):
-    return get_sgdisk_partition_info(part, 'Partition unique GUID: (\S+)')
+    return get_blkid_partition_info(part, 'ID_PART_ENTRY_UUID')
 
-def get_sgdisk_partition_info(dev, regexp):
-    (base, partnum) = split_dev_base_partnum(dev)
-    out, _ = command(['sgdisk', '-i', partnum, base])
+def get_blkid_partition_info(dev, what=None):
+    out, _, _ = command(
+        [
+            'blkid',
+            '-o',
+            'udev',
+            '-p',
+            dev,
+        ]
+    )
+    p = {}
     for line in out.splitlines():
-        m = re.match(regexp, line)
-        if m:
-            return m.group(1).lower()
-    return None
+        (key, value) = line.split('=')
+        p[key] = value
+    if what:
+        return p.get(what)
+    else:
+        return p
 
 def more_osd_info(path, uuid_map, desc):
     desc['ceph_fsid'] = get_oneliner(path, 'ceph_fsid')
@@ -3126,15 +3109,8 @@ def list_format_dev_plain(dev, devices=[], prefix=''):
         if not dmcrypt['holders']:
             desc = ['ceph data (dmcrypt %s)' % dmcrypt['type'], 'not currently mapped']
         elif len(dmcrypt['holders']) == 1:
-            holder = '/dev/' + dmcrypt['holders'][0]
-            # re-list with the dm-x path
-            devices = list_devices([holder])
-            def lookup_dev(devices, path):
-                for device in devices:
-                    if device['path'] == path:
-                        return device
-            holder_dev = lookup_dev(devices, holder)
-            desc = ['ceph data (dmcrypt %s %s)' % (dmcrypt['type'], holder)] + list_format_more_osd_info_plain(holder_dev)
+            holder = get_dev_path(dmcrypt['holders'][0])
+            desc = ['ceph data (dmcrypt %s %s)' % (dmcrypt['type'], holder)] + list_format_more_osd_info_plain(dev)
         else:
             desc = ['ceph data (dmcrypt %s)' % dmcrypt['type'], 'holders: ' + ','.join(dmcrypt['holders'])]
     elif dev['ptype'] == JOURNAL_UUID:
@@ -3145,7 +3121,8 @@ def list_format_dev_plain(dev, devices=[], prefix=''):
                           DMCRYPT_LUKS_JOURNAL_UUID):
         dmcrypt = dev['dmcrypt']
         if dmcrypt['holders'] and len(dmcrypt['holders']) == 1:
-            desc = ['ceph journal (dmcrypt %s /dev/%s)' % (dmcrypt['type'], dmcrypt['holders'][0])]
+            holder = get_dev_path(dmcrypt['holders'][0])
+            desc = ['ceph journal (dmcrypt %s %s)' % (dmcrypt['type'], holder)]
         else:
             desc = ['ceph journal (dmcrypt %s)' % dmcrypt['type']]
         if dev.get('journal_for'):
@@ -3160,9 +3137,9 @@ def list_format_dev_plain(dev, devices=[], prefix=''):
             desc.append('mounted on %s' % dev['mount'])
     return '%s%s %s' % (prefix, dev['path'], ', '.join(desc))
 
-def list_format_plain(devices):
+def list_format_plain(devices, selected_devices):
     lines = []
-    for device in devices:
+    for device in selected_devices:
         if device.get('partitions'):
             lines.append('%s :' % device['path'])
             for p in sorted(device['partitions']):
@@ -3200,14 +3177,14 @@ def list_dev(dev, uuid_map, journal_map):
         info['dmcrypt']['holders'] = holders
         info['dmcrypt']['type'] = 'plain'
         if len(holders) == 1:
-            list_dev_osd('/dev/' + holders[0], uuid_map, info)
+            list_dev_osd(get_dev_path(holders[0]), uuid_map, info)
     elif ptype == DMCRYPT_LUKS_OSD_UUID:
         holders = is_held(dev)
         info['type'] = 'data'
         info['dmcrypt']['holders'] = holders
         info['dmcrypt']['type'] = 'LUKS'
         if len(holders) == 1:
-            list_dev_osd('/dev/' + holders[0], uuid_map, info)
+            list_dev_osd(get_dev_path(holders[0]), uuid_map, info)
     elif ptype in (JOURNAL_UUID, MPATH_JOURNAL_UUID):
         info['type'] = 'journal'
         if ptype == MPATH_JOURNAL_UUID:
@@ -3242,8 +3219,8 @@ def list_dev(dev, uuid_map, journal_map):
 
     return info
 
-def list_devices(path):
-    partmap = list_all_partitions(path)
+def list_devices():
+    partmap = list_all_partitions()
 
     uuid_map = {}
     journal_map = {}
@@ -3265,7 +3242,7 @@ def list_devices(path):
                     holders = is_held(dev)
                     if len(holders) != 1:
                         continue
-                    dev_to_mount = '/dev/' + holders[0]
+                    dev_to_mount = get_dev_path(holders[0])
                 else:
                     dev_to_mount = dev
 
@@ -3303,11 +3280,25 @@ def list_devices(path):
     return devices
 
 def main_list(args):
-    devices = list_devices(args.path)
+    devices = list_devices()
+    if args.path:
+        paths = []
+        for path in args.path:
+            if os.path.exists(path):
+                paths.append(os.path.realpath(path))
+            else:
+                paths.append(path)
+        selected_devices = []
+        for device in devices:
+            for path in paths:
+                if re.search(path + '$', device['path']):
+                    selected_devices.append(device)
+    else:
+        selected_devices = devices
     if args.format == 'json':
-        print json.dumps(devices)
+        print json.dumps(selected_devices)
     else:
-        output = list_format_plain(devices)
+        output = list_format_plain(devices, selected_devices)
         if output:
             print output
 
@@ -3829,6 +3820,11 @@ def make_activate_journal_parser(subparsers):
         default='/etc/ceph/dmcrypt-keys',
         help='directory where dm-crypt keys are stored',
         )
+    activate_journal_parser.add_argument(
+        '--reactivate',
+        action='store_true', default=False,
+        help='activate the deactived OSD',
+        )
     activate_journal_parser.set_defaults(
         activate_key_template='{statedir}/bootstrap-osd/{cluster}.keyring',
         func=main_activate_journal,
diff --git a/src/ceph.in b/src/ceph.in
index 1142b20..e9df0cf 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -814,9 +814,8 @@ def main():
             childargs = injectargs
         if not len(childargs):
             print >> sys.stderr, \
-                'Cannot use \'tell\' with interactive mode.', \
-                'For an interactive shell,', \
-                'please start "{0}" without non-option arguments.'.format(sys.argv[0])
+                '"{0} tell" requires additional arguments.'.format(sys.argv[0]), \
+                'Try "{0} tell <name> <command> [options...]" instead.'.format(sys.argv[0])
             return errno.EINVAL
 
     # fetch JSON sigs from command
@@ -917,10 +916,14 @@ def main():
             if suffix != '':
                 outbuf = outbuf.rstrip()
             if outbuf != '':
-                # Write directly to binary stdout
-                raw_stdout.write(prefix)
-                raw_stdout.write(outbuf)
-                raw_stdout.write(suffix)
+                try:
+                    # Write directly to binary stdout
+                    raw_stdout.write(prefix)
+                    raw_stdout.write(outbuf)
+                    raw_stdout.write(suffix)
+                except IOError as e:
+                    if e.errno != errno.EPIPE:
+                        raise e
 
         sys.stdout.flush()
 
diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc
index 6d5c946..e66fe65 100644
--- a/src/ceph_fuse.cc
+++ b/src/ceph_fuse.cc
@@ -48,7 +48,6 @@ static void fuse_usage()
   if (fuse_parse_cmdline(&args, NULL, NULL, NULL) == -1) {
     derr << "fuse_parse_cmdline failed." << dendl;
     fuse_opt_free_args(&args);
-    free(argv);
   }
 
   assert(args.allocated);  // Checking fuse has realloc'd args so we can free newargv
@@ -70,6 +69,10 @@ int main(int argc, const char **argv, const char *envp[]) {
   //cerr << "ceph-fuse starting " << myrank << "/" << world << std::endl;
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
+  if (args.empty()) {
+    usage();
+    return 0;
+  }
   env_to_vec(args);
 
   global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
@@ -245,7 +248,7 @@ int main(int argc, const char **argv, const char *envp[]) {
 
     cerr << "ceph-fuse[" << getpid() << "]: starting fuse" << std::endl;
     tester.init(cfuse, client);
-    tester.create();
+    tester.create("tester");
     r = cfuse->loop();
     tester.join(&tester_rp);
     tester_r = static_cast<int>(reinterpret_cast<uint64_t>(tester_rp));
diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc
index 16d71da..0da51bf 100644
--- a/src/ceph_mds.cc
+++ b/src/ceph_mds.cc
@@ -213,8 +213,10 @@ int main(int argc, const char **argv)
     r = mds->init(shadow);
   else
     r = mds->init();
-  if (r < 0)
+  if (r < 0) {
+    msgr->wait();
     goto shutdown;
+  }
 
   // set up signal handlers, now that we've daemonized/forked.
   init_async_signal_handler();
diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc
index edec5d9..e6e3ada 100644
--- a/src/ceph_mon.cc
+++ b/src/ceph_mon.cc
@@ -527,7 +527,7 @@ int main(int argc, const char **argv)
 
   bufferlist magicbl;
   err = store->get(Monitor::MONITOR_NAME, "magic", magicbl);
-  if (!magicbl.length()) {
+  if (err || !magicbl.length()) {
     derr << "unable to read magic from mon data" << dendl;
     prefork.exit(1);
   }
diff --git a/src/client/Client.cc b/src/client/Client.cc
index 9a0c36a..7f89665 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -82,6 +82,7 @@ using namespace std;
 #include "common/perf_counters.h"
 #include "common/admin_socket.h"
 #include "common/errno.h"
+#include "include/str_list.h"
 
 #define dout_subsys ceph_subsys_client
 
@@ -98,6 +99,7 @@ using namespace std;
 #include "MetaSession.h"
 #include "MetaRequest.h"
 #include "ObjecterWriteback.h"
+#include "posix_acl.h"
 
 #include "include/assert.h"
 #include "include/stat.h"
@@ -122,7 +124,9 @@ using namespace std;
 #define O_RSYNC 0x0
 #endif
 
-
+#ifndef O_DIRECT
+#define O_DIRECT 0x0
+#endif
 
 void client_flush_set_callback(void *p, ObjectCacher::ObjectSet *oset)
 {
@@ -239,6 +243,7 @@ Client::Client(Messenger *m, MonClient *mc)
     ino_invalidate_cb(NULL),
     dentry_invalidate_cb(NULL),
     getgroups_cb(NULL),
+    umask_cb(NULL),
     can_invalidate_dentries(false),
     require_remount(false),
     async_ino_invalidator(m->cct),
@@ -270,6 +275,10 @@ Client::Client(Messenger *m, MonClient *mc)
   user_id = cct->_conf->client_mount_uid;
   group_id = cct->_conf->client_mount_gid;
 
+  acl_type = NO_ACL;
+  if (cct->_conf->client_acl_type == "posix_acl")
+    acl_type = POSIX_ACL;
+
   lru.lru_set_max(cct->_conf->client_cache_size);
   lru.lru_set_midpoint(cct->_conf->client_cache_mid);
 
@@ -1570,7 +1579,7 @@ int Client::make_request(MetaRequest *request,
     request->resend_mds = use_mds;
 
   while (1) {
-    if (request->aborted)
+    if (request->aborted())
       break;
 
     // set up wait cond
@@ -1605,6 +1614,11 @@ int Client::make_request(MetaRequest *request,
       if (session->state == MetaSession::STATE_OPENING) {
 	ldout(cct, 10) << "waiting for session to mds." << mds << " to open" << dendl;
 	wait_on_context_list(session->waiting_for_open);
+        // Abort requests on REJECT from MDS
+        if (rejected_by_mds.count(mds)) {
+          request->abort(-EPERM);
+          break;
+        }
 	continue;
       }
 
@@ -1632,12 +1646,12 @@ int Client::make_request(MetaRequest *request,
   }
 
   if (!request->reply) {
-    assert(request->aborted);
+    assert(request->aborted());
     assert(!request->got_unsafe);
     request->item.remove_myself();
     unregister_request(request);
     put_request(request); // ours
-    return -ETIMEDOUT;
+    return request->get_abort_code();
   }
 
   // got it!
@@ -1851,9 +1865,25 @@ void Client::populate_metadata()
   // Ceph entity id (the '0' in "client.0")
   metadata["entity_id"] = cct->_conf->name.get_id();
 
+  // Our mount position
+  metadata["root"] = cct->_conf->client_mountpoint;
+
   // Ceph version
   metadata["ceph_version"] = pretty_version_to_str();
   metadata["ceph_sha1"] = git_version_to_str();
+
+  // Apply any metadata from the user's configured overrides
+  std::vector<std::string> tokens;
+  get_str_vec(cct->_conf->client_metadata, ",", tokens);
+  for (const auto &i : tokens) {
+    auto eqpos = i.find("=");
+    // Throw out anything that isn't of the form "<str>=<str>"
+    if (eqpos == 0 || eqpos == std::string::npos || eqpos == i.size()) {
+      lderr(cct) << "Invalid metadata keyval pair: '" << i << "'" << dendl;
+      continue;
+    }
+    metadata[i.substr(0, eqpos)] = i.substr(eqpos + 1);
+  }
 }
 
 /**
@@ -1883,6 +1913,21 @@ MetaSession *Client::_open_mds_session(mds_rank_t mds)
   session->con = messenger->get_connection(session->inst);
   session->state = MetaSession::STATE_OPENING;
   mds_sessions[mds] = session;
+
+  // Maybe skip sending a request to open if this MDS daemon
+  // has previously sent us a REJECT.
+  if (rejected_by_mds.count(mds)) {
+    if (rejected_by_mds[mds] == session->inst) {
+      ldout(cct, 4) << "_open_mds_session mds." << mds << " skipping "
+                       "because we were rejected" << dendl;
+      return session;
+    } else {
+      ldout(cct, 4) << "_open_mds_session mds." << mds << " old inst "
+                       "rejected us, trying with new inst" << dendl;
+      rejected_by_mds.erase(mds);
+    }
+  }
+
   MClientSession *m = new MClientSession(CEPH_SESSION_REQUEST_OPEN);
   m->client_meta = metadata;
   session->con->send_message(m);
@@ -1959,6 +2004,12 @@ void Client::handle_client_session(MClientSession *m)
     force_session_readonly(session);
     break;
 
+  case CEPH_SESSION_REJECT:
+    rejected_by_mds[session->mds_num] = session->inst;
+    _closed_mds_session(session);
+
+    break;
+
   default:
     assert(0);
   }
@@ -2176,7 +2227,11 @@ void Client::handle_client_reply(MClientReply *reply)
     if (is_dir_operation(request)) {
       Inode *dir = request->inode();
       assert(dir);
-      dir->unsafe_dir_ops.push_back(&request->unsafe_dir_item);
+      dir->unsafe_ops.push_back(&request->unsafe_dir_item);
+    }
+    if (request->target) {
+      InodeRef &in = request->target;
+      in->unsafe_ops.push_back(&request->unsafe_target_item);
     }
   }
 
@@ -2203,6 +2258,7 @@ void Client::handle_client_reply(MClientReply *reply)
     if (request->got_unsafe) {
       request->unsafe_item.remove_myself();
       request->unsafe_dir_item.remove_myself();
+      request->unsafe_target_item.remove_myself();
       signal_cond_list(request->waitfor_safe);
     }
     request->item.remove_myself();
@@ -2565,6 +2621,30 @@ void Client::resend_unsafe_requests(MetaSession *session)
   }
 }
 
+void Client::wait_unsafe_requests()
+{
+  list<MetaRequest*> last_unsafe_reqs;
+  for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
+       p != mds_sessions.end();
+       ++p) {
+    MetaSession *s = p->second;
+    if (!s->unsafe_requests.empty()) {
+      MetaRequest *req = s->unsafe_requests.back();
+      req->get();
+      last_unsafe_reqs.push_back(req);
+    }
+  }
+
+  for (list<MetaRequest*>::iterator p = last_unsafe_reqs.begin();
+       p != last_unsafe_reqs.end();
+       ++p) {
+    MetaRequest *req = *p;
+    if (req->unsafe_item.is_on_list())
+      wait_on_list(req->waitfor_safe);
+    put_request(req);
+  }
+}
+
 void Client::kick_requests_closed(MetaSession *session)
 {
   ldout(cct, 10) << "kick_requests_closed for mds." << session->mds_num << dendl;
@@ -2582,6 +2662,7 @@ void Client::kick_requests_closed(MetaSession *session)
 	lderr(cct) << "kick_requests_closed removing unsafe request " << req->get_tid() << dendl;
 	req->unsafe_item.remove_myself();
 	req->unsafe_dir_item.remove_myself();
+	req->unsafe_target_item.remove_myself();
 	signal_cond_list(req->waitfor_safe);
 	unregister_request(req);
       }
@@ -3748,11 +3829,13 @@ void Client::_invalidate_kernel_dcache()
 void Client::trim_caps(MetaSession *s, int max)
 {
   mds_rank_t mds = s->mds_num;
-  ldout(cct, 10) << "trim_caps mds." << mds << " max " << max << dendl;
+  int caps_size = s->caps.size();
+  ldout(cct, 10) << "trim_caps mds." << mds << " max " << max 
+    << " caps " << caps_size << dendl;
 
   int trimmed = 0;
   xlist<Cap*>::iterator p = s->caps.begin();
-  while ((s->caps.size() - trimmed) > max && !p.end()) {
+  while ((caps_size - trimmed) > max && !p.end()) {
     Cap *cap = *p;
     s->s_cap_iterator = cap;
     Inode *in = cap->inode;
@@ -3892,6 +3975,8 @@ void Client::flush_caps(Inode *in, MetaSession *session)
   for (map<ceph_tid_t,int>::iterator p = in->flushing_cap_tids.begin();
        p != in->flushing_cap_tids.end();
        ++p) {
+    if (session->kicked_flush_tids.count(p->first))
+	continue;
     send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()),
 	     in->caps_wanted(), (cap->issued | cap->implemented),
 	     p->second, p->first);
@@ -3951,10 +4036,14 @@ void Client::kick_flushing_caps(MetaSession *session)
     if (in->flushing_caps)
       flush_caps(in, session);
   }
+
+  session->kicked_flush_tids.clear();
 }
 
 void Client::early_kick_flushing_caps(MetaSession *session)
 {
+  session->kicked_flush_tids.clear();
+
   for (xlist<Inode*>::iterator p = session->flushing_caps.begin(); !p.end(); ++p) {
     Inode *in = *p;
     if (!in->flushing_caps)
@@ -3965,20 +4054,19 @@ void Client::early_kick_flushing_caps(MetaSession *session)
     // if flushing caps were revoked, we re-send the cap flush in client reconnect
     // stage. This guarantees that MDS processes the cap flush message before issuing
     // the flushing caps to other client.
-    bool send_now = (in->flushing_caps & in->auth_cap->issued) != in->flushing_caps;
+    if ((in->flushing_caps & in->auth_cap->issued) == in->flushing_caps)
+      continue;
 
-    if (send_now)
-      ldout(cct, 20) << " reflushing caps (revoked) on " << *in
-		     << " to mds." << session->mds_num << dendl;
+    ldout(cct, 20) << " reflushing caps (revoked) on " << *in
+		   << " to mds." << session->mds_num << dendl;
 
     for (map<ceph_tid_t,int>::iterator q = in->flushing_cap_tids.begin();
 	 q != in->flushing_cap_tids.end();
 	 ++q) {
-      if (send_now) {
-	send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()),
-		 in->caps_wanted(), (cap->issued | cap->implemented),
-		 q->second, q->first);
-      }
+      send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()),
+	       in->caps_wanted(), (cap->issued | cap->implemented),
+	       q->second, q->first);
+      session->kicked_flush_tids.insert(q->first);
     }
   }
 }
@@ -4653,7 +4741,7 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient
     in->gid = m->head.gid;
   }
   bool deleted_inode = false;
-  if ((issued & CEPH_CAP_LINK_EXCL) == 0 && in->nlink != (int32_t)m->head.nlink) {
+  if ((issued & CEPH_CAP_LINK_EXCL) == 0) {
     in->nlink = m->head.nlink;
     if (in->nlink == 0 &&
 	(new_caps & (CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL)))
@@ -4738,65 +4826,314 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient
   m->put();
 }
 
-int Client::check_permissions(Inode *in, int flags, int uid, int gid)
+int Client::_getgrouplist(gid_t** sgids, int uid, int gid)
 {
-  gid_t *sgids = NULL;
-  int sgid_count = 0;
+  int sgid_count;
+  gid_t *sgid_buf;
+
   if (getgroups_cb) {
-    sgid_count = getgroups_cb(callback_handle, uid, &sgids);
-    if (sgid_count < 0) {
-      ldout(cct, 3) << "getgroups failed!" << dendl;
+    sgid_count = getgroups_cb(callback_handle, &sgid_buf);
+    if (sgid_count > 0) {
+      *sgids = sgid_buf;
       return sgid_count;
     }
   }
+
 #if HAVE_GETGROUPLIST
-  else {
-    //use PAM to get the group list
-    // initial number of group entries, defaults to posix standard of 16
-    // PAM implementations may provide more than 16 groups....
-    sgid_count = 16;
-    sgids = (gid_t*)malloc(sgid_count * sizeof(gid_t));
-    if (sgids == NULL) {
-      ldout(cct, 3) << "allocating group memory failed" << dendl;
-      return -EACCES;
-    }
-    struct passwd *pw;
-    pw = getpwuid(uid);
-    if (pw == NULL) {
-      ldout(cct, 3) << "getting user entry failed" << dendl;
-      free(sgids); 
-      return -EACCES;
-    }
-    while (1) {
+  struct passwd *pw;
+  pw = getpwuid(uid);
+  if (pw == NULL) {
+    ldout(cct, 3) << "getting user entry failed" << dendl;
+    return -errno;
+  }
+  //use PAM to get the group list
+  // initial number of group entries, defaults to posix standard of 16
+  // PAM implementations may provide more than 16 groups....
+  sgid_count = 16;
+  sgid_buf = (gid_t*)malloc(sgid_count * sizeof(gid_t));
+  if (sgid_buf == NULL) {
+    ldout(cct, 3) << "allocating group memory failed" << dendl;
+    return -ENOMEM;
+  }
+
+  while (1) {
 #if defined(__APPLE__)
-      if (getgrouplist(pw->pw_name, gid, (int *)sgids, &sgid_count) == -1) {
+    if (getgrouplist(pw->pw_name, gid, (int*)sgid_buf, &sgid_count) == -1) {
 #else
-      if (getgrouplist(pw->pw_name, gid, sgids, &sgid_count) == -1) {
+    if (getgrouplist(pw->pw_name, gid, sgid_buf, &sgid_count) == -1) {
 #endif
-        // we need to resize the group list and try again
-	void *_realloc = NULL;
-        if ((_realloc = realloc(sgids, sgid_count * sizeof(gid_t))) == NULL) {
-          ldout(cct, 3) << "allocating group memory failed" << dendl;
-	  free(sgids);
-          return -EACCES;
-        }
-	sgids = (gid_t*)_realloc;
-        continue;
+      // we need to resize the group list and try again
+      void *_realloc = NULL;
+      if ((_realloc = realloc(sgid_buf, sgid_count * sizeof(gid_t))) == NULL) {
+	ldout(cct, 3) << "allocating group memory failed" << dendl;
+	free(sgid_buf);
+	return -ENOMEM;
       }
-      // list was successfully retrieved
-      break;
-    }    
+      sgid_buf = (gid_t*)_realloc;
+      continue;
+    }
+    // list was successfully retrieved
+    break;
   }
+  *sgids = sgid_buf;
+  return sgid_count;
+#else
+  return 0;
 #endif
+}
+
+int Client::inode_permission(Inode *in, uid_t uid, UserGroups& groups, unsigned want)
+{
+  if (uid == 0)
+    return 0;
+
+  int ret;
+  if (uid != in->uid && (in->mode & S_IRWXG)) {
+    ret = _posix_acl_permission(in, uid, groups, want);
+    if (ret != -EAGAIN)
+      return ret;
+  }
 
   // check permissions before doing anything else
-  int ret = 0;
-  if (uid != 0 && !in->check_mode(uid, gid, sgids, sgid_count, flags)) {
-    ret = -EACCES;
+  if (!in->check_mode(uid, groups, want))
+    return -EACCES;
+  return 0;
+}
+
+int Client::xattr_permission(Inode *in, const char *name, unsigned want, int uid, int gid)
+{
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = _getattr_for_perm(in, uid, gid);
+  if (r < 0)
+    goto out;
+
+  r = 0;
+  if (strncmp(name, "system.", 7) == 0) {
+    if ((want & MAY_WRITE) && (uid != 0 && (uid_t)uid != in->uid))
+      r = -EPERM;
+  } else {
+    r = inode_permission(in, uid, groups, want);
   }
-  if (sgids)
-    free(sgids);
-  return ret;
+out:
+  ldout(cct, 3) << __func__ << " " << in << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::may_setattr(Inode *in, struct stat *st, int mask, int uid, int gid)
+{
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = _getattr_for_perm(in, uid, gid);
+  if (r < 0)
+    goto out;
+
+  if (mask & CEPH_SETATTR_SIZE) {
+    r = inode_permission(in, uid, groups, MAY_WRITE);
+    if (r < 0)
+      goto out;
+  }
+
+  r = -EPERM;
+  if (mask & CEPH_SETATTR_UID) {
+    if (uid != 0 && ((uid_t)uid != in->uid || st->st_uid != in->uid))
+      goto out;
+  }
+  if (mask & CEPH_SETATTR_GID) {
+    if (uid != 0 && ((uid_t)uid != in->uid ||
+      	       (!groups.is_in(st->st_gid) && st->st_gid != in->gid)))
+      goto out;
+  }
+
+  if (mask & CEPH_SETATTR_MODE) {
+    if (uid != 0 && (uid_t)uid != in->uid)
+      goto out;
+
+    gid_t i_gid = (mask & CEPH_SETATTR_GID) ? st->st_gid : in->gid;
+    if (uid != 0 && !groups.is_in(i_gid))
+      st->st_mode &= ~S_ISGID;
+  }
+
+  if (mask & (CEPH_SETATTR_CTIME | CEPH_SETATTR_MTIME | CEPH_SETATTR_ATIME)) {
+    if (uid != 0 && (uid_t)uid != in->uid) {
+      int check_mask = CEPH_SETATTR_CTIME;
+      if (!(mask & CEPH_SETATTR_MTIME_NOW))
+	check_mask |= CEPH_SETATTR_MTIME;
+      if (!(mask & CEPH_SETATTR_ATIME_NOW))
+	check_mask |= CEPH_SETATTR_ATIME;
+      if (check_mask & mask) {
+	goto out;
+      } else {
+	r = inode_permission(in, uid, groups, MAY_WRITE);
+	if (r < 0)
+	  goto out;
+      }
+    }
+  }
+  r = 0;
+out:
+  ldout(cct, 3) << __func__ << " " << in << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::may_open(Inode *in, int flags, int uid, int gid)
+{
+  unsigned want = 0;
+
+  if ((flags & O_ACCMODE) == O_WRONLY)
+    want = MAY_WRITE;
+  else if ((flags & O_ACCMODE) == O_RDWR)
+    want = MAY_READ | MAY_WRITE;
+  else if ((flags & O_ACCMODE) == O_RDONLY)
+    want = MAY_READ;
+  if (flags & O_TRUNC)
+    want |= MAY_WRITE;
+
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = 0;
+  switch (in->mode & S_IFMT) {
+    case S_IFLNK:
+      r = -ELOOP;
+      goto out;
+    case S_IFDIR:
+      if (want & MAY_WRITE) {
+	r = -EISDIR;
+	goto out;
+      }
+      break;
+  }
+
+  r = _getattr_for_perm(in, uid, gid);
+  if (r < 0)
+    goto out;
+
+  r = inode_permission(in, uid, groups, want);
+out:
+  ldout(cct, 3) << __func__ << " " << in << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::may_lookup(Inode *dir, int uid, int gid)
+{
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = _getattr_for_perm(dir, uid, gid);
+  if (r < 0)
+    goto out;
+
+  r = inode_permission(dir, uid, groups, MAY_EXEC);
+out:
+  ldout(cct, 3) << __func__ << " " << dir << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::may_create(Inode *dir, int uid, int gid)
+{
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = _getattr_for_perm(dir, uid, gid);
+  if (r < 0)
+    goto out;
+
+  r = inode_permission(dir, uid, groups, MAY_EXEC | MAY_WRITE);
+out:
+  ldout(cct, 3) << __func__ << " " << dir << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::may_delete(Inode *dir, const char *name, int uid, int gid)
+{
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = _getattr_for_perm(dir, uid, gid);
+  if (r < 0)
+    goto out;
+
+  r = inode_permission(dir, uid, groups, MAY_EXEC | MAY_WRITE);
+  if (r < 0)
+    goto out;
+
+  /* 'name == NULL' means rmsnap */
+  if (uid != 0 && name && (dir->mode & S_ISVTX)) {
+    InodeRef otherin;
+    r = _lookup(dir, name, &otherin, uid, gid);
+    if (r < 0)
+      goto out;
+    if (dir->uid != (uid_t)uid && otherin->uid != (uid_t)uid)
+      r = -EPERM;
+  }
+out:
+  ldout(cct, 3) << __func__ << " " << dir << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::may_hardlink(Inode *in, int uid, int gid)
+{
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+  RequestUserGroups groups(this, uid, gid);
+
+  int r = _getattr_for_perm(in, uid, gid);
+  if (r < 0)
+    goto out;
+
+  if (uid == 0 || (uid_t)uid == in->uid) {
+    r = 0;
+    goto out;
+  }
+
+  r = -EPERM;
+  if (!S_ISREG(in->mode))
+    goto out;
+
+  if (in->mode & S_ISUID)
+    goto out;
+
+  if ((in->mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
+    goto out;
+
+  r = inode_permission(in, uid, groups, MAY_READ | MAY_WRITE);
+out:
+  ldout(cct, 3) << __func__ << " " << in << " = " << r <<  dendl;
+  return r;
+}
+
+int Client::_getattr_for_perm(Inode *in, int uid, int gid)
+{
+  int mask = CEPH_STAT_CAP_MODE;
+  bool force = false;
+  if (acl_type != NO_ACL) {
+    mask |= CEPH_STAT_CAP_XATTR;
+    force = in->xattr_version == 0;
+  }
+  return _getattr(in, mask, uid, gid, force);
 }
 
 vinodeno_t Client::_get_vino(Inode *in)
@@ -5272,7 +5609,7 @@ void Client::tick()
   if (!mounted && !mds_requests.empty()) {
     MetaRequest *req = mds_requests.begin()->second;
     if (req->op_stamp + cct->_conf->client_mount_timeout < now) {
-      req->aborted = true;
+      req->abort(-ETIMEDOUT);
       if (req->caller_cond) {
 	req->kick = true;
 	req->caller_cond->Signal();
@@ -5497,6 +5834,11 @@ int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym,
     cur = cwd;
   assert(cur);
 
+  if (uid < 0)
+    uid = get_uid();
+  if (gid < 0)
+    gid = get_gid();
+
   ldout(cct, 10) << "path_walk " << path << dendl;
 
   int symlinks = 0;
@@ -5507,6 +5849,11 @@ int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym,
     ldout(cct, 10) << " " << i << " " << *cur << " " << dname << dendl;
     ldout(cct, 20) << "  (path is " << path << ")" << dendl;
     InodeRef next;
+    if (cct->_conf->client_permissions) {
+      int r = may_lookup(cur.get(), uid, gid);
+      if (r < 0)
+	return r;
+    }
     int r = _lookup(cur.get(), dname, &next, uid, gid);
     if (r < 0)
       return r;
@@ -5573,13 +5920,24 @@ int Client::link(const char *relexisting, const char *relpath)
   path.pop_dentry();
 
   InodeRef in, dir;
-  int r;
-  r = path_walk(existing, &in);
+  int r = path_walk(existing, &in);
   if (r < 0)
     goto out;
   r = path_walk(path, &dir);
   if (r < 0)
     goto out;
+  if (cct->_conf->client_permissions) {
+    if (S_ISDIR(in->mode)) {
+      r = -EPERM;
+      goto out;
+    }
+    r = may_hardlink(in.get());
+    if (r < 0)
+      goto out;
+    r = may_create(dir.get());
+    if (r < 0)
+      goto out;
+  }
   r = _link(in.get(), dir.get(), name.c_str());
  out:
   return r;
@@ -5598,6 +5956,11 @@ int Client::unlink(const char *relpath)
   int r = path_walk(path, &dir);
   if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    r = may_delete(dir.get(), name.c_str());
+    if (r < 0)
+      return r;
+  }
   return _unlink(dir.get(), name.c_str());
 }
 
@@ -5616,16 +5979,23 @@ int Client::rename(const char *relfrom, const char *relto)
   to.pop_dentry();
 
   InodeRef fromdir, todir;
-  int r;
-
-  r = path_walk(from, &fromdir);
+  int r = path_walk(from, &fromdir);
   if (r < 0)
     goto out;
   r = path_walk(to, &todir);
   if (r < 0)
     goto out;
+
+  if (cct->_conf->client_permissions) {
+    int r = may_delete(fromdir.get(), fromname.c_str());
+    if (r < 0)
+      return r;
+    r = may_delete(todir.get(), toname.c_str());
+    if (r < 0 && r != -ENOENT)
+      return r;
+  }
   r = _rename(fromdir.get(), fromname.c_str(), todir.get(), toname.c_str());
- out:
+out:
   return r;
 }
 
@@ -5644,13 +6014,17 @@ int Client::mkdir(const char *relpath, mode_t mode)
   path.pop_dentry();
   InodeRef dir;
   int r = path_walk(path, &dir);
-  if (r < 0) {
+  if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    r = may_create(dir.get());
+    if (r < 0)
+      return r;
   }
   return _mkdir(dir.get(), name.c_str(), mode);
 }
 
-int Client::mkdirs(const char *relpath, mode_t mode, int uid, int gid)
+int Client::mkdirs(const char *relpath, mode_t mode)
 {
   Mutex::Locker lock(client_lock);
   ldout(cct, 10) << "Client::mkdirs " << relpath << dendl;
@@ -5658,6 +6032,9 @@ int Client::mkdirs(const char *relpath, mode_t mode, int uid, int gid)
   tout(cct) << relpath << std::endl;
   tout(cct) << mode << std::endl;
 
+  uid_t uid = get_uid();
+  gid_t gid = get_gid();
+
   //get through existing parts of path
   filepath path(relpath);
   unsigned int i;
@@ -5665,6 +6042,11 @@ int Client::mkdirs(const char *relpath, mode_t mode, int uid, int gid)
   InodeRef cur, next;
   cur = cwd;
   for (i=0; i<path.depth(); ++i) {
+    if (cct->_conf->client_permissions) {
+      r = may_lookup(cur.get(), uid, gid);
+      if (r < 0)
+	break;
+    }
     r = _lookup(cur.get(), path[i].c_str(), &next, uid, gid);
     if (r < 0)
       break;
@@ -5676,20 +6058,19 @@ int Client::mkdirs(const char *relpath, mode_t mode, int uid, int gid)
   ldout(cct, 20) << "mkdirs got through " << i << " directories on path " << relpath << dendl;
   //make new directory at each level
   for (; i<path.depth(); ++i) {
+    if (cct->_conf->client_permissions) {
+      r = may_create(cur.get(), uid, gid);
+      if (r < 0)
+	return r;
+    }
     //make new dir
-    r = _mkdir(cur.get(), path[i].c_str(), mode);
+    r = _mkdir(cur.get(), path[i].c_str(), mode, uid, gid, &next);
     //check proper creation/existence
     if (r < 0) return r;
-    r = _lookup(cur.get(), path[i], &next, uid, gid);
-    if (r < 0) {
-      ldout(cct, 0) << "mkdirs: successfully created new directory " << path[i]
-	      << " but can't _lookup it!" << dendl;
-      return r;
-    }
     //move to new dir and continue
     cur.swap(next);
     ldout(cct, 20) << "mkdirs: successfully created directory "
-	     << filepath(cur->ino).get_path() << dendl;
+		   << filepath(cur->ino).get_path() << dendl;
   }
   return 0;
 }
@@ -5706,6 +6087,11 @@ int Client::rmdir(const char *relpath)
   int r = path_walk(path, &dir);
   if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    int r = may_delete(dir.get(), name.c_str());
+    if (r < 0)
+      return r;
+  }
   return _rmdir(dir.get(), name.c_str());
 }
 
@@ -5719,11 +6105,16 @@ int Client::mknod(const char *relpath, mode_t mode, dev_t rdev)
   filepath path(relpath);
   string name = path.last_dentry();
   path.pop_dentry();
-  InodeRef in;
-  int r = path_walk(path, &in);
+  InodeRef dir;
+  int r = path_walk(path, &dir);
   if (r < 0)
     return r;
-  return _mknod(in.get(), name.c_str(), mode, rdev);
+  if (cct->_conf->client_permissions) {
+    int r = may_create(dir.get());
+    if (r < 0)
+      return r;
+  }
+  return _mknod(dir.get(), name.c_str(), mode, rdev);
 }
 
 // symlinks
@@ -5742,6 +6133,11 @@ int Client::symlink(const char *target, const char *relpath)
   int r = path_walk(path, &dir);
   if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    int r = may_create(dir.get());
+    if (r < 0)
+      return r;
+  }
   return _symlink(dir.get(), name.c_str(), target);
 }
 
@@ -5796,8 +6192,8 @@ int Client::_getattr(Inode *in, int mask, int uid, int gid, bool force)
   return res;
 }
 
-int Client::_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid,
-		     InodeRef *inp)
+int Client::_do_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid,
+			InodeRef *inp)
 {
   int issued = in->caps_issued();
 
@@ -5956,6 +6352,31 @@ force_request:
   return res;
 }
 
+int Client::_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid,
+		     InodeRef *inp)
+{
+  int ret = _do_setattr(in, attr, mask, uid, gid, inp);
+  if (ret < 0)
+   return ret;
+  if (mask & CEPH_SETATTR_MODE)
+    ret = _posix_acl_chmod(in, attr->st_mode, uid, gid);
+  return ret;
+}
+
+int Client::_setattr(InodeRef &in, struct stat *attr, int mask)
+{
+  mask &= (CEPH_SETATTR_MODE | CEPH_SETATTR_UID |
+	   CEPH_SETATTR_GID | CEPH_SETATTR_MTIME |
+	   CEPH_SETATTR_ATIME | CEPH_SETATTR_SIZE |
+	   CEPH_SETATTR_CTIME);
+  if (cct->_conf->client_permissions) {
+    int r = may_setattr(in.get(), attr, mask);
+    if (r < 0)
+      return r;
+  }
+  return _setattr(in.get(), attr, mask);
+}
+
 int Client::setattr(const char *relpath, struct stat *attr, int mask)
 {
   Mutex::Locker lock(client_lock);
@@ -6252,7 +6673,7 @@ int Client::flock(int fd, int operation, uint64_t owner)
   if (!f)
     return -EBADF;
 
-  return _flock(f, operation, owner, NULL);
+  return _flock(f, operation, owner);
 }
 
 int Client::opendir(const char *relpath, dir_result_t **dirpp) 
@@ -6265,6 +6686,11 @@ int Client::opendir(const char *relpath, dir_result_t **dirpp)
   int r = path_walk(path, &in);
   if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    int r = may_open(in.get(), O_RDONLY);
+    if (r < 0)
+      return r;
+  }
   r = _opendir(in.get(), dirpp);
   tout(cct) << (unsigned long)*dirpp << std::endl;
   return r;
@@ -6918,6 +7344,9 @@ int Client::open(const char *relpath, int flags, mode_t mode, int stripe_unit,
   tout(cct) << relpath << std::endl;
   tout(cct) << flags << std::endl;
 
+  uid_t uid = get_uid();
+  gid_t gid = get_gid();
+
   Fh *fh = NULL;
 
 #if defined(__linux__) && defined(O_PATH)
@@ -6933,7 +7362,7 @@ int Client::open(const char *relpath, int flags, mode_t mode, int stripe_unit,
   bool created = false;
   /* O_CREATE with O_EXCL enforces O_NOFOLLOW. */
   bool followsym = !((flags & O_NOFOLLOW) || ((flags & O_CREAT) && (flags & O_EXCL)));
-  int r = path_walk(path, &in, followsym);
+  int r = path_walk(path, &in, followsym, uid, gid);
 
   if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
     return -EEXIST;
@@ -6950,26 +7379,31 @@ int Client::open(const char *relpath, int flags, mode_t mode, int stripe_unit,
     string dname = dirpath.last_dentry();
     dirpath.pop_dentry();
     InodeRef dir;
-    r = path_walk(dirpath, &dir);
+    r = path_walk(dirpath, &dir, true, uid, gid);
     if (r < 0)
-      return r;
+      goto out;
+    if (cct->_conf->client_permissions) {
+      r = may_create(dir.get(), uid, gid);
+      if (r < 0)
+	goto out;
+    }
     r = _create(dir.get(), dname.c_str(), flags, mode, &in, &fh, stripe_unit,
-                stripe_count, object_size, data_pool, &created);
+                stripe_count, object_size, data_pool, &created, uid, gid);
   }
   if (r < 0)
     goto out;
 
   if (!created) {
     // posix says we can only check permissions of existing files
-    uid_t uid = get_uid();
-    gid_t gid = get_gid();
-    r = check_permissions(in.get(), flags, uid, gid);
-    if (r < 0)
-      goto out;
+    if (cct->_conf->client_permissions) {
+      r = may_open(in.get(), flags, uid, gid);
+      if (r < 0)
+	goto out;
+    }
   }
 
   if (!fh)
-    r = _open(in.get(), flags, mode, &fh);
+    r = _open(in.get(), flags, mode, &fh, uid, gid);
   if (r >= 0) {
     // allocate a integer file descriptor
     assert(fh);
@@ -7332,13 +7766,13 @@ int Client::uninline_data(Inode *in, Context *onfinish)
   create_ops.create(false);
 
   objecter->mutate(oid,
-                   OSDMap::file_to_object_locator(in->layout),
-                   create_ops,
-                   in->snaprealm->get_snap_context(),
-                   ceph_clock_now(cct),
-                   0,
-                   NULL,
-                   NULL);
+		   OSDMap::file_to_object_locator(in->layout),
+		   create_ops,
+		   in->snaprealm->get_snap_context(),
+		   ceph::real_clock::now(cct),
+		   0,
+		   NULL,
+		   NULL);
 
   bufferlist inline_version_bl;
   ::encode(in->inline_version, inline_version_bl);
@@ -7353,13 +7787,13 @@ int Client::uninline_data(Inode *in, Context *onfinish)
   uninline_ops.setxattr("inline_version", stringify(in->inline_version));
 
   objecter->mutate(oid,
-                   OSDMap::file_to_object_locator(in->layout),
-                   uninline_ops,
-                   in->snaprealm->get_snap_context(),
-                   ceph_clock_now(cct),
-                   0,
-                   NULL,
-                   onfinish);
+		   OSDMap::file_to_object_locator(in->layout),
+		   uninline_ops,
+		   in->snaprealm->get_snap_context(),
+		   ceph::real_clock::now(cct),
+		   0,
+		   NULL,
+		   onfinish);
 
   return 0;
 }
@@ -7405,6 +7839,8 @@ int Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl)
   const md_config_t *conf = cct->_conf;
   Inode *in = f->inode.get();
 
+  if ((f->mode & CEPH_FILE_MODE_RD) == 0)
+    return -EBADF;
   //bool lazy = f->mode == CEPH_FILE_MODE_LAZY;
 
   bool movepos = false;
@@ -7428,6 +7864,9 @@ retry:
   if (r < 0)
     return r;
 
+  if (f->flags & O_DIRECT)
+    have &= ~CEPH_CAP_FILE_CACHE;
+
   Mutex uninline_flock("Clinet::_read_uninline_data flock");
   Cond uninline_cond;
   bool uninline_done = false;
@@ -7473,6 +7912,9 @@ retry:
     if (r < 0)
       goto done;
   } else {
+    if (f->flags & O_DIRECT)
+      _flush_range(in, offset, size);
+
     bool checkeof = false;
     r = _read_sync(f, offset, size, bl, &checkeof);
     if (r < 0)
@@ -7854,6 +8296,9 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
   if (r < 0)
     return r;
 
+  if (f->flags & O_DIRECT)
+    have &= ~CEPH_CAP_FILE_BUFFER;
+
   ldout(cct, 10) << " snaprealm " << *in->snaprealm << dendl;
 
   Mutex uninline_flock("Clinet::_write_uninline_data flock");
@@ -7901,8 +8346,10 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
     get_cap_ref(in, CEPH_CAP_FILE_BUFFER);
 
     // async, caching, non-blocking.
-    r = objectcacher->file_write(&in->oset, &in->layout, in->snaprealm->get_snap_context(),
-			         offset, size, bl, ceph_clock_now(cct), 0);
+    r = objectcacher->file_write(&in->oset, &in->layout,
+				 in->snaprealm->get_snap_context(),
+				 offset, size, bl, ceph::real_clock::now(cct),
+				 0);
     put_cap_ref(in, CEPH_CAP_FILE_BUFFER);
 
     if (r < 0)
@@ -7915,6 +8362,9 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
       _flush_range(in, offset, size);
     }
   } else {
+    if (f->flags & O_DIRECT)
+      _flush_range(in, offset, size);
+
     // simple, non-atomic sync write
     Mutex flock("Client::_write flock");
     Cond cond;
@@ -7926,7 +8376,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
     get_cap_ref(in, CEPH_CAP_FILE_BUFFER);  // released by onsafe callback
 
     r = filer->write_trunc(in->ino, &in->layout, in->snaprealm->get_snap_context(),
-			   offset, size, bl, ceph_clock_now(cct), 0,
+			   offset, size, bl, ceph::real_clock::now(cct), 0,
 			   in->truncate_size, in->truncate_seq,
 			   onfinish, new C_OnFinisher(onsafe, &objecter_finisher));
     if (r < 0)
@@ -8059,11 +8509,11 @@ int Client::fsync(int fd, bool syncdataonly)
 int Client::_fsync(Inode *in, bool syncdataonly)
 {
   int r = 0;
-  bool flushed_metadata = false;
   Mutex lock("Client::_fsync::lock");
   Cond cond;
   bool done = false;
   C_SafeCond *object_cacher_completion = NULL;
+  ceph_tid_t flush_tid = 0;
   InodeRef tmp_ref;
 
   ldout(cct, 3) << "_fsync on " << *in << " " << (syncdataonly ? "(dataonly)":"(data+metadata)") << dendl;
@@ -8078,9 +8528,18 @@ int Client::_fsync(Inode *in, bool syncdataonly)
   if (!syncdataonly && (in->dirty_caps & ~CEPH_CAP_ANY_FILE_WR)) {
     check_caps(in, true);
     if (in->flushing_caps)
-      flushed_metadata = true;
+      flush_tid = last_flush_tid;
   } else ldout(cct, 10) << "no metadata needs to commit" << dendl;
 
+  if (!syncdataonly && !in->unsafe_ops.empty()) {
+    MetaRequest *req = in->unsafe_ops.back();
+    ldout(cct, 15) << "waiting on unsafe requests, last tid " << req->get_tid() <<  dendl;
+
+    req->get();
+    wait_on_list(req->waitfor_safe);
+    put_request(req);
+  }
+
   if (object_cacher_completion) { // wait on a real reply instead of guessing
     client_lock.Unlock();
     lock.Lock();
@@ -8099,24 +8558,9 @@ int Client::_fsync(Inode *in, bool syncdataonly)
     }
   }
 
-  if (!in->unsafe_dir_ops.empty()) {
-    MetaRequest *req = in->unsafe_dir_ops.back();
-    uint64_t last_tid = req->get_tid();
-    ldout(cct, 15) << "waiting on unsafe requests, last tid " << last_tid <<  dendl;
-
-    do {
-      req->get();
-      wait_on_list(req->waitfor_safe);
-      put_request(req);
-      if (in->unsafe_dir_ops.empty())
-	break;
-      req = in->unsafe_dir_ops.front();
-    } while (req->tid < last_tid);
-  }
-
   if (!r) {
-    if (flushed_metadata)
-      wait_sync_caps(in, last_flush_tid);
+    if (flush_tid > 0)
+      wait_sync_caps(in, flush_tid);
 
     ldout(cct, 10) << "ino " << in->ino << " has no uncommitted writes" << dendl;
   } else {
@@ -8254,7 +8698,7 @@ int Client::statfs(const char *path, struct statvfs *stbuf)
 }
 
 int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep,
-			 struct flock *fl, uint64_t owner, void *fuse_req)
+			 struct flock *fl, uint64_t owner)
 {
   ldout(cct, 10) << "_do_filelock ino " << in->ino
 		 << (lock_type == CEPH_LOCK_FCNTL ? " fcntl" : " flock")
@@ -8298,14 +8742,14 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep,
   int ret;
   bufferlist bl;
 
-  if (sleep && switch_interrupt_cb && fuse_req) {
+  if (sleep && switch_interrupt_cb) {
     // enable interrupt
-    switch_interrupt_cb(fuse_req, req->get());
+    switch_interrupt_cb(callback_handle, req->get());
 
     ret = make_request(req, -1, -1, NULL, NULL, -1, &bl);
 
     // disable interrupt
-    switch_interrupt_cb(fuse_req, NULL);
+    switch_interrupt_cb(callback_handle, NULL);
     put_request(req);
   } else {
     ret = make_request(req, -1, -1, NULL, NULL, -1, &bl);
@@ -8499,16 +8943,16 @@ int Client::_getlk(Fh *fh, struct flock *fl, uint64_t owner)
   return ret;
 }
 
-int Client::_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req)
+int Client::_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep)
 {
   Inode *in = fh->inode.get();
   ldout(cct, 10) << "_setlk " << fh << " ino " << in->ino << dendl;
-  int ret =  _do_filelock(in, fh, CEPH_LOCK_FCNTL, CEPH_MDS_OP_SETFILELOCK, sleep, fl, owner, fuse_req);
+  int ret =  _do_filelock(in, fh, CEPH_LOCK_FCNTL, CEPH_MDS_OP_SETFILELOCK, sleep, fl, owner);
   ldout(cct, 10) << "_setlk " << fh << " ino " << in->ino << " result=" << ret << dendl;
   return ret;
 }
 
-int Client::_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req)
+int Client::_flock(Fh *fh, int cmd, uint64_t owner)
 {
   Inode *in = fh->inode.get();
   ldout(cct, 10) << "_flock " << fh << " ino " << in->ino << dendl;
@@ -8536,7 +8980,7 @@ int Client::_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req)
   fl.l_type = type;
   fl.l_whence = SEEK_SET;
 
-  int ret =  _do_filelock(in, fh, CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, sleep, &fl, owner, fuse_req);
+  int ret =  _do_filelock(in, fh, CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, sleep, &fl, owner);
   ldout(cct, 10) << "_flock " << fh << " ino " << in->ino << " result=" << ret << dendl;
   return ret;
 }
@@ -8579,6 +9023,7 @@ void Client::ll_register_callbacks(struct client_callback_args *args)
     remount_finisher.start();
   }
   getgroups_cb = args->getgroups_cb;
+  umask_cb = args->umask_cb;
 }
 
 int Client::test_dentry_handling(bool can_invalidate)
@@ -8613,15 +9058,33 @@ int Client::_sync_fs()
 {
   ldout(cct, 10) << "_sync_fs" << dendl;
 
-  // wait for unsafe mds requests
-  // FIXME
-  
+  // flush file data
+  Mutex lock("Client::_fsync::lock");
+  Cond cond;
+  bool flush_done = false;
+  if (cct->_conf->client_oc)
+    objectcacher->flush_all(new C_SafeCond(&lock, &cond, &flush_done));
+  else
+    flush_done = true;
+
   // flush caps
   flush_caps();
-  wait_sync_caps(last_flush_tid);
+  ceph_tid_t flush_tid = last_flush_tid;
 
-  // flush file data
-  // FIXME
+  // wait for unsafe mds requests
+  wait_unsafe_requests();
+
+  wait_sync_caps(flush_tid);
+
+  if (!flush_done) {
+    client_lock.Unlock();
+    lock.Lock();
+    ldout(cct, 15) << "waiting on data to flush" << dendl;
+    while (!flush_done)
+      cond.Wait(lock);
+    lock.Unlock();
+    client_lock.Lock();
+  }
 
   return 0;
 }
@@ -8684,6 +9147,11 @@ int Client::mksnap(const char *relpath, const char *name)
   int r = path_walk(path, &in);
   if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    r = may_create(in.get());
+    if (r < 0)
+      return r;
+  }
   Inode *snapdir = open_snapdir(in.get());
   return _mkdir(snapdir, name, 0);
 }
@@ -8695,6 +9163,11 @@ int Client::rmsnap(const char *relpath, const char *name)
   int r = path_walk(path, &in);
   if (r < 0)
     return r;
+  if (cct->_conf->client_permissions) {
+    r = may_delete(in.get(), NULL);
+    if (r < 0)
+      return r;
+  }
   Inode *snapdir = open_snapdir(in.get());
   return _rmdir(snapdir, name);
 }
@@ -8764,9 +9237,15 @@ int Client::ll_lookup(Inode *parent, const char *name, struct stat *attr,
   tout(cct) << "ll_lookup" << std::endl;
   tout(cct) << name << std::endl;
 
+  int r = 0;
+  if (!cct->_conf->fuse_default_permissions) {
+    r = may_lookup(parent, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   string dname(name);
   InodeRef in;
-  int r = 0;
 
   r = _lookup(parent, dname, &in, uid, gid);
   if (r < 0) {
@@ -8963,6 +9442,14 @@ int Client::ll_setattr(Inode *in, struct stat *attr, int mask, int uid,
   tout(cct) << attr->st_atime << std::endl;
   tout(cct) << mask << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int res = may_setattr(in, attr, mask, uid, gid);
+    if (res < 0)
+      return res;
+  }
+
+  mask &= ~(CEPH_SETATTR_MTIME_NOW | CEPH_SETATTR_ATIME_NOW);
+
   InodeRef target(in);
   int res = _setattr(in, attr, mask, uid, gid, &target);
   if (res == 0) {
@@ -8985,7 +9472,7 @@ int Client::getxattr(const char *path, const char *name, void *value, size_t siz
   int r = Client::path_walk(path, &in, true);
   if (r < 0)
     return r;
-  return Client::_getxattr(in.get(), name, value, size);
+  return _getxattr(in, name, value, size);
 }
 
 int Client::lgetxattr(const char *path, const char *name, void *value, size_t size)
@@ -8995,7 +9482,7 @@ int Client::lgetxattr(const char *path, const char *name, void *value, size_t si
   int r = Client::path_walk(path, &in, false);
   if (r < 0)
     return r;
-  return Client::_getxattr(in.get(), name, value, size);
+  return _getxattr(in, name, value, size);
 }
 
 int Client::fgetxattr(int fd, const char *name, void *value, size_t size)
@@ -9004,7 +9491,7 @@ int Client::fgetxattr(int fd, const char *name, void *value, size_t size)
   Fh *f = get_filehandle(fd);
   if (!f)
     return -EBADF;
-  return Client::_getxattr(f->inode.get(), name, value, size);
+  return _getxattr(f->inode, name, value, size);
 }
 
 int Client::listxattr(const char *path, char *list, size_t size)
@@ -9043,7 +9530,7 @@ int Client::removexattr(const char *path, const char *name)
   int r = Client::path_walk(path, &in, true);
   if (r < 0)
     return r;
-  return Client::_removexattr(in.get(), name);
+  return _removexattr(in, name);
 }
 
 int Client::lremovexattr(const char *path, const char *name)
@@ -9053,7 +9540,7 @@ int Client::lremovexattr(const char *path, const char *name)
   int r = Client::path_walk(path, &in, false);
   if (r < 0)
     return r;
-  return Client::_removexattr(in.get(), name);
+  return _removexattr(in, name);
 }
 
 int Client::fremovexattr(int fd, const char *name)
@@ -9062,7 +9549,7 @@ int Client::fremovexattr(int fd, const char *name)
   Fh *f = get_filehandle(fd);
   if (!f)
     return -EBADF;
-  return Client::_removexattr(f->inode.get(), name);
+  return _removexattr(f->inode, name);
 }
 
 int Client::setxattr(const char *path, const char *name, const void *value, size_t size, int flags)
@@ -9072,7 +9559,7 @@ int Client::setxattr(const char *path, const char *name, const void *value, size
   int r = Client::path_walk(path, &in, true);
   if (r < 0)
     return r;
-  return Client::_setxattr(in.get(), name, value, size, flags);
+  return _setxattr(in, name, value, size, flags);
 }
 
 int Client::lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
@@ -9082,7 +9569,7 @@ int Client::lsetxattr(const char *path, const char *name, const void *value, siz
   int r = Client::path_walk(path, &in, false);
   if (r < 0)
     return r;
-  return Client::_setxattr(in.get(), name, value, size, flags);
+  return _setxattr(in, name, value, size, flags);
 }
 
 int Client::fsetxattr(int fd, const char *name, const void *value, size_t size, int flags)
@@ -9091,7 +9578,7 @@ int Client::fsetxattr(int fd, const char *name, const void *value, size_t size,
   Fh *f = get_filehandle(fd);
   if (!f)
     return -EBADF;
-  return Client::_setxattr(f->inode.get(), name, value, size, flags);
+  return _setxattr(f->inode, name, value, size, flags);
 }
 
 int Client::_getxattr(Inode *in, const char *name, void *value, size_t size,
@@ -9118,6 +9605,11 @@ int Client::_getxattr(Inode *in, const char *name, void *value, size_t size,
     goto out;
   }
 
+  if (acl_type == NO_ACL && !strncmp(name, "system.", 7)) {
+    r = -EOPNOTSUPP;
+    goto out;
+  }
+
   r = _getattr(in, CEPH_STAT_CAP_XATTR, uid, gid, in->xattr_version == 0);
   if (r == 0) {
     string n(name);
@@ -9137,6 +9629,16 @@ int Client::_getxattr(Inode *in, const char *name, void *value, size_t size,
   return r;
 }
 
+int Client::_getxattr(InodeRef &in, const char *name, void *value, size_t size)
+{
+  if (cct->_conf->client_permissions) {
+    int r = xattr_permission(in.get(), name, MAY_READ);
+    if (r < 0)
+      return r;
+  }
+  return _getxattr(in.get(), name, value, size);
+}
+
 int Client::ll_getxattr(Inode *in, const char *name, void *value,
 			size_t size, int uid, int gid)
 {
@@ -9149,6 +9651,12 @@ int Client::ll_getxattr(Inode *in, const char *name, void *value,
   tout(cct) << vino.ino.val << std::endl;
   tout(cct) << name << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = xattr_permission(in, name, MAY_READ, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   return _getxattr(in, name, value, size, uid, gid);
 }
 
@@ -9211,23 +9719,9 @@ int Client::ll_listxattr(Inode *in, char *names, size_t size, int uid,
   return _listxattr(in, names, size, uid, gid);
 }
 
-int Client::_setxattr(Inode *in, const char *name, const void *value,
-		      size_t size, int flags, int uid, int gid)
+int Client::_do_setxattr(Inode *in, const char *name, const void *value,
+			 size_t size, int flags, int uid, int gid)
 {
-  if (in->snapid != CEPH_NOSNAP) {
-    return -EROFS;
-  }
-
-  // same xattrs supported by kernel client
-  if (strncmp(name, "user.", 5) &&
-      strncmp(name, "security.", 9) &&
-      strncmp(name, "trusted.", 8) &&
-      strncmp(name, "ceph.", 5))
-    return -EOPNOTSUPP;
-
-  const VXattr *vxattr = _match_vxattr(in, name);
-  if (vxattr && vxattr->readonly)
-    return -EOPNOTSUPP;
 
   int xattr_flags = 0;
   if (!value)
@@ -9257,6 +9751,73 @@ int Client::_setxattr(Inode *in, const char *name, const void *value,
   return res;
 }
 
+int Client::_setxattr(Inode *in, const char *name, const void *value,
+		      size_t size, int flags, int uid, int gid)
+{
+  if (in->snapid != CEPH_NOSNAP) {
+    return -EROFS;
+  }
+
+  bool posix_acl_xattr = false;
+  if (acl_type == POSIX_ACL)
+    posix_acl_xattr = !strncmp(name, "system.", 7);
+
+  if (strncmp(name, "user.", 5) &&
+      strncmp(name, "security.", 9) &&
+      strncmp(name, "trusted.", 8) &&
+      strncmp(name, "ceph.", 5) &&
+      !posix_acl_xattr)
+    return -EOPNOTSUPP;
+
+  if (posix_acl_xattr) {
+    if (!strcmp(name, ACL_EA_ACCESS)) {
+      mode_t new_mode = in->mode;
+      if (value) {
+	int ret = posix_acl_equiv_mode(value, size, &new_mode);
+	if (ret < 0)
+	  return ret;
+	if (ret == 0) {
+	  value = NULL;
+	  size = 0;
+	}
+	if (new_mode != in->mode) {
+	  struct stat attr;
+	  attr.st_mode = new_mode;
+	  ret = _do_setattr(in, &attr, CEPH_SETATTR_MODE, uid, gid, NULL);
+	  if (ret < 0)
+	    return ret;
+	}
+      }
+    } else if (!strcmp(name, ACL_EA_DEFAULT)) {
+      if (value) {
+	if (!S_ISDIR(in->mode))
+	  return -EACCES;
+	if (!posix_acl_check(value, size))
+	  return -EINVAL;
+      }
+    } else {
+      return -EOPNOTSUPP;
+    }
+  } else {
+    const VXattr *vxattr = _match_vxattr(in, name);
+    if (vxattr && vxattr->readonly)
+      return -EOPNOTSUPP;
+  }
+
+  return _do_setxattr(in, name, value, size, flags, uid, gid);
+}
+
+int Client::_setxattr(InodeRef &in, const char *name, const void *value,
+		      size_t size, int flags)
+{
+  if (cct->_conf->client_permissions) {
+    int r = xattr_permission(in.get(), name, MAY_WRITE);
+    if (r < 0)
+      return r;
+  }
+  return _setxattr(in.get(), name, value, size, flags);
+}
+
 int Client::check_data_pool_exist(string name, string value, const OSDMap *osdmap)
 {
   string tmp;
@@ -9327,6 +9888,12 @@ int Client::ll_setxattr(Inode *in, const char *name, const void *value,
   tout(cct) << vino.ino.val << std::endl;
   tout(cct) << name << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = xattr_permission(in, name, MAY_WRITE, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   return _setxattr(in, name, value, size, flags, uid, gid);
 }
 
@@ -9338,6 +9905,7 @@ int Client::_removexattr(Inode *in, const char *name, int uid, int gid)
 
   // same xattrs supported by kernel client
   if (strncmp(name, "user.", 5) &&
+      strncmp(name, "system.", 7) &&
       strncmp(name, "security.", 9) &&
       strncmp(name, "trusted.", 8) &&
       strncmp(name, "ceph.", 5))
@@ -9361,6 +9929,15 @@ int Client::_removexattr(Inode *in, const char *name, int uid, int gid)
   return res;
 }
 
+int Client::_removexattr(InodeRef &in, const char *name)
+{
+  if (cct->_conf->client_permissions) {
+    int r = xattr_permission(in.get(), name, MAY_WRITE);
+    if (r < 0)
+      return r;
+  }
+  return _removexattr(in.get(), name);
+}
 
 int Client::ll_removexattr(Inode *in, const char *name, int uid, int gid)
 {
@@ -9373,6 +9950,12 @@ int Client::ll_removexattr(Inode *in, const char *name, int uid, int gid)
   tout(cct) << vino.ino.val << std::endl;
   tout(cct) << name << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = xattr_permission(in, name, MAY_WRITE, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   return _removexattr(in, name, uid, gid);
 }
 
@@ -9633,13 +10216,20 @@ int Client::_mknod(Inode *dir, const char *name, mode_t mode, dev_t rdev,
   path.push_dentry(name);
   req->set_filepath(path); 
   req->set_inode(dir);
-  req->head.args.mknod.mode = mode;
   req->head.args.mknod.rdev = rdev;
   req->dentry_drop = CEPH_CAP_FILE_SHARED;
   req->dentry_unless = CEPH_CAP_FILE_EXCL;
 
+  bufferlist xattrs_bl;
+  int res = _posix_acl_create(dir, &mode, xattrs_bl, uid, gid);
+  if (res < 0)
+    goto fail;
+  req->head.args.mknod.mode = mode;
+  if (xattrs_bl.length() > 0)
+    req->set_data(xattrs_bl);
+
   Dentry *de;
-  int res = get_or_create(dir, name, &de);
+  res = get_or_create(dir, name, &de);
   if (res < 0)
     goto fail;
   req->set_dentry(de);
@@ -9671,6 +10261,12 @@ int Client::ll_mknod(Inode *parent, const char *name, mode_t mode,
   tout(cct) << mode << std::endl;
   tout(cct) << rdev << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_create(parent, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   InodeRef in;
   int r = _mknod(parent, name, mode, rdev, uid, gid, &in);
   if (r == 0) {
@@ -9724,7 +10320,6 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode,
   req->set_filepath(path);
   req->set_inode(dir);
   req->head.args.open.flags = flags | O_CREAT;
-  req->head.args.open.mode = mode;
 
   req->head.args.open.stripe_unit = stripe_unit;
   req->head.args.open.stripe_count = stripe_count;
@@ -9733,11 +10328,17 @@ int Client::_create(Inode *dir, const char *name, int flags, mode_t mode,
   req->dentry_drop = CEPH_CAP_FILE_SHARED;
   req->dentry_unless = CEPH_CAP_FILE_EXCL;
 
-  bufferlist extra_bl;
-  inodeno_t created_ino;
+  mode |= S_IFREG;
+  bufferlist xattrs_bl;
+  int res = _posix_acl_create(dir, &mode, xattrs_bl, uid, gid);
+  if (res < 0)
+    goto fail;
+  req->head.args.open.mode = mode;
+  if (xattrs_bl.length() > 0)
+    req->set_data(xattrs_bl);
 
   Dentry *de;
-  int res = get_or_create(dir, name, &de);
+  res = get_or_create(dir, name, &de);
   if (res < 0)
     goto fail;
   req->set_dentry(de);
@@ -9793,12 +10394,20 @@ int Client::_mkdir(Inode *dir, const char *name, mode_t mode, int uid, int gid,
   path.push_dentry(name);
   req->set_filepath(path);
   req->set_inode(dir);
-  req->head.args.mkdir.mode = mode;
   req->dentry_drop = CEPH_CAP_FILE_SHARED;
   req->dentry_unless = CEPH_CAP_FILE_EXCL;
 
+  mode |= S_IFDIR;
+  bufferlist xattrs_bl;
+  int res = _posix_acl_create(dir, &mode, xattrs_bl, uid, gid);
+  if (res < 0)
+    goto fail;
+  req->head.args.mkdir.mode = mode;
+  if (xattrs_bl.length() > 0)
+    req->set_data(xattrs_bl);
+
   Dentry *de;
-  int res = get_or_create(dir, name, &de);
+  res = get_or_create(dir, name, &de);
   if (res < 0)
     goto fail;
   req->set_dentry(de);
@@ -9830,6 +10439,12 @@ int Client::ll_mkdir(Inode *parent, const char *name, mode_t mode,
   tout(cct) << name << std::endl;
   tout(cct) << mode << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_create(parent, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   InodeRef in;
   int r = _mkdir(parent, name, mode, uid, gid, &in);
   if (r == 0) {
@@ -9902,6 +10517,12 @@ int Client::ll_symlink(Inode *parent, const char *name, const char *value,
   tout(cct) << name << std::endl;
   tout(cct) << value << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_create(parent, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   InodeRef in;
   int r = _symlink(parent, name, value, uid, gid, &in);
   if (r == 0) {
@@ -9970,6 +10591,11 @@ int Client::ll_unlink(Inode *in, const char *name, int uid, int gid)
   tout(cct) << vino.ino.val << std::endl;
   tout(cct) << name << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_delete(in, name, uid, gid);
+    if (r < 0)
+      return r;
+  }
   return _unlink(in, name, uid, gid);
 }
 
@@ -10031,6 +10657,12 @@ int Client::ll_rmdir(Inode *in, const char *name, int uid, int gid)
   tout(cct) << vino.ino.val << std::endl;
   tout(cct) << name << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_delete(in, name, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   return _rmdir(in, name, uid, gid);
 }
 
@@ -10140,6 +10772,15 @@ int Client::ll_rename(Inode *parent, const char *name, Inode *newparent,
   tout(cct) << vnewparent.ino.val << std::endl;
   tout(cct) << newname << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_delete(parent, name, uid, gid);
+    if (r < 0)
+      return r;
+    r = may_delete(newparent, newname, uid, gid);
+    if (r < 0 && r != -ENOENT)
+      return r;
+  }
+
   return _rename(parent, name, newparent, newname, uid, gid);
 }
 
@@ -10187,28 +10828,44 @@ int Client::_link(Inode *in, Inode *dir, const char *newname, int uid, int gid,
   return res;
 }
 
-int Client::ll_link(Inode *parent, Inode *newparent, const char *newname,
+int Client::ll_link(Inode *in, Inode *newparent, const char *newname,
 		    struct stat *attr, int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
 
-  vinodeno_t vparent = _get_vino(parent);
+  vinodeno_t vino = _get_vino(in);
   vinodeno_t vnewparent = _get_vino(newparent);
 
-  ldout(cct, 3) << "ll_link " << parent << " to " << vnewparent << " " <<
+  ldout(cct, 3) << "ll_link " << in << " to " << vnewparent << " " <<
     newname << dendl;
   tout(cct) << "ll_link" << std::endl;
-  tout(cct) << vparent.ino.val << std::endl;
+  tout(cct) << vino.ino.val << std::endl;
   tout(cct) << vnewparent << std::endl;
   tout(cct) << newname << std::endl;
 
+  int r = 0;
   InodeRef target;
-  int r = _link(parent, newparent, newname, uid, gid, &target);
+
+  if (!cct->_conf->fuse_default_permissions) {
+    if (S_ISDIR(in->mode)) {
+      r = -EPERM;
+      goto out;
+    }
+    r = may_hardlink(in, uid, gid);
+    if (r < 0)
+      goto out;
+    r = may_create(newparent, uid, gid);
+    if (r < 0)
+      goto out;
+  }
+
+  r = _link(in, newparent, newname, uid, gid, &target);
   if (r == 0) {
     assert(target);
     fill_stat(target, attr);
     _ll_get(target.get());
   }
+out:
   return r;
 }
 
@@ -10309,7 +10966,8 @@ uint64_t Client::ll_get_internal_offset(Inode *in, uint64_t blockno)
   return (blockno % stripes_per_object) * su;
 }
 
-int Client::ll_opendir(Inode *in, dir_result_t** dirpp, int uid, int gid)
+int Client::ll_opendir(Inode *in, int flags, dir_result_t** dirpp,
+		       int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
 
@@ -10319,6 +10977,12 @@ int Client::ll_opendir(Inode *in, dir_result_t** dirpp, int uid, int gid)
   tout(cct) << "ll_opendir" << std::endl;
   tout(cct) << vino.ino.val << std::endl;
 
+  if (!cct->_conf->fuse_default_permissions) {
+    int r = may_open(in, flags, uid, gid);
+    if (r < 0)
+      return r;
+  }
+
   int r = 0;
   if (vino.snapid == CEPH_SNAPDIR) {
     *dirpp = new dir_result_t(in);
@@ -10372,7 +11036,7 @@ int Client::ll_open(Inode *in, int flags, Fh **fhp, int uid, int gid)
     gid = get_gid();
   }
   if (!cct->_conf->fuse_default_permissions) {
-    r = check_permissions(in, flags, uid, gid);
+    r = may_open(in, flags, uid, gid);
     if (r < 0)
       goto out;
   }
@@ -10410,8 +11074,13 @@ int Client::ll_create(Inode *parent, const char *name, mode_t mode,
   if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
     return -EEXIST;
 
-   if (r == -ENOENT && (flags & O_CREAT)) {
-     r = _create(parent, name, flags, mode, &in, fhp /* may be NULL */,
+  if (r == -ENOENT && (flags & O_CREAT)) {
+    if (!cct->_conf->fuse_default_permissions) {
+      r = may_create(parent, uid, gid);
+      if (r < 0)
+	goto out;
+    }
+    r = _create(parent, name, flags, mode, &in, fhp /* may be NULL */,
 	        0, 0, 0, NULL, &created, uid, gid);
     if (r < 0)
       goto out;
@@ -10426,7 +11095,7 @@ int Client::ll_create(Inode *parent, const char *name, mode_t mode,
   ldout(cct, 20) << "ll_create created = " << created << dendl;
   if (!created) {
     if (!cct->_conf->fuse_default_permissions) {
-      r = check_permissions(in.get(), flags, uid, gid);
+      r = may_open(in.get(), flags, uid, gid);
       if (r < 0) {
 	if (fhp && *fhp) {
 	  int release_r = _release_fh(*fhp);
@@ -10436,7 +11105,7 @@ int Client::ll_create(Inode *parent, const char *name, mode_t mode,
       }
     }
     if (fhp && (*fhp == NULL)) {
-      r = _open(in.get(), flags, mode, fhp);
+      r = _open(in.get(), flags, mode, fhp, uid, gid);
       if (r < 0)
 	goto out;
     }
@@ -10576,7 +11245,7 @@ int Client::ll_write_block(Inode *in, uint64_t blockid,
 		  length,
 		  fakesnap,
 		  bl,
-		  ceph_clock_now(cct),
+		  ceph::real_clock::now(cct),
 		  0,
 		  onack,
 		  onsafe);
@@ -10742,12 +11411,13 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
 
       _invalidate_inode_cache(in, offset, length);
       r = filer->zero(in->ino, &in->layout,
-                      in->snaprealm->get_snap_context(),
-                      offset, length,
-                      ceph_clock_now(cct),
-                      0, true, onfinish, new C_OnFinisher(onsafe, &objecter_finisher));
+		      in->snaprealm->get_snap_context(),
+		      offset, length,
+		      ceph::real_clock::now(cct),
+		      0, true, onfinish,
+		      new C_OnFinisher(onsafe, &objecter_finisher));
       if (r < 0)
-        goto done;
+	goto done;
 
       in->mtime = ceph_clock_now(cct);
       mark_caps_dirty(in, CEPH_CAP_FILE_WR);
@@ -10854,24 +11524,24 @@ int Client::ll_getlk(Fh *fh, struct flock *fl, uint64_t owner)
   return _getlk(fh, fl, owner);
 }
 
-int Client::ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req)
+int Client::ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep)
 {
   Mutex::Locker lock(client_lock);
 
   ldout(cct, 3) << "ll_setlk  (fh) " << fh << " " << fh->inode->ino << dendl;
   tout(cct) << "ll_setk (fh)" << (unsigned long)fh << std::endl;
 
-  return _setlk(fh, fl, owner, sleep, fuse_req);
+  return _setlk(fh, fl, owner, sleep);
 }
 
-int Client::ll_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req)
+int Client::ll_flock(Fh *fh, int cmd, uint64_t owner)
 {
   Mutex::Locker lock(client_lock);
 
   ldout(cct, 3) << "ll_flock  (fh) " << fh << " " << fh->inode->ino << dendl;
   tout(cct) << "ll_flock (fh)" << (unsigned long)fh << std::endl;
 
-  return _flock(fh, cmd, owner, fuse_req);
+  return _flock(fh, cmd, owner);
 }
 
 class C_Client_RequestInterrupt : public Context  {
@@ -11374,17 +12044,17 @@ int Client::check_pool_perm(Inode *in, int need)
 
     C_SaferCond rd_cond;
     ObjectOperation rd_op;
-    rd_op.stat(NULL, (utime_t*)NULL, NULL);
+    rd_op.stat(NULL, (ceph::real_time*)nullptr, NULL);
 
     objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), rd_op,
-		     nullsnapc, ceph_clock_now(cct), 0, &rd_cond, NULL);
+		     nullsnapc, ceph::real_clock::now(cct), 0, &rd_cond, NULL);
 
     C_SaferCond wr_cond;
     ObjectOperation wr_op;
     wr_op.create(true);
 
     objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), wr_op,
-		     nullsnapc, ceph_clock_now(cct), 0, &wr_cond, NULL);
+		     nullsnapc, ceph::real_clock::now(cct), 0, &wr_cond, NULL);
 
     client_lock.Unlock();
     int rd_ret = rd_cond.wait();
@@ -11436,6 +12106,91 @@ int Client::check_pool_perm(Inode *in, int need)
   return 0;
 }
 
+int Client::_posix_acl_permission(Inode *in, uid_t uid, UserGroups& groups, unsigned want)
+{
+  if (acl_type == POSIX_ACL) {
+    if (in->xattrs.count(ACL_EA_ACCESS)) {
+      const bufferptr& access_acl = in->xattrs[ACL_EA_ACCESS];
+      return posix_acl_permits(access_acl, in->uid, in->gid, uid, groups, want);
+    }
+  }
+  return -EAGAIN;
+}
+
+int Client::_posix_acl_chmod(Inode *in, mode_t mode, int uid, int gid)
+{
+  if (acl_type == NO_ACL)
+    return 0;
+
+  int r = _getattr(in, CEPH_STAT_CAP_XATTR, uid, gid, in->xattr_version == 0);
+  if (r < 0)
+    goto out;
+
+  if (acl_type == POSIX_ACL) {
+    if (in->xattrs.count(ACL_EA_ACCESS)) {
+      const bufferptr& access_acl = in->xattrs[ACL_EA_ACCESS];
+      bufferptr acl(access_acl.c_str(), access_acl.length());
+      r = posix_acl_access_chmod(acl, mode);
+      if (r < 0)
+	goto out;
+      r = _do_setxattr(in, ACL_EA_ACCESS, acl.c_str(), acl.length(), 0, uid, gid);
+    } else {
+      r = 0;
+    }
+  }
+out:
+  ldout(cct, 10) << __func__ << " ino " << in->ino << " result=" << r << dendl;
+  return r;
+}
+
+int Client::_posix_acl_create(Inode *dir, mode_t *mode, bufferlist& xattrs_bl,
+			      int uid, int gid)
+{
+  if (acl_type == NO_ACL)
+    return 0;
+
+  if (S_ISLNK(*mode))
+    return 0;
+
+  int r = _getattr(dir, CEPH_STAT_CAP_XATTR, uid, gid, dir->xattr_version == 0);
+  if (r < 0)
+    goto out;
+
+  if (acl_type == POSIX_ACL) {
+    if (dir->xattrs.count(ACL_EA_DEFAULT)) {
+      map<string, bufferptr> xattrs;
+
+      const bufferptr& default_acl = dir->xattrs[ACL_EA_DEFAULT];
+      bufferptr acl(default_acl.c_str(), default_acl.length());
+      r = posix_acl_inherit_mode(acl, mode);
+      if (r < 0)
+	goto out;
+
+      if (r > 0) {
+	r = posix_acl_equiv_mode(acl.c_str(), acl.length(), mode);
+	if (r < 0)
+	  goto out;
+	if (r > 0)
+	  xattrs[ACL_EA_ACCESS] = acl;
+      }
+
+      if (S_ISDIR(*mode))
+	xattrs[ACL_EA_DEFAULT] = dir->xattrs[ACL_EA_DEFAULT];
+
+      r = xattrs.size();
+      if (r > 0)
+	::encode(xattrs, xattrs_bl);
+    } else {
+      if (umask_cb)
+	*mode &= ~umask_cb(callback_handle);
+      r = 0;
+    }
+  }
+out:
+  ldout(cct, 10) << __func__ << " dir ino " << dir->ino << " result=" << r << dendl;
+  return r;
+}
+
 void Client::set_filer_flags(int flags)
 {
   Mutex::Locker l(client_lock);
@@ -11469,6 +12224,7 @@ const char** Client::get_tracked_conf_keys() const
   static const char* keys[] = {
     "client_cache_size",
     "client_cache_mid",
+    "client_acl_type",
     NULL
   };
   return keys;
@@ -11482,6 +12238,37 @@ void Client::handle_conf_change(const struct md_config_t *conf,
     lru.lru_set_max(cct->_conf->client_cache_size);
     lru.lru_set_midpoint(cct->_conf->client_cache_mid);
   }
+  if (changed.count("client_acl_type")) {
+    acl_type = NO_ACL;
+    if (cct->_conf->client_acl_type == "posix_acl")
+      acl_type = POSIX_ACL;
+  }
+}
+
+bool Client::RequestUserGroups::is_in(gid_t id)
+{
+  if (id == gid)
+    return true;
+  if (sgid_count < 0)
+    init();
+  for (int i = 0; i < sgid_count; ++i) {
+    if (id == sgids[i])
+      return true;
+  }
+  return false;
+}
+
+int Client::RequestUserGroups::get_gids(const gid_t **out)
+{
+  if (sgid_count < 0)
+    init();
+  if (sgid_count > 0) {
+    *out = sgids;
+    return sgid_count;
+  } else {
+    *out = &gid;
+    return 1;
+  }
 }
 
 void intrusive_ptr_add_ref(Inode *in)
diff --git a/src/client/Client.h b/src/client/Client.h
index 8b31700..a3415b0 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -54,6 +54,7 @@ using std::fstream;
 #include "osdc/ObjectCacher.h"
 
 #include "InodeRef.h"
+#include "UserGroups.h"
 
 class MDSMap;
 class MonClient;
@@ -139,8 +140,9 @@ typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino,
 					 vinodeno_t ino, string& name);
 typedef int (*client_remount_callback_t)(void *handle);
 
-typedef int (*client_getgroups_callback_t)(void *handle, uid_t uid, gid_t **sgids);
-typedef void(*client_switch_interrupt_callback_t)(void *req, void *data);
+typedef int (*client_getgroups_callback_t)(void *handle, gid_t **sgids);
+typedef void(*client_switch_interrupt_callback_t)(void *handle, void *data);
+typedef mode_t (*client_umask_callback_t)(void *handle);
 
 struct client_callback_args {
   void *handle;
@@ -149,6 +151,7 @@ struct client_callback_args {
   client_switch_interrupt_callback_t switch_intr_cb;
   client_remount_callback_t remount_cb;
   client_getgroups_callback_t getgroups_cb;
+  client_umask_callback_t umask_cb;
 };
 
 // ========================================================
@@ -245,6 +248,7 @@ class Client : public Dispatcher, public md_config_obs_t {
   client_ino_callback_t ino_invalidate_cb;
   client_dentry_callback_t dentry_invalidate_cb;
   client_getgroups_callback_t getgroups_cb;
+  client_umask_callback_t umask_cb;
   bool can_invalidate_dentries;
   bool require_remount;
 
@@ -268,6 +272,7 @@ protected:
   client_t whoami;
 
   int user_id, group_id;
+  int acl_type;
 
   int get_uid() {
     if (user_id >= 0)
@@ -306,6 +311,7 @@ protected:
   void handle_client_session(MClientSession *m);
   void send_reconnect(MetaSession *s);
   void resend_unsafe_requests(MetaSession *s);
+  void wait_unsafe_requests();
 
   // mds requests
   ceph_tid_t last_tid;
@@ -349,6 +355,12 @@ protected:
   bool   mounted;
   bool   unmounting;
 
+  // When an MDS has sent us a REJECT, remember that and don't
+  // contact it again.  Remember which inst rejected us, so that
+  // when we talk to another inst with the same rank we can
+  // try again.
+  std::map<mds_rank_t, entity_inst_t> rejected_by_mds;
+
   int local_osd;
   epoch_t local_osd_epoch;
 
@@ -711,23 +723,26 @@ private:
   int _rmdir(Inode *dir, const char *name, int uid=-1, int gid=-1);
   int _symlink(Inode *dir, const char *name, const char *target, int uid=-1, int gid=-1, InodeRef *inp = 0);
   int _mknod(Inode *dir, const char *name, mode_t mode, dev_t rdev, int uid=-1, int gid=-1, InodeRef *inp = 0);
+  int _do_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid, InodeRef *inp);
   int _setattr(Inode *in, struct stat *attr, int mask, int uid=-1, int gid=-1, InodeRef *inp = 0);
-  int _setattr(InodeRef &in, struct stat *attr, int mask, int uid=-1, int gid=-1, InodeRef *inp = 0) {
-    return _setattr(in.get(), attr, mask, uid, gid, inp);
-  }
+  int _setattr(InodeRef &in, struct stat *attr, int mask);
   int _getattr(Inode *in, int mask, int uid=-1, int gid=-1, bool force=false);
   int _getattr(InodeRef &in, int mask, int uid=-1, int gid=-1, bool force=false) {
     return _getattr(in.get(), mask, uid, gid, force);
   }
   int _readlink(Inode *in, char *buf, size_t size);
   int _getxattr(Inode *in, const char *name, void *value, size_t len, int uid=-1, int gid=-1);
+  int _getxattr(InodeRef &in, const char *name, void *value, size_t len);
   int _listxattr(Inode *in, char *names, size_t len, int uid=-1, int gid=-1);
+  int _do_setxattr(Inode *in, const char *name, const void *value, size_t len, int flags, int uid, int gid);
   int _setxattr(Inode *in, const char *name, const void *value, size_t len, int flags, int uid=-1, int gid=-1);
+  int _setxattr(InodeRef &in, const char *name, const void *value, size_t len, int flags);
   int _removexattr(Inode *in, const char *nm, int uid=-1, int gid=-1);
-  int _open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid=-1, int gid=-1);
+  int _removexattr(InodeRef &in, const char *nm);
+  int _open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid);
   int _create(Inode *in, const char *name, int flags, mode_t mode, InodeRef *inp, Fh **fhp,
               int stripe_unit, int stripe_count, int object_size, const char *data_pool,
-	      bool *created = NULL, int uid=-1, int gid=-1);
+	      bool *created, int uid, int gid);
 
   loff_t _lseek(Fh *fh, loff_t offset, int whence);
   int _read(Fh *fh, int64_t offset, uint64_t size, bufferlist *bl);
@@ -740,13 +755,53 @@ private:
   int _sync_fs();
   int _fallocate(Fh *fh, int mode, int64_t offset, int64_t length);
   int _getlk(Fh *fh, struct flock *fl, uint64_t owner);
-  int _setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req=NULL);
-  int _flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req=NULL);
+  int _setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep);
+  int _flock(Fh *fh, int cmd, uint64_t owner);
 
   int get_or_create(Inode *dir, const char* name,
 		    Dentry **pdn, bool expect_null=false);
 
-  int check_permissions(Inode *in, int flags, int uid, int gid);
+  enum {
+    NO_ACL = 0,
+    POSIX_ACL,
+  };
+
+  enum {
+    MAY_EXEC = 1,
+    MAY_WRITE = 2,
+    MAY_READ = 4,
+  };
+
+  class RequestUserGroups : public UserGroups {
+    Client *client;
+    uid_t uid;
+    gid_t gid;
+    int sgid_count;
+    gid_t *sgids;
+    void init() {
+      sgid_count = client->_getgrouplist(&sgids, uid, gid);
+    }
+    public:
+    RequestUserGroups(Client *c, uid_t u, gid_t g) :
+      client(c), uid(u), gid(g), sgid_count(-1), sgids(NULL) {}
+    ~RequestUserGroups() {
+      free(sgids);
+    }
+    gid_t get_gid() { return gid; }
+    bool is_in(gid_t id);
+    int get_gids(const gid_t **out);
+  };
+
+  int inode_permission(Inode *in, uid_t uid, UserGroups& groups, unsigned want);
+  int xattr_permission(Inode *in, const char *name, unsigned want, int uid=-1, int gid=-1);
+  int may_setattr(Inode *in, struct stat *st, int mask, int uid=-1, int gid=-1);
+  int may_open(Inode *in, int flags, int uid=-1, int gid=-1);
+  int may_lookup(Inode *dir, int uid=-1, int gid=-1);
+  int may_create(Inode *dir, int uid=-1, int gid=-1);
+  int may_delete(Inode *dir, const char *name, int uid=-1, int gid=-1);
+  int may_hardlink(Inode *in, int uid=-1, int gid=-1);
+  int _getattr_for_perm(Inode *in, int uid, int gid);
+  int _getgrouplist(gid_t **sgids, int uid, int gid);
 
   int check_data_pool_exist(string name, string value, const OSDMap *osdmap);
 
@@ -802,11 +857,15 @@ private:
   }
 
   int _do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep,
-		   struct flock *fl, uint64_t owner, void *fuse_req=NULL);
+		   struct flock *fl, uint64_t owner);
   int _interrupt_filelock(MetaRequest *req);
   void _encode_filelocks(Inode *in, bufferlist& bl);
   void _release_filelocks(Fh *fh);
   void _update_lock_state(struct flock *fl, uint64_t owner, ceph_lock_state_t *lock_state);
+
+  int _posix_acl_create(Inode *dir, mode_t *mode, bufferlist& xattrs_bl, int uid, int gid);
+  int _posix_acl_chmod(Inode *in, mode_t mode, int uid, int gid);
+  int _posix_acl_permission(Inode *in, uid_t uid, UserGroups& groups, unsigned want);
 public:
   int mount(const std::string &mount_root, bool require_mds=false);
   void unmount();
@@ -867,7 +926,7 @@ public:
 
   // dirs
   int mkdir(const char *path, mode_t mode);
-  int mkdirs(const char *path, mode_t mode, int uid=-1, int gid=-1);
+  int mkdirs(const char *path, mode_t mode);
   int rmdir(const char *path);
 
   // symlinks
@@ -984,7 +1043,7 @@ public:
 		  int flags, int uid=-1, int gid=-1);
   int ll_removexattr(Inode *in, const char *name, int uid=-1, int gid=-1);
   int ll_listxattr(Inode *in, char *list, size_t size, int uid=-1, int gid=-1);
-  int ll_opendir(Inode *in, dir_result_t **dirpp, int uid = -1, int gid = -1);
+  int ll_opendir(Inode *in, int flags, dir_result_t **dirpp, int uid = -1, int gid = -1);
   int ll_releasedir(dir_result_t* dirp);
   int ll_fsyncdir(dir_result_t* dirp);
   int ll_readlink(Inode *in, char *buf, size_t bufsize, int uid = -1, int gid = -1);
@@ -1029,10 +1088,14 @@ public:
   int ll_fallocate(Fh *fh, int mode, loff_t offset, loff_t length);
   int ll_release(Fh *fh);
   int ll_getlk(Fh *fh, struct flock *fl, uint64_t owner);
-  int ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req);
-  int ll_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req);
+  int ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep);
+  int ll_flock(Fh *fh, int cmd, uint64_t owner);
   int ll_file_layout(Fh *fh, ceph_file_layout *layout);
   void ll_interrupt(void *d);
+  bool ll_handle_umask() {
+    return acl_type != NO_ACL;
+  }
+
   int ll_get_stripe_osd(struct Inode *in, uint64_t blockno,
 			ceph_file_layout* layout);
   uint64_t ll_get_internal_offset(struct Inode *in, uint64_t blockno);
diff --git a/src/client/Inode.cc b/src/client/Inode.cc
index 03e7a07..14ff341 100644
--- a/src/client/Inode.cc
+++ b/src/client/Inode.cc
@@ -7,6 +7,7 @@
 #include "Dir.h"
 #include "MetaSession.h"
 #include "ClientSnapRealm.h"
+#include "UserGroups.h"
 
 ostream& operator<<(ostream &out, Inode &in)
 {
@@ -279,34 +280,17 @@ Dir *Inode::open_dir()
   return dir;
 }
 
-bool Inode::check_mode(uid_t ruid, gid_t rgid, gid_t *sgids, int sgids_count, uint32_t rflags)
+bool Inode::check_mode(uid_t ruid, UserGroups& groups, unsigned want)
 {
-  unsigned fmode = 0;
-
-  if ((rflags & O_ACCMODE) == O_WRONLY)
-      fmode = 2;
-  else if ((rflags & O_ACCMODE) == O_RDWR)
-      fmode = 6;
-  else if ((rflags & O_ACCMODE) == O_RDONLY)
-      fmode = 4;
-
-  // if uid is owner, owner entry determines access
   if (uid == ruid) {
-    fmode = fmode << 6;
-  } else if (gid == rgid) {
+    // if uid is owner, owner entry determines access
+    want = want << 6;
+  } else if (groups.is_in(gid)) {
     // if a gid or sgid matches the owning group, group entry determines access
-    fmode = fmode << 3;
-  } else {
-    int i = 0;
-    for (; i < sgids_count; ++i) {
-      if (sgids[i] == gid) {
-        fmode = fmode << 3;
-	break;
-      }
-    }
+    want = want << 3;
   }
 
-  return (mode & fmode) == fmode;
+  return (mode & want) == want;
 }
 
 void Inode::get() {
diff --git a/src/client/Inode.h b/src/client/Inode.h
index a13fd98..bd10ad7 100644
--- a/src/client/Inode.h
+++ b/src/client/Inode.h
@@ -23,6 +23,7 @@ struct SnapRealm;
 struct Inode;
 class ceph_lock_state_t;
 class MetaRequest;
+class UserGroups;
 
 struct Cap {
   MetaSession *session;
@@ -295,7 +296,7 @@ struct Inode {
   ceph_lock_state_t *fcntl_locks;
   ceph_lock_state_t *flock_locks;
 
-  xlist<MetaRequest*> unsafe_dir_ops;
+  xlist<MetaRequest*> unsafe_ops;
 
   Inode(Client *c, vinodeno_t vino, ceph_file_layout *newlayout)
     : client(c), ino(vino.ino), snapid(vino.snapid), faked_ino(0),
@@ -334,7 +335,7 @@ struct Inode {
     }
   };
 
-  bool check_mode(uid_t uid, gid_t gid, gid_t *sgids, int sgid_count, uint32_t flags);
+  bool check_mode(uid_t uid, UserGroups& groups, unsigned want);
 
   // CAPS --------
   void get_open_ref(int mode);
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 8e47f51..31ca60c 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -6,7 +6,8 @@ libclient_la_SOURCES = \
 	client/MetaRequest.cc \
 	client/ClientSnapRealm.cc \
 	client/MetaSession.cc \
-	client/Trace.cc
+	client/Trace.cc \
+	client/posix_acl.cc
 libclient_la_LIBADD = $(LIBOSDC) $(LIBEDIT_LIBS)
 noinst_LTLIBRARIES += libclient.la
 
@@ -23,7 +24,9 @@ noinst_HEADERS += \
 	client/SyntheticClient.h \
 	client/Trace.h \
 	client/ioctl.h \
-	client/ObjecterWriteback.h
+	client/ObjecterWriteback.h \
+	client/posix_acl.h \
+	client/UserGroups.h
 
 if WITH_FUSE
 libclient_fuse_la_SOURCES = client/fuse_ll.cc
diff --git a/src/client/MetaRequest.cc b/src/client/MetaRequest.cc
index 330edde..1004f50 100644
--- a/src/client/MetaRequest.cc
+++ b/src/client/MetaRequest.cc
@@ -53,6 +53,8 @@ void MetaRequest::dump(Formatter *f) const
   f->dump_unsigned("num_retry", head.num_retry);
   f->dump_unsigned("num_fwd", head.num_fwd);
   f->dump_unsigned("num_releases", head.num_releases);
+
+  f->dump_int("abort_rc", abort_rc);
 }
 
 MetaRequest::~MetaRequest()
diff --git a/src/client/MetaRequest.h b/src/client/MetaRequest.h
index 660a88a..7a6bd3f 100644
--- a/src/client/MetaRequest.h
+++ b/src/client/MetaRequest.h
@@ -25,6 +25,7 @@ private:
   InodeRef _inode, _old_inode, _other_inode;
   Dentry *_dentry; //associated with path
   Dentry *_old_dentry; //associated with path2
+  int abort_rc;
 public:
   uint64_t tid;
   utime_t  op_stamp;
@@ -52,7 +53,6 @@ public:
   
   MClientReply *reply;         // the reply
   bool kick;
-  bool aborted;
   bool success;
   
   // readdir result
@@ -72,6 +72,7 @@ public:
   xlist<MetaRequest*>::item item;
   xlist<MetaRequest*>::item unsafe_item;
   xlist<MetaRequest*>::item unsafe_dir_item;
+  xlist<MetaRequest*>::item unsafe_target_item;
   Mutex lock; //for get/set sync
 
   Cond  *caller_cond;          // who to take up
@@ -81,7 +82,7 @@ public:
   InodeRef target;
 
   MetaRequest(int op) :
-    _dentry(NULL), _old_dentry(NULL),
+    _dentry(NULL), _old_dentry(NULL), abort_rc(0),
     tid(0),
     inode_drop(0), inode_unless(0),
     old_inode_drop(0), old_inode_unless(0),
@@ -92,9 +93,10 @@ public:
     mds(-1), resend_mds(-1), send_to_auth(false), sent_on_mseq(0),
     num_fwd(0), retry_attempt(0),
     ref(1), reply(0), 
-    kick(false), aborted(false), success(false),
+    kick(false), success(false),
     readdir_offset(0), readdir_end(false), readdir_num(0),
-    got_unsafe(false), item(this), unsafe_item(this), unsafe_dir_item(this),
+    got_unsafe(false), item(this), unsafe_item(this),
+    unsafe_dir_item(this), unsafe_target_item(this),
     lock("MetaRequest lock"),
     caller_cond(0), dispatch_cond(0) {
     memset(&head, 0, sizeof(ceph_mds_request_head));
@@ -102,6 +104,33 @@ public:
   }
   ~MetaRequest();
 
+  /**
+   * Prematurely terminate the request, such that callers
+   * to make_request will receive `rc` as their result.
+   */
+  void abort(int rc)
+  {
+    assert(rc != 0);
+    abort_rc = rc;
+  }
+
+  /**
+   * Whether abort() has been called for this request
+   */
+  inline bool aborted() const
+  {
+    return abort_rc != 0;
+  }
+
+  /**
+   * Given that abort() has been called for this request, what `rc` was
+   * passed into it?
+   */
+  int get_abort_code() const
+  {
+    return abort_rc;
+  }
+
   void set_inode(Inode *in) {
     _inode = in;
   }
diff --git a/src/client/MetaSession.h b/src/client/MetaSession.h
index e21be83..2eb8cd6 100644
--- a/src/client/MetaSession.h
+++ b/src/client/MetaSession.h
@@ -47,6 +47,7 @@ struct MetaSession {
   xlist<MetaRequest*> requests;
   xlist<MetaRequest*> unsafe_requests;
   std::set<ceph_tid_t> flushing_caps_tids;
+  std::set<ceph_tid_t> kicked_flush_tids;
 
   Cap *s_cap_iterator;
 
diff --git a/src/client/ObjecterWriteback.h b/src/client/ObjecterWriteback.h
index 69a9806..8acd3f7 100644
--- a/src/client/ObjecterWriteback.h
+++ b/src/client/ObjecterWriteback.h
@@ -30,16 +30,35 @@ class ObjecterWriteback : public WritebackHandler {
   }
 
   virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
-                           uint64_t off, uint64_t len, const SnapContext& snapc,
-                           const bufferlist &bl, utime_t mtime,
-                           uint64_t trunc_size, __u32 trunc_seq,
-                           ceph_tid_t journal_tid, Context *oncommit) {
+			   uint64_t off, uint64_t len,
+			   const SnapContext& snapc, const bufferlist &bl,
+			   ceph::real_time mtime, uint64_t trunc_size,
+			   __u32 trunc_seq, ceph_tid_t journal_tid,
+			   Context *oncommit) {
     return m_objecter->write_trunc(oid, oloc, off, len, snapc, bl, mtime, 0,
 				   trunc_size, trunc_seq, NULL,
-				   new C_OnFinisher(new C_Lock(m_lock, oncommit),
+				   new C_OnFinisher(new C_Lock(m_lock,
+							       oncommit),
 						    m_finisher));
   }
 
+  virtual bool can_scattered_write() { return true; }
+  virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
+                           vector<pair<uint64_t, bufferlist> >& io_vec,
+			   const SnapContext& snapc, ceph::real_time mtime,
+			   uint64_t trunc_size, __u32 trunc_seq,
+			   Context *oncommit) {
+    ObjectOperation op;
+    for (vector<pair<uint64_t, bufferlist> >::iterator p = io_vec.begin();
+	 p != io_vec.end();
+	 ++p)
+      op.write(p->first, p->second, trunc_size, trunc_seq);
+
+    return m_objecter->mutate(oid, oloc, op, snapc, mtime, 0, NULL,
+			      new C_OnFinisher(new C_Lock(m_lock, oncommit),
+					       m_finisher));
+  }
+
  private:
   Objecter *m_objecter;
   Finisher *m_finisher;
diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc
index 736448c..9d1888b 100644
--- a/src/client/SyntheticClient.cc
+++ b/src/client/SyntheticClient.cc
@@ -934,6 +934,7 @@ int SyntheticClient::start_thread()
 
   pthread_create(&thread_id, NULL, synthetic_client_thread_entry, this);
   assert(thread_id);
+  pthread_setname_np(thread_id, "client");
   return 0;
 }
 
@@ -1347,7 +1348,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
       dir_result_t *dirp;
       if (ll_inos.count(i)) {
 	i1 = client->ll_get_inode(vinodeno_t(ll_inos[i],CEPH_NOSNAP));
-	if (client->ll_opendir(i1, &dirp) == 0)
+	if (client->ll_opendir(i1, O_RDONLY, &dirp) == 0)
 	  ll_dirs[r] = dirp;
 	client->ll_put(i1);
       }
@@ -1441,7 +1442,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
       lock.Lock();
       object_locator_t oloc(SYNCLIENT_FIRST_POOL);
       uint64_t size;
-      utime_t mtime;
+      ceph::real_time mtime;
       client->objecter->stat(oid, oloc, CEPH_NOSNAP, &size, &mtime, 0, new C_SafeCond(&lock, &cond, &ack));
       while (!ack) cond.Wait(lock);
       lock.Unlock();
@@ -1471,7 +1472,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
       bufferlist bl;
       bl.push_back(bp);
       SnapContext snapc;
-      client->objecter->write(oid, oloc, off, len, snapc, bl, ceph_clock_now(client->cct), 0,
+      client->objecter->write(oid, oloc, off, len, snapc, bl,
+			      ceph::real_clock::now(client->cct), 0,
 			      new C_SafeCond(&lock, &cond, &ack),
 			      safeg.new_sub());
       safeg.activate();
@@ -1487,7 +1489,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
       object_locator_t oloc(SYNCLIENT_FIRST_POOL);
       lock.Lock();
       SnapContext snapc;
-      client->objecter->zero(oid, oloc, off, len, snapc, ceph_clock_now(client->cct), 0,
+      client->objecter->zero(oid, oloc, off, len, snapc,
+			     ceph::real_clock::now(client->cct), 0,
 			     new C_SafeCond(&lock, &cond, &ack),
 			     safeg.new_sub());
       safeg.activate();
@@ -1636,7 +1639,7 @@ int SyntheticClient::full_walk(string& basedir)
 	actual.nsubdirs++;
       else
 	actual.nfiles++;
-      
+
       // print
       char *tm = ctime(&st.st_mtime);
       tm[strlen(tm)-1] = 0;
@@ -2264,10 +2267,11 @@ int SyntheticClient::create_objects(int nobj, int osize, int inflight)
       dout(6) << "create_objects " << i << "/" << (nobj+1) << dendl;
     }
     dout(10) << "writing " << oid << dendl;
-    
+
     starts.push_back(ceph_clock_now(client->cct));
     client->client_lock.Lock();
-    client->objecter->write(oid, oloc, 0, osize, snapc, bl, ceph_clock_now(client->cct), 0,
+    client->objecter->write(oid, oloc, 0, osize, snapc, bl,
+			    ceph::real_clock::now(client->cct), 0,
 			    new C_Ref(lock, cond, &unack),
 			    new C_Ref(lock, cond, &unsafe));
     client->client_lock.Unlock();
@@ -2370,7 +2374,8 @@ int SyntheticClient::object_rw(int nobj, int osize, int wrpc,
       op.op.extent.length = osize;
       op.indata = bl;
       m.ops.push_back(op);
-      client->objecter->mutate(oid, oloc, m, snapc, ceph_clock_now(client->cct), 0,
+      client->objecter->mutate(oid, oloc, m, snapc,
+			       ceph::real_clock::now(client->cct), 0,
 			       NULL, new C_Ref(lock, cond, &unack));
     } else {
       dout(10) << "read from " << oid << dendl;
diff --git a/src/client/UserGroups.h b/src/client/UserGroups.h
new file mode 100644
index 0000000..3a3966f
--- /dev/null
+++ b/src/client/UserGroups.h
@@ -0,0 +1,12 @@
+#ifndef CEPH_CLIENT_USERGROUPS_H
+#define CEPH_CLIENT_USERGROUPS_H
+
+class UserGroups {
+public:
+  virtual bool is_in(gid_t gid) = 0;
+  virtual gid_t get_gid() = 0;
+  virtual int get_gids(const gid_t **gids) = 0;
+  virtual ~UserGroups() {};
+};
+
+#endif
diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc
index e46d6ac..bc55ffd 100644
--- a/src/client/fuse_ll.cc
+++ b/src/client/fuse_ll.cc
@@ -92,12 +92,23 @@ public:
   ceph::unordered_map<uint64_t,int> snap_stag_map;
   ceph::unordered_map<int,uint64_t> stag_snap_map;
 
+  pthread_key_t fuse_req_key;
+  void set_fuse_req(fuse_req_t);
+  fuse_req_t get_fuse_req();
+
   struct fuse_args args;
 };
 
-static void fuse_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
+static CephFuse::Handle *fuse_ll_req_prepare(fuse_req_t req)
 {
   CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  cfuse->set_fuse_req(req);
+  return cfuse;
+}
+
+static void fuse_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
+{
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   struct fuse_entry_param fe;
   Inode *i2, *i1 = cfuse->iget(parent); // see below
@@ -121,7 +132,7 @@ static void fuse_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
 static void fuse_ll_forget(fuse_req_t req, fuse_ino_t ino,
 			   long unsigned nlookup)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   cfuse->client->ll_forget(cfuse->iget(ino), nlookup+1);
   fuse_reply_none(req);
 }
@@ -129,7 +140,7 @@ static void fuse_ll_forget(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_getattr(fuse_req_t req, fuse_ino_t ino,
 			    struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   struct stat stbuf;
@@ -150,7 +161,7 @@ static void fuse_ll_getattr(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
 			    int to_set, struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
 
@@ -161,6 +172,8 @@ static void fuse_ll_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
   if (to_set & FUSE_SET_ATTR_MTIME) mask |= CEPH_SETATTR_MTIME;
   if (to_set & FUSE_SET_ATTR_ATIME) mask |= CEPH_SETATTR_ATIME;
   if (to_set & FUSE_SET_ATTR_SIZE) mask |= CEPH_SETATTR_SIZE;
+  if (to_set & FUSE_SET_ATTR_MTIME_NOW) mask |= CEPH_SETATTR_MTIME_NOW;
+  if (to_set & FUSE_SET_ATTR_ATIME_NOW) mask |= CEPH_SETATTR_ATIME_NOW;
 
   int r = cfuse->client->ll_setattr(in, attr, mask, ctx->uid, ctx->gid);
   if (r == 0)
@@ -181,7 +194,7 @@ static void fuse_ll_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
 #endif
   )
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
 
@@ -194,7 +207,7 @@ static void fuse_ll_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
 
 static void fuse_ll_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   char buf[size];
@@ -217,7 +230,7 @@ static void fuse_ll_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
 #endif
   )
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   char buf[size];
@@ -236,7 +249,7 @@ static void fuse_ll_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
 static void fuse_ll_removexattr(fuse_req_t req, fuse_ino_t ino,
 				const char *name)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
 
@@ -250,13 +263,13 @@ static void fuse_ll_removexattr(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_opendir(fuse_req_t req, fuse_ino_t ino,
 			    struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   void *dirp;
 
-  int r = cfuse->client->ll_opendir(in, (dir_result_t **) &dirp, ctx->uid,
-				    ctx->gid);
+  int r = cfuse->client->ll_opendir(in, fi->flags, (dir_result_t **)&dirp,
+				    ctx->uid, ctx->gid);
   if (r >= 0) {
     fi->fh = (long)dirp;
     fuse_reply_open(req, fi);
@@ -269,7 +282,7 @@ static void fuse_ll_opendir(fuse_req_t req, fuse_ino_t ino,
 
 static void fuse_ll_readlink(fuse_req_t req, fuse_ino_t ino)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   char buf[PATH_MAX + 1];  // leave room for a null terminator
@@ -288,7 +301,7 @@ static void fuse_ll_readlink(fuse_req_t req, fuse_ino_t ino)
 static void fuse_ll_mknod(fuse_req_t req, fuse_ino_t parent, const char *name,
 			  mode_t mode, dev_t rdev)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *i2, *i1 = cfuse->iget(parent);
   struct fuse_entry_param fe;
@@ -313,7 +326,7 @@ static void fuse_ll_mknod(fuse_req_t req, fuse_ino_t parent, const char *name,
 static void fuse_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name,
 			  mode_t mode)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *i2, *i1 = cfuse->iget(parent);
   struct fuse_entry_param fe;
@@ -337,7 +350,7 @@ static void fuse_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name,
 
 static void fuse_ll_unlink(fuse_req_t req, fuse_ino_t parent, const char *name)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(parent);
 
@@ -349,7 +362,7 @@ static void fuse_ll_unlink(fuse_req_t req, fuse_ino_t parent, const char *name)
 
 static void fuse_ll_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(parent);
 
@@ -362,7 +375,7 @@ static void fuse_ll_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name)
 static void fuse_ll_symlink(fuse_req_t req, const char *existing,
 			    fuse_ino_t parent, const char *name)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *i2, *i1 = cfuse->iget(parent);
   struct fuse_entry_param fe;
@@ -387,7 +400,7 @@ static void fuse_ll_symlink(fuse_req_t req, const char *existing,
 static void fuse_ll_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
 			   fuse_ino_t newparent, const char *newname)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(parent);
   Inode *nin = cfuse->iget(newparent);
@@ -402,7 +415,7 @@ static void fuse_ll_rename(fuse_req_t req, fuse_ino_t parent, const char *name,
 static void fuse_ll_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
 			 const char *newname)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   Inode *nin = cfuse->iget(newparent);
@@ -427,7 +440,7 @@ static void fuse_ll_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
 static void fuse_ll_open(fuse_req_t req, fuse_ino_t ino,
 			 struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *in = cfuse->iget(ino);
   Fh *fh = NULL;
@@ -450,7 +463,7 @@ static void fuse_ll_open(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
 			 struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
   bufferlist bl;
   int r = cfuse->client->ll_read(fh, off, size, &bl);
@@ -463,7 +476,7 @@ static void fuse_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
 static void fuse_ll_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
 			   size_t size, off_t off, struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
   int r = cfuse->client->ll_write(fh, off, size, buf);
   if (r >= 0)
@@ -475,7 +488,7 @@ static void fuse_ll_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
 static void fuse_ll_flush(fuse_req_t req, fuse_ino_t ino,
 			  struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
   int r = cfuse->client->ll_flush(fh);
   fuse_reply_err(req, -r);
@@ -485,7 +498,7 @@ static void fuse_ll_flush(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, struct fuse_file_info *fi,
                           unsigned flags, const void *in_buf, size_t in_bufsz, size_t out_bufsz)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
 
   if (flags & FUSE_IOCTL_COMPAT) {
     fuse_reply_err(req, ENOSYS);
@@ -517,7 +530,7 @@ static void fuse_ll_fallocate(fuse_req_t req, fuse_ino_t ino, int mode,
                               off_t offset, off_t length,
                               struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = (Fh*)fi->fh;
   int r = cfuse->client->ll_fallocate(fh, mode, offset, length);
   fuse_reply_err(req, -r);
@@ -528,7 +541,7 @@ static void fuse_ll_fallocate(fuse_req_t req, fuse_ino_t ino, int mode,
 static void fuse_ll_release(fuse_req_t req, fuse_ino_t ino,
 			    struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
   int r = cfuse->client->ll_release(fh);
   fuse_reply_err(req, -r);
@@ -537,7 +550,7 @@ static void fuse_ll_release(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
 			  struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
   int r = cfuse->client->ll_fsync(fh, datasync);
   fuse_reply_err(req, -r);
@@ -578,7 +591,7 @@ static int fuse_ll_add_dirent(void *p, struct dirent *de, struct stat *st,
 static void fuse_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
 			    off_t off, struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
 
   dir_result_t *dirp = reinterpret_cast<dir_result_t*>(fi->fh);
   cfuse->client->seekdir(dirp, off);
@@ -601,7 +614,7 @@ static void fuse_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
 static void fuse_ll_releasedir(fuse_req_t req, fuse_ino_t ino,
 			       struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   dir_result_t *dirp = reinterpret_cast<dir_result_t*>(fi->fh);
   cfuse->client->ll_releasedir(dirp);
   fuse_reply_err(req, 0);
@@ -610,7 +623,7 @@ static void fuse_ll_releasedir(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_fsyncdir(fuse_req_t req, fuse_ino_t ino, int datasync,
 			     struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   dir_result_t *dirp = reinterpret_cast<dir_result_t*>(fi->fh);
   int r = cfuse->client->ll_fsyncdir(dirp);
   fuse_reply_err(req, -r);
@@ -624,7 +637,7 @@ static void fuse_ll_access(fuse_req_t req, fuse_ino_t ino, int mask)
 static void fuse_ll_create(fuse_req_t req, fuse_ino_t parent, const char *name,
 			   mode_t mode, struct fuse_file_info *fi)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   const struct fuse_ctx *ctx = fuse_req_ctx(req);
   Inode *i1 = cfuse->iget(parent), *i2;
   struct fuse_entry_param fe;
@@ -649,7 +662,7 @@ static void fuse_ll_create(fuse_req_t req, fuse_ino_t parent, const char *name,
 static void fuse_ll_statfs(fuse_req_t req, fuse_ino_t ino)
 {
   struct statvfs stbuf;
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Inode *in = cfuse->iget(ino);
 
   int r = cfuse->client->ll_statfs(in, &stbuf);
@@ -664,7 +677,7 @@ static void fuse_ll_statfs(fuse_req_t req, fuse_ino_t ino)
 static void fuse_ll_getlk(fuse_req_t req, fuse_ino_t ino,
 			  struct fuse_file_info *fi, struct flock *lock)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
 
   int r = cfuse->client->ll_getlk(fh, lock, fi->lock_owner);
@@ -677,7 +690,7 @@ static void fuse_ll_getlk(fuse_req_t req, fuse_ino_t ino,
 static void fuse_ll_setlk(fuse_req_t req, fuse_ino_t ino,
 		          struct fuse_file_info *fi, struct flock *lock, int sleep)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = reinterpret_cast<Fh*>(fi->fh);
 
   // must use multithread if operation may block
@@ -687,29 +700,32 @@ static void fuse_ll_setlk(fuse_req_t req, fuse_ino_t ino,
     return;
   }
 
-  int r = cfuse->client->ll_setlk(fh, lock, fi->lock_owner, sleep, req);
+  int r = cfuse->client->ll_setlk(fh, lock, fi->lock_owner, sleep);
   fuse_reply_err(req, -r);
 }
 
 static void fuse_ll_interrupt(fuse_req_t req, void* data)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   cfuse->client->ll_interrupt(data);
 }
 
-static void switch_interrupt_cb(void *req, void* data)
+static void switch_interrupt_cb(void *handle, void* data)
 {
+  CephFuse::Handle *cfuse = (CephFuse::Handle *)handle;
+  fuse_req_t req = cfuse->get_fuse_req();
+
   if (data)
-    fuse_req_interrupt_func((fuse_req_t)req, fuse_ll_interrupt, data);
+    fuse_req_interrupt_func(req, fuse_ll_interrupt, data);
   else
-    fuse_req_interrupt_func((fuse_req_t)req, NULL, NULL);
+    fuse_req_interrupt_func(req, NULL, NULL);
 }
 
 #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 9)
 static void fuse_ll_flock(fuse_req_t req, fuse_ino_t ino,
 		          struct fuse_file_info *fi, int cmd)
 {
-  CephFuse::Handle *cfuse = (CephFuse::Handle *)fuse_req_userdata(req);
+  CephFuse::Handle *cfuse = fuse_ll_req_prepare(req);
   Fh *fh = (Fh*)fi->fh;
 
   // must use multithread if operation may block
@@ -719,17 +735,19 @@ static void fuse_ll_flock(fuse_req_t req, fuse_ino_t ino,
     return;
   }
 
-  int r = cfuse->client->ll_flock(fh, cmd, fi->lock_owner, req);
+  int r = cfuse->client->ll_flock(fh, cmd, fi->lock_owner);
   fuse_reply_err(req, -r);
 }
 #endif
 
-#if 0
-static int getgroups_cb(void *handle, uid_t uid, gid_t **sgids)
+static int getgroups_cb(void *handle, gid_t **sgids)
 {
-#ifdef HAVE_FUSE_GETGROUPS
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
+  CephFuse::Handle *cfuse = (CephFuse::Handle *)handle;
+  fuse_req_t req = cfuse->get_fuse_req();
+
   assert(sgids);
-  int c = fuse_getgroups(0, NULL);
+  int c = fuse_req_getgroups(req, 0, NULL);
   if (c < 0) {
     return c;
   }
@@ -741,16 +759,24 @@ static int getgroups_cb(void *handle, uid_t uid, gid_t **sgids)
   if (!*sgids) {
     return -ENOMEM;
   }
-  c = fuse_getgroups(c, *sgids);
+  c = fuse_req_getgroups(req, c, *sgids);
   if (c < 0) {
     free(*sgids);
     return c;
   }
   return c;
+#else
+  return -ENOSYS;
 #endif
-  return 0;
 }
-#endif
+
+static mode_t umask_cb(void *handle)
+{
+  CephFuse::Handle *cfuse = (CephFuse::Handle *)handle;
+  fuse_req_t req = cfuse->get_fuse_req();
+  const struct fuse_ctx *ctx = fuse_req_ctx(req);
+  return ctx->umask;
+}
 
 static void ino_invalidate_cb(void *handle, vinodeno_t vino, int64_t off,
 			      int64_t len)
@@ -792,9 +818,18 @@ static int remount_cb(void *handle)
   return r;
 }
 
-static void do_init(void *data, fuse_conn_info *bar)
+static void do_init(void *data, fuse_conn_info *conn)
 {
   CephFuse::Handle *cfuse = (CephFuse::Handle *)data;
+  Client *client = cfuse->client;
+
+  if (!client->cct->_conf->fuse_default_permissions &&
+      client->ll_handle_umask()) {
+    // apply umask in userspace if posix acl is enabled
+    if(conn->capable & FUSE_CAP_DONT_MASK)
+      conn->want |= FUSE_CAP_DONT_MASK;
+  }
+
   if (cfuse->fd_on_success) {
     //cout << "fuse init signaling on fd " << fd_on_success << std::endl;
     uint32_t r = 0;
@@ -898,10 +933,18 @@ void CephFuse::Handle::finalize()
   if (ch)
     fuse_unmount(mountpoint, ch);
 
+  pthread_key_delete(fuse_req_key);
 }
 
 int CephFuse::Handle::init(int argc, const char *argv[])
 {
+
+  int r = pthread_key_create(&fuse_req_key, NULL);
+  if (r) {
+    derr << "pthread_key_create failed." << dendl;
+    return r;
+  }
+
   // set up fuse argc/argv
   int newargc = 0;
   const char **newargv = (const char **) malloc((argc + 10) * sizeof(char *));
@@ -983,17 +1026,8 @@ int CephFuse::Handle::start()
 #if defined(__linux__)
     remount_cb: remount_cb,
 #endif
-    /*
-     * this is broken:
-     *
-     * - the cb needs the request handle to be useful; we should get the
-     *   gids in the method here in fuse_ll.c and pass the gid list in,
-     *   not use a callback.
-     * - the callback mallocs the list but it is not free()'d
-     *
-     * so disable it for now...
-     getgroups_cb: getgroups_cb,
-     */
+    getgroups_cb: getgroups_cb,
+    umask_cb: umask_cb,
   };
   client->ll_register_callbacks(&args);
 
@@ -1059,6 +1093,17 @@ uint64_t CephFuse::Handle::make_fake_ino(inodeno_t ino, snapid_t snapid)
   }
 }
 
+void CephFuse::Handle::set_fuse_req(fuse_req_t req)
+{
+  pthread_setspecific(fuse_req_key, (void*)req);
+}
+
+fuse_req_t CephFuse::Handle::get_fuse_req()
+{
+  return (fuse_req_t) pthread_getspecific(fuse_req_key);
+}
+
+
 CephFuse::CephFuse(Client *c, int fd) : _handle(new CephFuse::Handle(c, fd))
 {
 }
diff --git a/src/client/posix_acl.cc b/src/client/posix_acl.cc
new file mode 100644
index 0000000..50cb851
--- /dev/null
+++ b/src/client/posix_acl.cc
@@ -0,0 +1,283 @@
+#include "include/types.h"
+#include <sys/stat.h>
+#include "posix_acl.h"
+#include "UserGroups.h"
+
+int posix_acl_check(const void *xattr, size_t size)
+{
+  const acl_ea_header *header;
+  if (size < sizeof(*header))
+    return 0;
+  header = reinterpret_cast<const acl_ea_header*>(xattr);
+  ceph_le32 expected_version;
+  expected_version = ACL_EA_VERSION;
+  if (header->a_version != expected_version)
+    return 0;
+
+  const acl_ea_entry *entry = header->a_entries;
+  size -= sizeof(*header);
+  if (size % sizeof(*entry))
+    return 0;
+
+  int count = size / sizeof(*entry);
+  int state = ACL_USER_OBJ;
+  int needs_mask = 0;
+  for (int i = 0; i < count; ++i) {
+    __u16 tag = entry->e_tag;
+    switch(tag) {
+    case ACL_USER_OBJ:
+      if (state == ACL_USER_OBJ) {
+        state = ACL_USER;
+        break;
+      }
+      return 0;
+    case ACL_USER:
+      if (state != ACL_USER)
+        return 0;
+      needs_mask = 1;
+      break;
+    case ACL_GROUP_OBJ:
+      if (state == ACL_USER) {
+        state = ACL_GROUP;
+        break;
+      }
+      return 0;
+    case ACL_GROUP:
+      if (state != ACL_GROUP)
+        return 0;
+      needs_mask = 1;
+      break;
+    case ACL_MASK:
+      if (state != ACL_GROUP)
+        return 0;
+      state = ACL_OTHER;
+      break;
+    case ACL_OTHER:
+      if (state == ACL_OTHER ||
+          (state == ACL_GROUP && !needs_mask)) {
+        state = 0;
+        break;
+      }
+      // fall-thru
+    default:
+      return 0;
+    }
+    ++entry;
+  }
+
+  return state == 0;
+}
+
+int posix_acl_equiv_mode(const void *xattr, size_t size, mode_t *mode_p)
+{
+  if (!posix_acl_check(xattr, size))
+    return -EINVAL;
+
+  int not_equiv = 0;
+  mode_t mode = 0;
+
+  const acl_ea_header *header = reinterpret_cast<const acl_ea_header*>(xattr);
+  const acl_ea_entry *entry = header->a_entries;
+  int count = (size - sizeof(*header)) / sizeof(*entry);
+  for (int i = 0; i < count; ++i) {
+    __u16 tag = entry->e_tag;
+    __u16 perm = entry->e_perm;
+    switch(tag) {
+      case ACL_USER_OBJ:
+	mode |= (perm & S_IRWXO) << 6;
+	break;
+      case ACL_GROUP_OBJ:
+	mode |= (perm & S_IRWXO) << 3;
+	break;
+      case ACL_OTHER:
+	mode |= perm & S_IRWXO;
+	break;
+      case ACL_MASK:
+	mode = (mode & ~S_IRWXG) | ((perm & S_IRWXO) << 3);
+	/* fall through */
+      case ACL_USER:
+      case ACL_GROUP:
+	not_equiv = 1;
+	break;
+      default:
+	return -EINVAL;
+    }
+    ++entry;
+  }
+  if (mode_p)
+    *mode_p = (*mode_p & ~ACCESSPERMS) | mode;
+  return not_equiv;
+}
+
+int posix_acl_inherit_mode(bufferptr& acl, mode_t *mode_p)
+{
+  if (!posix_acl_check(acl.c_str(), acl.length()))
+    return -EIO;
+
+  acl_ea_entry *group_entry = NULL, *mask_entry = NULL;
+  mode_t mode = *mode_p;
+  int not_equiv = 0;
+
+  acl_ea_header *header = reinterpret_cast<acl_ea_header*>(acl.c_str());
+  acl_ea_entry *entry = header->a_entries;
+  int count = (acl.length() - sizeof(*header)) / sizeof(*entry);
+  for (int i = 0; i < count; ++i) {
+    __u16 tag = entry->e_tag;
+    __u16 perm = entry->e_perm;
+    switch(tag) {
+      case ACL_USER_OBJ:
+	perm &= (mode >> 6) | ~S_IRWXO;
+	mode &= (perm << 6) | ~S_IRWXU;
+	entry->e_perm = perm;
+	break;
+      case ACL_USER:
+      case ACL_GROUP:
+	not_equiv = 1;
+	break;
+      case ACL_GROUP_OBJ:
+	group_entry = entry;
+	break;
+      case ACL_OTHER:
+	perm &= mode | ~S_IRWXO;
+	mode &= perm | ~S_IRWXO;
+	entry->e_perm = perm;
+	break;
+      case ACL_MASK:
+	mask_entry = entry;
+	not_equiv = 1;
+	break;
+      default:
+	return -EIO;
+
+    }
+    ++entry;
+  }
+
+  if (mask_entry) {
+    __u16 perm = mask_entry->e_perm;
+    perm &= (mode >> 3) | ~S_IRWXO;
+    mode &= (perm << 3) | ~S_IRWXG;
+    mask_entry->e_perm = perm;
+  } else {
+    if (!group_entry)
+      return -EIO;
+    __u16 perm = group_entry->e_perm;
+    perm &= (mode >> 3) | ~S_IRWXO;
+    mode &= (perm << 3) | ~S_IRWXG;
+    group_entry->e_perm = perm;
+  }
+
+  *mode_p = (*mode_p & ~ACCESSPERMS) | mode;
+  return not_equiv;
+}
+
+int posix_acl_access_chmod(bufferptr& acl, mode_t mode)
+{
+  if (!posix_acl_check(acl.c_str(), acl.length()))
+    return -EIO;
+
+  acl_ea_entry *group_entry = NULL, *mask_entry = NULL;
+
+  acl_ea_header *header = reinterpret_cast<acl_ea_header*>(acl.c_str());
+  acl_ea_entry *entry = header->a_entries;
+  int count = (acl.length() - sizeof(*header)) / sizeof(*entry);
+  for (int i = 0; i < count; ++i) {
+    __u16 tag = entry->e_tag;
+    switch(tag) {
+      case ACL_USER_OBJ:
+	entry->e_perm = (mode & S_IRWXU) >> 6;
+	break;
+      case ACL_GROUP_OBJ:
+	group_entry = entry;
+	break;
+      case ACL_MASK:
+	mask_entry = entry;
+	break;
+      case ACL_OTHER:
+	entry->e_perm = mode & S_IRWXO;
+	break;
+      default:
+	break;
+    }
+    ++entry;
+  }
+
+  if (mask_entry) {
+    mask_entry->e_perm = (mode & S_IRWXG) >> 3;
+  } else {
+    if (!group_entry)
+      return -EIO;
+    group_entry->e_perm = (mode & S_IRWXG) >> 3;
+  }
+  return 0;
+}
+
+int posix_acl_permits(const bufferptr& acl, uid_t i_uid, gid_t i_gid,
+			 uid_t uid, UserGroups& groups, unsigned want)
+{
+  if (!posix_acl_check(acl.c_str(), acl.length()))
+    return -EIO;
+
+  const acl_ea_header *header = reinterpret_cast<const acl_ea_header*>(acl.c_str());
+  const acl_ea_entry *entry = header->a_entries;
+  const acl_ea_entry *next_entry;
+  __u16 perm, tag;
+  __u32 id;
+  int group_found = 0;
+  int idx;
+  int count = (acl.length() - sizeof(*header)) / sizeof(*entry);
+  for (idx = 0; idx < count; ++idx) {
+    tag = entry->e_tag;
+    perm = entry->e_perm;
+    switch(tag) {
+      case ACL_USER_OBJ:
+	if (i_uid == uid)
+	  goto check_perm;
+	break;
+      case ACL_USER:
+	id = entry->e_id;
+	if (id == uid)
+	  goto check_mask;
+	break;
+      case ACL_GROUP_OBJ:
+	/* fall through */
+      case ACL_GROUP:
+	id = (tag == ACL_GROUP_OBJ) ? i_gid : entry->e_id;
+	if (groups.is_in(id)) {
+	  group_found = 1;
+	  if ((perm & want) == want)
+	    goto check_mask;
+	}
+	break;
+      case ACL_MASK:
+	break;
+      case ACL_OTHER:
+	if (group_found)
+	  return -EACCES;
+	else
+	  goto check_perm;
+	break;
+      default:
+	return -EIO;
+    }
+    ++entry;
+  }
+  return -EIO;
+
+check_mask:
+  next_entry = entry + 1;
+  for (++idx; idx < count; ++idx) {
+    tag = next_entry->e_tag;
+    if (tag == ACL_MASK) {
+      __u16 mask = next_entry->e_perm;
+      if ((perm & mask & want) == want)
+	return 0;
+      return -EACCES;
+    }
+    ++next_entry;
+  }
+check_perm:
+  if ((perm & want) == want)
+    return 0;
+  return -EACCES;
+}
diff --git a/src/client/posix_acl.h b/src/client/posix_acl.h
new file mode 100644
index 0000000..d9c5cc8
--- /dev/null
+++ b/src/client/posix_acl.h
@@ -0,0 +1,35 @@
+#ifndef CEPH_POSIX_ACL
+#define CEPH_POSIX_ACL
+
+#define ACL_EA_VERSION          0x0002
+
+#define ACL_USER_OBJ            0x01
+#define ACL_USER                0x02
+#define ACL_GROUP_OBJ           0x04
+#define ACL_GROUP               0x08
+#define ACL_MASK                0x10
+#define ACL_OTHER               0x20
+
+#define ACL_EA_ACCESS  "system.posix_acl_access"
+#define ACL_EA_DEFAULT "system.posix_acl_default"
+
+typedef struct {
+  ceph_le16       e_tag;
+  ceph_le16       e_perm;
+  ceph_le32       e_id;
+} acl_ea_entry;
+
+typedef struct {
+  ceph_le32       a_version;
+  acl_ea_entry    a_entries[0];
+} acl_ea_header;
+
+class UserGroups;
+
+int posix_acl_check(const void *xattr, size_t size);
+int posix_acl_equiv_mode(const void *xattr, size_t size, mode_t *mode_p);
+int posix_acl_inherit_mode(bufferptr& acl, mode_t *mode_p);
+int posix_acl_access_chmod(bufferptr& acl, mode_t mode);
+int posix_acl_permits(const bufferptr& acl, uid_t i_uid, gid_t i_gid,
+		      uid_t uid, UserGroups& groups, unsigned want);
+#endif
diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc
index d1e7caa..8b88c5e 100644
--- a/src/cls/rbd/cls_rbd.cc
+++ b/src/cls/rbd/cls_rbd.cc
@@ -184,7 +184,7 @@ static int read_key(cls_method_context_t hctx, const string &key, T *out)
   int r = cls_cxx_map_get_val(hctx, key, &bl);
   if (r < 0) {
     if (r != -ENOENT) {
-      CLS_ERR("error reading omap key %s: %d", key.c_str(), r);
+      CLS_ERR("error reading omap key %s: %s", key.c_str(), cpp_strerror(r).c_str());
     }
     return r;
   }
@@ -515,7 +515,7 @@ int set_size(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   ::encode(size, sizebl);
   r = cls_cxx_map_set_val(hctx, "size", &sizebl);
   if (r < 0) {
-    CLS_ERR("error writing snapshot metadata: %d", r);
+    CLS_ERR("error writing snapshot metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -534,7 +534,7 @@ int set_size(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
       ::encode(parent, parentbl);
       r = cls_cxx_map_set_val(hctx, "parent", &parentbl);
       if (r < 0) {
-	CLS_ERR("error writing parent: %d", r);
+	CLS_ERR("error writing parent: %s", cpp_strerror(r).c_str());
 	return r;
       }
     }
@@ -672,7 +672,7 @@ int set_protection_status(cls_method_context_t hctx, bufferlist *in,
   ::encode(snap, snapshot_bl);
   r = cls_cxx_map_set_val(hctx, snapshot_key, &snapshot_bl);
   if (r < 0) {
-    CLS_ERR("error writing snapshot metadata: %d", r);
+    CLS_ERR("error writing snapshot metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -782,14 +782,14 @@ int set_stripe_unit_count(cls_method_context_t hctx, bufferlist *in, bufferlist
   ::encode(stripe_unit, bl);
   r = cls_cxx_map_set_val(hctx, "stripe_unit", &bl);
   if (r < 0) {
-    CLS_ERR("error writing stripe_unit metadata: %d", r);
+    CLS_ERR("error writing stripe_unit metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
   ::encode(stripe_count, bl2);
   r = cls_cxx_map_set_val(hctx, "stripe_count", &bl2);
   if (r < 0) {
-    CLS_ERR("error writing stripe_count metadata: %d", r);
+    CLS_ERR("error writing stripe_count metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1048,7 +1048,7 @@ int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   ::encode(parent, parentbl);
   r = cls_cxx_map_set_val(hctx, "parent", &parentbl);
   if (r < 0) {
-    CLS_ERR("error writing parent: %d", r);
+    CLS_ERR("error writing parent: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1132,7 +1132,7 @@ int remove_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 
   r = cls_cxx_map_remove_key(hctx, "parent");
   if (r < 0) {
-    CLS_ERR("error removing parent: %d", r);
+    CLS_ERR("error removing parent: %s", cpp_strerror(r).c_str());
     return r;
   }
   return 0;
@@ -1227,7 +1227,7 @@ int add_child(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   // get current child list for parent, if any
   r = read_key(hctx, key, &children);
   if ((r < 0) && (r != -ENOENT)) {
-    CLS_LOG(20, "add_child: omap read failed: %d", r);
+    CLS_LOG(20, "add_child: omap read failed: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1243,7 +1243,7 @@ int add_child(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   ::encode(children, childbl);
   r = cls_cxx_map_set_val(hctx, key, &childbl);
   if (r < 0)
-    CLS_LOG(20, "add_child: omap write failed: %d", r);
+    CLS_LOG(20, "add_child: omap write failed: %s", cpp_strerror(r).c_str());
   return r;
 }
 
@@ -1283,7 +1283,7 @@ int remove_child(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   // is an error (how can we remove something that doesn't exist?)
   r = read_key(hctx, key, &children);
   if (r < 0) {
-    CLS_LOG(20, "remove_child: read omap failed: %d", r);
+    CLS_LOG(20, "remove_child: read omap failed: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1298,14 +1298,14 @@ int remove_child(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   if (children.empty()) {
     r = cls_cxx_map_remove_key(hctx, key);
     if (r < 0)
-      CLS_LOG(20, "remove_child: remove key failed: %d", r);
+      CLS_LOG(20, "remove_child: remove key failed: %s", cpp_strerror(r).c_str());
   } else {
     // write back shortened children list
     bufferlist childbl;
     ::encode(children, childbl);
     r = cls_cxx_map_set_val(hctx, key, &childbl);
     if (r < 0)
-      CLS_LOG(20, "remove_child: write omap failed: %d ", r);
+      CLS_LOG(20, "remove_child: write omap failed: %s", cpp_strerror(r).c_str());
   }
   return r;
 }
@@ -1342,7 +1342,7 @@ int get_children(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   r = read_key(hctx, key, &children);
   if (r < 0) {
     if (r != -ENOENT)
-      CLS_LOG(20, "get_children: read omap failed: %d", r);
+      CLS_LOG(20, "get_children: read omap failed: %s", cpp_strerror(r).c_str());
     return r;
   }
   ::encode(children, *out);
@@ -1563,7 +1563,7 @@ int snapshot_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   vals[snapshot_key] = snap_metabl;
   r = cls_cxx_map_set_vals(hctx, &vals);
   if (r < 0) {
-    CLS_ERR("error writing snapshot metadata: %d", r);
+    CLS_ERR("error writing snapshot metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1641,7 +1641,7 @@ int snapshot_rename(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 
   r = cls_cxx_map_set_val(hctx, src_snap_key, &snap_metabl);
   if (r < 0) {
-    CLS_ERR("error writing snapshot metadata: %d", r);
+    CLS_ERR("error writing snapshot metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1685,7 +1685,7 @@ int snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 
   r = cls_cxx_map_remove_key(hctx, snapshot_key);
   if (r < 0) {
-    CLS_ERR("error writing snapshot metadata: %d", r);
+    CLS_ERR("error writing snapshot metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1753,7 +1753,7 @@ int get_id(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   bufferlist read_bl;
   r = cls_cxx_read(hctx, 0, size, &read_bl);
   if (r < 0) {
-    CLS_ERR("get_id: could not read id: %d", r);
+    CLS_ERR("get_id: could not read id: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1875,12 +1875,12 @@ static int dir_remove_image_helper(cls_method_context_t hctx,
   int r = read_key(hctx, name_key, &stored_id);
   if (r < 0) {
     if (r != -ENOENT)
-      CLS_ERR("error reading name to id mapping: %d", r);
+      CLS_ERR("error reading name to id mapping: %s", cpp_strerror(r).c_str());
     return r;
   }
   r = read_key(hctx, id_key, &stored_name);
   if (r < 0) {
-    CLS_ERR("error reading id to name mapping: %d", r);
+    CLS_ERR("error reading id to name mapping: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1893,13 +1893,13 @@ static int dir_remove_image_helper(cls_method_context_t hctx,
 
   r = cls_cxx_map_remove_key(hctx, name_key);
   if (r < 0) {
-    CLS_ERR("error removing name: %d", r);
+    CLS_ERR("error removing name: %s", cpp_strerror(r).c_str());
     return r;
   }
 
   r = cls_cxx_map_remove_key(hctx, id_key);
   if (r < 0) {
-    CLS_ERR("error removing id: %d", r);
+    CLS_ERR("error removing id: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -1970,7 +1970,7 @@ int dir_get_id(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   int r = read_key(hctx, dir_key_for_name(name), &id);
   if (r < 0) {
     if (r != -ENOENT)
-      CLS_ERR("error reading id for name '%s': %d", name.c_str(), r);
+      CLS_ERR("error reading id for name '%s': %s", name.c_str(), cpp_strerror(r).c_str());
     return r;
   }
   ::encode(id, *out);
@@ -2003,7 +2003,7 @@ int dir_get_name(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   string name;
   int r = read_key(hctx, dir_key_for_id(id), &name);
   if (r < 0) {
-    CLS_ERR("error reading name for id '%s': %d", id.c_str(), r);
+    CLS_ERR("error reading name for id '%s': %s", id.c_str(), cpp_strerror(r).c_str());
     return r;
   }
   ::encode(name, *out);
@@ -2047,7 +2047,7 @@ int dir_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
     r = cls_cxx_map_get_vals(hctx, last_read, RBD_DIR_NAME_KEY_PREFIX,
 			     max_read, &vals);
     if (r < 0) {
-      CLS_ERR("error reading directory by name: %d", r);
+      CLS_ERR("error reading directory by name: %s", cpp_strerror(r).c_str());
       return r;
     }
 
@@ -2093,7 +2093,7 @@ int dir_add_image(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 {
   int r = cls_cxx_create(hctx, false);
   if (r < 0) {
-    CLS_ERR("could not create directory: error %d", r);
+    CLS_ERR("could not create directory: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -2203,6 +2203,8 @@ int object_map_save(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
     return -EINVAL;
   }
 
+  object_map.set_crc_enabled(true);
+
   bufferlist bl;
   ::encode(object_map, bl);
   CLS_LOG(20, "object_map_save: object size=%" PRIu64 ", byte size=%u",
@@ -2315,6 +2317,11 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
   bufferlist footer_bl;
   r = cls_cxx_read(hctx, object_map.get_footer_offset(),
 		   size - object_map.get_footer_offset(), &footer_bl);
+  if (r < 0) {
+    CLS_ERR("object map footer read failed");
+    return r;
+  }
+ 
   try {
     bufferlist::iterator it = footer_bl.begin();
     object_map.decode_footer(it);
@@ -2370,19 +2377,23 @@ int object_map_update(cls_method_context_t hctx, bufferlist *in, bufferlist *out
     object_map.encode_data(data_bl, byte_offset, byte_length);
     r = cls_cxx_write(hctx, object_map.get_header_length() + byte_offset,
 		      data_bl.length(), &data_bl);
-
+    if (r < 0) {
+      CLS_ERR("failed to write object map header: %s", cpp_strerror(r).c_str());  
+      return r;         
+    }
+   
     footer_bl.clear();
     object_map.encode_footer(footer_bl);
     r = cls_cxx_write(hctx, object_map.get_footer_offset(), footer_bl.length(),
 		      &footer_bl);
+    if (r < 0) {
+      CLS_ERR("failed to write object map footer: %s", cpp_strerror(r).c_str());  
+      return r;
+    } 
   } else {
     CLS_LOG(20, "object_map_update: no update necessary");
   }
 
-  if (r < 0) {
-    return r;
-  }
-
   return 0;
 }
 
@@ -2552,7 +2563,7 @@ int metadata_set(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   }
   int r = cls_cxx_map_set_vals(hctx, &raw_data);
   if (r < 0) {
-    CLS_ERR("error writing metadata: %d", r);
+    CLS_ERR("error writing metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -2581,7 +2592,7 @@ int metadata_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 
   int r = cls_cxx_map_remove_key(hctx, metadata_key_for_name(key));
   if (r < 0) {
-    CLS_ERR("error remove metadata: %d", r);
+    CLS_ERR("error remove metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -2612,7 +2623,7 @@ int metadata_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 
   int r = cls_cxx_map_get_val(hctx, metadata_key_for_name(key), &value);
   if (r < 0) {
-    CLS_ERR("error get metadata: %d", r);
+    CLS_ERR("error get metadata: %s", cpp_strerror(r).c_str());
     return r;
   }
 
@@ -2790,7 +2801,7 @@ int old_snapshot_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *o
   if (header->snap_count) {
     int snaps_len = 0;
     int names_len = 0;
-    CLS_LOG(20, "i=%d\n", i);
+    CLS_LOG(20, "i=%u\n", i);
     if (i > 0) {
       snaps_len = sizeof(header->snaps[0]) * i;
       names_len =  snap_names - orig_names;
@@ -2887,7 +2898,7 @@ int old_snapshot_rename(cls_method_context_t hctx, bufferlist *in, bufferlist *o
 
   if (header->snap_count) {
     int names_len = 0;
-    CLS_LOG(20, "i=%d\n", i);
+    CLS_LOG(20, "i=%u\n", i);
     if (i > 0) {
       names_len =  snap_names - orig_names;
       memcpy(new_names_bp.c_str(), orig_names, names_len);
diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc
index b4892fd..088e2c5 100644
--- a/src/cls/rgw/cls_rgw.cc
+++ b/src/cls/rgw/cls_rgw.cc
@@ -461,7 +461,7 @@ int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
       decode_list_index_key(kiter->first, &key, &ver);
 
       start_key = kiter->first;
-      CLS_LOG(20, "start_key=%s len=%d", start_key.c_str(), start_key.size());
+      CLS_LOG(20, "start_key=%s len=%lu", start_key.c_str(), start_key.size());
 
       if (!entry.is_valid()) {
         CLS_LOG(20, "entry %s[%s] is not valid\n", key.name.c_str(), key.instance.c_str());
diff --git a/src/cls/user/cls_user.cc b/src/cls/user/cls_user.cc
index 3a91112..d168e7c 100644
--- a/src/cls/user/cls_user.cc
+++ b/src/cls/user/cls_user.cc
@@ -289,7 +289,9 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff
 
   map<string, bufferlist> keys;
 
-  string from_index = op.marker;
+  const string& from_index = op.marker;
+  const string& to_index = op.end_marker;
+  const bool to_index_valid = !to_index.empty();
 
 #define MAX_ENTRIES 1000
   size_t max_entries = op.max_entries;
@@ -302,7 +304,10 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff
   if (rc < 0)
     return rc;
 
-  CLS_LOG(20, "from_index=%s match_prefix=%s", from_index.c_str(), match_prefix.c_str());
+  CLS_LOG(20, "from_index=%s to_index=%s match_prefix=%s",
+          from_index.c_str(),
+          to_index.c_str(),
+          match_prefix.c_str());
   cls_user_list_buckets_ret ret;
 
   list<cls_user_bucket_entry>& entries = ret.entries;
@@ -316,6 +321,9 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff
     const string& index = iter->first;
     marker = index;
 
+    if (to_index_valid && to_index.compare(index) <= 0)
+      break;
+
     bufferlist& bl = iter->second;
     bufferlist::iterator biter = bl.begin();
     try {
diff --git a/src/cls/user/cls_user_client.cc b/src/cls/user/cls_user_client.cc
index d86c5bf..279117e 100644
--- a/src/cls/user/cls_user_client.cc
+++ b/src/cls/user/cls_user_client.cc
@@ -72,12 +72,18 @@ public:
 };
 
 void cls_user_bucket_list(librados::ObjectReadOperation& op,
-                       const string& in_marker, int max_entries, list<cls_user_bucket_entry>& entries,
-                       string *out_marker, bool *truncated, int *pret)
+                          const string& in_marker,
+                          const string& end_marker,
+                          int max_entries,
+                          list<cls_user_bucket_entry>& entries,
+                          string *out_marker,
+                          bool *truncated,
+                          int *pret)
 {
   bufferlist inbl;
   cls_user_list_buckets_op call;
   call.marker = in_marker;
+  call.end_marker = end_marker;
   call.max_entries = max_entries;
 
   ::encode(call, inbl);
diff --git a/src/cls/user/cls_user_client.h b/src/cls/user/cls_user_client.h
index dcfdab6..5a1d944 100644
--- a/src/cls/user/cls_user_client.h
+++ b/src/cls/user/cls_user_client.h
@@ -23,9 +23,12 @@ void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_buck
 void cls_user_complete_stats_sync(librados::ObjectWriteOperation& op);
 void cls_user_remove_bucket(librados::ObjectWriteOperation& op,  const cls_user_bucket& bucket);
 void cls_user_bucket_list(librados::ObjectReadOperation& op,
-                       const string& in_marker, int max_entries,
+                       const string& in_marker,
+                       const string& end_marker,
+                       int max_entries,
                        list<cls_user_bucket_entry>& entries,
-                       string *out_marker, bool *truncated,
+                       string *out_marker,
+                       bool *truncated,
                        int *pret);
 void cls_user_get_header(librados::ObjectReadOperation& op, cls_user_header *header, int *pret);
 int cls_user_get_header_async(librados::IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx);
diff --git a/src/cls/user/cls_user_ops.h b/src/cls/user/cls_user_ops.h
index e1a169b..9b3686e 100644
--- a/src/cls/user/cls_user_ops.h
+++ b/src/cls/user/cls_user_ops.h
@@ -59,6 +59,7 @@ WRITE_CLASS_ENCODER(cls_user_remove_bucket_op)
 
 struct cls_user_list_buckets_op {
   string marker;
+  string end_marker;
   int max_entries; /* upperbound to returned num of entries
                       might return less than that and still be truncated */
 
@@ -66,16 +67,20 @@ struct cls_user_list_buckets_op {
     : max_entries(0) {}
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(1, 1, bl);
+    ENCODE_START(2, 1, bl);
     ::encode(marker, bl);
     ::encode(max_entries, bl);
+    ::encode(end_marker, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-    DECODE_START(1, bl);
+    DECODE_START(2, bl);
     ::decode(marker, bl);
     ::decode(max_entries, bl);
+    if (struct_v >= 2) {
+      ::decode(end_marker, bl);
+    }
     DECODE_FINISH(bl);
   }
 
diff --git a/src/common/Cond.h b/src/common/Cond.h
index 46fdf15..c0301ea 100644
--- a/src/common/Cond.h
+++ b/src/common/Cond.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -17,13 +17,14 @@
 #define CEPH_COND_H
 
 #include <time.h>
-
-#include "Mutex.h"
-#include "Clock.h"
+#include <pthread.h>
 
 #include "include/Context.h"
 
-#include <pthread.h>
+#include "common/ceph_time.h"
+#include "common/Mutex.h"
+#include "common/Clock.h"
+
 
 class Cond {
   // my bits
@@ -73,12 +74,27 @@ class Cond {
 
     return r;
   }
+
   int WaitInterval(CephContext *cct, Mutex &mutex, utime_t interval) {
     utime_t when = ceph_clock_now(cct);
     when += interval;
     return WaitUntil(mutex, when);
   }
 
+  template<typename Duration>
+  int WaitInterval(CephContext *cct, Mutex &mutex, Duration interval) {
+    ceph::real_time when(ceph::real_clock::now(cct));
+    when += interval;
+
+    struct timespec ts = ceph::real_clock::to_timespec(when);
+
+    mutex._pre_unlock();
+    int r = pthread_cond_timedwait(&_c, &mutex._m, &ts);
+    mutex._post_lock();
+
+    return r;
+  }
+
   int SloppySignal() { 
     int r = pthread_cond_broadcast(&_c);
     return r;
diff --git a/src/common/Finisher.cc b/src/common/Finisher.cc
index 9b39dc8..73900dd 100644
--- a/src/common/Finisher.cc
+++ b/src/common/Finisher.cc
@@ -12,7 +12,7 @@
 void Finisher::start()
 {
   ldout(cct, 10) << __func__ << dendl;
-  finisher_thread.create();
+  finisher_thread.create(thread_name.c_str());
 }
 
 void Finisher::stop()
diff --git a/src/common/Finisher.h b/src/common/Finisher.h
index 95db977..26a41b7 100644
--- a/src/common/Finisher.h
+++ b/src/common/Finisher.h
@@ -48,6 +48,8 @@ class Finisher {
   /// should be completed in that place instead.
   vector<Context*> finisher_queue;
 
+  string thread_name;
+
   /// Queue for contexts for which the complete function will be called
   /// with a parameter other than 0.
   list<pair<Context*,int> > finisher_queue_rval;
@@ -135,14 +137,14 @@ class Finisher {
   Finisher(CephContext *cct_) :
     cct(cct_), finisher_lock("Finisher::finisher_lock"),
     finisher_stop(false), finisher_running(false),
-    logger(0),
+    thread_name("fn_anonymous"), logger(0),
     finisher_thread(this) {}
 
   /// Construct a named Finisher that logs its queue length.
-  Finisher(CephContext *cct_, string name) :
+  Finisher(CephContext *cct_, string name, string tn) :
     cct(cct_), finisher_lock("Finisher::finisher_lock"),
     finisher_stop(false), finisher_running(false),
-    logger(0),
+    thread_name(tn), logger(0),
     finisher_thread(this) {
     PerfCountersBuilder b(cct, string("finisher-") + name,
 			  l_finisher_first, l_finisher_last);
diff --git a/src/common/Formatter.cc b/src/common/Formatter.cc
index f5ce058..9e7fd38 100644
--- a/src/common/Formatter.cc
+++ b/src/common/Formatter.cc
@@ -139,8 +139,6 @@ void JSONFormatter::flush(std::ostream& os)
 {
   finish_pending_string();
   os << m_ss.str();
-  if (m_pretty)
-    os << "\n";
   m_ss.clear();
   m_ss.str("");
 }
@@ -251,6 +249,8 @@ void JSONFormatter::close_section()
   }
   m_ss << (entry.is_array ? ']' : '}');
   m_stack.pop_back();
+  if (m_pretty && m_stack.empty())
+    m_ss << "\n";
 }
 
 void JSONFormatter::finish_pending_string()
diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc
index f2bf02d..51b7aa7 100644
--- a/src/common/HeartbeatMap.cc
+++ b/src/common/HeartbeatMap.cc
@@ -21,6 +21,7 @@
 #include "HeartbeatMap.h"
 #include "ceph_context.h"
 #include "common/errno.h"
+#include "common/valgrind.h"
 
 #include "debug.h"
 #define dout_subsys ceph_subsys_heartbeatmap
@@ -48,6 +49,10 @@ heartbeat_handle_d *HeartbeatMap::add_worker(const string& name)
   m_rwlock.get_write();
   ldout(m_cct, 10) << "add_worker '" << name << "'" << dendl;
   heartbeat_handle_d *h = new heartbeat_handle_d(name);
+  ANNOTATE_BENIGN_RACE_SIZED(&h->timeout, sizeof(h->timeout),
+                             "heartbeat_handle_d timeout");
+  ANNOTATE_BENIGN_RACE_SIZED(&h->suicide_timeout, sizeof(h->suicide_timeout),
+                             "heartbeat_handle_d suicide_timeout");
   m_workers.push_front(h);
   h->list_item = m_workers.begin();
   m_rwlock.put_write();
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 182295f..5ed2d3b 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -14,6 +14,7 @@ libcommon_internal_la_SOURCES = \
 	common/cmdparse.cc \
 	common/escape.c \
 	common/io_priority.cc \
+	common/ceph_time.cc \
 	common/Clock.cc \
 	common/Throttle.cc \
 	common/Timer.cc \
@@ -156,6 +157,7 @@ noinst_HEADERS += \
 # important; libmsg before libauth!
 LIBCOMMON_DEPS += \
 	$(LIBERASURE_CODE) \
+	$(LIBCOMPRESSOR) \
 	$(LIBMSG) $(LIBAUTH) \
 	$(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
 	$(BOOST_RANDOM_LIBS)
@@ -263,7 +265,9 @@ noinst_HEADERS += \
 	common/valgrind.h \
 	common/TracepointProvider.h \
 	common/event_socket.h \
-	common/PluginRegistry.h
+	common/PluginRegistry.h \
+	common/ceph_time.h \
+	common/ceph_timer.h
 
 if ENABLE_XIO
 noinst_HEADERS += \
diff --git a/src/common/Mutex.cc b/src/common/Mutex.cc
index 5e9b590..05059b9 100644
--- a/src/common/Mutex.cc
+++ b/src/common/Mutex.cc
@@ -20,6 +20,7 @@
 #include "include/stringify.h"
 #include "include/utime.h"
 #include "common/Clock.h"
+#include "common/valgrind.h"
 
 Mutex::Mutex(const std::string &n, bool r, bool ld,
 	     bool bt,
@@ -27,6 +28,9 @@ Mutex::Mutex(const std::string &n, bool r, bool ld,
   name(n), id(-1), recursive(r), lockdep(ld), backtrace(bt), nlock(0),
   locked_by(0), cct(cct), logger(0)
 {
+  ANNOTATE_BENIGN_RACE_SIZED(&id, sizeof(id), "Mutex lockdep id");
+  ANNOTATE_BENIGN_RACE_SIZED(&nlock, sizeof(nlock), "Mutex nlock");
+  ANNOTATE_BENIGN_RACE_SIZED(&locked_by, sizeof(locked_by), "Mutex locked_by");
   if (cct) {
     PerfCountersBuilder b(cct, string("mutex-") + name,
 			  l_mutex_first, l_mutex_last);
@@ -71,7 +75,11 @@ Mutex::Mutex(const std::string &n, bool r, bool ld,
 
 Mutex::~Mutex() {
   assert(nlock == 0);
+
+  // helgrind gets confused by condition wakeups leading to mutex destruction
+  ANNOTATE_BENIGN_RACE_SIZED(&_m, sizeof(_m), "Mutex primitive");
   pthread_mutex_destroy(&_m);
+
   if (cct && logger) {
     cct->get_perfcounters_collection()->remove(logger);
     delete logger;
diff --git a/src/common/OutputDataSocket.cc b/src/common/OutputDataSocket.cc
index e43f5cf..a1c368b 100644
--- a/src/common/OutputDataSocket.cc
+++ b/src/common/OutputDataSocket.cc
@@ -371,7 +371,7 @@ bool OutputDataSocket::init(const std::string &path)
   m_shutdown_rd_fd = pipe_rd;
   m_shutdown_wr_fd = pipe_wr;
   m_path = path;
-  create();
+  create("out_data_socket");
   add_cleanup_file(m_path.c_str());
   return true;
 }
diff --git a/src/common/RWLock.h b/src/common/RWLock.h
index 47a8c87..282b69b 100644
--- a/src/common/RWLock.h
+++ b/src/common/RWLock.h
@@ -22,6 +22,7 @@
 #include <include/assert.h>
 #include "lockdep.h"
 #include "include/atomic.h"
+#include "common/valgrind.h"
 
 class RWLock
 {
@@ -39,6 +40,9 @@ public:
 
   RWLock(const std::string &n, bool track_lock=true) : name(n), id(-1), nrlock(0), nwlock(0), track(track_lock) {
     pthread_rwlock_init(&L, NULL);
+    ANNOTATE_BENIGN_RACE_SIZED(&id, sizeof(id), "RWLock lockdep id");
+    ANNOTATE_BENIGN_RACE_SIZED(&nrlock, sizeof(nrlock), "RWlock nrlock");
+    ANNOTATE_BENIGN_RACE_SIZED(&nwlock, sizeof(nwlock), "RWlock nwlock");
     if (g_lockdep) id = lockdep_register(name.c_str());
   }
 
diff --git a/src/common/RefCountedObj.h b/src/common/RefCountedObj.h
index 3755018..cd886f6 100644
--- a/src/common/RefCountedObj.h
+++ b/src/common/RefCountedObj.h
@@ -19,6 +19,7 @@
 #include "common/Cond.h"
 #include "include/atomic.h"
 #include "common/ceph_context.h"
+#include "common/valgrind.h"
 
 struct RefCountedObject {
 private:
@@ -41,8 +42,13 @@ public:
   void put() {
     CephContext *local_cct = cct;
     int v = nref.dec();
-    if (v == 0)
+    if (v == 0) {
+      ANNOTATE_HAPPENS_AFTER(&nref);
+      ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&nref);
       delete this;
+    } else {
+      ANNOTATE_HAPPENS_BEFORE(&nref);
+    }
     if (local_cct)
       lsubdout(local_cct, refs, 1) << "RefCountedObject::put " << this << " "
 				   << (v + 1) << " -> " << v
diff --git a/src/common/Thread.cc b/src/common/Thread.cc
index b917838..4d40016 100644
--- a/src/common/Thread.cc
+++ b/src/common/Thread.cc
@@ -143,7 +143,7 @@ int Thread::try_create(size_t stacksize)
   return r;
 }
 
-void Thread::create(size_t stacksize)
+void Thread::create(const char *name, size_t stacksize)
 {
   int ret = try_create(stacksize);
   if (ret != 0) {
@@ -152,6 +152,9 @@ void Thread::create(size_t stacksize)
 	     "failed with error %d", ret);
     dout_emergency(buf);
     assert(ret == 0);
+  } else if (thread_id > 0) {
+      assert(strlen(name) < 16);
+      pthread_setname_np(thread_id, name);
   }
 }
 
diff --git a/src/common/Thread.h b/src/common/Thread.h
index 98b76fd..deced8f 100644
--- a/src/common/Thread.h
+++ b/src/common/Thread.h
@@ -48,7 +48,7 @@ class Thread {
   bool am_self() const;
   int kill(int signal);
   int try_create(size_t stacksize);
-  void create(size_t stacksize = 0);
+  void create(const char *name, size_t stacksize = 0);
   int join(void **prval = 0);
   int detach();
   int set_ioprio(int cls, int prio);
diff --git a/src/common/Timer.cc b/src/common/Timer.cc
index e49a700..1160541 100644
--- a/src/common/Timer.cc
+++ b/src/common/Timer.cc
@@ -62,7 +62,7 @@ void SafeTimer::init()
 {
   ldout(cct,10) << "init" << dendl;
   thread = new SafeTimerThread(this);
-  thread->create();
+  thread->create("safe_timer");
 }
 
 void SafeTimer::shutdown()
diff --git a/src/common/TracepointProvider.h b/src/common/TracepointProvider.h
index e54a037..447e2de 100644
--- a/src/common/TracepointProvider.h
+++ b/src/common/TracepointProvider.h
@@ -56,7 +56,7 @@ public:
 
   template <const Traits &traits>
   static void initialize(CephContext *cct) {
-#if WITH_LTTNG
+#ifdef WITH_LTTNG
     TypedSingleton<traits> *singleton;
     cct->lookup_or_create_singleton_object(singleton, traits.library);
 #endif
diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc
index 00666fa..9d99fd1 100644
--- a/src/common/WorkQueue.cc
+++ b/src/common/WorkQueue.cc
@@ -27,8 +27,8 @@
 #define dout_prefix *_dout << name << " "
 
 
-ThreadPool::ThreadPool(CephContext *cct_, string nm, int n, const char *option)
-  : cct(cct_), name(nm),
+ThreadPool::ThreadPool(CephContext *cct_, string nm, string tn, int n, const char *option)
+  : cct(cct_), name(nm), thread_name(tn),
     lockname(nm + "::lock"),
     _lock(lockname.c_str()),  // this should be safe due to declaration order
     _stop(false),
@@ -169,7 +169,7 @@ void ThreadPool::start_threads()
     if (r < 0)
       lderr(cct) << " set_ioprio got " << cpp_strerror(r) << dendl;
 
-    wt->create();
+    wt->create(thread_name.c_str());
   }
 }
 
@@ -286,8 +286,8 @@ void ThreadPool::set_ioprio(int cls, int priority)
   }
 }
 
-ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, 
-  uint32_t pnum_threads): cct(pcct_),name(nm),lockname(nm + "::lock"), 
+ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, string tn,
+  uint32_t pnum_threads): cct(pcct_),name(nm),thread_name(tn),lockname(nm + "::lock"),
   shardedpool_lock(lockname.c_str()),num_threads(pnum_threads),stop_threads(0), 
   pause_threads(0),drain_threads(0), num_paused(0), num_drained(0), wq(NULL) {}
 
@@ -356,7 +356,7 @@ void ShardedThreadPool::start_threads()
     WorkThreadSharded *wt = new WorkThreadSharded(this, thread_index);
     ldout(cct, 10) << "start_threads creating and starting " << wt << dendl;
     threads_shardedpool.push_back(wt);
-    wt->create();
+    wt->create(thread_name.c_str());
     thread_index++;
   }
 }
diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h
index a6e7972..67c1a87 100644
--- a/src/common/WorkQueue.h
+++ b/src/common/WorkQueue.h
@@ -28,6 +28,7 @@ class CephContext;
 class ThreadPool : public md_config_obs_t {
   CephContext *cct;
   string name;
+  string thread_name;
   string lockname;
   Mutex _lock;
   Cond _cond;
@@ -353,10 +354,6 @@ public:
   template<typename T>
   class PointerWQ : public WorkQueue_ {
   public:
-    PointerWQ(string n, time_t ti, time_t sti, ThreadPool* p)
-      : WorkQueue_(n, ti, sti), m_pool(p), m_processing(0) {
-      m_pool->add_work_queue(this);
-    }
     ~PointerWQ() {
       m_pool->remove_work_queue(this);
       assert(m_processing == 0);
@@ -382,6 +379,9 @@ public:
       return _empty();
     }
   protected:
+    PointerWQ(string n, time_t ti, time_t sti, ThreadPool* p)
+      : WorkQueue_(n, ti, sti), m_pool(p), m_processing(0) {
+    }
     virtual void _clear() {
       assert(m_pool->_lock.is_locked());
       m_items.clear();
@@ -459,7 +459,7 @@ private:
   void worker(WorkThread *wt);
 
 public:
-  ThreadPool(CephContext *cct_, string nm, int n, const char *option = NULL);
+  ThreadPool(CephContext *cct_, string nm, string tn, int n, const char *option = NULL);
   virtual ~ThreadPool();
 
   /// return number of threads currently running
@@ -579,6 +579,7 @@ public:
   ContextWQ(const string &name, time_t ti, ThreadPool *tp)
     : ThreadPool::PointerWQ<Context>(name, ti, 0, tp),
       m_lock("ContextWQ::m_lock") {
+    tp->add_work_queue(this);
   }
 
   void queue(Context *ctx, int result = 0) {
@@ -618,6 +619,7 @@ class ShardedThreadPool {
 
   CephContext *cct;
   string name;
+  string thread_name;
   string lockname;
   Mutex shardedpool_lock;
   Cond shardedpool_cond;
@@ -698,7 +700,7 @@ private:
 
 public:
 
-  ShardedThreadPool(CephContext *cct_, string nm, uint32_t pnum_threads);
+  ShardedThreadPool(CephContext *cct_, string nm, string tn, uint32_t pnum_threads);
 
   ~ShardedThreadPool(){};
 
diff --git a/src/common/address_helper.cc b/src/common/address_helper.cc
index 1bde1ac..35cb0f2 100644
--- a/src/common/address_helper.cc
+++ b/src/common/address_helper.cc
@@ -59,6 +59,7 @@ int entity_addr_from_url(entity_addr_t *addr /* out */, const char *url)
 				break;
 			};
 			addr->set_port(std::atoi(port.c_str()));
+			freeaddrinfo(res);
 			return 0;
 		}
 	}
diff --git a/src/common/admin_socket.cc b/src/common/admin_socket.cc
index 07a2246..1d51ef5 100644
--- a/src/common/admin_socket.cc
+++ b/src/common/admin_socket.cc
@@ -556,7 +556,7 @@ bool AdminSocket::init(const std::string &path)
   register_command("get_command_descriptions", "get_command_descriptions",
 		   m_getdescs_hook, "list available commands");
 
-  create();
+  create("admin_socket");
   add_cleanup_file(m_path.c_str());
   return true;
 }
diff --git a/src/common/assert.cc b/src/common/assert.cc
index 67c43df..5802e8f 100644
--- a/src/common/assert.cc
+++ b/src/common/assert.cc
@@ -43,7 +43,8 @@ namespace ceph {
     g_assert_context = cct;
   }
 
-  void __ceph_assert_fail(const char *assertion, const char *file, int line, const char *func)
+  void __ceph_assert_fail(const char *assertion, const char *file, int line,
+			  const char *func)
   {
     ostringstream tss;
     tss << ceph_clock_now(g_assert_context);
@@ -74,10 +75,11 @@ namespace ceph {
       g_assert_context->_log->dump_recent();
     }
 
-    throw FailedAssertion(bt);
+    abort();
   }
 
-  void __ceph_assertf_fail(const char *assertion, const char *file, int line, const char *func, const char* msg, ...)
+  void __ceph_assertf_fail(const char *assertion, const char *file, int line,
+			   const char *func, const char* msg, ...)
   {
     ostringstream tss;
     tss << ceph_clock_now(g_assert_context);
@@ -143,7 +145,7 @@ namespace ceph {
       g_assert_context->_log->dump_recent();
     }
 
-    throw FailedAssertion(bt);
+    abort();
   }
 
   void __ceph_assert_warn(const char *assertion, const char *file,
diff --git a/src/common/buffer.cc b/src/common/buffer.cc
index 10e01a0..e2de936 100644
--- a/src/common/buffer.cc
+++ b/src/common/buffer.cc
@@ -20,6 +20,7 @@
 #include "common/simple_spin.h"
 #include "common/strtol.h"
 #include "common/likely.h"
+#include "common/valgrind.h"
 #include "include/atomic.h"
 #include "common/RWLock.h"
 #include "include/types.h"
@@ -746,7 +747,11 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
       _raw = tr->clone();
       _raw->nref.set(1);
       if (unlikely(tr->nref.dec() == 0)) {
+        ANNOTATE_HAPPENS_AFTER(&tr->nref);
+        ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&tr->nref);
         delete tr;
+      } else {
+        ANNOTATE_HAPPENS_BEFORE(&tr->nref);
       }
     }
     return *this;
@@ -771,7 +776,11 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
       bdout << "ptr " << this << " release " << _raw << bendl;
       if (_raw->nref.dec() == 0) {
 	//cout << "hosing raw " << (void*)_raw << " len " << _raw->len << std::endl;
+        ANNOTATE_HAPPENS_AFTER(&_raw->nref);
+        ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&_raw->nref);
 	delete _raw;  // dealloc old (if any)
+      } else {
+        ANNOTATE_HAPPENS_BEFORE(&_raw->nref);
       }
       _raw = 0;
     }
@@ -1402,6 +1411,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
     if (nb.length())
       _buffers.push_back(nb);
     invalidate_crc();
+    last_p = begin();
   }
 
   void buffer::list::rebuild_aligned(unsigned align)
@@ -1449,6 +1459,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
       }
       _buffers.insert(p, unaligned._buffers.front());
     }
+    last_p = begin();
   }
   
   void buffer::list::rebuild_page_aligned()
@@ -1693,6 +1704,8 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
       return tmp.c_str() + off;
     }
 
+    last_p = begin();  // we modified _buffers
+
     return curbuf->c_str() + off;
   }
 
@@ -2093,24 +2106,58 @@ void buffer::list::write_stream(std::ostream &out) const
 
 void buffer::list::hexdump(std::ostream &out) const
 {
+  if (!length())
+    return;
+
   std::ios_base::fmtflags original_flags = out.flags();
 
+  // do our best to match the output of hexdump -C, for better
+  // diff'ing!
+
   out.setf(std::ios::right);
   out.fill('0');
 
   unsigned per = 16;
-
+  bool was_zeros = false, did_star = false;
   for (unsigned o=0; o<length(); o += per) {
-    out << std::hex << std::setw(4) << o << " :";
+    bool row_is_zeros = false;
+    if (o + per < length()) {
+      row_is_zeros = true;
+      for (unsigned i=0; i<per && o+i<length(); i++) {
+	if ((*this)[o+i]) {
+	  row_is_zeros = false;
+	}
+      }
+      if (row_is_zeros) {
+	if (was_zeros) {
+	  if (!did_star) {
+	    out << "*\n";
+	    did_star = true;
+	  }
+	  continue;
+	}
+	was_zeros = true;
+      } else {
+	was_zeros = false;
+	did_star = false;
+      }
+    }
+
+    out << std::hex << std::setw(8) << o << " ";
 
     unsigned i;
     for (i=0; i<per && o+i<length(); i++) {
+      if (i == 8)
+	out << ' ';
       out << " " << std::setw(2) << ((unsigned)(*this)[o+i] & 0xff);
     }
-    for (; i<per; i++)
+    for (; i<per; i++) {
+      if (i == 8)
+	out << ' ';
       out << "   ";
+    }
     
-    out << " : ";
+    out << "  |";
     for (i=0; i<per && o+i<length(); i++) {
       char c = (*this)[o+i];
       if (isupper(c) || islower(c) || isdigit(c) || c == ' ' || ispunct(c))
@@ -2118,8 +2165,9 @@ void buffer::list::hexdump(std::ostream &out) const
       else
 	out << '.';
     }
-    out << std::dec << std::endl;
+    out << '|' << std::dec << std::endl;
   }
+  out << std::hex << std::setw(8) << length() << "\n";
 
   out.flags(original_flags);
 }
diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc
index 4ead871..42595f5 100644
--- a/src/common/ceph_context.cc
+++ b/src/common/ceph_context.cc
@@ -33,6 +33,7 @@
 #include "common/Mutex.h"
 #include "common/Cond.h"
 #include "common/PluginRegistry.h"
+#include "common/valgrind.h"
 
 #include <iostream>
 #include <pthread.h>
@@ -533,6 +534,16 @@ CephContext::~CephContext()
     ceph::crypto::shutdown();
 }
 
+void CephContext::put() {
+  if (nref.dec() == 0) {
+    ANNOTATE_HAPPENS_AFTER(&nref);
+    ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&nref);
+    delete this;
+  } else {
+    ANNOTATE_HAPPENS_BEFORE(&nref);
+  }
+}
+
 void CephContext::init_crypto()
 {
   ceph::crypto::init(this);
@@ -547,7 +558,7 @@ void CephContext::start_service_thread()
     return;
   }
   _service_thread = new CephContextServiceThread(this);
-  _service_thread->create();
+  _service_thread->create("service");
   ceph_spin_unlock(&_service_thread_lock);
 
   // make logs flush on_exit()
diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h
index ab187c5..99b2181 100644
--- a/src/common/ceph_context.h
+++ b/src/common/ceph_context.h
@@ -67,10 +67,7 @@ public:
     nref.inc();
     return this;
   }
-  void put() {
-    if (nref.dec() == 0)
-      delete this;
-  }
+  void put();
 
   md_config_t *_conf;
   ceph::log::Log *_log;
diff --git a/src/common/ceph_strings.cc b/src/common/ceph_strings.cc
index d1a418d..6f262e1 100644
--- a/src/common/ceph_strings.cc
+++ b/src/common/ceph_strings.cc
@@ -97,6 +97,7 @@ const char *ceph_session_op_name(int op)
 	case CEPH_SESSION_RECALL_STATE: return "recall_state";
 	case CEPH_SESSION_FLUSHMSG: return "flushmsg";
 	case CEPH_SESSION_FLUSHMSG_ACK: return "flushmsg_ack";
+	case CEPH_SESSION_REJECT: return "reject";
 	}
 	return "???";
 }
diff --git a/src/common/ceph_time.cc b/src/common/ceph_time.cc
new file mode 100644
index 0000000..a18a316
--- /dev/null
+++ b/src/common/ceph_time.cc
@@ -0,0 +1,112 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage at newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.	See file COPYING.
+ *
+ */
+
+// For ceph_timespec
+#include "include/types.h"
+
+#include "ceph_context.h"
+#include "ceph_time.h"
+#include "config.h"
+
+namespace ceph {
+  namespace time_detail {
+    real_clock::time_point real_clock::now(const CephContext* cct) noexcept {
+      struct timespec ts;
+      clock_gettime(CLOCK_REALTIME, &ts);
+      // TODO: After we get the time-literal configuration patch in,
+      // just add the configured duration.
+      if (cct)
+	ts.tv_sec += cct->_conf->clock_offset;
+      return from_timespec(ts);
+    }
+
+    void real_clock::to_ceph_timespec(const time_point& t,
+				      struct ceph_timespec& ts) {
+      ts.tv_sec = to_time_t(t);
+      ts.tv_nsec = (t.time_since_epoch() % seconds(1)).count();
+    }
+    struct ceph_timespec real_clock::to_ceph_timespec(const time_point& t) {
+      struct ceph_timespec ts;
+      to_ceph_timespec(t, ts);
+      return ts;
+    }
+    real_clock::time_point real_clock::from_ceph_timespec(
+      const struct ceph_timespec& ts) {
+      return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+    }
+
+    coarse_real_clock::time_point coarse_real_clock::now(
+      const CephContext* cct) noexcept {
+      struct timespec ts;
+      clock_gettime(CLOCK_REALTIME_COARSE, &ts);
+      // TODO: After we get the time-literal configuration patch in,
+      // just add the configured duration.
+      if (cct)
+	ts.tv_sec += cct->_conf->clock_offset;
+      return from_timespec(ts);
+    }
+
+    void coarse_real_clock::to_ceph_timespec(const time_point& t,
+					     struct ceph_timespec& ts) {
+      ts.tv_sec = to_time_t(t);
+      ts.tv_nsec = (t.time_since_epoch() % seconds(1)).count();
+    }
+    struct ceph_timespec coarse_real_clock::to_ceph_timespec(
+      const time_point& t) {
+      struct ceph_timespec ts;
+      to_ceph_timespec(t, ts);
+      return ts;
+    }
+    real_clock::time_point coarse_real_clock::from_ceph_timespec(
+      const struct ceph_timespec& ts) {
+      return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+    }
+  };
+
+  using std::chrono::duration_cast;
+  using std::chrono::seconds;
+  using std::chrono::microseconds;
+
+  std::ostream& operator<<(std::ostream& m, const mono_time& t) {
+    return m << std::chrono::duration<double>(t.time_since_epoch()).count()
+	     << "s";
+  }
+
+  std::ostream& operator<<(std::ostream& m, const timespan& t) {
+    return m << std::chrono::duration<double>(t).count() << "s";
+  }
+
+  std::ostream& operator<<(std::ostream& m, const real_time& t) {
+    m.setf(std::ios::right);
+    char oldfill = m.fill();
+    m.fill('0');
+    // localtime.  this looks like an absolute time.
+    //  aim for http://en.wikipedia.org/wiki/ISO_8601
+    struct tm bdt;
+    time_t tt = ceph::real_clock::to_time_t(t);
+    localtime_r(&tt, &bdt);
+    m << std::setw(4) << (bdt.tm_year+1900)  // 2007 -> '07'
+      << '-' << std::setw(2) << (bdt.tm_mon+1)
+      << '-' << std::setw(2) << bdt.tm_mday
+      << ' '
+      << std::setw(2) << bdt.tm_hour
+      << ':' << std::setw(2) << bdt.tm_min
+      << ':' << std::setw(2) << bdt.tm_sec
+      << "." << std::setw(6) << duration_cast<microseconds>(
+	t.time_since_epoch() % seconds(1));
+    m.fill(oldfill);
+    m.unsetf(std::ios::right);
+    return m;
+  }
+};
diff --git a/src/common/ceph_time.h b/src/common/ceph_time.h
new file mode 100644
index 0000000..a634e7f
--- /dev/null
+++ b/src/common/ceph_time.h
@@ -0,0 +1,383 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage at newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.	See file COPYING.
+ *
+ */
+
+#ifndef COMMON_CEPH_TIME_H
+#define COMMON_CEPH_TIME_H
+
+#include <chrono>
+#include <ctime>
+
+#include "include/encoding.h"
+
+class CephContext;
+struct ceph_timespec;
+
+namespace ceph {
+  namespace time_detail {
+    using std::chrono::duration_cast;
+    using std::chrono::seconds;
+    using std::chrono::microseconds;
+    using std::chrono::nanoseconds;
+    // Currently we use a 64-bit count of nanoseconds.
+
+    // We could, if we wished, use a struct holding a uint64_t count
+    // of seconds and a uint32_t count of nanoseconds.
+
+    // At least this way we can change it to something else if we
+    // want.
+    typedef uint64_t rep;
+
+    // A concrete duration, unsigned. The timespan Ceph thinks in.
+    typedef std::chrono::duration<rep, std::nano> timespan;
+
+
+    // Like the above but signed.
+    typedef int64_t signed_rep;
+
+    typedef std::chrono::duration<signed_rep, std::nano> signedspan;
+
+    // We define our own clocks so we can have our choice of all time
+    // sources supported by the operating system. With the standard
+    // library the resolution and cost are unspecified. (For example,
+    // the libc++ system_clock class gives only microsecond
+    // resolution.)
+
+    // One potential issue is that we should accept system_clock
+    // timepoints in user-facing APIs alongside (or instead of)
+    // ceph::real_clock times.
+    class real_clock {
+    public:
+      typedef timespan duration;
+      typedef duration::rep rep;
+      typedef duration::period period;
+      // The second template parameter defaults to the clock's duration
+      // type.
+      typedef std::chrono::time_point<real_clock> time_point;
+      static constexpr const bool is_steady = false;
+
+      static time_point now() noexcept {
+	struct timespec ts;
+	clock_gettime(CLOCK_REALTIME, &ts);
+	return from_timespec(ts);
+      }
+      // We need a version of 'now' that can take a CephContext for
+      // introducing configurable clock skew.
+      static time_point now(const CephContext* cct) noexcept;
+
+      // Allow conversion to/from any clock with the same interface as
+      // std::chrono::system_clock)
+      template<typename Clock, typename Duration>
+      static time_point to_system_time_point(
+	const std::chrono::time_point<Clock, Duration>& t) {
+	return time_point(seconds(Clock::to_time_t(t)) +
+			  duration_cast<duration>(t.time_since_epoch() %
+						  seconds(1)));
+      }
+      template<typename Clock, typename Duration>
+      static std::chrono::time_point<Clock, Duration> to_system_time_point(
+	const time_point& t) {
+	return (Clock::from_time_t(to_time_t(t)) +
+		duration_cast<Duration>(t.time_since_epoch() % seconds(1)));
+      }
+
+      static time_t to_time_t(const time_point& t) noexcept {
+	return duration_cast<seconds>(t.time_since_epoch()).count();
+      }
+      static time_point from_time_t(const time_t& t) noexcept {
+	return time_point(seconds(t));
+      }
+
+      static void to_timespec(const time_point& t, struct timespec& ts) {
+	ts.tv_sec = to_time_t(t);
+	ts.tv_nsec = (t.time_since_epoch() % seconds(1)).count();
+      }
+      static struct timespec to_timespec(const time_point& t) {
+	struct timespec ts;
+	to_timespec(t, ts);
+	return ts;
+      }
+      static time_point from_timespec(const struct timespec& ts) {
+	return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+      }
+
+      static void to_ceph_timespec(const time_point& t,
+				   struct ceph_timespec& ts);
+      static struct ceph_timespec to_ceph_timespec(const time_point& t);
+      static time_point from_ceph_timespec(const struct ceph_timespec& ts);
+
+      static void to_timeval(const time_point& t, struct timeval& tv) {
+	tv.tv_sec = to_time_t(t);
+	tv.tv_usec = duration_cast<microseconds>(t.time_since_epoch() %
+						 seconds(1)).count();
+      }
+      static struct timeval to_timeval(const time_point& t) {
+	struct timeval tv;
+	to_timeval(t, tv);
+	return tv;
+      }
+      static time_point from_timeval(const struct timeval& tv) {
+	return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+      }
+
+      static double to_double(const time_point& t) {
+	return std::chrono::duration<double>(t.time_since_epoch()).count();
+      }
+      static time_point from_double(const double d) {
+	return time_point(duration_cast<duration>(
+			    std::chrono::duration<double>(d)));
+      }
+    };
+
+    class coarse_real_clock {
+    public:
+      typedef timespan duration;
+      typedef duration::rep rep;
+      typedef duration::period period;
+      // The second template parameter defaults to the clock's duration
+      // type.
+      typedef std::chrono::time_point<real_clock> time_point;
+      static constexpr const bool is_steady = false;
+
+      static time_point now() noexcept {
+	struct timespec ts;
+	clock_gettime(CLOCK_REALTIME_COARSE, &ts);
+	return from_timespec(ts);
+      }
+      static time_point now(const CephContext* cct) noexcept;
+
+      static time_t to_time_t(const time_point& t) noexcept {
+	return duration_cast<seconds>(t.time_since_epoch()).count();
+      }
+      static time_point from_time_t(const time_t t) noexcept {
+	return time_point(seconds(t));
+      }
+
+      static void to_timespec(const time_point& t, struct timespec& ts) {
+	ts.tv_sec = to_time_t(t);
+	ts.tv_nsec = (t.time_since_epoch() % seconds(1)).count();
+      }
+      static struct timespec to_timespec(const time_point& t) {
+	struct timespec ts;
+	to_timespec(t, ts);
+	return ts;
+      }
+      static time_point from_timespec(const struct timespec& ts) {
+	return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+      }
+
+      static void to_ceph_timespec(const time_point& t,
+				   struct ceph_timespec& ts);
+      static struct ceph_timespec to_ceph_timespec(const time_point& t);
+      static time_point from_ceph_timespec(const struct ceph_timespec& ts);
+
+      static void to_timeval(const time_point& t, struct timeval& tv) {
+	tv.tv_sec = to_time_t(t);
+	tv.tv_usec = duration_cast<microseconds>(t.time_since_epoch() %
+						 seconds(1)).count();
+      }
+      static struct timeval to_timeval(const time_point& t) {
+	struct timeval tv;
+	to_timeval(t, tv);
+	return tv;
+      }
+      static time_point from_timeval(const struct timeval& tv) {
+	return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+      }
+
+      static double to_double(const time_point& t) {
+	return std::chrono::duration<double>(t.time_since_epoch()).count();
+      }
+      static time_point from_double(const double d) {
+	return time_point(duration_cast<duration>(
+			    std::chrono::duration<double>(d)));
+      }
+    };
+
+    class mono_clock {
+    public:
+      typedef timespan duration;
+      typedef duration::rep rep;
+      typedef duration::period period;
+      typedef std::chrono::time_point<mono_clock> time_point;
+      static constexpr const bool is_steady = true;
+
+      static time_point now() noexcept {
+	struct timespec ts;
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+      }
+
+      // A monotonic clock's timepoints are only meaningful to the
+      // computer on which they were generated. Thus having an
+      // optional skew is meaningless.
+    };
+
+    class coarse_mono_clock {
+    public:
+      typedef timespan duration;
+      typedef duration::rep rep;
+      typedef duration::period period;
+      typedef std::chrono::time_point<mono_clock> time_point;
+      static constexpr const bool is_steady = true;
+
+      static time_point now() noexcept {
+	struct timespec ts;
+	clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
+	return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
+      }
+    };
+  } // namespace time_detail
+
+  // duration is the concrete time representation for our code in the
+  // case that we are only interested in durations between now and the
+  // future. Using it means we don't have to have EVERY function that
+  // deals with a duration be a template. We can do so for user-facing
+  // APIs, however.
+  using time_detail::timespan;
+
+  // Similar to the above but for durations that can specify
+  // differences between now and a time point in the past.
+  using time_detail::signedspan;
+
+  // High-resolution real-time clock
+  using time_detail::real_clock;
+
+  // Low-resolution but preusmably faster real-time clock
+  using time_detail::coarse_real_clock;
+
+
+  // High-resolution monotonic clock
+  using time_detail::mono_clock;
+
+  // Low-resolution but, I would hope or there's no point, faster
+  // monotonic clock
+  using time_detail::coarse_mono_clock;
+
+  // Please note that the coarse clocks are disjoint. You cannot
+  // subtract a real_clock timepoint from a coarse_real_clock
+  // timepoint as, from C++'s perspective, they are disjoint types.
+
+  // This is not necessarily bad. If I sample a mono_clock and then a
+  // coarse_mono_clock, the coarse_mono_clock's time could potentially
+  // be previous to the mono_clock's time (just due to differing
+  // resolution) which would be Incorrect.
+
+  // This is not horrible, though, since you can use an idiom like
+  // mono_clock::timepoint(coarsepoint.time_since_epoch()) to unwrap
+  // and rewrap if you know what you're doing.
+
+
+  // Actual wall-clock times
+  typedef real_clock::time_point real_time;
+
+  // Monotonic times should never be serialized or communicated
+  // between machines, since they are incomparable. Thus we also don't
+  // make any provision for converting between
+  // std::chrono::steady_clock time and ceph::mono_clock time.
+  typedef mono_clock::time_point mono_time;
+
+  template<typename Rep1, typename Ratio1, typename Rep2, typename Ratio2>
+  auto floor(const std::chrono::duration<Rep1, Ratio1>& duration,
+	     const std::chrono::duration<Rep2, Ratio2>& precision) ->
+    typename std::common_type<std::chrono::duration<Rep1, Ratio1>,
+			      std::chrono::duration<Rep2, Ratio2> >::type {
+    return duration - (duration % precision);
+  }
+
+  template<typename Rep1, typename Ratio1, typename Rep2, typename Ratio2>
+  auto ceil(const std::chrono::duration<Rep1, Ratio1>& duration,
+	    const std::chrono::duration<Rep2, Ratio2>& precision) ->
+    typename std::common_type<std::chrono::duration<Rep1, Ratio1>,
+			      std::chrono::duration<Rep2, Ratio2> >::type {
+    auto tmod = duration % precision;
+    return duration - tmod + (tmod > tmod.zero() ? 1 : 0) * precision;
+  }
+
+  template<typename Clock, typename Duration, typename Rep, typename Ratio>
+  auto floor(const std::chrono::time_point<Clock, Duration>& timepoint,
+	     const std::chrono::duration<Rep, Ratio>& precision) ->
+    std::chrono::time_point<Clock,
+			    typename std::common_type<
+			      Duration, std::chrono::duration<Rep, Ratio>
+			      >::type> {
+    return std::chrono::time_point<
+      Clock, typename std::common_type<
+	Duration, std::chrono::duration<Rep, Ratio> >::type>(
+	  floor(timepoint.time_since_epoch(), precision));
+  }
+  template<typename Clock, typename Duration, typename Rep, typename Ratio>
+  auto ceil(const std::chrono::time_point<Clock, Duration>& timepoint,
+	    const std::chrono::duration<Rep, Ratio>& precision) ->
+    std::chrono::time_point<Clock,
+			    typename std::common_type<
+			      Duration,
+			      std::chrono::duration<Rep, Ratio> >::type> {
+    return std::chrono::time_point<
+      Clock, typename std::common_type<
+	Duration, std::chrono::duration<Rep, Ratio> >::type>(
+	  ceil(timepoint.time_since_epoch(), precision));
+  }
+
+  static inline timespan make_timespan(const double d) {
+    return std::chrono::duration_cast<timespan>(
+      std::chrono::duration<double>(d));
+  }
+
+  std::ostream& operator<<(std::ostream& m, const timespan& t);
+  std::ostream& operator<<(std::ostream& m, const real_time& t);
+  std::ostream& operator<<(std::ostream& m, const mono_time& t);
+} // namespace ceph
+
+// We need these definitions to be able to hande ::encode/::decode on
+// time points.
+
+template<typename Clock, typename Duration>
+void encode(const std::chrono::time_point<Clock, Duration>& t,
+	    ceph::bufferlist &bl) {
+  struct timespec ts = Clock::to_timespec();
+  // A 32 bit count of seconds causes me vast unhappiness.
+  ::encode((uint32_t) ts.tv_sec, bl);
+  ::encode((uint32_t) ts.tv_nsec, bl);
+}
+
+template<typename Clock, typename Duration>
+void decode(std::chrono::time_point<Clock, Duration>& t,
+	    bufferlist::iterator& p) {
+  struct timespec ts;
+  ::decode((uint32_t&) ts.tv_sec, p);
+  ::decode((uint32_t&) ts.tv_nsec, p);
+
+  t = Clock::from_timespec(ts);
+}
+
+// C++ Overload Resolution requires that our encode/decode functions
+// be defined in the same namespace as the type. So we need this
+// to handle things like ::encode(std::vector<ceph::real_time // > >)
+
+namespace std {
+  namespace chrono {
+    template<typename Clock, typename Duration>
+    void encode(const time_point<Clock, Duration>& t,
+		ceph::bufferlist &bl) {
+      ::encode(t, bl);
+    }
+
+    template<typename Clock, typename Duration>
+    void decode(time_point<Clock, Duration>& t, bufferlist::iterator &p) {
+      ::decode(t, p);
+    }
+  } // namespace chrono
+} // namespace std
+
+#endif // COMMON_CEPH_TIME_H
diff --git a/src/common/ceph_timer.h b/src/common/ceph_timer.h
new file mode 100644
index 0000000..ae95eb2
--- /dev/null
+++ b/src/common/ceph_timer.h
@@ -0,0 +1,309 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage at newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef COMMON_CEPH_TIMER_H
+#define COMMON_CEPH_TIMER_H
+
+#include <condition_variable>
+#include <functional>
+#include <mutex>
+#include <thread>
+
+#include <boost/intrusive/set.hpp>
+
+#include "ceph_time.h"
+
+namespace ceph {
+
+  /// Newly constructed timer should be suspended at point of
+  /// construction.
+
+  struct construct_suspended_t { };
+  constexpr construct_suspended_t construct_suspended { };
+
+  namespace timer_detail {
+    using boost::intrusive::member_hook;
+    using boost::intrusive::set_member_hook;
+    using boost::intrusive::link_mode;
+    using boost::intrusive::normal_link;
+    using boost::intrusive::set;
+    using boost::intrusive::constant_time_size;
+    using boost::intrusive::compare;
+
+    // Compared to the SafeTimer this does fewer allocations (you
+    // don't have to allocate a new Context every time you
+    // want to cue the next tick.)
+    //
+    // It also does not share a lock with the caller. If you call
+    // cancel event, it either cancels the event (and returns true) or
+    // you missed it. If this does not work for you, you can set up a
+    // flag and mutex of your own.
+    //
+    // You get to pick your clock. I like mono_clock, since I usually
+    // want to wait FOR a given duration. real_clock is worthwhile if
+    // you want to wait UNTIL a specific moment of wallclock time.  If
+    // you want you can set up a timer that executes a function after
+    // you use up ten seconds of CPU time.
+
+    template <class TC>
+    class timer {
+      typedef set_member_hook<link_mode<normal_link> > sh;
+
+      struct event {
+	typename TC::time_point t;
+	uint64_t id;
+	std::function<void()> f;
+
+	sh schedule_link;
+	sh event_link;
+
+	event() : t(TC::time_point::min()), id(0) {}
+	event(uint64_t _id) : t(TC::time_point::min()), id(_id) {}
+	event(typename TC::time_point _t, uint64_t _id,
+	      std::function<void()>&& _f) : t(_t), id(_id), f(_f) {}
+	event(typename TC::time_point _t, uint64_t _id,
+	      const std::function<void()>& _f) : t(_t), id(_id), f(_f) {}
+	bool operator <(const event& e) {
+	  return t == e.t ? id < e.id : t < e.t;
+	}
+      };
+      struct SchedCompare {
+	bool operator()(const event& e1, const event& e2) const {
+	  return e1.t == e2.t ? e1.id < e2.id : e1.t < e2.t;
+	}
+      };
+      struct EventCompare {
+	bool operator()(const event& e1, const event& e2) const {
+	  return e1.id < e2.id;
+	}
+      };
+
+      set<event,
+	  member_hook<event, sh, &event::schedule_link>,
+	  constant_time_size<false>,
+	  compare<SchedCompare> > schedule;
+
+      set<event,
+	  member_hook<event, sh, &event::event_link>,
+	  constant_time_size<false>,
+	  compare<EventCompare> > events;
+
+      std::mutex lock;
+      using lock_guard = std::lock_guard<std::mutex>;
+      using unique_lock = std::unique_lock<std::mutex>;
+      std::condition_variable cond;
+
+      event* running{ nullptr };
+      uint64_t next_id{ 0 };
+
+      bool suspended;
+      std::thread thread;
+
+      void timer_thread() {
+	unique_lock l(lock);
+	while (!suspended) {
+	  typename TC::time_point now = TC::now();
+
+	  while (!schedule.empty()) {
+	    auto p = schedule.begin();
+	    // Should we wait for the future?
+	    if (p->t > now)
+	      break;
+
+	    event& e = *p;
+	    schedule.erase(e);
+	    events.erase(e);
+
+	    // Since we have only one thread it is impossible to have more
+	    // than one running event
+	    running = &e;
+
+	    l.unlock();
+	    e.f();
+	    l.lock();
+
+	    if (running) {
+	      running = nullptr;
+	      delete &e;
+	    } // Otherwise the event requeued itself
+	  }
+
+	  if (schedule.empty())
+	    cond.wait(l);
+	  else
+	    cond.wait_until(l, schedule.begin()->t);
+	}
+      }
+
+  public:
+      timer() {
+	lock_guard l(lock);
+	suspended = false;
+	thread = std::thread(&timer::timer_thread, this);
+      }
+
+      // Create a suspended timer, jobs will be executed in order when
+      // it is resumed.
+      timer(construct_suspended_t) {
+	lock_guard l(lock);
+	suspended = true;
+      }
+
+      timer(const timer &) = delete;
+      timer& operator=(const timer &) = delete;
+
+      ~timer() {
+	suspend();
+	cancel_all_events();
+      }
+
+      // Suspend operation of the timer (and let its thread die).
+      void suspend() {
+	unique_lock l(lock);
+	if (suspended)
+	  return;
+
+	suspended = true;
+	cond.notify_one();
+	l.unlock();
+	thread.join();
+      }
+
+
+      // Resume operation of the timer. (Must have been previously
+      // suspended.)
+      void resume() {
+	unique_lock l(lock);
+	  if (!suspended)
+	  return;
+
+	suspended = false;
+	assert(!thread.joinable());
+	thread = std::thread(&timer::timer_thread, this);
+      }
+
+      // Schedule an event in the relative future
+      template<typename Callable, typename... Args>
+      uint64_t add_event(typename TC::duration duration,
+			 Callable&& f, Args&&... args) {
+	typename TC::time_point when = TC::now();
+	when += duration;
+	return add_event(when,
+			 std::forward<Callable>(f),
+			 std::forward<Args>(args)...);
+      }
+
+      // Schedule an event in the absolute future
+      template<typename Callable, typename... Args>
+      uint64_t add_event(typename TC::time_point when,
+			 Callable&& f, Args&&... args) {
+	std::lock_guard<std::mutex> l(lock);
+	event& e = *(new event(
+		       when, ++next_id,
+		       std::forward<std::function<void()> >(
+			 std::bind(std::forward<Callable>(f),
+				   std::forward<Args>(args)...))));
+	auto i = schedule.insert(e);
+	events.insert(e);
+
+	/* If the event we have just inserted comes before everything
+	 * else, we need to adjust our timeout. */
+	if (i.first == schedule.begin())
+	  cond.notify_one();
+
+	// Previously each event was a context, identified by a
+	// pointer, and each context to be called only once. Since you
+	// can queue the same function pointer, member function,
+	// lambda, or functor up multiple times, identifying things by
+	// function for the purposes of cancellation is no longer
+	// suitable. Thus:
+	return e.id;
+      }
+
+      // Cancel an event. If the event has already come and gone (or you
+      // never submitted it) you will receive false. Otherwise you will
+      // receive true and it is guaranteed the event will not execute.
+      bool cancel_event(const uint64_t id) {
+	std::lock_guard<std::mutex> l(lock);
+	event dummy(id);
+	auto p = events.find(dummy);
+	if (p == events.end()) {
+	  return false;
+	}
+
+	event& e = *p;
+	events.erase(e);
+	schedule.erase(e);
+	delete &e;
+
+	return true;
+      }
+
+      // Reschedules a currently running event in the relative
+      // future. Must be called only from an event executed by this
+      // timer. If you have a function that can be called either from
+      // this timer or some other way, it is your responsibility to make
+      // sure it can tell the difference only does not call
+      // reschedule_me in the non-timer case.
+      //
+      // Returns an event id. If you had an event_id from the first
+      // scheduling, replace it with this return value.
+      uint64_t reschedule_me(typename TC::duration duration) {
+	return reschedule_me(TC::now() + duration);
+      }
+
+      // Reschedules a currently running event in the absolute
+      // future. Must be called only from an event executed by this
+      // timer. if you have a function that can be called either from
+      // this timer or some other way, it is your responsibility to make
+      // sure it can tell the difference only does not call
+      // reschedule_me in the non-timer case.
+      //
+      // Returns an event id. If you had an event_id from the first
+      // scheduling, replace it with this return value.
+      uint64_t reschedule_me(typename TC::time_point when) {
+	if (std::this_thread::get_id() != thread.get_id())
+	  throw std::make_error_condition(std::errc::operation_not_permitted);
+	std::lock_guard<std::mutex> l(lock);
+	running->t = when;
+	uint64_t id = ++next_id;
+	running->id = id;
+	schedule.insert(*running);
+	events.insert(*running);
+
+	// Hacky, but keeps us from being deleted
+	running = nullptr;
+
+	// Same function, but you get a new ID.
+	return id;
+      }
+
+      // Remove all events from the queue.
+      void cancel_all_events() {
+	std::lock_guard<std::mutex> l(lock);
+	while (!events.empty()) {
+	  auto p = events.begin();
+	  event& e = *p;
+	  schedule.erase(e);
+	  events.erase(e);
+	  delete &e;
+	}
+      }
+    }; // timer
+  }; // timer_detail
+
+  using timer_detail::timer;
+}; // ceph
+
+#endif
diff --git a/src/common/common_init.cc b/src/common/common_init.cc
index 23c2e7c..3303a7a 100644
--- a/src/common/common_init.cc
+++ b/src/common/common_init.cc
@@ -21,6 +21,7 @@
 #include "common/dout.h"
 #include "common/errno.h"
 #include "common/safe_io.h"
+#include "common/valgrind.h"
 #include "common/version.h"
 #include "include/color.h"
 
@@ -36,6 +37,7 @@ CephContext *common_preinit(const CephInitParameters &iparams,
 			  enum code_environment_t code_env, int flags)
 {
   // set code environment
+  ANNOTATE_BENIGN_RACE_SIZED(&g_code_env, sizeof(g_code_env), "g_code_env");
   g_code_env = code_env;
 
   // Create a configuration object
diff --git a/src/common/config.cc b/src/common/config.cc
index 4ee54bb..37758d4 100644
--- a/src/common/config.cc
+++ b/src/common/config.cc
@@ -590,13 +590,16 @@ void md_config_t::_apply_changes(std::ostream *oss)
   for (changed_set_t::const_iterator c = changed.begin();
        c != changed.end(); ++c) {
     const std::string &key(*c);
+    pair < obs_map_t::iterator, obs_map_t::iterator >
+      range(observers.equal_range(key));
     if ((oss) &&
 	(!_get_val(key.c_str(), &bufptr, sizeof(buf))) &&
 	!_internal_field(key)) {
       (*oss) << key << " = '" << buf << "' ";
+      if (range.first == range.second) {
+	(*oss) << "(unchangeable) ";
+      }
     }
-    pair < obs_map_t::iterator, obs_map_t::iterator >
-      range(observers.equal_range(key));
     for (obs_map_t::iterator r = range.first; r != range.second; ++r) {
       rev_obs_map_t::value_type robs_val(r->second, empty_set);
       pair < rev_obs_map_t::iterator, bool > robs_ret(robs.insert(robs_val));
@@ -616,17 +619,21 @@ void md_config_t::_apply_changes(std::ostream *oss)
 
 void md_config_t::call_all_observers()
 {
-  Mutex::Locker l(lock);
+  std::map<md_config_obs_t*,std::set<std::string> > obs;
+  {
+    Mutex::Locker l(lock);
 
-  expand_all_meta();
+    expand_all_meta();
 
-  std::map<md_config_obs_t*,std::set<std::string> > obs;
-  for (obs_map_t::iterator r = observers.begin(); r != observers.end(); ++r)
-    obs[r->second].insert(r->first);
+    for (obs_map_t::iterator r = observers.begin(); r != observers.end(); ++r) {
+      obs[r->second].insert(r->first);
+    }
+  }
   for (std::map<md_config_obs_t*,std::set<std::string> >::iterator p = obs.begin();
        p != obs.end();
-       ++p)
+       ++p) {
     p->first->handle_conf_change(this, p->second);
+  }
 }
 
 int md_config_t::injectargs(const std::string& s, std::ostream *oss)
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index 39f6499..dcbb7e0 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -39,6 +39,7 @@ OPTION(restapi_log_level, OPT_STR, "") 	// default set by Python code
 OPTION(restapi_base_url, OPT_STR, "")	// "
 OPTION(fatal_signal_handlers, OPT_BOOL, true)
 OPTION(erasure_code_dir, OPT_STR, CEPH_PKGLIBDIR"/erasure-code") // default location for erasure-code plugins
+OPTION(compression_dir, OPT_STR, CEPH_PKGLIBDIR"/compressor") // default location for compression plugins
 
 OPTION(log_file, OPT_STR, "/var/log/ceph/$cluster-$name.log") // default changed by common_preinit()
 OPTION(log_max_new, OPT_INT, 1000) // default changed by common_preinit()
@@ -137,6 +138,12 @@ SUBSYS(refs, 0, 0)
 SUBSYS(xio, 1, 5)
 SUBSYS(compressor, 1, 5)
 SUBSYS(newstore, 1, 5)
+SUBSYS(bluestore, 1, 5)
+SUBSYS(bluefs, 1, 5)
+SUBSYS(bdev, 1, 3)
+SUBSYS(kstore, 1, 5)
+SUBSYS(rocksdb, 4, 5)
+SUBSYS(leveldb, 4, 5)
 
 OPTION(key, OPT_STR, "")
 OPTION(keyfile, OPT_STR, "")
@@ -201,6 +208,7 @@ OPTION(mon_subscribe_interval, OPT_DOUBLE, 24*3600)  // for legacy clients only
 OPTION(mon_delta_reset_interval, OPT_DOUBLE, 10)   // seconds of inactivity before we reset the pg delta to 0
 OPTION(mon_osd_laggy_halflife, OPT_INT, 60*60)        // (seconds) how quickly our laggy estimations decay
 OPTION(mon_osd_laggy_weight, OPT_DOUBLE, .3)          // weight for new 'samples's in laggy estimations
+OPTION(mon_osd_laggy_max_interval, OPT_INT, 300)      // maximum value of laggy_interval in laggy estimations
 OPTION(mon_osd_adjust_heartbeat_grace, OPT_BOOL, true)    // true if we should scale based on laggy estimations
 OPTION(mon_osd_adjust_down_out_interval, OPT_BOOL, true)  // true if we should scale based on laggy estimations
 OPTION(mon_osd_auto_mark_in, OPT_BOOL, false)         // mark any booting osds 'in'
@@ -360,6 +368,9 @@ OPTION(client_debug_inject_tick_delay, OPT_INT, 0) // delay the client tick for
 OPTION(client_max_inline_size, OPT_U64, 4096)
 OPTION(client_inject_release_failure, OPT_BOOL, false)  // synthetic client bug for testing
 OPTION(client_inject_fixed_oldest_tid, OPT_BOOL, false)  // synthetic client bug for testing
+OPTION(client_metadata, OPT_STR, "")
+OPTION(client_acl_type, OPT_STR, "")
+OPTION(client_permissions, OPT_BOOL, true)
 
 // note: the max amount of "in flight" dirty data is roughly (max - target)
 OPTION(fuse_use_invalidate_cb, OPT_BOOL, false) // use fuse 2.8+ invalidate callback to keep page cache consistent
@@ -421,6 +432,7 @@ OPTION(mds_client_prealloc_inos, OPT_INT, 1000)
 OPTION(mds_early_reply, OPT_BOOL, true)
 OPTION(mds_default_dir_hash, OPT_INT, CEPH_STR_HASH_RJENKINS)
 OPTION(mds_log, OPT_BOOL, true)
+OPTION(mds_log_pause, OPT_BOOL, false)
 OPTION(mds_log_skip_corrupt_events, OPT_BOOL, false)
 OPTION(mds_log_max_events, OPT_INT, -1)
 OPTION(mds_log_events_per_segment, OPT_INT, 1024)
@@ -553,6 +565,7 @@ OPTION(osd_max_write_size, OPT_INT, 90)
 OPTION(osd_max_pgls, OPT_U64, 1024) // max number of pgls entries to return
 OPTION(osd_client_message_size_cap, OPT_U64, 500*1024L*1024L) // client data allowed in-memory (in bytes)
 OPTION(osd_client_message_cap, OPT_U64, 100)              // num client messages allowed in-memory
+OPTION(osd_pg_op_threshold_ratio, OPT_U64, 2)             // the expected maximum op over the average number of ops per pg
 OPTION(osd_pg_bits, OPT_INT, 6)  // bits per osd
 OPTION(osd_pgp_bits, OPT_INT, 6)  // bits per osd
 OPTION(osd_crush_chooseleaf_type, OPT_INT, 1) // 1 = host
@@ -564,6 +577,9 @@ OPTION(osd_pool_default_size, OPT_INT, 3)
 OPTION(osd_pool_default_min_size, OPT_INT, 0)  // 0 means no specific default; ceph will use size-size/2
 OPTION(osd_pool_default_pg_num, OPT_INT, 8) // number of PGs for new pools. Configure in global or mon section of ceph.conf
 OPTION(osd_pool_default_pgp_num, OPT_INT, 8) // number of PGs for placement purposes. Should be equal to pg_num
+OPTION(osd_compression_plugins, OPT_STR,
+       "snappy"
+       ) // list of compression plugins
 OPTION(osd_pool_default_erasure_code_profile,
        OPT_STR,
        "plugin=jerasure "
@@ -593,6 +609,7 @@ OPTION(osd_pool_default_cache_target_dirty_high_ratio, OPT_FLOAT, .6)
 OPTION(osd_pool_default_cache_target_full_ratio, OPT_FLOAT, .8)
 OPTION(osd_pool_default_cache_min_flush_age, OPT_INT, 0)  // seconds
 OPTION(osd_pool_default_cache_min_evict_age, OPT_INT, 0)  // seconds
+OPTION(osd_pool_default_cache_max_evict_check_size, OPT_INT, 10)  // max size to check for eviction
 OPTION(osd_hit_set_min_size, OPT_INT, 1000)  // min target size for a HitSet
 OPTION(osd_hit_set_max_size, OPT_INT, 100000)  // max target size for a HitSet
 OPTION(osd_hit_set_namespace, OPT_STR, ".ceph-internal") // rados namespace for hit_set tracking
@@ -613,6 +630,10 @@ OPTION(osd_map_message_max, OPT_INT, 100)  // max maps per MOSDMap message
 OPTION(osd_map_share_max_epochs, OPT_INT, 100)  // cap on # of inc maps we send to peers, clients
 OPTION(osd_inject_bad_map_crc_probability, OPT_FLOAT, 0)
 OPTION(osd_inject_failure_on_pg_removal, OPT_BOOL, false)
+// shutdown the OSD if stuatus flipping more than max_markdown_count times in recent max_markdown_period seconds
+OPTION(osd_max_markdown_period , OPT_INT, 600)
+OPTION(osd_max_markdown_count, OPT_INT, 5)
+
 OPTION(osd_op_threads, OPT_INT, 2)    // 0 == no threading
 OPTION(osd_peering_wq_batch_size, OPT_U64, 20)
 OPTION(osd_op_pq_max_tokens_per_priority, OPT_U64, 4194304)
@@ -746,6 +767,7 @@ OPTION(threadpool_default_timeout, OPT_INT, 60)
 // default wait time for an empty queue before pinging the hb timeout
 OPTION(threadpool_empty_queue_max_wait, OPT_INT, 2)
 
+OPTION(leveldb_log_to_ceph_log, OPT_BOOL, true)
 OPTION(leveldb_write_buffer_size, OPT_U64, 8 *1024*1024) // leveldb write buffer size
 OPTION(leveldb_cache_size, OPT_U64, 128 *1024*1024) // leveldb cache size
 OPTION(leveldb_block_size, OPT_U64, 0) // leveldb block size
@@ -763,6 +785,9 @@ OPTION(kinetic_hmac_key, OPT_STR, "asdfasdf") // kinetic key to authenticate wit
 OPTION(kinetic_use_ssl, OPT_BOOL, false) // whether to secure kinetic traffic with TLS
 
 
+OPTION(rocksdb_separate_wal_dir, OPT_BOOL, false) // use $path.wal for wal
+OPTION(rocksdb_db_paths, OPT_STR, "")   // path,size( path,size)*
+OPTION(rocksdb_log_to_ceph_log, OPT_BOOL, true)  // log to ceph log
 // rocksdb options that will be used for keyvaluestore(if backend is rocksdb)
 OPTION(keyvaluestore_rocksdb_options, OPT_STR, "")
 // rocksdb options that will be used for omap(if omap_backend is rocksdb)
@@ -817,34 +842,79 @@ OPTION(memstore_device_bytes, OPT_U64, 1024*1024*1024)
 OPTION(memstore_page_set, OPT_BOOL, true)
 OPTION(memstore_page_size, OPT_U64, 64 << 10)
 
-OPTION(newstore_max_dir_size, OPT_U32, 1000000)
-OPTION(newstore_onode_map_size, OPT_U32, 1024)   // onodes per collection
-OPTION(newstore_backend, OPT_STR, "rocksdb")
-OPTION(newstore_rocksdb_options, OPT_STR, "compression=kNoCompression,max_write_buffer_number=16,min_write_buffer_number_to_merge=6")
-OPTION(newstore_fail_eio, OPT_BOOL, true)
-OPTION(newstore_sync_io, OPT_BOOL, false)  // perform initial io synchronously
-OPTION(newstore_sync_transaction, OPT_BOOL, false)  // perform kv txn synchronously
-OPTION(newstore_sync_submit_transaction, OPT_BOOL, false)
-OPTION(newstore_sync_wal_apply, OPT_BOOL, true)     // perform initial wal work synchronously (possibly in combination with aio so we only *queue* ios)
-OPTION(newstore_fsync_threads, OPT_INT, 16)  // num threads calling fsync
-OPTION(newstore_fsync_thread_timeout, OPT_INT, 30) // thread timeout value
-OPTION(newstore_fsync_thread_suicide_timeout, OPT_INT, 120) // suicide timeout value
-OPTION(newstore_wal_threads, OPT_INT, 4)
-OPTION(newstore_wal_thread_timeout, OPT_INT, 30)
-OPTION(newstore_wal_thread_suicide_timeout, OPT_INT, 120)
-OPTION(newstore_max_ops, OPT_U64, 512)
-OPTION(newstore_max_bytes, OPT_U64, 64*1024*1024)
-OPTION(newstore_wal_max_ops, OPT_U64, 512)
-OPTION(newstore_wal_max_bytes, OPT_U64, 128*1024*1024)
-OPTION(newstore_fid_prealloc, OPT_INT, 1024)
-OPTION(newstore_nid_prealloc, OPT_INT, 1024)
-OPTION(newstore_overlay_max_length, OPT_INT, 65536)
-OPTION(newstore_overlay_max, OPT_INT, 32)
-OPTION(newstore_open_by_handle, OPT_BOOL, true)
-OPTION(newstore_o_direct, OPT_BOOL, true)
-OPTION(newstore_aio, OPT_BOOL, true)
-OPTION(newstore_aio_poll_ms, OPT_INT, 250)  // milliseconds
-OPTION(newstore_aio_max_queue_depth, OPT_INT, 4096)
+OPTION(bdev_debug_inflight_ios, OPT_BOOL, false)
+OPTION(bdev_inject_crash, OPT_INT, 0)  // if N>0, then ~ 1/N IOs will complete before we crash on flush.
+OPTION(bdev_aio, OPT_BOOL, true)
+OPTION(bdev_aio_poll_ms, OPT_INT, 250)  // milliseconds
+OPTION(bdev_aio_max_queue_depth, OPT_INT, 32)
+
+OPTION(bluefs_alloc_size, OPT_U64, 1048576)
+OPTION(bluefs_max_prefetch, OPT_U64, 1048576)
+OPTION(bluefs_min_log_runway, OPT_U64, 1048576)  // alloc when we get this low
+OPTION(bluefs_max_log_runway, OPT_U64, 4194304)  // alloc this much at a time
+OPTION(bluefs_log_compact_min_ratio, OPT_FLOAT, 5.0)      // before we consider
+OPTION(bluefs_log_compact_min_size, OPT_U64, 16*1048576)  // before we consider
+OPTION(bluefs_min_flush_size, OPT_U64, 65536)  // ignore flush until its this big
+
+OPTION(bluestore_bluefs, OPT_BOOL, true)
+OPTION(bluestore_bluefs_env_mirror, OPT_BOOL, false) // mirror to normal Env for debug
+OPTION(bluestore_bluefs_min, OPT_U64, 1*1024*1024*1024) // 1gb
+OPTION(bluestore_bluefs_min_ratio, OPT_FLOAT, .02)  // min fs free / total free
+OPTION(bluestore_bluefs_max_ratio, OPT_FLOAT, .90)  // max fs free / total free
+OPTION(bluestore_bluefs_gift_ratio, OPT_FLOAT, .02) // how much to add at a time
+OPTION(bluestore_bluefs_reclaim_ratio, OPT_FLOAT, .20) // how much to reclaim at a time
+OPTION(bluestore_block_path, OPT_STR, "")
+OPTION(bluestore_block_size, OPT_U64, 10 * 1024*1024*1024)  // 10gb for testing
+OPTION(bluestore_block_db_path, OPT_STR, "")
+OPTION(bluestore_block_db_size, OPT_U64, 0)      // rocksdb primary storage
+OPTION(bluestore_block_wal_path, OPT_STR, "")
+OPTION(bluestore_block_wal_size, OPT_U64, 0)     // rocksdb wal
+OPTION(bluestore_max_dir_size, OPT_U32, 1000000)
+OPTION(bluestore_min_alloc_size, OPT_U32, 64*1024)
+OPTION(bluestore_onode_map_size, OPT_U32, 1024)   // onodes per collection
+OPTION(bluestore_cache_tails, OPT_BOOL, true)   // cache tail blocks in Onode
+OPTION(bluestore_backend, OPT_STR, "rocksdb")
+OPTION(bluestore_rocksdb_options, OPT_STR, "compression=kNoCompression,max_write_buffer_number=16,min_write_buffer_number_to_merge=3,recycle_log_file_num=16")
+OPTION(bluestore_fsck_on_mount, OPT_BOOL, false)
+OPTION(bluestore_fsck_on_umount, OPT_BOOL, false)
+OPTION(bluestore_fail_eio, OPT_BOOL, true)
+OPTION(bluestore_sync_io, OPT_BOOL, false)  // perform initial io synchronously
+OPTION(bluestore_sync_transaction, OPT_BOOL, false)  // perform kv txn synchronously
+OPTION(bluestore_sync_submit_transaction, OPT_BOOL, false)
+OPTION(bluestore_sync_wal_apply, OPT_BOOL, true)     // perform initial wal work synchronously (possibly in combination with aio so we only *queue* ios)
+OPTION(bluestore_wal_threads, OPT_INT, 4)
+OPTION(bluestore_wal_thread_timeout, OPT_INT, 30)
+OPTION(bluestore_wal_thread_suicide_timeout, OPT_INT, 120)
+OPTION(bluestore_max_ops, OPT_U64, 512)
+OPTION(bluestore_max_bytes, OPT_U64, 64*1024*1024)
+OPTION(bluestore_wal_max_ops, OPT_U64, 512)
+OPTION(bluestore_wal_max_bytes, OPT_U64, 128*1024*1024)
+OPTION(bluestore_fid_prealloc, OPT_INT, 1024)
+OPTION(bluestore_nid_prealloc, OPT_INT, 1024)
+OPTION(bluestore_overlay_max_length, OPT_INT, 65536)
+OPTION(bluestore_overlay_max, OPT_INT, 0)
+OPTION(bluestore_open_by_handle, OPT_BOOL, true)
+OPTION(bluestore_o_direct, OPT_BOOL, true)
+OPTION(bluestore_clone_cow, OPT_BOOL, true)  // do copy-on-write for clones
+OPTION(bluestore_default_buffered_read, OPT_BOOL, false)
+OPTION(bluestore_debug_misc, OPT_BOOL, false)
+OPTION(bluestore_debug_no_reuse_blocks, OPT_BOOL, false)
+OPTION(bluestore_debug_small_allocations, OPT_INT, 0)
+OPTION(bluestore_debug_freelist, OPT_BOOL, false)
+OPTION(bluestore_debug_prefill, OPT_FLOAT, 0)
+OPTION(bluestore_debug_prefragment_max, OPT_INT, 1048576)
+
+OPTION(kstore_max_ops, OPT_U64, 512)
+OPTION(kstore_max_bytes, OPT_U64, 64*1024*1024)
+OPTION(kstore_backend, OPT_STR, "rocksdb")
+OPTION(kstore_rocksdb_options, OPT_STR, "compression=kNoCompression")
+OPTION(kstore_fsck_on_mount, OPT_BOOL, false)
+OPTION(kstore_nid_prealloc, OPT_U64, 1024)
+OPTION(kstore_sync_transaction, OPT_BOOL, false)
+OPTION(kstore_sync_submit_transaction, OPT_BOOL, false)
+OPTION(kstore_onode_map_size, OPT_U64, 1024)
+OPTION(kstore_cache_tails, OPT_BOOL, true)
+OPTION(kstore_default_stripe_size, OPT_INT, 65536)
 
 OPTION(filestore_omap_backend, OPT_STR, "leveldb")
 
@@ -903,12 +973,17 @@ OPTION(filestore_fsync_flushes_journal_data, OPT_BOOL, false)
 OPTION(filestore_fiemap, OPT_BOOL, false)     // (try to) use fiemap
 OPTION(filestore_seek_data_hole, OPT_BOOL, false)     // (try to) use seek_data/hole
 OPTION(filestore_fadvise, OPT_BOOL, true)
+//collect device partition information for management application to use
+OPTION(filestore_collect_device_partition_information, OPT_BOOL, true)
 
 // (try to) use extsize for alloc hint NOTE: extsize seems to trigger
 // data corruption in xfs prior to kernel 3.5.  filestore will
 // implicity disable this if it cannot confirm the kernel is newer
 // than that.
-OPTION(filestore_xfs_extsize, OPT_BOOL, true)
+// NOTE: This option involves a tradeoff: When disabled, fragmentation is
+// worse, but large sequential writes are faster. When enabled, large
+// sequential writes are slower, but fragmentation is reduced.
+OPTION(filestore_xfs_extsize, OPT_BOOL, false)
 
 OPTION(filestore_journal_parallel, OPT_BOOL, false)
 OPTION(filestore_journal_writeahead, OPT_BOOL, false)
diff --git a/src/common/ipaddr.cc b/src/common/ipaddr.cc
index abf09b0..72fe7de 100644
--- a/src/common/ipaddr.cc
+++ b/src/common/ipaddr.cc
@@ -34,6 +34,9 @@ const struct sockaddr *find_ipv4_in_subnet(const struct ifaddrs *addrs,
     if (addrs->ifa_addr == NULL)
       continue;
 
+    if (strcmp(addrs->ifa_name, "lo") == 0)
+      continue;
+
     if (addrs->ifa_addr->sa_family != net->sin_family)
       continue;
 
@@ -75,6 +78,9 @@ const struct sockaddr *find_ipv6_in_subnet(const struct ifaddrs *addrs,
     if (addrs->ifa_addr == NULL)
       continue;
 
+    if (strcmp(addrs->ifa_name, "lo") == 0)
+      continue;
+
     if (addrs->ifa_addr->sa_family != net->sin6_family)
       continue;
 
diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc
index c39dbf0..66e1c07 100644
--- a/src/common/lockdep.cc
+++ b/src/common/lockdep.cc
@@ -15,6 +15,7 @@
 #include "Clock.h"
 #include "common/dout.h"
 #include "common/environment.h"
+#include "common/valgrind.h"
 #include "include/types.h"
 #include "lockdep.h"
 
@@ -34,7 +35,7 @@ namespace std {
 
 /******* Constants **********/
 #define lockdep_dout(v) lsubdout(g_lockdep_ceph_ctx, lockdep, v)
-#define MAX_LOCKS  2000   // increase me as needed
+#define MAX_LOCKS  4096   // increase me as needed
 #define BACKTRACE_SKIP 2
 
 /******* Globals **********/
@@ -67,6 +68,10 @@ void lockdep_register_ceph_context(CephContext *cct)
 {
   pthread_mutex_lock(&lockdep_mutex);
   if (g_lockdep_ceph_ctx == NULL) {
+    ANNOTATE_BENIGN_RACE_SIZED(&g_lockdep_ceph_ctx, sizeof(g_lockdep_ceph_ctx),
+                               "lockdep cct");
+    ANNOTATE_BENIGN_RACE_SIZED(&g_lockdep, sizeof(g_lockdep),
+                               "lockdep enabled");
     g_lockdep = true;
     g_lockdep_ceph_ctx = cct;
     lockdep_dout(0) << "lockdep start" << dendl;
diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc
index 9ecfbec..525a542 100644
--- a/src/common/obj_bencher.cc
+++ b/src/common/obj_bencher.cc
@@ -390,6 +390,7 @@ int ObjBencher::write_bench(int secondsToRun,
   pthread_t print_thread;
 
   pthread_create(&print_thread, NULL, ObjBencher::status_printer, (void *)this);
+  pthread_setname_np(print_thread, "write_stat");
   lock.Lock();
   data.finished = 0;
   data.start_time = ceph_clock_now(cct);
@@ -610,6 +611,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
 
   pthread_t print_thread;
   pthread_create(&print_thread, NULL, status_printer, (void *)this);
+  pthread_setname_np(print_thread, "seq_read_stat");
 
   utime_t finish_time = data.start_time + time_to_run;
   //start initial reads
@@ -830,6 +832,7 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
 
   pthread_t print_thread;
   pthread_create(&print_thread, NULL, status_printer, (void *)this);
+  pthread_setname_np(print_thread, "rand_read_stat");
 
   utime_t finish_time = data.start_time + time_to_run;
   //start initial reads
diff --git a/src/common/perf_counters.cc b/src/common/perf_counters.cc
index 0c86f13..2b80a25 100644
--- a/src/common/perf_counters.cc
+++ b/src/common/perf_counters.cc
@@ -18,6 +18,7 @@
 #include "common/dout.h"
 #include "common/errno.h"
 #include "common/Formatter.h"
+#include "common/valgrind.h"
 
 #include <errno.h>
 #include <map>
@@ -180,6 +181,9 @@ void PerfCounters::set(int idx, uint64_t amt)
   perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]);
   if (!(data.type & PERFCOUNTER_U64))
     return;
+
+  ANNOTATE_BENIGN_RACE_SIZED(&data.u64, sizeof(data.u64),
+                             "perf counter atomic");
   if (data.type & PERFCOUNTER_LONGRUNAVG) {
     data.avgcount.inc();
     data.u64.set(amt);
@@ -221,6 +225,25 @@ void PerfCounters::tinc(int idx, utime_t amt)
   }
 }
 
+void PerfCounters::tinc(int idx, ceph::timespan amt)
+{
+  if (!m_cct->_conf->perf)
+    return;
+
+  assert(idx > m_lower_bound);
+  assert(idx < m_upper_bound);
+  perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]);
+  if (!(data.type & PERFCOUNTER_TIME))
+    return;
+  if (data.type & PERFCOUNTER_LONGRUNAVG) {
+    data.avgcount.inc();
+    data.u64.add(amt.count());
+    data.avgcount2.inc();
+  } else {
+    data.u64.add(amt.count());
+  }
+}
+
 void PerfCounters::tset(int idx, utime_t amt)
 {
   if (!m_cct->_conf->perf)
diff --git a/src/common/perf_counters.h b/src/common/perf_counters.h
index 74dfa7d..5a462f9 100644
--- a/src/common/perf_counters.h
+++ b/src/common/perf_counters.h
@@ -20,6 +20,10 @@
 #include "common/Mutex.h"
 #include "include/utime.h"
 
+#include "common/config_obs.h"
+#include "common/Mutex.h"
+#include "common/ceph_time.h"
+
 #include <stdint.h>
 #include <string>
 #include <vector>
@@ -91,6 +95,7 @@ public:
 
   void tset(int idx, utime_t v);
   void tinc(int idx, utime_t v);
+  void tinc(int idx, ceph::timespan v);
   utime_t tget(int idx) const;
 
   void reset();
diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp
index c55119c..8ff9490 100644
--- a/src/common/shared_cache.hpp
+++ b/src/common/shared_cache.hpp
@@ -21,8 +21,9 @@
 #include <utility>
 #include "common/Mutex.h"
 #include "common/Cond.h"
+#include "include/unordered_map.h"
 
-template <class K, class V, class C = std::less<K> >
+template <class K, class V, class C = std::less<K>, class H = std::hash<K> >
 class SharedLRU {
   CephContext *cct;
   typedef ceph::shared_ptr<V> VPtr;
@@ -34,7 +35,7 @@ class SharedLRU {
 public:
   int waiting;
 private:
-  map<K, typename list<pair<K, VPtr> >::iterator, C> contents;
+  ceph::unordered_map<K, typename list<pair<K, VPtr> >::iterator, H> contents;
   list<pair<K, VPtr> > lru;
 
   map<K, pair<WeakVPtr, V*>, C> weak_refs;
@@ -47,7 +48,7 @@ private:
   }
 
   void lru_remove(const K& key) {
-    typename map<K, typename list<pair<K, VPtr> >::iterator, C>::iterator i =
+    typename ceph::unordered_map<K, typename list<pair<K, VPtr> >::iterator, H>::iterator i = 
       contents.find(key);
     if (i == contents.end())
       return;
@@ -57,7 +58,7 @@ private:
   }
 
   void lru_add(const K& key, const VPtr& val, list<VPtr> *to_release) {
-    typename map<K, typename list<pair<K, VPtr> >::iterator, C>::iterator i =
+    typename ceph::unordered_map<K, typename list<pair<K, VPtr> >::iterator, H>::iterator i =
       contents.find(key);
     if (i != contents.end()) {
       lru.splice(lru.begin(), lru, i->second);
@@ -92,7 +93,9 @@ private:
 public:
   SharedLRU(CephContext *cct = NULL, size_t max_size = 20)
     : cct(cct), lock("SharedLRU::lock"), max_size(max_size), 
-      size(0), waiting(0) {}
+      size(0), waiting(0) {
+    contents.rehash(max_size); 
+  }
   
   ~SharedLRU() {
     contents.clear();
@@ -161,8 +164,9 @@ public:
     VPtr val; // release any ref we have after we drop the lock
     {
       Mutex::Locker l(lock);
-      if (weak_refs.count(key)) {
-	val = weak_refs[key].first.lock();
+      typename map<K, pair<WeakVPtr, V*>, C>::iterator i = weak_refs.find(key);
+      if (i != weak_refs.end()) {
+	val = i->second.first.lock();
       }
       lru_remove(key);
     }
@@ -172,11 +176,12 @@ public:
     VPtr val; // release any ref we have after we drop the lock
     {
       Mutex::Locker l(lock);
-      if (weak_refs.count(key)) {
-	val = weak_refs[key].first.lock();
+      typename map<K, pair<WeakVPtr, V*>, C>::iterator i = weak_refs.find(key);
+      if (i != weak_refs.end()) {
+	val = i->second.first.lock();
+        weak_refs.erase(i);
       }
       lru_remove(key);
-      weak_refs.erase(key);
     }
   }
 
diff --git a/src/common/simple_cache.hpp b/src/common/simple_cache.hpp
index 8038306..3627632 100644
--- a/src/common/simple_cache.hpp
+++ b/src/common/simple_cache.hpp
@@ -20,12 +20,13 @@
 #include <memory>
 #include "common/Mutex.h"
 #include "common/Cond.h"
+#include "include/unordered_map.h"
 
-template <class K, class V, class C = std::less<K> >
+template <class K, class V, class C = std::less<K>, class H = std::hash<K> >
 class SimpleLRU {
   Mutex lock;
   size_t max_size;
-  map<K, typename list<pair<K, V> >::iterator, C> contents;
+  ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H> contents;
   list<pair<K, V> > lru;
   map<K, V, C> pinned;
 
@@ -43,7 +44,9 @@ class SimpleLRU {
   }
 
 public:
-  SimpleLRU(size_t max_size) : lock("SimpleLRU::lock"), max_size(max_size) {}
+  SimpleLRU(size_t max_size) : lock("SimpleLRU::lock"), max_size(max_size) {
+    contents.rehash(max_size);
+  }
 
   void pin(K key, V val) {
     Mutex::Locker l(lock);
@@ -55,16 +58,18 @@ public:
     for (typename map<K, V, C>::iterator i = pinned.begin();
 	 i != pinned.end() && i->first <= e;
 	 pinned.erase(i++)) {
-      if (!contents.count(i->first))
+      typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator iter =
+        contents.find(i->first);
+      if (iter == contents.end())
 	_add(i->first, i->second);
       else
-	lru.splice(lru.begin(), lru, contents[i->first]);
+	lru.splice(lru.begin(), lru, iter->second);
     }
   }
 
   void clear(K key) {
     Mutex::Locker l(lock);
-    typename map<K, typename list<pair<K, V> >::iterator, C>::iterator i =
+    typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator i =
       contents.find(key);
     if (i == contents.end())
       return;
@@ -80,15 +85,16 @@ public:
 
   bool lookup(K key, V *out) {
     Mutex::Locker l(lock);
-    typename list<pair<K, V> >::iterator loc = contents.count(key) ?
-      contents[key] : lru.end();
-    if (loc != lru.end()) {
-      *out = loc->second;
-      lru.splice(lru.begin(), lru, loc);
+    typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator i =
+      contents.find(key);
+    if (i != contents.end()) {
+      *out = i->second->second;
+      lru.splice(lru.begin(), lru, i->second);
       return true;
     }
-    if (pinned.count(key)) {
-      *out = pinned[key];
+    typename map<K, V, C>::iterator i_pinned = pinned.find(key);
+    if (i_pinned != pinned.end()) {
+      *out = i_pinned->second;
       return true;
     }
     return false;
diff --git a/src/common/sync_filesystem.h b/src/common/sync_filesystem.h
index a664a86..f457f65 100644
--- a/src/common/sync_filesystem.h
+++ b/src/common/sync_filesystem.h
@@ -20,7 +20,7 @@
 #if defined(__linux__)
 #include <sys/ioctl.h>
 #include <syscall.h>
-#include "../os/btrfs_ioctl.h"
+#include "os/fs/btrfs_ioctl.h"
 #endif
 
 inline int sync_filesystem(int fd)
diff --git a/src/common/util.cc b/src/common/util.cc
index f9262f3..2c60cb2 100644
--- a/src/common/util.cc
+++ b/src/common/util.cc
@@ -30,26 +30,6 @@
 #include <sys/mount.h>
 #endif
 
-// test if an entire buf is zero in 8-byte chunks
-bool buf_is_zero(const char *buf, size_t len)
-{
-  size_t ofs;
-  int chunk = sizeof(uint64_t);
-
-  for (ofs = 0; ofs < len; ofs += sizeof(uint64_t)) {
-    if (*(uint64_t *)(buf + ofs) != 0) {
-      return false;
-    }
-  }
-  for (ofs = (len / chunk) * chunk; ofs < len; ofs++) {
-    if (buf[ofs] != '\0') {
-      return false;
-    }
-  }
-  return true;
-}
-
-
 int64_t unit_to_bytesize(string val, ostream *pss)
 {
   if (val.empty()) {
diff --git a/src/common/valgrind.h b/src/common/valgrind.h
index 2aa3fb5..8efa60b 100644
--- a/src/common/valgrind.h
+++ b/src/common/valgrind.h
@@ -4,12 +4,16 @@
 #ifndef CEPH_VALGRIND_H
 #define CEPH_VALGRIND_H
 
+#include "acconfig.h"
+
 #ifdef HAVE_VALGRIND_HELGRIND_H
   #include <valgrind/helgrind.h>
 #else
-  #define ANNOTATE_HAPPENS_AFTER(x)             do {} while (0)
-  #define ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(x) ANNOTATE_HAPPENS_AFTER(x)
-  #define ANNOTATE_HAPPENS_BEFORE(x)            ANNOTATE_HAPPENS_AFTER(x)
+  #define ANNOTATE_HAPPENS_AFTER(x)             (void)0
+  #define ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(x) (void)0
+  #define ANNOTATE_HAPPENS_BEFORE(x)            (void)0
+
+  #define ANNOTATE_BENIGN_RACE_SIZED(address, size, description) (void)0
 #endif
 
 #endif // CEPH_VALGRIND_H
diff --git a/src/compressor/AsyncCompressor.cc b/src/compressor/AsyncCompressor.cc
index 564d614..7a9071a 100644
--- a/src/compressor/AsyncCompressor.cc
+++ b/src/compressor/AsyncCompressor.cc
@@ -21,9 +21,9 @@
 #define dout_prefix *_dout << "compressor "
 
 AsyncCompressor::AsyncCompressor(CephContext *c):
-  compressor(Compressor::create(c->_conf->async_compressor_type)), cct(c),
+  compressor(Compressor::create(c, c->_conf->async_compressor_type)), cct(c),
   job_id(0),
-  compress_tp(g_ceph_context, "AsyncCompressor::compressor_tp", cct->_conf->async_compressor_threads, "async_compressor_threads"),
+  compress_tp(cct, "AsyncCompressor::compressor_tp", "tp_async_compr", cct->_conf->async_compressor_threads, "async_compressor_threads"),
   job_lock("AsyncCompressor::job_lock"),
   compress_wq(this, c->_conf->async_compressor_thread_timeout, c->_conf->async_compressor_thread_suicide_timeout, &compress_tp) {
 }
diff --git a/src/compressor/AsyncCompressor.h b/src/compressor/AsyncCompressor.h
index 15af92b..cec2e96 100644
--- a/src/compressor/AsyncCompressor.h
+++ b/src/compressor/AsyncCompressor.h
@@ -25,7 +25,7 @@
 
 class AsyncCompressor {
  private:
-  Compressor *compressor;
+  CompressorRef compressor;
   CephContext *cct;
   atomic_t job_id;
   vector<int> coreids;
diff --git a/src/compressor/CompressionPlugin.h b/src/compressor/CompressionPlugin.h
new file mode 100644
index 0000000..d699d00
--- /dev/null
+++ b/src/compressor/CompressionPlugin.h
@@ -0,0 +1,45 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph distributed storage system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ * 
+ */
+
+#ifndef COMPRESSION_PLUGIN_H
+#define COMPRESSION_PLUGIN_H
+
+#include "common/Mutex.h"
+#include "common/PluginRegistry.h"
+#include "Compressor.h"
+
+namespace ceph {
+
+  class CompressionPlugin :  public Plugin {
+  public:
+    CompressorRef compressor;
+
+    CompressionPlugin(CephContext *cct) : Plugin(cct),
+                                          compressor(0) 
+    {}
+    
+    virtual ~CompressionPlugin() {}
+
+    virtual int factory(CompressorRef *cs,
+			                  ostream *ss) = 0;
+
+    virtual const char* name() {return "CompressionPlugin";}
+  };
+
+}
+
+#endif
diff --git a/src/compressor/Compressor.cc b/src/compressor/Compressor.cc
index 0d11e74..2ef817c 100644
--- a/src/compressor/Compressor.cc
+++ b/src/compressor/Compressor.cc
@@ -13,13 +13,21 @@
  */
 
 #include "Compressor.h"
-#include "SnappyCompressor.h"
+#include "CompressionPlugin.h"
 
 
-Compressor* Compressor::create(const string &type)
+CompressorRef Compressor::create(CephContext *cct, const string &type)
 {
-  if (type == "snappy")
-    return new SnappyCompressor();
-
-  assert(0);
+  CompressorRef cs_impl = NULL;
+  stringstream ss;
+  PluginRegistry *reg = cct->get_plugin_registry();
+  CompressionPlugin *factory = dynamic_cast<CompressionPlugin*>(reg->get_with_load("compressor", type));
+  if (factory == NULL) {
+    lderr(cct) << __func__ << " cannot load compressor of type " << type << dendl;
+    return NULL;
+  }
+  int err = factory->factory(&cs_impl, &ss);
+  if (err)
+    lderr(cct) << __func__ << " factory return error " << err << dendl;
+  return cs_impl;
 }
diff --git a/src/compressor/Compressor.h b/src/compressor/Compressor.h
index 3eb71aa..c891bbe 100644
--- a/src/compressor/Compressor.h
+++ b/src/compressor/Compressor.h
@@ -18,13 +18,19 @@
 #include "include/int_types.h"
 #include "include/Context.h"
 
+class Compressor;
+typedef shared_ptr<Compressor> CompressorRef;
+
+
 class Compressor {
  public:
   virtual ~Compressor() {}
   virtual int compress(bufferlist &in, bufferlist &out) = 0;
   virtual int decompress(bufferlist &in, bufferlist &out) = 0;
 
-  static Compressor *create(const string &type);
+  static CompressorRef create(CephContext *cct, const string &type);
 };
 
+
+
 #endif
diff --git a/src/compressor/Makefile.am b/src/compressor/Makefile.am
index bd2a2d7..47a069f 100644
--- a/src/compressor/Makefile.am
+++ b/src/compressor/Makefile.am
@@ -1,11 +1,20 @@
+compressorlibdir = $(pkglibdir)/compressor
+compressorlib_LTLIBRARIES =  
+
+include compressor/snappy/Makefile.am
+
 libcompressor_la_SOURCES = \
 	compressor/Compressor.cc \
 	compressor/AsyncCompressor.cc
+compressor/CompressionPlugin.cc: ./ceph_ver.h
+libcompressor_la_DEPENDENCIES = $(compressorlib_LTLIBRARIES)
+if LINUX
+libcompressor_la_LIBADD = -ldl
+endif # LINUX
 noinst_LTLIBRARIES += libcompressor.la
 
-libcompressor_la_LIBADD = $(LIBCOMMON)
-
 noinst_HEADERS += \
 	compressor/Compressor.h \
 	compressor/AsyncCompressor.h \
-	compressor/SnappyCompressor.h
+    compressor/CompressionPlugin.h
+
diff --git a/src/compressor/snappy/CompressionPluginSnappy.cc b/src/compressor/snappy/CompressionPluginSnappy.cc
new file mode 100644
index 0000000..2030d56
--- /dev/null
+++ b/src/compressor/snappy/CompressionPluginSnappy.cc
@@ -0,0 +1,57 @@
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+
+// -----------------------------------------------------------------------------
+#include "ceph_ver.h"
+#include "compressor/CompressionPlugin.h"
+#include "SnappyCompressor.h"
+// -----------------------------------------------------------------------------
+
+class CompressionPluginSnappy : public CompressionPlugin {
+
+public:
+
+  CompressionPluginSnappy(CephContext* cct) : CompressionPlugin(cct)
+  {}
+
+  virtual int factory(CompressorRef *cs,
+                      ostream *ss)
+  {
+    if (compressor == 0) {
+      SnappyCompressor *interface = new SnappyCompressor();
+      compressor = CompressorRef(interface);
+    }
+    *cs = compressor;
+    return 0;
+  }
+};
+
+// -----------------------------------------------------------------------------
+
+const char *__ceph_plugin_version()
+{
+  return CEPH_GIT_NICE_VER;
+}
+
+// -----------------------------------------------------------------------------
+
+int __ceph_plugin_init(CephContext *cct,
+                       const std::string& type,
+                       const std::string& name)
+{
+  PluginRegistry *instance = cct->get_plugin_registry();
+
+  return instance->add(type, name, new CompressionPluginSnappy(cct));
+}
diff --git a/src/compressor/snappy/Makefile.am b/src/compressor/snappy/Makefile.am
new file mode 100644
index 0000000..49d3db0
--- /dev/null
+++ b/src/compressor/snappy/Makefile.am
@@ -0,0 +1,22 @@
+# snappy plugin
+noinst_HEADERS += \
+  compressor/snappy/SnappyCompressor.h
+
+snappy_sources = \
+  compressor/Compressor.cc \
+  compressor/snappy/CompressionPluginSnappy.cc
+
+compressor/snappy/CompressionPluginSnappy.cc: ./ceph_ver.h
+
+libceph_snappy_la_SOURCES = ${snappy_sources}
+libceph_snappy_la_CFLAGS = ${AM_CFLAGS}  \
+  -I$(srcdir)/compressor/snappy/snappy-1.2.8
+libceph_snappy_la_CXXFLAGS= ${AM_CXXFLAGS} \
+  -I$(srcdir)/compressor/snappy/snappy-1.2.8
+libceph_snappy_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+libceph_snappy_la_LDFLAGS = ${AM_LDFLAGS} -lsnappy -version-info 2:0:0
+if LINUX
+libceph_snappy_la_LDFLAGS += -export-symbols-regex '.*__compressor_.*'
+endif
+
+compressorlib_LTLIBRARIES += libceph_snappy.la
diff --git a/src/compressor/SnappyCompressor.h b/src/compressor/snappy/SnappyCompressor.h
similarity index 95%
rename from src/compressor/SnappyCompressor.h
rename to src/compressor/snappy/SnappyCompressor.h
index ba58b46..40ec450 100644
--- a/src/compressor/SnappyCompressor.h
+++ b/src/compressor/snappy/SnappyCompressor.h
@@ -18,7 +18,7 @@
 #include <snappy.h>
 #include <snappy-sinksource.h>
 #include "include/buffer.h"
-#include "Compressor.h"
+#include "compressor/Compressor.h"
 
 class BufferlistSource : public snappy::Source {
   list<bufferptr>::const_iterator pb;
@@ -52,6 +52,7 @@ class BufferlistSource : public snappy::Source {
 class SnappyCompressor : public Compressor {
  public:
   virtual ~SnappyCompressor() {}
+  virtual const char* get_method_name() { return "snappy"; }
   virtual int compress(bufferlist &src, bufferlist &dst) {
     BufferlistSource source(src);
     bufferptr ptr(snappy::MaxCompressedLength(src.length()));
diff --git a/src/crush/CrushCompiler.cc b/src/crush/CrushCompiler.cc
index b4c2e88..22e5913 100644
--- a/src/crush/CrushCompiler.cc
+++ b/src/crush/CrushCompiler.cc
@@ -19,6 +19,7 @@
 
 #include <typeinfo>
 #include "common/errno.h"
+#include <boost/algorithm/string.hpp>
 
 // -------------
 
@@ -195,6 +196,8 @@ int CrushCompiler::decompile(ostream &out)
     out << "tunable chooseleaf_descend_once " << crush.get_chooseleaf_descend_once() << "\n";
   if (crush.get_chooseleaf_vary_r() != 0)
     out << "tunable chooseleaf_vary_r " << crush.get_chooseleaf_vary_r() << "\n";
+  if (crush.get_chooseleaf_stable() != 0)
+    out << "tunable chooseleaf_stable " << crush.get_chooseleaf_stable() << "\n";
   if (crush.get_straw_calc_version() != 0)
     out << "tunable straw_calc_version " << crush.get_straw_calc_version() << "\n";
   if (crush.get_allowed_bucket_algs() != CRUSH_LEGACY_ALLOWED_BUCKET_ALGS)
@@ -213,7 +216,7 @@ int CrushCompiler::decompile(ostream &out)
   for (int i=0; n; i++) {
     const char *name = crush.get_type_name(i);
     if (!name) {
-      if (i == 0) out << "type 0 device\n";
+      if (i == 0) out << "type 0 osd\n";
       continue;
     }
     n--;
@@ -285,6 +288,10 @@ int CrushCompiler::decompile(ostream &out)
 	out << "\tstep set_chooseleaf_vary_r " << crush.get_rule_arg1(i, j)
 	    << "\n";
 	break;
+      case CRUSH_RULE_SET_CHOOSELEAF_STABLE:
+	out << "\tstep set_chooseleaf_stable " << crush.get_rule_arg1(i, j)
+	    << "\n";
+	break;
       case CRUSH_RULE_CHOOSE_FIRSTN:
 	out << "\tstep choose firstn "
 	    << crush.get_rule_arg1(i, j) 
@@ -326,11 +333,7 @@ int CrushCompiler::decompile(ostream &out)
 
 string CrushCompiler::string_node(node_t &node)
 {
-  string s = string(node.value.begin(), node.value.end());
-  while (s.length() > 0 &&
-	 s[0] == ' ')
-    s = string(s.begin() + 1, s.end());
-  return s;
+  return boost::trim_copy(string(node.value.begin(), node.value.end()));
 }
 
 int CrushCompiler::int_node(node_t &node) 
@@ -377,6 +380,8 @@ int CrushCompiler::parse_tunable(iter_t const& i)
     crush.set_chooseleaf_descend_once(val);
   else if (name == "chooseleaf_vary_r")
     crush.set_chooseleaf_vary_r(val);
+  else if (name == "chooseleaf_stable")
+    crush.set_chooseleaf_stable(val);
   else if (name == "straw_calc_version")
     crush.set_straw_calc_version(val);
   else if (name == "allowed_bucket_algs")
@@ -676,6 +681,13 @@ int CrushCompiler::parse_rule(iter_t const& i)
       }
       break;
 
+    case crush_grammar::_step_set_chooseleaf_stable:
+      {
+	int val = int_node(s->children[1]);
+	crush.set_rule_step_set_chooseleaf_stable(ruleno, step++, val);
+      }
+      break;
+
     case crush_grammar::_step_choose:
     case crush_grammar::_step_chooseleaf:
       {
diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc
index d10aab9..adf147b 100644
--- a/src/crush/CrushTester.cc
+++ b/src/crush/CrushTester.cc
@@ -8,6 +8,8 @@
 #include <algorithm>
 #include <stdlib.h>
 #include <boost/lexical_cast.hpp>
+#include <boost/icl/interval_map.hpp>
+#include <boost/algorithm/string/join.hpp>
 #include <common/SubProcess.h>
 
 void CrushTester::set_device_weight(int dev, float f)
@@ -450,6 +452,51 @@ bool CrushTester::check_name_maps(unsigned max_id) const
   return true;
 }
 
+static string get_rule_name(CrushWrapper& crush, int rule)
+{
+  if (crush.get_rule_name(rule))
+    return crush.get_rule_name(rule);
+  else
+    return string("rule") + std::to_string(rule);
+}
+
+void CrushTester::check_overlapped_rules() const
+{
+  namespace icl = boost::icl;
+  typedef std::set<string> RuleNames;
+  typedef icl::interval_map<int, RuleNames> Rules;
+  // <ruleset, type> => interval_map<size, {names}>
+  typedef std::map<std::pair<int, int>, Rules> RuleSets;
+  using interval = icl::interval<int>;
+
+  // mimic the logic of crush_find_rule(), but it only return the first matched
+  // one, but I am collecting all of them by the overlapped sizes.
+  RuleSets rulesets;
+  for (int rule = 0; rule < crush.get_max_rules(); rule++) {
+    if (!crush.rule_exists(rule)) {
+      continue;
+    }
+    Rules& rules = rulesets[{crush.get_rule_mask_ruleset(rule),
+			     crush.get_rule_mask_type(rule)}];
+    rules += make_pair(interval::closed(crush.get_rule_mask_min_size(rule),
+					crush.get_rule_mask_max_size(rule)),
+		       RuleNames{get_rule_name(crush, rule)});
+  }
+  for (auto i : rulesets) {
+    auto ruleset_type = i.first;
+    const Rules& rules = i.second;
+    for (auto r : rules) {
+      const RuleNames& names = r.second;
+      // if there are more than one rules covering the same size range,
+      // print them out.
+      if (names.size() > 1) {
+	err << "overlapped rules in ruleset " << ruleset_type.first << ": "
+	    << boost::join(names, ", ") << "\n";
+      }
+    }
+  }
+}
+
 int CrushTester::test()
 {
   if (min_rule < 0 || max_rule < 0) {
diff --git a/src/crush/CrushTester.h b/src/crush/CrushTester.h
index 2f1a2c6..bd625f3 100644
--- a/src/crush/CrushTester.h
+++ b/src/crush/CrushTester.h
@@ -347,6 +347,10 @@ public:
    *         large, true otherwise
    */
   bool check_name_maps(unsigned max_id = 0) const;
+  /**
+   * print out overlapped crush rules belonging to the same ruleset
+   */
+  void check_overlapped_rules() const;
   int test();
   int test_with_crushtool(const char *crushtool_cmd = "crushtool",
 			  int max_id = -1,
diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc
index ba365dd..8a2d28b 100644
--- a/src/crush/CrushWrapper.cc
+++ b/src/crush/CrushWrapper.cc
@@ -78,6 +78,32 @@ bool CrushWrapper::has_v4_buckets() const
   return false;
 }
 
+bool CrushWrapper::has_v5_rules() const
+{
+  for (unsigned i=0; i<crush->max_rules; i++) {
+    if (is_v5_rule(i)) {
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CrushWrapper::is_v5_rule(unsigned ruleid) const
+{
+  // check rule for use of SET_CHOOSELEAF_STABLE step
+  if (ruleid >= crush->max_rules)
+    return false;
+  crush_rule *r = crush->rules[ruleid];
+  if (!r)
+    return false;
+  for (unsigned j=0; j<r->len; j++) {
+    if (r->steps[j].op == CRUSH_RULE_SET_CHOOSELEAF_STABLE) {
+      return true;
+    }
+  }
+  return false;
+}
+
 int CrushWrapper::can_rename_item(const string& srcname,
                                   const string& dstname,
                                   ostream *ss) const
@@ -1184,6 +1210,7 @@ void CrushWrapper::encode(bufferlist& bl, bool lean) const
   ::encode(crush->chooseleaf_vary_r, bl);
   ::encode(crush->straw_calc_version, bl);
   ::encode(crush->allowed_bucket_algs, bl);
+  ::encode(crush->chooseleaf_stable, bl);
 }
 
 static void decode_32_or_64_string_map(map<int32_t,string>& m, bufferlist::iterator& blp)
@@ -1273,6 +1300,9 @@ void CrushWrapper::decode(bufferlist::iterator& blp)
     if (!blp.end()) {
       ::decode(crush->allowed_bucket_algs, blp);
     }
+    if (!blp.end()) {
+      ::decode(crush->chooseleaf_stable, blp);
+    }
     finalize();
   }
   catch (...) {
@@ -1519,11 +1549,14 @@ void CrushWrapper::dump_tunables(Formatter *f) const
   f->dump_int("choose_total_tries", get_choose_total_tries());
   f->dump_int("chooseleaf_descend_once", get_chooseleaf_descend_once());
   f->dump_int("chooseleaf_vary_r", get_chooseleaf_vary_r());
+  f->dump_int("chooseleaf_stable", get_chooseleaf_stable());
   f->dump_int("straw_calc_version", get_straw_calc_version());
   f->dump_int("allowed_bucket_algs", get_allowed_bucket_algs());
 
   // be helpful about it
-  if (has_hammer_tunables())
+  if (has_jewel_tunables())
+    f->dump_string("profile", "jewel");
+  else if (has_hammer_tunables())
     f->dump_string("profile", "hammer");
   else if (has_firefly_tunables())
     f->dump_string("profile", "firefly");
@@ -1538,10 +1571,12 @@ void CrushWrapper::dump_tunables(Formatter *f) const
 
   f->dump_int("require_feature_tunables", (int)has_nondefault_tunables());
   f->dump_int("require_feature_tunables2", (int)has_nondefault_tunables2());
-  f->dump_int("require_feature_tunables3", (int)has_nondefault_tunables3());
   f->dump_int("has_v2_rules", (int)has_v2_rules());
+  f->dump_int("require_feature_tunables3", (int)has_nondefault_tunables3());
   f->dump_int("has_v3_rules", (int)has_v3_rules());
   f->dump_int("has_v4_buckets", (int)has_v4_buckets());
+  f->dump_int("require_feature_tunables5", (int)has_nondefault_tunables5());
+  f->dump_int("has_v5_rules", (int)has_v5_rules());
 }
 
 void CrushWrapper::dump_rules(Formatter *f) const
diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h
index e3b4c48..77baa2c 100644
--- a/src/crush/CrushWrapper.h
+++ b/src/crush/CrushWrapper.h
@@ -107,6 +107,7 @@ public:
     crush->choose_total_tries = 19;
     crush->chooseleaf_descend_once = 0;
     crush->chooseleaf_vary_r = 0;
+    crush->chooseleaf_stable = 0;
     crush->allowed_bucket_algs = CRUSH_LEGACY_ALLOWED_BUCKET_ALGS;
   }
   void set_tunables_bobtail() {
@@ -115,6 +116,7 @@ public:
     crush->choose_total_tries = 50;
     crush->chooseleaf_descend_once = 1;
     crush->chooseleaf_vary_r = 0;
+    crush->chooseleaf_stable = 0;
     crush->allowed_bucket_algs = CRUSH_LEGACY_ALLOWED_BUCKET_ALGS;
   }
   void set_tunables_firefly() {
@@ -123,6 +125,7 @@ public:
     crush->choose_total_tries = 50;
     crush->chooseleaf_descend_once = 1;
     crush->chooseleaf_vary_r = 1;
+    crush->chooseleaf_stable = 0;
     crush->allowed_bucket_algs = CRUSH_LEGACY_ALLOWED_BUCKET_ALGS;
   }
   void set_tunables_hammer() {
@@ -131,6 +134,20 @@ public:
     crush->choose_total_tries = 50;
     crush->chooseleaf_descend_once = 1;
     crush->chooseleaf_vary_r = 1;
+    crush->chooseleaf_stable = 0;
+    crush->allowed_bucket_algs =
+      (1 << CRUSH_BUCKET_UNIFORM) |
+      (1 << CRUSH_BUCKET_LIST) |
+      (1 << CRUSH_BUCKET_STRAW) |
+      (1 << CRUSH_BUCKET_STRAW2);
+  }
+  void set_tunables_jewel() {
+    crush->choose_local_tries = 0;
+    crush->choose_local_fallback_tries = 0;
+    crush->choose_total_tries = 50;
+    crush->chooseleaf_descend_once = 1;
+    crush->chooseleaf_vary_r = 1;
+    crush->chooseleaf_stable = 1;
     crush->allowed_bucket_algs =
       (1 << CRUSH_BUCKET_UNIFORM) |
       (1 << CRUSH_BUCKET_LIST) |
@@ -143,7 +160,7 @@ public:
     crush->straw_calc_version = 0;
   }
   void set_tunables_optimal() {
-    set_tunables_hammer();
+    set_tunables_jewel();
     crush->straw_calc_version = 1;
   }
   void set_tunables_default() {
@@ -186,6 +203,13 @@ public:
     crush->chooseleaf_vary_r = n;
   }
 
+  int get_chooseleaf_stable() const {
+    return crush->chooseleaf_stable;
+  }
+  void set_chooseleaf_stable(int n) {
+    crush->chooseleaf_stable = n;
+  }
+
   int get_straw_calc_version() const {
     return crush->straw_calc_version;
   }
@@ -207,6 +231,7 @@ public:
       crush->choose_total_tries == 19 &&
       crush->chooseleaf_descend_once == 0 &&
       crush->chooseleaf_vary_r == 0 &&
+      crush->chooseleaf_stable == 0 &&
       crush->straw_calc_version == 0 &&
       crush->allowed_bucket_algs == CRUSH_LEGACY_ALLOWED_BUCKET_ALGS;
   }
@@ -217,6 +242,7 @@ public:
       crush->choose_total_tries == 50 &&
       crush->chooseleaf_descend_once == 1 &&
       crush->chooseleaf_vary_r == 0 &&
+      crush->chooseleaf_stable == 0 &&
       crush->straw_calc_version == 0 &&
       crush->allowed_bucket_algs == CRUSH_LEGACY_ALLOWED_BUCKET_ALGS;
   }
@@ -227,6 +253,7 @@ public:
       crush->choose_total_tries == 50 &&
       crush->chooseleaf_descend_once == 1 &&
       crush->chooseleaf_vary_r == 1 &&
+      crush->chooseleaf_stable == 0 &&
       crush->straw_calc_version == 0 &&
       crush->allowed_bucket_algs == CRUSH_LEGACY_ALLOWED_BUCKET_ALGS;
   }
@@ -237,15 +264,30 @@ public:
       crush->choose_total_tries == 50 &&
       crush->chooseleaf_descend_once == 1 &&
       crush->chooseleaf_vary_r == 1 &&
+      crush->chooseleaf_stable == 0 &&
       crush->straw_calc_version == 1 &&
       crush->allowed_bucket_algs == ((1 << CRUSH_BUCKET_UNIFORM) |
 				      (1 << CRUSH_BUCKET_LIST) |
 				      (1 << CRUSH_BUCKET_STRAW) |
 				      (1 << CRUSH_BUCKET_STRAW2));
-}
+  }
+  bool has_jewel_tunables() const {
+    return
+      crush->choose_local_tries == 0 &&
+      crush->choose_local_fallback_tries == 0 &&
+      crush->choose_total_tries == 50 &&
+      crush->chooseleaf_descend_once == 1 &&
+      crush->chooseleaf_vary_r == 1 &&
+      crush->chooseleaf_stable == 1 &&
+      crush->straw_calc_version == 1 &&
+      crush->allowed_bucket_algs == ((1 << CRUSH_BUCKET_UNIFORM) |
+				      (1 << CRUSH_BUCKET_LIST) |
+				      (1 << CRUSH_BUCKET_STRAW) |
+				      (1 << CRUSH_BUCKET_STRAW2));
+  }
 
   bool has_optimal_tunables() const {
-    return has_firefly_tunables();
+    return has_jewel_tunables();
   }
   bool has_legacy_tunables() const {
     return has_argonaut_tunables();
@@ -265,13 +307,19 @@ public:
     return
       crush->chooseleaf_vary_r != 0;
   }
+  bool has_nondefault_tunables5() const {
+    return
+        crush->chooseleaf_stable != 0;
+  }
 
   bool has_v2_rules() const;
   bool has_v3_rules() const;
   bool has_v4_buckets() const;
+  bool has_v5_rules() const;
 
   bool is_v2_rule(unsigned ruleid) const;
   bool is_v3_rule(unsigned ruleid) const;
+  bool is_v5_rule(unsigned ruleid) const;
 
   // default bucket types
   unsigned get_default_bucket_alg() const {
@@ -779,6 +827,9 @@ public:
   int set_rule_step_set_chooseleaf_vary_r(unsigned ruleno, unsigned step, int val) {
     return set_rule_step(ruleno, step, CRUSH_RULE_SET_CHOOSELEAF_VARY_R, val, 0);
   }
+  int set_rule_step_set_chooseleaf_stable(unsigned ruleno, unsigned step, int val) {
+    return set_rule_step(ruleno, step, CRUSH_RULE_SET_CHOOSELEAF_STABLE, val, 0);
+  }
   int set_rule_step_choose_firstn(unsigned ruleno, unsigned step, int val, int type) {
     return set_rule_step(ruleno, step, CRUSH_RULE_CHOOSE_FIRSTN, val, type);
   }
diff --git a/src/crush/crush.h b/src/crush/crush.h
index 48b4930..be8f12b 100644
--- a/src/crush/crush.h
+++ b/src/crush/crush.h
@@ -59,7 +59,8 @@ enum {
 	CRUSH_RULE_SET_CHOOSELEAF_TRIES = 9, /* override chooseleaf_descend_once */
 	CRUSH_RULE_SET_CHOOSE_LOCAL_TRIES = 10,
 	CRUSH_RULE_SET_CHOOSE_LOCAL_FALLBACK_TRIES = 11,
-	CRUSH_RULE_SET_CHOOSELEAF_VARY_R = 12
+	CRUSH_RULE_SET_CHOOSELEAF_VARY_R = 12,
+	CRUSH_RULE_SET_CHOOSELEAF_STABLE = 13
 };
 
 /*
@@ -205,6 +206,11 @@ struct crush_map {
 	 * mappings line up a bit better with previous mappings. */
 	__u8 chooseleaf_vary_r;
 
+	/* if true, it makes chooseleaf firstn to return stable results (if
+	 * no local retry) so that data migrations would be optimal when some
+	 * device fails. */
+	__u8 chooseleaf_stable;
+
 #ifndef __KERNEL__
 	/*
 	 * version 0 (original) of straw_calc has various flaws.  version 1
diff --git a/src/crush/grammar.h b/src/crush/grammar.h
index de77696..351cf0c 100644
--- a/src/crush/grammar.h
+++ b/src/crush/grammar.h
@@ -46,6 +46,7 @@ struct crush_grammar : public grammar<crush_grammar>
     _step_take,
     _step_set_chooseleaf_tries,
     _step_set_chooseleaf_vary_r,
+    _step_set_chooseleaf_stable,
     _step_set_choose_tries,
     _step_set_choose_local_tries,
     _step_set_choose_local_fallback_tries,
@@ -84,6 +85,7 @@ struct crush_grammar : public grammar<crush_grammar>
     rule<ScannerT, parser_context<>, parser_tag<_step_set_choose_local_fallback_tries> >    step_set_choose_local_fallback_tries;
     rule<ScannerT, parser_context<>, parser_tag<_step_set_chooseleaf_tries> >    step_set_chooseleaf_tries;
     rule<ScannerT, parser_context<>, parser_tag<_step_set_chooseleaf_vary_r> >    step_set_chooseleaf_vary_r;
+    rule<ScannerT, parser_context<>, parser_tag<_step_set_chooseleaf_stable> >    step_set_chooseleaf_stable;
     rule<ScannerT, parser_context<>, parser_tag<_step_choose> >    step_choose;
     rule<ScannerT, parser_context<>, parser_tag<_step_chooseleaf> >      step_chooseleaf;
     rule<ScannerT, parser_context<>, parser_tag<_step_emit> >      step_emit;
@@ -128,6 +130,7 @@ struct crush_grammar : public grammar<crush_grammar>
       step_set_choose_local_fallback_tries = str_p("set_choose_local_fallback_tries") >> posint;
       step_set_chooseleaf_tries = str_p("set_chooseleaf_tries") >> posint;
       step_set_chooseleaf_vary_r = str_p("set_chooseleaf_vary_r") >> posint;
+      step_set_chooseleaf_stable = str_p("set_chooseleaf_stable") >> posint;
       step_choose = str_p("choose")
 	>> ( str_p("indep") | str_p("firstn") )
 	>> integer
@@ -143,6 +146,7 @@ struct crush_grammar : public grammar<crush_grammar>
 				step_set_choose_local_fallback_tries |
 				step_set_chooseleaf_tries |
 				step_set_chooseleaf_vary_r |
+				step_set_chooseleaf_stable |
 				step_choose |
 				step_chooseleaf |
 				step_emit );
diff --git a/src/crush/mapper.c b/src/crush/mapper.c
index 412e7e8..832900f 100644
--- a/src/crush/mapper.c
+++ b/src/crush/mapper.c
@@ -403,6 +403,7 @@ static int is_out(const struct crush_map *map,
  * @local_retries: localized retries
  * @local_fallback_retries: localized fallback retries
  * @recurse_to_leaf: true if we want one device under each item of given type (chooseleaf instead of choose)
+ * @stable: stable mode starts rep=0 in the recursive call for all replicas
  * @vary_r: pass r to recursive calls
  * @out2: second output vector for leaf items (if @recurse_to_leaf)
  * @parent_r: r value passed from the parent
@@ -419,6 +420,7 @@ static int crush_choose_firstn(const struct crush_map *map,
 			       unsigned int local_fallback_retries,
 			       int recurse_to_leaf,
 			       unsigned int vary_r,
+			       unsigned int stable,
 			       int *out2,
 			       int parent_r)
 {
@@ -433,13 +435,15 @@ static int crush_choose_firstn(const struct crush_map *map,
 	int collide, reject;
 	int count = out_size;
 
-	dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d tries %d recurse_tries %d local_retries %d local_fallback_retries %d parent_r %d\n",
+	dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d tries %d \
+recurse_tries %d local_retries %d local_fallback_retries %d \
+parent_r %d stable %d\n",
 		recurse_to_leaf ? "_LEAF" : "",
 		bucket->id, x, outpos, numrep,
 		tries, recurse_tries, local_retries, local_fallback_retries,
-		parent_r);
+		parent_r, stable);
 
-	for (rep = outpos; rep < numrep && count > 0 ; rep++) {
+	for (rep = stable ? 0 : outpos; rep < numrep && count > 0 ; rep++) {
 		/* keep trying until we get a non-out, non-colliding item */
 		ftotal = 0;
 		skip_rep = 0;
@@ -512,13 +516,14 @@ static int crush_choose_firstn(const struct crush_map *map,
 						if (crush_choose_firstn(map,
 							 map->buckets[-1-item],
 							 weight, weight_max,
-							 x, outpos+1, 0,
+							 x, stable ? 1 : outpos+1, 0,
 							 out2, outpos, count,
 							 recurse_tries, 0,
 							 local_retries,
 							 local_fallback_retries,
 							 0,
 							 vary_r,
+							 stable,
 							 NULL,
 							 sub_r) <= outpos)
 							/* didn't get leaf */
@@ -816,6 +821,7 @@ int crush_do_rule(const struct crush_map *map,
 	int choose_local_fallback_retries = map->choose_local_fallback_tries;
 
 	int vary_r = map->chooseleaf_vary_r;
+	int stable = map->chooseleaf_stable;
 
 	if ((__u32)ruleno >= map->max_rules) {
 		dprintk(" bad ruleno %d\n", ruleno);
@@ -870,6 +876,11 @@ int crush_do_rule(const struct crush_map *map,
 				vary_r = curstep->arg1;
 			break;
 
+		case CRUSH_RULE_SET_CHOOSELEAF_STABLE:
+			if (curstep->arg1 >= 0)
+				stable = curstep->arg1;
+			break;
+
 		case CRUSH_RULE_CHOOSELEAF_FIRSTN:
 		case CRUSH_RULE_CHOOSE_FIRSTN:
 			firstn = 1;
@@ -932,6 +943,7 @@ int crush_do_rule(const struct crush_map *map,
 						choose_local_fallback_retries,
 						recurse_to_leaf,
 						vary_r,
+						stable,
 						c+osize,
 						0);
 				} else {
diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc
index 560f2fd..6254646 100644
--- a/src/global/signal_handler.cc
+++ b/src/global/signal_handler.cc
@@ -30,7 +30,6 @@
 extern char *sys_siglist[]; 
 #endif 
 
-
 void install_sighandler(int signum, signal_handler_t handler, int flags)
 {
   int ret;
@@ -54,7 +53,7 @@ void install_sighandler(int signum, signal_handler_t handler, int flags)
 #else
     snprintf(buf, sizeof(buf), "install_sighandler: sigaction returned "
 	    "%d when trying to install a signal handler for %s\n",
-	     ret, sys_siglist[signum]);
+	     ret, sig_str(signum));
 #endif
     dout_emergency(buf);
     exit(1);
@@ -99,7 +98,7 @@ static void handle_fatal_signal(int signum)
 	    "in thread %llx\n", message, (unsigned long long)pthread_self());
 #else
   snprintf(buf, sizeof(buf), "*** Caught signal (%s) **\n "
-	    "in thread %llx\n", sys_siglist[signum], (unsigned long long)pthread_self());
+	    "in thread %llx\n", sig_str(signum), (unsigned long long)pthread_self());
 #endif
   dout_emergency(buf);
   pidfile_remove();
@@ -193,7 +192,7 @@ struct SignalHandler : public Thread {
     assert(r == 0);
 
     // create thread
-    create();
+    create("sginal_handler");
   }
 
   ~SignalHandler() {
diff --git a/src/global/signal_handler.h b/src/global/signal_handler.h
index 3a11f54..d768e4e 100644
--- a/src/global/signal_handler.h
+++ b/src/global/signal_handler.h
@@ -18,8 +18,16 @@
 #include <signal.h>
 #include <string>
 
+#include "acconfig.h"
+
 typedef void (*signal_handler_t)(int);
 
+#ifndef HAVE_REENTRANT_STRSIGNAL
+# define sig_str(signum) sys_siglist[signum]
+#else
+# define sig_str(signum) strsignal(signum)
+#endif
+
 void install_sighandler(int signum, signal_handler_t handler, int flags);
 
 // handles SIGHUP
diff --git a/src/gmock/Makefile.in b/src/gmock/Makefile.in
index e1f406a..4c43153 100644
--- a/src/gmock/Makefile.in
+++ b/src/gmock/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,17 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -88,26 +98,14 @@ check_PROGRAMS = test/gmock-spec-builders_test$(EXEEXT) \
 @HAVE_PYTHON_TRUE at am__append_1 = test/gmock_fused_test
 @HAVE_PYTHON_TRUE at am__append_2 = test/gmock_fused_test
 subdir = .
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/configure $(am__configure_deps) \
-	$(top_srcdir)/build-aux/config.h.in \
-	$(top_srcdir)/scripts/gmock-config.in \
-	$(top_srcdir)/build-aux/depcomp $(pkginclude_HEADERS) \
-	$(pkginclude_internal_HEADERS) \
-	$(top_srcdir)/build-aux/test-driver README build-aux/compile \
-	build-aux/config.guess build-aux/config.sub build-aux/depcomp \
-	build-aux/install-sh build-aux/missing build-aux/ltmain.sh \
-	$(top_srcdir)/build-aux/compile \
-	$(top_srcdir)/build-aux/config.guess \
-	$(top_srcdir)/build-aux/config.sub \
-	$(top_srcdir)/build-aux/install-sh \
-	$(top_srcdir)/build-aux/ltmain.sh \
-	$(top_srcdir)/build-aux/missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/gtest/m4/acx_pthread.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+	$(am__configure_deps) $(pkginclude_HEADERS) \
+	$(pkginclude_internal_HEADERS) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
@@ -456,6 +454,19 @@ TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
 	$(TEST_LOG_FLAGS)
 DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+	$(top_srcdir)/build-aux/compile \
+	$(top_srcdir)/build-aux/config.guess \
+	$(top_srcdir)/build-aux/config.h.in \
+	$(top_srcdir)/build-aux/config.sub \
+	$(top_srcdir)/build-aux/depcomp \
+	$(top_srcdir)/build-aux/install-sh \
+	$(top_srcdir)/build-aux/ltmain.sh \
+	$(top_srcdir)/build-aux/missing \
+	$(top_srcdir)/build-aux/test-driver \
+	$(top_srcdir)/scripts/gmock-config.in README build-aux/compile \
+	build-aux/config.guess build-aux/config.sub build-aux/depcomp \
+	build-aux/install-sh build-aux/ltmain.sh build-aux/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -547,6 +558,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -620,6 +632,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -770,7 +783,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -1155,7 +1167,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 	if test -n "$$am__remaking_logs"; then \
 	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
 	       "recursion detected" >&2; \
-	else \
+	elif test -n "$$redo_logs"; then \
 	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
 	fi; \
 	if $(am__make_dryrun); then :; else \
@@ -1382,15 +1394,15 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
@@ -1425,17 +1437,17 @@ distcheck: dist
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_inst
+	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build \
-	  && ../configure \
+	  && $(am__cd) $(distdir)/_build/sub \
+	  && ../../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=.. --prefix="$$dc_install_base" \
+	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -1643,6 +1655,8 @@ uninstall-am: uninstall-pkgincludeHEADERS \
 	uninstall-pkgincludeHEADERS \
 	uninstall-pkginclude_internalHEADERS
 
+.PRECIOUS: Makefile
+
 
 @HAVE_PYTHON_TRUE@  # Tests that fused gmock files compile and work.
 
diff --git a/src/gmock/aclocal.m4 b/src/gmock/aclocal.m4
index bed39b9..1c87fd9 100644
--- a/src/gmock/aclocal.m4
+++ b/src/gmock/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -22,9 +22,7 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
+#   Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -32,36 +30,30 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 # modifications, as long as this notice is preserved.
 
 m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ])
 
-# serial 57 LT_INIT
+# serial 58 LT_INIT
 
 
 # LT_PREREQ(VERSION)
@@ -89,7 +81,7 @@ esac
 # LT_INIT([OPTIONS])
 # ------------------
 AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 AC_BEFORE([$0], [LT_LANG])dnl
 AC_BEFORE([$0], [LT_OUTPUT])dnl
@@ -113,7 +105,7 @@ dnl Parse OPTIONS
 _LT_SET_OPTIONS([$0], [$1])
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -133,26 +125,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in @S|@*""; do
+      case $cc_temp in
+        compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+        distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
 # _LT_CC_BASENAME(CC)
 # -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
 m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
 ])
 
 
 # _LT_FILEUTILS_DEFAULTS
 # ----------------------
 # It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
 m4_defun([_LT_FILEUTILS_DEFAULTS],
 [: ${CP="cp -f"}
 : ${MV="mv -f"}
@@ -199,15 +208,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
 m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
 
 _LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 ])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -220,7 +230,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -231,14 +241,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -291,21 +301,21 @@ no_glob_subst='s/\*/\\\*/g'
 
 # _LT_PROG_LTMAIN
 # ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
 # now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
 # so we pass a copy along to make sure it has a sensible value anyway.
 m4_defun([_LT_PROG_LTMAIN],
 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 ])# _LT_PROG_LTMAIN
 
 
 
 # So that we can recreate a full libtool script including additional
 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
 # label.
 
 
@@ -437,8 +447,8 @@ m4_define([_lt_decl_all_varnames],
 
 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
 # ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'.  VARNAME
 # must have a single quote delimited value for this to work.
 m4_define([_LT_CONFIG_STATUS_DECLARE],
 [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
@@ -462,7 +472,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
 # Output comment and list of tags supported by the script
 m4_defun([_LT_LIBTOOL_TAGS],
 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
 ])
 
 
@@ -490,7 +500,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
 # _LT_LIBTOOL_CONFIG_VARS
 # -----------------------
 # Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
 # script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
 # section) are produced by _LT_LIBTOOL_TAG_VARS.
 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -516,8 +526,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 # Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
 # variables for single and double quote escaping we saved from calls
 # to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'.  Finally, any additional code accumulated
 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
 m4_defun([_LT_CONFIG_COMMANDS],
 [AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -563,7 +573,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_quote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -576,7 +586,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_dquote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -592,7 +602,7 @@ _LT_OUTPUT_LIBTOOL_INIT
 # Generate a child script FILE with all initialization necessary to
 # reuse the environment learned by the parent script, and make the
 # file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
+# '#!' sequence but before initialization text begins.  After this
 # macro, additional text can be appended to FILE to form the body of
 # the child script.  The macro ends with non-zero status if the
 # file could not be fully written (such as if the disk is full).
@@ -614,7 +624,7 @@ AS_SHELL_SANITIZE
 _AS_PREPARE
 exec AS_MESSAGE_FD>&1
 _ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
 m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
 # LT_OUTPUT
@@ -637,7 +647,7 @@ exec AS_MESSAGE_LOG_FD>>config.log
 } >&AS_MESSAGE_LOG_FD
 
 lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
 for use in further configure time tests before the real libtool is
 generated.
 
@@ -659,7 +669,7 @@ Copyright (C) 2011 Free Software Foundation, Inc.
 This config.lt script is free software; the Free Software Foundation
 gives unlimited permision to copy, distribute and modify it."
 
-while test $[#] != 0
+while test 0 != $[#]
 do
   case $[1] in
     --version | --v* | -V )
@@ -672,10 +682,10 @@ do
       lt_cl_silent=: ;;
 
     -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
 
     *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
   esac
   shift
 done
@@ -701,7 +711,7 @@ chmod +x "$CONFIG_LT"
 # open by configure.  Here we exec the FD to /dev/null, effectively closing
 # config.log, so it can be properly (re)opened and appended to by config.lt.
 lt_cl_success=:
-test "$silent" = yes &&
+test yes = "$silent" &&
   lt_config_lt_args="$lt_config_lt_args --quiet"
 exec AS_MESSAGE_LOG_FD>/dev/null
 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
@@ -721,27 +731,31 @@ m4_defun([_LT_CONFIG],
 _LT_CONFIG_SAVE_COMMANDS([
   m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
   m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
 _LT_COPYING
 _LT_LIBTOOL_TAGS
 
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
 # ### BEGIN LIBTOOL CONFIG
 _LT_LIBTOOL_CONFIG_VARS
 _LT_LIBTOOL_TAG_VARS
@@ -749,13 +763,24 @@ _LT_LIBTOOL_TAG_VARS
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -772,8 +797,6 @@ _LT_EOF
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  _LT_PROG_REPLACE_SHELLFNS
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -791,7 +814,6 @@ _LT_EOF
 [m4_if([$1], [], [
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'], [])
 ])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -988,7 +1010,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 
     AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
       [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -1006,7 +1028,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1024,7 +1046,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
 	[lt_cv_ld_exported_symbols_list=yes],
 	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
     ])
 
     AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
@@ -1046,7 +1068,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&AS_MESSAGE_LOG_FD
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1056,32 +1078,32 @@ _LT_EOF
     ])
     case $host_os in
     rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]][[,.]]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -1101,29 +1123,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_automatic, $1)=yes
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
     m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
                   [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
   else
     _LT_TAGVAR(whole_archive_flag_spec, $1)=''
   fi
   _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
     m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[   if test yes != "$lt_cv_apple_cc_single_mod"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 ],[])
   else
@@ -1143,7 +1165,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
 # Allow to override them for all tags through lt_cv_aix_libpath.
 m4_defun([_LT_SYS_MODULE_PATH_AIX],
 [m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
+if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
@@ -1161,7 +1183,7 @@ else
     _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi],[])
   if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
   fi
   ])
   aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
@@ -1181,8 +1203,8 @@ m4_define([_LT_SHELL_INIT],
 # -----------------------
 # Find how we can fake an echo command that does not interpret backslash.
 # In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
 m4_defun([_LT_PROG_ECHO_BACKSLASH],
 [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
@@ -1210,10 +1232,10 @@ fi
 # Invoke $ECHO with all args, space-separated.
 func_echo_all ()
 {
-    $ECHO "$*" 
+    $ECHO "$*"
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) AC_MSG_RESULT([printf]) ;;
   print*) AC_MSG_RESULT([print -r]) ;;
   *) AC_MSG_RESULT([cat]) ;;
@@ -1239,16 +1261,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
 AC_DEFUN([_LT_WITH_SYSROOT],
 [AC_MSG_CHECKING([for sysroot])
 AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+  [Search for dependent libraries within DIR (or the compiler's sysroot
+   if not specified).])],
 [], [with_sysroot=no])
 
 dnl lt_sysroot will always be passed unquoted.  We quote it here
 dnl in case the user passed a directory name.
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -1258,14 +1281,14 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_RESULT([$with_sysroot])
    AC_MSG_ERROR([The sysroot must be an absolute path.])
    ;;
 esac
 
  AC_MSG_RESULT([${lt_sysroot:-no}])
 _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+[dependent libraries, and where our libraries should be installed.])])
 
 # _LT_ENABLE_LOCK
 # ---------------
@@ -1273,31 +1296,33 @@ m4_defun([_LT_ENABLE_LOCK],
 [AC_ARG_ENABLE([libtool-lock],
   [AS_HELP_STRING([--disable-libtool-lock],
     [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -1326,9 +1351,46 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1347,10 +1409,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1369,10 +1431,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -1390,19 +1452,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
     [AC_LANG_PUSH(C)
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
      AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1410,7 +1473,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -1419,7 +1482,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -1435,7 +1498,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 ])# _LT_ENABLE_LOCK
 
 
@@ -1454,11 +1517,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      [echo conftest.$ac_objext > conftest.lst
       lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
       AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -1466,7 +1529,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      ])
   ])
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -1497,7 +1560,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -1533,7 +1596,7 @@ AC_CACHE_CHECK([$1], [$2],
   [$2=no
    m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
+   lt_compiler_flag="$3"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -1560,7 +1623,7 @@ AC_CACHE_CHECK([$1], [$2],
    $RM conftest*
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$5], , :, [$5])
 else
     m4_if([$6], , :, [$6])
@@ -1582,7 +1645,7 @@ AC_DEFUN([_LT_LINKER_OPTION],
 m4_require([_LT_DECL_SED])dnl
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $3"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1601,10 +1664,10 @@ AC_CACHE_CHECK([$1], [$2],
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$4], , :, [$4])
 else
     m4_if([$5], , :, [$5])
@@ -1625,7 +1688,7 @@ AC_DEFUN([LT_CMD_MAX_LEN],
 AC_MSG_CHECKING([the maximum length of command line arguments])
 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -1665,7 +1728,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1716,22 +1779,22 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -1747,7 +1810,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     ;;
   esac
 ])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
 else
   AC_MSG_RESULT(none)
@@ -1775,7 +1838,7 @@ m4_defun([_LT_HEADER_DLFCN],
 # ----------------------------------------------------------------
 m4_defun([_LT_TRY_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
   [$4]
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -1822,9 +1885,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -1850,7 +1913,7 @@ int main ()
   return status;
 }]
 _LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+  if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -1871,7 +1934,7 @@ rm -fr conftest*
 # ------------------
 AC_DEFUN([LT_SYS_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -1881,44 +1944,52 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ])
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
+	  [lt_cv_dlopen=shl_load],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	    [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
 	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
+	      [lt_cv_dlopen=dlopen],
 	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
 	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+		  [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+		    [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
 	      ])
 	    ])
 	  ])
@@ -1927,21 +1998,21 @@ else
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1951,7 +2022,7 @@ else
 	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
     ])
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
 	  lt_cv_dlopen_self_static, [dnl
@@ -1961,9 +2032,9 @@ else
       ])
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -2055,8 +2126,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS],
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 _LT_COMPILER_C_O([$1])
 
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   AC_MSG_CHECKING([if we can lock with hard links])
   hard_links=yes
@@ -2066,8 +2137,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" !=
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+  if test no = "$hard_links"; then
+    AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
     need_locks=warn
   fi
 else
@@ -2094,8 +2165,8 @@ objdir=$lt_cv_objdir
 _LT_DECL([], [objdir], [0],
          [The name of the directory that contains temporary libtool files])dnl
 m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+  [Define to the sub-directory where libtool stores uninstalled libraries.])
 ])# _LT_CHECK_OBJDIR
 
 
@@ -2107,15 +2178,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
 _LT_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
    test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
 
   # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+  if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+     test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
     # Linking always hardcodes the temporary library directory.
     _LT_TAGVAR(hardcode_action, $1)=relink
   else
@@ -2129,12 +2200,12 @@ else
 fi
 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
 
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+   test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -2158,7 +2229,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       AC_MSG_RESULT([yes])
@@ -2176,6 +2247,47 @@ _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
 
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x at S|@2 in
+    x)
+        ;;
+    *:)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+        ;;
+    x:*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+        ;;
+    *)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
@@ -2186,17 +2298,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_OBJDUMP])dnl
 m4_require([_LT_DECL_SED])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
 	[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -2212,28 +2325,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -2247,7 +2367,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+      $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -2256,7 +2376,7 @@ fi])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -2273,14 +2393,17 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[[4-9]]*)
@@ -2288,41 +2411,91 @@ aix[[4-9]]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[[01]] | aix4.[[01]].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a[(]lib.so.V[)]'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -2332,18 +2505,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -2351,8 +2524,8 @@ beos*)
 bsdi[[45]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2364,7 +2537,7 @@ bsdi[[45]]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -2373,8 +2546,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -2390,17 +2563,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -2409,8 +2582,8 @@ m4_if([$1], [],[
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -2437,7 +2610,7 @@ m4_if([$1], [],[
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -2450,8 +2623,8 @@ m4_if([$1], [],[
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -2464,7 +2637,7 @@ m4_if([$1], [],[
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -2477,8 +2650,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2491,8 +2664,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2510,12 +2683,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -2545,10 +2719,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -2566,14 +2740,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -2581,8 +2756,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -2591,8 +2766,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -2605,8 +2780,8 @@ interix[[3-9]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2617,7 +2792,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -2625,8 +2800,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -2645,8 +2820,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -2655,13 +2830,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2686,7 +2881,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -2718,12 +2918,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -2733,7 +2933,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -2742,58 +2942,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -2804,8 +3014,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -2815,11 +3025,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -2827,8 +3037,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -2849,24 +3059,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2884,7 +3094,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -2892,8 +3102,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2902,20 +3112,30 @@ uts4*)
   ;;
 esac
 AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
 _LT_DECL([], [variables_saved_for_relink], [1],
     [Variables whose values should be saved in libtool wrapper scripts and
     restored at link time])
@@ -2948,39 +3168,41 @@ _LT_DECL([], [hardcode_into_libs], [0],
     [Whether we should hardcode library paths into libraries])
 _LT_DECL([], [sys_lib_search_path_spec], [2],
     [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+    [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+    [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
 ])# _LT_SYS_DYNAMIC_LINKER
 
 
 # _LT_PATH_TOOL_PREFIX(TOOL)
 # --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
 [m4_require([_LT_DECL_EGREP])dnl
 AC_MSG_CHECKING([for $1])
 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
 [case $MAGIC_CMD in
 [[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
 dnl $ac_dummy forces splitting on constant user-supplied paths.
 dnl POSIX.2 word splitting is done only on the output of word expansions,
 dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="m4_if([$2], , $PATH, [$2])"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+    if test -f "$ac_dir/$1"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -3003,11 +3225,11 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   AC_MSG_RESULT($MAGIC_CMD)
 else
@@ -3025,7 +3247,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
 
 # _LT_PATH_MAGIC
 # --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
 m4_defun([_LT_PATH_MAGIC],
 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -3052,16 +3274,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
 AC_ARG_WITH([gnu-ld],
     [AS_HELP_STRING([--with-gnu-ld],
 	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
+    [test no = "$withval" || with_gnu_ld=yes],
     [with_gnu_ld=no])dnl
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   AC_MSG_CHECKING([for ld used by $CC])
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -3075,7 +3297,7 @@ if test "$GCC" = yes; then
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -3086,37 +3308,37 @@ if test "$GCC" = yes; then
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   AC_MSG_CHECKING([for GNU ld])
 else
   AC_MSG_CHECKING([for non-GNU ld])
 fi
 AC_CACHE_VAL(lt_cv_path_LD,
 [if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi])
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   AC_MSG_RESULT($LD)
 else
@@ -3170,13 +3392,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -3187,6 +3409,43 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl
 ])# _LT_CMD_RELOAD
 
 
+# _LT_PATH_DD
+# -----------
+# find a working dd
+m4_defun([_LT_PATH_DD],
+[AC_CACHE_CHECK([for a working dd], [ac_cv_path_lt_DD],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+  [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
 # _LT_CHECK_MAGIC_METHOD
 # ----------------------
 # how to check for library dependencies
@@ -3202,13 +3461,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[[4-9]]*)
@@ -3235,8 +3494,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -3332,8 +3590,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3386,6 +3644,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 ])
 
@@ -3426,33 +3687,38 @@ AC_DEFUN([LT_PATH_NM],
 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
 [if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3463,21 +3729,21 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
     # Let the user override the test.
   else
     AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -3485,8 +3751,8 @@ else
     esac
   fi
   AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -3532,8 +3798,8 @@ lt_cv_sharedlib_from_linklib_cmd,
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -3545,7 +3811,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 ])
@@ -3572,13 +3838,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool
     lt_cv_path_mainfest_tool=yes
   fi
   rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
 ])# _LT_PATH_MANIFEST_TOOL
 
 
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+  test DEF = "`$SED -n dnl
+    -e '\''s/^[[	 ]]*//'\'' dnl Strip leading whitespace
+    -e '\''/^\(;.*\)*$/d'\'' dnl      Delete empty lines and comments
+    -e '\''s/^\(EXPORTS\|LIBRARY\)\([[	 ]].*\)*$/DEF/p'\'' dnl
+    -e q dnl                          Only consider the first "real" line
+    $1`" dnl
+])# _LT_DLL_DEF_P
+
+
 # LT_LIB_M
 # --------
 # check for math library
@@ -3590,11 +3871,11 @@ case $host in
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
   AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
   ;;
 *)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  AC_CHECK_LIB(m, cos, LIBM=-lm)
   ;;
 esac
 AC_SUBST([LIBM])
@@ -3613,7 +3894,7 @@ m4_defun([_LT_COMPILER_NO_RTTI],
 
 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
@@ -3665,7 +3946,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[[ABCDGISTW]]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[[ABCDEGRST]]'
   fi
   ;;
@@ -3698,14 +3979,44 @@ case `$NM -V 2>&1` in
   symcode='[[ABCDGIRSTW]]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -3723,21 +4034,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK ['"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx]"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -3777,11 +4091,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT@&t at _DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT@&t at _DLSYM_CONST
 #else
@@ -3807,7 +4121,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -3827,9 +4141,9 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	  if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -3850,7 +4164,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -3877,12 +4191,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
     [Take the output of nm and produce a listing of raw symbols and C names])
 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
     [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+    [Transform the output of nm into a list of symbols to manually relocate])
 _LT_DECL([global_symbol_to_c_name_address],
     [lt_cv_sys_global_symbol_to_c_name_address], [1],
     [Transform the output of nm in a C name address pair])
 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
     [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
     [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+    [The name lister interface])
 _LT_DECL([], [nm_file_list_spec], [1],
     [Specify filename containing input files for $NM])
 ]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3898,17 +4216,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)=
 
 m4_if([$1], [CXX], [
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -3919,8 +4238,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -3936,6 +4255,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -3985,7 +4309,7 @@ m4_if([$1], [CXX], [
     case $host_os in
       aix[[4-9]]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	else
@@ -4026,14 +4350,14 @@ m4_if([$1], [CXX], [
 	case $cc_basename in
 	  CC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -4070,7 +4394,7 @@ m4_if([$1], [CXX], [
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -4215,17 +4539,18 @@ m4_if([$1], [CXX], [
   fi
 ],
 [
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -4236,8 +4561,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -4254,6 +4579,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -4324,7 +4654,7 @@ m4_if([$1], [CXX], [
     case $host_os in
     aix*)
       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       else
@@ -4332,11 +4662,30 @@ m4_if([$1], [CXX], [
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -4352,7 +4701,7 @@ m4_if([$1], [CXX], [
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -4363,7 +4712,7 @@ m4_if([$1], [CXX], [
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -4388,6 +4737,12 @@ m4_if([$1], [CXX], [
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -4485,7 +4840,7 @@ m4_if([$1], [CXX], [
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
@@ -4514,7 +4869,7 @@ m4_if([$1], [CXX], [
   fi
 ])
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_TAGVAR(lt_prog_compiler_pic, $1)=
     ;;
@@ -4580,17 +4935,21 @@ m4_if([$1], [CXX], [
   case $host_os in
   aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+    _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -4639,9 +4998,9 @@ m4_if([$1], [CXX], [
   # included in the symbol list
   _LT_TAGVAR(include_expsyms, $1)=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4657,7 +5016,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -4665,7 +5024,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
   linux* | k*bsd*-gnu | gnu*)
@@ -4678,7 +5037,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -4700,24 +5059,24 @@ dnl Note also adjust exclude_expsyms for C++ above.
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       _LT_TAGVAR(whole_archive_flag_spec, $1)=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -4730,7 +5089,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     case $host_os in
     aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
@@ -4749,7 +5108,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -4765,7 +5124,7 @@ _LT_EOF
 	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4775,7 +5134,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_TAGVAR(always_export_symbols, $1)=no
       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -4783,61 +5142,89 @@ _LT_EOF
       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
     haiku*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
     interix[[3-9]]*)
       _LT_TAGVAR(hardcode_direct, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -4848,42 +5235,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -4897,8 +5289,8 @@ _LT_EOF
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -4916,8 +5308,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4929,7 +5321,7 @@ _LT_EOF
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -4944,9 +5336,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -4963,15 +5355,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
     esac
 
-    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+    if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
       runpath_var=
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
       _LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4987,7 +5379,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4995,34 +5387,57 @@ _LT_EOF
       ;;
 
     aix[[4-9]]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -5041,13 +5456,21 @@ _LT_EOF
       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+      _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[[012]]|aix4.[[012]].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -5066,62 +5489,80 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       _LT_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
         _LT_SYS_MODULE_PATH_AIX([$1])
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
 	 _LT_SYS_MODULE_PATH_AIX([$1])
-	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  fi
 	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 3 [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -5130,7 +5571,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -5160,16 +5601,17 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -5178,18 +5620,18 @@ _LT_EOF
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -5198,7 +5640,7 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -5248,33 +5690,33 @@ _LT_EOF
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_direct, $1)=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5282,25 +5724,25 @@ _LT_EOF
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 	m4_if($1, [], [
@@ -5308,14 +5750,14 @@ _LT_EOF
 	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 	  _LT_LINKER_OPTION([if $CC understands -b],
 	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
 	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	case $host_cpu in
@@ -5326,7 +5768,7 @@ _LT_EOF
 	*)
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -5337,16 +5779,16 @@ _LT_EOF
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
 	# This should be the same for all languages, so no per-tag cache variable.
 	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
 	  [lt_cv_irix_exported_symbol],
-	  [save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	  [save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   AC_LINK_IFELSE(
 	     [AC_LANG_SOURCE(
 	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
@@ -5359,21 +5801,32 @@ _LT_EOF
       end]])])],
 	      [lt_cv_irix_exported_symbol=yes],
 	      [lt_cv_irix_exported_symbol=no])
-           LDFLAGS="$save_LDFLAGS"])
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+           LDFLAGS=$save_LDFLAGS])
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
+	_LT_TAGVAR(link_all_deplibs, $1)=no
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(inherit_rpath, $1)=yes
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
     netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -5388,7 +5841,7 @@ _LT_EOF
     newsos6)
       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
@@ -5396,27 +5849,19 @@ _LT_EOF
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	     ;;
-	   *)
-	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	fi
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5427,33 +5872,53 @@ _LT_EOF
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5464,24 +5929,24 @@ _LT_EOF
 
     solaris*)
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -5491,11 +5956,11 @@ _LT_EOF
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	fi
@@ -5505,10 +5970,10 @@ _LT_EOF
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -5557,43 +6022,43 @@ _LT_EOF
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -5608,17 +6073,17 @@ _LT_EOF
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
 	;;
       esac
     fi
   fi
 ])
 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
 
@@ -5635,7 +6100,7 @@ x|xyes)
   # Assume -lc should be added
   _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $_LT_TAGVAR(archive_cmds, $1) in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -5715,12 +6180,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
     [Whether we need a single "-rpath" flag with a separated argument])
 _LT_TAGDECL([], [hardcode_direct], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary])
 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary and the resulting library dependency is
-    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    "absolute", i.e impossible to change by setting $shlibpath_var if the
     library is relocated])
 _LT_TAGDECL([], [hardcode_minus_L], [0],
     [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5761,10 +6226,10 @@ dnl    [Compiler flag to generate thread safe objects])
 # ------------------------
 # Ensure that the configuration variables for a C compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_C_CONFIG],
 [m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
 AC_LANG_PUSH(C)
 
 # Source file extension for C test sources.
@@ -5800,18 +6265,18 @@ if test -n "$compiler"; then
   LT_SYS_DLOPEN_SELF
   _LT_CMD_STRIPLIB
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   AC_MSG_CHECKING([if libtool supports shared libraries])
   AC_MSG_RESULT([$can_build_shared])
 
   AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -5819,8 +6284,12 @@ if test -n "$compiler"; then
     ;;
 
   aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -5828,13 +6297,13 @@ if test -n "$compiler"; then
 
   AC_MSG_CHECKING([whether to build static libraries])
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   AC_MSG_RESULT([$enable_static])
 
   _LT_CONFIG($1)
 fi
 AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
 ])# _LT_LANG_C_CONFIG
 
 
@@ -5842,14 +6311,14 @@ CC="$lt_save_CC"
 # --------------------------
 # Ensure that the configuration variables for a C++ compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_CXX_CONFIG],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
 m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   AC_PROG_CXXCPP
 else
   _lt_caught_CXX_error=yes
@@ -5891,7 +6360,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -5933,35 +6402,35 @@ if test "$_lt_caught_CXX_error" != yes; then
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
     else
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
       LT_PATH_LD
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           _LT_TAGVAR(whole_archive_flag_spec, $1)=
         fi
@@ -5997,18 +6466,30 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
       aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -6018,6 +6499,13 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -6036,13 +6524,21 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+        _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          _LT_TAGVAR(hardcode_direct, $1)=no
+          _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[[012]]|aix4.[[012]].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -6060,64 +6556,84 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
           _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
 	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	    fi
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -6127,7 +6643,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  _LT_TAGVAR(ld_shlibs, $1)=no
 	fi
@@ -6155,57 +6671,58 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 	  # Don't use ranlib
 	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  _LT_TAGVAR(always_export_symbols, $1)=no
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -6216,6 +6733,34 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_DARWIN_LINKER_FEATURES($1)
 	;;
 
+      os2*)
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	shrext_cmds=.dll
+	_LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -6251,14 +6796,14 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
         ;;
 
       hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
         _LT_TAGVAR(hardcode_direct, $1)=yes
         _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
 				             # but as the default
@@ -6270,7 +6815,7 @@ if test "$_lt_caught_CXX_error" != yes; then
             _LT_TAGVAR(ld_shlibs, $1)=no
             ;;
           aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -6279,11 +6824,11 @@ if test "$_lt_caught_CXX_error" != yes; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               _LT_TAGVAR(ld_shlibs, $1)=no
@@ -6293,15 +6838,15 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
               ;;
           esac
         fi
@@ -6327,13 +6872,13 @@ if test "$_lt_caught_CXX_error" != yes; then
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -6344,20 +6889,20 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -6372,22 +6917,22 @@ if test "$_lt_caught_CXX_error" != yes; then
       interix[[3-9]]*)
 	_LT_TAGVAR(hardcode_direct, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -6396,17 +6941,17 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    _LT_TAGVAR(link_all_deplibs, $1)=yes
 	    ;;
         esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         _LT_TAGVAR(inherit_rpath, $1)=yes
         ;;
@@ -6419,8 +6964,8 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -6429,10 +6974,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -6446,59 +6991,59 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
 	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6512,18 +7057,18 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -6531,10 +7076,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      _LT_TAGVAR(compiler_needs_object, $1)=yes
 
 	      # Not sure whether something based on
@@ -6592,22 +7137,17 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -6623,9 +7163,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	    # Archives containing C++ object files must be created using
@@ -6643,17 +7183,17 @@ if test "$_lt_caught_CXX_error" != yes; then
           cxx*)
 	    case $host in
 	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
 		;;
 	    esac
@@ -6668,21 +7208,21 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -6728,9 +7268,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # Sun C++ 4.2, 5.x and Centerline C++
             _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
 	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6738,7 +7278,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -6755,30 +7295,30 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -6786,11 +7326,11 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -6799,52 +7339,52 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
 	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
 	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
+              '"$_LT_TAGVAR(old_archive_cmds, $1)"
 	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
+              '"$_LT_TAGVAR(reload_cmds, $1)"
 	    ;;
 	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -6875,10 +7415,10 @@ if test "$_lt_caught_CXX_error" != yes; then
     esac
 
     AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+    test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
-    _LT_TAGVAR(GCC, $1)="$GXX"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$GXX
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -6905,7 +7445,7 @@ if test "$_lt_caught_CXX_error" != yes; then
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 AC_LANG_POP
 ])# _LT_LANG_CXX_CONFIG
@@ -6927,13 +7467,14 @@ AC_REQUIRE([_LT_DECL_SED])
 AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case @S|@2 in
+  .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
   esac
 } # func_stripname_cnf
 ])# _LT_FUNC_STRIPNAME_CNF
 
+
 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
 # ---------------------------------
 # Figure out "hidden" library dependencies from verbose
@@ -7017,13 +7558,13 @@ if AC_TRY_EVAL(ac_compile); then
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -7039,16 +7580,16 @@ if AC_TRY_EVAL(ac_compile); then
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
 	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -7056,9 +7597,9 @@ if AC_TRY_EVAL(ac_compile); then
 	 esac
        else
 	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)=$prev$p
 	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
 	 fi
        fi
        prev=
@@ -7073,15 +7614,15 @@ if AC_TRY_EVAL(ac_compile); then
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
+	   _LT_TAGVAR(predep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
 	 fi
        else
 	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	   _LT_TAGVAR(postdep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
 	 fi
@@ -7112,51 +7653,6 @@ interix[[3-9]]*)
   _LT_TAGVAR(postdep_objects,$1)=
   _LT_TAGVAR(postdeps,$1)=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 ])
 
@@ -7165,7 +7661,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in
 esac
  _LT_TAGVAR(compiler_lib_search_dirs, $1)=
 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
     [The directories searched by this compiler when creating a shared library])
@@ -7185,10 +7681,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1],
 # --------------------------
 # Ensure that the configuration variables for a Fortran 77 compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_F77_CONFIG],
 [AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
+if test -z "$F77" || test no = "$F77"; then
   _lt_disable_F77=yes
 fi
 
@@ -7225,7 +7721,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the F77 compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7247,7 +7743,7 @@ if test "$_lt_disable_F77" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${F77-"f77"}
@@ -7261,21 +7757,25 @@ if test "$_lt_disable_F77" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7283,11 +7783,11 @@ if test "$_lt_disable_F77" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$G77
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7304,9 +7804,9 @@ if test "$_lt_disable_F77" != yes; then
   fi # test -n "$compiler"
 
   GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
 
 AC_LANG_POP
 ])# _LT_LANG_F77_CONFIG
@@ -7316,11 +7816,11 @@ AC_LANG_POP
 # -------------------------
 # Ensure that the configuration variables for a Fortran compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_FC_CONFIG],
 [AC_LANG_PUSH(Fortran)
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
+if test -z "$FC" || test no = "$FC"; then
   _lt_disable_FC=yes
 fi
 
@@ -7357,7 +7857,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the FC compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7379,7 +7879,7 @@ if test "$_lt_disable_FC" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${FC-"f95"}
@@ -7395,21 +7895,25 @@ if test "$_lt_disable_FC" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7417,11 +7921,11 @@ if test "$_lt_disable_FC" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7441,7 +7945,7 @@ if test "$_lt_disable_FC" != yes; then
   GCC=$lt_save_GCC
   CC=$lt_save_CC
   CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+fi # test yes != "$_lt_disable_FC"
 
 AC_LANG_POP
 ])# _LT_LANG_FC_CONFIG
@@ -7451,7 +7955,7 @@ AC_LANG_POP
 # --------------------------
 # Ensure that the configuration variables for the GNU Java Compiler compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GCJ_CONFIG],
 [AC_REQUIRE([LT_PROG_GCJ])dnl
 AC_LANG_SAVE
@@ -7485,7 +7989,7 @@ CC=${GCJ-"gcj"}
 CFLAGS=$GCJFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
@@ -7518,7 +8022,7 @@ CFLAGS=$lt_save_CFLAGS
 # --------------------------
 # Ensure that the configuration variables for the GNU Go compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GO_CONFIG],
 [AC_REQUIRE([LT_PROG_GO])dnl
 AC_LANG_SAVE
@@ -7552,7 +8056,7 @@ CC=${GOC-"gccgo"}
 CFLAGS=$GOFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # Go did not exist at the time GCC didn't implicitly link libc in.
@@ -7585,7 +8089,7 @@ CFLAGS=$lt_save_CFLAGS
 # -------------------------
 # Ensure that the configuration variables for the Windows resource compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_RC_CONFIG],
 [AC_REQUIRE([LT_PROG_RC])dnl
 AC_LANG_SAVE
@@ -7601,7 +8105,7 @@ _LT_TAGVAR(objext, $1)=$objext
 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
 
 # Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
@@ -7611,7 +8115,7 @@ _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
 # Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
 lt_save_GCC=$GCC
 GCC=
@@ -7640,7 +8144,7 @@ AC_DEFUN([LT_PROG_GCJ],
 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
   [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
     [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
       AC_SUBST(GCJFLAGS)])])[]dnl
 ])
 
@@ -7749,7 +8253,7 @@ lt_ac_count=0
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f "$lt_ac_sed" && continue
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7766,9 +8270,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
     $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
     cmp -s conftest.out conftest.nl || break
     # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
+    test 10 -lt "$lt_ac_count" && break
     lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
+    if test "$lt_ac_count" -gt "$lt_ac_max"; then
       lt_ac_max=$lt_ac_count
       lt_cv_path_SED=$lt_ac_sed
     fi
@@ -7792,27 +8296,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], [])
 # Find out whether the shell is Bourne or XSI compatible,
 # or has some other useful features.
 m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
   lt_unset=false
@@ -7836,102 +8320,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
 ])# _LT_CHECK_SHELL_FEATURES
 
 
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
-
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
-
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
 # _LT_PATH_CONVERSION_FUNCTIONS
 # -----------------------------
-# Determine which file name conversion functions should be used by
+# Determine what file name conversion functions should be used by
 # func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
 # for certain cross-compile configurations and native mingw.
 m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
@@ -7998,15 +8389,15 @@ _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
 
 # Helper functions for option handling.                    -*- Autoconf -*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
+#   Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 7 ltoptions.m4
+# serial 8 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -8027,7 +8418,7 @@ m4_define([_LT_SET_OPTION],
 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
+    [m4_warning([Unknown $1 option '$2'])])[]dnl
 ])
 
 
@@ -8073,13 +8464,15 @@ m4_if([$1],[LT_INIT],[
   dnl
   dnl If no reference was made to various pairs of opposing options, then
   dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
   dnl archives by default:
   _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
   _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
+		   [_LT_ENABLE_FAST_INSTALL])
+  _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+		   [_LT_WITH_AIX_SONAME([aix])])
   ])
 ])# _LT_SET_OPTIONS
 
@@ -8107,7 +8500,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
 [_LT_SET_OPTION([LT_INIT], [dlopen])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -8143,7 +8536,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 _LT_SET_OPTION([LT_INIT], [win32-dll])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -8152,9 +8545,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
 # _LT_ENABLE_SHARED([DEFAULT])
 # ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_SHARED],
 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([shared],
@@ -8167,14 +8560,14 @@ AC_ARG_ENABLE([shared],
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -8206,9 +8599,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
 # _LT_ENABLE_STATIC([DEFAULT])
 # ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_STATIC],
 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([static],
@@ -8221,14 +8614,14 @@ AC_ARG_ENABLE([static],
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -8260,9 +8653,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
 # ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_FAST_INSTALL],
 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([fast-install],
@@ -8275,14 +8668,14 @@ AC_ARG_ENABLE([fast-install],
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -8299,14 +8692,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
 ])
 
 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -8314,11 +8707,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
 
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'.  If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+  AC_MSG_CHECKING([which variant of shared library versioning to provide])
+  AC_ARG_WITH([aix-soname],
+    [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+      [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+    [case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname],
+    [AC_CACHE_VAL([lt_cv_with_aix_soname],
+      [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+    with_aix_soname=$lt_cv_with_aix_soname])
+  AC_MSG_RESULT([$with_aix_soname])
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+    [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'.  If omitted, it defaults to 'both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
     [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@@ -8329,19 +8775,17 @@ m4_define([_LT_WITH_PIC],
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+    [pic_mode=m4_default([$1], [default])])
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
@@ -8354,7 +8798,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
 [_LT_SET_OPTION([LT_INIT], [pic-only])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -8377,7 +8821,8 @@ LT_OPTION_DEFINE([LTDL_INIT], [convenience],
 
 # ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
 #
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
 # Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -8410,7 +8855,7 @@ m4_define([_lt_join],
 # ------------
 # Manipulate m4 lists.
 # These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
 m4_define([lt_car], [[$1]])
 m4_define([lt_cdr],
 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -8421,7 +8866,7 @@ m4_define([lt_unquote], $1)
 
 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
 # ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
 # Note that neither SEPARATOR nor STRING are expanded; they are appended
 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
@@ -8501,7 +8946,7 @@ m4_define([lt_dict_filter],
 
 # ltversion.m4 -- version numbers			-*- Autoconf -*-
 #
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
 #   Written by Scott James Remnant, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -8510,22 +8955,23 @@ m4_define([lt_dict_filter],
 
 # @configure_input@
 
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])
 
 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
@@ -8536,7 +8982,7 @@ _LT_DECL(, macro_revision, 0)
 
 # These exist entirely to fool aclocal when bootstrapping libtool.
 #
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
 # which have later been changed to m4_define as they aren't part of the
 # exported API, or moved to Autoconf or Automake where they belong.
 #
@@ -8550,7 +8996,7 @@ _LT_DECL(, macro_revision, 0)
 # included after everything else.  This provides aclocal with the
 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
 # because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
 #
 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
 # Yes, that means every name once taken will need to remain here until
@@ -8622,7 +9068,7 @@ m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
 m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
 m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
 
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -8634,10 +9080,10 @@ m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.14'
+[am__api_version='1.15'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.14.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -8653,14 +9099,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.14.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -8705,15 +9151,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 # configured tree to be moved without reconfiguration.
 
 AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 ])
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -8744,7 +9189,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -8935,7 +9380,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9011,7 +9456,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9101,8 +9546,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@@ -9175,7 +9620,11 @@ to "yes", and re-run configure.
 END
     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   fi
-fi])
+fi
+dnl The trailing newline in this macro's definition is deliberate, for
+dnl backward compatibility and to allow trailing 'dnl'-style comments
+dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
+])
 
 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
@@ -9204,7 +9653,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9215,7 +9664,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -9225,7 +9674,7 @@ if test x"${install_sh}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9246,7 +9695,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9296,7 +9745,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9335,7 +9784,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9364,7 +9813,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9411,7 +9860,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9646,7 +10095,7 @@ for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
 sys.exit(sys.hexversion < minverhex)"
   AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9665,7 +10114,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9746,7 +10195,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9806,7 +10255,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9834,7 +10283,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -9853,7 +10302,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/src/gmock/build-aux/compile b/src/gmock/build-aux/compile
index 531136b..a85b723 100755
--- a/src/gmock/build-aux/compile
+++ b/src/gmock/build-aux/compile
@@ -3,7 +3,7 @@
 
 scriptversion=2012-10-14.11; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/src/gmock/build-aux/config.guess b/src/gmock/build-aux/config.guess
index b79252d..1659250 100755
--- a/src/gmock/build-aux/config.guess
+++ b/src/gmock/build-aux/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2013 Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2013-06-10'
+timestamp='2015-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -24,12 +24,12 @@ timestamp='2013-06-10'
 # program.  This Exception is an additional permission under section 7
 # of the GNU General Public License, version 3 ("GPLv3").
 #
-# Originally written by Per Bothner.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 #
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 
 
 me=`echo "$0" | sed -e 's,.*/,,'`
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -149,7 +149,7 @@ Linux|GNU|GNU/*)
 	LIBC=gnu
 	#endif
 	EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
 	;;
 esac
 
@@ -168,20 +168,27 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
 	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+	    /sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || \
+	    echo unknown)`
 	case "${UNAME_MACHINE_ARCH}" in
 	    armeb) machine=armeb-unknown ;;
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
 	    sh3eb) machine=sh-unknown ;;
 	    sh5el) machine=sh5le-unknown ;;
+	    earmv*)
+		arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+		endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
+		machine=${arch}${endian}-unknown
+		;;
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently, or will in the future.
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
@@ -197,6 +204,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		os=netbsd
 		;;
 	esac
+	# Determine ABI tags.
+	case "${UNAME_MACHINE_ARCH}" in
+	    earm*)
+		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+		abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+		;;
+	esac
 	# The OS release
 	# Debian GNU/NetBSD machines have a different userland, and
 	# thus, need a distinct triplet. However, they do not need
@@ -207,13 +221,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		release='-gnu'
 		;;
 	    *)
-		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
 		;;
 	esac
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "${machine}-${os}${release}"
+	echo "${machine}-${os}${release}${abi}"
 	exit ;;
     *:Bitrig:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
@@ -235,6 +249,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:MirBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
+    *:Sortix:*:*)
+	echo ${UNAME_MACHINE}-unknown-sortix
+	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	*4.0)
@@ -579,8 +596,9 @@ EOF
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
+	if [ -x /usr/bin/lslpp ] ; then
+		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
@@ -826,7 +844,7 @@ EOF
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
-    i*:MSYS*:*)
+    *:MSYS*:*)
 	echo ${UNAME_MACHINE}-pc-msys
 	exit ;;
     i*:windows32*:*)
@@ -932,6 +950,9 @@ EOF
     crisv32:Linux:*:*)
 	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
+    e2k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     frv:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
@@ -969,10 +990,10 @@ EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
-    or1k:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+    openrisc*:Linux:*:*)
+	echo or1k-unknown-linux-${LIBC}
 	exit ;;
-    or32:Linux:*:*)
+    or32:Linux:*:* | or1k*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     padre:Linux:*:*)
@@ -1020,7 +1041,7 @@ EOF
 	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
     xtensa*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
@@ -1260,16 +1281,26 @@ EOF
 	if test "$UNAME_PROCESSOR" = unknown ; then
 	    UNAME_PROCESSOR=powerpc
 	fi
-	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		grep IS_64BIT_ARCH >/dev/null
-	    then
-		case $UNAME_PROCESSOR in
-		    i386) UNAME_PROCESSOR=x86_64 ;;
-		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
-		esac
+	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+	    if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		    (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		    grep IS_64BIT_ARCH >/dev/null
+		then
+		    case $UNAME_PROCESSOR in
+			i386) UNAME_PROCESSOR=x86_64 ;;
+			powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		    esac
+		fi
 	    fi
+	elif test "$UNAME_PROCESSOR" = i386 ; then
+	    # Avoid executing cc on OS X 10.9, as it ships with a stub
+	    # that puts up a graphical alert prompting to install
+	    # developer tools.  Any system running Mac OS X 10.7 or
+	    # later (Darwin 11 and later) is required to have a 64-bit
+	    # processor. This is not true of the ARM version of Darwin
+	    # that Apple uses in portable devices.
+	    UNAME_PROCESSOR=x86_64
 	fi
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
@@ -1361,154 +1392,6 @@ EOF
 	exit ;;
 esac
 
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-	"4"
-#else
-	""
-#endif
-	); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-	printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-	printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-	{ echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-	echo c1-convex-bsd
-	exit ;;
-    c2*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-	exit ;;
-    c34*)
-	echo c34-convex-bsd
-	exit ;;
-    c38*)
-	echo c38-convex-bsd
-	exit ;;
-    c4*)
-	echo c4-convex-bsd
-	exit ;;
-    esac
-fi
-
 cat >&2 <<EOF
 $0: unable to guess system type
 
diff --git a/src/gmock/build-aux/config.h.in b/src/gmock/build-aux/config.h.in
index 843b5b1..6ea2e69 100644
--- a/src/gmock/build-aux/config.h.in
+++ b/src/gmock/build-aux/config.h.in
@@ -33,8 +33,7 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Name of package */
diff --git a/src/gmock/build-aux/config.sub b/src/gmock/build-aux/config.sub
index 9633db7..1acc966 100755
--- a/src/gmock/build-aux/config.sub
+++ b/src/gmock/build-aux/config.sub
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2013 Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2013-08-10'
+timestamp='2015-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ timestamp='2013-08-10'
 # of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -68,7 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -117,7 +117,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
@@ -255,16 +255,18 @@ case $basic_machine in
 	| arc | arceb \
 	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
 	| avr | avr32 \
+	| ba \
 	| be32 | be64 \
 	| bfin \
 	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
-	| epiphany \
-	| fido | fr30 | frv \
+	| e2k | epiphany \
+	| fido | fr30 | frv | ft32 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| k1om \
 	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
@@ -282,8 +284,10 @@ case $basic_machine in
 	| mips64vr5900 | mips64vr5900el \
 	| mipsisa32 | mipsisa32el \
 	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa32r6 | mipsisa32r6el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64r6 | mipsisa64r6el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipsr5900 | mipsr5900el \
@@ -295,14 +299,14 @@ case $basic_machine in
 	| nds32 | nds32le | nds32be \
 	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
-	| open8 \
-	| or1k | or32 \
+	| open8 | or1k | or1knd | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
+	| riscv32 | riscv64 \
 	| rl78 | rx \
 	| score \
-	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -310,6 +314,7 @@ case $basic_machine in
 	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
 	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+	| visium \
 	| we32k \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
@@ -324,7 +329,10 @@ case $basic_machine in
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+	leon|leon[3-9])
+		basic_machine=sparc-$basic_machine
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -369,18 +377,20 @@ case $basic_machine in
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| ba-* \
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| c8051-* | clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
-	| elxsi-* \
+	| e2k-* | elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| k1om-* \
 	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
@@ -400,8 +410,10 @@ case $basic_machine in
 	| mips64vr5900-* | mips64vr5900el-* \
 	| mipsisa32-* | mipsisa32el-* \
 	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa32r6-* | mipsisa32r6el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64r6-* | mipsisa64r6el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipsr5900-* | mipsr5900el-* \
@@ -413,16 +425,18 @@ case $basic_machine in
 	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
+	| or1k*-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
+	| riscv32-* | riscv64-* \
 	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
 	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tile*-* \
@@ -430,6 +444,7 @@ case $basic_machine in
 	| ubicom32-* \
 	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
 	| vax-* \
+	| visium-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -506,6 +521,9 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-aros
 		;;
+        asmjs)
+		basic_machine=asmjs-unknown
+		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
@@ -767,6 +785,9 @@ case $basic_machine in
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	leon-*|leon[3-9]-*)
+		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
@@ -822,6 +843,10 @@ case $basic_machine in
 		basic_machine=powerpc-unknown
 		os=-morphos
 		;;
+	moxiebox)
+		basic_machine=moxie-unknown
+		os=-moxiebox
+		;;
 	msdos)
 		basic_machine=i386-pc
 		os=-msdos
@@ -1354,7 +1379,7 @@ case $os in
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* | -aros* \
+	      | -aos* | -aros* | -cloudabi* | -sortix* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
@@ -1367,14 +1392,14 @@ case $os in
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1592,9 +1617,6 @@ case $basic_machine in
 	mips*-*)
 		os=-elf
 		;;
-	or1k-*)
-		os=-elf
-		;;
 	or32-*)
 		os=-coff
 		;;
diff --git a/src/gmock/build-aux/depcomp b/src/gmock/build-aux/depcomp
index 4ebd5b3..fc98710 100755
--- a/src/gmock/build-aux/depcomp
+++ b/src/gmock/build-aux/depcomp
@@ -3,7 +3,7 @@
 
 scriptversion=2013-05-30.07; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/gmock/build-aux/install-sh b/src/gmock/build-aux/install-sh
index 377bb86..59990a1 100755
--- a/src/gmock/build-aux/install-sh
+++ b/src/gmock/build-aux/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2011-11-20.07; # UTC
+scriptversion=2014-09-12.12; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
 # This script is compatible with the BSD install script, but was written
 # from scratch.
 
+tab='	'
 nl='
 '
-IFS=" ""	$nl"
+IFS=" $tab$nl"
 
-# set DOITPROG to echo to test this script
+# Set DOITPROG to "echo" to test this script.
 
-# Don't use :- since 4.3BSD and earlier shells don't like it.
 doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
+doit_exec=${doit:-exec}
 
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
 rmprog=${RMPROG-rm}
 stripprog=${STRIPPROG-strip}
 
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
 posix_mkdir=
 
 # Desired mode of installed file.
@@ -97,7 +82,7 @@ dir_arg=
 dst_arg=
 
 copy_on_change=false
-no_target_directory=
+is_target_a_directory=possibly
 
 usage="\
 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -137,46 +122,57 @@ while test $# -ne 0; do
     -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-	shift;;
+        shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-	case $mode in
-	  *' '* | *'	'* | *'
-'*	  | *'*'* | *'?'* | *'['*)
-	    echo "$0: invalid mode: $mode" >&2
-	    exit 1;;
-	esac
-	shift;;
+        case $mode in
+          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+            echo "$0: invalid mode: $mode" >&2
+            exit 1;;
+        esac
+        shift;;
 
     -o) chowncmd="$chownprog $2"
-	shift;;
+        shift;;
 
     -s) stripcmd=$stripprog;;
 
-    -t) dst_arg=$2
-	# Protect names problematic for 'test' and other utilities.
-	case $dst_arg in
-	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
-	esac
-	shift;;
+    -t)
+        is_target_a_directory=always
+        dst_arg=$2
+        # Protect names problematic for 'test' and other utilities.
+        case $dst_arg in
+          -* | [=\(\)!]) dst_arg=./$dst_arg;;
+        esac
+        shift;;
 
-    -T) no_target_directory=true;;
+    -T) is_target_a_directory=never;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    --)	shift
-	break;;
+    --) shift
+        break;;
 
-    -*)	echo "$0: invalid option: $1" >&2
-	exit 1;;
+    -*) echo "$0: invalid option: $1" >&2
+        exit 1;;
 
     *)  break;;
   esac
   shift
 done
 
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
+
+if test -n "$dir_arg"; then
+  if test -n "$dst_arg"; then
+    echo "$0: target directory not allowed when installing a directory." >&2
+    exit 1
+  fi
+fi
+
 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
@@ -208,6 +204,15 @@ if test $# -eq 0; then
 fi
 
 if test -z "$dir_arg"; then
+  if test $# -gt 1 || test "$is_target_a_directory" = always; then
+    if test ! -d "$dst_arg"; then
+      echo "$0: $dst_arg: Is not a directory." >&2
+      exit 1
+    fi
+  fi
+fi
+
+if test -z "$dir_arg"; then
   do_exit='(exit $ret); exit $ret'
   trap "ret=129; $do_exit" 1
   trap "ret=130; $do_exit" 2
@@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
 
     *[0-7])
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw='% 200'
+        u_plus_rw='% 200'
       fi
       cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
     *)
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw=,u+rw
+        u_plus_rw=,u+rw
       fi
       cp_umask=$mode$u_plus_rw;;
   esac
@@ -269,41 +274,15 @@ do
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-	echo "$0: $dst_arg: Is a directory" >&2
-	exit 1
+      if test "$is_target_a_directory" = never; then
+        echo "$0: $dst_arg: Is a directory" >&2
+        exit 1
       fi
       dstdir=$dst
       dst=$dstdir/`basename "$src"`
       dstdir_status=0
     else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-	(dirname "$dst") 2>/dev/null ||
-	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	     X"$dst" : 'X\(//\)[^/]' \| \
-	     X"$dst" : 'X\(//\)$' \| \
-	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-	echo X"$dst" |
-	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)[^/].*/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\).*/{
-		   s//\1/
-		   q
-		 }
-		 s/.*/./; q'
-      `
-
+      dstdir=`dirname "$dst"`
       test -d "$dstdir"
       dstdir_status=$?
     fi
@@ -314,74 +293,81 @@ do
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-	# Create intermediate dirs using mode 755 as modified by the umask.
-	# This is like FreeBSD 'install' as of 1997-10-28.
-	umask=`umask`
-	case $stripcmd.$umask in
-	  # Optimize common cases.
-	  *[2367][2367]) mkdir_umask=$umask;;
-	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-	  *[0-7])
-	    mkdir_umask=`expr $umask + 22 \
-	      - $umask % 100 % 40 + $umask % 20 \
-	      - $umask % 10 % 4 + $umask % 2
-	    `;;
-	  *) mkdir_umask=$umask,go-w;;
-	esac
-
-	# With -d, create the new directory with the user-specified mode.
-	# Otherwise, rely on $mkdir_umask.
-	if test -n "$dir_arg"; then
-	  mkdir_mode=-m$mode
-	else
-	  mkdir_mode=
-	fi
-
-	posix_mkdir=false
-	case $umask in
-	  *[123567][0-7][0-7])
-	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-	    ;;
-	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-	    if (umask $mkdir_umask &&
-		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-	    then
-	      if test -z "$dir_arg" || {
-		   # Check for POSIX incompatibilities with -m.
-		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writable bit of parent directory when it shouldn't.
-		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-		   case $ls_ld_tmpdir in
-		     d????-?r-*) different_mode=700;;
-		     d????-?--*) different_mode=755;;
-		     *) false;;
-		   esac &&
-		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-		   }
-		 }
-	      then posix_mkdir=:
-	      fi
-	      rmdir "$tmpdir/d" "$tmpdir"
-	    else
-	      # Remove any dirs left behind by ancient mkdir implementations.
-	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-	    fi
-	    trap '' 0;;
-	esac;;
+        # Create intermediate dirs using mode 755 as modified by the umask.
+        # This is like FreeBSD 'install' as of 1997-10-28.
+        umask=`umask`
+        case $stripcmd.$umask in
+          # Optimize common cases.
+          *[2367][2367]) mkdir_umask=$umask;;
+          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+          *[0-7])
+            mkdir_umask=`expr $umask + 22 \
+              - $umask % 100 % 40 + $umask % 20 \
+              - $umask % 10 % 4 + $umask % 2
+            `;;
+          *) mkdir_umask=$umask,go-w;;
+        esac
+
+        # With -d, create the new directory with the user-specified mode.
+        # Otherwise, rely on $mkdir_umask.
+        if test -n "$dir_arg"; then
+          mkdir_mode=-m$mode
+        else
+          mkdir_mode=
+        fi
+
+        posix_mkdir=false
+        case $umask in
+          *[123567][0-7][0-7])
+            # POSIX mkdir -p sets u+wx bits regardless of umask, which
+            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+            ;;
+          *)
+            # $RANDOM is not portable (e.g. dash);  use it when possible to
+            # lower collision chance
+            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+            trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+            # As "mkdir -p" follows symlinks and we work in /tmp possibly;  so
+            # create the $tmpdir first (and fail if unsuccessful) to make sure
+            # that nobody tries to guess the $tmpdir name.
+            if (umask $mkdir_umask &&
+                $mkdirprog $mkdir_mode "$tmpdir" &&
+                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
+            then
+              if test -z "$dir_arg" || {
+                   # Check for POSIX incompatibilities with -m.
+                   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                   # other-writable bit of parent directory when it shouldn't.
+                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                   test_tmpdir="$tmpdir/a"
+                   ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
+                   case $ls_ld_tmpdir in
+                     d????-?r-*) different_mode=700;;
+                     d????-?--*) different_mode=755;;
+                     *) false;;
+                   esac &&
+                   $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+                     ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
+                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                   }
+                 }
+              then posix_mkdir=:
+              fi
+              rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
+            else
+              # Remove any dirs left behind by ancient mkdir implementations.
+              rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
+            fi
+            trap '' 0;;
+        esac;;
     esac
 
     if
       $posix_mkdir && (
-	umask $mkdir_umask &&
-	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+        umask $mkdir_umask &&
+        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
       )
     then :
     else
@@ -391,53 +377,51 @@ do
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-	/*) prefix='/';;
-	[-=\(\)!]*) prefix='./';;
-	*)  prefix='';;
+        /*) prefix='/';;
+        [-=\(\)!]*) prefix='./';;
+        *)  prefix='';;
       esac
 
-      eval "$initialize_posix_glob"
-
       oIFS=$IFS
       IFS=/
-      $posix_glob set -f
+      set -f
       set fnord $dstdir
       shift
-      $posix_glob set +f
+      set +f
       IFS=$oIFS
 
       prefixes=
 
       for d
       do
-	test X"$d" = X && continue
-
-	prefix=$prefix$d
-	if test -d "$prefix"; then
-	  prefixes=
-	else
-	  if $posix_mkdir; then
-	    (umask=$mkdir_umask &&
-	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-	    # Don't fail if two instances are running concurrently.
-	    test -d "$prefix" || exit 1
-	  else
-	    case $prefix in
-	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-	      *) qprefix=$prefix;;
-	    esac
-	    prefixes="$prefixes '$qprefix'"
-	  fi
-	fi
-	prefix=$prefix/
+        test X"$d" = X && continue
+
+        prefix=$prefix$d
+        if test -d "$prefix"; then
+          prefixes=
+        else
+          if $posix_mkdir; then
+            (umask=$mkdir_umask &&
+             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+            # Don't fail if two instances are running concurrently.
+            test -d "$prefix" || exit 1
+          else
+            case $prefix in
+              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+              *) qprefix=$prefix;;
+            esac
+            prefixes="$prefixes '$qprefix'"
+          fi
+        fi
+        prefix=$prefix/
       done
 
       if test -n "$prefixes"; then
-	# Don't fail if two instances are running concurrently.
-	(umask $mkdir_umask &&
-	 eval "\$doit_exec \$mkdirprog $prefixes") ||
-	  test -d "$dstdir" || exit 1
-	obsolete_mkdir_used=true
+        # Don't fail if two instances are running concurrently.
+        (umask $mkdir_umask &&
+         eval "\$doit_exec \$mkdirprog $prefixes") ||
+          test -d "$dstdir" || exit 1
+        obsolete_mkdir_used=true
       fi
     fi
   fi
@@ -472,15 +456,12 @@ do
 
     # If -C, don't bother to copy if it wouldn't change the file.
     if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
+       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
+       set -f &&
        set X $old && old=:$2:$4:$5:$6 &&
        set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
+       set +f &&
        test "$old" = "$new" &&
        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     then
@@ -493,24 +474,24 @@ do
       # to itself, or perhaps because mv is so ancient that it does not
       # support -f.
       {
-	# Now remove or move aside any old file at destination location.
-	# We try this two ways since rm can't unlink itself on some
-	# systems and the destination file might be busy for other
-	# reasons.  In this case, the final cleanup might fail but the new
-	# file should still install successfully.
-	{
-	  test ! -f "$dst" ||
-	  $doit $rmcmd -f "$dst" 2>/dev/null ||
-	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-	  } ||
-	  { echo "$0: cannot unlink or rename $dst" >&2
-	    (exit 1); exit 1
-	  }
-	} &&
-
-	# Now rename the file to the real destination.
-	$doit $mvcmd "$dsttmp" "$dst"
+        # Now remove or move aside any old file at destination location.
+        # We try this two ways since rm can't unlink itself on some
+        # systems and the destination file might be busy for other
+        # reasons.  In this case, the final cleanup might fail but the new
+        # file should still install successfully.
+        {
+          test ! -f "$dst" ||
+          $doit $rmcmd -f "$dst" 2>/dev/null ||
+          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+          } ||
+          { echo "$0: cannot unlink or rename $dst" >&2
+            (exit 1); exit 1
+          }
+        } &&
+
+        # Now rename the file to the real destination.
+        $doit $mvcmd "$dsttmp" "$dst"
       }
     fi || exit 1
 
diff --git a/src/gmock/build-aux/ltmain.sh b/src/gmock/build-aux/ltmain.sh
index a356aca..147d758 100644
--- a/src/gmock/build-aux/ltmain.sh
+++ b/src/gmock/build-aux/ltmain.sh
@@ -1,9 +1,12 @@
+#! /bin/sh
+## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
+##               by inline-source v2014-01-03.01
 
-# libtool (GNU libtool) 2.4.2
+# libtool (GNU libtool) 2.4.6
+# Provide generalized library-building support services.
 # Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2015 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -23,881 +26,2112 @@
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html,
-# or obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Usage: $progname [OPTION]... [MODE-ARG]...
-#
-# Provide generalized library-building support services.
-#
-#       --config             show all configuration variables
-#       --debug              enable verbose shell tracing
-#   -n, --dry-run            display commands without modifying any files
-#       --features           display basic configuration information and exit
-#       --mode=MODE          use operation mode MODE
-#       --preserve-dup-deps  don't remove duplicate dependency libraries
-#       --quiet, --silent    don't print informational messages
-#       --no-quiet, --no-silent
-#                            print informational messages (default)
-#       --no-warn            don't display warning messages
-#       --tag=TAG            use configuration variables from tag TAG
-#   -v, --verbose            print more informational messages than default
-#       --no-verbose         don't print the extra informational messages
-#       --version            print version information
-#   -h, --help, --help-all   print short, long, or detailed help message
-#
-# MODE must be one of the following:
-#
-#         clean              remove files from the build directory
-#         compile            compile a source file into a libtool object
-#         execute            automatically set library path, then run a program
-#         finish             complete the installation of libtool libraries
-#         install            install libraries or executables
-#         link               create a library or an executable
-#         uninstall          remove libraries from an installed directory
-#
-# MODE-ARGS vary depending on the MODE.  When passed as first option,
-# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
-# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
-#
-# When reporting a bug, please describe a test case to reproduce it and
-# include the following information:
-#
-#         host-triplet:	$host
-#         shell:		$SHELL
-#         compiler:		$LTCC
-#         compiler flags:		$LTCFLAGS
-#         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
-#         automake:	$automake_version
-#         autoconf:	$autoconf_version
-#
-# Report bugs to <bug-libtool at gnu.org>.
-# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
-# General help using GNU software: <http://www.gnu.org/gethelp/>.
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
-TIMESTAMP=""
-package_revision=1.3337
+VERSION="2.4.6 Debian-2.4.6-0.1"
+package_revision=2.4.6
 
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Run './libtool --help' for help with using this script from the
+# command line.
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# After configure completes, it has a better idea of some of the
+# shell tools we need than the defaults used by the functions shared
+# with bootstrap, so set those here where they can still be over-
+# ridden by the user, but otherwise take precedence.
+
+: ${AUTOCONF="autoconf"}
+: ${AUTOMAKE="automake"}
+
+
+## -------------------------- ##
+## Source external libraries. ##
+## -------------------------- ##
+
+# Much of our low-level functionality needs to be sourced from external
+# libraries, which are installed to $pkgauxdir.
+
+# Set a version string for this script.
+scriptversion=2015-01-20.17; # UTC
+
+# General shell script boiler plate, and helper functions.
+# Written by Gary V. Vaughan, 2004
+
+# Copyright (C) 2004-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# As a special exception to the GNU General Public License, if you distribute
+# this file as part of a program or library that is built using GNU Libtool,
+# you may include this file under the same distribution terms that you use
+# for the rest of that program.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Evaluate this file near the top of your script to gain access to
+# the functions and variables defined here:
+#
+#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
+#
+# If you need to override any of the default environment variable
+# settings, do that before evaluating this file.
+
+
+## -------------------- ##
+## Shell normalisation. ##
+## -------------------- ##
+
+# Some shells need a little help to be as Bourne compatible as possible.
+# Before doing anything else, make sure all that help has been provided!
+
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
 fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
 
-# NLS nuisances: We save the old values to restore during execute mode.
-lt_user_locale=
-lt_safe_locale=
-for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+# NLS nuisances: We save the old values in case they are required later.
+_G_user_locale=
+_G_safe_locale=
+for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
-  eval "if test \"\${$lt_var+set}\" = set; then
-          save_$lt_var=\$$lt_var
-          $lt_var=C
-	  export $lt_var
-	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
-	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+  eval "if test set = \"\${$_G_var+set}\"; then
+          save_$_G_var=\$$_G_var
+          $_G_var=C
+	  export $_G_var
+	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
+	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
 	fi"
 done
-LC_ALL=C
-LANGUAGE=C
-export LANGUAGE LC_ALL
 
-$lt_unset CDPATH
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Make sure IFS has a sensible default
+sp=' '
+nl='
+'
+IFS="$sp	$nl"
+
+# There are apparently some retarded systems that use ';' as a PATH separator!
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
 
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
 
 
+## ------------------------- ##
+## Locate command utilities. ##
+## ------------------------- ##
+
+
+# func_executable_p FILE
+# ----------------------
+# Check that FILE is an executable regular file.
+func_executable_p ()
+{
+    test -f "$1" && test -x "$1"
+}
+
+
+# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
+# --------------------------------------------
+# Search for either a program that responds to --version with output
+# containing "GNU", or else returned by CHECK_FUNC otherwise, by
+# trying all the directories in PATH with each of the elements of
+# PROGS_LIST.
+#
+# CHECK_FUNC should accept the path to a candidate program, and
+# set $func_check_prog_result if it truncates its output less than
+# $_G_path_prog_max characters.
+func_path_progs ()
+{
+    _G_progs_list=$1
+    _G_check_func=$2
+    _G_PATH=${3-"$PATH"}
+
+    _G_path_prog_max=0
+    _G_path_prog_found=false
+    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
+    for _G_dir in $_G_PATH; do
+      IFS=$_G_save_IFS
+      test -z "$_G_dir" && _G_dir=.
+      for _G_prog_name in $_G_progs_list; do
+        for _exeext in '' .EXE; do
+          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
+          func_executable_p "$_G_path_prog" || continue
+          case `"$_G_path_prog" --version 2>&1` in
+            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
+            *)     $_G_check_func $_G_path_prog
+		   func_path_progs_result=$func_check_prog_result
+		   ;;
+          esac
+          $_G_path_prog_found && break 3
+        done
+      done
+    done
+    IFS=$_G_save_IFS
+    test -z "$func_path_progs_result" && {
+      echo "no acceptable sed could be found in \$PATH" >&2
+      exit 1
+    }
+}
+
+
+# We want to be able to use the functions in this file before configure
+# has figured out where the best binaries are kept, which means we have
+# to search for them ourselves - except when the results are already set
+# where we skip the searches.
+
+# Unless the user overrides by setting SED, search the path for either GNU
+# sed, or the sed that truncates its output the least.
+test -z "$SED" && {
+  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+  for _G_i in 1 2 3 4 5 6 7; do
+    _G_sed_script=$_G_sed_script$nl$_G_sed_script
+  done
+  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
+  _G_sed_script=
+
+  func_check_prog_sed ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo '' >> conftest.nl
+      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
+  rm -f conftest.sed
+  SED=$func_path_progs_result
+}
+
+
+# Unless the user overrides by setting GREP, search the path for either GNU
+# grep, or the grep that truncates its output the least.
+test -z "$GREP" && {
+  func_check_prog_grep ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    _G_path_prog_max=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo 'GREP' >> conftest.nl
+      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
+  GREP=$func_path_progs_result
+}
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# All uppercase variable names are used for environment variables.  These
+# variables can be overridden by the user before calling a script that
+# uses them if a suitable command of that name is not already available
+# in the command search PATH.
 
 : ${CP="cp -f"}
-test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${ECHO="printf %s\n"}
+: ${EGREP="$GREP -E"}
+: ${FGREP="$GREP -F"}
+: ${LN_S="ln -s"}
 : ${MAKE="make"}
 : ${MKDIR="mkdir"}
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
-: ${Xsed="$SED -e 1s/^X//"}
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
-EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
-
-exit_status=$EXIT_SUCCESS
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
 
-dirname="s,/[^/]*$,,"
-basename="s,^.*/,,"
 
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
-    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-} # func_dirname may be replaced by extended shell implementation
+## -------------------- ##
+## Useful sed snippets. ##
+## -------------------- ##
 
+sed_dirname='s|/[^/]*$||'
+sed_basename='s|^.*/||'
 
-# func_basename file
-func_basename ()
-{
-    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
-} # func_basename may be replaced by extended shell implementation
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
 
+# Same as above, but do not quote variable references.
+sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-#             add APPEND to the result, otherwise set result
-#             to NONDIR_REPLACEMENT.
-#             value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-#             value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-    # Extract subdirectory from the argument.
-    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
-} # func_dirname_and_basename may be replaced by extended shell implementation
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
 
+# Sed substitution that converts a w32 file name or path
+# that contains forward slashes, into one that contains
+# (escaped) backslashes.  A very naive implementation.
+sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-'\' parameter expansions in output of sed_double_quote_subst that
+# were '\'-ed in input to the same.  If an odd number of '\' preceded a
+# '$' in input to sed_double_quote_subst, that '$' was protected from
+# expansion.  Since each input '\' is now two '\'s, look for any number
+# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
+_G_bs='\\'
+_G_bs2='\\\\'
+_G_bs4='\\\\\\\\'
+_G_dollar='\$'
+sed_double_backslash="\
+  s/$_G_bs4/&\\
+/g
+  s/^$_G_bs2$_G_dollar/$_G_bs&/
+  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
+  s/\n//g"
 
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-# func_strip_suffix prefix name
-func_stripname ()
-{
-    case ${2} in
-      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-    esac
-} # func_stripname may be replaced by extended shell implementation
 
+## ----------------- ##
+## Global variables. ##
+## ----------------- ##
 
-# These SED scripts presuppose an absolute path with a trailing slash.
-pathcar='s,^/\([^/]*\).*$,\1,'
-pathcdr='s,^/[^/]*,,'
-removedotparts=':dotsl
-		s@/\./@/@g
-		t dotsl
-		s,/\.$,/,'
-collapseslashes='s@/\{1,\}@/@g'
-finalslash='s,/*$,/,'
+# Except for the global variables explicitly listed below, the following
+# functions in the '^func_' namespace, and the '^require_' namespace
+# variables initialised in the 'Resource management' section, sourcing
+# this file will not pollute your global namespace with anything
+# else. There's no portable way to scope variables in Bourne shell
+# though, so actually running these functions will sometimes place
+# results into a variable named after the function, and often use
+# temporary variables in the '^_G_' namespace. If you are careful to
+# avoid using those namespaces casually in your sourcing script, things
+# should continue to work as you expect. And, of course, you can freely
+# overwrite any of the functions or variables defined here before
+# calling anything to customize them.
 
-# func_normal_abspath PATH
-# Remove doubled-up and trailing slashes, "." path components,
-# and cancel out any ".." path components in PATH after making
-# it an absolute path.
-#             value returned in "$func_normal_abspath_result"
-func_normal_abspath ()
-{
-  # Start from root dir and reassemble the path.
-  func_normal_abspath_result=
-  func_normal_abspath_tpath=$1
-  func_normal_abspath_altnamespace=
-  case $func_normal_abspath_tpath in
-    "")
-      # Empty path, that just means $cwd.
-      func_stripname '' '/' "`pwd`"
-      func_normal_abspath_result=$func_stripname_result
-      return
-    ;;
-    # The next three entries are used to spot a run of precisely
-    # two leading slashes without using negated character classes;
-    # we take advantage of case's first-match behaviour.
-    ///*)
-      # Unusual form of absolute path, do nothing.
-    ;;
-    //*)
-      # Not necessarily an ordinary path; POSIX reserves leading '//'
-      # and for example Cygwin uses it to access remote file shares
-      # over CIFS/SMB, so we conserve a leading double slash if found.
-      func_normal_abspath_altnamespace=/
-    ;;
-    /*)
-      # Absolute path, do nothing.
-    ;;
-    *)
-      # Relative path, prepend $cwd.
-      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
-    ;;
-  esac
-  # Cancel out all the simple stuff to save iterations.  We also want
-  # the path to end with a slash for ease of parsing, so make sure
-  # there is one (and only one) here.
-  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
-  while :; do
-    # Processed it all yet?
-    if test "$func_normal_abspath_tpath" = / ; then
-      # If we ascended to the root using ".." the result may be empty now.
-      if test -z "$func_normal_abspath_result" ; then
-        func_normal_abspath_result=/
-      fi
-      break
-    fi
-    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcar"`
-    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcdr"`
-    # Figure out what to do with it
-    case $func_normal_abspath_tcomponent in
-      "")
-        # Trailing empty path component, ignore it.
-      ;;
-      ..)
-        # Parent dir; strip last assembled component from result.
-        func_dirname "$func_normal_abspath_result"
-        func_normal_abspath_result=$func_dirname_result
-      ;;
-      *)
-        # Actual path component, append it.
-        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
-      ;;
-    esac
-  done
-  # Restore leading double-slash if one was found on entry.
-  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
-}
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 
-# func_relative_path SRCDIR DSTDIR
-# generates a relative path from SRCDIR to DSTDIR, with a trailing
-# slash if non-empty, suitable for immediately appending a filename
-# without needing to append a separator.
-#             value returned in "$func_relative_path_result"
-func_relative_path ()
-{
-  func_relative_path_result=
-  func_normal_abspath "$1"
-  func_relative_path_tlibdir=$func_normal_abspath_result
-  func_normal_abspath "$2"
-  func_relative_path_tbindir=$func_normal_abspath_result
-
-  # Ascend the tree starting from libdir
-  while :; do
-    # check if we have found a prefix of bindir
-    case $func_relative_path_tbindir in
-      $func_relative_path_tlibdir)
-        # found an exact match
-        func_relative_path_tcancelled=
-        break
-        ;;
-      $func_relative_path_tlibdir*)
-        # found a matching prefix
-        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
-        func_relative_path_tcancelled=$func_stripname_result
-        if test -z "$func_relative_path_result"; then
-          func_relative_path_result=.
-        fi
-        break
-        ;;
-      *)
-        func_dirname $func_relative_path_tlibdir
-        func_relative_path_tlibdir=${func_dirname_result}
-        if test "x$func_relative_path_tlibdir" = x ; then
-          # Have to descend all the way to the root!
-          func_relative_path_result=../$func_relative_path_result
-          func_relative_path_tcancelled=$func_relative_path_tbindir
-          break
-        fi
-        func_relative_path_result=../$func_relative_path_result
-        ;;
-    esac
-  done
+# Allow overriding, eg assuming that you follow the convention of
+# putting '$debug_cmd' at the start of all your functions, you can get
+# bash to show function call trace with:
+#
+#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+debug_cmd=${debug_cmd-":"}
+exit_cmd=:
 
-  # Now calculate path; take care to avoid doubling-up slashes.
-  func_stripname '' '/' "$func_relative_path_result"
-  func_relative_path_result=$func_stripname_result
-  func_stripname '/' '/' "$func_relative_path_tcancelled"
-  if test "x$func_stripname_result" != x ; then
-    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
-  fi
+# By convention, finish your script with:
+#
+#    exit $exit_status
+#
+# so that you can set exit_status to non-zero if you want to indicate
+# something went wrong during execution without actually bailing out at
+# the point of failure.
+exit_status=$EXIT_SUCCESS
 
-  # Normalisation. If bindir is libdir, return empty string,
-  # else relative path ending with a slash; either way, target
-  # file name can be directly appended.
-  if test ! -z "$func_relative_path_result"; then
-    func_stripname './' '' "$func_relative_path_result/"
-    func_relative_path_result=$func_stripname_result
-  fi
-}
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath=$0
 
-# The name of this program:
-func_dirname_and_basename "$progpath"
-progname=$func_basename_result
+# The name of this program.
+progname=`$ECHO "$progpath" |$SED "$sed_basename"`
 
-# Make sure we have an absolute path for reexecution:
+# Make sure we have an absolute progpath for reexecution:
 case $progpath in
   [\\/]*|[A-Za-z]:\\*) ;;
   *[\\/]*)
-     progdir=$func_dirname_result
+     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
      progdir=`cd "$progdir" && pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
   *)
-     save_IFS="$IFS"
+     _G_IFS=$IFS
      IFS=${PATH_SEPARATOR-:}
      for progdir in $PATH; do
-       IFS="$save_IFS"
+       IFS=$_G_IFS
        test -x "$progdir/$progname" && break
      done
-     IFS="$save_IFS"
+     IFS=$_G_IFS
      test -n "$progdir" || progdir=`pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
 esac
 
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# Sed substitution that turns a string into a regex matching for the
-# string literally.
-sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+## ----------------- ##
+## Standard options. ##
+## ----------------- ##
 
-# Sed substitution that converts a w32 file name or path
-# which contains forward slashes, into one that contains
-# (escaped) backslashes.  A very naive implementation.
-lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-
-# Re-`\' parameter expansions in output of double_quote_subst that were
-# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
-# in input to double_quote_subst, that '$' was protected from expansion.
-# Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
-bs='\\'
-bs2='\\\\'
-bs4='\\\\\\\\'
-dollar='\$'
-sed_double_backslash="\
-  s/$bs4/&\\
-/g
-  s/^$bs2$dollar/$bs&/
-  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
-  s/\n//g"
+# The following options affect the operation of the functions defined
+# below, and should be set appropriately depending on run-time para-
+# meters passed on the command line.
 
-# Standard options:
 opt_dry_run=false
-opt_help=false
 opt_quiet=false
 opt_verbose=false
-opt_warning=:
 
-# func_echo arg...
-# Echo program name prefixed message, along with the current mode
-# name if it has been set yet.
-func_echo ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
-}
+# Categories 'all' and 'none' are always available.  Append any others
+# you will pass as the first argument to func_warning from your own
+# code.
+warning_categories=
 
-# func_verbose arg...
-# Echo program name prefixed message in verbose mode only.
-func_verbose ()
-{
-    $opt_verbose && func_echo ${1+"$@"}
+# By default, display warnings according to 'opt_warning_types'.  Set
+# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
+# treat the next displayed warning as a fatal error.
+warning_func=func_warn_and_continue
 
-    # A bug in bash halts the script if the last line of a function
-    # fails when set -e is in force, so we need another command to
-    # work around that:
-    :
-}
+# Set to 'all' to display all warnings, 'none' to suppress all
+# warnings, or a space delimited list of some subset of
+# 'warning_categories' to display only the listed warnings.
+opt_warning_types=all
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*"
-}
 
-# func_error arg...
-# Echo program name prefixed message to standard error.
-func_error ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
-}
+## -------------------- ##
+## Resource management. ##
+## -------------------- ##
 
-# func_warning arg...
-# Echo program name prefixed warning message to standard error.
-func_warning ()
-{
-    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+# This section contains definitions for functions that each ensure a
+# particular resource (a file, or a non-empty configuration variable for
+# example) is available, and if appropriate to extract default values
+# from pertinent package files. Call them using their associated
+# 'require_*' variable to ensure that they are executed, at most, once.
+#
+# It's entirely deliberate that calling these functions can set
+# variables that don't obey the namespace limitations obeyed by the rest
+# of this file, in order that that they be as useful as possible to
+# callers.
 
-    # bash bug again:
-    :
-}
 
-# func_fatal_error arg...
-# Echo program name prefixed message to standard error, and exit.
-func_fatal_error ()
+# require_term_colors
+# -------------------
+# Allow display of bold text on terminals that support it.
+require_term_colors=func_require_term_colors
+func_require_term_colors ()
 {
-    func_error ${1+"$@"}
-    exit $EXIT_FAILURE
-}
+    $debug_cmd
+
+    test -t 1 && {
+      # COLORTERM and USE_ANSI_COLORS environment variables take
+      # precedence, because most terminfo databases neglect to describe
+      # whether color sequences are supported.
+      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
+
+      if test 1 = "$USE_ANSI_COLORS"; then
+        # Standard ANSI escape sequences
+        tc_reset=''
+        tc_bold='';   tc_standout=''
+        tc_red='';   tc_green=''
+        tc_blue='';  tc_cyan=''
+      else
+        # Otherwise trust the terminfo database after all.
+        test -n "`tput sgr0 2>/dev/null`" && {
+          tc_reset=`tput sgr0`
+          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
+          tc_standout=$tc_bold
+          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
+          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
+          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
+          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
+          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
+        }
+      fi
+    }
 
-# func_fatal_help arg...
-# Echo program name prefixed message to standard error, followed by
-# a help hint, and exit.
-func_fatal_help ()
-{
-    func_error ${1+"$@"}
-    func_fatal_error "$help"
+    require_term_colors=:
 }
-help="Try \`$progname --help' for more information."  ## default
 
 
-# func_grep expression filename
+## ----------------- ##
+## Function library. ##
+## ----------------- ##
+
+# This section contains a variety of useful functions to call in your
+# scripts. Take note of the portable wrappers for features provided by
+# some modern shells, which will fall back to slower equivalents on
+# less featureful shells.
+
+
+# func_append VAR VALUE
+# ---------------------
+# Append VALUE onto the existing contents of VAR.
+
+  # We should try to minimise forks, especially on Windows where they are
+  # unreasonably slow, so skip the feature probes when bash or zsh are
+  # being used:
+  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
+    : ${_G_HAVE_ARITH_OP="yes"}
+    : ${_G_HAVE_XSI_OPS="yes"}
+    # The += operator was introduced in bash 3.1
+    case $BASH_VERSION in
+      [12].* | 3.0 | 3.0*) ;;
+      *)
+        : ${_G_HAVE_PLUSEQ_OP="yes"}
+        ;;
+    esac
+  fi
+
+  # _G_HAVE_PLUSEQ_OP
+  # Can be empty, in which case the shell is probed, "yes" if += is
+  # useable or anything else if it does not work.
+  test -z "$_G_HAVE_PLUSEQ_OP" \
+    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
+    && _G_HAVE_PLUSEQ_OP=yes
+
+if test yes = "$_G_HAVE_PLUSEQ_OP"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_append ()
+  {
+    $debug_cmd
+
+    eval "$1+=\$2"
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_append ()
+  {
+    $debug_cmd
+
+    eval "$1=\$$1\$2"
+  }
+fi
+
+
+# func_append_quoted VAR VALUE
+# ----------------------------
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+  eval 'func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1+=\\ \$func_quote_for_eval_result"
+  }'
+else
+  func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1=\$$1\\ \$func_quote_for_eval_result"
+  }
+fi
+
+
+# func_append_uniq VAR VALUE
+# --------------------------
+# Append unique VALUE onto the existing contents of VAR, assuming
+# entries are delimited by the first character of VALUE.  For example:
+#
+#   func_append_uniq options " --another-option option-argument"
+#
+# will only append to $options if " --another-option option-argument "
+# is not already present somewhere in $options already (note spaces at
+# each end implied by leading space in second argument).
+func_append_uniq ()
+{
+    $debug_cmd
+
+    eval _G_current_value='`$ECHO $'$1'`'
+    _G_delim=`expr "$2" : '\(.\)'`
+
+    case $_G_delim$_G_current_value$_G_delim in
+      *"$2$_G_delim"*) ;;
+      *) func_append "$@" ;;
+    esac
+}
+
+
+# func_arith TERM...
+# ------------------
+# Set func_arith_result to the result of evaluating TERMs.
+  test -z "$_G_HAVE_ARITH_OP" \
+    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
+    && _G_HAVE_ARITH_OP=yes
+
+if test yes = "$_G_HAVE_ARITH_OP"; then
+  eval 'func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=$(( $* ))
+  }'
+else
+  func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=`expr "$@"`
+  }
+fi
+
+
+# func_basename FILE
+# ------------------
+# Set func_basename_result to FILE with everything up to and including
+# the last / stripped.
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  # If this shell supports suffix pattern removal, then use it to avoid
+  # forking. Hide the definitions single quotes in case the shell chokes
+  # on unsupported syntax...
+  _b='func_basename_result=${1##*/}'
+  _d='case $1 in
+        */*) func_dirname_result=${1%/*}$2 ;;
+        *  ) func_dirname_result=$3        ;;
+      esac'
+
+else
+  # ...otherwise fall back to using sed.
+  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
+  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
+      if test "X$func_dirname_result" = "X$1"; then
+        func_dirname_result=$3
+      else
+        func_append func_dirname_result "$2"
+      fi'
+fi
+
+eval 'func_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+}'
+
+
+# func_dirname FILE APPEND NONDIR_REPLACEMENT
+# -------------------------------------------
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+eval 'func_dirname ()
+{
+    $debug_cmd
+
+    '"$_d"'
+}'
+
+
+# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
+# --------------------------------------------------------
+# Perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# For efficiency, we do not delegate to the functions above but instead
+# duplicate the functionality here.
+eval 'func_dirname_and_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+    '"$_d"'
+}'
+
+
+# func_echo ARG...
+# ----------------
+# Echo program name prefixed message.
+func_echo ()
+{
+    $debug_cmd
+
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
+
+
+# func_echo_all ARG...
+# --------------------
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+
+# func_echo_infix_1 INFIX ARG...
+# ------------------------------
+# Echo program name, followed by INFIX on the first line, with any
+# additional lines not showing INFIX.
+func_echo_infix_1 ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    _G_infix=$1; shift
+    _G_indent=$_G_infix
+    _G_prefix="$progname: $_G_infix: "
+    _G_message=$*
+
+    # Strip color escape sequences before counting printable length
+    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
+    do
+      test -n "$_G_tc" && {
+        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
+        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
+      }
+    done
+    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
+
+    func_echo_infix_1_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_infix_1_IFS
+      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
+      _G_prefix=$_G_indent
+    done
+    IFS=$func_echo_infix_1_IFS
+}
+
+
+# func_error ARG...
+# -----------------
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
+}
+
+
+# func_fatal_error ARG...
+# -----------------------
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    $debug_cmd
+
+    func_error "$*"
+    exit $EXIT_FAILURE
+}
+
+
+# func_grep EXPRESSION FILENAME
+# -----------------------------
 # Check whether EXPRESSION matches any line of FILENAME, without output.
 func_grep ()
 {
+    $debug_cmd
+
     $GREP "$1" "$2" >/dev/null 2>&1
 }
 
 
-# func_mkdir_p directory-path
+# func_len STRING
+# ---------------
+# Set func_len_result to the length of STRING. STRING may not
+# start with a hyphen.
+  test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=${#1}
+  }'
+else
+  func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+  }
+fi
+
+
+# func_mkdir_p DIRECTORY-PATH
+# ---------------------------
 # Make sure the entire path to DIRECTORY-PATH is available.
 func_mkdir_p ()
 {
-    my_directory_path="$1"
-    my_dir_list=
+    $debug_cmd
 
-    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+    _G_directory_path=$1
+    _G_dir_list=
 
-      # Protect directory names starting with `-'
-      case $my_directory_path in
-        -*) my_directory_path="./$my_directory_path" ;;
+    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
+
+      # Protect directory names starting with '-'
+      case $_G_directory_path in
+        -*) _G_directory_path=./$_G_directory_path ;;
       esac
 
       # While some portion of DIR does not yet exist...
-      while test ! -d "$my_directory_path"; do
+      while test ! -d "$_G_directory_path"; do
         # ...make a list in topmost first order.  Use a colon delimited
 	# list incase some portion of path contains whitespace.
-        my_dir_list="$my_directory_path:$my_dir_list"
+        _G_dir_list=$_G_directory_path:$_G_dir_list
 
         # If the last portion added has no slash in it, the list is done
-        case $my_directory_path in */*) ;; *) break ;; esac
+        case $_G_directory_path in */*) ;; *) break ;; esac
 
         # ...otherwise throw away the child directory and loop
-        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
       done
-      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
 
-      save_mkdir_p_IFS="$IFS"; IFS=':'
-      for my_dir in $my_dir_list; do
-	IFS="$save_mkdir_p_IFS"
-        # mkdir can fail with a `File exist' error if two processes
+      func_mkdir_p_IFS=$IFS; IFS=:
+      for _G_dir in $_G_dir_list; do
+	IFS=$func_mkdir_p_IFS
+        # mkdir can fail with a 'File exist' error if two processes
         # try to create one of the directories concurrently.  Don't
         # stop in that case!
-        $MKDIR "$my_dir" 2>/dev/null || :
+        $MKDIR "$_G_dir" 2>/dev/null || :
       done
-      IFS="$save_mkdir_p_IFS"
+      IFS=$func_mkdir_p_IFS
 
       # Bail out if we (or some other process) failed to create a directory.
-      test -d "$my_directory_path" || \
-        func_fatal_error "Failed to create \`$1'"
+      test -d "$_G_directory_path" || \
+        func_fatal_error "Failed to create '$1'"
     fi
 }
 
 
-# func_mktempdir [string]
+# func_mktempdir [BASENAME]
+# -------------------------
 # Make a temporary directory that won't clash with other running
 # libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
+# given, BASENAME is the basename for that directory.
 func_mktempdir ()
 {
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
+    $debug_cmd
+
+    _G_template=${TMPDIR-/tmp}/${1-$progname}
 
-    if test "$opt_dry_run" = ":"; then
+    if test : = "$opt_dry_run"; then
       # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
+      _G_tmpdir=$_G_template-$$
     else
 
       # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
 
-      if test ! -d "$my_tmpdir"; then
+      if test ! -d "$_G_tmpdir"; then
         # Failing that, at least try and use $RANDOM to avoid a race
-        my_tmpdir="${my_template}-${RANDOM-0}$$"
+        _G_tmpdir=$_G_template-${RANDOM-0}$$
 
-        save_mktempdir_umask=`umask`
+        func_mktempdir_umask=`umask`
         umask 0077
-        $MKDIR "$my_tmpdir"
-        umask $save_mktempdir_umask
+        $MKDIR "$_G_tmpdir"
+        umask $func_mktempdir_umask
       fi
 
       # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || \
-        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+      test -d "$_G_tmpdir" || \
+        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
+    fi
+
+    $ECHO "$_G_tmpdir"
+}
+
+
+# func_normal_abspath PATH
+# ------------------------
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+func_normal_abspath ()
+{
+    $debug_cmd
+
+    # These SED scripts presuppose an absolute path with a trailing slash.
+    _G_pathcar='s|^/\([^/]*\).*$|\1|'
+    _G_pathcdr='s|^/[^/]*||'
+    _G_removedotparts=':dotsl
+		s|/\./|/|g
+		t dotsl
+		s|/\.$|/|'
+    _G_collapseslashes='s|/\{1,\}|/|g'
+    _G_finalslash='s|/*$|/|'
+
+    # Start from root dir and reassemble the path.
+    func_normal_abspath_result=
+    func_normal_abspath_tpath=$1
+    func_normal_abspath_altnamespace=
+    case $func_normal_abspath_tpath in
+      "")
+        # Empty path, that just means $cwd.
+        func_stripname '' '/' "`pwd`"
+        func_normal_abspath_result=$func_stripname_result
+        return
+        ;;
+      # The next three entries are used to spot a run of precisely
+      # two leading slashes without using negated character classes;
+      # we take advantage of case's first-match behaviour.
+      ///*)
+        # Unusual form of absolute path, do nothing.
+        ;;
+      //*)
+        # Not necessarily an ordinary path; POSIX reserves leading '//'
+        # and for example Cygwin uses it to access remote file shares
+        # over CIFS/SMB, so we conserve a leading double slash if found.
+        func_normal_abspath_altnamespace=/
+        ;;
+      /*)
+        # Absolute path, do nothing.
+        ;;
+      *)
+        # Relative path, prepend $cwd.
+        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+        ;;
+    esac
+
+    # Cancel out all the simple stuff to save iterations.  We also want
+    # the path to end with a slash for ease of parsing, so make sure
+    # there is one (and only one) here.
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
+    while :; do
+      # Processed it all yet?
+      if test / = "$func_normal_abspath_tpath"; then
+        # If we ascended to the root using ".." the result may be empty now.
+        if test -z "$func_normal_abspath_result"; then
+          func_normal_abspath_result=/
+        fi
+        break
+      fi
+      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcar"`
+      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcdr"`
+      # Figure out what to do with it
+      case $func_normal_abspath_tcomponent in
+        "")
+          # Trailing empty path component, ignore it.
+          ;;
+        ..)
+          # Parent dir; strip last assembled component from result.
+          func_dirname "$func_normal_abspath_result"
+          func_normal_abspath_result=$func_dirname_result
+          ;;
+        *)
+          # Actual path component, append it.
+          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
+          ;;
+      esac
+    done
+    # Restore leading double-slash if one was found on entry.
+    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+
+# func_notquiet ARG...
+# --------------------
+# Echo program name prefixed message only when not in quiet mode.
+func_notquiet ()
+{
+    $debug_cmd
+
+    $opt_quiet || func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+
+# func_relative_path SRCDIR DSTDIR
+# --------------------------------
+# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
+func_relative_path ()
+{
+    $debug_cmd
+
+    func_relative_path_result=
+    func_normal_abspath "$1"
+    func_relative_path_tlibdir=$func_normal_abspath_result
+    func_normal_abspath "$2"
+    func_relative_path_tbindir=$func_normal_abspath_result
+
+    # Ascend the tree starting from libdir
+    while :; do
+      # check if we have found a prefix of bindir
+      case $func_relative_path_tbindir in
+        $func_relative_path_tlibdir)
+          # found an exact match
+          func_relative_path_tcancelled=
+          break
+          ;;
+        $func_relative_path_tlibdir*)
+          # found a matching prefix
+          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+          func_relative_path_tcancelled=$func_stripname_result
+          if test -z "$func_relative_path_result"; then
+            func_relative_path_result=.
+          fi
+          break
+          ;;
+        *)
+          func_dirname $func_relative_path_tlibdir
+          func_relative_path_tlibdir=$func_dirname_result
+          if test -z "$func_relative_path_tlibdir"; then
+            # Have to descend all the way to the root!
+            func_relative_path_result=../$func_relative_path_result
+            func_relative_path_tcancelled=$func_relative_path_tbindir
+            break
+          fi
+          func_relative_path_result=../$func_relative_path_result
+          ;;
+      esac
+    done
+
+    # Now calculate path; take care to avoid doubling-up slashes.
+    func_stripname '' '/' "$func_relative_path_result"
+    func_relative_path_result=$func_stripname_result
+    func_stripname '/' '/' "$func_relative_path_tcancelled"
+    if test -n "$func_stripname_result"; then
+      func_append func_relative_path_result "/$func_stripname_result"
+    fi
+
+    # Normalisation. If bindir is libdir, return '.' else relative path.
+    if test -n "$func_relative_path_result"; then
+      func_stripname './' '' "$func_relative_path_result"
+      func_relative_path_result=$func_stripname_result
     fi
 
-    $ECHO "$my_tmpdir"
+    test -n "$func_relative_path_result" || func_relative_path_result=.
+
+    :
+}
+
+
+# func_quote_for_eval ARG...
+# --------------------------
+# Aesthetically quote ARGs to be evaled later.
+# This function returns two values:
+#   i) func_quote_for_eval_result
+#      double-quoted, suitable for a subsequent eval
+#  ii) func_quote_for_eval_unquoted_result
+#      has all characters that are still active within double
+#      quotes backslashified.
+func_quote_for_eval ()
+{
+    $debug_cmd
+
+    func_quote_for_eval_unquoted_result=
+    func_quote_for_eval_result=
+    while test 0 -lt $#; do
+      case $1 in
+        *[\\\`\"\$]*)
+	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+        *)
+          _G_unquoted_arg=$1 ;;
+      esac
+      if test -n "$func_quote_for_eval_unquoted_result"; then
+	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+      else
+        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+      fi
+
+      case $_G_unquoted_arg in
+        # Double-quote args containing shell metacharacters to delay
+        # word splitting, command substitution and variable expansion
+        # for a subsequent eval.
+        # Many Bourne shells cannot handle close brackets correctly
+        # in scan sets, so we specify it separately.
+        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+          _G_quoted_arg=\"$_G_unquoted_arg\"
+          ;;
+        *)
+          _G_quoted_arg=$_G_unquoted_arg
+	  ;;
+      esac
+
+      if test -n "$func_quote_for_eval_result"; then
+	func_append func_quote_for_eval_result " $_G_quoted_arg"
+      else
+        func_append func_quote_for_eval_result "$_G_quoted_arg"
+      fi
+      shift
+    done
+}
+
+
+# func_quote_for_expand ARG
+# -------------------------
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    $debug_cmd
+
+    case $1 in
+      *[\\\`\"]*)
+	_G_arg=`$ECHO "$1" | $SED \
+	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        _G_arg=$1 ;;
+    esac
+
+    case $_G_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        _G_arg=\"$_G_arg\"
+        ;;
+    esac
+
+    func_quote_for_expand_result=$_G_arg
+}
+
+
+# func_stripname PREFIX SUFFIX NAME
+# ---------------------------------
+# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_stripname ()
+  {
+    $debug_cmd
+
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary variable first.
+    func_stripname_result=$3
+    func_stripname_result=${func_stripname_result#"$1"}
+    func_stripname_result=${func_stripname_result%"$2"}
+  }'
+else
+  func_stripname ()
+  {
+    $debug_cmd
+
+    case $2 in
+      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
+      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
+    esac
+  }
+fi
+
+
+# func_show_eval CMD [FAIL_EXP]
+# -----------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    func_quote_for_expand "$_G_cmd"
+    eval "func_notquiet $func_quote_for_expand_result"
+
+    $opt_dry_run || {
+      eval "$_G_cmd"
+      _G_status=$?
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_show_eval_locale CMD [FAIL_EXP]
+# ------------------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    $opt_quiet || {
+      func_quote_for_expand "$_G_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    $opt_dry_run || {
+      eval "$_G_user_locale
+	    $_G_cmd"
+      _G_status=$?
+      eval "$_G_safe_locale"
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_tr_sh
+# ----------
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result.  All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+    $debug_cmd
+
+    case $1 in
+    [0-9]* | *[!a-zA-Z0-9_]*)
+      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
+      ;;
+    * )
+      func_tr_sh_result=$1
+      ;;
+    esac
+}
+
+
+# func_verbose ARG...
+# -------------------
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $debug_cmd
+
+    $opt_verbose && func_echo "$*"
+
+    :
+}
+
+
+# func_warn_and_continue ARG...
+# -----------------------------
+# Echo program name prefixed warning message to standard error.
+func_warn_and_continue ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
+}
+
+
+# func_warning CATEGORY ARG...
+# ----------------------------
+# Echo program name prefixed warning message to standard error. Warning
+# messages can be filtered according to CATEGORY, where this function
+# elides messages where CATEGORY is not listed in the global variable
+# 'opt_warning_types'.
+func_warning ()
+{
+    $debug_cmd
+
+    # CATEGORY must be in the warning_categories list!
+    case " $warning_categories " in
+      *" $1 "*) ;;
+      *) func_internal_error "invalid warning category '$1'" ;;
+    esac
+
+    _G_category=$1
+    shift
+
+    case " $opt_warning_types " in
+      *" $_G_category "*) $warning_func ${1+"$@"} ;;
+    esac
+}
+
+
+# func_sort_ver VER1 VER2
+# -----------------------
+# 'sort -V' is not generally available.
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+func_sort_ver ()
+{
+    $debug_cmd
+
+    printf '%s\n%s\n' "$1" "$2" \
+      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
+}
+
+# func_lt_ver PREV CURR
+# ---------------------
+# Return true if PREV and CURR are in the correct order according to
+# func_sort_ver, otherwise false.  Use it like this:
+#
+#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
+func_lt_ver ()
+{
+    $debug_cmd
+
+    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
+}
+
+
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
+#! /bin/sh
+
+# Set a version string for this script.
+scriptversion=2014-01-07.03; # UTC
+
+# A portable, pluggable option parser for Bourne shell.
+# Written by Gary V. Vaughan, 2010
+
+# Copyright (C) 2010-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# This file is a library for parsing options in your shell scripts along
+# with assorted other useful supporting features that you can make use
+# of too.
+#
+# For the simplest scripts you might need only:
+#
+#   #!/bin/sh
+#   . relative/path/to/funclib.sh
+#   . relative/path/to/options-parser
+#   scriptversion=1.0
+#   func_options ${1+"$@"}
+#   eval set dummy "$func_options_result"; shift
+#   ...rest of your script...
+#
+# In order for the '--version' option to work, you will need to have a
+# suitably formatted comment like the one at the top of this file
+# starting with '# Written by ' and ending with '# warranty; '.
+#
+# For '-h' and '--help' to work, you will also need a one line
+# description of your script's purpose in a comment directly above the
+# '# Written by ' line, like the one at the top of this file.
+#
+# The default options also support '--debug', which will turn on shell
+# execution tracing (see the comment above debug_cmd below for another
+# use), and '--verbose' and the func_verbose function to allow your script
+# to display verbose messages only when your user has specified
+# '--verbose'.
+#
+# After sourcing this file, you can plug processing for additional
+# options by amending the variables from the 'Configuration' section
+# below, and following the instructions in the 'Option parsing'
+# section further down.
+
+## -------------- ##
+## Configuration. ##
+## -------------- ##
+
+# You should override these variables in your script after sourcing this
+# file so that they reflect the customisations you have added to the
+# option parser.
+
+# The usage line for option parsing errors and the start of '-h' and
+# '--help' output messages. You can embed shell variables for delayed
+# expansion at the time the message is displayed, but you will need to
+# quote other shell meta-characters carefully to prevent them being
+# expanded when the contents are evaled.
+usage='$progpath [OPTION]...'
+
+# Short help message in response to '-h' and '--help'.  Add to this or
+# override it after sourcing this library to reflect the full set of
+# options your script accepts.
+usage_message="\
+       --debug        enable verbose shell tracing
+   -W, --warnings=CATEGORY
+                      report the warnings falling in CATEGORY [all]
+   -v, --verbose      verbosely report processing
+       --version      print version information and exit
+   -h, --help         print short or long help message and exit
+"
+
+# Additional text appended to 'usage_message' in response to '--help'.
+long_help_message="
+Warning categories include:
+       'all'          show all warnings
+       'none'         turn off all the warnings
+       'error'        warnings are treated as fatal errors"
+
+# Help message printed before fatal option parsing errors.
+fatal_help="Try '\$progname --help' for more information."
+
+
+
+## ------------------------- ##
+## Hook function management. ##
+## ------------------------- ##
+
+# This section contains functions for adding, removing, and running hooks
+# to the main code.  A hook is just a named list of of function, that can
+# be run in order later on.
+
+# func_hookable FUNC_NAME
+# -----------------------
+# Declare that FUNC_NAME will run hooks added with
+# 'func_add_hook FUNC_NAME ...'.
+func_hookable ()
+{
+    $debug_cmd
+
+    func_append hookable_fns " $1"
+}
+
+
+# func_add_hook FUNC_NAME HOOK_FUNC
+# ---------------------------------
+# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
+# first have been declared "hookable" by a call to 'func_hookable'.
+func_add_hook ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not accept hook functions." ;;
+    esac
+
+    eval func_append ${1}_hooks '" $2"'
+}
+
+
+# func_remove_hook FUNC_NAME HOOK_FUNC
+# ------------------------------------
+# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
+func_remove_hook ()
+{
+    $debug_cmd
+
+    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
+}
+
+
+# func_run_hooks FUNC_NAME [ARG]...
+# ---------------------------------
+# Run all hook functions registered to FUNC_NAME.
+# It is assumed that the list of hook functions contains nothing more
+# than a whitespace-delimited list of legal shell function names, and
+# no effort is wasted trying to catch shell meta-characters or preserve
+# whitespace.
+func_run_hooks ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+    esac
+
+    eval _G_hook_fns=\$$1_hooks; shift
+
+    for _G_hook in $_G_hook_fns; do
+      eval $_G_hook '"$@"'
+
+      # store returned options list back into positional
+      # parameters for next 'cmd' execution.
+      eval _G_hook_result=\$${_G_hook}_result
+      eval set dummy "$_G_hook_result"; shift
+    done
+
+    func_quote_for_eval ${1+"$@"}
+    func_run_hooks_result=$func_quote_for_eval_result
+}
+
+
+
+## --------------- ##
+## Option parsing. ##
+## --------------- ##
+
+# In order to add your own option parsing hooks, you must accept the
+# full positional parameter list in your hook function, remove any
+# options that you action, and then pass back the remaining unprocessed
+# options in '<hooked_function_name>_result', escaped suitably for
+# 'eval'.  Like this:
+#
+#    my_options_prep ()
+#    {
+#        $debug_cmd
+#
+#        # Extend the existing usage message.
+#        usage_message=$usage_message'
+#      -s, --silent       don'\''t print informational messages
+#    '
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_options_prep_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_options_prep my_options_prep
+#
+#
+#    my_silent_option ()
+#    {
+#        $debug_cmd
+#
+#        # Note that for efficiency, we parse as many options as we can
+#        # recognise in a loop before passing the remainder back to the
+#        # caller on the first unrecognised argument we encounter.
+#        while test $# -gt 0; do
+#          opt=$1; shift
+#          case $opt in
+#            --silent|-s) opt_silent=: ;;
+#            # Separate non-argument short options:
+#            -s*)         func_split_short_opt "$_G_opt"
+#                         set dummy "$func_split_short_opt_name" \
+#                             "-$func_split_short_opt_arg" ${1+"$@"}
+#                         shift
+#                         ;;
+#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#          esac
+#        done
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_silent_option_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_parse_options my_silent_option
+#
+#
+#    my_option_validation ()
+#    {
+#        $debug_cmd
+#
+#        $opt_silent && $opt_verbose && func_fatal_help "\
+#    '--silent' and '--verbose' options are mutually exclusive."
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_option_validation_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_validate_options my_option_validation
+#
+# You'll alse need to manually amend $usage_message to reflect the extra
+# options you parse.  It's preferable to append if you can, so that
+# multiple option parsing hooks can be added safely.
+
+
+# func_options [ARG]...
+# ---------------------
+# All the functions called inside func_options are hookable. See the
+# individual implementations for details.
+func_hookable func_options
+func_options ()
+{
+    $debug_cmd
+
+    func_options_prep ${1+"$@"}
+    eval func_parse_options \
+        ${func_options_prep_result+"$func_options_prep_result"}
+    eval func_validate_options \
+        ${func_parse_options_result+"$func_parse_options_result"}
+
+    eval func_run_hooks func_options \
+        ${func_validate_options_result+"$func_validate_options_result"}
+
+    # save modified positional parameters for caller
+    func_options_result=$func_run_hooks_result
 }
 
 
-# func_quote_for_eval arg
-# Aesthetically quote ARG to be evaled later.
-# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
-# is double-quoted, suitable for a subsequent eval, whereas
-# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
-# which are still active within double quotes backslashified.
-func_quote_for_eval ()
+# func_options_prep [ARG]...
+# --------------------------
+# All initialisations required before starting the option parse loop.
+# Note that when calling hook functions, we pass through the list of
+# positional parameters.  If a hook function modifies that list, and
+# needs to propogate that back to rest of this script, then the complete
+# modified list must be put in 'func_run_hooks_result' before
+# returning.
+func_hookable func_options_prep
+func_options_prep ()
 {
-    case $1 in
-      *[\\\`\"\$]*)
-	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
-      *)
-        func_quote_for_eval_unquoted_result="$1" ;;
-    esac
+    $debug_cmd
 
-    case $func_quote_for_eval_unquoted_result in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting, command substitution and and variable
-      # expansion for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
-        ;;
-      *)
-        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
-    esac
+    # Option defaults:
+    opt_verbose=false
+    opt_warning_types=
+
+    func_run_hooks func_options_prep ${1+"$@"}
+
+    # save modified positional parameters for caller
+    func_options_prep_result=$func_run_hooks_result
 }
 
 
-# func_quote_for_expand arg
-# Aesthetically quote ARG to be evaled later; same as above,
-# but do not quote variable references.
-func_quote_for_expand ()
+# func_parse_options [ARG]...
+# ---------------------------
+# The main option parsing loop.
+func_hookable func_parse_options
+func_parse_options ()
 {
-    case $1 in
-      *[\\\`\"]*)
-	my_arg=`$ECHO "$1" | $SED \
-	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
-      *)
-        my_arg="$1" ;;
-    esac
+    $debug_cmd
 
-    case $my_arg in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting and command substitution for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        my_arg="\"$my_arg\""
-        ;;
-    esac
+    func_parse_options_result=
 
-    func_quote_for_expand_result="$my_arg"
-}
+    # this just eases exit handling
+    while test $# -gt 0; do
+      # Defer to hook functions for initial option parsing, so they
+      # get priority in the event of reusing an option name.
+      func_run_hooks func_parse_options ${1+"$@"}
 
+      # Adjust func_parse_options positional parameters to match
+      eval set dummy "$func_run_hooks_result"; shift
 
-# func_show_eval cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.
-func_show_eval ()
-{
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+      # Break out of the loop if we already parsed every option.
+      test $# -gt 0 || break
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --debug|-x)   debug_cmd='set -x'
+                      func_echo "enabling shell trace mode"
+                      $debug_cmd
+                      ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                      set dummy --warnings none ${1+"$@"}
+                      shift
+		      ;;
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$my_cmd"
-      my_status=$?
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+        --warnings|--warning|-W)
+                      test $# = 0 && func_missing_arg $_G_opt && break
+                      case " $warning_categories $1" in
+                        *" $1 "*)
+                          # trailing space prevents matching last $1 above
+                          func_append_uniq opt_warning_types " $1"
+                          ;;
+                        *all)
+                          opt_warning_types=$warning_categories
+                          ;;
+                        *none)
+                          opt_warning_types=none
+                          warning_func=:
+                          ;;
+                        *error)
+                          opt_warning_types=$warning_categories
+                          warning_func=func_fatal_error
+                          ;;
+                        *)
+                          func_fatal_error \
+                             "unsupported warning category: '$1'"
+                          ;;
+                      esac
+                      shift
+                      ;;
+
+        --verbose|-v) opt_verbose=: ;;
+        --version)    func_version ;;
+        -\?|-h)       func_usage ;;
+        --help)       func_help ;;
+
+	# Separate optargs to long options (plugins may need this):
+	--*=*)        func_split_equals "$_G_opt"
+	              set dummy "$func_split_equals_lhs" \
+                          "$func_split_equals_rhs" ${1+"$@"}
+                      shift
+                      ;;
+
+       # Separate optargs to short options:
+        -W*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        # Separate non-argument short options:
+        -\?*|-h*|-v*|-x*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "-$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        --)           break ;;
+        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+      esac
+    done
+
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    func_parse_options_result=$func_quote_for_eval_result
 }
 
 
-# func_show_eval_locale cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.  Use the saved locale for evaluation.
-func_show_eval_locale ()
+# func_validate_options [ARG]...
+# ------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+func_hookable func_validate_options
+func_validate_options ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    # Display all warnings if -W was not given.
+    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$lt_user_locale
-	    $my_cmd"
-      my_status=$?
-      eval "$lt_safe_locale"
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
-}
+    func_run_hooks func_validate_options ${1+"$@"}
 
-# func_tr_sh
-# Turn $1 into a string suitable for a shell variable name.
-# Result is stored in $func_tr_sh_result.  All characters
-# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
-# if $1 begins with a digit, a '_' is prepended as well.
-func_tr_sh ()
-{
-  case $1 in
-  [0-9]* | *[!a-zA-Z0-9_]*)
-    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
-    ;;
-  * )
-    func_tr_sh_result=$1
-    ;;
-  esac
+    # Bail if the options were screwed!
+    $exit_cmd $EXIT_FAILURE
+
+    # save modified positional parameters for caller
+    func_validate_options_result=$func_run_hooks_result
 }
 
 
-# func_version
-# Echo version message to standard output and exit.
-func_version ()
-{
-    $opt_debug
 
-    $SED -n '/(C)/!b go
-	:more
-	/\./!{
-	  N
-	  s/\n# / /
-	  b more
-	}
-	:go
-	/^# '$PROGRAM' (GNU /,/# warranty; / {
-        s/^# //
-	s/^# *$//
-        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
-        p
-     }' < "$progpath"
-     exit $?
-}
+## ----------------- ##
+## Helper functions. ##
+## ----------------- ##
 
-# func_usage
-# Echo short help message to standard output and exit.
-func_usage ()
+# This section contains the helper functions used by the rest of the
+# hookable option parser framework in ascii-betical order.
+
+
+# func_fatal_help ARG...
+# ----------------------
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/^# Usage:/,/^#  *.*--help/ {
-        s/^# //
-	s/^# *$//
-	s/\$progname/'$progname'/
-	p
-    }' < "$progpath"
-    echo
-    $ECHO "run \`$progname --help | more' for full usage"
-    exit $?
+    eval \$ECHO \""Usage: $usage"\"
+    eval \$ECHO \""$fatal_help"\"
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
 }
 
-# func_help [NOEXIT]
-# Echo long help message to standard output and exit,
-# unless 'noexit' is passed as argument.
+
+# func_help
+# ---------
+# Echo long help message to standard output and exit.
 func_help ()
 {
-    $opt_debug
-
-    $SED -n '/^# Usage:/,/# Report bugs to/ {
-	:print
-        s/^# //
-	s/^# *$//
-	s*\$progname*'$progname'*
-	s*\$host*'"$host"'*
-	s*\$SHELL*'"$SHELL"'*
-	s*\$LTCC*'"$LTCC"'*
-	s*\$LTCFLAGS*'"$LTCFLAGS"'*
-	s*\$LD*'"$LD"'*
-	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
-	p
-	d
-     }
-     /^# .* home page:/b print
-     /^# General help using/b print
-     ' < "$progpath"
-    ret=$?
-    if test -z "$1"; then
-      exit $ret
-    fi
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message"
+    exit 0
 }
 
-# func_missing_arg argname
+
+# func_missing_arg ARGNAME
+# ------------------------
 # Echo program name prefixed message to standard error and set global
 # exit_cmd.
 func_missing_arg ()
 {
-    $opt_debug
+    $debug_cmd
 
-    func_error "missing argument for $1."
+    func_error "Missing argument for '$1'."
     exit_cmd=exit
 }
 
 
-# func_split_short_opt shortopt
+# func_split_equals STRING
+# ------------------------
+# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
+# splitting STRING at the '=' sign.
+test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=${1%%=*}
+      func_split_equals_rhs=${1#*=}
+      test "x$func_split_equals_lhs" = "x$1" \
+        && func_split_equals_rhs=
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
+      func_split_equals_rhs=
+      test "x$func_split_equals_lhs" = "x$1" \
+        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
+  }
+fi #func_split_equals
+
+
+# func_split_short_opt SHORTOPT
+# -----------------------------
 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 # variables after splitting SHORTOPT after the 2nd character.
-func_split_short_opt ()
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_arg=${1#??}
+      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
+      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
+  }
+fi #func_split_short_opt
+
+
+# func_usage
+# ----------
+# Echo short help message to standard output and exit.
+func_usage ()
 {
-    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
-    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+    $debug_cmd
 
-    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
-    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
-} # func_split_short_opt may be replaced by extended shell implementation
+    func_usage_message
+    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
+    exit 0
+}
 
 
-# func_split_long_opt longopt
-# Set func_split_long_opt_name and func_split_long_opt_arg shell
-# variables after splitting LONGOPT at the `=' sign.
-func_split_long_opt ()
+# func_usage_message
+# ------------------
+# Echo short help message to standard output.
+func_usage_message ()
 {
-    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
-    my_sed_long_arg='1s/^--[^=]*=//'
+    $debug_cmd
 
-    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
-    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
-} # func_split_long_opt may be replaced by extended shell implementation
+    eval \$ECHO \""Usage: $usage"\"
+    echo
+    $SED -n 's|^# ||
+        /^Written by/{
+          x;p;x
+        }
+	h
+	/^Written by/q' < "$progpath"
+    echo
+    eval \$ECHO \""$usage_message"\"
+}
 
-exit_cmd=:
 
+# func_version
+# ------------
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $debug_cmd
 
+    printf '%s\n' "$progname $scriptversion"
+    $SED -n '
+        /(C)/!b go
+        :more
+        /\./!{
+          N
+          s|\n# | |
+          b more
+        }
+        :go
+        /^# Written by /,/# warranty; / {
+          s|^# ||
+          s|^# *$||
+          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
+          p
+        }
+        /^# Written by / {
+          s|^# ||
+          p
+        }
+        /^warranty; /q' < "$progpath"
 
+    exit $?
+}
 
 
-magic="%%%MAGIC variable%%%"
-magic_exe="%%%MAGIC EXE variable%%%"
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
 
-# Global variables.
-nonopt=
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-extracted_archives=
-extracted_serial=0
+# Set a version string.
+scriptversion='(GNU libtool) 2.4.6'
 
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
 
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
+# func_echo ARG...
+# ----------------
+# Libtool also displays the current mode in messages, so override
+# funclib.sh func_echo with this custom definition.
+func_echo ()
 {
-    eval "${1}=\$${1}\${2}"
-} # func_append may be replaced by extended shell implementation
+    $debug_cmd
 
-# func_append_quoted var value
-# Quote VALUE and append to the end of shell variable VAR, separated
-# by a space.
-func_append_quoted ()
-{
-    func_quote_for_eval "${2}"
-    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
-} # func_append_quoted may be replaced by extended shell implementation
+    _G_message=$*
 
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
 
-# func_arith arithmetic-term...
-func_arith ()
+
+# func_warning ARG...
+# -------------------
+# Libtool warnings are not categorized, so override funclib.sh
+# func_warning with this simpler definition.
+func_warning ()
 {
-    func_arith_result=`expr "${@}"`
-} # func_arith may be replaced by extended shell implementation
+    $debug_cmd
 
+    $warning_func ${1+"$@"}
+}
 
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
-{
-    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
-} # func_len may be replaced by extended shell implementation
 
+## ---------------- ##
+## Options parsing. ##
+## ---------------- ##
+
+# Hook in the functions to make sure our own options are parsed during
+# the option parsing loop.
+
+usage='$progpath [OPTION]... [MODE-ARG]...'
+
+# Short help message in response to '-h'.
+usage_message="Options:
+       --config             show all configuration variables
+       --debug              enable verbose shell tracing
+   -n, --dry-run            display commands without modifying any files
+       --features           display basic configuration information and exit
+       --mode=MODE          use operation mode MODE
+       --no-warnings        equivalent to '-Wnone'
+       --preserve-dup-deps  don't remove duplicate dependency libraries
+       --quiet, --silent    don't print informational messages
+       --tag=TAG            use configuration variables from tag TAG
+   -v, --verbose            print more informational messages than default
+       --version            print version information
+   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
+   -h, --help, --help-all   print short, long, or detailed help message
+"
 
-# func_lo2o object
-func_lo2o ()
+# Additional text appended to 'usage_message' in response to '--help'.
+func_help ()
 {
-    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
-} # func_lo2o may be replaced by extended shell implementation
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message
+
+MODE must be one of the following:
+
+       clean           remove files from the build directory
+       compile         compile a source file into a libtool object
+       execute         automatically set library path, then run a program
+       finish          complete the installation of libtool libraries
+       install         install libraries or executables
+       link            create a library or an executable
+       uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  When passed as first option,
+'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
+Try '$progname --help --mode=MODE' for a more detailed description of MODE.
+
+When reporting a bug, please describe a test case to reproduce it and
+include the following information:
+
+       host-triplet:   $host
+       shell:          $SHELL
+       compiler:       $LTCC
+       compiler flags: $LTCFLAGS
+       linker:         $LD (gnu? $with_gnu_ld)
+       version:        $progname (GNU libtool) 2.4.6
+       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
+       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
+
+Report bugs to <bug-libtool at gnu.org>.
+GNU libtool home page: <http://www.gnu.org/s/libtool/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>."
+    exit 0
+}
 
 
-# func_xform libobj-or-source
-func_xform ()
-{
-    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
-} # func_xform may be replaced by extended shell implementation
+# func_lo2o OBJECT-NAME
+# ---------------------
+# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
+# object suffix.
+
+lo2o=s/\\.lo\$/.$objext/
+o2lo=s/\\.$objext\$/.lo/
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_lo2o ()
+  {
+    case $1 in
+      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
+      *   ) func_lo2o_result=$1               ;;
+    esac
+  }'
+
+  # func_xform LIBOBJ-OR-SOURCE
+  # ---------------------------
+  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
+  # suffix to a '.lo' libtool-object suffix.
+  eval 'func_xform ()
+  {
+    func_xform_result=${1%.*}.lo
+  }'
+else
+  # ...otherwise fall back to using sed.
+  func_lo2o ()
+  {
+    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
+  }
+
+  func_xform ()
+  {
+    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
+  }
+fi
 
 
-# func_fatal_configuration arg...
+# func_fatal_configuration ARG...
+# -------------------------------
 # Echo program name prefixed message to standard error, followed by
 # a configuration failure hint, and exit.
 func_fatal_configuration ()
 {
-    func_error ${1+"$@"}
-    func_error "See the $PACKAGE documentation for more information."
-    func_fatal_error "Fatal configuration error."
+    func__fatal_error ${1+"$@"} \
+      "See the $PACKAGE documentation for more information." \
+      "Fatal configuration error."
 }
 
 
 # func_config
+# -----------
 # Display the configuration for all the tags in this script.
 func_config ()
 {
@@ -915,17 +2149,19 @@ func_config ()
     exit $?
 }
 
+
 # func_features
+# -------------
 # Display the features supported by this script.
 func_features ()
 {
     echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       echo "enable shared libraries"
     else
       echo "disable shared libraries"
     fi
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       echo "enable static libraries"
     else
       echo "disable static libraries"
@@ -934,314 +2170,350 @@ func_features ()
     exit $?
 }
 
-# func_enable_tag tagname
+
+# func_enable_tag TAGNAME
+# -----------------------
 # Verify that TAGNAME is valid, and either flag an error and exit, or
 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 # variable here.
 func_enable_tag ()
 {
-  # Global variable:
-  tagname="$1"
+    # Global variable:
+    tagname=$1
 
-  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
-  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
-  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+    sed_extractcf=/$re_begincf/,/$re_endcf/p
 
-  # Validate tagname.
-  case $tagname in
-    *[!-_A-Za-z0-9,/]*)
-      func_fatal_error "invalid tag name: $tagname"
-      ;;
-  esac
+    # Validate tagname.
+    case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+        func_fatal_error "invalid tag name: $tagname"
+        ;;
+    esac
 
-  # Don't test for the "default" C tag, as we know it's
-  # there but not specially marked.
-  case $tagname in
-    CC) ;;
+    # Don't test for the "default" C tag, as we know it's
+    # there but not specially marked.
+    case $tagname in
+        CC) ;;
     *)
-      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
-	taglist="$taglist $tagname"
-
-	# Evaluate the configuration.  Be careful to quote the path
-	# and the sed script, to avoid splitting on whitespace, but
-	# also don't use non-portable quotes within backquotes within
-	# quotes we have to do it in 2 steps:
-	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
-	eval "$extractedcf"
-      else
-	func_error "ignoring unknown tag $tagname"
-      fi
-      ;;
-  esac
+        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	  taglist="$taglist $tagname"
+
+	  # Evaluate the configuration.  Be careful to quote the path
+	  # and the sed script, to avoid splitting on whitespace, but
+	  # also don't use non-portable quotes within backquotes within
+	  # quotes we have to do it in 2 steps:
+	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	  eval "$extractedcf"
+        else
+	  func_error "ignoring unknown tag $tagname"
+        fi
+        ;;
+    esac
 }
 
+
 # func_check_version_match
+# ------------------------
 # Ensure that we are using m4 macros, and libtool script from the same
 # release of libtool.
 func_check_version_match ()
 {
-  if test "$package_revision" != "$macro_revision"; then
-    if test "$VERSION" != "$macro_version"; then
-      if test -z "$macro_version"; then
-        cat >&2 <<_LT_EOF
+    if test "$package_revision" != "$macro_revision"; then
+      if test "$VERSION" != "$macro_version"; then
+        if test -z "$macro_version"; then
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from an older release.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      else
-        cat >&2 <<_LT_EOF
+        else
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      fi
-    else
-      cat >&2 <<_LT_EOF
+        fi
+      else
+        cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
 $progname: of $PACKAGE $VERSION and run autoconf again.
 _LT_EOF
-    fi
+      fi
 
-    exit $EXIT_MISMATCH
-  fi
+      exit $EXIT_MISMATCH
+    fi
 }
 
 
-# Shorthand for --mode=foo, only valid as the first argument
-case $1 in
-clean|clea|cle|cl)
-  shift; set dummy --mode clean ${1+"$@"}; shift
-  ;;
-compile|compil|compi|comp|com|co|c)
-  shift; set dummy --mode compile ${1+"$@"}; shift
-  ;;
-execute|execut|execu|exec|exe|ex|e)
-  shift; set dummy --mode execute ${1+"$@"}; shift
-  ;;
-finish|finis|fini|fin|fi|f)
-  shift; set dummy --mode finish ${1+"$@"}; shift
-  ;;
-install|instal|insta|inst|ins|in|i)
-  shift; set dummy --mode install ${1+"$@"}; shift
-  ;;
-link|lin|li|l)
-  shift; set dummy --mode link ${1+"$@"}; shift
-  ;;
-uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
-  shift; set dummy --mode uninstall ${1+"$@"}; shift
-  ;;
-esac
+# libtool_options_prep [ARG]...
+# -----------------------------
+# Preparation for options parsed by libtool.
+libtool_options_prep ()
+{
+    $debug_mode
 
+    # Option defaults:
+    opt_config=false
+    opt_dlopen=
+    opt_dry_run=false
+    opt_help=false
+    opt_mode=
+    opt_preserve_dup_deps=false
+    opt_quiet=false
 
+    nonopt=
+    preserve_args=
 
-# Option defaults:
-opt_debug=:
-opt_dry_run=false
-opt_config=false
-opt_preserve_dup_deps=false
-opt_features=false
-opt_finish=false
-opt_help=false
-opt_help_all=false
-opt_silent=:
-opt_warning=:
-opt_verbose=:
-opt_silent=false
-opt_verbose=false
+    # Shorthand for --mode=foo, only valid as the first argument
+    case $1 in
+    clean|clea|cle|cl)
+      shift; set dummy --mode clean ${1+"$@"}; shift
+      ;;
+    compile|compil|compi|comp|com|co|c)
+      shift; set dummy --mode compile ${1+"$@"}; shift
+      ;;
+    execute|execut|execu|exec|exe|ex|e)
+      shift; set dummy --mode execute ${1+"$@"}; shift
+      ;;
+    finish|finis|fini|fin|fi|f)
+      shift; set dummy --mode finish ${1+"$@"}; shift
+      ;;
+    install|instal|insta|inst|ins|in|i)
+      shift; set dummy --mode install ${1+"$@"}; shift
+      ;;
+    link|lin|li|l)
+      shift; set dummy --mode link ${1+"$@"}; shift
+      ;;
+    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+      shift; set dummy --mode uninstall ${1+"$@"}; shift
+      ;;
+    esac
+
+    # Pass back the list of options.
+    func_quote_for_eval ${1+"$@"}
+    libtool_options_prep_result=$func_quote_for_eval_result
+}
+func_add_hook func_options_prep libtool_options_prep
 
 
-# Parse options once, thoroughly.  This comes as soon as possible in the
-# script to make things like `--version' happen as quickly as we can.
+# libtool_parse_options [ARG]...
+# ---------------------------------
+# Provide handling for libtool specific options.
+libtool_parse_options ()
 {
-  # this just eases exit handling
-  while test $# -gt 0; do
-    opt="$1"
-    shift
-    case $opt in
-      --debug|-x)	opt_debug='set -x'
-			func_echo "enabling shell trace mode"
-			$opt_debug
-			;;
-      --dry-run|--dryrun|-n)
-			opt_dry_run=:
-			;;
-      --config)
-			opt_config=:
-func_config
-			;;
-      --dlopen|-dlopen)
-			optarg="$1"
-			opt_dlopen="${opt_dlopen+$opt_dlopen
-}$optarg"
-			shift
-			;;
-      --preserve-dup-deps)
-			opt_preserve_dup_deps=:
-			;;
-      --features)
-			opt_features=:
-func_features
-			;;
-      --finish)
-			opt_finish=:
-set dummy --mode finish ${1+"$@"}; shift
-			;;
-      --help)
-			opt_help=:
-			;;
-      --help-all)
-			opt_help_all=:
-opt_help=': help-all'
-			;;
-      --mode)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_mode="$optarg"
-case $optarg in
-  # Valid mode arguments:
-  clean|compile|execute|finish|install|link|relink|uninstall) ;;
-
-  # Catch anything else as an error
-  *) func_error "invalid argument for $opt"
-     exit_cmd=exit
-     break
-     ;;
-esac
-			shift
-			;;
-      --no-silent|--no-quiet)
-			opt_silent=false
-func_append preserve_args " $opt"
-			;;
-      --no-warning|--no-warn)
-			opt_warning=false
-func_append preserve_args " $opt"
-			;;
-      --no-verbose)
-			opt_verbose=false
-func_append preserve_args " $opt"
-			;;
-      --silent|--quiet)
-			opt_silent=:
-func_append preserve_args " $opt"
-        opt_verbose=false
-			;;
-      --verbose|-v)
-			opt_verbose=:
-func_append preserve_args " $opt"
-opt_silent=false
-			;;
-      --tag)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_tag="$optarg"
-func_append preserve_args " $opt $optarg"
-func_enable_tag "$optarg"
-			shift
-			;;
-
-      -\?|-h)		func_usage				;;
-      --help)		func_help				;;
-      --version)	func_version				;;
-
-      # Separate optargs to long options:
-      --*=*)
-			func_split_long_opt "$opt"
-			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      # Separate non-argument short options:
-      -\?*|-h*|-n*|-v*)
-			func_split_short_opt "$opt"
-			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      --)		break					;;
-      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
-      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
-    esac
-  done
+    $debug_cmd
 
-  # Validate options:
+    # Perform our own loop to consume as many options as possible in
+    # each iteration.
+    while test $# -gt 0; do
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --dry-run|--dryrun|-n)
+                        opt_dry_run=:
+                        ;;
+
+        --config)       func_config ;;
+
+        --dlopen|-dlopen)
+                        opt_dlopen="${opt_dlopen+$opt_dlopen
+}$1"
+                        shift
+                        ;;
+
+        --preserve-dup-deps)
+                        opt_preserve_dup_deps=: ;;
+
+        --features)     func_features ;;
+
+        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
+
+        --help)         opt_help=: ;;
+
+        --help-all)     opt_help=': help-all' ;;
+
+        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_mode=$1
+                        case $1 in
+                          # Valid mode arguments:
+                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+                          # Catch anything else as an error
+                          *) func_error "invalid argument for $_G_opt"
+                             exit_cmd=exit
+                             break
+                             ;;
+                        esac
+                        shift
+                        ;;
+
+        --no-silent|--no-quiet)
+                        opt_quiet=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                        opt_warning=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-verbose)
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --silent|--quiet)
+                        opt_quiet=:
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_tag=$1
+                        func_append preserve_args " $_G_opt $1"
+                        func_enable_tag "$1"
+                        shift
+                        ;;
+
+        --verbose|-v)   opt_quiet=false
+                        opt_verbose=:
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+	# An option not handled by this hook function:
+        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
+      esac
+    done
 
-  # save first non-option argument
-  if test "$#" -gt 0; then
-    nonopt="$opt"
-    shift
-  fi
 
-  # preserve --debug
-  test "$opt_debug" = : || func_append preserve_args " --debug"
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    libtool_parse_options_result=$func_quote_for_eval_result
+}
+func_add_hook func_parse_options libtool_parse_options
 
-  case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc*)
-      # don't eliminate duplications in $postdeps and $predeps
-      opt_duplicate_compiler_generated_deps=:
-      ;;
-    *)
-      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
-      ;;
-  esac
 
-  $opt_help || {
-    # Sanity checks first:
-    func_check_version_match
 
-    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-      func_fatal_configuration "not configured to build any kind of library"
+# libtool_validate_options [ARG]...
+# ---------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+libtool_validate_options ()
+{
+    # save first non-option argument
+    if test 0 -lt $#; then
+      nonopt=$1
+      shift
     fi
 
-    # Darwin sucks
-    eval std_shrext=\"$shrext_cmds\"
+    # preserve --debug
+    test : = "$debug_cmd" || func_append preserve_args " --debug"
 
-    # Only execute mode is allowed to have -dlopen flags.
-    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
-      func_error "unrecognized option \`-dlopen'"
-      $ECHO "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
+    case $host in
+      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
+      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
+      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
+        # don't eliminate duplications in $postdeps and $predeps
+        opt_duplicate_compiler_generated_deps=:
+        ;;
+      *)
+        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+        ;;
+    esac
 
-    # Change the help message to a mode-specific one.
-    generic_help="$help"
-    help="Try \`$progname --help --mode=$opt_mode' for more information."
-  }
+    $opt_help || {
+      # Sanity checks first:
+      func_check_version_match
+
+      test yes != "$build_libtool_libs" \
+        && test yes != "$build_old_libs" \
+        && func_fatal_configuration "not configured to build any kind of library"
+
+      # Darwin sucks
+      eval std_shrext=\"$shrext_cmds\"
+
+      # Only execute mode is allowed to have -dlopen flags.
+      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
+        func_error "unrecognized option '-dlopen'"
+        $ECHO "$help" 1>&2
+        exit $EXIT_FAILURE
+      fi
 
+      # Change the help message to a mode-specific one.
+      generic_help=$help
+      help="Try '$progname --help --mode=$opt_mode' for more information."
+    }
 
-  # Bail if the options were screwed
-  $exit_cmd $EXIT_FAILURE
+    # Pass back the unparsed argument list
+    func_quote_for_eval ${1+"$@"}
+    libtool_validate_options_result=$func_quote_for_eval_result
 }
+func_add_hook func_validate_options libtool_validate_options
 
 
+# Process options as early as possible so that --help and --version
+# can return quickly.
+func_options ${1+"$@"}
+eval set dummy "$func_options_result"; shift
+
 
 
 ## ----------- ##
 ##    Main.    ##
 ## ----------- ##
 
+magic='%%%MAGIC variable%%%'
+magic_exe='%%%MAGIC EXE variable%%%'
+
+# Global variables.
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# func_generated_by_libtool
+# True iff stdin has been generated by Libtool. This function is only
+# a basic sanity check; it will hardly flush out determined imposters.
+func_generated_by_libtool_p ()
+{
+  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
 # func_lalib_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function is only a basic sanity check; it will hardly flush out
 # determined imposters.
 func_lalib_p ()
 {
     test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
-        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_lalib_unsafe_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function implements the same check as func_lalib_p without
 # resorting to external programs.  To this end, it redirects stdin and
 # closes it afterwards, without saving the original file descriptor.
 # As a safety measure, use it only where a negative result would be
-# fatal anyway.  Works if `file' does not exist.
+# fatal anyway.  Works if 'file' does not exist.
 func_lalib_unsafe_p ()
 {
     lalib_p=no
@@ -1249,13 +2521,13 @@ func_lalib_unsafe_p ()
 	for lalib_p_l in 1 2 3 4
 	do
 	    read lalib_p_line
-	    case "$lalib_p_line" in
+	    case $lalib_p_line in
 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
 	    esac
 	done
 	exec 0<&5 5<&-
     fi
-    test "$lalib_p" = yes
+    test yes = "$lalib_p"
 }
 
 # func_ltwrapper_script_p file
@@ -1264,7 +2536,8 @@ func_lalib_unsafe_p ()
 # determined imposters.
 func_ltwrapper_script_p ()
 {
-    func_lalib_p "$1"
+    test -f "$1" &&
+      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_ltwrapper_executable_p file
@@ -1289,7 +2562,7 @@ func_ltwrapper_scriptname ()
 {
     func_dirname_and_basename "$1" "" "."
     func_stripname '' '.exe' "$func_basename_result"
-    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
 }
 
 # func_ltwrapper_p file
@@ -1308,11 +2581,13 @@ func_ltwrapper_p ()
 # FAIL_CMD may read-access the current command in variable CMD!
 func_execute_cmds ()
 {
-    $opt_debug
+    $debug_cmd
+
     save_ifs=$IFS; IFS='~'
     for cmd in $1; do
-      IFS=$save_ifs
+      IFS=$sp$nl
       eval cmd=\"$cmd\"
+      IFS=$save_ifs
       func_show_eval "$cmd" "${2-:}"
     done
     IFS=$save_ifs
@@ -1324,10 +2599,11 @@ func_execute_cmds ()
 # Note that it is not necessary on cygwin/mingw to append a dot to
 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-# `FILE.' does not work on cygwin managed mounts.
+# 'FILE.' does not work on cygwin managed mounts.
 func_source ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $1 in
     */* | *\\*)	. "$1" ;;
     *)		. "./$1" ;;
@@ -1354,10 +2630,10 @@ func_resolve_sysroot ()
 # store the result into func_replace_sysroot_result.
 func_replace_sysroot ()
 {
-  case "$lt_sysroot:$1" in
+  case $lt_sysroot:$1 in
   ?*:"$lt_sysroot"*)
     func_stripname "$lt_sysroot" '' "$1"
-    func_replace_sysroot_result="=$func_stripname_result"
+    func_replace_sysroot_result='='$func_stripname_result
     ;;
   *)
     # Including no sysroot.
@@ -1374,7 +2650,8 @@ func_replace_sysroot ()
 # arg is usually of the form 'gcc ...'
 func_infer_tag ()
 {
-    $opt_debug
+    $debug_cmd
+
     if test -n "$available_tags" && test -z "$tagname"; then
       CC_quoted=
       for arg in $CC; do
@@ -1393,7 +2670,7 @@ func_infer_tag ()
 	for z in $available_tags; do
 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
 	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
 	    CC_quoted=
 	    for arg in $CC; do
 	      # Double-quote args containing other shell metacharacters.
@@ -1418,7 +2695,7 @@ func_infer_tag ()
 	# line option must be used.
 	if test -z "$tagname"; then
 	  func_echo "unable to infer tagged configuration"
-	  func_fatal_error "specify a tag with \`--tag'"
+	  func_fatal_error "specify a tag with '--tag'"
 #	else
 #	  func_verbose "using $tagname tagged configuration"
 	fi
@@ -1434,15 +2711,15 @@ func_infer_tag ()
 # but don't create it if we're doing a dry run.
 func_write_libtool_object ()
 {
-    write_libobj=${1}
-    if test "$build_libtool_libs" = yes; then
-      write_lobj=\'${2}\'
+    write_libobj=$1
+    if test yes = "$build_libtool_libs"; then
+      write_lobj=\'$2\'
     else
       write_lobj=none
     fi
 
-    if test "$build_old_libs" = yes; then
-      write_oldobj=\'${3}\'
+    if test yes = "$build_old_libs"; then
+      write_oldobj=\'$3\'
     else
       write_oldobj=none
     fi
@@ -1450,7 +2727,7 @@ func_write_libtool_object ()
     $opt_dry_run || {
       cat >${write_libobj}T <<EOF
 # $write_libobj - a libtool object file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -1462,7 +2739,7 @@ pic_object=$write_lobj
 non_pic_object=$write_oldobj
 
 EOF
-      $MV "${write_libobj}T" "${write_libobj}"
+      $MV "${write_libobj}T" "$write_libobj"
     }
 }
 
@@ -1482,8 +2759,9 @@ EOF
 # be empty on error (or when ARG is empty)
 func_convert_core_file_wine_to_w32 ()
 {
-  $opt_debug
-  func_convert_core_file_wine_to_w32_result="$1"
+  $debug_cmd
+
+  func_convert_core_file_wine_to_w32_result=$1
   if test -n "$1"; then
     # Unfortunately, winepath does not exit with a non-zero error code, so we
     # are forced to check the contents of stdout. On the other hand, if the
@@ -1491,9 +2769,9 @@ func_convert_core_file_wine_to_w32 ()
     # *an error message* to stdout. So we must check for both error code of
     # zero AND non-empty stdout, which explains the odd construction:
     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
-    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
-        $SED -e "$lt_sed_naive_backslashify"`
+        $SED -e "$sed_naive_backslashify"`
     else
       func_convert_core_file_wine_to_w32_result=
     fi
@@ -1514,18 +2792,19 @@ func_convert_core_file_wine_to_w32 ()
 # are convertible, then the result may be empty.
 func_convert_core_path_wine_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # unfortunately, winepath doesn't convert paths, only file names
-  func_convert_core_path_wine_to_w32_result=""
+  func_convert_core_path_wine_to_w32_result=
   if test -n "$1"; then
     oldIFS=$IFS
     IFS=:
     for func_convert_core_path_wine_to_w32_f in $1; do
       IFS=$oldIFS
       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
-      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+      if test -n "$func_convert_core_file_wine_to_w32_result"; then
         if test -z "$func_convert_core_path_wine_to_w32_result"; then
-          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
         else
           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
         fi
@@ -1554,7 +2833,8 @@ func_convert_core_path_wine_to_w32 ()
 # environment variable; do not put it in $PATH.
 func_cygpath ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
     if test "$?" -ne 0; then
@@ -1563,7 +2843,7 @@ func_cygpath ()
     fi
   else
     func_cygpath_result=
-    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
   fi
 }
 #end: func_cygpath
@@ -1574,10 +2854,11 @@ func_cygpath ()
 # result in func_convert_core_msys_to_w32_result.
 func_convert_core_msys_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # awkward: cmd appends spaces to result
   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
-    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
 }
 #end: func_convert_core_msys_to_w32
 
@@ -1588,13 +2869,14 @@ func_convert_core_msys_to_w32 ()
 # func_to_host_file_result to ARG1).
 func_convert_file_check ()
 {
-  $opt_debug
-  if test -z "$2" && test -n "$1" ; then
+  $debug_cmd
+
+  if test -z "$2" && test -n "$1"; then
     func_error "Could not determine host file name corresponding to"
-    func_error "  \`$1'"
+    func_error "  '$1'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback:
-    func_to_host_file_result="$1"
+    func_to_host_file_result=$1
   fi
 }
 # end func_convert_file_check
@@ -1606,10 +2888,11 @@ func_convert_file_check ()
 # func_to_host_file_result to a simplistic fallback value (see below).
 func_convert_path_check ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$4" && test -n "$3"; then
     func_error "Could not determine the host path corresponding to"
-    func_error "  \`$3'"
+    func_error "  '$3'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback.  This is a deliberately simplistic "conversion" and
     # should not be "improved".  See libtool.info.
@@ -1618,7 +2901,7 @@ func_convert_path_check ()
       func_to_host_path_result=`echo "$3" |
         $SED -e "$lt_replace_pathsep_chars"`
     else
-      func_to_host_path_result="$3"
+      func_to_host_path_result=$3
     fi
   fi
 }
@@ -1630,9 +2913,10 @@ func_convert_path_check ()
 # and appending REPL if ORIG matches BACKPAT.
 func_convert_path_front_back_pathsep ()
 {
-  $opt_debug
+  $debug_cmd
+
   case $4 in
-  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+  $1 ) func_to_host_path_result=$3$func_to_host_path_result
     ;;
   esac
   case $4 in
@@ -1646,7 +2930,7 @@ func_convert_path_front_back_pathsep ()
 ##################################################
 # $build to $host FILE NAME CONVERSION FUNCTIONS #
 ##################################################
-# invoked via `$to_host_file_cmd ARG'
+# invoked via '$to_host_file_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # Result will be available in $func_to_host_file_result.
@@ -1657,7 +2941,8 @@ func_convert_path_front_back_pathsep ()
 # in func_to_host_file_result.
 func_to_host_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   $to_host_file_cmd "$1"
 }
 # end func_to_host_file
@@ -1669,7 +2954,8 @@ func_to_host_file ()
 # in (the comma separated) LAZY, no conversion takes place.
 func_to_tool_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   case ,$2, in
     *,"$to_tool_file_cmd",*)
       func_to_tool_file_result=$1
@@ -1687,7 +2973,7 @@ func_to_tool_file ()
 # Copy ARG to func_to_host_file_result.
 func_convert_file_noop ()
 {
-  func_to_host_file_result="$1"
+  func_to_host_file_result=$1
 }
 # end func_convert_file_noop
 
@@ -1698,11 +2984,12 @@ func_convert_file_noop ()
 # func_to_host_file_result.
 func_convert_file_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_file_result=$func_convert_core_msys_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1714,8 +3001,9 @@ func_convert_file_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_file_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
     # LT_CYGPATH in this case.
@@ -1731,11 +3019,12 @@ func_convert_file_cygwin_to_w32 ()
 # and a working winepath. Returns result in func_to_host_file_result.
 func_convert_file_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_file_wine_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1747,12 +3036,13 @@ func_convert_file_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_file_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
     func_cygpath -u "$func_convert_core_msys_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1765,13 +3055,14 @@ func_convert_file_msys_to_cygwin ()
 # in func_to_host_file_result.
 func_convert_file_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
     func_convert_core_file_wine_to_w32 "$1"
     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1781,7 +3072,7 @@ func_convert_file_nix_to_cygwin ()
 #############################################
 # $build to $host PATH CONVERSION FUNCTIONS #
 #############################################
-# invoked via `$to_host_path_cmd ARG'
+# invoked via '$to_host_path_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # The result will be available in $func_to_host_path_result.
@@ -1805,10 +3096,11 @@ func_convert_file_nix_to_cygwin ()
 to_host_path_cmd=
 func_init_to_host_path_cmd ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$to_host_path_cmd"; then
     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
-    to_host_path_cmd="func_convert_path_${func_stripname_result}"
+    to_host_path_cmd=func_convert_path_$func_stripname_result
   fi
 }
 
@@ -1818,7 +3110,8 @@ func_init_to_host_path_cmd ()
 # in func_to_host_path_result.
 func_to_host_path ()
 {
-  $opt_debug
+  $debug_cmd
+
   func_init_to_host_path_cmd
   $to_host_path_cmd "$1"
 }
@@ -1829,7 +3122,7 @@ func_to_host_path ()
 # Copy ARG to func_to_host_path_result.
 func_convert_path_noop ()
 {
-  func_to_host_path_result="$1"
+  func_to_host_path_result=$1
 }
 # end func_convert_path_noop
 
@@ -1840,8 +3133,9 @@ func_convert_path_noop ()
 # func_to_host_path_result.
 func_convert_path_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from ARG.  MSYS
     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
@@ -1849,7 +3143,7 @@ func_convert_path_msys_to_w32 ()
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_path_result=$func_convert_core_msys_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1863,8 +3157,9 @@ func_convert_path_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_path_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
@@ -1883,14 +3178,15 @@ func_convert_path_cygwin_to_w32 ()
 # a working winepath.  Returns result in func_to_host_file_result.
 func_convert_path_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1904,15 +3200,16 @@ func_convert_path_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_path_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1927,8 +3224,9 @@ func_convert_path_msys_to_cygwin ()
 # func_to_host_file_result.
 func_convert_path_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from
     # ARG. msys behavior is inconsistent here, cygpath turns them
@@ -1937,7 +3235,7 @@ func_convert_path_nix_to_cygwin ()
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1946,13 +3244,31 @@ func_convert_path_nix_to_cygwin ()
 # end func_convert_path_nix_to_cygwin
 
 
+# func_dll_def_p FILE
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with _LT_DLL_DEF_P in libtool.m4
+func_dll_def_p ()
+{
+  $debug_cmd
+
+  func_dll_def_p_tmp=`$SED -n \
+    -e 's/^[	 ]*//' \
+    -e '/^\(;.*\)*$/d' \
+    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
+    -e q \
+    "$1"`
+  test DEF = "$func_dll_def_p_tmp"
+}
+
+
 # func_mode_compile arg...
 func_mode_compile ()
 {
-    $opt_debug
+    $debug_cmd
+
     # Get the compilation command and the source file.
     base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
     suppress_opt=yes
     suppress_output=
     arg_mode=normal
@@ -1965,12 +3281,12 @@ func_mode_compile ()
       case $arg_mode in
       arg  )
 	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
+	lastarg=$arg
 	arg_mode=normal
 	;;
 
       target )
-	libobj="$arg"
+	libobj=$arg
 	arg_mode=normal
 	continue
 	;;
@@ -1980,7 +3296,7 @@ func_mode_compile ()
 	case $arg in
 	-o)
 	  test -n "$libobj" && \
-	    func_fatal_error "you cannot specify \`-o' more than once"
+	    func_fatal_error "you cannot specify '-o' more than once"
 	  arg_mode=target
 	  continue
 	  ;;
@@ -2009,12 +3325,12 @@ func_mode_compile ()
 	  func_stripname '-Wc,' '' "$arg"
 	  args=$func_stripname_result
 	  lastarg=
-	  save_ifs="$IFS"; IFS=','
+	  save_ifs=$IFS; IFS=,
 	  for arg in $args; do
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 	    func_append_quoted lastarg "$arg"
 	  done
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
 	  func_stripname ' ' '' "$lastarg"
 	  lastarg=$func_stripname_result
 
@@ -2027,8 +3343,8 @@ func_mode_compile ()
 	  # Accept the current argument as the source file.
 	  # The previous "srcfile" becomes the current argument.
 	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
+	  lastarg=$srcfile
+	  srcfile=$arg
 	  ;;
 	esac  #  case $arg
 	;;
@@ -2043,13 +3359,13 @@ func_mode_compile ()
       func_fatal_error "you must specify an argument for -Xcompile"
       ;;
     target)
-      func_fatal_error "you must specify a target with \`-o'"
+      func_fatal_error "you must specify a target with '-o'"
       ;;
     *)
       # Get the name of the library object.
       test -z "$libobj" && {
 	func_basename "$srcfile"
-	libobj="$func_basename_result"
+	libobj=$func_basename_result
       }
       ;;
     esac
@@ -2069,7 +3385,7 @@ func_mode_compile ()
     case $libobj in
     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
     *)
-      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      func_fatal_error "cannot determine name of library object from '$libobj'"
       ;;
     esac
 
@@ -2078,8 +3394,8 @@ func_mode_compile ()
     for arg in $later; do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes = "$build_libtool_libs" \
+	  || func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	continue
 	;;
@@ -2105,17 +3421,17 @@ func_mode_compile ()
     func_quote_for_eval "$libobj"
     test "X$libobj" != "X$func_quote_for_eval_result" \
       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
-      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+      && func_warning "libobj name '$libobj' may not contain shell special characters."
     func_dirname_and_basename "$obj" "/" ""
-    objname="$func_basename_result"
-    xdir="$func_dirname_result"
-    lobj=${xdir}$objdir/$objname
+    objname=$func_basename_result
+    xdir=$func_dirname_result
+    lobj=$xdir$objdir/$objname
 
     test -z "$base_compile" && \
       func_fatal_help "you must specify a compilation command"
 
     # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       removelist="$obj $lobj $libobj ${libobj}T"
     else
       removelist="$lobj $libobj ${libobj}T"
@@ -2127,16 +3443,16 @@ func_mode_compile ()
       pic_mode=default
       ;;
     esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
       # non-PIC code in shared libraries is not supported
       pic_mode=default
     fi
 
     # Calculate the filename of the output object if compiler does
     # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
+    if test no = "$compiler_c_o"; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
+      lockfile=$output_obj.lock
     else
       output_obj=
       need_locks=no
@@ -2145,12 +3461,12 @@ func_mode_compile ()
 
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
+    if test yes = "$need_locks"; then
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
 	sleep 2
       done
-    elif test "$need_locks" = warn; then
+    elif test warn = "$need_locks"; then
       if test -f "$lockfile"; then
 	$ECHO "\
 *** ERROR, $lockfile exists and contains:
@@ -2158,7 +3474,7 @@ func_mode_compile ()
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2180,11 +3496,11 @@ compiler."
     qsrcfile=$func_quote_for_eval_result
 
     # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       # Without this assignment, base_compile gets emptied.
       fbsd_hideous_sh_bug=$base_compile
 
-      if test "$pic_mode" != no; then
+      if test no != "$pic_mode"; then
 	command="$base_compile $qsrcfile $pic_flag"
       else
 	# Don't build PIC code
@@ -2201,7 +3517,7 @@ compiler."
       func_show_eval_locale "$command"	\
           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2212,7 +3528,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2228,20 +3544,20 @@ compiler."
       fi
 
       # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
+      if test yes = "$suppress_opt"; then
 	suppress_output=' >/dev/null 2>&1'
       fi
     fi
 
     # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
+    if test yes = "$build_old_libs"; then
+      if test yes != "$pic_mode"; then
 	# Don't build PIC code
 	command="$base_compile $qsrcfile$pie_flag"
       else
 	command="$base_compile $qsrcfile $pic_flag"
       fi
-      if test "$compiler_c_o" = yes; then
+      if test yes = "$compiler_c_o"; then
 	func_append command " -o $obj"
       fi
 
@@ -2250,7 +3566,7 @@ compiler."
       func_show_eval_locale "$command" \
         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2261,7 +3577,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2281,7 +3597,7 @@ compiler."
       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
 
       # Unlock the critical section if it was locked
-      if test "$need_locks" != no; then
+      if test no != "$need_locks"; then
 	removelist=$lockfile
         $RM "$lockfile"
       fi
@@ -2291,7 +3607,7 @@ compiler."
 }
 
 $opt_help || {
-  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
 }
 
 func_mode_help ()
@@ -2311,7 +3627,7 @@ func_mode_help ()
 Remove files from the build directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, object or program, all the files associated
@@ -2330,16 +3646,16 @@ This mode accepts the following additional options:
   -no-suppress      do not suppress compiler output for multiple passes
   -prefer-pic       try to build PIC objects only
   -prefer-non-pic   try to build non-PIC objects only
-  -shared           do not build a \`.o' file suitable for static linking
-  -static           only build a \`.o' file suitable for static linking
+  -shared           do not build a '.o' file suitable for static linking
+  -static           only build a '.o' file suitable for static linking
   -Wc,FLAG          pass FLAG directly to the compiler
 
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+COMPILE-COMMAND is a command to be used in creating a 'standard' object file
 from the given SOURCEFILE.
 
 The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
+SOURCEFILE, then substituting the C source code suffix '.c' with the
+library object suffix, '.lo'."
         ;;
 
       execute)
@@ -2352,7 +3668,7 @@ This mode accepts the following additional options:
 
   -dlopen FILE      add the directory containing FILE to the library path
 
-This mode sets the library path environment variable according to \`-dlopen'
+This mode sets the library path environment variable according to '-dlopen'
 flags.
 
 If any of the ARGS are libtool executable wrappers, then they are translated
@@ -2371,7 +3687,7 @@ Complete the installation of libtool libraries.
 Each LIBDIR is a directory that contains libtool libraries.
 
 The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
+the '--dry-run' option if you just want to see what would be executed."
         ;;
 
       install)
@@ -2381,7 +3697,7 @@ the \`--dry-run' option if you just want to see what would be executed."
 Install executables or libraries.
 
 INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
+either the 'install' or 'cp' program.
 
 The following components of INSTALL-COMMAND are treated specially:
 
@@ -2407,7 +3723,7 @@ The following components of LINK-COMMAND are treated specially:
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
@@ -2421,7 +3737,8 @@ The following components of LINK-COMMAND are treated specially:
   -no-install       link a not-installable executable
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -objectlist FILE  use a list of object files found in FILE to specify objects
+  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
   -precious-files-regex REGEX
                     don't remove output files matching REGEX
   -release RELEASE  specify package release information
@@ -2441,20 +3758,20 @@ The following components of LINK-COMMAND are treated specially:
   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
 
-All other options (arguments beginning with \`-') are ignored.
+All other options (arguments beginning with '-') are ignored.
 
-Every other argument is treated as a filename.  Files ending in \`.la' are
+Every other argument is treated as a filename.  Files ending in '.la' are
 treated as uninstalled libtool libraries, other files are standard or library
 object files.
 
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
+If the OUTPUT-FILE ends in '.la', then a libtool library is created,
+only library objects ('.lo' files) may be specified, and '-rpath' is
 required, except when creating a convenience library.
 
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
+If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
+using 'ar' and 'ranlib', or on Windows using 'lib'.
 
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
 is created, otherwise an executable program is created."
         ;;
 
@@ -2465,7 +3782,7 @@ is created, otherwise an executable program is created."
 Remove libraries from an installation directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, all the files associated with it are deleted.
@@ -2473,17 +3790,17 @@ Otherwise, only FILE itself is deleted using RM."
         ;;
 
       *)
-        func_fatal_help "invalid operation mode \`$opt_mode'"
+        func_fatal_help "invalid operation mode '$opt_mode'"
         ;;
     esac
 
     echo
-    $ECHO "Try \`$progname --help' for more information about other modes."
+    $ECHO "Try '$progname --help' for more information about other modes."
 }
 
 # Now that we've collected a possible --mode arg, show help if necessary
 if $opt_help; then
-  if test "$opt_help" = :; then
+  if test : = "$opt_help"; then
     func_mode_help
   else
     {
@@ -2491,7 +3808,7 @@ if $opt_help; then
       for opt_mode in compile link execute install finish uninstall clean; do
 	func_mode_help
       done
-    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
     {
       func_help noexit
       for opt_mode in compile link execute install finish uninstall clean; do
@@ -2499,7 +3816,7 @@ if $opt_help; then
 	func_mode_help
       done
     } |
-    sed '1d
+    $SED '1d
       /^When reporting/,/^Report/{
 	H
 	d
@@ -2516,16 +3833,17 @@ fi
 # func_mode_execute arg...
 func_mode_execute ()
 {
-    $opt_debug
+    $debug_cmd
+
     # The first argument is the command name.
-    cmd="$nonopt"
+    cmd=$nonopt
     test -z "$cmd" && \
       func_fatal_help "you must specify a COMMAND"
 
     # Handle -dlopen flags immediately.
     for file in $opt_dlopen; do
       test -f "$file" \
-	|| func_fatal_help "\`$file' is not a file"
+	|| func_fatal_help "'$file' is not a file"
 
       dir=
       case $file in
@@ -2535,7 +3853,7 @@ func_mode_execute ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+	  || func_fatal_help "'$lib' is not a valid libtool archive"
 
 	# Read the libtool library.
 	dlname=
@@ -2546,18 +3864,18 @@ func_mode_execute ()
 	if test -z "$dlname"; then
 	  # Warn if it was a shared library.
 	  test -n "$library_names" && \
-	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	    func_warning "'$file' was not linked with '-export-dynamic'"
 	  continue
 	fi
 
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 
 	if test -f "$dir/$objdir/$dlname"; then
 	  func_append dir "/$objdir"
 	else
 	  if test ! -f "$dir/$dlname"; then
-	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
 	  fi
 	fi
 	;;
@@ -2565,18 +3883,18 @@ func_mode_execute ()
       *.lo)
 	# Just add the directory containing the .lo file.
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	;;
 
       *)
-	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
 	continue
 	;;
       esac
 
       # Get the absolute pathname.
       absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
+      test -n "$absdir" && dir=$absdir
 
       # Now add the directory to shlibpath_var.
       if eval "test -z \"\$$shlibpath_var\""; then
@@ -2588,7 +3906,7 @@ func_mode_execute ()
 
     # This variable tells wrapper scripts just to set shlibpath_var
     # rather than running their programs.
-    libtool_execute_magic="$magic"
+    libtool_execute_magic=$magic
 
     # Check if any of the arguments is a wrapper script.
     args=
@@ -2601,12 +3919,12 @@ func_mode_execute ()
 	if func_ltwrapper_script_p "$file"; then
 	  func_source "$file"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	elif func_ltwrapper_executable_p "$file"; then
 	  func_ltwrapper_scriptname "$file"
 	  func_source "$func_ltwrapper_scriptname_result"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	fi
 	;;
       esac
@@ -2614,7 +3932,15 @@ func_mode_execute ()
       func_append_quoted args "$file"
     done
 
-    if test "X$opt_dry_run" = Xfalse; then
+    if $opt_dry_run; then
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    else
       if test -n "$shlibpath_var"; then
 	# Export the shlibpath_var.
 	eval "export $shlibpath_var"
@@ -2631,25 +3957,18 @@ func_mode_execute ()
       done
 
       # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
-	echo "export $shlibpath_var"
-      fi
-      $ECHO "$cmd$args"
-      exit $EXIT_SUCCESS
+      exec_cmd=\$cmd$args
     fi
 }
 
-test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
 
 
 # func_mode_finish arg...
 func_mode_finish ()
 {
-    $opt_debug
+    $debug_cmd
+
     libs=
     libdirs=
     admincmds=
@@ -2663,11 +3982,11 @@ func_mode_finish ()
 	if func_lalib_unsafe_p "$opt"; then
 	  func_append libs " $opt"
 	else
-	  func_warning "\`$opt' is not a valid libtool archive"
+	  func_warning "'$opt' is not a valid libtool archive"
 	fi
 
       else
-	func_fatal_error "invalid argument \`$opt'"
+	func_fatal_error "invalid argument '$opt'"
       fi
     done
 
@@ -2682,12 +4001,12 @@ func_mode_finish ()
       # Remove sysroot references
       if $opt_dry_run; then
         for lib in $libs; do
-          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
         done
       else
         tmpdir=`func_mktempdir`
         for lib in $libs; do
-	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
 	    > $tmpdir/tmp-la
 	  mv -f $tmpdir/tmp-la $lib
 	done
@@ -2712,7 +4031,7 @@ func_mode_finish ()
     fi
 
     # Exit here if they wanted silent mode.
-    $opt_silent && exit $EXIT_SUCCESS
+    $opt_quiet && exit $EXIT_SUCCESS
 
     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
       echo "----------------------------------------------------------------------"
@@ -2723,27 +4042,27 @@ func_mode_finish ()
       echo
       echo "If you ever happen to want to link against installed libraries"
       echo "in a given directory, LIBDIR, you must either use libtool, and"
-      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
       echo "flag during linking and do at least one of the following:"
       if test -n "$shlibpath_var"; then
-	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
 	echo "     during execution"
       fi
       if test -n "$runpath_var"; then
-	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+	echo "   - add LIBDIR to the '$runpath_var' environment variable"
 	echo "     during linking"
       fi
       if test -n "$hardcode_libdir_flag_spec"; then
 	libdir=LIBDIR
 	eval flag=\"$hardcode_libdir_flag_spec\"
 
-	$ECHO "   - use the \`$flag' linker flag"
+	$ECHO "   - use the '$flag' linker flag"
       fi
       if test -n "$admincmds"; then
 	$ECHO "   - have your system administrator run these commands:$admincmds"
       fi
       if test -f /etc/ld.so.conf; then
-	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
       fi
       echo
 
@@ -2762,18 +4081,20 @@ func_mode_finish ()
     exit $EXIT_SUCCESS
 }
 
-test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
 
 
 # func_mode_install arg...
 func_mode_install ()
 {
-    $opt_debug
+    $debug_cmd
+
     # There may be an optional sh(1) argument at the beginning of
     # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
        # Allow the use of GNU shtool's install command.
-       case $nonopt in *shtool*) :;; *) false;; esac; then
+       case $nonopt in *shtool*) :;; *) false;; esac
+    then
       # Aesthetically quote it.
       func_quote_for_eval "$nonopt"
       install_prog="$func_quote_for_eval_result "
@@ -2800,7 +4121,7 @@ func_mode_install ()
     opts=
     prev=
     install_type=
-    isdir=no
+    isdir=false
     stripme=
     no_mode=:
     for arg
@@ -2813,7 +4134,7 @@ func_mode_install ()
       fi
 
       case $arg in
-      -d) isdir=yes ;;
+      -d) isdir=: ;;
       -f)
 	if $install_cp; then :; else
 	  prev=$arg
@@ -2831,7 +4152,7 @@ func_mode_install ()
       *)
 	# If the previous option needed an argument, then skip it.
 	if test -n "$prev"; then
-	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
+	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
 	    arg2=$install_override_mode
 	    no_mode=false
 	  fi
@@ -2856,7 +4177,7 @@ func_mode_install ()
       func_fatal_help "you must specify an install program"
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prev' option requires an argument"
+      func_fatal_help "the '$prev' option requires an argument"
 
     if test -n "$install_override_mode" && $no_mode; then
       if $install_cp; then :; else
@@ -2878,19 +4199,19 @@ func_mode_install ()
     dest=$func_stripname_result
 
     # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
+    test -d "$dest" && isdir=:
+    if $isdir; then
+      destdir=$dest
       destname=
     else
       func_dirname_and_basename "$dest" "" "."
-      destdir="$func_dirname_result"
-      destname="$func_basename_result"
+      destdir=$func_dirname_result
+      destname=$func_basename_result
 
       # Not a directory, so check to see that there is only one file specified.
       set dummy $files; shift
       test "$#" -gt 1 && \
-	func_fatal_help "\`$dest' is not a directory"
+	func_fatal_help "'$dest' is not a directory"
     fi
     case $destdir in
     [\\/]* | [A-Za-z]:[\\/]*) ;;
@@ -2899,7 +4220,7 @@ func_mode_install ()
 	case $file in
 	*.lo) ;;
 	*)
-	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  func_fatal_help "'$destdir' must be an absolute directory name"
 	  ;;
 	esac
       done
@@ -2908,7 +4229,7 @@ func_mode_install ()
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     staticlibs=
     future_libdirs=
@@ -2928,7 +4249,7 @@ func_mode_install ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$file' is not a valid libtool archive"
+	  || func_fatal_help "'$file' is not a valid libtool archive"
 
 	library_names=
 	old_library=
@@ -2950,7 +4271,7 @@ func_mode_install ()
 	fi
 
 	func_dirname "$file" "/" ""
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	func_append dir "$objdir"
 
 	if test -n "$relink_command"; then
@@ -2964,7 +4285,7 @@ func_mode_install ()
 	  # are installed into $libdir/../bin (currently, that works fine)
 	  # but it's something to keep an eye on.
 	  test "$inst_prefix_dir" = "$destdir" && \
-	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
@@ -2973,29 +4294,36 @@ func_mode_install ()
 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
 	  fi
 
-	  func_warning "relinking \`$file'"
+	  func_warning "relinking '$file'"
 	  func_show_eval "$relink_command" \
-	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
 	fi
 
 	# See the names of the shared library.
 	set dummy $library_names; shift
 	if test -n "$1"; then
-	  realname="$1"
+	  realname=$1
 	  shift
 
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
+	  srcname=$realname
+	  test -n "$relink_command" && srcname=${realname}T
 
 	  # Install the shared library and build the symlinks.
 	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
 	      'exit $?'
-	  tstripme="$stripme"
+	  tstripme=$stripme
 	  case $host_os in
 	  cygwin* | mingw* | pw32* | cegcc*)
 	    case $realname in
 	    *.dll.a)
-	      tstripme=""
+	      tstripme=
+	      ;;
+	    esac
+	    ;;
+	  os2*)
+	    case $realname in
+	    *_dll.a)
+	      tstripme=
 	      ;;
 	    esac
 	    ;;
@@ -3006,7 +4334,7 @@ func_mode_install ()
 
 	  if test "$#" -gt 0; then
 	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # Try 'ln -sf' first, because the 'ln' binary might depend on
 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
 	    # so we also need to try rm && ln -s.
 	    for linkname
@@ -3017,14 +4345,14 @@ func_mode_install ()
 	  fi
 
 	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
+	  lib=$destdir/$realname
 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
 	fi
 
 	# Install the pseudo-library for information purposes.
 	func_basename "$file"
-	name="$func_basename_result"
-	instname="$dir/$name"i
+	name=$func_basename_result
+	instname=$dir/${name}i
 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
 
 	# Maybe install the static library, too.
@@ -3036,11 +4364,11 @@ func_mode_install ()
 
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# Deduce the name of the destination old-style object file.
@@ -3050,11 +4378,11 @@ func_mode_install ()
 	  staticdest=$func_lo2o_result
 	  ;;
 	*.$objext)
-	  staticdest="$destfile"
+	  staticdest=$destfile
 	  destfile=
 	  ;;
 	*)
-	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  func_fatal_help "cannot copy a libtool object to '$destfile'"
 	  ;;
 	esac
 
@@ -3063,7 +4391,7 @@ func_mode_install ()
 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
 
 	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
+	if test yes = "$build_old_libs"; then
 	  # Deduce the name of the old-style object file.
 	  func_lo2o "$file"
 	  staticobj=$func_lo2o_result
@@ -3075,23 +4403,23 @@ func_mode_install ()
       *)
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# If the file is missing, and there is a .exe on the end, strip it
 	# because it is most likely a libtool script we actually want to
 	# install
-	stripped_ext=""
+	stripped_ext=
 	case $file in
 	  *.exe)
 	    if test ! -f "$file"; then
 	      func_stripname '' '.exe' "$file"
 	      file=$func_stripname_result
-	      stripped_ext=".exe"
+	      stripped_ext=.exe
 	    fi
 	    ;;
 	esac
@@ -3119,19 +4447,19 @@ func_mode_install ()
 
 	  # Check the variables that should have been set.
 	  test -z "$generated_by_libtool_version" && \
-	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
 
-	  finalize=yes
+	  finalize=:
 	  for lib in $notinst_deplibs; do
 	    # Check to see that each library is installed.
 	    libdir=
 	    if test -f "$lib"; then
 	      func_source "$lib"
 	    fi
-	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
 	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      func_warning "\`$lib' has not been installed in \`$libdir'"
-	      finalize=no
+	      func_warning "'$lib' has not been installed in '$libdir'"
+	      finalize=false
 	    fi
 	  done
 
@@ -3139,29 +4467,29 @@ func_mode_install ()
 	  func_source "$wrapper"
 
 	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
+	  if test no = "$fast_install" && test -n "$relink_command"; then
 	    $opt_dry_run || {
-	      if test "$finalize" = yes; then
+	      if $finalize; then
 	        tmpdir=`func_mktempdir`
 		func_basename "$file$stripped_ext"
-		file="$func_basename_result"
-	        outputname="$tmpdir/$file"
+		file=$func_basename_result
+	        outputname=$tmpdir/$file
 	        # Replace the output file specification.
 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
 
-	        $opt_silent || {
+	        $opt_quiet || {
 	          func_quote_for_expand "$relink_command"
 		  eval "func_echo $func_quote_for_expand_result"
 	        }
 	        if eval "$relink_command"; then :
 	          else
-		  func_error "error: relink \`$file' with the above command before installing it"
+		  func_error "error: relink '$file' with the above command before installing it"
 		  $opt_dry_run || ${RM}r "$tmpdir"
 		  continue
 	        fi
-	        file="$outputname"
+	        file=$outputname
 	      else
-	        func_warning "cannot relink \`$file'"
+	        func_warning "cannot relink '$file'"
 	      fi
 	    }
 	  else
@@ -3198,10 +4526,10 @@ func_mode_install ()
 
     for file in $staticlibs; do
       func_basename "$file"
-      name="$func_basename_result"
+      name=$func_basename_result
 
       # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
+      oldlib=$destdir/$name
       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
       tool_oldlib=$func_to_tool_file_result
 
@@ -3216,18 +4544,18 @@ func_mode_install ()
     done
 
     test -n "$future_libdirs" && \
-      func_warning "remember to run \`$progname --finish$future_libdirs'"
+      func_warning "remember to run '$progname --finish$future_libdirs'"
 
     if test -n "$current_libdirs"; then
       # Maybe just do a dry run.
       $opt_dry_run && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
     else
       exit $EXIT_SUCCESS
     fi
 }
 
-test "$opt_mode" = install && func_mode_install ${1+"$@"}
+test install = "$opt_mode" && func_mode_install ${1+"$@"}
 
 
 # func_generate_dlsyms outputname originator pic_p
@@ -3235,16 +4563,17 @@ test "$opt_mode" = install && func_mode_install ${1+"$@"}
 # a dlpreopen symbol table.
 func_generate_dlsyms ()
 {
-    $opt_debug
-    my_outputname="$1"
-    my_originator="$2"
-    my_pic_p="${3-no}"
-    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    $debug_cmd
+
+    my_outputname=$1
+    my_originator=$2
+    my_pic_p=${3-false}
+    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
     my_dlsyms=
 
-    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
       if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	my_dlsyms="${my_outputname}S.c"
+	my_dlsyms=${my_outputname}S.c
       else
 	func_error "not configured to extract global symbols from dlpreopened files"
       fi
@@ -3255,7 +4584,7 @@ func_generate_dlsyms ()
       "") ;;
       *.c)
 	# Discover the nlist of each of the dlfiles.
-	nlist="$output_objdir/${my_outputname}.nm"
+	nlist=$output_objdir/$my_outputname.nm
 
 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
 
@@ -3263,34 +4592,36 @@ func_generate_dlsyms ()
 	func_verbose "creating $output_objdir/$my_dlsyms"
 
 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
-/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
-/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
 
 #ifdef __cplusplus
 extern \"C\" {
 #endif
 
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
 #endif
 
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
 # define LT_DLSYM_CONST const
 #endif
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* External symbol declarations for the compiler. */\
 "
 
-	if test "$dlself" = yes; then
-	  func_verbose "generating symbol list for \`$output'"
+	if test yes = "$dlself"; then
+	  func_verbose "generating symbol list for '$output'"
 
 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
 
@@ -3298,7 +4629,7 @@ extern \"C\" {
 	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	  for progfile in $progfiles; do
 	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
-	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
 	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
 	  done
 
@@ -3318,10 +4649,10 @@ extern \"C\" {
 
 	  # Prepare the list of exported symbols
 	  if test -z "$export_symbols"; then
-	    export_symbols="$output_objdir/$outputname.exp"
+	    export_symbols=$output_objdir/$outputname.exp
 	    $opt_dry_run || {
 	      $RM $export_symbols
-	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 	      case $host in
 	      *cygwin* | *mingw* | *cegcc* )
                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
@@ -3331,7 +4662,7 @@ extern \"C\" {
 	    }
 	  else
 	    $opt_dry_run || {
-	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 	      eval '$MV "$nlist"T "$nlist"'
 	      case $host in
@@ -3345,22 +4676,22 @@ extern \"C\" {
 	fi
 
 	for dlprefile in $dlprefiles; do
-	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_verbose "extracting global C symbols from '$dlprefile'"
 	  func_basename "$dlprefile"
-	  name="$func_basename_result"
+	  name=$func_basename_result
           case $host in
 	    *cygwin* | *mingw* | *cegcc* )
 	      # if an import library, we need to obtain dlname
 	      if func_win32_import_lib_p "$dlprefile"; then
 	        func_tr_sh "$dlprefile"
 	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
-	        dlprefile_dlbasename=""
+	        dlprefile_dlbasename=
 	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
 	          # Use subshell, to avoid clobbering current variable values
 	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
-	          if test -n "$dlprefile_dlname" ; then
+	          if test -n "$dlprefile_dlname"; then
 	            func_basename "$dlprefile_dlname"
-	            dlprefile_dlbasename="$func_basename_result"
+	            dlprefile_dlbasename=$func_basename_result
 	          else
 	            # no lafile. user explicitly requested -dlpreopen <import library>.
 	            $sharedlib_from_linklib_cmd "$dlprefile"
@@ -3368,7 +4699,7 @@ extern \"C\" {
 	          fi
 	        fi
 	        $opt_dry_run || {
-	          if test -n "$dlprefile_dlbasename" ; then
+	          if test -n "$dlprefile_dlbasename"; then
 	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
 	          else
 	            func_warning "Could not compute DLL name from $name"
@@ -3424,6 +4755,11 @@ extern \"C\" {
 	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
 	  fi
 
+	  func_show_eval '$RM "${nlist}I"'
+	  if test -n "$global_symbol_to_import"; then
+	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
+	  fi
+
 	  echo >> "$output_objdir/$my_dlsyms" "\
 
 /* The mapping between symbol names and symbols.  */
@@ -3432,11 +4768,30 @@ typedef struct {
   void *address;
 } lt_dlsymlist;
 extern LT_DLSYM_CONST lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[];
+lt_${my_prefix}_LTX_preloaded_symbols[];\
+"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+static void lt_syminit(void)
+{
+  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
+  for (; symbol->name; ++symbol)
+    {"
+	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
+	    echo >> "$output_objdir/$my_dlsyms" "\
+    }
+}"
+	  fi
+	  echo >> "$output_objdir/$my_dlsyms" "\
 LT_DLSYM_CONST lt_dlsymlist
 lt_${my_prefix}_LTX_preloaded_symbols[] =
-{\
-  { \"$my_originator\", (void *) 0 },"
+{ {\"$my_originator\", (void *) 0},"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+  {\"@INIT@\", (void *) &lt_syminit},"
+	  fi
 
 	  case $need_lib_prefix in
 	  no)
@@ -3478,9 +4833,7 @@ static const void *lt_preloaded_setup() {
 	  *-*-hpux*)
 	    pic_flag_for_symtable=" $pic_flag"  ;;
 	  *)
-	    if test "X$my_pic_p" != Xno; then
-	      pic_flag_for_symtable=" $pic_flag"
-	    fi
+	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
 	    ;;
 	  esac
 	  ;;
@@ -3497,10 +4850,10 @@ static const void *lt_preloaded_setup() {
 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
 
 	# Clean up the generated files.
-	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
 
 	# Transform the symbol file into the correct name.
-	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	symfileobj=$output_objdir/${my_outputname}S.$objext
 	case $host in
 	*cygwin* | *mingw* | *cegcc* )
 	  if test -f "$output_objdir/$my_outputname.def"; then
@@ -3518,7 +4871,7 @@ static const void *lt_preloaded_setup() {
 	esac
 	;;
       *)
-	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	func_fatal_error "unknown suffix for '$my_dlsyms'"
 	;;
       esac
     else
@@ -3532,6 +4885,32 @@ static const void *lt_preloaded_setup() {
     fi
 }
 
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+  test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+  test -n "$func_cygming_ms_implib_tmp"
+}
+
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -3541,8 +4920,9 @@ static const void *lt_preloaded_setup() {
 # Despite the name, also deal with 64 bit binaries.
 func_win32_libid ()
 {
-  $opt_debug
-  win32_libid_type="unknown"
+  $debug_cmd
+
+  win32_libid_type=unknown
   win32_fileres=`file -L $1 2>/dev/null`
   case $win32_fileres in
   *ar\ archive\ import\ library*) # definitely import
@@ -3552,16 +4932,29 @@ func_win32_libid ()
     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
-      func_to_tool_file "$1" func_convert_file_msys_to_w32
-      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
-	$SED -n -e '
+      case $nm_interface in
+      "MS dumpbin")
+	if func_cygming_ms_implib_p "$1" ||
+	   func_cygming_gnu_implib_p "$1"
+	then
+	  win32_nmres=import
+	else
+	  win32_nmres=
+	fi
+	;;
+      *)
+	func_to_tool_file "$1" func_convert_file_msys_to_w32
+	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+	  $SED -n -e '
 	    1,100{
 		/ I /{
-		    s,.*,import,
+		    s|.*|import|
 		    p
 		    q
 		}
 	    }'`
+	;;
+      esac
       case $win32_nmres in
       import*)  win32_libid_type="x86 archive import";;
       *)        win32_libid_type="x86 archive static";;
@@ -3593,7 +4986,8 @@ func_win32_libid ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib ()
 {
-  $opt_debug
+  $debug_cmd
+
   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
 }
 
@@ -3610,7 +5004,8 @@ func_cygming_dll_for_implib ()
 # specified import library.
 func_cygming_dll_for_implib_fallback_core ()
 {
-  $opt_debug
+  $debug_cmd
+
   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
     $SED '/^Contents of section '"$match_literal"':/{
@@ -3646,8 +5041,8 @@ func_cygming_dll_for_implib_fallback_core ()
       /./p' |
     # we now have a list, one entry per line, of the stringified
     # contents of the appropriate section of all members of the
-    # archive which possess that section. Heuristic: eliminate
-    # all those which have a first or second character that is
+    # archive that possess that section. Heuristic: eliminate
+    # all those that have a first or second character that is
     # a '.' (that is, objdump's representation of an unprintable
     # character.) This should work for all archives with less than
     # 0x302f exports -- but will fail for DLLs whose name actually
@@ -3658,30 +5053,6 @@ func_cygming_dll_for_implib_fallback_core ()
     $SED -e '/^\./d;/^.\./d;q'
 }
 
-# func_cygming_gnu_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is a GNU/binutils-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_gnu_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
-  test -n "$func_cygming_gnu_implib_tmp"
-}
-
-# func_cygming_ms_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is an MS-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_ms_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
-  test -n "$func_cygming_ms_implib_tmp"
-}
-
 # func_cygming_dll_for_implib_fallback ARG
 # Platform-specific function to extract the
 # name of the DLL associated with the specified
@@ -3695,16 +5066,17 @@ func_cygming_ms_implib_p ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib_fallback ()
 {
-  $opt_debug
-  if func_cygming_gnu_implib_p "$1" ; then
+  $debug_cmd
+
+  if func_cygming_gnu_implib_p "$1"; then
     # binutils import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
-  elif func_cygming_ms_implib_p "$1" ; then
+  elif func_cygming_ms_implib_p "$1"; then
     # ms-generated import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
   else
     # unknown
-    sharedlib_from_linklib_result=""
+    sharedlib_from_linklib_result=
   fi
 }
 
@@ -3712,10 +5084,11 @@ func_cygming_dll_for_implib_fallback ()
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
-    $opt_debug
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-    if test "$lock_old_archive_extraction" = yes; then
+    $debug_cmd
+
+    f_ex_an_ar_dir=$1; shift
+    f_ex_an_ar_oldlib=$1
+    if test yes = "$lock_old_archive_extraction"; then
       lockfile=$f_ex_an_ar_oldlib.lock
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
@@ -3724,7 +5097,7 @@ func_extract_an_archive ()
     fi
     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
 		   'stat=$?; rm -f "$lockfile"; exit $stat'
-    if test "$lock_old_archive_extraction" = yes; then
+    if test yes = "$lock_old_archive_extraction"; then
       $opt_dry_run || rm -f "$lockfile"
     fi
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
@@ -3738,22 +5111,23 @@ func_extract_an_archive ()
 # func_extract_archives gentop oldlib ...
 func_extract_archives ()
 {
-    $opt_debug
-    my_gentop="$1"; shift
+    $debug_cmd
+
+    my_gentop=$1; shift
     my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
+    my_oldobjs=
+    my_xlib=
+    my_xabs=
+    my_xdir=
 
     for my_xlib in $my_oldlibs; do
       # Extract the objects.
       case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       func_basename "$my_xlib"
-      my_xlib="$func_basename_result"
+      my_xlib=$func_basename_result
       my_xlib_u=$my_xlib
       while :; do
         case " $extracted_archives " in
@@ -3765,7 +5139,7 @@ func_extract_archives ()
 	esac
       done
       extracted_archives="$extracted_archives $my_xlib_u"
-      my_xdir="$my_gentop/$my_xlib_u"
+      my_xdir=$my_gentop/$my_xlib_u
 
       func_mkdir_p "$my_xdir"
 
@@ -3778,22 +5152,23 @@ func_extract_archives ()
 	  cd $my_xdir || exit $?
 	  darwin_archive=$my_xabs
 	  darwin_curdir=`pwd`
-	  darwin_base_archive=`basename "$darwin_archive"`
+	  func_basename "$darwin_archive"
+	  darwin_base_archive=$func_basename_result
 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
 	  if test -n "$darwin_arches"; then
 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
 	    darwin_arch=
 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	    for darwin_arch in  $darwin_arches; do
+	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
+	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
 	      cd "$darwin_curdir"
-	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
 	    done # $darwin_arches
             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
 	    darwin_file=
 	    darwin_files=
 	    for darwin_file in $darwin_filelist; do
@@ -3815,7 +5190,7 @@ func_extract_archives ()
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
     done
 
-    func_extract_archives_result="$my_oldobjs"
+    func_extract_archives_result=$my_oldobjs
 }
 
 
@@ -3830,7 +5205,7 @@ func_extract_archives ()
 #
 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
 # variable will take.  If 'yes', then the emitted script
-# will assume that the directory in which it is stored is
+# will assume that the directory where it is stored is
 # the $objdir directory.  This is a cygwin/mingw-specific
 # behavior.
 func_emit_wrapper ()
@@ -3841,7 +5216,7 @@ func_emit_wrapper ()
 #! $SHELL
 
 # $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # The $output program cannot be directly executed until all the libtool
 # libraries that it depends on are installed.
@@ -3898,9 +5273,9 @@ _LTECHO_EOF'
 
 # Very basic option parsing. These options are (a) specific to
 # the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
+# /script/ and the wrapper /executable/ that is used only on
 # windows platforms, and (c) all begin with the string "--lt-"
-# (application programs are unlikely to have options which match
+# (application programs are unlikely to have options that match
 # this pattern).
 #
 # There are only two supported options: --lt-debug and
@@ -3933,7 +5308,7 @@ func_parse_lt_options ()
 
   # Print the debug banner immediately:
   if test -n \"\$lt_option_debug\"; then
-    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
   fi
 }
 
@@ -3944,7 +5319,7 @@ func_lt_dump_args ()
   lt_dump_args_N=1;
   for lt_arg
   do
-    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
   done
 }
@@ -3958,7 +5333,7 @@ func_exec_program_core ()
   *-*-mingw | *-*-os2* | *-cegcc*)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
@@ -3968,7 +5343,7 @@ func_exec_program_core ()
   *)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir/\$program\" \${1+\"\$@\"}
@@ -4043,13 +5418,13 @@ func_exec_program ()
   test -n \"\$absdir\" && thisdir=\"\$absdir\"
 "
 
-	if test "$fast_install" = yes; then
+	if test yes = "$fast_install"; then
 	  $ECHO "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" ||
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 
     file=\"\$\$-\$program\"
@@ -4066,7 +5441,7 @@ func_exec_program ()
     if test -n \"\$relink_command\"; then
       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
       else
-	$ECHO \"\$relink_command_output\" >&2
+	\$ECHO \"\$relink_command_output\" >&2
 	$RM \"\$progdir/\$file\"
 	exit 1
       fi
@@ -4101,7 +5476,7 @@ func_exec_program ()
 	fi
 
 	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 	  $ECHO "\
     # Add our own library path to $shlibpath_var
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
@@ -4121,7 +5496,7 @@ func_exec_program ()
     fi
   else
     # The program doesn't exist.
-    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
     exit 1
@@ -4140,7 +5515,7 @@ func_emit_cwrapperexe_src ()
 	cat <<EOF
 
 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 
    The $output program cannot be directly executed until all the libtool
    libraries that it depends on are installed.
@@ -4175,47 +5550,45 @@ EOF
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* declarations of non-ANSI functions */
-#if defined(__MINGW32__)
+#if defined __MINGW32__
 # ifdef __STRICT_ANSI__
 int _putenv (const char *);
 # endif
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # ifdef __STRICT_ANSI__
 char *realpath (const char *, char *);
 int putenv (char *);
 int setenv (const char *, const char *, int);
 # endif
-/* #elif defined (other platforms) ... */
+/* #elif defined other_platform || defined ... */
 #endif
 
 /* portability defines, excluding path handling macros */
-#if defined(_MSC_VER)
+#if defined _MSC_VER
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
 # define S_IXUSR _S_IEXEC
-# ifndef _INTPTR_T_DEFINED
-#  define _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#elif defined(__MINGW32__)
+#elif defined __MINGW32__
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # define HAVE_SETENV
 # define FOPEN_WB "wb"
-/* #elif defined (other platforms) ... */
+/* #elif defined other platforms ... */
 #endif
 
-#if defined(PATH_MAX)
+#if defined PATH_MAX
 # define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
+#elif defined MAXPATHLEN
 # define LT_PATHMAX MAXPATHLEN
 #else
 # define LT_PATHMAX 1024
@@ -4234,8 +5607,8 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
+  defined __OS2__
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"
 # ifndef DIR_SEPARATOR_2
@@ -4268,10 +5641,10 @@ int setenv (const char *, const char *, int);
 
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
+  if (stale) { free (stale); stale = 0; } \
 } while (0)
 
-#if defined(LT_DEBUGWRAPPER)
+#if defined LT_DEBUGWRAPPER
 static int lt_debug = 1;
 #else
 static int lt_debug = 0;
@@ -4300,11 +5673,16 @@ void lt_dump_script (FILE *f);
 EOF
 
 	    cat <<EOF
-volatile const char * MAGIC_EXE = "$magic_exe";
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
+# define externally_visible volatile
+#else
+# define externally_visible __attribute__((externally_visible)) volatile
+#endif
+externally_visible const char * MAGIC_EXE = "$magic_exe";
 const char * LIB_PATH_VARNAME = "$shlibpath_var";
 EOF
 
-	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
               func_to_host_path "$temp_rpath"
 	      cat <<EOF
 const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
@@ -4328,7 +5706,7 @@ const char * EXE_PATH_VALUE   = "";
 EOF
 	    fi
 
-	    if test "$fast_install" = yes; then
+	    if test yes = "$fast_install"; then
 	      cat <<EOF
 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
 EOF
@@ -4357,12 +5735,12 @@ main (int argc, char *argv[])
   char *actual_cwrapper_name;
   char *target_name;
   char *lt_argv_zero;
-  intptr_t rval = 127;
+  int rval = 127;
 
   int i;
 
   program_name = (char *) xstrdup (base_name (argv[0]));
-  newargz = XMALLOC (char *, argc + 1);
+  newargz = XMALLOC (char *, (size_t) argc + 1);
 
   /* very simple arg parsing; don't want to rely on getopt
    * also, copy all non cwrapper options to newargz, except
@@ -4371,10 +5749,10 @@ main (int argc, char *argv[])
   newargc=0;
   for (i = 1; i < argc; i++)
     {
-      if (strcmp (argv[i], dumpscript_opt) == 0)
+      if (STREQ (argv[i], dumpscript_opt))
 	{
 EOF
-	    case "$host" in
+	    case $host in
 	      *mingw* | *cygwin* )
 		# make stdout use "unix" line endings
 		echo "          setmode(1,_O_BINARY);"
@@ -4385,12 +5763,12 @@ EOF
 	  lt_dump_script (stdout);
 	  return 0;
 	}
-      if (strcmp (argv[i], debug_opt) == 0)
+      if (STREQ (argv[i], debug_opt))
 	{
           lt_debug = 1;
           continue;
 	}
-      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+      if (STREQ (argv[i], ltwrapper_option_prefix))
         {
           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
              namespace, but it is not one of the ones we know about and
@@ -4413,7 +5791,7 @@ EOF
 EOF
 	    cat <<EOF
   /* The GNU banner must be the first non-error debug message */
-  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
 EOF
 	    cat <<"EOF"
   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
@@ -4524,7 +5902,7 @@ EOF
 		cat <<"EOF"
   /* execv doesn't actually work on mingw as expected on unix */
   newargz = prepare_spawn (newargz);
-  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
   if (rval == -1)
     {
       /* failed to start process */
@@ -4569,7 +5947,7 @@ base_name (const char *name)
 {
   const char *base;
 
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   /* Skip over the disk name in MSDOS pathnames. */
   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
     name += 2;
@@ -4628,7 +6006,7 @@ find_executable (const char *wrapper)
   const char *p_next;
   /* static buffer for getcwd */
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
+  size_t tmp_len;
   char *concat_name;
 
   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
@@ -4638,7 +6016,7 @@ find_executable (const char *wrapper)
     return NULL;
 
   /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
     {
       concat_name = xstrdup (wrapper);
@@ -4656,7 +6034,7 @@ find_executable (const char *wrapper)
 	    return concat_name;
 	  XFREE (concat_name);
 	}
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
     }
 #endif
 
@@ -4679,7 +6057,7 @@ find_executable (const char *wrapper)
 	      for (q = p; *q; q++)
 		if (IS_PATH_SEPARATOR (*q))
 		  break;
-	      p_len = q - p;
+	      p_len = (size_t) (q - p);
 	      p_next = (*q == '\0' ? q : q + 1);
 	      if (p_len == 0)
 		{
@@ -4798,7 +6176,7 @@ strendzap (char *str, const char *pat)
   if (patlen <= len)
     {
       str += len - patlen;
-      if (strcmp (str, pat) == 0)
+      if (STREQ (str, pat))
 	*str = '\0';
     }
   return str;
@@ -4863,7 +6241,7 @@ lt_setenv (const char *name, const char *value)
     char *str = xstrdup (value);
     setenv (name, str, 1);
 #else
-    int len = strlen (name) + 1 + strlen (value) + 1;
+    size_t len = strlen (name) + 1 + strlen (value) + 1;
     char *str = XMALLOC (char, len);
     sprintf (str, "%s=%s", name, value);
     if (putenv (str) != EXIT_SUCCESS)
@@ -4880,8 +6258,8 @@ lt_extend_str (const char *orig_value, const char *add, int to_end)
   char *new_value;
   if (orig_value && *orig_value)
     {
-      int orig_value_len = strlen (orig_value);
-      int add_len = strlen (add);
+      size_t orig_value_len = strlen (orig_value);
+      size_t add_len = strlen (add);
       new_value = XMALLOC (char, add_len + orig_value_len + 1);
       if (to_end)
         {
@@ -4912,10 +6290,10 @@ lt_update_exe_path (const char *name, const char *value)
     {
       char *new_value = lt_extend_str (getenv (name), value, 0);
       /* some systems can't cope with a ':'-terminated path #' */
-      int len = strlen (new_value);
-      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+      size_t len = strlen (new_value);
+      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
         {
-          new_value[len-1] = '\0';
+          new_value[--len] = '\0';
         }
       lt_setenv (name, new_value);
       XFREE (new_value);
@@ -5082,27 +6460,47 @@ EOF
 # True if ARG is an import lib, as indicated by $file_magic_cmd
 func_win32_import_lib_p ()
 {
-    $opt_debug
+    $debug_cmd
+
     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
     *import*) : ;;
     *) false ;;
     esac
 }
 
+# func_suncc_cstd_abi
+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
+# Several compiler flags select an ABI that is incompatible with the
+# Cstd library. Avoid specifying it if any are in CXXFLAGS.
+func_suncc_cstd_abi ()
+{
+    $debug_cmd
+
+    case " $compile_command " in
+    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
+      suncc_use_cstd_abi=no
+      ;;
+    *)
+      suncc_use_cstd_abi=yes
+      ;;
+    esac
+}
+
 # func_mode_link arg...
 func_mode_link ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $host in
     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
+      # what system we are compiling for in order to pass an extra
       # flag for every libtool invocation.
       # allow_undefined=no
 
       # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
+      # to make a dll that has undefined symbols, in which case not
       # even a static library is built.  For now, we need to specify
       # -no-undefined on the libtool link line when we can be certain
       # that all symbols are satisfied, otherwise we get a static library.
@@ -5146,10 +6544,11 @@ func_mode_link ()
     module=no
     no_install=no
     objs=
+    os2dllname=
     non_pic_objects=
     precious_files_regex=
     prefer_static_libs=no
-    preload=no
+    preload=false
     prev=
     prevarg=
     release=
@@ -5161,7 +6560,7 @@ func_mode_link ()
     vinfo=
     vinfo_number=no
     weak_libs=
-    single_module="${wl}-single_module"
+    single_module=$wl-single_module
     func_infer_tag $base_compile
 
     # We need to know -static, to get the right output filenames.
@@ -5169,15 +6568,15 @@ func_mode_link ()
     do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes != "$build_libtool_libs" \
+	  && func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	break
 	;;
       -all-static | -static | -static-libtool-libs)
 	case $arg in
 	-all-static)
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
 	    func_warning "complete static linking is impossible in this configuration"
 	  fi
 	  if test -n "$link_static_flag"; then
@@ -5210,7 +6609,7 @@ func_mode_link ()
 
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
-      arg="$1"
+      arg=$1
       shift
       func_quote_for_eval "$arg"
       qarg=$func_quote_for_eval_unquoted_result
@@ -5227,21 +6626,21 @@ func_mode_link ()
 
 	case $prev in
 	bindir)
-	  bindir="$arg"
+	  bindir=$arg
 	  prev=
 	  continue
 	  ;;
 	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
+	  $preload || {
 	    # Add the symbol object into the linking commands.
 	    func_append compile_command " @SYMFILE@"
 	    func_append finalize_command " @SYMFILE@"
-	    preload=yes
-	  fi
+	    preload=:
+	  }
 	  case $arg in
 	  *.la | *.lo) ;;  # We handle these cases below.
 	  force)
-	    if test "$dlself" = no; then
+	    if test no = "$dlself"; then
 	      dlself=needless
 	      export_dynamic=yes
 	    fi
@@ -5249,9 +6648,9 @@ func_mode_link ()
 	    continue
 	    ;;
 	  self)
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
 	      dlself=yes
 	    else
 	      dlself=needless
@@ -5261,7 +6660,7 @@ func_mode_link ()
 	    continue
 	    ;;
 	  *)
-	    if test "$prev" = dlfiles; then
+	    if test dlfiles = "$prev"; then
 	      func_append dlfiles " $arg"
 	    else
 	      func_append dlprefiles " $arg"
@@ -5272,14 +6671,14 @@ func_mode_link ()
 	  esac
 	  ;;
 	expsyms)
-	  export_symbols="$arg"
+	  export_symbols=$arg
 	  test -f "$arg" \
-	    || func_fatal_error "symbol file \`$arg' does not exist"
+	    || func_fatal_error "symbol file '$arg' does not exist"
 	  prev=
 	  continue
 	  ;;
 	expsyms_regex)
-	  export_symbols_regex="$arg"
+	  export_symbols_regex=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5297,7 +6696,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	inst_prefix)
-	  inst_prefix_dir="$arg"
+	  inst_prefix_dir=$arg
+	  prev=
+	  continue
+	  ;;
+	mllvm)
+	  # Clang does not use LLVM to link, so we can simply discard any
+	  # '-mllvm $arg' options when doing the link step.
 	  prev=
 	  continue
 	  ;;
@@ -5321,21 +6726,21 @@ func_mode_link ()
 
 		if test -z "$pic_object" ||
 		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none &&
-		   test "$non_pic_object" = none; then
-		  func_fatal_error "cannot find name of object for \`$arg'"
+		   test none = "$pic_object" &&
+		   test none = "$non_pic_object"; then
+		  func_fatal_error "cannot find name of object for '$arg'"
 		fi
 
 		# Extract subdirectory from the argument.
 		func_dirname "$arg" "/" ""
-		xdir="$func_dirname_result"
+		xdir=$func_dirname_result
 
-		if test "$pic_object" != none; then
+		if test none != "$pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
+		  pic_object=$xdir$pic_object
 
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		  if test dlfiles = "$prev"; then
+		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		      func_append dlfiles " $pic_object"
 		      prev=
 		      continue
@@ -5346,7 +6751,7 @@ func_mode_link ()
 		  fi
 
 		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
+		  if test dlprefiles = "$prev"; then
 		    # Preload the old-style object.
 		    func_append dlprefiles " $pic_object"
 		    prev=
@@ -5354,23 +6759,23 @@ func_mode_link ()
 
 		  # A PIC object.
 		  func_append libobjs " $pic_object"
-		  arg="$pic_object"
+		  arg=$pic_object
 		fi
 
 		# Non-PIC object.
-		if test "$non_pic_object" != none; then
+		if test none != "$non_pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
+		  non_pic_object=$xdir$non_pic_object
 
 		  # A standard non-PIC object
 		  func_append non_pic_objects " $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
+		  if test -z "$pic_object" || test none = "$pic_object"; then
+		    arg=$non_pic_object
 		  fi
 		else
 		  # If the PIC object exists, use it instead.
 		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
+		  non_pic_object=$pic_object
 		  func_append non_pic_objects " $non_pic_object"
 		fi
 	      else
@@ -5378,7 +6783,7 @@ func_mode_link ()
 		if $opt_dry_run; then
 		  # Extract subdirectory from the argument.
 		  func_dirname "$arg" "/" ""
-		  xdir="$func_dirname_result"
+		  xdir=$func_dirname_result
 
 		  func_lo2o "$arg"
 		  pic_object=$xdir$objdir/$func_lo2o_result
@@ -5386,24 +6791,29 @@ func_mode_link ()
 		  func_append libobjs " $pic_object"
 		  func_append non_pic_objects " $non_pic_object"
 	        else
-		  func_fatal_error "\`$arg' is not a valid libtool object"
+		  func_fatal_error "'$arg' is not a valid libtool object"
 		fi
 	      fi
 	    done
 	  else
-	    func_fatal_error "link input file \`$arg' does not exist"
+	    func_fatal_error "link input file '$arg' does not exist"
 	  fi
 	  arg=$save_arg
 	  prev=
 	  continue
 	  ;;
+	os2dllname)
+	  os2dllname=$arg
+	  prev=
+	  continue
+	  ;;
 	precious_regex)
-	  precious_files_regex="$arg"
+	  precious_files_regex=$arg
 	  prev=
 	  continue
 	  ;;
 	release)
-	  release="-$arg"
+	  release=-$arg
 	  prev=
 	  continue
 	  ;;
@@ -5415,7 +6825,7 @@ func_mode_link ()
 	    func_fatal_error "only absolute run-paths are allowed"
 	    ;;
 	  esac
-	  if test "$prev" = rpath; then
+	  if test rpath = "$prev"; then
 	    case "$rpath " in
 	    *" $arg "*) ;;
 	    *) func_append rpath " $arg" ;;
@@ -5430,7 +6840,7 @@ func_mode_link ()
 	  continue
 	  ;;
 	shrext)
-	  shrext_cmds="$arg"
+	  shrext_cmds=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5470,7 +6880,7 @@ func_mode_link ()
 	esac
       fi # test -n "$prev"
 
-      prevarg="$arg"
+      prevarg=$arg
 
       case $arg in
       -all-static)
@@ -5484,7 +6894,7 @@ func_mode_link ()
 
       -allow-undefined)
 	# FIXME: remove this flag sometime in the future.
-	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	func_fatal_error "'-allow-undefined' must not be used because it is the default"
 	;;
 
       -avoid-version)
@@ -5516,7 +6926,7 @@ func_mode_link ()
 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
 	fi
-	if test "X$arg" = "X-export-symbols"; then
+	if test X-export-symbols = "X$arg"; then
 	  prev=expsyms
 	else
 	  prev=expsyms_regex
@@ -5550,9 +6960,9 @@ func_mode_link ()
 	func_stripname "-L" '' "$arg"
 	if test -z "$func_stripname_result"; then
 	  if test "$#" -gt 0; then
-	    func_fatal_error "require no space between \`-L' and \`$1'"
+	    func_fatal_error "require no space between '-L' and '$1'"
 	  else
-	    func_fatal_error "need path for \`-L' option"
+	    func_fatal_error "need path for '-L' option"
 	  fi
 	fi
 	func_resolve_sysroot "$func_stripname_result"
@@ -5563,8 +6973,8 @@ func_mode_link ()
 	*)
 	  absdir=`cd "$dir" && pwd`
 	  test -z "$absdir" && \
-	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
-	  dir="$absdir"
+	    func_fatal_error "cannot determine absolute directory name of '$dir'"
+	  dir=$absdir
 	  ;;
 	esac
 	case "$deplibs " in
@@ -5599,7 +7009,7 @@ func_mode_link ()
 	;;
 
       -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # These systems don't actually have a C or math library (as such)
@@ -5607,11 +7017,11 @@ func_mode_link ()
 	    ;;
 	  *-*-os2*)
 	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-rhapsody* | *-*-darwin1.[012])
 	    # Rhapsody C and math libraries are in the System framework
@@ -5620,16 +7030,16 @@ func_mode_link ()
 	    ;;
 	  *-*-sco3.2v5* | *-*-sco5v6*)
 	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
 	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  esac
-	elif test "X$arg" = "X-lc_r"; then
+	elif test X-lc_r = "X$arg"; then
 	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	   # Do not include libc_r directly, use -pthread flag.
 	   continue
 	   ;;
@@ -5639,6 +7049,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -mllvm)
+	prev=mllvm
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -5668,7 +7083,7 @@ func_mode_link ()
 	;;
 
       -multi_module)
-	single_module="${wl}-multi_module"
+	single_module=$wl-multi_module
 	continue
 	;;
 
@@ -5682,8 +7097,8 @@ func_mode_link ()
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
 	  # The PATH hackery in wrapper scripts is required on Windows
 	  # and Darwin in order for the loader to find any dlls it needs.
-	  func_warning "\`-no-install' is ignored for $host"
-	  func_warning "assuming \`-no-fast-install' instead"
+	  func_warning "'-no-install' is ignored for $host"
+	  func_warning "assuming '-no-fast-install' instead"
 	  fast_install=no
 	  ;;
 	*) no_install=yes ;;
@@ -5701,6 +7116,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -os2dllname)
+	prev=os2dllname
+	continue
+	;;
+
       -o) prev=output ;;
 
       -precious-files-regex)
@@ -5788,14 +7208,14 @@ func_mode_link ()
 	func_stripname '-Wc,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $func_quote_for_eval_result"
 	  func_append compiler_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5804,15 +7224,15 @@ func_mode_link ()
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $wl$func_quote_for_eval_result"
 	  func_append compiler_flags " $wl$func_quote_for_eval_result"
 	  func_append linker_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5835,7 +7255,7 @@ func_mode_link ()
       # -msg_* for osf cc
       -msg_*)
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       # Flags to be passed through unchanged, with rationale:
@@ -5847,25 +7267,49 @@ func_mode_link ()
       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
       # -F/path              path to uninstalled frameworks, gcc on darwin
       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # -fstack-protector*   stack protector flags for GCC
       # @file                GCC response files
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
-      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -specs=*             GCC specs files
+      # -stdlib=*            select c++ std lib with clang
+      # -fsanitize=*         Clang/GCC memory and address sanitizer
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
+      -specs=*|-fsanitize=*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
         func_append finalize_command " $arg"
         func_append compiler_flags " $arg"
         continue
         ;;
 
+      -Z*)
+        if test os2 = "`expr $host : '.*\(os2\)'`"; then
+          # OS/2 uses -Zxxx to specify OS/2-specific options
+	  compiler_flags="$compiler_flags $arg"
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  case $arg in
+	  -Zlinker | -Zstack)
+	    prev=xcompiler
+	    ;;
+	  esac
+	  continue
+        else
+	  # Otherwise treat like 'Some other compiler flag' below
+	  func_quote_for_eval "$arg"
+	  arg=$func_quote_for_eval_result
+        fi
+	;;
+
       # Some other compiler flag.
       -* | +*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       *.$objext)
@@ -5886,21 +7330,21 @@ func_mode_link ()
 
 	  if test -z "$pic_object" ||
 	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none &&
-	     test "$non_pic_object" = none; then
-	    func_fatal_error "cannot find name of object for \`$arg'"
+	     test none = "$pic_object" &&
+	     test none = "$non_pic_object"; then
+	    func_fatal_error "cannot find name of object for '$arg'"
 	  fi
 
 	  # Extract subdirectory from the argument.
 	  func_dirname "$arg" "/" ""
-	  xdir="$func_dirname_result"
+	  xdir=$func_dirname_result
 
-	  if test "$pic_object" != none; then
+	  test none = "$pic_object" || {
 	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
+	    pic_object=$xdir$pic_object
 
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+	    if test dlfiles = "$prev"; then
+	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		func_append dlfiles " $pic_object"
 		prev=
 		continue
@@ -5911,7 +7355,7 @@ func_mode_link ()
 	    fi
 
 	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      # Preload the old-style object.
 	      func_append dlprefiles " $pic_object"
 	      prev=
@@ -5919,23 +7363,23 @@ func_mode_link ()
 
 	    # A PIC object.
 	    func_append libobjs " $pic_object"
-	    arg="$pic_object"
-	  fi
+	    arg=$pic_object
+	  }
 
 	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
+	  if test none != "$non_pic_object"; then
 	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
+	    non_pic_object=$xdir$non_pic_object
 
 	    # A standard non-PIC object
 	    func_append non_pic_objects " $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
+	    if test -z "$pic_object" || test none = "$pic_object"; then
+	      arg=$non_pic_object
 	    fi
 	  else
 	    # If the PIC object exists, use it instead.
 	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
+	    non_pic_object=$pic_object
 	    func_append non_pic_objects " $non_pic_object"
 	  fi
 	else
@@ -5943,7 +7387,7 @@ func_mode_link ()
 	  if $opt_dry_run; then
 	    # Extract subdirectory from the argument.
 	    func_dirname "$arg" "/" ""
-	    xdir="$func_dirname_result"
+	    xdir=$func_dirname_result
 
 	    func_lo2o "$arg"
 	    pic_object=$xdir$objdir/$func_lo2o_result
@@ -5951,7 +7395,7 @@ func_mode_link ()
 	    func_append libobjs " $pic_object"
 	    func_append non_pic_objects " $non_pic_object"
 	  else
-	    func_fatal_error "\`$arg' is not a valid libtool object"
+	    func_fatal_error "'$arg' is not a valid libtool object"
 	  fi
 	fi
 	;;
@@ -5967,11 +7411,11 @@ func_mode_link ()
 	# A libtool-controlled library.
 
 	func_resolve_sysroot "$arg"
-	if test "$prev" = dlfiles; then
+	if test dlfiles = "$prev"; then
 	  # This library was specified with -dlopen.
 	  func_append dlfiles " $func_resolve_sysroot_result"
 	  prev=
-	elif test "$prev" = dlprefiles; then
+	elif test dlprefiles = "$prev"; then
 	  # The library was specified with -dlpreopen.
 	  func_append dlprefiles " $func_resolve_sysroot_result"
 	  prev=
@@ -5986,7 +7430,7 @@ func_mode_link ()
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
       esac # arg
 
@@ -5998,9 +7442,9 @@ func_mode_link ()
     done # argument parsing loop
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prevarg' option requires an argument"
+      func_fatal_help "the '$prevarg' option requires an argument"
 
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
       eval arg=\"$export_dynamic_flag_spec\"
       func_append compile_command " $arg"
       func_append finalize_command " $arg"
@@ -6009,20 +7453,23 @@ func_mode_link ()
     oldlibs=
     # calculate the name of the file, without its directory
     func_basename "$output"
-    outputname="$func_basename_result"
-    libobjs_save="$libobjs"
+    outputname=$func_basename_result
+    libobjs_save=$libobjs
 
     if test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
     else
       shlib_search_path=
     fi
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    # Definition is injected by LT_CONFIG during libtool generation.
+    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
-    output_objdir="$func_dirname_result$objdir"
+    output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
     tool_output_objdir=$func_to_tool_file_result
     # Create the object directory.
@@ -6045,7 +7492,7 @@ func_mode_link ()
     # Find all interdependent deplibs by searching for libraries
     # that are linked more than once (e.g. -la -lb -la)
     for deplib in $deplibs; do
-      if $opt_preserve_dup_deps ; then
+      if $opt_preserve_dup_deps; then
 	case "$libs " in
 	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	esac
@@ -6053,7 +7500,7 @@ func_mode_link ()
       func_append libs " $deplib"
     done
 
-    if test "$linkmode" = lib; then
+    if test lib = "$linkmode"; then
       libs="$predeps $libs $compiler_lib_search_path $postdeps"
 
       # Compute libraries that are listed more than once in $predeps
@@ -6085,7 +7532,7 @@ func_mode_link ()
 	  case $file in
 	  *.la) ;;
 	  *)
-	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
 	    ;;
 	  esac
 	done
@@ -6093,7 +7540,7 @@ func_mode_link ()
     prog)
 	compile_deplibs=
 	finalize_deplibs=
-	alldeplibs=no
+	alldeplibs=false
 	newdlfiles=
 	newdlprefiles=
 	passes="conv scan dlopen dlpreopen link"
@@ -6105,32 +7552,32 @@ func_mode_link ()
     for pass in $passes; do
       # The preopen pass in lib mode reverses $deplibs; put it back here
       # so that -L comes before libs that need it for instance...
-      if test "$linkmode,$pass" = "lib,link"; then
+      if test lib,link = "$linkmode,$pass"; then
 	## FIXME: Find the place where the list is rebuilt in the wrong
 	##        order, and fix it there properly
         tmp_deplibs=
 	for deplib in $deplibs; do
 	  tmp_deplibs="$deplib $tmp_deplibs"
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
       fi
 
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
+      if test lib,link = "$linkmode,$pass" ||
+	 test prog,scan = "$linkmode,$pass"; then
+	libs=$deplibs
 	deplibs=
       fi
-      if test "$linkmode" = prog; then
+      if test prog = "$linkmode"; then
 	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
+	dlopen) libs=$dlfiles ;;
+	dlpreopen) libs=$dlprefiles ;;
 	link)
 	  libs="$deplibs %DEPLIBS%"
 	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
 	  ;;
 	esac
       fi
-      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+      if test lib,dlpreopen = "$linkmode,$pass"; then
 	# Collect and forward deplibs of preopened libtool libs
 	for lib in $dlprefiles; do
 	  # Ignore non-libtool-libs
@@ -6151,26 +7598,26 @@ func_mode_link ()
 	    esac
 	  done
 	done
-	libs="$dlprefiles"
+	libs=$dlprefiles
       fi
-      if test "$pass" = dlopen; then
+      if test dlopen = "$pass"; then
 	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
+	save_deplibs=$deplibs
 	deplibs=
       fi
 
       for deplib in $libs; do
 	lib=
-	found=no
+	found=false
 	case $deplib in
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    func_append compiler_flags " $deplib"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6180,13 +7627,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    func_warning "\`-l' is ignored for archives/objects"
+	  if test lib != "$linkmode" && test prog != "$linkmode"; then
+	    func_warning "'-l' is ignored for archives/objects"
 	    continue
 	  fi
 	  func_stripname '-l' '' "$deplib"
 	  name=$func_stripname_result
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
 	  else
 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
@@ -6194,31 +7641,22 @@ func_mode_link ()
 	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
+	      lib=$searchdir/lib$name$search_ext
 	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
+		if test .la = "$search_ext"; then
+		  found=:
 		else
-		  found=no
+		  found=false
 		fi
 		break 2
 	      fi
 	    done
 	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
+	  if $found; then
+	    # deplib is a libtool library
 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
 	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 	      case " $predeps $postdeps " in
 	      *" $deplib "*)
 		if func_lalib_p "$lib"; then
@@ -6226,19 +7664,19 @@ func_mode_link ()
 		  old_library=
 		  func_source "$lib"
 		  for l in $old_library $library_names; do
-		    ll="$l"
+		    ll=$l
 		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
+		  if test "X$ll" = "X$old_library"; then # only static version available
+		    found=false
 		    func_dirname "$lib" "" "."
-		    ladir="$func_dirname_result"
+		    ladir=$func_dirname_result
 		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
+		    if test prog,link = "$linkmode,$pass"; then
 		      compile_deplibs="$deplib $compile_deplibs"
 		      finalize_deplibs="$deplib $finalize_deplibs"
 		    else
 		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
 		    fi
 		    continue
 		  fi
@@ -6247,15 +7685,25 @@ func_mode_link ()
 	      *) ;;
 	      esac
 	    fi
+	  else
+	    # deplib doesn't seem to be a libtool library
+	    if test prog,link = "$linkmode,$pass"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
 	  fi
 	  ;; # -l
 	*.ltframework)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    deplibs="$deplib $deplibs"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6268,18 +7716,18 @@ func_mode_link ()
 	  case $linkmode in
 	  lib)
 	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
+	    test conv = "$pass" && continue
 	    newdependency_libs="$deplib $newdependency_libs"
 	    func_stripname '-L' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  prog)
-	    if test "$pass" = conv; then
+	    if test conv = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	      continue
 	    fi
-	    if test "$pass" = scan; then
+	    if test scan = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6290,13 +7738,13 @@ func_mode_link ()
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  *)
-	    func_warning "\`-L' is ignored for archives/objects"
+	    func_warning "'-L' is ignored for archives/objects"
 	    ;;
 	  esac # linkmode
 	  continue
 	  ;; # -L
 	-R*)
-	  if test "$pass" = link; then
+	  if test link = "$pass"; then
 	    func_stripname '-R' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    dir=$func_resolve_sysroot_result
@@ -6314,7 +7762,7 @@ func_mode_link ()
 	  lib=$func_resolve_sysroot_result
 	  ;;
 	*.$libext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
 	    continue
 	  fi
@@ -6325,21 +7773,26 @@ func_mode_link ()
 	    case " $dlpreconveniencelibs " in
 	    *" $deplib "*) ;;
 	    *)
-	      valid_a_lib=no
+	      valid_a_lib=false
 	      case $deplibs_check_method in
 		match_pattern*)
 		  set dummy $deplibs_check_method; shift
 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
 		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
 		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		    valid_a_lib=yes
+		    valid_a_lib=:
 		  fi
 		;;
 		pass_all)
-		  valid_a_lib=yes
+		  valid_a_lib=:
 		;;
 	      esac
-	      if test "$valid_a_lib" != yes; then
+	      if $valid_a_lib; then
+		echo
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      else
 		echo
 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
 		echo "*** I have the capability to make that library automatically link in when"
@@ -6347,18 +7800,13 @@ func_mode_link ()
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because the file extensions .$libext of this argument makes me believe"
 		echo "*** that it is just a static archive that I should not use here."
-	      else
-		echo
-		$ECHO "*** Warning: Linking the shared library $output against the"
-		$ECHO "*** static library $deplib is not portable!"
-		deplibs="$deplib $deplibs"
 	      fi
 	      ;;
 	    esac
 	    continue
 	    ;;
 	  prog)
-	    if test "$pass" != link; then
+	    if test link != "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6369,10 +7817,10 @@ func_mode_link ()
 	  esac # linkmode
 	  ;; # *.$libext
 	*.lo | *.$objext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	  elif test prog = "$linkmode"; then
+	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
 	      # If there is no dlopen support or we're linking statically,
 	      # we need to preload.
 	      func_append newdlprefiles " $deplib"
@@ -6385,22 +7833,20 @@ func_mode_link ()
 	  continue
 	  ;;
 	%DEPLIBS%)
-	  alldeplibs=yes
+	  alldeplibs=:
 	  continue
 	  ;;
 	esac # case $deplib
 
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
-	fi
+	$found || test -f "$lib" \
+	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$lib" \
-	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+	  || func_fatal_error "'$lib' is not a valid libtool archive"
 
 	func_dirname "$lib" "" "."
-	ladir="$func_dirname_result"
+	ladir=$func_dirname_result
 
 	dlname=
 	dlopen=
@@ -6430,19 +7876,19 @@ func_mode_link ()
 	  done
 	fi
 	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	if test lib,link = "$linkmode,$pass" ||
+	   test prog,scan = "$linkmode,$pass" ||
+	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
 	  test -n "$dlopen" && func_append dlfiles " $dlopen"
 	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
 	fi
 
-	if test "$pass" = conv; then
+	if test conv = "$pass"; then
 	  # Only check for convenience libraries
 	  deplibs="$lib $deplibs"
 	  if test -z "$libdir"; then
 	    if test -z "$old_library"; then
-	      func_fatal_error "cannot find name of link library for \`$lib'"
+	      func_fatal_error "cannot find name of link library for '$lib'"
 	    fi
 	    # It is a libtool convenience library, so add in its objects.
 	    func_append convenience " $ladir/$objdir/$old_library"
@@ -6450,15 +7896,15 @@ func_mode_link ()
 	    tmp_libs=
 	    for deplib in $dependency_libs; do
 	      deplibs="$deplib $deplibs"
-	      if $opt_preserve_dup_deps ; then
+	      if $opt_preserve_dup_deps; then
 		case "$tmp_libs " in
 		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 		esac
 	      fi
 	      func_append tmp_libs " $deplib"
 	    done
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    func_fatal_error "\`$lib' is not a convenience library"
+	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
+	    func_fatal_error "'$lib' is not a convenience library"
 	  fi
 	  continue
 	fi # $pass = conv
@@ -6467,26 +7913,26 @@ func_mode_link ()
 	# Get the name of the library we link against.
 	linklib=
 	if test -n "$old_library" &&
-	   { test "$prefer_static_libs" = yes ||
-	     test "$prefer_static_libs,$installed" = "built,no"; }; then
+	   { test yes = "$prefer_static_libs" ||
+	     test built,no = "$prefer_static_libs,$installed"; }; then
 	  linklib=$old_library
 	else
 	  for l in $old_library $library_names; do
-	    linklib="$l"
+	    linklib=$l
 	  done
 	fi
 	if test -z "$linklib"; then
-	  func_fatal_error "cannot find name of link library for \`$lib'"
+	  func_fatal_error "cannot find name of link library for '$lib'"
 	fi
 
 	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
-	  fi
+	if test dlopen = "$pass"; then
+	  test -z "$libdir" \
+	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
 	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
+	     test yes != "$dlopen_support" ||
+	     test no = "$build_libtool_libs"
+	  then
 	    # If there is no dlname, no dlopen support or we're linking
 	    # statically, we need to preload.  We also need to preload any
 	    # dependent libraries so libltdl's deplib preloader doesn't
@@ -6500,40 +7946,40 @@ func_mode_link ()
 
 	# We need an absolute path.
 	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
 	*)
 	  abs_ladir=`cd "$ladir" && pwd`
 	  if test -z "$abs_ladir"; then
-	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "cannot determine absolute directory name of '$ladir'"
 	    func_warning "passing it literally to the linker, although it might fail"
-	    abs_ladir="$ladir"
+	    abs_ladir=$ladir
 	  fi
 	  ;;
 	esac
 	func_basename "$lib"
-	laname="$func_basename_result"
+	laname=$func_basename_result
 
 	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
+	if test yes = "$installed"; then
 	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    func_warning "library \`$lib' was moved."
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
+	    func_warning "library '$lib' was moved."
+	    dir=$ladir
+	    absdir=$abs_ladir
+	    libdir=$abs_ladir
 	  else
-	    dir="$lt_sysroot$libdir"
-	    absdir="$lt_sysroot$libdir"
+	    dir=$lt_sysroot$libdir
+	    absdir=$lt_sysroot$libdir
 	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
 	else
 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
+	    dir=$ladir
+	    absdir=$abs_ladir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
+	    dir=$ladir/$objdir
+	    absdir=$abs_ladir/$objdir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  fi
@@ -6542,11 +7988,11 @@ func_mode_link ()
 	name=$func_stripname_result
 
 	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir" && test "$linkmode" = prog; then
-	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	if test dlpreopen = "$pass"; then
+	  if test -z "$libdir" && test prog = "$linkmode"; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
 	  fi
-	  case "$host" in
+	  case $host in
 	    # special handling for platforms with PE-DLLs.
 	    *cygwin* | *mingw* | *cegcc* )
 	      # Linker will automatically link against shared library if both
@@ -6590,9 +8036,9 @@ func_mode_link ()
 
 	if test -z "$libdir"; then
 	  # Link the convenience library
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
+	  elif test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$dir/$old_library $compile_deplibs"
 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
 	  else
@@ -6602,14 +8048,14 @@ func_mode_link ()
 	fi
 
 
-	if test "$linkmode" = prog && test "$pass" != link; then
+	if test prog = "$linkmode" && test link != "$pass"; then
 	  func_append newlib_search_path " $ladir"
 	  deplibs="$lib $deplibs"
 
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
+	  linkalldeplibs=false
+	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
+	     test no = "$build_libtool_libs"; then
+	    linkalldeplibs=:
 	  fi
 
 	  tmp_libs=
@@ -6621,14 +8067,14 @@ func_mode_link ()
 		 ;;
 	    esac
 	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
+	    if $linkalldeplibs; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      # Need to hardcode shared library paths
 	      # or/and link against static libraries
 	      newdependency_libs="$deplib $newdependency_libs"
 	    fi
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	      esac
@@ -6638,15 +8084,15 @@ func_mode_link ()
 	  continue
 	fi # $linkmode = prog...
 
-	if test "$linkmode,$pass" = "prog,link"; then
+	if test prog,link = "$linkmode,$pass"; then
 	  if test -n "$library_names" &&
-	     { { test "$prefer_static_libs" = no ||
-	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	     { { test no = "$prefer_static_libs" ||
+	         test built,yes = "$prefer_static_libs,$installed"; } ||
 	       test -z "$old_library"; }; then
 	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath:" in
+	      case $temp_rpath: in
 	      *"$absdir:"*) ;;
 	      *) func_append temp_rpath "$absdir:" ;;
 	      esac
@@ -6675,9 +8121,9 @@ func_mode_link ()
 	    esac
 	  fi # $linkmode,$pass = prog,link...
 
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
+	  if $alldeplibs &&
+	     { test pass_all = "$deplibs_check_method" ||
+	       { test yes = "$build_libtool_libs" &&
 		 test -n "$library_names"; }; }; then
 	    # We only need to search for static libraries
 	    continue
@@ -6686,19 +8132,19 @@ func_mode_link ()
 
 	link_static=no # Whether the deplib will be linked statically
 	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes; then
+	if test built = "$use_static_libs" && test yes = "$installed"; then
 	  use_static_libs=no
 	fi
 	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
+	  *cygwin* | *mingw* | *cegcc* | *os2*)
 	      # No point in relinking DLLs because paths are not encoded
 	      func_append notinst_deplibs " $lib"
 	      need_relink=no
 	    ;;
 	  *)
-	    if test "$installed" = no; then
+	    if test no = "$installed"; then
 	      func_append notinst_deplibs " $lib"
 	      need_relink=yes
 	    fi
@@ -6708,24 +8154,24 @@ func_mode_link ()
 
 	  # Warn about portability, can't link against -module's on some
 	  # systems (darwin).  Don't bleat about dlopened modules though!
-	  dlopenmodule=""
+	  dlopenmodule=
 	  for dlpremoduletest in $dlprefiles; do
 	    if test "X$dlpremoduletest" = "X$lib"; then
-	      dlopenmodule="$dlpremoduletest"
+	      dlopenmodule=$dlpremoduletest
 	      break
 	    fi
 	  done
-	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
 	    echo
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
 	    else
 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
 	    fi
 	    $ECHO "*** $linklib is not portable!"
 	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
+	  if test lib = "$linkmode" &&
+	     test yes = "$hardcode_into_libs"; then
 	    # Hardcode the library path.
 	    # Skip directories that are in the system default run-time
 	    # search path.
@@ -6753,43 +8199,43 @@ func_mode_link ()
 	    # figure out the soname
 	    set dummy $library_names
 	    shift
-	    realname="$1"
+	    realname=$1
 	    shift
 	    libname=`eval "\\$ECHO \"$libname_spec\""`
 	    # use dlname if we got it. it's perfectly good, no?
 	    if test -n "$dlname"; then
-	      soname="$dlname"
+	      soname=$dlname
 	    elif test -n "$soname_spec"; then
 	      # bleh windows
 	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
+	      *cygwin* | mingw* | *cegcc* | *os2*)
 	        func_arith $current - $age
 		major=$func_arith_result
-		versuffix="-$major"
+		versuffix=-$major
 		;;
 	      esac
 	      eval soname=\"$soname_spec\"
 	    else
-	      soname="$realname"
+	      soname=$realname
 	    fi
 
 	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
+	    soroot=$soname
 	    func_basename "$soroot"
-	    soname="$func_basename_result"
+	    soname=$func_basename_result
 	    func_stripname 'lib' '.dll' "$soname"
 	    newlib=libimp-$func_stripname_result.a
 
 	    # If the library has no export list, then create one now
 	    if test -f "$output_objdir/$soname-def"; then :
 	    else
-	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_verbose "extracting exported symbol list from '$soname'"
 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
 	    fi
 
 	    # Create $newlib
 	    if test -f "$output_objdir/$newlib"; then :; else
-	      func_verbose "generating import library for \`$soname'"
+	      func_verbose "generating import library for '$soname'"
 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
 	    fi
 	    # make sure the library variables are pointing to the new library
@@ -6797,58 +8243,58 @@ func_mode_link ()
 	    linklib=$newlib
 	  fi # test -n "$old_archive_from_expsyms_cmds"
 
-	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
+	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    lib_linked=yes
 	    case $hardcode_action in
 	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
+	      if test no = "$hardcode_direct"; then
+		add=$dir/$linklib
 		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
+		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
+		    *-*-unixware7*) add_dir=-L$dir ;;
 		  *-*-darwin* )
-		    # if the lib is a (non-dlopened) module then we can not
+		    # if the lib is a (non-dlopened) module then we cannot
 		    # link against it, someone is ignoring the earlier warnings
 		    if /usr/bin/file -L $add 2> /dev/null |
-			 $GREP ": [^:]* bundle" >/dev/null ; then
+			 $GREP ": [^:]* bundle" >/dev/null; then
 		      if test "X$dlopenmodule" != "X$lib"; then
 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
-			if test -z "$old_library" ; then
+			if test -z "$old_library"; then
 			  echo
 			  echo "*** And there doesn't seem to be a static archive available"
 			  echo "*** The link will probably fail, sorry"
 			else
-			  add="$dir/$old_library"
+			  add=$dir/$old_library
 			fi
 		      elif test -n "$old_library"; then
-			add="$dir/$old_library"
+			add=$dir/$old_library
 		      fi
 		    fi
 		esac
-	      elif test "$hardcode_minus_L" = no; then
+	      elif test no = "$hardcode_minus_L"; then
 		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
+		*-*-sunos*) add_shlibpath=$dir ;;
 		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add_dir=-L$dir
+		add=-l$name
+	      elif test no = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
 	      ;;
 	    relink)
-	      if test "$hardcode_direct" = yes &&
-	         test "$hardcode_direct_absolute" = no; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$absdir"
+	      if test yes = "$hardcode_direct" &&
+	         test no = "$hardcode_direct_absolute"; then
+		add=$dir/$linklib
+	      elif test yes = "$hardcode_minus_L"; then
+		add_dir=-L$absdir
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
 		  case $libdir in
@@ -6857,10 +8303,10 @@ func_mode_link ()
 		      ;;
 		  esac
 		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add=-l$name
+	      elif test yes = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
@@ -6868,7 +8314,7 @@ func_mode_link ()
 	    *) lib_linked=no ;;
 	    esac
 
-	    if test "$lib_linked" != yes; then
+	    if test yes != "$lib_linked"; then
 	      func_fatal_configuration "unsupported hardcode properties"
 	    fi
 
@@ -6878,15 +8324,15 @@ func_mode_link ()
 	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
 	      esac
 	    fi
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
 	    else
 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
 	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes &&
-		 test "$hardcode_minus_L" != yes &&
-		 test "$hardcode_shlibpath_var" = yes; then
+	      if test yes != "$hardcode_direct" &&
+		 test yes != "$hardcode_minus_L" &&
+		 test yes = "$hardcode_shlibpath_var"; then
 		case :$finalize_shlibpath: in
 		*":$libdir:"*) ;;
 		*) func_append finalize_shlibpath "$libdir:" ;;
@@ -6895,33 +8341,33 @@ func_mode_link ()
 	    fi
 	  fi
 
-	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
+	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes &&
-	       test "$hardcode_direct_absolute" = no; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
+	    if test yes = "$hardcode_direct" &&
+	       test no = "$hardcode_direct_absolute"; then
+	      add=$libdir/$linklib
+	    elif test yes = "$hardcode_minus_L"; then
+	      add_dir=-L$libdir
+	      add=-l$name
+	    elif test yes = "$hardcode_shlibpath_var"; then
 	      case :$finalize_shlibpath: in
 	      *":$libdir:"*) ;;
 	      *) func_append finalize_shlibpath "$libdir:" ;;
 	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
+	      add=-l$name
+	    elif test yes = "$hardcode_automatic"; then
 	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-		add="$inst_prefix_dir$libdir/$linklib"
+		 test -f "$inst_prefix_dir$libdir/$linklib"; then
+		add=$inst_prefix_dir$libdir/$linklib
 	      else
-		add="$libdir/$linklib"
+		add=$libdir/$linklib
 	      fi
 	    else
 	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
+	      add_dir=-L$libdir
 	      # Try looking first in the location we're being installed to.
 	      if test -n "$inst_prefix_dir"; then
 		case $libdir in
@@ -6930,10 +8376,10 @@ func_mode_link ()
 		    ;;
 		esac
 	      fi
-	      add="-l$name"
+	      add=-l$name
 	    fi
 
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
 	    else
@@ -6941,43 +8387,43 @@ func_mode_link ()
 	      test -n "$add" && deplibs="$add $deplibs"
 	    fi
 	  fi
-	elif test "$linkmode" = prog; then
+	elif test prog = "$linkmode"; then
 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
 	  # is not unsupported.  This is valid on all known static and
 	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
+	  if test unsupported != "$hardcode_direct"; then
+	    test -n "$old_library" && linklib=$old_library
 	    compile_deplibs="$dir/$linklib $compile_deplibs"
 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
 	  else
 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
 	  fi
-	elif test "$build_libtool_libs" = yes; then
+	elif test yes = "$build_libtool_libs"; then
 	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
+	  if test pass_all != "$deplibs_check_method"; then
 	    # We're trying link a shared library against a static one
 	    # but the system doesn't support it.
 
 	    # Just print a warning and add the library to dependency_libs so
 	    # that the program can be linked against the static library.
 	    echo
-	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
 	    echo "*** I have the capability to make that library automatically link in when"
 	    echo "*** you link to this library.  But I can only do this if you have a"
 	    echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
+	    if test yes = "$module"; then
 	      echo "*** But as you try to build a module library, libtool will still create "
 	      echo "*** a static module, that should work as long as the dlopening application"
 	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
 	      if test -z "$global_symbol_pipe"; then
 		echo
 		echo "*** However, this would only work if libtool was able to extract symbol"
-		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 		echo "*** not find such a program.  So, this module is probably useless."
-		echo "*** \`nm' from GNU binutils and a full rebuild may help."
+		echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	      fi
-	      if test "$build_old_libs" = no; then
+	      if test no = "$build_old_libs"; then
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -6990,11 +8436,11 @@ func_mode_link ()
 	  fi
 	fi # link shared/static library?
 
-	if test "$linkmode" = lib; then
+	if test lib = "$linkmode"; then
 	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
+	     { test yes != "$hardcode_into_libs" ||
+	       test yes = "$build_old_libs" ||
+	       test yes = "$link_static"; }; then
 	    # Extract -R from dependency_libs
 	    temp_deplibs=
 	    for libdir in $dependency_libs; do
@@ -7008,12 +8454,12 @@ func_mode_link ()
 	      *) func_append temp_deplibs " $libdir";;
 	      esac
 	    done
-	    dependency_libs="$temp_deplibs"
+	    dependency_libs=$temp_deplibs
 	  fi
 
 	  func_append newlib_search_path " $absdir"
 	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
 	  # ... and its dependency_libs
 	  tmp_libs=
 	  for deplib in $dependency_libs; do
@@ -7023,7 +8469,7 @@ func_mode_link ()
                    func_resolve_sysroot "$func_stripname_result";;
               *) func_resolve_sysroot "$deplib" ;;
             esac
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $func_resolve_sysroot_result "*)
                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
@@ -7032,12 +8478,12 @@ func_mode_link ()
 	    func_append tmp_libs " $func_resolve_sysroot_result"
 	  done
 
-	  if test "$link_all_deplibs" != no; then
+	  if test no != "$link_all_deplibs"; then
 	    # Add the search paths of all dependency libraries
 	    for deplib in $dependency_libs; do
 	      path=
 	      case $deplib in
-	      -L*) path="$deplib" ;;
+	      -L*) path=$deplib ;;
 	      *.la)
 	        func_resolve_sysroot "$deplib"
 	        deplib=$func_resolve_sysroot_result
@@ -7045,12 +8491,12 @@ func_mode_link ()
 		dir=$func_dirname_result
 		# We need an absolute path.
 		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
 		*)
 		  absdir=`cd "$dir" && pwd`
 		  if test -z "$absdir"; then
-		    func_warning "cannot determine absolute directory name of \`$dir'"
-		    absdir="$dir"
+		    func_warning "cannot determine absolute directory name of '$dir'"
+		    absdir=$dir
 		  fi
 		  ;;
 		esac
@@ -7058,35 +8504,35 @@ func_mode_link ()
 		case $host in
 		*-*-darwin*)
 		  depdepl=
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
+		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names"; then
+		    for tmp in $deplibrary_names; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$absdir/$objdir/$depdepl" ; then
-		      depdepl="$absdir/$objdir/$depdepl"
-		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+		    if test -f "$absdir/$objdir/$depdepl"; then
+		      depdepl=$absdir/$objdir/$depdepl
+		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
                       if test -z "$darwin_install_name"; then
-                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
                       fi
-		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
-		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
+		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
 		      path=
 		    fi
 		  fi
 		  ;;
 		*)
-		  path="-L$absdir/$objdir"
+		  path=-L$absdir/$objdir
 		  ;;
 		esac
 		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  test -z "$libdir" && \
-		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		    func_fatal_error "'$deplib' is not a valid libtool archive"
 		  test "$absdir" != "$libdir" && \
-		    func_warning "\`$deplib' seems to be moved"
+		    func_warning "'$deplib' seems to be moved"
 
-		  path="-L$absdir"
+		  path=-L$absdir
 		fi
 		;;
 	      esac
@@ -7098,23 +8544,23 @@ func_mode_link ()
 	  fi # link_all_deplibs != no
 	fi # linkmode = lib
       done # for deplib in $libs
-      if test "$pass" = link; then
-	if test "$linkmode" = "prog"; then
+      if test link = "$pass"; then
+	if test prog = "$linkmode"; then
 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
 	else
 	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
 	fi
       fi
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
+      dependency_libs=$newdependency_libs
+      if test dlpreopen = "$pass"; then
 	# Link the dlpreopened libraries before other libraries
 	for deplib in $save_deplibs; do
 	  deplibs="$deplib $deplibs"
 	done
       fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
+      if test dlopen != "$pass"; then
+	test conv = "$pass" || {
 	  # Make sure lib_search_path contains only unique directories.
 	  lib_search_path=
 	  for dir in $newlib_search_path; do
@@ -7124,12 +8570,12 @@ func_mode_link ()
 	    esac
 	  done
 	  newlib_search_path=
-	fi
+	}
 
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
+	if test prog,link = "$linkmode,$pass"; then
 	  vars="compile_deplibs finalize_deplibs"
+	else
+	  vars=deplibs
 	fi
 	for var in $vars dependency_libs; do
 	  # Add libraries to $var in reverse order
@@ -7187,62 +8633,93 @@ func_mode_link ()
 	  eval $var=\"$tmp_libs\"
 	done # for var
       fi
+
+      # Add Sun CC postdeps if required:
+      test CXX = "$tagname" && {
+        case $host_os in
+        linux*)
+          case `$CC -V 2>&1 | sed 5q` in
+          *Sun\ C*) # Sun C++ 5.9
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+
+        solaris*)
+          func_cc_basename "$CC"
+          case $func_cc_basename_result in
+          CC* | sunCC*)
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+        esac
+      }
+
       # Last step: remove runtime libs from dependency_libs
       # (they stay in deplibs)
       tmp_libs=
-      for i in $dependency_libs ; do
+      for i in $dependency_libs; do
 	case " $predeps $postdeps $compiler_lib_search_path " in
 	*" $i "*)
-	  i=""
+	  i=
 	  ;;
 	esac
-	if test -n "$i" ; then
+	if test -n "$i"; then
 	  func_append tmp_libs " $i"
 	fi
       done
       dependency_libs=$tmp_libs
     done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
+    if test prog = "$linkmode"; then
+      dlfiles=$newdlfiles
     fi
-    if test "$linkmode" = prog || test "$linkmode" = lib; then
-      dlprefiles="$newdlprefiles"
+    if test prog = "$linkmode" || test lib = "$linkmode"; then
+      dlprefiles=$newdlprefiles
     fi
 
     case $linkmode in
     oldlib)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for archives"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for archives"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+	func_warning "'-l' and '-L' are ignored for archives" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for archives"
+	func_warning "'-rpath' is ignored for archives"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for archives"
+	func_warning "'-R' is ignored for archives"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info/-version-number' is ignored for archives"
+	func_warning "'-version-info/-version-number' is ignored for archives"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for archives"
+	func_warning "'-release' is ignored for archives"
 
       test -n "$export_symbols$export_symbols_regex" && \
-	func_warning "\`-export-symbols' is ignored for archives"
+	func_warning "'-export-symbols' is ignored for archives"
 
       # Now set the variables for building old libraries.
       build_libtool_libs=no
-      oldlibs="$output"
+      oldlibs=$output
       func_append objs "$old_deplibs"
       ;;
 
     lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
+      # Make sure we only generate libraries of the form 'libNAME.la'.
       case $outputname in
       lib*)
 	func_stripname 'lib' '.la' "$outputname"
@@ -7251,10 +8728,10 @@ func_mode_link ()
 	eval libname=\"$libname_spec\"
 	;;
       *)
-	test "$module" = no && \
-	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+	test no = "$module" \
+	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
 
-	if test "$need_lib_prefix" != no; then
+	if test no != "$need_lib_prefix"; then
 	  # Add the "lib" prefix for modules if required
 	  func_stripname '' '.la' "$outputname"
 	  name=$func_stripname_result
@@ -7268,8 +8745,8 @@ func_mode_link ()
       esac
 
       if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	if test pass_all != "$deplibs_check_method"; then
+	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
 	else
 	  echo
 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
@@ -7278,21 +8755,21 @@ func_mode_link ()
 	fi
       fi
 
-      test "$dlself" != no && \
-	func_warning "\`-dlopen self' is ignored for libtool libraries"
+      test no = "$dlself" \
+	|| func_warning "'-dlopen self' is ignored for libtool libraries"
 
       set dummy $rpath
       shift
-      test "$#" -gt 1 && \
-	func_warning "ignoring multiple \`-rpath's for a libtool library"
+      test 1 -lt "$#" \
+	&& func_warning "ignoring multiple '-rpath's for a libtool library"
 
-      install_libdir="$1"
+      install_libdir=$1
 
       oldlibs=
       if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
+	if test yes = "$build_libtool_libs"; then
 	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
+	  # Some compilers have problems with a '.al' extension so
 	  # convenience libraries should have the same extension an
 	  # archive normally would.
 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
@@ -7301,20 +8778,20 @@ func_mode_link ()
 	fi
 
 	test -n "$vinfo" && \
-	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
 
 	test -n "$release" && \
-	  func_warning "\`-release' is ignored for convenience libraries"
+	  func_warning "'-release' is ignored for convenience libraries"
       else
 
 	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
+	save_ifs=$IFS; IFS=:
 	set dummy $vinfo 0 0 0
 	shift
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	test -n "$7" && \
-	  func_fatal_help "too many parameters to \`-version-info'"
+	  func_fatal_help "too many parameters to '-version-info'"
 
 	# convert absolute version numbers to libtool ages
 	# this retains compatibility with .la files and attempts
@@ -7322,45 +8799,45 @@ func_mode_link ()
 
 	case $vinfo_number in
 	yes)
-	  number_major="$1"
-	  number_minor="$2"
-	  number_revision="$3"
+	  number_major=$1
+	  number_minor=$2
+	  number_revision=$3
 	  #
 	  # There are really only two kinds -- those that
 	  # use the current revision as the major version
 	  # and those that subtract age and use age as
 	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
+	  # that has an extra 1 added just for fun
 	  #
 	  case $version_type in
 	  # correct linux to gnu/linux during the next big refactor
-	  darwin|linux|osf|windows|none)
+	  darwin|freebsd-elf|linux|osf|windows|none)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_revision"
+	    age=$number_minor
+	    revision=$number_revision
 	    ;;
-	  freebsd-aout|freebsd-elf|qnx|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
+	  freebsd-aout|qnx|sunos)
+	    current=$number_major
+	    revision=$number_minor
+	    age=0
 	    ;;
 	  irix|nonstopux)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_minor"
+	    age=$number_minor
+	    revision=$number_minor
 	    lt_irix_increment=no
 	    ;;
 	  *)
-	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
 	    ;;
 	  esac
 	  ;;
 	no)
-	  current="$1"
-	  revision="$2"
-	  age="$3"
+	  current=$1
+	  revision=$2
+	  age=$3
 	  ;;
 	esac
 
@@ -7368,30 +8845,30 @@ func_mode_link ()
 	case $current in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "CURRENT \`$current' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "CURRENT '$current' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $revision in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "REVISION \`$revision' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "REVISION '$revision' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $age in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "AGE \`$age' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	if test "$age" -gt "$current"; then
-	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' is greater than the current interface number '$current'"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	fi
 
 	# Calculate the version variables.
@@ -7406,26 +8883,36 @@ func_mode_link ()
 	  # verstring for coding it into the library header
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  # Darwin ld doesn't like 0 for these options...
 	  func_arith $current + 1
 	  minor_current=$func_arith_result
-	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+          # On Darwin other compilers
+          case $CC in
+              nagfor*)
+                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
+                  ;;
+              *)
+                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+                  ;;
+          esac
 	  ;;
 
 	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current"
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	irix | nonstopux)
-	  if test "X$lt_irix_increment" = "Xno"; then
+	  if test no = "$lt_irix_increment"; then
 	    func_arith $current - $age
 	  else
 	    func_arith $current - $age + 1
@@ -7436,69 +8923,74 @@ func_mode_link ()
 	    nonstopux) verstring_prefix=nonstopux ;;
 	    *)         verstring_prefix=sgi ;;
 	  esac
-	  verstring="$verstring_prefix$major.$revision"
+	  verstring=$verstring_prefix$major.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$revision
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $revision - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring_prefix$major.$iface:$verstring"
+	    verstring=$verstring_prefix$major.$iface:$verstring
 	  done
 
-	  # Before this point, $major must not contain `.'.
+	  # Before this point, $major must not contain '.'.
 	  major=.$major
-	  versuffix="$major.$revision"
+	  versuffix=$major.$revision
 	  ;;
 
 	linux) # correct to gnu/linux during the next big refactor
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	osf)
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
+	  versuffix=.$current.$age.$revision
+	  verstring=$current.$age.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$age
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $current - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring:${iface}.0"
+	    verstring=$verstring:$iface.0
 	  done
 
 	  # Make executables depend on our current version.
-	  func_append verstring ":${current}.0"
+	  func_append verstring ":$current.0"
 	  ;;
 
 	qnx)
-	  major=".$current"
-	  versuffix=".$current"
+	  major=.$current
+	  versuffix=.$current
+	  ;;
+
+	sco)
+	  major=.$current
+	  versuffix=.$current
 	  ;;
 
 	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	windows)
 	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
+	  # extension on DOS 8.3 file systems.
 	  func_arith $current - $age
 	  major=$func_arith_result
-	  versuffix="-$major"
+	  versuffix=-$major
 	  ;;
 
 	*)
-	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  func_fatal_configuration "unknown library version type '$version_type'"
 	  ;;
 	esac
 
@@ -7512,42 +9004,45 @@ func_mode_link ()
 	    verstring=
 	    ;;
 	  *)
-	    verstring="0.0"
+	    verstring=0.0
 	    ;;
 	  esac
-	  if test "$need_version" = no; then
+	  if test no = "$need_version"; then
 	    versuffix=
 	  else
-	    versuffix=".0.0"
+	    versuffix=.0.0
 	  fi
 	fi
 
 	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
+	if test yes,no = "$avoid_version,$need_version"; then
 	  major=
 	  versuffix=
-	  verstring=""
+	  verstring=
 	fi
 
 	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    func_warning "undefined symbols not allowed in $host shared libraries"
-	    build_libtool_libs=no
-	    build_old_libs=yes
+	if test yes = "$allow_undefined"; then
+	  if test unsupported = "$allow_undefined_flag"; then
+	    if test yes = "$build_old_libs"; then
+	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
+	      build_libtool_libs=no
+	    else
+	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
+	    fi
 	  fi
 	else
 	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
+	  allow_undefined_flag=$no_undefined_flag
 	fi
 
       fi
 
-      func_generate_dlsyms "$libname" "$libname" "yes"
+      func_generate_dlsyms "$libname" "$libname" :
       func_append libobjs " $symfileobj"
-      test "X$libobjs" = "X " && libobjs=
+      test " " = "$libobjs" && libobjs=
 
-      if test "$opt_mode" != relink; then
+      if test relink != "$opt_mode"; then
 	# Remove our outputs, but don't remove object files since they
 	# may have been created when compiling PIC objects.
 	removelist=
@@ -7556,8 +9051,8 @@ func_mode_link ()
 	  case $p in
 	    *.$objext | *.gcno)
 	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
+	       if test -n "$precious_files_regex"; then
 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
 		 then
 		   continue
@@ -7573,11 +9068,11 @@ func_mode_link ()
       fi
 
       # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
 	func_append oldlibs " $output_objdir/$libname.$libext"
 
 	# Transform .lo files to .o files.
-	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
       fi
 
       # Eliminate all temporary directories.
@@ -7598,13 +9093,13 @@ func_mode_link ()
 	  *) func_append finalize_rpath " $libdir" ;;
 	  esac
 	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
 	  dependency_libs="$temp_xrpath $dependency_libs"
 	fi
       fi
 
       # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
+      old_dlfiles=$dlfiles
       dlfiles=
       for lib in $old_dlfiles; do
 	case " $dlprefiles $dlfiles " in
@@ -7614,7 +9109,7 @@ func_mode_link ()
       done
 
       # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
+      old_dlprefiles=$dlprefiles
       dlprefiles=
       for lib in $old_dlprefiles; do
 	case "$dlprefiles " in
@@ -7623,7 +9118,7 @@ func_mode_link ()
 	esac
       done
 
-      if test "$build_libtool_libs" = yes; then
+      if test yes = "$build_libtool_libs"; then
 	if test -n "$rpath"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
@@ -7647,7 +9142,7 @@ func_mode_link ()
 	    ;;
 	  *)
 	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
+	    if test yes = "$build_libtool_need_lc"; then
 	      func_append deplibs " -lc"
 	    fi
 	    ;;
@@ -7663,9 +9158,9 @@ func_mode_link ()
 	# I'm not sure if I'm treating the release correctly.  I think
 	# release should show up in the -l (ie -lgmp5) so we don't want to
 	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
+	release=
+	versuffix=
+	major=
 	newdeplibs=
 	droppeddeps=no
 	case $deplibs_check_method in
@@ -7694,20 +9189,20 @@ EOF
 	      -l*)
 		func_stripname -l '' "$i"
 		name=$func_stripname_result
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
 		    func_append newdeplibs " $i"
-		    i=""
+		    i=
 		    ;;
 		  esac
 		fi
-		if test -n "$i" ; then
+		if test -n "$i"; then
 		  libname=`eval "\\$ECHO \"$libname_spec\""`
 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		  set dummy $deplib_matches; shift
 		  deplib_match=$1
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		    func_append newdeplibs " $i"
 		  else
 		    droppeddeps=yes
@@ -7737,20 +9232,20 @@ EOF
 		$opt_dry_run || $RM conftest
 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		    case " $predeps $postdeps " in
 		    *" $i "*)
 		      func_append newdeplibs " $i"
-		      i=""
+		      i=
 		      ;;
 		    esac
 		  fi
-		  if test -n "$i" ; then
+		  if test -n "$i"; then
 		    libname=`eval "\\$ECHO \"$libname_spec\""`
 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		    set dummy $deplib_matches; shift
 		    deplib_match=$1
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		      func_append newdeplibs " $i"
 		    else
 		      droppeddeps=yes
@@ -7787,24 +9282,24 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		if test -n "$file_magic_glob"; then
 		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
 		else
 		  libnameglob=$libname
 		fi
-		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  if test "$want_nocaseglob" = yes; then
+		  if test yes = "$want_nocaseglob"; then
 		    shopt -s nocaseglob
 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
 		    $nocaseglob
@@ -7822,25 +9317,25 @@ EOF
 		      # We might still enter an endless loop, since a link
 		      # loop can be closed while we follow links,
 		      # but so what?
-		      potlib="$potent_lib"
+		      potlib=$potent_lib
 		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
 			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
+			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
 			esac
 		      done
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
 			 $SED -e 10q |
 			 $EGREP "$file_magic_regex" > /dev/null; then
 			func_append newdeplibs " $a_deplib"
-			a_deplib=""
+			a_deplib=
 			break 2
 		      fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7848,7 +9343,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7871,30 +9366,30 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
 		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    potlib=$potent_lib # see symlink-check above in file_magic test
 		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
 		       $EGREP "$match_pattern_regex" > /dev/null; then
 		      func_append newdeplibs " $a_deplib"
-		      a_deplib=""
+		      a_deplib=
 		      break 2
 		    fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7902,7 +9397,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7918,18 +9413,18 @@ EOF
 	  done # Gone through all deplibs.
 	  ;;
 	none | unknown | *)
-	  newdeplibs=""
+	  newdeplibs=
 	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
+	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
+	    for i in $predeps $postdeps; do
 	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
 	    done
 	  fi
 	  case $tmp_deplibs in
 	  *[!\	\ ]*)
 	    echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
+	    if test none = "$deplibs_check_method"; then
 	      echo "*** Warning: inter-library dependencies are not supported in this platform."
 	    else
 	      echo "*** Warning: inter-library dependencies are not known to be supported."
@@ -7953,8 +9448,8 @@ EOF
 	  ;;
 	esac
 
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
+	if test yes = "$droppeddeps"; then
+	  if test yes = "$module"; then
 	    echo
 	    echo "*** Warning: libtool could not satisfy all declared inter-library"
 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
@@ -7963,12 +9458,12 @@ EOF
 	    if test -z "$global_symbol_pipe"; then
 	      echo
 	      echo "*** However, this would only work if libtool was able to extract symbol"
-	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 	      echo "*** not find such a program.  So, this module is probably useless."
-	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
+	    if test no = "$build_old_libs"; then
+	      oldlibs=$output_objdir/$libname.$libext
 	      build_libtool_libs=module
 	      build_old_libs=yes
 	    else
@@ -7979,14 +9474,14 @@ EOF
 	    echo "*** automatically added whenever a program is linked with this library"
 	    echo "*** or is declared to -dlopen it."
 
-	    if test "$allow_undefined" = no; then
+	    if test no = "$allow_undefined"; then
 	      echo
 	      echo "*** Since this library must not contain undefined symbols,"
 	      echo "*** because either the platform does not support them or"
 	      echo "*** it was explicitly requested with -no-undefined,"
 	      echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
+	      if test no = "$build_old_libs"; then
+		oldlibs=$output_objdir/$libname.$libext
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -8032,7 +9527,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      deplibs="$new_libs"
+      deplibs=$new_libs
 
       # All the library-specific variables (install_libdir is set above).
       library_names=
@@ -8040,25 +9535,25 @@ EOF
       dlname=
 
       # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	# Remove ${wl} instances when linking with ld.
+      if test yes = "$build_libtool_libs"; then
+	# Remove $wl instances when linking with ld.
 	# FIXME: should test the right _cmds variable.
 	case $archive_cmds in
 	  *\$LD\ *) wl= ;;
         esac
-	if test "$hardcode_into_libs" = yes; then
+	if test yes = "$hardcode_into_libs"; then
 	  # Hardcode the library paths
 	  hardcode_libdirs=
 	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+	  rpath=$finalize_rpath
+	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
 	  for libdir in $rpath; do
 	    if test -n "$hardcode_libdir_flag_spec"; then
 	      if test -n "$hardcode_libdir_separator"; then
 		func_replace_sysroot "$libdir"
 		libdir=$func_replace_sysroot_result
 		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
+		  hardcode_libdirs=$libdir
 		else
 		  # Just accumulate the unique libdirs.
 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8083,7 +9578,7 @@ EOF
 	  # Substitute the hardcoded libdirs into the rpath.
 	  if test -n "$hardcode_libdir_separator" &&
 	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
+	    libdir=$hardcode_libdirs
 	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
 	  fi
 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
@@ -8097,8 +9592,8 @@ EOF
 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
 	fi
 
-	shlibpath="$finalize_shlibpath"
-	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	shlibpath=$finalize_shlibpath
+	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
 	if test -n "$shlibpath"; then
 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
 	fi
@@ -8108,19 +9603,19 @@ EOF
 	eval library_names=\"$library_names_spec\"
 	set dummy $library_names
 	shift
-	realname="$1"
+	realname=$1
 	shift
 
 	if test -n "$soname_spec"; then
 	  eval soname=\"$soname_spec\"
 	else
-	  soname="$realname"
+	  soname=$realname
 	fi
 	if test -z "$dlname"; then
 	  dlname=$soname
 	fi
 
-	lib="$output_objdir/$realname"
+	lib=$output_objdir/$realname
 	linknames=
 	for link
 	do
@@ -8134,7 +9629,7 @@ EOF
 	delfiles=
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
-	  export_symbols="$output_objdir/$libname.uexp"
+	  export_symbols=$output_objdir/$libname.uexp
 	  func_append delfiles " $export_symbols"
 	fi
 
@@ -8143,31 +9638,31 @@ EOF
 	cygwin* | mingw* | cegcc*)
 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
 	    # exporting using user supplied symfile
-	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	    func_dll_def_p "$export_symbols" || {
 	      # and it's NOT already a .def file. Must figure out
 	      # which of the given symbols are data symbols and tag
 	      # them as such. So, trigger use of export_symbols_cmds.
 	      # export_symbols gets reassigned inside the "prepare
 	      # the list of exported symbols" if statement, so the
 	      # include_expsyms logic still works.
-	      orig_export_symbols="$export_symbols"
+	      orig_export_symbols=$export_symbols
 	      export_symbols=
 	      always_export_symbols=yes
-	    fi
+	    }
 	  fi
 	  ;;
 	esac
 
 	# Prepare the list of exported symbols
 	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    func_verbose "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
+	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for '$libname.la'"
+	    export_symbols=$output_objdir/$libname.exp
 	    $opt_dry_run || $RM $export_symbols
 	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd1 in $cmds; do
-	      IFS="$save_ifs"
+	      IFS=$save_ifs
 	      # Take the normal branch if the nm_file_list_spec branch
 	      # doesn't work or if tool conversion is not needed.
 	      case $nm_file_list_spec~$to_tool_file_cmd in
@@ -8181,7 +9676,7 @@ EOF
 		  try_normal_branch=no
 		  ;;
 	      esac
-	      if test "$try_normal_branch" = yes \
+	      if test yes = "$try_normal_branch" \
 		 && { test "$len" -lt "$max_cmd_len" \
 		      || test "$max_cmd_len" -le -1; }
 	      then
@@ -8192,7 +9687,7 @@ EOF
 		output_la=$func_basename_result
 		save_libobjs=$libobjs
 		save_output=$output
-		output=${output_objdir}/${output_la}.nm
+		output=$output_objdir/$output_la.nm
 		func_to_tool_file "$output"
 		libobjs=$nm_file_list_spec$func_to_tool_file_result
 		func_append delfiles " $output"
@@ -8215,8 +9710,8 @@ EOF
 		break
 	      fi
 	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	    IFS=$save_ifs
+	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
 	    fi
@@ -8224,16 +9719,16 @@ EOF
 	fi
 
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  tmp_export_symbols="$export_symbols"
-	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  tmp_export_symbols=$export_symbols
+	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	fi
 
-	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
 	  # The given exports_symbols file has to be filtered, so filter it.
-	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # 's' commands, which not all seds can handle. GNU sed should be fine
 	  # though. Also, the filter scales superlinearly with the number of
 	  # global variables. join(1) would be nice here, but unfortunately
 	  # isn't a blessed tool.
@@ -8252,11 +9747,11 @@ EOF
 	    ;;
 	  esac
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
 
 	if test -n "$convenience"; then
 	  if test -n "$whole_archive_flag_spec" &&
-	    test "$compiler_needs_object" = yes &&
+	    test yes = "$compiler_needs_object" &&
 	    test -z "$libobjs"; then
 	    # extract the archives, so we have objects to list.
 	    # TODO: could optimize this to just extract one archive.
@@ -8267,7 +9762,7 @@ EOF
 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
 	    test "X$libobjs" = "X " && libobjs=
 	  else
-	    gentop="$output_objdir/${outputname}x"
+	    gentop=$output_objdir/${outputname}x
 	    func_append generated " $gentop"
 
 	    func_extract_archives $gentop $convenience
@@ -8276,18 +9771,18 @@ EOF
 	  fi
 	fi
 
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
 	  eval flag=\"$thread_safe_flag_spec\"
 	  func_append linker_flags " $flag"
 	fi
 
 	# Make a backup of the uninstalled library when relinking
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
 	fi
 
 	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
+	if test yes = "$module" && test -n "$module_cmds"; then
 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	    eval test_cmds=\"$module_expsym_cmds\"
 	    cmds=$module_expsym_cmds
@@ -8305,7 +9800,7 @@ EOF
 	  fi
 	fi
 
-	if test "X$skipped_export" != "X:" &&
+	if test : != "$skipped_export" &&
 	   func_len " $test_cmds" &&
 	   len=$func_len_result &&
 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
@@ -8338,8 +9833,8 @@ EOF
 	  last_robj=
 	  k=1
 
-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
-	    output=${output_objdir}/${output_la}.lnkscript
+	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
+	    output=$output_objdir/$output_la.lnkscript
 	    func_verbose "creating GNU ld script: $output"
 	    echo 'INPUT (' > $output
 	    for obj in $save_libobjs
@@ -8351,14 +9846,14 @@ EOF
 	    func_append delfiles " $output"
 	    func_to_tool_file "$output"
 	    output=$func_to_tool_file_result
-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
-	    output=${output_objdir}/${output_la}.lnk
+	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
+	    output=$output_objdir/$output_la.lnk
 	    func_verbose "creating linker input file list: $output"
 	    : > $output
 	    set x $save_libobjs
 	    shift
 	    firstobj=
-	    if test "$compiler_needs_object" = yes; then
+	    if test yes = "$compiler_needs_object"; then
 	      firstobj="$1 "
 	      shift
 	    fi
@@ -8373,7 +9868,7 @@ EOF
 	  else
 	    if test -n "$save_libobjs"; then
 	      func_verbose "creating reloadable object files..."
-	      output=$output_objdir/$output_la-${k}.$objext
+	      output=$output_objdir/$output_la-$k.$objext
 	      eval test_cmds=\"$reload_cmds\"
 	      func_len " $test_cmds"
 	      len0=$func_len_result
@@ -8385,13 +9880,13 @@ EOF
 		func_len " $obj"
 		func_arith $len + $func_len_result
 		len=$func_arith_result
-		if test "X$objlist" = X ||
+		if test -z "$objlist" ||
 		   test "$len" -lt "$max_cmd_len"; then
 		  func_append objlist " $obj"
 		else
 		  # The command $test_cmds is almost too long, add a
 		  # command to the queue.
-		  if test "$k" -eq 1 ; then
+		  if test 1 -eq "$k"; then
 		    # The first file doesn't have a previous command to add.
 		    reload_objs=$objlist
 		    eval concat_cmds=\"$reload_cmds\"
@@ -8401,10 +9896,10 @@ EOF
 		    reload_objs="$objlist $last_robj"
 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
 		  fi
-		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  last_robj=$output_objdir/$output_la-$k.$objext
 		  func_arith $k + 1
 		  k=$func_arith_result
-		  output=$output_objdir/$output_la-${k}.$objext
+		  output=$output_objdir/$output_la-$k.$objext
 		  objlist=" $obj"
 		  func_len " $last_robj"
 		  func_arith $len0 + $func_len_result
@@ -8416,9 +9911,9 @@ EOF
 	      # files will link in the last one created.
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
 	      reload_objs="$objlist $last_robj"
-	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
 	      if test -n "$last_robj"; then
-	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
 	      func_append delfiles " $output"
 
@@ -8426,9 +9921,9 @@ EOF
 	      output=
 	    fi
 
-	    if ${skipped_export-false}; then
-	      func_verbose "generating symbol list for \`$libname.la'"
-	      export_symbols="$output_objdir/$libname.exp"
+	    ${skipped_export-false} && {
+	      func_verbose "generating symbol list for '$libname.la'"
+	      export_symbols=$output_objdir/$libname.exp
 	      $opt_dry_run || $RM $export_symbols
 	      libobjs=$output
 	      # Append the command to create the export file.
@@ -8437,16 +9932,16 @@ EOF
 	      if test -n "$last_robj"; then
 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
-	    fi
+	    }
 
 	    test -n "$save_libobjs" &&
 	      func_verbose "creating a temporary reloadable object file: $output"
 
 	    # Loop through the commands generated above and execute them.
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd in $concat_cmds; do
-	      IFS="$save_ifs"
-	      $opt_silent || {
+	      IFS=$save_ifs
+	      $opt_quiet || {
 		  func_quote_for_expand "$cmd"
 		  eval "func_echo $func_quote_for_expand_result"
 	      }
@@ -8454,7 +9949,7 @@ EOF
 		lt_exit=$?
 
 		# Restore the uninstalled library and exit
-		if test "$opt_mode" = relink; then
+		if test relink = "$opt_mode"; then
 		  ( cd "$output_objdir" && \
 		    $RM "${realname}T" && \
 		    $MV "${realname}U" "$realname" )
@@ -8463,7 +9958,7 @@ EOF
 		exit $lt_exit
 	      }
 	    done
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 
 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
@@ -8471,18 +9966,18 @@ EOF
 	    fi
 	  fi
 
-          if ${skipped_export-false}; then
+          ${skipped_export-false} && {
 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	      tmp_export_symbols="$export_symbols"
-	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      tmp_export_symbols=$export_symbols
+	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	    fi
 
 	    if test -n "$orig_export_symbols"; then
 	      # The given exports_symbols file has to be filtered, so filter it.
-	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # 's' commands, which not all seds can handle. GNU sed should be fine
 	      # though. Also, the filter scales superlinearly with the number of
 	      # global variables. join(1) would be nice here, but unfortunately
 	      # isn't a blessed tool.
@@ -8491,7 +9986,7 @@ EOF
 	      export_symbols=$output_objdir/$libname.def
 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
 	    fi
-	  fi
+	  }
 
 	  libobjs=$output
 	  # Restore the value of output.
@@ -8505,7 +10000,7 @@ EOF
 	  # value of $libobjs for piecewise linking.
 
 	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test yes = "$module" && test -n "$module_cmds"; then
 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	      cmds=$module_expsym_cmds
 	    else
@@ -8527,7 +10022,7 @@ EOF
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -8535,11 +10030,12 @@ EOF
 	  test "X$libobjs" = "X " && libobjs=
 	fi
 
-	save_ifs="$IFS"; IFS='~'
+	save_ifs=$IFS; IFS='~'
 	for cmd in $cmds; do
-	  IFS="$save_ifs"
+	  IFS=$sp$nl
 	  eval cmd=\"$cmd\"
-	  $opt_silent || {
+	  IFS=$save_ifs
+	  $opt_quiet || {
 	    func_quote_for_expand "$cmd"
 	    eval "func_echo $func_quote_for_expand_result"
 	  }
@@ -8547,7 +10043,7 @@ EOF
 	    lt_exit=$?
 
 	    # Restore the uninstalled library and exit
-	    if test "$opt_mode" = relink; then
+	    if test relink = "$opt_mode"; then
 	      ( cd "$output_objdir" && \
 	        $RM "${realname}T" && \
 		$MV "${realname}U" "$realname" )
@@ -8556,10 +10052,10 @@ EOF
 	    exit $lt_exit
 	  }
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	# Restore the uninstalled library and exit
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
 
 	  if test -n "$convenience"; then
@@ -8579,39 +10075,39 @@ EOF
 	done
 
 	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
+	if test yes = "$module" || test yes = "$export_dynamic"; then
 	  # On all known operating systems, these are identical.
-	  dlname="$soname"
+	  dlname=$soname
 	fi
       fi
       ;;
 
     obj)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for objects"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for objects"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+	func_warning "'-l' and '-L' are ignored for objects" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for objects"
+	func_warning "'-rpath' is ignored for objects"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for objects"
+	func_warning "'-R' is ignored for objects"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for objects"
+	func_warning "'-version-info' is ignored for objects"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for objects"
+	func_warning "'-release' is ignored for objects"
 
       case $output in
       *.lo)
 	test -n "$objs$old_deplibs" && \
-	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
 
 	libobj=$output
 	func_lo2o "$libobj"
@@ -8619,7 +10115,7 @@ EOF
 	;;
       *)
 	libobj=
-	obj="$output"
+	obj=$output
 	;;
       esac
 
@@ -8632,17 +10128,19 @@ EOF
       # the extraction.
       reload_conv_objs=
       gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec and hope we can get by with
-      # turning comma into space..
-      wl=
-
+      # if reload_cmds runs $LD directly, get rid of -Wl from
+      # whole_archive_flag_spec and hope we can get by with turning comma
+      # into space.
+      case $reload_cmds in
+        *\$LD[\ \$]*) wl= ;;
+      esac
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
-	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
 	else
-	  gentop="$output_objdir/${obj}x"
+	  gentop=$output_objdir/${obj}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $convenience
@@ -8651,12 +10149,12 @@ EOF
       fi
 
       # If we're not building shared, we need to use non_pic_objs
-      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
 
       # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
 
-      output="$obj"
+      output=$obj
       func_execute_cmds "$reload_cmds" 'exit $?'
 
       # Exit if we aren't doing a library object file.
@@ -8668,7 +10166,7 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$build_libtool_libs" != yes; then
+      test yes = "$build_libtool_libs" || {
 	if test -n "$gentop"; then
 	  func_show_eval '${RM}r "$gentop"'
 	fi
@@ -8678,12 +10176,12 @@ EOF
 	# $show "echo timestamp > $libobj"
 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
 	exit $EXIT_SUCCESS
-      fi
+      }
 
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
+      if test -n "$pic_flag" || test default != "$pic_mode"; then
 	# Only do commands if we really have different PIC objects.
 	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
+	output=$libobj
 	func_execute_cmds "$reload_cmds" 'exit $?'
       fi
 
@@ -8700,16 +10198,14 @@ EOF
 	          output=$func_stripname_result.exe;;
       esac
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for programs"
+	func_warning "'-version-info' is ignored for programs"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for programs"
+	func_warning "'-release' is ignored for programs"
 
-      test "$preload" = yes \
-        && test "$dlopen_support" = unknown \
-	&& test "$dlopen_self" = unknown \
-	&& test "$dlopen_self_static" = unknown && \
-	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+      $preload \
+	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
+	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
 
       case $host in
       *-*-rhapsody* | *-*-darwin1.[012])
@@ -8723,11 +10219,11 @@ EOF
       *-*-darwin*)
 	# Don't allow lazy linking, it breaks C++ global constructors
 	# But is supposedly fixed on 10.4 or later (yay!).
-	if test "$tagname" = CXX ; then
+	if test CXX = "$tagname"; then
 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
 	    10.[0123])
-	      func_append compile_command " ${wl}-bind_at_load"
-	      func_append finalize_command " ${wl}-bind_at_load"
+	      func_append compile_command " $wl-bind_at_load"
+	      func_append finalize_command " $wl-bind_at_load"
 	    ;;
 	  esac
 	fi
@@ -8763,7 +10259,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      compile_deplibs="$new_libs"
+      compile_deplibs=$new_libs
 
 
       func_append compile_command " $compile_deplibs"
@@ -8787,7 +10283,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8810,7 +10306,7 @@ EOF
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  ::) dllsearchpath=$libdir;;
@@ -8827,10 +10323,10 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      compile_rpath="$rpath"
+      compile_rpath=$rpath
 
       rpath=
       hardcode_libdirs=
@@ -8838,7 +10334,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8863,45 +10359,43 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      finalize_rpath="$rpath"
+      finalize_rpath=$rpath
 
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+      if test -n "$libobjs" && test yes = "$build_old_libs"; then
 	# Transform all the library objects into standard objects.
 	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
       fi
 
-      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+      func_generate_dlsyms "$outputname" "@PROGRAM@" false
 
       # template prelinking step
       if test -n "$prelink_cmds"; then
 	func_execute_cmds "$prelink_cmds" 'exit $?'
       fi
 
-      wrappers_required=yes
+      wrappers_required=:
       case $host in
       *cegcc* | *mingw32ce*)
         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
-        wrappers_required=no
+        wrappers_required=false
         ;;
       *cygwin* | *mingw* )
-        if test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
+        test yes = "$build_libtool_libs" || wrappers_required=false
         ;;
       *)
-        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-          wrappers_required=no
+        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
+          wrappers_required=false
         fi
         ;;
       esac
-      if test "$wrappers_required" = no; then
+      $wrappers_required || {
 	# Replace the output file specification.
 	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
+	link_command=$compile_command$compile_rpath
 
 	# We have no uninstalled library dependencies, so finalize right now.
 	exit_status=0
@@ -8914,12 +10408,12 @@ EOF
 	fi
 
 	# Delete the generated files.
-	if test -f "$output_objdir/${outputname}S.${objext}"; then
-	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	if test -f "$output_objdir/${outputname}S.$objext"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
 	fi
 
 	exit $exit_status
-      fi
+      }
 
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
@@ -8949,9 +10443,9 @@ EOF
 	fi
       fi
 
-      if test "$no_install" = yes; then
+      if test yes = "$no_install"; then
 	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
+	link_command=$compile_var$compile_command$compile_rpath
 	# Replace the output file specification.
 	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
 	# Delete the old output file.
@@ -8968,27 +10462,28 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
+      case $hardcode_action,$fast_install in
+        relink,*)
+	  # Fast installation is not supported
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
 
-	func_warning "this platform does not like uninstalled shared libraries"
-	func_warning "\`$output' will be relinked during installation"
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
+	  func_warning "this platform does not like uninstalled shared libraries"
+	  func_warning "'$output' will be relinked during installation"
+	  ;;
+        *,yes)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+          ;;
+	*,no)
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
+          ;;
+	*,needless)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=
+          ;;
+      esac
 
       # Replace the output file specification.
       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
@@ -9045,8 +10540,8 @@ EOF
 	    func_dirname_and_basename "$output" "" "."
 	    output_name=$func_basename_result
 	    output_path=$func_dirname_result
-	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
-	    cwrapper="$output_path/$output_name.exe"
+	    cwrappersource=$output_path/$objdir/lt-$output_name.c
+	    cwrapper=$output_path/$output_name.exe
 	    $RM $cwrappersource $cwrapper
 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
@@ -9067,7 +10562,7 @@ EOF
 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
 	    $opt_dry_run || {
 	      # note: this script will not be executed, so do not chmod.
-	      if test "x$build" = "x$host" ; then
+	      if test "x$build" = "x$host"; then
 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
 	      else
 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
@@ -9090,25 +10585,27 @@ EOF
     # See if we need to build an old-fashioned archive.
     for oldlib in $oldlibs; do
 
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save $symfileobj"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
+      case $build_libtool_libs in
+        convenience)
+	  oldobjs="$libobjs_save $symfileobj"
+	  addlibs=$convenience
 	  build_libtool_libs=no
-	else
+	  ;;
+	module)
+	  oldobjs=$libobjs_save
+	  addlibs=$old_convenience
+	  build_libtool_libs=no
+          ;;
+	*)
 	  oldobjs="$old_deplibs $non_pic_objects"
-	  if test "$preload" = yes && test -f "$symfileobj"; then
-	    func_append oldobjs " $symfileobj"
-	  fi
-	fi
-	addlibs="$old_convenience"
-      fi
+	  $preload && test -f "$symfileobj" \
+	    && func_append oldobjs " $symfileobj"
+	  addlibs=$old_convenience
+	  ;;
+      esac
 
       if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
+	gentop=$output_objdir/${outputname}x
 	func_append generated " $gentop"
 
 	func_extract_archives $gentop $addlibs
@@ -9116,13 +10613,13 @@ EOF
       fi
 
       # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
 	cmds=$old_archive_from_new_cmds
       else
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -9143,7 +10640,7 @@ EOF
 	  :
 	else
 	  echo "copying selected object files to avoid basename conflicts..."
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 	  func_mkdir_p "$gentop"
 	  save_oldobjs=$oldobjs
@@ -9152,7 +10649,7 @@ EOF
 	  for obj in $save_oldobjs
 	  do
 	    func_basename "$obj"
-	    objbase="$func_basename_result"
+	    objbase=$func_basename_result
 	    case " $oldobjs " in
 	    " ") oldobjs=$obj ;;
 	    *[\ /]"$objbase "*)
@@ -9221,18 +10718,18 @@ EOF
 	    else
 	      # the above command should be used before it gets too long
 	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
+	      if test "$obj" = "$last_oldobj"; then
 		RANLIB=$save_RANLIB
 	      fi
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
 	      objlist=
 	      len=$len0
 	    fi
 	  done
 	  RANLIB=$save_RANLIB
 	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
+	  if test -z "$oldobjs"; then
 	    eval cmds=\"\$concat_cmds\"
 	  else
 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
@@ -9249,7 +10746,7 @@ EOF
     case $output in
     *.la)
       old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      test yes = "$build_old_libs" && old_library=$libname.$libext
       func_verbose "creating $output"
 
       # Preserve any variables that may affect compiler behavior
@@ -9264,31 +10761,31 @@ EOF
 	fi
       done
       # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
+      if test yes = "$hardcode_automatic"; then
 	relink_command=
       fi
 
       # Only create the output if not a dry run.
       $opt_dry_run || {
 	for installed in no yes; do
-	  if test "$installed" = yes; then
+	  if test yes = "$installed"; then
 	    if test -z "$install_libdir"; then
 	      break
 	    fi
-	    output="$output_objdir/$outputname"i
+	    output=$output_objdir/${outputname}i
 	    # Replace all uninstalled libtool libraries with the installed ones
 	    newdependency_libs=
 	    for deplib in $dependency_libs; do
 	      case $deplib in
 	      *.la)
 		func_basename "$deplib"
-		name="$func_basename_result"
+		name=$func_basename_result
 		func_resolve_sysroot "$deplib"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  func_fatal_error "'$deplib' is not a valid libtool archive"
 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      -L*)
@@ -9304,23 +10801,23 @@ EOF
 	      *) func_append newdependency_libs " $deplib" ;;
 	      esac
 	    done
-	    dependency_libs="$newdependency_libs"
+	    dependency_libs=$newdependency_libs
 	    newdlfiles=
 
 	    for lib in $dlfiles; do
 	      case $lib in
 	      *.la)
 	        func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      *) func_append newdlfiles " $lib" ;;
 	      esac
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
@@ -9330,34 +10827,34 @@ EOF
 		# didn't already link the preopened objects directly into
 		# the library:
 		func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      esac
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  else
 	    newdlfiles=
 	    for lib in $dlfiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlfiles " $abs"
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlprefiles " $abs"
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  fi
 	  $RM $output
 	  # place dlname in correct position for cygwin
@@ -9373,10 +10870,9 @@ EOF
 	  case $host,$output,$installed,$module,$dlname in
 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
 	      # If a -bindir argument was supplied, place the dll there.
-	      if test "x$bindir" != x ;
-	      then
+	      if test -n "$bindir"; then
 		func_relative_path "$install_libdir" "$bindir"
-		tdlname=$func_relative_path_result$dlname
+		tdlname=$func_relative_path_result/$dlname
 	      else
 		# Otherwise fall back on heuristic.
 		tdlname=../bin/$dlname
@@ -9385,7 +10881,7 @@ EOF
 	  esac
 	  $ECHO > $output "\
 # $outputname - a libtool library file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -9399,7 +10895,7 @@ library_names='$library_names'
 # The name of the static archive.
 old_library='$old_library'
 
-# Linker flags that can not go in dependency_libs.
+# Linker flags that cannot go in dependency_libs.
 inherited_linker_flags='$new_inherited_linker_flags'
 
 # Libraries that this one depends upon.
@@ -9425,7 +10921,7 @@ dlpreopen='$dlprefiles'
 
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
+	  if test no,yes = "$installed,$need_relink"; then
 	    $ECHO >> $output "\
 relink_command=\"$relink_command\""
 	  fi
@@ -9440,27 +10936,29 @@ relink_command=\"$relink_command\""
     exit $EXIT_SUCCESS
 }
 
-{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
-    func_mode_link ${1+"$@"}
+if test link = "$opt_mode" || test relink = "$opt_mode"; then
+  func_mode_link ${1+"$@"}
+fi
 
 
 # func_mode_uninstall arg...
 func_mode_uninstall ()
 {
-    $opt_debug
-    RM="$nonopt"
+    $debug_cmd
+
+    RM=$nonopt
     files=
-    rmforce=
+    rmforce=false
     exit_status=0
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     for arg
     do
       case $arg in
-      -f) func_append RM " $arg"; rmforce=yes ;;
+      -f) func_append RM " $arg"; rmforce=: ;;
       -*) func_append RM " $arg" ;;
       *) func_append files " $arg" ;;
       esac
@@ -9473,18 +10971,18 @@ func_mode_uninstall ()
 
     for file in $files; do
       func_dirname "$file" "" "."
-      dir="$func_dirname_result"
-      if test "X$dir" = X.; then
-	odir="$objdir"
+      dir=$func_dirname_result
+      if test . = "$dir"; then
+	odir=$objdir
       else
-	odir="$dir/$objdir"
+	odir=$dir/$objdir
       fi
       func_basename "$file"
-      name="$func_basename_result"
-      test "$opt_mode" = uninstall && odir="$dir"
+      name=$func_basename_result
+      test uninstall = "$opt_mode" && odir=$dir
 
       # Remember odir for removal later, being careful to avoid duplicates
-      if test "$opt_mode" = clean; then
+      if test clean = "$opt_mode"; then
 	case " $rmdirs " in
 	  *" $odir "*) ;;
 	  *) func_append rmdirs " $odir" ;;
@@ -9499,11 +10997,11 @@ func_mode_uninstall ()
       elif test -d "$file"; then
 	exit_status=1
 	continue
-      elif test "$rmforce" = yes; then
+      elif $rmforce; then
 	continue
       fi
 
-      rmfiles="$file"
+      rmfiles=$file
 
       case $name in
       *.la)
@@ -9517,7 +11015,7 @@ func_mode_uninstall ()
 	  done
 	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
 
-	  case "$opt_mode" in
+	  case $opt_mode in
 	  clean)
 	    case " $library_names " in
 	    *" $dlname "*) ;;
@@ -9528,12 +11026,12 @@ func_mode_uninstall ()
 	  uninstall)
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
-	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 
 	    if test -n "$old_library"; then
 	      # Do each command in the old_postuninstall commands.
-	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
 	    ;;
@@ -9549,21 +11047,19 @@ func_mode_uninstall ()
 	  func_source $dir/$name
 
 	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" &&
-	     test "$pic_object" != none; then
+	  if test -n "$pic_object" && test none != "$pic_object"; then
 	    func_append rmfiles " $dir/$pic_object"
 	  fi
 
 	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" &&
-	     test "$non_pic_object" != none; then
+	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
 	    func_append rmfiles " $dir/$non_pic_object"
 	  fi
 	fi
 	;;
 
       *)
-	if test "$opt_mode" = clean ; then
+	if test clean = "$opt_mode"; then
 	  noexename=$name
 	  case $file in
 	  *.exe)
@@ -9590,12 +11086,12 @@ func_mode_uninstall ()
 
 	    # note $name still contains .exe if it was in $file originally
 	    # as does the version of $file that was added into $rmfiles
-	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
+	    if test yes = "$fast_install" && test -n "$relink_command"; then
 	      func_append rmfiles " $odir/lt-$name"
 	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      func_append rmfiles " $odir/lt-${noexename}.c"
+	    if test "X$noexename" != "X$name"; then
+	      func_append rmfiles " $odir/lt-$noexename.c"
 	    fi
 	  fi
 	fi
@@ -9604,7 +11100,7 @@ func_mode_uninstall ()
       func_show_eval "$RM $rmfiles" 'exit_status=1'
     done
 
-    # Try to remove the ${objdir}s in the directories where we deleted files
+    # Try to remove the $objdir's in the directories where we deleted files
     for dir in $rmdirs; do
       if test -d "$dir"; then
 	func_show_eval "rmdir $dir >/dev/null 2>&1"
@@ -9614,16 +11110,17 @@ func_mode_uninstall ()
     exit $exit_status
 }
 
-{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
-    func_mode_uninstall ${1+"$@"}
+if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
+  func_mode_uninstall ${1+"$@"}
+fi
 
 test -z "$opt_mode" && {
-  help="$generic_help"
+  help=$generic_help
   func_fatal_help "you must specify a MODE"
 }
 
 test -z "$exec_cmd" && \
-  func_fatal_help "invalid operation mode \`$opt_mode'"
+  func_fatal_help "invalid operation mode '$opt_mode'"
 
 if test -n "$exec_cmd"; then
   eval exec "$exec_cmd"
@@ -9634,7 +11131,7 @@ exit $exit_status
 
 
 # The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
+# where we disable both kinds of libraries.  Given conflicting
 # choices, we go for a static library, that is the most portable,
 # since we can't tell whether shared libraries were disabled because
 # the user asked for that or because the platform doesn't support
@@ -9657,5 +11154,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
 # mode:shell-script
 # sh-indentation:2
 # End:
-# vi:sw=2
-
diff --git a/src/gmock/build-aux/missing b/src/gmock/build-aux/missing
index db98974..f62bbae 100755
--- a/src/gmock/build-aux/missing
+++ b/src/gmock/build-aux/missing
@@ -3,7 +3,7 @@
 
 scriptversion=2013-10-28.13; # UTC
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
diff --git a/src/gmock/build-aux/test-driver b/src/gmock/build-aux/test-driver
index d306056..8e575b0 100755
--- a/src/gmock/build-aux/test-driver
+++ b/src/gmock/build-aux/test-driver
@@ -3,7 +3,7 @@
 
 scriptversion=2013-07-13.22; # UTC
 
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -106,11 +106,14 @@ trap "st=143; $do_exit" 15
 # Test script is run here.
 "$@" >$log_file 2>&1
 estatus=$?
+
 if test $enable_hard_errors = no && test $estatus -eq 99; then
-  estatus=1
+  tweaked_estatus=1
+else
+  tweaked_estatus=$estatus
 fi
 
-case $estatus:$expect_failure in
+case $tweaked_estatus:$expect_failure in
   0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
   0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
   77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
@@ -119,6 +122,12 @@ case $estatus:$expect_failure in
   *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
 esac
 
+# Report the test outcome and exit status in the logs, so that one can
+# know whether the test passed or failed simply by looking at the '.log'
+# file, without the need of also peaking into the corresponding '.trs'
+# file (automake bug#11814).
+echo "$res $test_name (exit status: $estatus)" >>$log_file
+
 # Report outcome to console.
 echo "${col}${res}${std}: $test_name"
 
diff --git a/src/gmock/configure b/src/gmock/configure
index 04e603a..be52680 100755
--- a/src/gmock/configure
+++ b/src/gmock/configure
@@ -655,6 +655,7 @@ HAVE_PYTHON_TRUE
 PYTHON
 CXXCPP
 CPP
+LT_SYS_LIBRARY_PATH
 OTOOL64
 OTOOL
 LIPO
@@ -753,6 +754,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -781,6 +783,7 @@ enable_shared
 enable_static
 with_pic
 enable_fast_install
+with_aix_soname
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -799,6 +802,7 @@ CPPFLAGS
 CXX
 CXXFLAGS
 CCC
+LT_SYS_LIBRARY_PATH
 CPP
 CXXCPP
 GTEST_CONFIG
@@ -845,6 +849,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1097,6 +1102,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1234,7 +1248,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1387,6 +1401,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1447,9 +1462,12 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-aix-soname=aix|svr4|both
+                          shared library versioning (aka "SONAME") variant to
+                          provide on AIX, [default=aix].
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
-  --with-sysroot=DIR Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).
+  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
+                          compiler's sysroot if not specified).
   --with-pthreads         use pthreads (default is yes)
   --with-gtest            Specifies how to find the gtest package. If no
                           arguments are given, the default behavior, a system
@@ -1468,6 +1486,8 @@ Some influential environment variables:
               you have headers in a nonstandard directory <include dir>
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  LT_SYS_LIBRARY_PATH
+              User-defined run-time library search path.
   CPP         C preprocessor
   CXXCPP      C++ preprocessor
   GTEST_CONFIG
@@ -2338,7 +2358,7 @@ ac_config_files="$ac_config_files scripts/gmock-config"
 # Initialize Automake with various options. We require at least v1.9, prevent
 # pedantic complaints about package files, and enable various distribution
 # targets.
-am__api_version='1.14'
+am__api_version='1.15'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -2510,8 +2530,8 @@ test "$program_suffix" != NONE &&
 ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 if test x"${MISSING+set}" != xset; then
   case $am_aux_dir in
@@ -2530,7 +2550,7 @@ else
 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -2858,8 +2878,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 mkdir_p='$(MKDIR_P)'
 
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
@@ -2917,6 +2937,7 @@ END
   fi
 fi
 
+
 # Check for programs used in building Google Test.
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -4356,8 +4377,8 @@ esac
 
 
 
-macro_version='2.4.2'
-macro_revision='1.3337'
+macro_version='2.4.6'
+macro_revision='2.4.6'
 
 
 
@@ -4371,7 +4392,7 @@ macro_revision='1.3337'
 
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@@ -4491,7 +4512,7 @@ func_echo_all ()
     $ECHO ""
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
 $as_echo "printf" >&6; } ;;
   print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
@@ -4814,19 +4835,19 @@ test -z "$GREP" && GREP=grep
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -4840,7 +4861,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -4851,7 +4872,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -4862,32 +4883,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -4930,33 +4951,38 @@ if ${lt_cv_path_NM+:} false; then :
 else
   if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -4967,15 +4993,15 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
@@ -5081,9 +5107,9 @@ esac
   fi
 fi
 
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -5091,8 +5117,8 @@ fi
     esac
   fi
 
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -5143,7 +5169,7 @@ if ${lt_cv_sys_max_cmd_len+:} false; then :
   $as_echo_n "(cached) " >&6
 else
     i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -5183,7 +5209,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -5234,22 +5260,22 @@ else
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -5267,7 +5293,7 @@ else
 
 fi
 
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 else
@@ -5285,30 +5311,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
-$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
-$as_echo "$xsi_shell" >&6; }
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
-$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
-$as_echo "$lt_shell_append" >&6; }
-
-
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
@@ -5431,13 +5433,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -5565,13 +5567,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[4-9]*)
@@ -5598,8 +5600,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -5695,8 +5696,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
@@ -5749,6 +5750,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 
 fi
@@ -5906,8 +5910,8 @@ else
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -5919,7 +5923,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 
@@ -6074,7 +6078,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
@@ -6082,7 +6086,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -6095,7 +6099,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
 $as_echo "$lt_cv_ar_at_file" >&6; }
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -6312,7 +6316,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -6402,7 +6406,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[ABCDEGRST]'
   fi
   ;;
@@ -6435,14 +6439,44 @@ case `$NM -V 2>&1` in
   symcode='[ABCDGIRSTW]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -6460,21 +6494,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK '"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -6522,11 +6559,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
@@ -6552,7 +6589,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -6572,13 +6609,13 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
 	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -6599,7 +6636,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -6652,6 +6689,16 @@ fi
 
 
 
+
+
+
+
+
+
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
 $as_echo_n "checking for sysroot... " >&6; }
 
@@ -6664,9 +6711,9 @@ fi
 
 
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -6676,8 +6723,8 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
-$as_echo "${with_sysroot}" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+$as_echo "$with_sysroot" >&6; }
    as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
    ;;
 esac
@@ -6689,19 +6736,100 @@ $as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+$as_echo_n "checking for a working dd... " >&6; }
+if ${ac_cv_path_lt_DD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+if test -z "$lt_DD"; then
+  ac_path_lt_DD_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in dd; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_lt_DD" || continue
+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi
+      $ac_path_lt_DD_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_lt_DD"; then
+    :
+  fi
+else
+  ac_cv_path_lt_DD=$lt_DD
+fi
+
+rm -f conftest.i conftest2.i conftest.out
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+$as_echo "$ac_cv_path_lt_DD" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+$as_echo_n "checking how to truncate binary pipes... " >&6; }
+if ${lt_cv_truncate_bin+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+$as_echo "$lt_cv_truncate_bin" >&6; }
+
+
+
+
+
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
 
 # Check whether --enable-libtool-lock was given.
 if test "${enable_libtool_lock+set}" = set; then :
   enableval=$enable_libtool_lock;
 fi
 
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -6710,24 +6838,25 @@ ia64-*-hpux*)
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '#line '$LINENO' "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -6756,9 +6885,50 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -6781,10 +6951,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -6803,10 +6973,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -6824,7 +6994,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
@@ -6864,13 +7034,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
 $as_echo "$lt_cv_cc_needs_belf" >&6; }
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -6882,7 +7053,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -6891,7 +7062,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -6907,7 +7078,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
@@ -7018,7 +7189,7 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
 $as_echo "$lt_cv_path_mainfest_tool" >&6; }
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 
@@ -7521,7 +7692,7 @@ if ${lt_cv_apple_cc_single_mod+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -7539,7 +7710,7 @@ else
 	  cat conftest.err >&5
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&5
@@ -7578,7 +7749,7 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
@@ -7607,7 +7778,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&5
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&5
@@ -7620,32 +7791,32 @@ fi
 $as_echo "$lt_cv_ld_force_load" >&6; }
     case $host_os in
     rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[012]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[012][,.]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -7653,6 +7824,41 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
     ;;
   esac
 
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -7937,9 +8143,9 @@ done
 
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case $2 in
+  .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;;
   esac
 } # func_stripname_cnf
 
@@ -7966,14 +8172,14 @@ if test "${enable_shared+set}" = set; then :
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -7997,14 +8203,14 @@ if test "${enable_static+set}" = set; then :
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8028,14 +8234,14 @@ if test "${with_pic+set}" = set; then :
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8043,8 +8249,6 @@ else
 fi
 
 
-test -z "$pic_mode" && pic_mode=default
-
 
 
 
@@ -8060,14 +8264,14 @@ if test "${enable_fast_install+set}" = set; then :
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8081,11 +8285,63 @@ fi
 
 
 
+  shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[5-9]*,yes)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+$as_echo_n "checking which variant of shared library versioning to provide... " >&6; }
+
+# Check whether --with-aix-soname was given.
+if test "${with_aix_soname+set}" = set; then :
+  withval=$with_aix_soname; case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname
+else
+  if ${lt_cv_with_aix_soname+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_with_aix_soname=aix
+fi
+
+    with_aix_soname=$lt_cv_with_aix_soname
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+$as_echo "$with_aix_soname" >&6; }
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+
+
+
+
+
+
 
 
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -8134,7 +8390,7 @@ test -z "$LN_S" && LN_S="ln -s"
 
 
 
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -8173,7 +8429,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -8184,14 +8440,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -8200,15 +8456,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$LD" && LD=ld
 test -z "$ac_objext" && ac_objext=o
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
 # Only perform the check for file, if the check method requires it
@@ -8223,22 +8472,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+    if test -f "$ac_dir/${ac_tool_prefix}file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8261,13 +8510,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8289,22 +8538,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+    if test -f "$ac_dir/file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8327,13 +8576,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8354,7 +8603,7 @@ esac
 
 # Use C for the default configuration in the libtool script
 
-lt_save_CC="$CC"
+lt_save_CC=$CC
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -8412,7 +8661,7 @@ if test -n "$compiler"; then
 
 lt_prog_compiler_no_builtin_flag=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
@@ -8428,7 +8677,7 @@ else
   lt_cv_prog_compiler_rtti_exceptions=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -8458,7 +8707,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
     lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
 else
     :
@@ -8476,17 +8725,18 @@ lt_prog_compiler_pic=
 lt_prog_compiler_static=
 
 
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     lt_prog_compiler_wl='-Wl,'
     lt_prog_compiler_static='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       fi
+      lt_prog_compiler_pic='-fPIC'
       ;;
 
     amigaos*)
@@ -8497,8 +8747,8 @@ lt_prog_compiler_static=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -8514,6 +8764,11 @@ lt_prog_compiler_static=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -8584,7 +8839,7 @@ lt_prog_compiler_static=
     case $host_os in
     aix*)
       lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       else
@@ -8592,10 +8847,29 @@ lt_prog_compiler_static=
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        lt_prog_compiler_wl='-Wl,-Wl,,'
+        lt_prog_compiler_pic='-PIC'
+        lt_prog_compiler_static='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -8611,7 +8885,7 @@ lt_prog_compiler_static=
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      lt_prog_compiler_static='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -8622,7 +8896,7 @@ lt_prog_compiler_static=
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
@@ -8647,6 +8921,12 @@ lt_prog_compiler_static=
 	lt_prog_compiler_pic='-PIC'
 	lt_prog_compiler_static='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -8744,7 +9024,7 @@ lt_prog_compiler_static=
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	lt_prog_compiler_pic='-Kconform_pic'
 	lt_prog_compiler_static='-Bstatic'
       fi
@@ -8773,7 +9053,7 @@ lt_prog_compiler_static=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
     ;;
@@ -8805,7 +9085,7 @@ else
   lt_cv_prog_compiler_pic_works=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -8835,7 +9115,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works"; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -8867,7 +9147,7 @@ if ${lt_cv_prog_compiler_static_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -8886,13 +9166,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works"; then
     :
 else
     lt_prog_compiler_static=
@@ -9012,8 +9292,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -9025,9 +9305,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -9070,9 +9350,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # included in the symbol list
   include_expsyms=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -9087,7 +9367,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -9095,7 +9375,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
   linux* | k*bsd*-gnu | gnu*)
@@ -9108,7 +9388,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -9130,24 +9410,24 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
+    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+    export_dynamic_flag_spec='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       whole_archive_flag_spec=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -9160,7 +9440,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     case $host_os in
     aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
@@ -9179,7 +9459,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -9195,7 +9475,7 @@ _LT_EOF
 	allow_undefined_flag=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9205,7 +9485,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      export_dynamic_flag_spec='$wl--export-all-symbols'
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
@@ -9213,61 +9493,89 @@ _LT_EOF
       exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	ld_shlibs=no
       fi
       ;;
 
     haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       link_all_deplibs=yes
       ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
     interix[3-9]*)
       hardcode_direct=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
+      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+      export_dynamic_flag_spec='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -9278,42 +9586,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  whole_archive_flag_spec=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  export_dynamic_flag_spec='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	  hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
 	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -9327,8 +9640,8 @@ _LT_EOF
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -9346,8 +9659,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9359,7 +9672,7 @@ _LT_EOF
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -9374,9 +9687,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    ld_shlibs=no
 	  fi
@@ -9393,15 +9706,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
+    if test no = "$ld_shlibs"; then
       runpath_var=
       hardcode_libdir_flag_spec=
       export_dynamic_flag_spec=
@@ -9417,7 +9730,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
@@ -9425,34 +9738,57 @@ _LT_EOF
       ;;
 
     aix[4-9]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -9471,13 +9807,21 @@ _LT_EOF
       hardcode_direct_absolute=yes
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      file_list_spec='${wl}-f,'
+      file_list_spec='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	hardcode_direct=no
+	hardcode_direct_absolute=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -9496,36 +9840,42 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	link_all_deplibs=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      export_dynamic_flag_spec='${wl}-bexpall'
+      export_dynamic_flag_spec='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	allow_undefined_flag='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
+        if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -9560,7 +9910,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -9568,17 +9918,17 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
+	 if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -9613,7 +9963,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -9621,21 +9971,33 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  no_undefined_flag=' $wl-bernotok'
+	  allow_undefined_flag=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    whole_archive_flag_spec='$convenience'
 	  fi
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) >  [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -9644,7 +10006,7 @@ fi
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -9674,16 +10036,17 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
 	enable_shared_with_static_runtimes=yes
@@ -9692,18 +10055,18 @@ fi
 	# Don't use ranlib
 	old_postinstall_cmds='chmod 644 $oldlib'
 	postlink_cmds='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -9712,7 +10075,7 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -9731,24 +10094,24 @@ fi
   hardcode_direct=no
   hardcode_automatic=yes
   hardcode_shlibpath_var=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec=''
   fi
   link_all_deplibs=yes
-  allow_undefined_flag="$_lt_dar_allow_undefined"
+  allow_undefined_flag=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
   else
   ld_shlibs=no
@@ -9790,33 +10153,33 @@ fi
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_direct=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
+      export_dynamic_flag_spec='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 	hardcode_direct=yes
 	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='${wl}-E'
+	export_dynamic_flag_spec='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	hardcode_minus_L=yes
@@ -9824,25 +10187,25 @@ fi
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 
@@ -9854,7 +10217,7 @@ if ${lt_cv_prog_compiler__b+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler__b=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS -b"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -9873,14 +10236,14 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
 $as_echo "$lt_cv_prog_compiler__b" >&6; }
 
-if test x"$lt_cv_prog_compiler__b" = xyes; then
-    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+if test yes = "$lt_cv_prog_compiler__b"; then
+    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 else
     archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 fi
@@ -9888,8 +10251,8 @@ fi
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 
 	case $host_cpu in
@@ -9900,7 +10263,7 @@ fi
 	*)
 	  hardcode_direct=yes
 	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='${wl}-E'
+	  export_dynamic_flag_spec='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -9911,8 +10274,8 @@ fi
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
@@ -9922,8 +10285,8 @@ $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >
 if ${lt_cv_irix_exported_symbol+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+  save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo (void) { return 0; }
@@ -9935,24 +10298,35 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
+           LDFLAGS=$save_LDFLAGS
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
 $as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
+	link_all_deplibs=no
       else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       inherit_rpath=yes
       link_all_deplibs=yes
       ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	ld_shlibs=yes
+	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
     netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -9967,7 +10341,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     newsos6)
       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_shlibpath_var=no
       ;;
@@ -9975,27 +10349,19 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	hardcode_direct=yes
 	hardcode_shlibpath_var=no
 	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec='${wl}-E'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	  export_dynamic_flag_spec='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
 	fi
       else
 	ld_shlibs=no
@@ -10006,33 +10372,53 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       hardcode_libdir_flag_spec='-L$libdir'
       hardcode_minus_L=yes
       allow_undefined_flag=unsupported
-      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -10043,24 +10429,24 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
     solaris*)
       no_undefined_flag=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -10070,11 +10456,11 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       solaris2.[0-5] | solaris2.[0-5].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
 	fi
@@ -10084,10 +10470,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -10136,43 +10522,43 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='${wl}-z,text'
+      no_undefined_flag='$wl-z,text'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
+      no_undefined_flag='$wl-z,text'
+      allow_undefined_flag='$wl-z,nodefs'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_flag_spec='$wl-R,$libdir'
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
+      export_dynamic_flag_spec='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -10187,10 +10573,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	export_dynamic_flag_spec='$wl-Blargedynsym'
 	;;
       esac
     fi
@@ -10198,7 +10584,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
 $as_echo "$ld_shlibs" >&6; }
-test "$ld_shlibs" = no && can_build_shared=no
+test no = "$ld_shlibs" && can_build_shared=no
 
 with_gnu_ld=$with_gnu_ld
 
@@ -10224,7 +10610,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -10439,14 +10825,14 @@ esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -10462,28 +10848,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -10497,7 +10890,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -10506,7 +10899,7 @@ fi
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -10523,14 +10916,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -10538,41 +10933,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -10582,18 +11027,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -10601,8 +11046,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -10614,7 +11059,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -10623,8 +11068,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -10640,17 +11085,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -10659,8 +11104,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -10687,7 +11132,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -10700,8 +11145,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -10714,7 +11159,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -10727,8 +11172,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -10741,8 +11186,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -10760,12 +11205,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -10795,10 +11241,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -10816,14 +11262,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -10831,8 +11278,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -10841,8 +11288,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -10855,8 +11302,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -10867,7 +11314,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -10875,8 +11322,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -10895,8 +11342,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -10905,13 +11352,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -10955,7 +11422,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -10987,12 +11459,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -11002,7 +11474,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -11011,58 +11483,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -11073,8 +11555,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -11084,11 +11566,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -11096,8 +11578,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -11118,24 +11600,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -11153,7 +11635,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -11161,8 +11643,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -11172,20 +11654,35 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
+
+
+
 
 
 
@@ -11282,15 +11779,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" ||
    test -n "$runpath_var" ||
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test yes = "$hardcode_automatic"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct" != no &&
+  if test no != "$hardcode_direct" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
+     test no != "$hardcode_minus_L"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action=relink
   else
@@ -11305,12 +11802,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
 $as_echo "$hardcode_action" >&6; }
 
-if test "$hardcode_action" = relink ||
-   test "$inherit_rpath" = yes; then
+if test relink = "$hardcode_action" ||
+   test yes = "$inherit_rpath"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -11320,7 +11817,7 @@ fi
 
 
 
-  if test "x$enable_dlopen" != xyes; then
+  if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -11330,23 +11827,23 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
 if ${ac_cv_lib_dl_dlopen+:} false; then :
@@ -11384,10 +11881,10 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
 
-    lt_cv_dlopen="dyld"
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
 
@@ -11395,10 +11892,18 @@ fi
 
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
 if test "x$ac_cv_func_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load"
+  lt_cv_dlopen=shl_load
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
 $as_echo_n "checking for shl_load in -ldld... " >&6; }
@@ -11437,11 +11942,11 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
 else
   ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
 if test "x$ac_cv_func_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen"
+  lt_cv_dlopen=dlopen
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
@@ -11480,7 +11985,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
@@ -11519,7 +12024,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
 $as_echo_n "checking for dld_link in -ldld... " >&6; }
@@ -11558,7 +12063,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
 
 
@@ -11579,21 +12084,21 @@ fi
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
@@ -11601,7 +12106,7 @@ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -11648,9 +12153,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -11680,7 +12185,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -11700,14 +12205,14 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
 $as_echo "$lt_cv_dlopen_self" >&6; }
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self_static+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self_static=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -11754,9 +12259,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -11786,7 +12291,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -11807,9 +12312,9 @@ fi
 $as_echo "$lt_cv_dlopen_self_static" >&6; }
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -11853,7 +12358,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -11881,7 +12386,7 @@ fi
 
 
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
 $as_echo_n "checking if libtool supports shared libraries... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
@@ -11889,13 +12394,13 @@ $as_echo "$can_build_shared" >&6; }
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
 $as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -11903,8 +12408,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     ;;
 
   aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -11914,7 +12423,7 @@ $as_echo "$enable_shared" >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
 $as_echo_n "checking whether to build static libraries... " >&6; }
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
 $as_echo "$enable_static" >&6; }
 
@@ -11928,11 +12437,11 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-CC="$lt_save_CC"
+CC=$lt_save_CC
 
-      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+      if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -12111,7 +12620,7 @@ objext_CXX=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -12172,46 +12681,39 @@ $RM -r conftest*
   CFLAGS=$CXXFLAGS
   compiler=$CC
   compiler_CXX=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+  func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
     else
       lt_prog_compiler_no_builtin_flag_CXX=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
 
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -12225,7 +12727,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -12236,7 +12738,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -12247,32 +12749,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -12308,22 +12810,22 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+        export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           whole_archive_flag_spec_CXX=
         fi
@@ -12360,18 +12862,30 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         ld_shlibs_CXX=no
         ;;
       aix[4-9]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -12381,6 +12895,13 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -12399,13 +12920,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         hardcode_direct_absolute_CXX=yes
         hardcode_libdir_separator_CXX=':'
         link_all_deplibs_CXX=yes
-        file_list_spec_CXX='${wl}-f,'
+        file_list_spec_CXX='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          hardcode_direct_CXX=no
+          hardcode_direct_absolute_CXX=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[012]|aix4.[012].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -12423,36 +12952,44 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        export_dynamic_flag_spec_CXX='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         always_export_symbols_CXX=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          allow_undefined_flag_CXX='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          no_undefined_flag_CXX='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
-          if test "${lt_cv_aix_libpath+set}" = set; then
+          if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -12487,7 +13024,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -12495,18 +13032,18 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+          hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib'
 	    allow_undefined_flag_CXX="-z nodefs"
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
-	    if test "${lt_cv_aix_libpath+set}" = set; then
+	    if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -12541,7 +13078,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -12549,22 +13086,34 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    no_undefined_flag_CXX=' ${wl}-bernotok'
-	    allow_undefined_flag_CXX=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    no_undefined_flag_CXX=' $wl-bernotok'
+	    allow_undefined_flag_CXX=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      whole_archive_flag_spec_CXX='$convenience'
 	    fi
 	    archive_cmds_need_lc_CXX=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_sy [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -12574,7 +13123,7 @@ fi
 	  allow_undefined_flag_CXX=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  ld_shlibs_CXX=no
 	fi
@@ -12602,57 +13151,58 @@ fi
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
 	  enable_shared_with_static_runtimes_CXX=yes
 	  # Don't use ranlib
 	  old_postinstall_cmds_CXX='chmod 644 $oldlib'
 	  postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  hardcode_libdir_flag_spec_CXX='-L$libdir'
-	  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+	  export_dynamic_flag_spec_CXX='$wl--export-all-symbols'
 	  allow_undefined_flag_CXX=unsupported
 	  always_export_symbols_CXX=no
 	  enable_shared_with_static_runtimes_CXX=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    ld_shlibs_CXX=no
 	  fi
@@ -12666,27 +13216,27 @@ fi
   hardcode_direct_CXX=no
   hardcode_automatic_CXX=yes
   hardcode_shlibpath_var_CXX=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec_CXX=''
   fi
   link_all_deplibs_CXX=yes
-  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  allow_undefined_flag_CXX=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
+       if test yes != "$lt_cv_apple_cc_single_mod"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 
   else
@@ -12695,6 +13245,34 @@ fi
 
 	;;
 
+      os2*)
+	hardcode_libdir_flag_spec_CXX='-L$libdir'
+	hardcode_minus_L_CXX=yes
+	allow_undefined_flag_CXX=unsupported
+	shrext_cmds=.dll
+	archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	enable_shared_with_static_runtimes_CXX=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -12730,14 +13308,14 @@ fi
         ;;
 
       haiku*)
-        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         link_all_deplibs_CXX=yes
         ;;
 
       hpux9*)
-        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
         hardcode_libdir_separator_CXX=:
-        export_dynamic_flag_spec_CXX='${wl}-E'
+        export_dynamic_flag_spec_CXX='$wl-E'
         hardcode_direct_CXX=yes
         hardcode_minus_L_CXX=yes # Not in the search PATH,
 				             # but as the default
@@ -12749,7 +13327,7 @@ fi
             ld_shlibs_CXX=no
             ;;
           aCC*)
-            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -12758,11 +13336,11 @@ fi
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               ld_shlibs_CXX=no
@@ -12772,15 +13350,15 @@ fi
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
 	  hardcode_libdir_separator_CXX=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      export_dynamic_flag_spec_CXX='${wl}-E'
+	      export_dynamic_flag_spec_CXX='$wl-E'
               ;;
           esac
         fi
@@ -12806,13 +13384,13 @@ fi
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -12823,20 +13401,20 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -12851,22 +13429,22 @@ fi
       interix[3-9]*)
 	hardcode_direct_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}-E'
+	hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -12875,17 +13453,17 @@ fi
 	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    link_all_deplibs_CXX=yes
 	    ;;
         esac
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
         hardcode_libdir_separator_CXX=:
         inherit_rpath_CXX=yes
         ;;
@@ -12898,8 +13476,8 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -12908,10 +13486,10 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -12925,59 +13503,59 @@ fi
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    archive_cmds_need_lc_CXX=no
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
 	      prelink_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      old_archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      archive_expsym_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -12991,18 +13569,18 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -13010,10 +13588,10 @@ fi
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      no_undefined_flag_CXX=' -zdefs'
-	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      hardcode_libdir_flag_spec_CXX='-R$libdir'
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      compiler_needs_object_CXX=yes
 
 	      # Not sure whether something based on
@@ -13071,22 +13649,17 @@ fi
         ld_shlibs_CXX=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	ld_shlibs_CXX=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  hardcode_direct_CXX=yes
 	  hardcode_shlibpath_var_CXX=no
 	  hardcode_direct_absolute_CXX=yes
 	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    export_dynamic_flag_spec_CXX='${wl}-E'
-	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='$wl-E'
+	    whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -13102,9 +13675,9 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
 	    hardcode_libdir_separator_CXX=:
 
 	    # Archives containing C++ object files must be created using
@@ -13122,17 +13695,17 @@ fi
           cxx*)
 	    case $host in
 	      osf3*)
-	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	        allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        allow_undefined_flag_CXX=' -expect_unresolved \*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
 		;;
 	    esac
@@ -13147,21 +13720,21 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 	      hardcode_libdir_separator_CXX=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -13207,9 +13780,9 @@ fi
 	    # Sun C++ 4.2, 5.x and Centerline C++
             archive_cmds_need_lc_CXX=yes
 	    no_undefined_flag_CXX=' -zdefs'
-	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    hardcode_libdir_flag_spec_CXX='-R$libdir'
 	    hardcode_shlibpath_var_CXX=no
@@ -13217,7 +13790,7 @@ fi
 	      solaris2.[0-5] | solaris2.[0-5].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -13234,30 +13807,30 @@ fi
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      no_undefined_flag_CXX=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -13265,11 +13838,11 @@ fi
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[0-5] | solaris2.[0-5].*) ;;
 		*)
-		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -13278,52 +13851,52 @@ fi
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_CXX='${wl}-z,text'
+      no_undefined_flag_CXX='$wl-z,text'
       archive_cmds_need_lc_CXX=no
       hardcode_shlibpath_var_CXX=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	no_undefined_flag_CXX='${wl}-z,text'
-	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	no_undefined_flag_CXX='$wl-z,text'
+	allow_undefined_flag_CXX='$wl-z,nodefs'
 	archive_cmds_need_lc_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_flag_spec_CXX='$wl-R,$libdir'
 	hardcode_libdir_separator_CXX=':'
 	link_all_deplibs_CXX=yes
-	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	export_dynamic_flag_spec_CXX='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
-	      '"$old_archive_cmds_CXX"
+              '"$old_archive_cmds_CXX"
 	    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
-	      '"$reload_cmds_CXX"
+              '"$reload_cmds_CXX"
 	    ;;
 	  *)
-	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -13355,10 +13928,10 @@ fi
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-    test "$ld_shlibs_CXX" = no && can_build_shared=no
+    test no = "$ld_shlibs_CXX" && can_build_shared=no
 
-    GCC_CXX="$GXX"
-    LD_CXX="$LD"
+    GCC_CXX=$GXX
+    LD_CXX=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -13402,13 +13975,13 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -13424,16 +13997,16 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$compiler_lib_search_path_CXX"; then
-	     compiler_lib_search_path_CXX="${prev}${p}"
+	     compiler_lib_search_path_CXX=$prev$p
 	   else
-	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -13441,9 +14014,9 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 esac
        else
 	 if test -z "$postdeps_CXX"; then
-	   postdeps_CXX="${prev}${p}"
+	   postdeps_CXX=$prev$p
 	 else
-	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	   postdeps_CXX="${postdeps_CXX} $prev$p"
 	 fi
        fi
        prev=
@@ -13458,15 +14031,15 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$predep_objects_CXX"; then
-	   predep_objects_CXX="$p"
+	   predep_objects_CXX=$p
 	 else
 	   predep_objects_CXX="$predep_objects_CXX $p"
 	 fi
        else
 	 if test -z "$postdep_objects_CXX"; then
-	   postdep_objects_CXX="$p"
+	   postdep_objects_CXX=$p
 	 else
 	   postdep_objects_CXX="$postdep_objects_CXX $p"
 	 fi
@@ -13496,51 +14069,6 @@ interix[3-9]*)
   postdep_objects_CXX=
   postdeps_CXX=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 
 
@@ -13549,7 +14077,7 @@ case " $postdeps_CXX " in
 esac
  compiler_lib_search_dirs_CXX=
 if test -n "${compiler_lib_search_path_CXX}"; then
- compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 
 
@@ -13588,17 +14116,18 @@ lt_prog_compiler_static_CXX=
 
 
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     lt_prog_compiler_wl_CXX='-Wl,'
     lt_prog_compiler_static_CXX='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static_CXX='-Bstatic'
       fi
+      lt_prog_compiler_pic_CXX='-fPIC'
       ;;
 
     amigaos*)
@@ -13609,8 +14138,8 @@ lt_prog_compiler_static_CXX=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -13625,6 +14154,11 @@ lt_prog_compiler_static_CXX=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static_CXX='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -13674,7 +14208,7 @@ lt_prog_compiler_static_CXX=
     case $host_os in
       aix[4-9]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  lt_prog_compiler_static_CXX='-Bstatic'
 	else
@@ -13714,14 +14248,14 @@ lt_prog_compiler_static_CXX=
 	case $cc_basename in
 	  CC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -13758,7 +14292,7 @@ lt_prog_compiler_static_CXX=
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
@@ -13903,7 +14437,7 @@ lt_prog_compiler_static_CXX=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
     ;;
@@ -13935,7 +14469,7 @@ else
   lt_cv_prog_compiler_pic_works_CXX=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -13965,7 +14499,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then
     case $lt_prog_compiler_pic_CXX in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
@@ -13991,7 +14525,7 @@ if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -14010,13 +14544,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then
     :
 else
     lt_prog_compiler_static_CXX=
@@ -14130,8 +14664,8 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -14143,9 +14677,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -14162,17 +14696,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   case $host_os in
   aix[4-9]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    export_symbols_cmds_CXX="$ltdll_cmds"
+    export_symbols_cmds_CXX=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -14195,7 +14733,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-test "$ld_shlibs_CXX" = no && can_build_shared=no
+test no = "$ld_shlibs_CXX" && can_build_shared=no
 
 with_gnu_ld_CXX=$with_gnu_ld
 
@@ -14212,7 +14750,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc_CXX=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds_CXX in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -14340,7 +14878,7 @@ $as_echo_n "checking dynamic linker characteristics... " >&6; }
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -14357,14 +14895,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -14372,41 +14912,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -14416,18 +15006,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -14435,8 +15025,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -14448,7 +15038,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -14457,8 +15047,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -14474,16 +15064,16 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -14492,8 +15082,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -14520,7 +15110,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -14533,8 +15123,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -14547,7 +15137,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -14560,8 +15150,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -14573,8 +15163,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -14592,12 +15182,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -14627,10 +15218,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -14648,14 +15239,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -14663,8 +15255,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -14673,8 +15265,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -14687,8 +15279,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -14699,7 +15291,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -14707,8 +15299,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -14727,8 +15319,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -14737,13 +15329,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec_CXX='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -14787,7 +15399,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -14819,12 +15436,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -14834,7 +15451,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -14843,58 +15460,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -14905,8 +15532,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -14916,11 +15543,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -14928,8 +15555,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -14950,24 +15577,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -14985,7 +15612,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -14993,8 +15620,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -15004,20 +15631,32 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
 
 
 
@@ -15060,15 +15699,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" ||
    test -n "$runpath_var_CXX" ||
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+   test yes = "$hardcode_automatic_CXX"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct_CXX" != no &&
+  if test no != "$hardcode_direct_CXX" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
-     test "$hardcode_minus_L_CXX" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" &&
+     test no != "$hardcode_minus_L_CXX"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action_CXX=relink
   else
@@ -15083,12 +15722,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
 $as_echo "$hardcode_action_CXX" >&6; }
 
-if test "$hardcode_action_CXX" = relink ||
-   test "$inherit_rpath_CXX" = yes; then
+if test relink = "$hardcode_action_CXX" ||
+   test yes = "$inherit_rpath_CXX"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -15111,7 +15750,7 @@ fi
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
@@ -16654,6 +17293,7 @@ enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`'
 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
 PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
@@ -16703,10 +17343,13 @@ compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
 GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`'
 nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
 lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`'
 objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
 MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
@@ -16771,7 +17414,8 @@ finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
 finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
 hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
 sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
-sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`'
+configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`'
 hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
 enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
 enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
@@ -16876,9 +17520,12 @@ CFLAGS \
 compiler \
 lt_cv_sys_global_symbol_pipe \
 lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_import \
 lt_cv_sys_global_symbol_to_c_name_address \
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+lt_cv_nm_interface \
 nm_file_list_spec \
+lt_cv_truncate_bin \
 lt_prog_compiler_no_builtin_flag \
 lt_prog_compiler_pic \
 lt_prog_compiler_wl \
@@ -16944,7 +17591,7 @@ postdeps_CXX \
 compiler_lib_search_path_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -16971,7 +17618,8 @@ postinstall_cmds \
 postuninstall_cmds \
 finish_cmds \
 sys_lib_search_path_spec \
-sys_lib_dlsearch_path_spec \
+configure_time_dlsearch_path \
+configure_time_lt_sys_library_path \
 reload_cmds_CXX \
 old_archive_cmds_CXX \
 old_archive_from_new_cmds_CXX \
@@ -16985,7 +17633,7 @@ prelink_cmds_CXX \
 postlink_cmds_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -16994,19 +17642,16 @@ postlink_cmds_CXX; do
 done
 
 ac_aux_dir='$ac_aux_dir'
-xsi_shell='$xsi_shell'
-lt_shell_append='$lt_shell_append'
 
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
 
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'
 
@@ -17719,55 +18364,53 @@ $as_echo X"$file" |
  ;;
     "libtool":C)
 
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # The names of the tagged configurations supported by this script.
-available_tags="CXX "
+available_tags='CXX '
+
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
 
 # ### BEGIN LIBTOOL CONFIG
 
@@ -17787,6 +18430,9 @@ pic_mode=$pic_mode
 # Whether or not to optimize for fast installation.
 fast_install=$enable_fast_install
 
+# Shared archive member basename,for filename based shared library versioning on AIX.
+shared_archive_member_spec=$shared_archive_member_spec
+
 # Shell to use when invoking shell scripts.
 SHELL=$lt_SHELL
 
@@ -17904,18 +18550,27 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 # Transform the output of nm in a proper C declaration.
 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
+# Transform the output of nm into a list of symbols to manually relocate.
+global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import
+
 # Transform the output of nm in a C name address pair.
 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
 # Transform the output of nm in a C name address pair when lib prefix is needed.
 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 
+# The name lister interface.
+nm_interface=$lt_lt_cv_nm_interface
+
 # Specify filename containing input files for \$NM.
 nm_file_list_spec=$lt_nm_file_list_spec
 
-# The root where to search for dependent libraries,and in which our libraries should be installed.
+# The root where to search for dependent libraries,and where our libraries should be installed.
 lt_sysroot=$lt_sysroot
 
+# Command to truncate a binary pipe.
+lt_truncate_bin=$lt_lt_cv_truncate_bin
+
 # The name of the directory that contains temporary libtool files.
 objdir=$objdir
 
@@ -18006,8 +18661,11 @@ hardcode_into_libs=$hardcode_into_libs
 # Compile-time system search path for libraries.
 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
-# Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+# Detected run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path
+
+# Explicit LT_SYS_LIBRARY_PATH set during ./configure time.
+configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path
 
 # Whether dlopen is supported.
 dlopen_support=$enable_dlopen
@@ -18100,13 +18758,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute
 
@@ -18172,13 +18830,72 @@ compiler_lib_search_path=$lt_compiler_lib_search_path
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -18187,7 +18904,7 @@ _LT_EOF
   esac
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 
   # We use sed instead of cat because bash on DJGPP gets confused if
@@ -18197,165 +18914,6 @@ ltmain="$ac_aux_dir/ltmain.sh"
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  if test x"$xsi_shell" = xyes; then
-  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
-func_dirname ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_basename ()$/,/^} # func_basename /c\
-func_basename ()\
-{\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
-func_dirname_and_basename ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
-func_stripname ()\
-{\
-\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
-\    # positional parameters, so assign one to ordinary parameter first.\
-\    func_stripname_result=${3}\
-\    func_stripname_result=${func_stripname_result#"${1}"}\
-\    func_stripname_result=${func_stripname_result%"${2}"}\
-} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
-func_split_long_opt ()\
-{\
-\    func_split_long_opt_name=${1%%=*}\
-\    func_split_long_opt_arg=${1#*=}\
-} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
-func_split_short_opt ()\
-{\
-\    func_split_short_opt_arg=${1#??}\
-\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
-} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
-func_lo2o ()\
-{\
-\    case ${1} in\
-\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
-\      *)    func_lo2o_result=${1} ;;\
-\    esac\
-} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_xform ()$/,/^} # func_xform /c\
-func_xform ()\
-{\
-    func_xform_result=${1%.*}.lo\
-} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_arith ()$/,/^} # func_arith /c\
-func_arith ()\
-{\
-    func_arith_result=$(( $* ))\
-} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_len ()$/,/^} # func_len /c\
-func_len ()\
-{\
-    func_len_result=${#1}\
-} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  sed -e '/^func_append ()$/,/^} # func_append /c\
-func_append ()\
-{\
-    eval "${1}+=\\${2}"\
-} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
-func_append_quoted ()\
-{\
-\    func_quote_for_eval "${2}"\
-\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
-} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
-$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
-fi
-
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -18442,13 +19000,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute_CXX
 
diff --git a/src/gmock/gtest/Makefile.in b/src/gmock/gtest/Makefile.in
index 1dc844f..87f521f 100644
--- a/src/gmock/gtest/Makefile.in
+++ b/src/gmock/gtest/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,17 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -91,21 +101,6 @@ check_PROGRAMS = samples/sample1_unittest$(EXEEXT) \
 @HAVE_PYTHON_TRUE at am__append_1 = test/fused_gtest_test
 @HAVE_PYTHON_TRUE at am__append_2 = test/fused_gtest_test
 subdir = .
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(top_srcdir)/configure $(am__configure_deps) \
-	$(top_srcdir)/build-aux/config.h.in \
-	$(top_srcdir)/scripts/gtest-config.in \
-	$(top_srcdir)/build-aux/depcomp $(pkginclude_HEADERS) \
-	$(pkginclude_internal_HEADERS) \
-	$(top_srcdir)/build-aux/test-driver README build-aux/compile \
-	build-aux/config.guess build-aux/config.sub build-aux/depcomp \
-	build-aux/install-sh build-aux/missing build-aux/ltmain.sh \
-	$(top_srcdir)/build-aux/compile \
-	$(top_srcdir)/build-aux/config.guess \
-	$(top_srcdir)/build-aux/config.sub \
-	$(top_srcdir)/build-aux/install-sh \
-	$(top_srcdir)/build-aux/ltmain.sh \
-	$(top_srcdir)/build-aux/missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -113,6 +108,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/acx_pthread.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+	$(am__configure_deps) $(pkginclude_HEADERS) \
+	$(pkginclude_internal_HEADERS) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
@@ -461,6 +459,19 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log)
 TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
 	$(TEST_LOG_FLAGS)
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+	$(top_srcdir)/build-aux/compile \
+	$(top_srcdir)/build-aux/config.guess \
+	$(top_srcdir)/build-aux/config.h.in \
+	$(top_srcdir)/build-aux/config.sub \
+	$(top_srcdir)/build-aux/depcomp \
+	$(top_srcdir)/build-aux/install-sh \
+	$(top_srcdir)/build-aux/ltmain.sh \
+	$(top_srcdir)/build-aux/missing \
+	$(top_srcdir)/build-aux/test-driver \
+	$(top_srcdir)/scripts/gtest-config.in README build-aux/compile \
+	build-aux/config.guess build-aux/config.sub build-aux/depcomp \
+	build-aux/install-sh build-aux/ltmain.sh build-aux/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -521,6 +532,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -594,6 +606,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -814,7 +827,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -1217,7 +1229,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
 	if test -n "$$am__remaking_logs"; then \
 	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
 	       "recursion detected" >&2; \
-	else \
+	elif test -n "$$redo_logs"; then \
 	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
 	fi; \
 	if $(am__make_dryrun); then :; else \
@@ -1426,15 +1438,15 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
@@ -1469,17 +1481,17 @@ distcheck: dist
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_inst
+	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build \
-	  && ../configure \
+	  && $(am__cd) $(distdir)/_build/sub \
+	  && ../../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=.. --prefix="$$dc_install_base" \
+	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -1686,6 +1698,8 @@ uninstall-am: uninstall-m4dataDATA uninstall-pkgincludeHEADERS \
 	uninstall-am uninstall-m4dataDATA uninstall-pkgincludeHEADERS \
 	uninstall-pkginclude_internalHEADERS
 
+.PRECIOUS: Makefile
+
 
 # Build rules for putting fused Google Test files into the distribution
 # package. The user can also create those files by manually running
diff --git a/src/gmock/gtest/aclocal.m4 b/src/gmock/gtest/aclocal.m4
index 8f34cf4..a83ad2f 100644
--- a/src/gmock/gtest/aclocal.m4
+++ b/src/gmock/gtest/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.15 -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.14'
+[am__api_version='1.15'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.14.1], [],
+m4_if([$1], [1.15], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.14.1])dnl
+[AM_AUTOMAKE_VERSION([1.15])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 # configured tree to be moved without reconfiguration.
 
 AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 ])
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -142,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -333,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -409,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -499,8 +498,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@@ -573,7 +572,11 @@ to "yes", and re-run configure.
 END
     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
   fi
-fi])
+fi
+dnl The trailing newline in this macro's definition is deliberate, for
+dnl backward compatibility and to allow trailing 'dnl'-style comments
+dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
+])
 
 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
@@ -602,7 +605,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -613,7 +616,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -623,7 +626,7 @@ if test x"${install_sh}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -644,7 +647,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -694,7 +697,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -733,7 +736,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -762,7 +765,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -809,7 +812,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1044,7 +1047,7 @@ for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
 sys.exit(sys.hexversion < minverhex)"
   AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1063,7 +1066,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1144,7 +1147,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1204,7 +1207,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+# Copyright (C) 2001-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1232,7 +1235,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1251,7 +1254,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/src/gmock/gtest/build-aux/compile b/src/gmock/gtest/build-aux/compile
index 531136b..a85b723 100755
--- a/src/gmock/gtest/build-aux/compile
+++ b/src/gmock/gtest/build-aux/compile
@@ -3,7 +3,7 @@
 
 scriptversion=2012-10-14.11; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/src/gmock/gtest/build-aux/config.guess b/src/gmock/gtest/build-aux/config.guess
index b79252d..1659250 100755
--- a/src/gmock/gtest/build-aux/config.guess
+++ b/src/gmock/gtest/build-aux/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2013 Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2013-06-10'
+timestamp='2015-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -24,12 +24,12 @@ timestamp='2013-06-10'
 # program.  This Exception is an additional permission under section 7
 # of the GNU General Public License, version 3 ("GPLv3").
 #
-# Originally written by Per Bothner.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 #
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 
 
 me=`echo "$0" | sed -e 's,.*/,,'`
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -149,7 +149,7 @@ Linux|GNU|GNU/*)
 	LIBC=gnu
 	#endif
 	EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
 	;;
 esac
 
@@ -168,20 +168,27 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
 	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+	    /sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || \
+	    echo unknown)`
 	case "${UNAME_MACHINE_ARCH}" in
 	    armeb) machine=armeb-unknown ;;
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
 	    sh3eb) machine=sh-unknown ;;
 	    sh5el) machine=sh5le-unknown ;;
+	    earmv*)
+		arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+		endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
+		machine=${arch}${endian}-unknown
+		;;
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently, or will in the future.
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
@@ -197,6 +204,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		os=netbsd
 		;;
 	esac
+	# Determine ABI tags.
+	case "${UNAME_MACHINE_ARCH}" in
+	    earm*)
+		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+		abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+		;;
+	esac
 	# The OS release
 	# Debian GNU/NetBSD machines have a different userland, and
 	# thus, need a distinct triplet. However, they do not need
@@ -207,13 +221,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		release='-gnu'
 		;;
 	    *)
-		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
 		;;
 	esac
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "${machine}-${os}${release}"
+	echo "${machine}-${os}${release}${abi}"
 	exit ;;
     *:Bitrig:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
@@ -235,6 +249,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:MirBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
+    *:Sortix:*:*)
+	echo ${UNAME_MACHINE}-unknown-sortix
+	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	*4.0)
@@ -579,8 +596,9 @@ EOF
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
+	if [ -x /usr/bin/lslpp ] ; then
+		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
@@ -826,7 +844,7 @@ EOF
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
-    i*:MSYS*:*)
+    *:MSYS*:*)
 	echo ${UNAME_MACHINE}-pc-msys
 	exit ;;
     i*:windows32*:*)
@@ -932,6 +950,9 @@ EOF
     crisv32:Linux:*:*)
 	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
+    e2k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     frv:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
@@ -969,10 +990,10 @@ EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
-    or1k:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+    openrisc*:Linux:*:*)
+	echo or1k-unknown-linux-${LIBC}
 	exit ;;
-    or32:Linux:*:*)
+    or32:Linux:*:* | or1k*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     padre:Linux:*:*)
@@ -1020,7 +1041,7 @@ EOF
 	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
     xtensa*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
@@ -1260,16 +1281,26 @@ EOF
 	if test "$UNAME_PROCESSOR" = unknown ; then
 	    UNAME_PROCESSOR=powerpc
 	fi
-	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		grep IS_64BIT_ARCH >/dev/null
-	    then
-		case $UNAME_PROCESSOR in
-		    i386) UNAME_PROCESSOR=x86_64 ;;
-		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
-		esac
+	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+	    if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		    (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		    grep IS_64BIT_ARCH >/dev/null
+		then
+		    case $UNAME_PROCESSOR in
+			i386) UNAME_PROCESSOR=x86_64 ;;
+			powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		    esac
+		fi
 	    fi
+	elif test "$UNAME_PROCESSOR" = i386 ; then
+	    # Avoid executing cc on OS X 10.9, as it ships with a stub
+	    # that puts up a graphical alert prompting to install
+	    # developer tools.  Any system running Mac OS X 10.7 or
+	    # later (Darwin 11 and later) is required to have a 64-bit
+	    # processor. This is not true of the ARM version of Darwin
+	    # that Apple uses in portable devices.
+	    UNAME_PROCESSOR=x86_64
 	fi
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
@@ -1361,154 +1392,6 @@ EOF
 	exit ;;
 esac
 
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-	"4"
-#else
-	""
-#endif
-	); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-	printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-	printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-	{ echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-	echo c1-convex-bsd
-	exit ;;
-    c2*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-	exit ;;
-    c34*)
-	echo c34-convex-bsd
-	exit ;;
-    c38*)
-	echo c38-convex-bsd
-	exit ;;
-    c4*)
-	echo c4-convex-bsd
-	exit ;;
-    esac
-fi
-
 cat >&2 <<EOF
 $0: unable to guess system type
 
diff --git a/src/gmock/gtest/build-aux/config.h.in b/src/gmock/gtest/build-aux/config.h.in
index 843b5b1..6ea2e69 100644
--- a/src/gmock/gtest/build-aux/config.h.in
+++ b/src/gmock/gtest/build-aux/config.h.in
@@ -33,8 +33,7 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Name of package */
diff --git a/src/gmock/gtest/build-aux/config.sub b/src/gmock/gtest/build-aux/config.sub
index 9633db7..1acc966 100755
--- a/src/gmock/gtest/build-aux/config.sub
+++ b/src/gmock/gtest/build-aux/config.sub
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2013 Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2013-08-10'
+timestamp='2015-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ timestamp='2013-08-10'
 # of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+# Please send patches to <config-patches at gnu.org>.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -68,7 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -117,7 +117,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
@@ -255,16 +255,18 @@ case $basic_machine in
 	| arc | arceb \
 	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
 	| avr | avr32 \
+	| ba \
 	| be32 | be64 \
 	| bfin \
 	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
-	| epiphany \
-	| fido | fr30 | frv \
+	| e2k | epiphany \
+	| fido | fr30 | frv | ft32 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| k1om \
 	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
@@ -282,8 +284,10 @@ case $basic_machine in
 	| mips64vr5900 | mips64vr5900el \
 	| mipsisa32 | mipsisa32el \
 	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa32r6 | mipsisa32r6el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64r6 | mipsisa64r6el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipsr5900 | mipsr5900el \
@@ -295,14 +299,14 @@ case $basic_machine in
 	| nds32 | nds32le | nds32be \
 	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
-	| open8 \
-	| or1k | or32 \
+	| open8 | or1k | or1knd | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
+	| riscv32 | riscv64 \
 	| rl78 | rx \
 	| score \
-	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -310,6 +314,7 @@ case $basic_machine in
 	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
 	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+	| visium \
 	| we32k \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
@@ -324,7 +329,10 @@ case $basic_machine in
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+	leon|leon[3-9])
+		basic_machine=sparc-$basic_machine
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -369,18 +377,20 @@ case $basic_machine in
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| ba-* \
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| c8051-* | clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
-	| elxsi-* \
+	| e2k-* | elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| k1om-* \
 	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
@@ -400,8 +410,10 @@ case $basic_machine in
 	| mips64vr5900-* | mips64vr5900el-* \
 	| mipsisa32-* | mipsisa32el-* \
 	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa32r6-* | mipsisa32r6el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64r6-* | mipsisa64r6el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipsr5900-* | mipsr5900el-* \
@@ -413,16 +425,18 @@ case $basic_machine in
 	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
+	| or1k*-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
+	| riscv32-* | riscv64-* \
 	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
 	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tile*-* \
@@ -430,6 +444,7 @@ case $basic_machine in
 	| ubicom32-* \
 	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
 	| vax-* \
+	| visium-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -506,6 +521,9 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-aros
 		;;
+        asmjs)
+		basic_machine=asmjs-unknown
+		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
@@ -767,6 +785,9 @@ case $basic_machine in
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	leon-*|leon[3-9]-*)
+		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
@@ -822,6 +843,10 @@ case $basic_machine in
 		basic_machine=powerpc-unknown
 		os=-morphos
 		;;
+	moxiebox)
+		basic_machine=moxie-unknown
+		os=-moxiebox
+		;;
 	msdos)
 		basic_machine=i386-pc
 		os=-msdos
@@ -1354,7 +1379,7 @@ case $os in
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
 	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* | -aros* \
+	      | -aos* | -aros* | -cloudabi* | -sortix* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
@@ -1367,14 +1392,14 @@ case $os in
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1592,9 +1617,6 @@ case $basic_machine in
 	mips*-*)
 		os=-elf
 		;;
-	or1k-*)
-		os=-elf
-		;;
 	or32-*)
 		os=-coff
 		;;
diff --git a/src/gmock/gtest/build-aux/depcomp b/src/gmock/gtest/build-aux/depcomp
index 4ebd5b3..fc98710 100755
--- a/src/gmock/gtest/build-aux/depcomp
+++ b/src/gmock/gtest/build-aux/depcomp
@@ -3,7 +3,7 @@
 
 scriptversion=2013-05-30.07; # UTC
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/gmock/gtest/build-aux/install-sh b/src/gmock/gtest/build-aux/install-sh
index 377bb86..59990a1 100755
--- a/src/gmock/gtest/build-aux/install-sh
+++ b/src/gmock/gtest/build-aux/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2011-11-20.07; # UTC
+scriptversion=2014-09-12.12; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
 # This script is compatible with the BSD install script, but was written
 # from scratch.
 
+tab='	'
 nl='
 '
-IFS=" ""	$nl"
+IFS=" $tab$nl"
 
-# set DOITPROG to echo to test this script
+# Set DOITPROG to "echo" to test this script.
 
-# Don't use :- since 4.3BSD and earlier shells don't like it.
 doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
+doit_exec=${doit:-exec}
 
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
 rmprog=${RMPROG-rm}
 stripprog=${STRIPPROG-strip}
 
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
 posix_mkdir=
 
 # Desired mode of installed file.
@@ -97,7 +82,7 @@ dir_arg=
 dst_arg=
 
 copy_on_change=false
-no_target_directory=
+is_target_a_directory=possibly
 
 usage="\
 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -137,46 +122,57 @@ while test $# -ne 0; do
     -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-	shift;;
+        shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-	case $mode in
-	  *' '* | *'	'* | *'
-'*	  | *'*'* | *'?'* | *'['*)
-	    echo "$0: invalid mode: $mode" >&2
-	    exit 1;;
-	esac
-	shift;;
+        case $mode in
+          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
+            echo "$0: invalid mode: $mode" >&2
+            exit 1;;
+        esac
+        shift;;
 
     -o) chowncmd="$chownprog $2"
-	shift;;
+        shift;;
 
     -s) stripcmd=$stripprog;;
 
-    -t) dst_arg=$2
-	# Protect names problematic for 'test' and other utilities.
-	case $dst_arg in
-	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
-	esac
-	shift;;
+    -t)
+        is_target_a_directory=always
+        dst_arg=$2
+        # Protect names problematic for 'test' and other utilities.
+        case $dst_arg in
+          -* | [=\(\)!]) dst_arg=./$dst_arg;;
+        esac
+        shift;;
 
-    -T) no_target_directory=true;;
+    -T) is_target_a_directory=never;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    --)	shift
-	break;;
+    --) shift
+        break;;
 
-    -*)	echo "$0: invalid option: $1" >&2
-	exit 1;;
+    -*) echo "$0: invalid option: $1" >&2
+        exit 1;;
 
     *)  break;;
   esac
   shift
 done
 
+# We allow the use of options -d and -T together, by making -d
+# take the precedence; this is for compatibility with GNU install.
+
+if test -n "$dir_arg"; then
+  if test -n "$dst_arg"; then
+    echo "$0: target directory not allowed when installing a directory." >&2
+    exit 1
+  fi
+fi
+
 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
@@ -208,6 +204,15 @@ if test $# -eq 0; then
 fi
 
 if test -z "$dir_arg"; then
+  if test $# -gt 1 || test "$is_target_a_directory" = always; then
+    if test ! -d "$dst_arg"; then
+      echo "$0: $dst_arg: Is not a directory." >&2
+      exit 1
+    fi
+  fi
+fi
+
+if test -z "$dir_arg"; then
   do_exit='(exit $ret); exit $ret'
   trap "ret=129; $do_exit" 1
   trap "ret=130; $do_exit" 2
@@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
 
     *[0-7])
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw='% 200'
+        u_plus_rw='% 200'
       fi
       cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
     *)
       if test -z "$stripcmd"; then
-	u_plus_rw=
+        u_plus_rw=
       else
-	u_plus_rw=,u+rw
+        u_plus_rw=,u+rw
       fi
       cp_umask=$mode$u_plus_rw;;
   esac
@@ -269,41 +274,15 @@ do
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-	echo "$0: $dst_arg: Is a directory" >&2
-	exit 1
+      if test "$is_target_a_directory" = never; then
+        echo "$0: $dst_arg: Is a directory" >&2
+        exit 1
       fi
       dstdir=$dst
       dst=$dstdir/`basename "$src"`
       dstdir_status=0
     else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-	(dirname "$dst") 2>/dev/null ||
-	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	     X"$dst" : 'X\(//\)[^/]' \| \
-	     X"$dst" : 'X\(//\)$' \| \
-	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-	echo X"$dst" |
-	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)[^/].*/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\).*/{
-		   s//\1/
-		   q
-		 }
-		 s/.*/./; q'
-      `
-
+      dstdir=`dirname "$dst"`
       test -d "$dstdir"
       dstdir_status=$?
     fi
@@ -314,74 +293,81 @@ do
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-	# Create intermediate dirs using mode 755 as modified by the umask.
-	# This is like FreeBSD 'install' as of 1997-10-28.
-	umask=`umask`
-	case $stripcmd.$umask in
-	  # Optimize common cases.
-	  *[2367][2367]) mkdir_umask=$umask;;
-	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-	  *[0-7])
-	    mkdir_umask=`expr $umask + 22 \
-	      - $umask % 100 % 40 + $umask % 20 \
-	      - $umask % 10 % 4 + $umask % 2
-	    `;;
-	  *) mkdir_umask=$umask,go-w;;
-	esac
-
-	# With -d, create the new directory with the user-specified mode.
-	# Otherwise, rely on $mkdir_umask.
-	if test -n "$dir_arg"; then
-	  mkdir_mode=-m$mode
-	else
-	  mkdir_mode=
-	fi
-
-	posix_mkdir=false
-	case $umask in
-	  *[123567][0-7][0-7])
-	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-	    ;;
-	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-	    if (umask $mkdir_umask &&
-		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-	    then
-	      if test -z "$dir_arg" || {
-		   # Check for POSIX incompatibilities with -m.
-		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writable bit of parent directory when it shouldn't.
-		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-		   case $ls_ld_tmpdir in
-		     d????-?r-*) different_mode=700;;
-		     d????-?--*) different_mode=755;;
-		     *) false;;
-		   esac &&
-		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-		   }
-		 }
-	      then posix_mkdir=:
-	      fi
-	      rmdir "$tmpdir/d" "$tmpdir"
-	    else
-	      # Remove any dirs left behind by ancient mkdir implementations.
-	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-	    fi
-	    trap '' 0;;
-	esac;;
+        # Create intermediate dirs using mode 755 as modified by the umask.
+        # This is like FreeBSD 'install' as of 1997-10-28.
+        umask=`umask`
+        case $stripcmd.$umask in
+          # Optimize common cases.
+          *[2367][2367]) mkdir_umask=$umask;;
+          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+          *[0-7])
+            mkdir_umask=`expr $umask + 22 \
+              - $umask % 100 % 40 + $umask % 20 \
+              - $umask % 10 % 4 + $umask % 2
+            `;;
+          *) mkdir_umask=$umask,go-w;;
+        esac
+
+        # With -d, create the new directory with the user-specified mode.
+        # Otherwise, rely on $mkdir_umask.
+        if test -n "$dir_arg"; then
+          mkdir_mode=-m$mode
+        else
+          mkdir_mode=
+        fi
+
+        posix_mkdir=false
+        case $umask in
+          *[123567][0-7][0-7])
+            # POSIX mkdir -p sets u+wx bits regardless of umask, which
+            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+            ;;
+          *)
+            # $RANDOM is not portable (e.g. dash);  use it when possible to
+            # lower collision chance
+            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+            trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+            # As "mkdir -p" follows symlinks and we work in /tmp possibly;  so
+            # create the $tmpdir first (and fail if unsuccessful) to make sure
+            # that nobody tries to guess the $tmpdir name.
+            if (umask $mkdir_umask &&
+                $mkdirprog $mkdir_mode "$tmpdir" &&
+                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
+            then
+              if test -z "$dir_arg" || {
+                   # Check for POSIX incompatibilities with -m.
+                   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                   # other-writable bit of parent directory when it shouldn't.
+                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                   test_tmpdir="$tmpdir/a"
+                   ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
+                   case $ls_ld_tmpdir in
+                     d????-?r-*) different_mode=700;;
+                     d????-?--*) different_mode=755;;
+                     *) false;;
+                   esac &&
+                   $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+                     ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
+                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                   }
+                 }
+              then posix_mkdir=:
+              fi
+              rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
+            else
+              # Remove any dirs left behind by ancient mkdir implementations.
+              rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
+            fi
+            trap '' 0;;
+        esac;;
     esac
 
     if
       $posix_mkdir && (
-	umask $mkdir_umask &&
-	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+        umask $mkdir_umask &&
+        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
       )
     then :
     else
@@ -391,53 +377,51 @@ do
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-	/*) prefix='/';;
-	[-=\(\)!]*) prefix='./';;
-	*)  prefix='';;
+        /*) prefix='/';;
+        [-=\(\)!]*) prefix='./';;
+        *)  prefix='';;
       esac
 
-      eval "$initialize_posix_glob"
-
       oIFS=$IFS
       IFS=/
-      $posix_glob set -f
+      set -f
       set fnord $dstdir
       shift
-      $posix_glob set +f
+      set +f
       IFS=$oIFS
 
       prefixes=
 
       for d
       do
-	test X"$d" = X && continue
-
-	prefix=$prefix$d
-	if test -d "$prefix"; then
-	  prefixes=
-	else
-	  if $posix_mkdir; then
-	    (umask=$mkdir_umask &&
-	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-	    # Don't fail if two instances are running concurrently.
-	    test -d "$prefix" || exit 1
-	  else
-	    case $prefix in
-	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-	      *) qprefix=$prefix;;
-	    esac
-	    prefixes="$prefixes '$qprefix'"
-	  fi
-	fi
-	prefix=$prefix/
+        test X"$d" = X && continue
+
+        prefix=$prefix$d
+        if test -d "$prefix"; then
+          prefixes=
+        else
+          if $posix_mkdir; then
+            (umask=$mkdir_umask &&
+             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+            # Don't fail if two instances are running concurrently.
+            test -d "$prefix" || exit 1
+          else
+            case $prefix in
+              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+              *) qprefix=$prefix;;
+            esac
+            prefixes="$prefixes '$qprefix'"
+          fi
+        fi
+        prefix=$prefix/
       done
 
       if test -n "$prefixes"; then
-	# Don't fail if two instances are running concurrently.
-	(umask $mkdir_umask &&
-	 eval "\$doit_exec \$mkdirprog $prefixes") ||
-	  test -d "$dstdir" || exit 1
-	obsolete_mkdir_used=true
+        # Don't fail if two instances are running concurrently.
+        (umask $mkdir_umask &&
+         eval "\$doit_exec \$mkdirprog $prefixes") ||
+          test -d "$dstdir" || exit 1
+        obsolete_mkdir_used=true
       fi
     fi
   fi
@@ -472,15 +456,12 @@ do
 
     # If -C, don't bother to copy if it wouldn't change the file.
     if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
+       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
+       set -f &&
        set X $old && old=:$2:$4:$5:$6 &&
        set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
+       set +f &&
        test "$old" = "$new" &&
        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     then
@@ -493,24 +474,24 @@ do
       # to itself, or perhaps because mv is so ancient that it does not
       # support -f.
       {
-	# Now remove or move aside any old file at destination location.
-	# We try this two ways since rm can't unlink itself on some
-	# systems and the destination file might be busy for other
-	# reasons.  In this case, the final cleanup might fail but the new
-	# file should still install successfully.
-	{
-	  test ! -f "$dst" ||
-	  $doit $rmcmd -f "$dst" 2>/dev/null ||
-	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-	  } ||
-	  { echo "$0: cannot unlink or rename $dst" >&2
-	    (exit 1); exit 1
-	  }
-	} &&
-
-	# Now rename the file to the real destination.
-	$doit $mvcmd "$dsttmp" "$dst"
+        # Now remove or move aside any old file at destination location.
+        # We try this two ways since rm can't unlink itself on some
+        # systems and the destination file might be busy for other
+        # reasons.  In this case, the final cleanup might fail but the new
+        # file should still install successfully.
+        {
+          test ! -f "$dst" ||
+          $doit $rmcmd -f "$dst" 2>/dev/null ||
+          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+          } ||
+          { echo "$0: cannot unlink or rename $dst" >&2
+            (exit 1); exit 1
+          }
+        } &&
+
+        # Now rename the file to the real destination.
+        $doit $mvcmd "$dsttmp" "$dst"
       }
     fi || exit 1
 
diff --git a/src/gmock/gtest/build-aux/ltmain.sh b/src/gmock/gtest/build-aux/ltmain.sh
index a356aca..147d758 100644
--- a/src/gmock/gtest/build-aux/ltmain.sh
+++ b/src/gmock/gtest/build-aux/ltmain.sh
@@ -1,9 +1,12 @@
+#! /bin/sh
+## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
+##               by inline-source v2014-01-03.01
 
-# libtool (GNU libtool) 2.4.2
+# libtool (GNU libtool) 2.4.6
+# Provide generalized library-building support services.
 # Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
-# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1996-2015 Free Software Foundation, Inc.
 # This is free software; see the source for copying conditions.  There is NO
 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
@@ -23,881 +26,2112 @@
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html,
-# or obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Usage: $progname [OPTION]... [MODE-ARG]...
-#
-# Provide generalized library-building support services.
-#
-#       --config             show all configuration variables
-#       --debug              enable verbose shell tracing
-#   -n, --dry-run            display commands without modifying any files
-#       --features           display basic configuration information and exit
-#       --mode=MODE          use operation mode MODE
-#       --preserve-dup-deps  don't remove duplicate dependency libraries
-#       --quiet, --silent    don't print informational messages
-#       --no-quiet, --no-silent
-#                            print informational messages (default)
-#       --no-warn            don't display warning messages
-#       --tag=TAG            use configuration variables from tag TAG
-#   -v, --verbose            print more informational messages than default
-#       --no-verbose         don't print the extra informational messages
-#       --version            print version information
-#   -h, --help, --help-all   print short, long, or detailed help message
-#
-# MODE must be one of the following:
-#
-#         clean              remove files from the build directory
-#         compile            compile a source file into a libtool object
-#         execute            automatically set library path, then run a program
-#         finish             complete the installation of libtool libraries
-#         install            install libraries or executables
-#         link               create a library or an executable
-#         uninstall          remove libraries from an installed directory
-#
-# MODE-ARGS vary depending on the MODE.  When passed as first option,
-# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
-# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
-#
-# When reporting a bug, please describe a test case to reproduce it and
-# include the following information:
-#
-#         host-triplet:	$host
-#         shell:		$SHELL
-#         compiler:		$LTCC
-#         compiler flags:		$LTCFLAGS
-#         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
-#         automake:	$automake_version
-#         autoconf:	$autoconf_version
-#
-# Report bugs to <bug-libtool at gnu.org>.
-# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
-# General help using GNU software: <http://www.gnu.org/gethelp/>.
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
-TIMESTAMP=""
-package_revision=1.3337
+VERSION="2.4.6 Debian-2.4.6-0.1"
+package_revision=2.4.6
 
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Run './libtool --help' for help with using this script from the
+# command line.
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# After configure completes, it has a better idea of some of the
+# shell tools we need than the defaults used by the functions shared
+# with bootstrap, so set those here where they can still be over-
+# ridden by the user, but otherwise take precedence.
+
+: ${AUTOCONF="autoconf"}
+: ${AUTOMAKE="automake"}
+
+
+## -------------------------- ##
+## Source external libraries. ##
+## -------------------------- ##
+
+# Much of our low-level functionality needs to be sourced from external
+# libraries, which are installed to $pkgauxdir.
+
+# Set a version string for this script.
+scriptversion=2015-01-20.17; # UTC
+
+# General shell script boiler plate, and helper functions.
+# Written by Gary V. Vaughan, 2004
+
+# Copyright (C) 2004-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# As a special exception to the GNU General Public License, if you distribute
+# this file as part of a program or library that is built using GNU Libtool,
+# you may include this file under the same distribution terms that you use
+# for the rest of that program.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# Evaluate this file near the top of your script to gain access to
+# the functions and variables defined here:
+#
+#   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
+#
+# If you need to override any of the default environment variable
+# settings, do that before evaluating this file.
+
+
+## -------------------- ##
+## Shell normalisation. ##
+## -------------------- ##
+
+# Some shells need a little help to be as Bourne compatible as possible.
+# Before doing anything else, make sure all that help has been provided!
+
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
 fi
-BIN_SH=xpg4; export BIN_SH # for Tru64
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# A function that is used when there is no print builtin or printf.
-func_fallback_echo ()
-{
-  eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-}
 
-# NLS nuisances: We save the old values to restore during execute mode.
-lt_user_locale=
-lt_safe_locale=
-for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+# NLS nuisances: We save the old values in case they are required later.
+_G_user_locale=
+_G_safe_locale=
+for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
-  eval "if test \"\${$lt_var+set}\" = set; then
-          save_$lt_var=\$$lt_var
-          $lt_var=C
-	  export $lt_var
-	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
-	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+  eval "if test set = \"\${$_G_var+set}\"; then
+          save_$_G_var=\$$_G_var
+          $_G_var=C
+	  export $_G_var
+	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
+	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
 	fi"
 done
-LC_ALL=C
-LANGUAGE=C
-export LANGUAGE LC_ALL
 
-$lt_unset CDPATH
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Make sure IFS has a sensible default
+sp=' '
+nl='
+'
+IFS="$sp	$nl"
+
+# There are apparently some retarded systems that use ';' as a PATH separator!
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
 
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
 
 
+## ------------------------- ##
+## Locate command utilities. ##
+## ------------------------- ##
+
+
+# func_executable_p FILE
+# ----------------------
+# Check that FILE is an executable regular file.
+func_executable_p ()
+{
+    test -f "$1" && test -x "$1"
+}
+
+
+# func_path_progs PROGS_LIST CHECK_FUNC [PATH]
+# --------------------------------------------
+# Search for either a program that responds to --version with output
+# containing "GNU", or else returned by CHECK_FUNC otherwise, by
+# trying all the directories in PATH with each of the elements of
+# PROGS_LIST.
+#
+# CHECK_FUNC should accept the path to a candidate program, and
+# set $func_check_prog_result if it truncates its output less than
+# $_G_path_prog_max characters.
+func_path_progs ()
+{
+    _G_progs_list=$1
+    _G_check_func=$2
+    _G_PATH=${3-"$PATH"}
+
+    _G_path_prog_max=0
+    _G_path_prog_found=false
+    _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
+    for _G_dir in $_G_PATH; do
+      IFS=$_G_save_IFS
+      test -z "$_G_dir" && _G_dir=.
+      for _G_prog_name in $_G_progs_list; do
+        for _exeext in '' .EXE; do
+          _G_path_prog=$_G_dir/$_G_prog_name$_exeext
+          func_executable_p "$_G_path_prog" || continue
+          case `"$_G_path_prog" --version 2>&1` in
+            *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
+            *)     $_G_check_func $_G_path_prog
+		   func_path_progs_result=$func_check_prog_result
+		   ;;
+          esac
+          $_G_path_prog_found && break 3
+        done
+      done
+    done
+    IFS=$_G_save_IFS
+    test -z "$func_path_progs_result" && {
+      echo "no acceptable sed could be found in \$PATH" >&2
+      exit 1
+    }
+}
+
+
+# We want to be able to use the functions in this file before configure
+# has figured out where the best binaries are kept, which means we have
+# to search for them ourselves - except when the results are already set
+# where we skip the searches.
+
+# Unless the user overrides by setting SED, search the path for either GNU
+# sed, or the sed that truncates its output the least.
+test -z "$SED" && {
+  _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+  for _G_i in 1 2 3 4 5 6 7; do
+    _G_sed_script=$_G_sed_script$nl$_G_sed_script
+  done
+  echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
+  _G_sed_script=
+
+  func_check_prog_sed ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo '' >> conftest.nl
+      "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
+  rm -f conftest.sed
+  SED=$func_path_progs_result
+}
+
+
+# Unless the user overrides by setting GREP, search the path for either GNU
+# grep, or the grep that truncates its output the least.
+test -z "$GREP" && {
+  func_check_prog_grep ()
+  {
+    _G_path_prog=$1
+
+    _G_count=0
+    _G_path_prog_max=0
+    printf 0123456789 >conftest.in
+    while :
+    do
+      cat conftest.in conftest.in >conftest.tmp
+      mv conftest.tmp conftest.in
+      cp conftest.in conftest.nl
+      echo 'GREP' >> conftest.nl
+      "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
+      diff conftest.out conftest.nl >/dev/null 2>&1 || break
+      _G_count=`expr $_G_count + 1`
+      if test "$_G_count" -gt "$_G_path_prog_max"; then
+        # Best one so far, save it but keep looking for a better one
+        func_check_prog_result=$_G_path_prog
+        _G_path_prog_max=$_G_count
+      fi
+      # 10*(2^10) chars as input seems more than enough
+      test 10 -lt "$_G_count" && break
+    done
+    rm -f conftest.in conftest.tmp conftest.nl conftest.out
+  }
+
+  func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
+  GREP=$func_path_progs_result
+}
+
+
+## ------------------------------- ##
+## User overridable command paths. ##
+## ------------------------------- ##
+
+# All uppercase variable names are used for environment variables.  These
+# variables can be overridden by the user before calling a script that
+# uses them if a suitable command of that name is not already available
+# in the command search PATH.
 
 : ${CP="cp -f"}
-test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${ECHO="printf %s\n"}
+: ${EGREP="$GREP -E"}
+: ${FGREP="$GREP -F"}
+: ${LN_S="ln -s"}
 : ${MAKE="make"}
 : ${MKDIR="mkdir"}
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
-: ${Xsed="$SED -e 1s/^X//"}
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
-EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
-
-exit_status=$EXIT_SUCCESS
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
 
-dirname="s,/[^/]*$,,"
-basename="s,^.*/,,"
 
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
-    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-} # func_dirname may be replaced by extended shell implementation
+## -------------------- ##
+## Useful sed snippets. ##
+## -------------------- ##
 
+sed_dirname='s|/[^/]*$||'
+sed_basename='s|^.*/||'
 
-# func_basename file
-func_basename ()
-{
-    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
-} # func_basename may be replaced by extended shell implementation
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
 
+# Same as above, but do not quote variable references.
+sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-#             add APPEND to the result, otherwise set result
-#             to NONDIR_REPLACEMENT.
-#             value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-#             value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-    # Extract subdirectory from the argument.
-    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
-    if test "X$func_dirname_result" = "X${1}"; then
-      func_dirname_result="${3}"
-    else
-      func_dirname_result="$func_dirname_result${2}"
-    fi
-    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
-} # func_dirname_and_basename may be replaced by extended shell implementation
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
 
+# Sed substitution that converts a w32 file name or path
+# that contains forward slashes, into one that contains
+# (escaped) backslashes.  A very naive implementation.
+sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-'\' parameter expansions in output of sed_double_quote_subst that
+# were '\'-ed in input to the same.  If an odd number of '\' preceded a
+# '$' in input to sed_double_quote_subst, that '$' was protected from
+# expansion.  Since each input '\' is now two '\'s, look for any number
+# of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
+_G_bs='\\'
+_G_bs2='\\\\'
+_G_bs4='\\\\\\\\'
+_G_dollar='\$'
+sed_double_backslash="\
+  s/$_G_bs4/&\\
+/g
+  s/^$_G_bs2$_G_dollar/$_G_bs&/
+  s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
+  s/\n//g"
 
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-# func_strip_suffix prefix name
-func_stripname ()
-{
-    case ${2} in
-      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
-    esac
-} # func_stripname may be replaced by extended shell implementation
 
+## ----------------- ##
+## Global variables. ##
+## ----------------- ##
 
-# These SED scripts presuppose an absolute path with a trailing slash.
-pathcar='s,^/\([^/]*\).*$,\1,'
-pathcdr='s,^/[^/]*,,'
-removedotparts=':dotsl
-		s@/\./@/@g
-		t dotsl
-		s,/\.$,/,'
-collapseslashes='s@/\{1,\}@/@g'
-finalslash='s,/*$,/,'
+# Except for the global variables explicitly listed below, the following
+# functions in the '^func_' namespace, and the '^require_' namespace
+# variables initialised in the 'Resource management' section, sourcing
+# this file will not pollute your global namespace with anything
+# else. There's no portable way to scope variables in Bourne shell
+# though, so actually running these functions will sometimes place
+# results into a variable named after the function, and often use
+# temporary variables in the '^_G_' namespace. If you are careful to
+# avoid using those namespaces casually in your sourcing script, things
+# should continue to work as you expect. And, of course, you can freely
+# overwrite any of the functions or variables defined here before
+# calling anything to customize them.
 
-# func_normal_abspath PATH
-# Remove doubled-up and trailing slashes, "." path components,
-# and cancel out any ".." path components in PATH after making
-# it an absolute path.
-#             value returned in "$func_normal_abspath_result"
-func_normal_abspath ()
-{
-  # Start from root dir and reassemble the path.
-  func_normal_abspath_result=
-  func_normal_abspath_tpath=$1
-  func_normal_abspath_altnamespace=
-  case $func_normal_abspath_tpath in
-    "")
-      # Empty path, that just means $cwd.
-      func_stripname '' '/' "`pwd`"
-      func_normal_abspath_result=$func_stripname_result
-      return
-    ;;
-    # The next three entries are used to spot a run of precisely
-    # two leading slashes without using negated character classes;
-    # we take advantage of case's first-match behaviour.
-    ///*)
-      # Unusual form of absolute path, do nothing.
-    ;;
-    //*)
-      # Not necessarily an ordinary path; POSIX reserves leading '//'
-      # and for example Cygwin uses it to access remote file shares
-      # over CIFS/SMB, so we conserve a leading double slash if found.
-      func_normal_abspath_altnamespace=/
-    ;;
-    /*)
-      # Absolute path, do nothing.
-    ;;
-    *)
-      # Relative path, prepend $cwd.
-      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
-    ;;
-  esac
-  # Cancel out all the simple stuff to save iterations.  We also want
-  # the path to end with a slash for ease of parsing, so make sure
-  # there is one (and only one) here.
-  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
-  while :; do
-    # Processed it all yet?
-    if test "$func_normal_abspath_tpath" = / ; then
-      # If we ascended to the root using ".." the result may be empty now.
-      if test -z "$func_normal_abspath_result" ; then
-        func_normal_abspath_result=/
-      fi
-      break
-    fi
-    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcar"`
-    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
-        -e "$pathcdr"`
-    # Figure out what to do with it
-    case $func_normal_abspath_tcomponent in
-      "")
-        # Trailing empty path component, ignore it.
-      ;;
-      ..)
-        # Parent dir; strip last assembled component from result.
-        func_dirname "$func_normal_abspath_result"
-        func_normal_abspath_result=$func_dirname_result
-      ;;
-      *)
-        # Actual path component, append it.
-        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
-      ;;
-    esac
-  done
-  # Restore leading double-slash if one was found on entry.
-  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
-}
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 
-# func_relative_path SRCDIR DSTDIR
-# generates a relative path from SRCDIR to DSTDIR, with a trailing
-# slash if non-empty, suitable for immediately appending a filename
-# without needing to append a separator.
-#             value returned in "$func_relative_path_result"
-func_relative_path ()
-{
-  func_relative_path_result=
-  func_normal_abspath "$1"
-  func_relative_path_tlibdir=$func_normal_abspath_result
-  func_normal_abspath "$2"
-  func_relative_path_tbindir=$func_normal_abspath_result
-
-  # Ascend the tree starting from libdir
-  while :; do
-    # check if we have found a prefix of bindir
-    case $func_relative_path_tbindir in
-      $func_relative_path_tlibdir)
-        # found an exact match
-        func_relative_path_tcancelled=
-        break
-        ;;
-      $func_relative_path_tlibdir*)
-        # found a matching prefix
-        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
-        func_relative_path_tcancelled=$func_stripname_result
-        if test -z "$func_relative_path_result"; then
-          func_relative_path_result=.
-        fi
-        break
-        ;;
-      *)
-        func_dirname $func_relative_path_tlibdir
-        func_relative_path_tlibdir=${func_dirname_result}
-        if test "x$func_relative_path_tlibdir" = x ; then
-          # Have to descend all the way to the root!
-          func_relative_path_result=../$func_relative_path_result
-          func_relative_path_tcancelled=$func_relative_path_tbindir
-          break
-        fi
-        func_relative_path_result=../$func_relative_path_result
-        ;;
-    esac
-  done
+# Allow overriding, eg assuming that you follow the convention of
+# putting '$debug_cmd' at the start of all your functions, you can get
+# bash to show function call trace with:
+#
+#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+debug_cmd=${debug_cmd-":"}
+exit_cmd=:
 
-  # Now calculate path; take care to avoid doubling-up slashes.
-  func_stripname '' '/' "$func_relative_path_result"
-  func_relative_path_result=$func_stripname_result
-  func_stripname '/' '/' "$func_relative_path_tcancelled"
-  if test "x$func_stripname_result" != x ; then
-    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
-  fi
+# By convention, finish your script with:
+#
+#    exit $exit_status
+#
+# so that you can set exit_status to non-zero if you want to indicate
+# something went wrong during execution without actually bailing out at
+# the point of failure.
+exit_status=$EXIT_SUCCESS
 
-  # Normalisation. If bindir is libdir, return empty string,
-  # else relative path ending with a slash; either way, target
-  # file name can be directly appended.
-  if test ! -z "$func_relative_path_result"; then
-    func_stripname './' '' "$func_relative_path_result/"
-    func_relative_path_result=$func_stripname_result
-  fi
-}
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath=$0
 
-# The name of this program:
-func_dirname_and_basename "$progpath"
-progname=$func_basename_result
+# The name of this program.
+progname=`$ECHO "$progpath" |$SED "$sed_basename"`
 
-# Make sure we have an absolute path for reexecution:
+# Make sure we have an absolute progpath for reexecution:
 case $progpath in
   [\\/]*|[A-Za-z]:\\*) ;;
   *[\\/]*)
-     progdir=$func_dirname_result
+     progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
      progdir=`cd "$progdir" && pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
   *)
-     save_IFS="$IFS"
+     _G_IFS=$IFS
      IFS=${PATH_SEPARATOR-:}
      for progdir in $PATH; do
-       IFS="$save_IFS"
+       IFS=$_G_IFS
        test -x "$progdir/$progname" && break
      done
-     IFS="$save_IFS"
+     IFS=$_G_IFS
      test -n "$progdir" || progdir=`pwd`
-     progpath="$progdir/$progname"
+     progpath=$progdir/$progname
      ;;
 esac
 
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
-# Sed substitution that turns a string into a regex matching for the
-# string literally.
-sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+## ----------------- ##
+## Standard options. ##
+## ----------------- ##
 
-# Sed substitution that converts a w32 file name or path
-# which contains forward slashes, into one that contains
-# (escaped) backslashes.  A very naive implementation.
-lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
-
-# Re-`\' parameter expansions in output of double_quote_subst that were
-# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
-# in input to double_quote_subst, that '$' was protected from expansion.
-# Since each input `\' is now two `\'s, look for any number of runs of
-# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
-bs='\\'
-bs2='\\\\'
-bs4='\\\\\\\\'
-dollar='\$'
-sed_double_backslash="\
-  s/$bs4/&\\
-/g
-  s/^$bs2$dollar/$bs&/
-  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
-  s/\n//g"
+# The following options affect the operation of the functions defined
+# below, and should be set appropriately depending on run-time para-
+# meters passed on the command line.
 
-# Standard options:
 opt_dry_run=false
-opt_help=false
 opt_quiet=false
 opt_verbose=false
-opt_warning=:
 
-# func_echo arg...
-# Echo program name prefixed message, along with the current mode
-# name if it has been set yet.
-func_echo ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
-}
+# Categories 'all' and 'none' are always available.  Append any others
+# you will pass as the first argument to func_warning from your own
+# code.
+warning_categories=
 
-# func_verbose arg...
-# Echo program name prefixed message in verbose mode only.
-func_verbose ()
-{
-    $opt_verbose && func_echo ${1+"$@"}
+# By default, display warnings according to 'opt_warning_types'.  Set
+# 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
+# treat the next displayed warning as a fatal error.
+warning_func=func_warn_and_continue
 
-    # A bug in bash halts the script if the last line of a function
-    # fails when set -e is in force, so we need another command to
-    # work around that:
-    :
-}
+# Set to 'all' to display all warnings, 'none' to suppress all
+# warnings, or a space delimited list of some subset of
+# 'warning_categories' to display only the listed warnings.
+opt_warning_types=all
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO "$*"
-}
 
-# func_error arg...
-# Echo program name prefixed message to standard error.
-func_error ()
-{
-    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
-}
+## -------------------- ##
+## Resource management. ##
+## -------------------- ##
 
-# func_warning arg...
-# Echo program name prefixed warning message to standard error.
-func_warning ()
-{
-    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+# This section contains definitions for functions that each ensure a
+# particular resource (a file, or a non-empty configuration variable for
+# example) is available, and if appropriate to extract default values
+# from pertinent package files. Call them using their associated
+# 'require_*' variable to ensure that they are executed, at most, once.
+#
+# It's entirely deliberate that calling these functions can set
+# variables that don't obey the namespace limitations obeyed by the rest
+# of this file, in order that that they be as useful as possible to
+# callers.
 
-    # bash bug again:
-    :
-}
 
-# func_fatal_error arg...
-# Echo program name prefixed message to standard error, and exit.
-func_fatal_error ()
+# require_term_colors
+# -------------------
+# Allow display of bold text on terminals that support it.
+require_term_colors=func_require_term_colors
+func_require_term_colors ()
 {
-    func_error ${1+"$@"}
-    exit $EXIT_FAILURE
-}
+    $debug_cmd
+
+    test -t 1 && {
+      # COLORTERM and USE_ANSI_COLORS environment variables take
+      # precedence, because most terminfo databases neglect to describe
+      # whether color sequences are supported.
+      test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
+
+      if test 1 = "$USE_ANSI_COLORS"; then
+        # Standard ANSI escape sequences
+        tc_reset=''
+        tc_bold='';   tc_standout=''
+        tc_red='';   tc_green=''
+        tc_blue='';  tc_cyan=''
+      else
+        # Otherwise trust the terminfo database after all.
+        test -n "`tput sgr0 2>/dev/null`" && {
+          tc_reset=`tput sgr0`
+          test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
+          tc_standout=$tc_bold
+          test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
+          test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
+          test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
+          test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
+          test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
+        }
+      fi
+    }
 
-# func_fatal_help arg...
-# Echo program name prefixed message to standard error, followed by
-# a help hint, and exit.
-func_fatal_help ()
-{
-    func_error ${1+"$@"}
-    func_fatal_error "$help"
+    require_term_colors=:
 }
-help="Try \`$progname --help' for more information."  ## default
 
 
-# func_grep expression filename
+## ----------------- ##
+## Function library. ##
+## ----------------- ##
+
+# This section contains a variety of useful functions to call in your
+# scripts. Take note of the portable wrappers for features provided by
+# some modern shells, which will fall back to slower equivalents on
+# less featureful shells.
+
+
+# func_append VAR VALUE
+# ---------------------
+# Append VALUE onto the existing contents of VAR.
+
+  # We should try to minimise forks, especially on Windows where they are
+  # unreasonably slow, so skip the feature probes when bash or zsh are
+  # being used:
+  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
+    : ${_G_HAVE_ARITH_OP="yes"}
+    : ${_G_HAVE_XSI_OPS="yes"}
+    # The += operator was introduced in bash 3.1
+    case $BASH_VERSION in
+      [12].* | 3.0 | 3.0*) ;;
+      *)
+        : ${_G_HAVE_PLUSEQ_OP="yes"}
+        ;;
+    esac
+  fi
+
+  # _G_HAVE_PLUSEQ_OP
+  # Can be empty, in which case the shell is probed, "yes" if += is
+  # useable or anything else if it does not work.
+  test -z "$_G_HAVE_PLUSEQ_OP" \
+    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
+    && _G_HAVE_PLUSEQ_OP=yes
+
+if test yes = "$_G_HAVE_PLUSEQ_OP"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_append ()
+  {
+    $debug_cmd
+
+    eval "$1+=\$2"
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_append ()
+  {
+    $debug_cmd
+
+    eval "$1=\$$1\$2"
+  }
+fi
+
+
+# func_append_quoted VAR VALUE
+# ----------------------------
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+  eval 'func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1+=\\ \$func_quote_for_eval_result"
+  }'
+else
+  func_append_quoted ()
+  {
+    $debug_cmd
+
+    func_quote_for_eval "$2"
+    eval "$1=\$$1\\ \$func_quote_for_eval_result"
+  }
+fi
+
+
+# func_append_uniq VAR VALUE
+# --------------------------
+# Append unique VALUE onto the existing contents of VAR, assuming
+# entries are delimited by the first character of VALUE.  For example:
+#
+#   func_append_uniq options " --another-option option-argument"
+#
+# will only append to $options if " --another-option option-argument "
+# is not already present somewhere in $options already (note spaces at
+# each end implied by leading space in second argument).
+func_append_uniq ()
+{
+    $debug_cmd
+
+    eval _G_current_value='`$ECHO $'$1'`'
+    _G_delim=`expr "$2" : '\(.\)'`
+
+    case $_G_delim$_G_current_value$_G_delim in
+      *"$2$_G_delim"*) ;;
+      *) func_append "$@" ;;
+    esac
+}
+
+
+# func_arith TERM...
+# ------------------
+# Set func_arith_result to the result of evaluating TERMs.
+  test -z "$_G_HAVE_ARITH_OP" \
+    && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
+    && _G_HAVE_ARITH_OP=yes
+
+if test yes = "$_G_HAVE_ARITH_OP"; then
+  eval 'func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=$(( $* ))
+  }'
+else
+  func_arith ()
+  {
+    $debug_cmd
+
+    func_arith_result=`expr "$@"`
+  }
+fi
+
+
+# func_basename FILE
+# ------------------
+# Set func_basename_result to FILE with everything up to and including
+# the last / stripped.
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  # If this shell supports suffix pattern removal, then use it to avoid
+  # forking. Hide the definitions single quotes in case the shell chokes
+  # on unsupported syntax...
+  _b='func_basename_result=${1##*/}'
+  _d='case $1 in
+        */*) func_dirname_result=${1%/*}$2 ;;
+        *  ) func_dirname_result=$3        ;;
+      esac'
+
+else
+  # ...otherwise fall back to using sed.
+  _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
+  _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
+      if test "X$func_dirname_result" = "X$1"; then
+        func_dirname_result=$3
+      else
+        func_append func_dirname_result "$2"
+      fi'
+fi
+
+eval 'func_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+}'
+
+
+# func_dirname FILE APPEND NONDIR_REPLACEMENT
+# -------------------------------------------
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+eval 'func_dirname ()
+{
+    $debug_cmd
+
+    '"$_d"'
+}'
+
+
+# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
+# --------------------------------------------------------
+# Perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# For efficiency, we do not delegate to the functions above but instead
+# duplicate the functionality here.
+eval 'func_dirname_and_basename ()
+{
+    $debug_cmd
+
+    '"$_b"'
+    '"$_d"'
+}'
+
+
+# func_echo ARG...
+# ----------------
+# Echo program name prefixed message.
+func_echo ()
+{
+    $debug_cmd
+
+    _G_message=$*
+
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
+
+
+# func_echo_all ARG...
+# --------------------
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO "$*"
+}
+
+
+# func_echo_infix_1 INFIX ARG...
+# ------------------------------
+# Echo program name, followed by INFIX on the first line, with any
+# additional lines not showing INFIX.
+func_echo_infix_1 ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    _G_infix=$1; shift
+    _G_indent=$_G_infix
+    _G_prefix="$progname: $_G_infix: "
+    _G_message=$*
+
+    # Strip color escape sequences before counting printable length
+    for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
+    do
+      test -n "$_G_tc" && {
+        _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
+        _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
+      }
+    done
+    _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
+
+    func_echo_infix_1_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_infix_1_IFS
+      $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
+      _G_prefix=$_G_indent
+    done
+    IFS=$func_echo_infix_1_IFS
+}
+
+
+# func_error ARG...
+# -----------------
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
+}
+
+
+# func_fatal_error ARG...
+# -----------------------
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    $debug_cmd
+
+    func_error "$*"
+    exit $EXIT_FAILURE
+}
+
+
+# func_grep EXPRESSION FILENAME
+# -----------------------------
 # Check whether EXPRESSION matches any line of FILENAME, without output.
 func_grep ()
 {
+    $debug_cmd
+
     $GREP "$1" "$2" >/dev/null 2>&1
 }
 
 
-# func_mkdir_p directory-path
+# func_len STRING
+# ---------------
+# Set func_len_result to the length of STRING. STRING may not
+# start with a hyphen.
+  test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=${#1}
+  }'
+else
+  func_len ()
+  {
+    $debug_cmd
+
+    func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+  }
+fi
+
+
+# func_mkdir_p DIRECTORY-PATH
+# ---------------------------
 # Make sure the entire path to DIRECTORY-PATH is available.
 func_mkdir_p ()
 {
-    my_directory_path="$1"
-    my_dir_list=
+    $debug_cmd
 
-    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+    _G_directory_path=$1
+    _G_dir_list=
 
-      # Protect directory names starting with `-'
-      case $my_directory_path in
-        -*) my_directory_path="./$my_directory_path" ;;
+    if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
+
+      # Protect directory names starting with '-'
+      case $_G_directory_path in
+        -*) _G_directory_path=./$_G_directory_path ;;
       esac
 
       # While some portion of DIR does not yet exist...
-      while test ! -d "$my_directory_path"; do
+      while test ! -d "$_G_directory_path"; do
         # ...make a list in topmost first order.  Use a colon delimited
 	# list incase some portion of path contains whitespace.
-        my_dir_list="$my_directory_path:$my_dir_list"
+        _G_dir_list=$_G_directory_path:$_G_dir_list
 
         # If the last portion added has no slash in it, the list is done
-        case $my_directory_path in */*) ;; *) break ;; esac
+        case $_G_directory_path in */*) ;; *) break ;; esac
 
         # ...otherwise throw away the child directory and loop
-        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+        _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
       done
-      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+      _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
 
-      save_mkdir_p_IFS="$IFS"; IFS=':'
-      for my_dir in $my_dir_list; do
-	IFS="$save_mkdir_p_IFS"
-        # mkdir can fail with a `File exist' error if two processes
+      func_mkdir_p_IFS=$IFS; IFS=:
+      for _G_dir in $_G_dir_list; do
+	IFS=$func_mkdir_p_IFS
+        # mkdir can fail with a 'File exist' error if two processes
         # try to create one of the directories concurrently.  Don't
         # stop in that case!
-        $MKDIR "$my_dir" 2>/dev/null || :
+        $MKDIR "$_G_dir" 2>/dev/null || :
       done
-      IFS="$save_mkdir_p_IFS"
+      IFS=$func_mkdir_p_IFS
 
       # Bail out if we (or some other process) failed to create a directory.
-      test -d "$my_directory_path" || \
-        func_fatal_error "Failed to create \`$1'"
+      test -d "$_G_directory_path" || \
+        func_fatal_error "Failed to create '$1'"
     fi
 }
 
 
-# func_mktempdir [string]
+# func_mktempdir [BASENAME]
+# -------------------------
 # Make a temporary directory that won't clash with other running
 # libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
+# given, BASENAME is the basename for that directory.
 func_mktempdir ()
 {
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
+    $debug_cmd
+
+    _G_template=${TMPDIR-/tmp}/${1-$progname}
 
-    if test "$opt_dry_run" = ":"; then
+    if test : = "$opt_dry_run"; then
       # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
+      _G_tmpdir=$_G_template-$$
     else
 
       # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+      _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
 
-      if test ! -d "$my_tmpdir"; then
+      if test ! -d "$_G_tmpdir"; then
         # Failing that, at least try and use $RANDOM to avoid a race
-        my_tmpdir="${my_template}-${RANDOM-0}$$"
+        _G_tmpdir=$_G_template-${RANDOM-0}$$
 
-        save_mktempdir_umask=`umask`
+        func_mktempdir_umask=`umask`
         umask 0077
-        $MKDIR "$my_tmpdir"
-        umask $save_mktempdir_umask
+        $MKDIR "$_G_tmpdir"
+        umask $func_mktempdir_umask
       fi
 
       # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || \
-        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+      test -d "$_G_tmpdir" || \
+        func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
+    fi
+
+    $ECHO "$_G_tmpdir"
+}
+
+
+# func_normal_abspath PATH
+# ------------------------
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+func_normal_abspath ()
+{
+    $debug_cmd
+
+    # These SED scripts presuppose an absolute path with a trailing slash.
+    _G_pathcar='s|^/\([^/]*\).*$|\1|'
+    _G_pathcdr='s|^/[^/]*||'
+    _G_removedotparts=':dotsl
+		s|/\./|/|g
+		t dotsl
+		s|/\.$|/|'
+    _G_collapseslashes='s|/\{1,\}|/|g'
+    _G_finalslash='s|/*$|/|'
+
+    # Start from root dir and reassemble the path.
+    func_normal_abspath_result=
+    func_normal_abspath_tpath=$1
+    func_normal_abspath_altnamespace=
+    case $func_normal_abspath_tpath in
+      "")
+        # Empty path, that just means $cwd.
+        func_stripname '' '/' "`pwd`"
+        func_normal_abspath_result=$func_stripname_result
+        return
+        ;;
+      # The next three entries are used to spot a run of precisely
+      # two leading slashes without using negated character classes;
+      # we take advantage of case's first-match behaviour.
+      ///*)
+        # Unusual form of absolute path, do nothing.
+        ;;
+      //*)
+        # Not necessarily an ordinary path; POSIX reserves leading '//'
+        # and for example Cygwin uses it to access remote file shares
+        # over CIFS/SMB, so we conserve a leading double slash if found.
+        func_normal_abspath_altnamespace=/
+        ;;
+      /*)
+        # Absolute path, do nothing.
+        ;;
+      *)
+        # Relative path, prepend $cwd.
+        func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+        ;;
+    esac
+
+    # Cancel out all the simple stuff to save iterations.  We also want
+    # the path to end with a slash for ease of parsing, so make sure
+    # there is one (and only one) here.
+    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
+    while :; do
+      # Processed it all yet?
+      if test / = "$func_normal_abspath_tpath"; then
+        # If we ascended to the root using ".." the result may be empty now.
+        if test -z "$func_normal_abspath_result"; then
+          func_normal_abspath_result=/
+        fi
+        break
+      fi
+      func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcar"`
+      func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+          -e "$_G_pathcdr"`
+      # Figure out what to do with it
+      case $func_normal_abspath_tcomponent in
+        "")
+          # Trailing empty path component, ignore it.
+          ;;
+        ..)
+          # Parent dir; strip last assembled component from result.
+          func_dirname "$func_normal_abspath_result"
+          func_normal_abspath_result=$func_dirname_result
+          ;;
+        *)
+          # Actual path component, append it.
+          func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
+          ;;
+      esac
+    done
+    # Restore leading double-slash if one was found on entry.
+    func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+
+# func_notquiet ARG...
+# --------------------
+# Echo program name prefixed message only when not in quiet mode.
+func_notquiet ()
+{
+    $debug_cmd
+
+    $opt_quiet || func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+
+# func_relative_path SRCDIR DSTDIR
+# --------------------------------
+# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
+func_relative_path ()
+{
+    $debug_cmd
+
+    func_relative_path_result=
+    func_normal_abspath "$1"
+    func_relative_path_tlibdir=$func_normal_abspath_result
+    func_normal_abspath "$2"
+    func_relative_path_tbindir=$func_normal_abspath_result
+
+    # Ascend the tree starting from libdir
+    while :; do
+      # check if we have found a prefix of bindir
+      case $func_relative_path_tbindir in
+        $func_relative_path_tlibdir)
+          # found an exact match
+          func_relative_path_tcancelled=
+          break
+          ;;
+        $func_relative_path_tlibdir*)
+          # found a matching prefix
+          func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+          func_relative_path_tcancelled=$func_stripname_result
+          if test -z "$func_relative_path_result"; then
+            func_relative_path_result=.
+          fi
+          break
+          ;;
+        *)
+          func_dirname $func_relative_path_tlibdir
+          func_relative_path_tlibdir=$func_dirname_result
+          if test -z "$func_relative_path_tlibdir"; then
+            # Have to descend all the way to the root!
+            func_relative_path_result=../$func_relative_path_result
+            func_relative_path_tcancelled=$func_relative_path_tbindir
+            break
+          fi
+          func_relative_path_result=../$func_relative_path_result
+          ;;
+      esac
+    done
+
+    # Now calculate path; take care to avoid doubling-up slashes.
+    func_stripname '' '/' "$func_relative_path_result"
+    func_relative_path_result=$func_stripname_result
+    func_stripname '/' '/' "$func_relative_path_tcancelled"
+    if test -n "$func_stripname_result"; then
+      func_append func_relative_path_result "/$func_stripname_result"
+    fi
+
+    # Normalisation. If bindir is libdir, return '.' else relative path.
+    if test -n "$func_relative_path_result"; then
+      func_stripname './' '' "$func_relative_path_result"
+      func_relative_path_result=$func_stripname_result
     fi
 
-    $ECHO "$my_tmpdir"
+    test -n "$func_relative_path_result" || func_relative_path_result=.
+
+    :
+}
+
+
+# func_quote_for_eval ARG...
+# --------------------------
+# Aesthetically quote ARGs to be evaled later.
+# This function returns two values:
+#   i) func_quote_for_eval_result
+#      double-quoted, suitable for a subsequent eval
+#  ii) func_quote_for_eval_unquoted_result
+#      has all characters that are still active within double
+#      quotes backslashified.
+func_quote_for_eval ()
+{
+    $debug_cmd
+
+    func_quote_for_eval_unquoted_result=
+    func_quote_for_eval_result=
+    while test 0 -lt $#; do
+      case $1 in
+        *[\\\`\"\$]*)
+	  _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+        *)
+          _G_unquoted_arg=$1 ;;
+      esac
+      if test -n "$func_quote_for_eval_unquoted_result"; then
+	func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+      else
+        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+      fi
+
+      case $_G_unquoted_arg in
+        # Double-quote args containing shell metacharacters to delay
+        # word splitting, command substitution and variable expansion
+        # for a subsequent eval.
+        # Many Bourne shells cannot handle close brackets correctly
+        # in scan sets, so we specify it separately.
+        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+          _G_quoted_arg=\"$_G_unquoted_arg\"
+          ;;
+        *)
+          _G_quoted_arg=$_G_unquoted_arg
+	  ;;
+      esac
+
+      if test -n "$func_quote_for_eval_result"; then
+	func_append func_quote_for_eval_result " $_G_quoted_arg"
+      else
+        func_append func_quote_for_eval_result "$_G_quoted_arg"
+      fi
+      shift
+    done
+}
+
+
+# func_quote_for_expand ARG
+# -------------------------
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    $debug_cmd
+
+    case $1 in
+      *[\\\`\"]*)
+	_G_arg=`$ECHO "$1" | $SED \
+	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        _G_arg=$1 ;;
+    esac
+
+    case $_G_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        _G_arg=\"$_G_arg\"
+        ;;
+    esac
+
+    func_quote_for_expand_result=$_G_arg
+}
+
+
+# func_stripname PREFIX SUFFIX NAME
+# ---------------------------------
+# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_stripname ()
+  {
+    $debug_cmd
+
+    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+    # positional parameters, so assign one to ordinary variable first.
+    func_stripname_result=$3
+    func_stripname_result=${func_stripname_result#"$1"}
+    func_stripname_result=${func_stripname_result%"$2"}
+  }'
+else
+  func_stripname ()
+  {
+    $debug_cmd
+
+    case $2 in
+      .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
+      *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
+    esac
+  }
+fi
+
+
+# func_show_eval CMD [FAIL_EXP]
+# -----------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    func_quote_for_expand "$_G_cmd"
+    eval "func_notquiet $func_quote_for_expand_result"
+
+    $opt_dry_run || {
+      eval "$_G_cmd"
+      _G_status=$?
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_show_eval_locale CMD [FAIL_EXP]
+# ------------------------------------
+# Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    $debug_cmd
+
+    _G_cmd=$1
+    _G_fail_exp=${2-':'}
+
+    $opt_quiet || {
+      func_quote_for_expand "$_G_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    $opt_dry_run || {
+      eval "$_G_user_locale
+	    $_G_cmd"
+      _G_status=$?
+      eval "$_G_safe_locale"
+      if test 0 -ne "$_G_status"; then
+	eval "(exit $_G_status); $_G_fail_exp"
+      fi
+    }
+}
+
+
+# func_tr_sh
+# ----------
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result.  All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+    $debug_cmd
+
+    case $1 in
+    [0-9]* | *[!a-zA-Z0-9_]*)
+      func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
+      ;;
+    * )
+      func_tr_sh_result=$1
+      ;;
+    esac
+}
+
+
+# func_verbose ARG...
+# -------------------
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $debug_cmd
+
+    $opt_verbose && func_echo "$*"
+
+    :
+}
+
+
+# func_warn_and_continue ARG...
+# -----------------------------
+# Echo program name prefixed warning message to standard error.
+func_warn_and_continue ()
+{
+    $debug_cmd
+
+    $require_term_colors
+
+    func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
+}
+
+
+# func_warning CATEGORY ARG...
+# ----------------------------
+# Echo program name prefixed warning message to standard error. Warning
+# messages can be filtered according to CATEGORY, where this function
+# elides messages where CATEGORY is not listed in the global variable
+# 'opt_warning_types'.
+func_warning ()
+{
+    $debug_cmd
+
+    # CATEGORY must be in the warning_categories list!
+    case " $warning_categories " in
+      *" $1 "*) ;;
+      *) func_internal_error "invalid warning category '$1'" ;;
+    esac
+
+    _G_category=$1
+    shift
+
+    case " $opt_warning_types " in
+      *" $_G_category "*) $warning_func ${1+"$@"} ;;
+    esac
+}
+
+
+# func_sort_ver VER1 VER2
+# -----------------------
+# 'sort -V' is not generally available.
+# Note this deviates from the version comparison in automake
+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
+# but this should suffice as we won't be specifying old
+# version formats or redundant trailing .0 in bootstrap.conf.
+# If we did want full compatibility then we should probably
+# use m4_version_compare from autoconf.
+func_sort_ver ()
+{
+    $debug_cmd
+
+    printf '%s\n%s\n' "$1" "$2" \
+      | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
+}
+
+# func_lt_ver PREV CURR
+# ---------------------
+# Return true if PREV and CURR are in the correct order according to
+# func_sort_ver, otherwise false.  Use it like this:
+#
+#  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
+func_lt_ver ()
+{
+    $debug_cmd
+
+    test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
+}
+
+
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
+#! /bin/sh
+
+# Set a version string for this script.
+scriptversion=2014-01-07.03; # UTC
+
+# A portable, pluggable option parser for Bourne shell.
+# Written by Gary V. Vaughan, 2010
+
+# Copyright (C) 2010-2015 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Please report bugs or propose patches to gary at gnu.org.
+
+
+## ------ ##
+## Usage. ##
+## ------ ##
+
+# This file is a library for parsing options in your shell scripts along
+# with assorted other useful supporting features that you can make use
+# of too.
+#
+# For the simplest scripts you might need only:
+#
+#   #!/bin/sh
+#   . relative/path/to/funclib.sh
+#   . relative/path/to/options-parser
+#   scriptversion=1.0
+#   func_options ${1+"$@"}
+#   eval set dummy "$func_options_result"; shift
+#   ...rest of your script...
+#
+# In order for the '--version' option to work, you will need to have a
+# suitably formatted comment like the one at the top of this file
+# starting with '# Written by ' and ending with '# warranty; '.
+#
+# For '-h' and '--help' to work, you will also need a one line
+# description of your script's purpose in a comment directly above the
+# '# Written by ' line, like the one at the top of this file.
+#
+# The default options also support '--debug', which will turn on shell
+# execution tracing (see the comment above debug_cmd below for another
+# use), and '--verbose' and the func_verbose function to allow your script
+# to display verbose messages only when your user has specified
+# '--verbose'.
+#
+# After sourcing this file, you can plug processing for additional
+# options by amending the variables from the 'Configuration' section
+# below, and following the instructions in the 'Option parsing'
+# section further down.
+
+## -------------- ##
+## Configuration. ##
+## -------------- ##
+
+# You should override these variables in your script after sourcing this
+# file so that they reflect the customisations you have added to the
+# option parser.
+
+# The usage line for option parsing errors and the start of '-h' and
+# '--help' output messages. You can embed shell variables for delayed
+# expansion at the time the message is displayed, but you will need to
+# quote other shell meta-characters carefully to prevent them being
+# expanded when the contents are evaled.
+usage='$progpath [OPTION]...'
+
+# Short help message in response to '-h' and '--help'.  Add to this or
+# override it after sourcing this library to reflect the full set of
+# options your script accepts.
+usage_message="\
+       --debug        enable verbose shell tracing
+   -W, --warnings=CATEGORY
+                      report the warnings falling in CATEGORY [all]
+   -v, --verbose      verbosely report processing
+       --version      print version information and exit
+   -h, --help         print short or long help message and exit
+"
+
+# Additional text appended to 'usage_message' in response to '--help'.
+long_help_message="
+Warning categories include:
+       'all'          show all warnings
+       'none'         turn off all the warnings
+       'error'        warnings are treated as fatal errors"
+
+# Help message printed before fatal option parsing errors.
+fatal_help="Try '\$progname --help' for more information."
+
+
+
+## ------------------------- ##
+## Hook function management. ##
+## ------------------------- ##
+
+# This section contains functions for adding, removing, and running hooks
+# to the main code.  A hook is just a named list of of function, that can
+# be run in order later on.
+
+# func_hookable FUNC_NAME
+# -----------------------
+# Declare that FUNC_NAME will run hooks added with
+# 'func_add_hook FUNC_NAME ...'.
+func_hookable ()
+{
+    $debug_cmd
+
+    func_append hookable_fns " $1"
+}
+
+
+# func_add_hook FUNC_NAME HOOK_FUNC
+# ---------------------------------
+# Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
+# first have been declared "hookable" by a call to 'func_hookable'.
+func_add_hook ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not accept hook functions." ;;
+    esac
+
+    eval func_append ${1}_hooks '" $2"'
+}
+
+
+# func_remove_hook FUNC_NAME HOOK_FUNC
+# ------------------------------------
+# Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
+func_remove_hook ()
+{
+    $debug_cmd
+
+    eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
+}
+
+
+# func_run_hooks FUNC_NAME [ARG]...
+# ---------------------------------
+# Run all hook functions registered to FUNC_NAME.
+# It is assumed that the list of hook functions contains nothing more
+# than a whitespace-delimited list of legal shell function names, and
+# no effort is wasted trying to catch shell meta-characters or preserve
+# whitespace.
+func_run_hooks ()
+{
+    $debug_cmd
+
+    case " $hookable_fns " in
+      *" $1 "*) ;;
+      *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+    esac
+
+    eval _G_hook_fns=\$$1_hooks; shift
+
+    for _G_hook in $_G_hook_fns; do
+      eval $_G_hook '"$@"'
+
+      # store returned options list back into positional
+      # parameters for next 'cmd' execution.
+      eval _G_hook_result=\$${_G_hook}_result
+      eval set dummy "$_G_hook_result"; shift
+    done
+
+    func_quote_for_eval ${1+"$@"}
+    func_run_hooks_result=$func_quote_for_eval_result
+}
+
+
+
+## --------------- ##
+## Option parsing. ##
+## --------------- ##
+
+# In order to add your own option parsing hooks, you must accept the
+# full positional parameter list in your hook function, remove any
+# options that you action, and then pass back the remaining unprocessed
+# options in '<hooked_function_name>_result', escaped suitably for
+# 'eval'.  Like this:
+#
+#    my_options_prep ()
+#    {
+#        $debug_cmd
+#
+#        # Extend the existing usage message.
+#        usage_message=$usage_message'
+#      -s, --silent       don'\''t print informational messages
+#    '
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_options_prep_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_options_prep my_options_prep
+#
+#
+#    my_silent_option ()
+#    {
+#        $debug_cmd
+#
+#        # Note that for efficiency, we parse as many options as we can
+#        # recognise in a loop before passing the remainder back to the
+#        # caller on the first unrecognised argument we encounter.
+#        while test $# -gt 0; do
+#          opt=$1; shift
+#          case $opt in
+#            --silent|-s) opt_silent=: ;;
+#            # Separate non-argument short options:
+#            -s*)         func_split_short_opt "$_G_opt"
+#                         set dummy "$func_split_short_opt_name" \
+#                             "-$func_split_short_opt_arg" ${1+"$@"}
+#                         shift
+#                         ;;
+#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#          esac
+#        done
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_silent_option_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_parse_options my_silent_option
+#
+#
+#    my_option_validation ()
+#    {
+#        $debug_cmd
+#
+#        $opt_silent && $opt_verbose && func_fatal_help "\
+#    '--silent' and '--verbose' options are mutually exclusive."
+#
+#        func_quote_for_eval ${1+"$@"}
+#        my_option_validation_result=$func_quote_for_eval_result
+#    }
+#    func_add_hook func_validate_options my_option_validation
+#
+# You'll alse need to manually amend $usage_message to reflect the extra
+# options you parse.  It's preferable to append if you can, so that
+# multiple option parsing hooks can be added safely.
+
+
+# func_options [ARG]...
+# ---------------------
+# All the functions called inside func_options are hookable. See the
+# individual implementations for details.
+func_hookable func_options
+func_options ()
+{
+    $debug_cmd
+
+    func_options_prep ${1+"$@"}
+    eval func_parse_options \
+        ${func_options_prep_result+"$func_options_prep_result"}
+    eval func_validate_options \
+        ${func_parse_options_result+"$func_parse_options_result"}
+
+    eval func_run_hooks func_options \
+        ${func_validate_options_result+"$func_validate_options_result"}
+
+    # save modified positional parameters for caller
+    func_options_result=$func_run_hooks_result
 }
 
 
-# func_quote_for_eval arg
-# Aesthetically quote ARG to be evaled later.
-# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
-# is double-quoted, suitable for a subsequent eval, whereas
-# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
-# which are still active within double quotes backslashified.
-func_quote_for_eval ()
+# func_options_prep [ARG]...
+# --------------------------
+# All initialisations required before starting the option parse loop.
+# Note that when calling hook functions, we pass through the list of
+# positional parameters.  If a hook function modifies that list, and
+# needs to propogate that back to rest of this script, then the complete
+# modified list must be put in 'func_run_hooks_result' before
+# returning.
+func_hookable func_options_prep
+func_options_prep ()
 {
-    case $1 in
-      *[\\\`\"\$]*)
-	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
-      *)
-        func_quote_for_eval_unquoted_result="$1" ;;
-    esac
+    $debug_cmd
 
-    case $func_quote_for_eval_unquoted_result in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting, command substitution and and variable
-      # expansion for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
-        ;;
-      *)
-        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
-    esac
+    # Option defaults:
+    opt_verbose=false
+    opt_warning_types=
+
+    func_run_hooks func_options_prep ${1+"$@"}
+
+    # save modified positional parameters for caller
+    func_options_prep_result=$func_run_hooks_result
 }
 
 
-# func_quote_for_expand arg
-# Aesthetically quote ARG to be evaled later; same as above,
-# but do not quote variable references.
-func_quote_for_expand ()
+# func_parse_options [ARG]...
+# ---------------------------
+# The main option parsing loop.
+func_hookable func_parse_options
+func_parse_options ()
 {
-    case $1 in
-      *[\\\`\"]*)
-	my_arg=`$ECHO "$1" | $SED \
-	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
-      *)
-        my_arg="$1" ;;
-    esac
+    $debug_cmd
 
-    case $my_arg in
-      # Double-quote args containing shell metacharacters to delay
-      # word splitting and command substitution for a subsequent eval.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, so we specify it separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-        my_arg="\"$my_arg\""
-        ;;
-    esac
+    func_parse_options_result=
 
-    func_quote_for_expand_result="$my_arg"
-}
+    # this just eases exit handling
+    while test $# -gt 0; do
+      # Defer to hook functions for initial option parsing, so they
+      # get priority in the event of reusing an option name.
+      func_run_hooks func_parse_options ${1+"$@"}
 
+      # Adjust func_parse_options positional parameters to match
+      eval set dummy "$func_run_hooks_result"; shift
 
-# func_show_eval cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.
-func_show_eval ()
-{
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+      # Break out of the loop if we already parsed every option.
+      test $# -gt 0 || break
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --debug|-x)   debug_cmd='set -x'
+                      func_echo "enabling shell trace mode"
+                      $debug_cmd
+                      ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                      set dummy --warnings none ${1+"$@"}
+                      shift
+		      ;;
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$my_cmd"
-      my_status=$?
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
+        --warnings|--warning|-W)
+                      test $# = 0 && func_missing_arg $_G_opt && break
+                      case " $warning_categories $1" in
+                        *" $1 "*)
+                          # trailing space prevents matching last $1 above
+                          func_append_uniq opt_warning_types " $1"
+                          ;;
+                        *all)
+                          opt_warning_types=$warning_categories
+                          ;;
+                        *none)
+                          opt_warning_types=none
+                          warning_func=:
+                          ;;
+                        *error)
+                          opt_warning_types=$warning_categories
+                          warning_func=func_fatal_error
+                          ;;
+                        *)
+                          func_fatal_error \
+                             "unsupported warning category: '$1'"
+                          ;;
+                      esac
+                      shift
+                      ;;
+
+        --verbose|-v) opt_verbose=: ;;
+        --version)    func_version ;;
+        -\?|-h)       func_usage ;;
+        --help)       func_help ;;
+
+	# Separate optargs to long options (plugins may need this):
+	--*=*)        func_split_equals "$_G_opt"
+	              set dummy "$func_split_equals_lhs" \
+                          "$func_split_equals_rhs" ${1+"$@"}
+                      shift
+                      ;;
+
+       # Separate optargs to short options:
+        -W*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        # Separate non-argument short options:
+        -\?*|-h*|-v*|-x*)
+                      func_split_short_opt "$_G_opt"
+                      set dummy "$func_split_short_opt_name" \
+                          "-$func_split_short_opt_arg" ${1+"$@"}
+                      shift
+                      ;;
+
+        --)           break ;;
+        -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+      esac
+    done
+
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    func_parse_options_result=$func_quote_for_eval_result
 }
 
 
-# func_show_eval_locale cmd [fail_exp]
-# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
-# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
-# is given, then evaluate it.  Use the saved locale for evaluation.
-func_show_eval_locale ()
+# func_validate_options [ARG]...
+# ------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+func_hookable func_validate_options
+func_validate_options ()
 {
-    my_cmd="$1"
-    my_fail_exp="${2-:}"
+    $debug_cmd
 
-    ${opt_silent-false} || {
-      func_quote_for_expand "$my_cmd"
-      eval "func_echo $func_quote_for_expand_result"
-    }
+    # Display all warnings if -W was not given.
+    test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 
-    if ${opt_dry_run-false}; then :; else
-      eval "$lt_user_locale
-	    $my_cmd"
-      my_status=$?
-      eval "$lt_safe_locale"
-      if test "$my_status" -eq 0; then :; else
-	eval "(exit $my_status); $my_fail_exp"
-      fi
-    fi
-}
+    func_run_hooks func_validate_options ${1+"$@"}
 
-# func_tr_sh
-# Turn $1 into a string suitable for a shell variable name.
-# Result is stored in $func_tr_sh_result.  All characters
-# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
-# if $1 begins with a digit, a '_' is prepended as well.
-func_tr_sh ()
-{
-  case $1 in
-  [0-9]* | *[!a-zA-Z0-9_]*)
-    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
-    ;;
-  * )
-    func_tr_sh_result=$1
-    ;;
-  esac
+    # Bail if the options were screwed!
+    $exit_cmd $EXIT_FAILURE
+
+    # save modified positional parameters for caller
+    func_validate_options_result=$func_run_hooks_result
 }
 
 
-# func_version
-# Echo version message to standard output and exit.
-func_version ()
-{
-    $opt_debug
 
-    $SED -n '/(C)/!b go
-	:more
-	/\./!{
-	  N
-	  s/\n# / /
-	  b more
-	}
-	:go
-	/^# '$PROGRAM' (GNU /,/# warranty; / {
-        s/^# //
-	s/^# *$//
-        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
-        p
-     }' < "$progpath"
-     exit $?
-}
+## ----------------- ##
+## Helper functions. ##
+## ----------------- ##
 
-# func_usage
-# Echo short help message to standard output and exit.
-func_usage ()
+# This section contains the helper functions used by the rest of the
+# hookable option parser framework in ascii-betical order.
+
+
+# func_fatal_help ARG...
+# ----------------------
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
 {
-    $opt_debug
+    $debug_cmd
 
-    $SED -n '/^# Usage:/,/^#  *.*--help/ {
-        s/^# //
-	s/^# *$//
-	s/\$progname/'$progname'/
-	p
-    }' < "$progpath"
-    echo
-    $ECHO "run \`$progname --help | more' for full usage"
-    exit $?
+    eval \$ECHO \""Usage: $usage"\"
+    eval \$ECHO \""$fatal_help"\"
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
 }
 
-# func_help [NOEXIT]
-# Echo long help message to standard output and exit,
-# unless 'noexit' is passed as argument.
+
+# func_help
+# ---------
+# Echo long help message to standard output and exit.
 func_help ()
 {
-    $opt_debug
-
-    $SED -n '/^# Usage:/,/# Report bugs to/ {
-	:print
-        s/^# //
-	s/^# *$//
-	s*\$progname*'$progname'*
-	s*\$host*'"$host"'*
-	s*\$SHELL*'"$SHELL"'*
-	s*\$LTCC*'"$LTCC"'*
-	s*\$LTCFLAGS*'"$LTCFLAGS"'*
-	s*\$LD*'"$LD"'*
-	s/\$with_gnu_ld/'"$with_gnu_ld"'/
-	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
-	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
-	p
-	d
-     }
-     /^# .* home page:/b print
-     /^# General help using/b print
-     ' < "$progpath"
-    ret=$?
-    if test -z "$1"; then
-      exit $ret
-    fi
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message"
+    exit 0
 }
 
-# func_missing_arg argname
+
+# func_missing_arg ARGNAME
+# ------------------------
 # Echo program name prefixed message to standard error and set global
 # exit_cmd.
 func_missing_arg ()
 {
-    $opt_debug
+    $debug_cmd
 
-    func_error "missing argument for $1."
+    func_error "Missing argument for '$1'."
     exit_cmd=exit
 }
 
 
-# func_split_short_opt shortopt
+# func_split_equals STRING
+# ------------------------
+# Set func_split_equals_lhs and func_split_equals_rhs shell variables after
+# splitting STRING at the '=' sign.
+test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=${1%%=*}
+      func_split_equals_rhs=${1#*=}
+      test "x$func_split_equals_lhs" = "x$1" \
+        && func_split_equals_rhs=
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_equals ()
+  {
+      $debug_cmd
+
+      func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
+      func_split_equals_rhs=
+      test "x$func_split_equals_lhs" = "x$1" \
+        || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
+  }
+fi #func_split_equals
+
+
+# func_split_short_opt SHORTOPT
+# -----------------------------
 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 # variables after splitting SHORTOPT after the 2nd character.
-func_split_short_opt ()
+if test yes = "$_G_HAVE_XSI_OPS"
+then
+  # This is an XSI compatible shell, allowing a faster implementation...
+  eval 'func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_arg=${1#??}
+      func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
+  }'
+else
+  # ...otherwise fall back to using expr, which is often a shell builtin.
+  func_split_short_opt ()
+  {
+      $debug_cmd
+
+      func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
+      func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
+  }
+fi #func_split_short_opt
+
+
+# func_usage
+# ----------
+# Echo short help message to standard output and exit.
+func_usage ()
 {
-    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
-    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+    $debug_cmd
 
-    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
-    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
-} # func_split_short_opt may be replaced by extended shell implementation
+    func_usage_message
+    $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
+    exit 0
+}
 
 
-# func_split_long_opt longopt
-# Set func_split_long_opt_name and func_split_long_opt_arg shell
-# variables after splitting LONGOPT at the `=' sign.
-func_split_long_opt ()
+# func_usage_message
+# ------------------
+# Echo short help message to standard output.
+func_usage_message ()
 {
-    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
-    my_sed_long_arg='1s/^--[^=]*=//'
+    $debug_cmd
 
-    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
-    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
-} # func_split_long_opt may be replaced by extended shell implementation
+    eval \$ECHO \""Usage: $usage"\"
+    echo
+    $SED -n 's|^# ||
+        /^Written by/{
+          x;p;x
+        }
+	h
+	/^Written by/q' < "$progpath"
+    echo
+    eval \$ECHO \""$usage_message"\"
+}
 
-exit_cmd=:
 
+# func_version
+# ------------
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $debug_cmd
 
+    printf '%s\n' "$progname $scriptversion"
+    $SED -n '
+        /(C)/!b go
+        :more
+        /\./!{
+          N
+          s|\n# | |
+          b more
+        }
+        :go
+        /^# Written by /,/# warranty; / {
+          s|^# ||
+          s|^# *$||
+          s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
+          p
+        }
+        /^# Written by / {
+          s|^# ||
+          p
+        }
+        /^warranty; /q' < "$progpath"
 
+    exit $?
+}
 
 
-magic="%%%MAGIC variable%%%"
-magic_exe="%%%MAGIC EXE variable%%%"
+# Local variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
+# time-stamp-time-zone: "UTC"
+# End:
 
-# Global variables.
-nonopt=
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-extracted_archives=
-extracted_serial=0
+# Set a version string.
+scriptversion='(GNU libtool) 2.4.6'
 
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
 
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
+# func_echo ARG...
+# ----------------
+# Libtool also displays the current mode in messages, so override
+# funclib.sh func_echo with this custom definition.
+func_echo ()
 {
-    eval "${1}=\$${1}\${2}"
-} # func_append may be replaced by extended shell implementation
+    $debug_cmd
 
-# func_append_quoted var value
-# Quote VALUE and append to the end of shell variable VAR, separated
-# by a space.
-func_append_quoted ()
-{
-    func_quote_for_eval "${2}"
-    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
-} # func_append_quoted may be replaced by extended shell implementation
+    _G_message=$*
 
+    func_echo_IFS=$IFS
+    IFS=$nl
+    for _G_line in $_G_message; do
+      IFS=$func_echo_IFS
+      $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
+    done
+    IFS=$func_echo_IFS
+}
 
-# func_arith arithmetic-term...
-func_arith ()
+
+# func_warning ARG...
+# -------------------
+# Libtool warnings are not categorized, so override funclib.sh
+# func_warning with this simpler definition.
+func_warning ()
 {
-    func_arith_result=`expr "${@}"`
-} # func_arith may be replaced by extended shell implementation
+    $debug_cmd
 
+    $warning_func ${1+"$@"}
+}
 
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
-{
-    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
-} # func_len may be replaced by extended shell implementation
 
+## ---------------- ##
+## Options parsing. ##
+## ---------------- ##
+
+# Hook in the functions to make sure our own options are parsed during
+# the option parsing loop.
+
+usage='$progpath [OPTION]... [MODE-ARG]...'
+
+# Short help message in response to '-h'.
+usage_message="Options:
+       --config             show all configuration variables
+       --debug              enable verbose shell tracing
+   -n, --dry-run            display commands without modifying any files
+       --features           display basic configuration information and exit
+       --mode=MODE          use operation mode MODE
+       --no-warnings        equivalent to '-Wnone'
+       --preserve-dup-deps  don't remove duplicate dependency libraries
+       --quiet, --silent    don't print informational messages
+       --tag=TAG            use configuration variables from tag TAG
+   -v, --verbose            print more informational messages than default
+       --version            print version information
+   -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
+   -h, --help, --help-all   print short, long, or detailed help message
+"
 
-# func_lo2o object
-func_lo2o ()
+# Additional text appended to 'usage_message' in response to '--help'.
+func_help ()
 {
-    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
-} # func_lo2o may be replaced by extended shell implementation
+    $debug_cmd
+
+    func_usage_message
+    $ECHO "$long_help_message
+
+MODE must be one of the following:
+
+       clean           remove files from the build directory
+       compile         compile a source file into a libtool object
+       execute         automatically set library path, then run a program
+       finish          complete the installation of libtool libraries
+       install         install libraries or executables
+       link            create a library or an executable
+       uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  When passed as first option,
+'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
+Try '$progname --help --mode=MODE' for a more detailed description of MODE.
+
+When reporting a bug, please describe a test case to reproduce it and
+include the following information:
+
+       host-triplet:   $host
+       shell:          $SHELL
+       compiler:       $LTCC
+       compiler flags: $LTCFLAGS
+       linker:         $LD (gnu? $with_gnu_ld)
+       version:        $progname (GNU libtool) 2.4.6
+       automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
+       autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
+
+Report bugs to <bug-libtool at gnu.org>.
+GNU libtool home page: <http://www.gnu.org/s/libtool/>.
+General help using GNU software: <http://www.gnu.org/gethelp/>."
+    exit 0
+}
 
 
-# func_xform libobj-or-source
-func_xform ()
-{
-    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
-} # func_xform may be replaced by extended shell implementation
+# func_lo2o OBJECT-NAME
+# ---------------------
+# Transform OBJECT-NAME from a '.lo' suffix to the platform specific
+# object suffix.
+
+lo2o=s/\\.lo\$/.$objext/
+o2lo=s/\\.$objext\$/.lo/
+
+if test yes = "$_G_HAVE_XSI_OPS"; then
+  eval 'func_lo2o ()
+  {
+    case $1 in
+      *.lo) func_lo2o_result=${1%.lo}.$objext ;;
+      *   ) func_lo2o_result=$1               ;;
+    esac
+  }'
+
+  # func_xform LIBOBJ-OR-SOURCE
+  # ---------------------------
+  # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
+  # suffix to a '.lo' libtool-object suffix.
+  eval 'func_xform ()
+  {
+    func_xform_result=${1%.*}.lo
+  }'
+else
+  # ...otherwise fall back to using sed.
+  func_lo2o ()
+  {
+    func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
+  }
+
+  func_xform ()
+  {
+    func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
+  }
+fi
 
 
-# func_fatal_configuration arg...
+# func_fatal_configuration ARG...
+# -------------------------------
 # Echo program name prefixed message to standard error, followed by
 # a configuration failure hint, and exit.
 func_fatal_configuration ()
 {
-    func_error ${1+"$@"}
-    func_error "See the $PACKAGE documentation for more information."
-    func_fatal_error "Fatal configuration error."
+    func__fatal_error ${1+"$@"} \
+      "See the $PACKAGE documentation for more information." \
+      "Fatal configuration error."
 }
 
 
 # func_config
+# -----------
 # Display the configuration for all the tags in this script.
 func_config ()
 {
@@ -915,17 +2149,19 @@ func_config ()
     exit $?
 }
 
+
 # func_features
+# -------------
 # Display the features supported by this script.
 func_features ()
 {
     echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       echo "enable shared libraries"
     else
       echo "disable shared libraries"
     fi
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       echo "enable static libraries"
     else
       echo "disable static libraries"
@@ -934,314 +2170,350 @@ func_features ()
     exit $?
 }
 
-# func_enable_tag tagname
+
+# func_enable_tag TAGNAME
+# -----------------------
 # Verify that TAGNAME is valid, and either flag an error and exit, or
 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
 # variable here.
 func_enable_tag ()
 {
-  # Global variable:
-  tagname="$1"
+    # Global variable:
+    tagname=$1
 
-  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
-  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
-  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+    re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+    re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+    sed_extractcf=/$re_begincf/,/$re_endcf/p
 
-  # Validate tagname.
-  case $tagname in
-    *[!-_A-Za-z0-9,/]*)
-      func_fatal_error "invalid tag name: $tagname"
-      ;;
-  esac
+    # Validate tagname.
+    case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+        func_fatal_error "invalid tag name: $tagname"
+        ;;
+    esac
 
-  # Don't test for the "default" C tag, as we know it's
-  # there but not specially marked.
-  case $tagname in
-    CC) ;;
+    # Don't test for the "default" C tag, as we know it's
+    # there but not specially marked.
+    case $tagname in
+        CC) ;;
     *)
-      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
-	taglist="$taglist $tagname"
-
-	# Evaluate the configuration.  Be careful to quote the path
-	# and the sed script, to avoid splitting on whitespace, but
-	# also don't use non-portable quotes within backquotes within
-	# quotes we have to do it in 2 steps:
-	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
-	eval "$extractedcf"
-      else
-	func_error "ignoring unknown tag $tagname"
-      fi
-      ;;
-  esac
+        if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	  taglist="$taglist $tagname"
+
+	  # Evaluate the configuration.  Be careful to quote the path
+	  # and the sed script, to avoid splitting on whitespace, but
+	  # also don't use non-portable quotes within backquotes within
+	  # quotes we have to do it in 2 steps:
+	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	  eval "$extractedcf"
+        else
+	  func_error "ignoring unknown tag $tagname"
+        fi
+        ;;
+    esac
 }
 
+
 # func_check_version_match
+# ------------------------
 # Ensure that we are using m4 macros, and libtool script from the same
 # release of libtool.
 func_check_version_match ()
 {
-  if test "$package_revision" != "$macro_revision"; then
-    if test "$VERSION" != "$macro_version"; then
-      if test -z "$macro_version"; then
-        cat >&2 <<_LT_EOF
+    if test "$package_revision" != "$macro_revision"; then
+      if test "$VERSION" != "$macro_version"; then
+        if test -z "$macro_version"; then
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from an older release.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      else
-        cat >&2 <<_LT_EOF
+        else
+          cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
 $progname: and run autoconf again.
 _LT_EOF
-      fi
-    else
-      cat >&2 <<_LT_EOF
+        fi
+      else
+        cat >&2 <<_LT_EOF
 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
 $progname: of $PACKAGE $VERSION and run autoconf again.
 _LT_EOF
-    fi
+      fi
 
-    exit $EXIT_MISMATCH
-  fi
+      exit $EXIT_MISMATCH
+    fi
 }
 
 
-# Shorthand for --mode=foo, only valid as the first argument
-case $1 in
-clean|clea|cle|cl)
-  shift; set dummy --mode clean ${1+"$@"}; shift
-  ;;
-compile|compil|compi|comp|com|co|c)
-  shift; set dummy --mode compile ${1+"$@"}; shift
-  ;;
-execute|execut|execu|exec|exe|ex|e)
-  shift; set dummy --mode execute ${1+"$@"}; shift
-  ;;
-finish|finis|fini|fin|fi|f)
-  shift; set dummy --mode finish ${1+"$@"}; shift
-  ;;
-install|instal|insta|inst|ins|in|i)
-  shift; set dummy --mode install ${1+"$@"}; shift
-  ;;
-link|lin|li|l)
-  shift; set dummy --mode link ${1+"$@"}; shift
-  ;;
-uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
-  shift; set dummy --mode uninstall ${1+"$@"}; shift
-  ;;
-esac
+# libtool_options_prep [ARG]...
+# -----------------------------
+# Preparation for options parsed by libtool.
+libtool_options_prep ()
+{
+    $debug_mode
 
+    # Option defaults:
+    opt_config=false
+    opt_dlopen=
+    opt_dry_run=false
+    opt_help=false
+    opt_mode=
+    opt_preserve_dup_deps=false
+    opt_quiet=false
 
+    nonopt=
+    preserve_args=
 
-# Option defaults:
-opt_debug=:
-opt_dry_run=false
-opt_config=false
-opt_preserve_dup_deps=false
-opt_features=false
-opt_finish=false
-opt_help=false
-opt_help_all=false
-opt_silent=:
-opt_warning=:
-opt_verbose=:
-opt_silent=false
-opt_verbose=false
+    # Shorthand for --mode=foo, only valid as the first argument
+    case $1 in
+    clean|clea|cle|cl)
+      shift; set dummy --mode clean ${1+"$@"}; shift
+      ;;
+    compile|compil|compi|comp|com|co|c)
+      shift; set dummy --mode compile ${1+"$@"}; shift
+      ;;
+    execute|execut|execu|exec|exe|ex|e)
+      shift; set dummy --mode execute ${1+"$@"}; shift
+      ;;
+    finish|finis|fini|fin|fi|f)
+      shift; set dummy --mode finish ${1+"$@"}; shift
+      ;;
+    install|instal|insta|inst|ins|in|i)
+      shift; set dummy --mode install ${1+"$@"}; shift
+      ;;
+    link|lin|li|l)
+      shift; set dummy --mode link ${1+"$@"}; shift
+      ;;
+    uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+      shift; set dummy --mode uninstall ${1+"$@"}; shift
+      ;;
+    esac
+
+    # Pass back the list of options.
+    func_quote_for_eval ${1+"$@"}
+    libtool_options_prep_result=$func_quote_for_eval_result
+}
+func_add_hook func_options_prep libtool_options_prep
 
 
-# Parse options once, thoroughly.  This comes as soon as possible in the
-# script to make things like `--version' happen as quickly as we can.
+# libtool_parse_options [ARG]...
+# ---------------------------------
+# Provide handling for libtool specific options.
+libtool_parse_options ()
 {
-  # this just eases exit handling
-  while test $# -gt 0; do
-    opt="$1"
-    shift
-    case $opt in
-      --debug|-x)	opt_debug='set -x'
-			func_echo "enabling shell trace mode"
-			$opt_debug
-			;;
-      --dry-run|--dryrun|-n)
-			opt_dry_run=:
-			;;
-      --config)
-			opt_config=:
-func_config
-			;;
-      --dlopen|-dlopen)
-			optarg="$1"
-			opt_dlopen="${opt_dlopen+$opt_dlopen
-}$optarg"
-			shift
-			;;
-      --preserve-dup-deps)
-			opt_preserve_dup_deps=:
-			;;
-      --features)
-			opt_features=:
-func_features
-			;;
-      --finish)
-			opt_finish=:
-set dummy --mode finish ${1+"$@"}; shift
-			;;
-      --help)
-			opt_help=:
-			;;
-      --help-all)
-			opt_help_all=:
-opt_help=': help-all'
-			;;
-      --mode)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_mode="$optarg"
-case $optarg in
-  # Valid mode arguments:
-  clean|compile|execute|finish|install|link|relink|uninstall) ;;
-
-  # Catch anything else as an error
-  *) func_error "invalid argument for $opt"
-     exit_cmd=exit
-     break
-     ;;
-esac
-			shift
-			;;
-      --no-silent|--no-quiet)
-			opt_silent=false
-func_append preserve_args " $opt"
-			;;
-      --no-warning|--no-warn)
-			opt_warning=false
-func_append preserve_args " $opt"
-			;;
-      --no-verbose)
-			opt_verbose=false
-func_append preserve_args " $opt"
-			;;
-      --silent|--quiet)
-			opt_silent=:
-func_append preserve_args " $opt"
-        opt_verbose=false
-			;;
-      --verbose|-v)
-			opt_verbose=:
-func_append preserve_args " $opt"
-opt_silent=false
-			;;
-      --tag)
-			test $# = 0 && func_missing_arg $opt && break
-			optarg="$1"
-			opt_tag="$optarg"
-func_append preserve_args " $opt $optarg"
-func_enable_tag "$optarg"
-			shift
-			;;
-
-      -\?|-h)		func_usage				;;
-      --help)		func_help				;;
-      --version)	func_version				;;
-
-      # Separate optargs to long options:
-      --*=*)
-			func_split_long_opt "$opt"
-			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      # Separate non-argument short options:
-      -\?*|-h*|-n*|-v*)
-			func_split_short_opt "$opt"
-			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
-			shift
-			;;
-
-      --)		break					;;
-      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
-      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
-    esac
-  done
+    $debug_cmd
 
-  # Validate options:
+    # Perform our own loop to consume as many options as possible in
+    # each iteration.
+    while test $# -gt 0; do
+      _G_opt=$1
+      shift
+      case $_G_opt in
+        --dry-run|--dryrun|-n)
+                        opt_dry_run=:
+                        ;;
+
+        --config)       func_config ;;
+
+        --dlopen|-dlopen)
+                        opt_dlopen="${opt_dlopen+$opt_dlopen
+}$1"
+                        shift
+                        ;;
+
+        --preserve-dup-deps)
+                        opt_preserve_dup_deps=: ;;
+
+        --features)     func_features ;;
+
+        --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
+
+        --help)         opt_help=: ;;
+
+        --help-all)     opt_help=': help-all' ;;
+
+        --mode)         test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_mode=$1
+                        case $1 in
+                          # Valid mode arguments:
+                          clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+                          # Catch anything else as an error
+                          *) func_error "invalid argument for $_G_opt"
+                             exit_cmd=exit
+                             break
+                             ;;
+                        esac
+                        shift
+                        ;;
+
+        --no-silent|--no-quiet)
+                        opt_quiet=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-warnings|--no-warning|--no-warn)
+                        opt_warning=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --no-verbose)
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --silent|--quiet)
+                        opt_quiet=:
+                        opt_verbose=false
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+        --tag)          test $# = 0 && func_missing_arg $_G_opt && break
+                        opt_tag=$1
+                        func_append preserve_args " $_G_opt $1"
+                        func_enable_tag "$1"
+                        shift
+                        ;;
+
+        --verbose|-v)   opt_quiet=false
+                        opt_verbose=:
+                        func_append preserve_args " $_G_opt"
+                        ;;
+
+	# An option not handled by this hook function:
+        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
+      esac
+    done
 
-  # save first non-option argument
-  if test "$#" -gt 0; then
-    nonopt="$opt"
-    shift
-  fi
 
-  # preserve --debug
-  test "$opt_debug" = : || func_append preserve_args " --debug"
+    # save modified positional parameters for caller
+    func_quote_for_eval ${1+"$@"}
+    libtool_parse_options_result=$func_quote_for_eval_result
+}
+func_add_hook func_parse_options libtool_parse_options
 
-  case $host in
-    *cygwin* | *mingw* | *pw32* | *cegcc*)
-      # don't eliminate duplications in $postdeps and $predeps
-      opt_duplicate_compiler_generated_deps=:
-      ;;
-    *)
-      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
-      ;;
-  esac
 
-  $opt_help || {
-    # Sanity checks first:
-    func_check_version_match
 
-    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-      func_fatal_configuration "not configured to build any kind of library"
+# libtool_validate_options [ARG]...
+# ---------------------------------
+# Perform any sanity checks on option settings and/or unconsumed
+# arguments.
+libtool_validate_options ()
+{
+    # save first non-option argument
+    if test 0 -lt $#; then
+      nonopt=$1
+      shift
     fi
 
-    # Darwin sucks
-    eval std_shrext=\"$shrext_cmds\"
+    # preserve --debug
+    test : = "$debug_cmd" || func_append preserve_args " --debug"
 
-    # Only execute mode is allowed to have -dlopen flags.
-    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
-      func_error "unrecognized option \`-dlopen'"
-      $ECHO "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
+    case $host in
+      # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
+      # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
+      *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
+        # don't eliminate duplications in $postdeps and $predeps
+        opt_duplicate_compiler_generated_deps=:
+        ;;
+      *)
+        opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+        ;;
+    esac
 
-    # Change the help message to a mode-specific one.
-    generic_help="$help"
-    help="Try \`$progname --help --mode=$opt_mode' for more information."
-  }
+    $opt_help || {
+      # Sanity checks first:
+      func_check_version_match
+
+      test yes != "$build_libtool_libs" \
+        && test yes != "$build_old_libs" \
+        && func_fatal_configuration "not configured to build any kind of library"
+
+      # Darwin sucks
+      eval std_shrext=\"$shrext_cmds\"
+
+      # Only execute mode is allowed to have -dlopen flags.
+      if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
+        func_error "unrecognized option '-dlopen'"
+        $ECHO "$help" 1>&2
+        exit $EXIT_FAILURE
+      fi
 
+      # Change the help message to a mode-specific one.
+      generic_help=$help
+      help="Try '$progname --help --mode=$opt_mode' for more information."
+    }
 
-  # Bail if the options were screwed
-  $exit_cmd $EXIT_FAILURE
+    # Pass back the unparsed argument list
+    func_quote_for_eval ${1+"$@"}
+    libtool_validate_options_result=$func_quote_for_eval_result
 }
+func_add_hook func_validate_options libtool_validate_options
 
 
+# Process options as early as possible so that --help and --version
+# can return quickly.
+func_options ${1+"$@"}
+eval set dummy "$func_options_result"; shift
+
 
 
 ## ----------- ##
 ##    Main.    ##
 ## ----------- ##
 
+magic='%%%MAGIC variable%%%'
+magic_exe='%%%MAGIC EXE variable%%%'
+
+# Global variables.
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# func_generated_by_libtool
+# True iff stdin has been generated by Libtool. This function is only
+# a basic sanity check; it will hardly flush out determined imposters.
+func_generated_by_libtool_p ()
+{
+  $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
 # func_lalib_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function is only a basic sanity check; it will hardly flush out
 # determined imposters.
 func_lalib_p ()
 {
     test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
-        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+      $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_lalib_unsafe_p file
-# True iff FILE is a libtool `.la' library or `.lo' object file.
+# True iff FILE is a libtool '.la' library or '.lo' object file.
 # This function implements the same check as func_lalib_p without
 # resorting to external programs.  To this end, it redirects stdin and
 # closes it afterwards, without saving the original file descriptor.
 # As a safety measure, use it only where a negative result would be
-# fatal anyway.  Works if `file' does not exist.
+# fatal anyway.  Works if 'file' does not exist.
 func_lalib_unsafe_p ()
 {
     lalib_p=no
@@ -1249,13 +2521,13 @@ func_lalib_unsafe_p ()
 	for lalib_p_l in 1 2 3 4
 	do
 	    read lalib_p_line
-	    case "$lalib_p_line" in
+	    case $lalib_p_line in
 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
 	    esac
 	done
 	exec 0<&5 5<&-
     fi
-    test "$lalib_p" = yes
+    test yes = "$lalib_p"
 }
 
 # func_ltwrapper_script_p file
@@ -1264,7 +2536,8 @@ func_lalib_unsafe_p ()
 # determined imposters.
 func_ltwrapper_script_p ()
 {
-    func_lalib_p "$1"
+    test -f "$1" &&
+      $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
 }
 
 # func_ltwrapper_executable_p file
@@ -1289,7 +2562,7 @@ func_ltwrapper_scriptname ()
 {
     func_dirname_and_basename "$1" "" "."
     func_stripname '' '.exe' "$func_basename_result"
-    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
 }
 
 # func_ltwrapper_p file
@@ -1308,11 +2581,13 @@ func_ltwrapper_p ()
 # FAIL_CMD may read-access the current command in variable CMD!
 func_execute_cmds ()
 {
-    $opt_debug
+    $debug_cmd
+
     save_ifs=$IFS; IFS='~'
     for cmd in $1; do
-      IFS=$save_ifs
+      IFS=$sp$nl
       eval cmd=\"$cmd\"
+      IFS=$save_ifs
       func_show_eval "$cmd" "${2-:}"
     done
     IFS=$save_ifs
@@ -1324,10 +2599,11 @@ func_execute_cmds ()
 # Note that it is not necessary on cygwin/mingw to append a dot to
 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-# `FILE.' does not work on cygwin managed mounts.
+# 'FILE.' does not work on cygwin managed mounts.
 func_source ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $1 in
     */* | *\\*)	. "$1" ;;
     *)		. "./$1" ;;
@@ -1354,10 +2630,10 @@ func_resolve_sysroot ()
 # store the result into func_replace_sysroot_result.
 func_replace_sysroot ()
 {
-  case "$lt_sysroot:$1" in
+  case $lt_sysroot:$1 in
   ?*:"$lt_sysroot"*)
     func_stripname "$lt_sysroot" '' "$1"
-    func_replace_sysroot_result="=$func_stripname_result"
+    func_replace_sysroot_result='='$func_stripname_result
     ;;
   *)
     # Including no sysroot.
@@ -1374,7 +2650,8 @@ func_replace_sysroot ()
 # arg is usually of the form 'gcc ...'
 func_infer_tag ()
 {
-    $opt_debug
+    $debug_cmd
+
     if test -n "$available_tags" && test -z "$tagname"; then
       CC_quoted=
       for arg in $CC; do
@@ -1393,7 +2670,7 @@ func_infer_tag ()
 	for z in $available_tags; do
 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
 	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
 	    CC_quoted=
 	    for arg in $CC; do
 	      # Double-quote args containing other shell metacharacters.
@@ -1418,7 +2695,7 @@ func_infer_tag ()
 	# line option must be used.
 	if test -z "$tagname"; then
 	  func_echo "unable to infer tagged configuration"
-	  func_fatal_error "specify a tag with \`--tag'"
+	  func_fatal_error "specify a tag with '--tag'"
 #	else
 #	  func_verbose "using $tagname tagged configuration"
 	fi
@@ -1434,15 +2711,15 @@ func_infer_tag ()
 # but don't create it if we're doing a dry run.
 func_write_libtool_object ()
 {
-    write_libobj=${1}
-    if test "$build_libtool_libs" = yes; then
-      write_lobj=\'${2}\'
+    write_libobj=$1
+    if test yes = "$build_libtool_libs"; then
+      write_lobj=\'$2\'
     else
       write_lobj=none
     fi
 
-    if test "$build_old_libs" = yes; then
-      write_oldobj=\'${3}\'
+    if test yes = "$build_old_libs"; then
+      write_oldobj=\'$3\'
     else
       write_oldobj=none
     fi
@@ -1450,7 +2727,7 @@ func_write_libtool_object ()
     $opt_dry_run || {
       cat >${write_libobj}T <<EOF
 # $write_libobj - a libtool object file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -1462,7 +2739,7 @@ pic_object=$write_lobj
 non_pic_object=$write_oldobj
 
 EOF
-      $MV "${write_libobj}T" "${write_libobj}"
+      $MV "${write_libobj}T" "$write_libobj"
     }
 }
 
@@ -1482,8 +2759,9 @@ EOF
 # be empty on error (or when ARG is empty)
 func_convert_core_file_wine_to_w32 ()
 {
-  $opt_debug
-  func_convert_core_file_wine_to_w32_result="$1"
+  $debug_cmd
+
+  func_convert_core_file_wine_to_w32_result=$1
   if test -n "$1"; then
     # Unfortunately, winepath does not exit with a non-zero error code, so we
     # are forced to check the contents of stdout. On the other hand, if the
@@ -1491,9 +2769,9 @@ func_convert_core_file_wine_to_w32 ()
     # *an error message* to stdout. So we must check for both error code of
     # zero AND non-empty stdout, which explains the odd construction:
     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
-    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+    if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
-        $SED -e "$lt_sed_naive_backslashify"`
+        $SED -e "$sed_naive_backslashify"`
     else
       func_convert_core_file_wine_to_w32_result=
     fi
@@ -1514,18 +2792,19 @@ func_convert_core_file_wine_to_w32 ()
 # are convertible, then the result may be empty.
 func_convert_core_path_wine_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # unfortunately, winepath doesn't convert paths, only file names
-  func_convert_core_path_wine_to_w32_result=""
+  func_convert_core_path_wine_to_w32_result=
   if test -n "$1"; then
     oldIFS=$IFS
     IFS=:
     for func_convert_core_path_wine_to_w32_f in $1; do
       IFS=$oldIFS
       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
-      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+      if test -n "$func_convert_core_file_wine_to_w32_result"; then
         if test -z "$func_convert_core_path_wine_to_w32_result"; then
-          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+          func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
         else
           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
         fi
@@ -1554,7 +2833,8 @@ func_convert_core_path_wine_to_w32 ()
 # environment variable; do not put it in $PATH.
 func_cygpath ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
     if test "$?" -ne 0; then
@@ -1563,7 +2843,7 @@ func_cygpath ()
     fi
   else
     func_cygpath_result=
-    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+    func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
   fi
 }
 #end: func_cygpath
@@ -1574,10 +2854,11 @@ func_cygpath ()
 # result in func_convert_core_msys_to_w32_result.
 func_convert_core_msys_to_w32 ()
 {
-  $opt_debug
+  $debug_cmd
+
   # awkward: cmd appends spaces to result
   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
-    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
 }
 #end: func_convert_core_msys_to_w32
 
@@ -1588,13 +2869,14 @@ func_convert_core_msys_to_w32 ()
 # func_to_host_file_result to ARG1).
 func_convert_file_check ()
 {
-  $opt_debug
-  if test -z "$2" && test -n "$1" ; then
+  $debug_cmd
+
+  if test -z "$2" && test -n "$1"; then
     func_error "Could not determine host file name corresponding to"
-    func_error "  \`$1'"
+    func_error "  '$1'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback:
-    func_to_host_file_result="$1"
+    func_to_host_file_result=$1
   fi
 }
 # end func_convert_file_check
@@ -1606,10 +2888,11 @@ func_convert_file_check ()
 # func_to_host_file_result to a simplistic fallback value (see below).
 func_convert_path_check ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$4" && test -n "$3"; then
     func_error "Could not determine the host path corresponding to"
-    func_error "  \`$3'"
+    func_error "  '$3'"
     func_error "Continuing, but uninstalled executables may not work."
     # Fallback.  This is a deliberately simplistic "conversion" and
     # should not be "improved".  See libtool.info.
@@ -1618,7 +2901,7 @@ func_convert_path_check ()
       func_to_host_path_result=`echo "$3" |
         $SED -e "$lt_replace_pathsep_chars"`
     else
-      func_to_host_path_result="$3"
+      func_to_host_path_result=$3
     fi
   fi
 }
@@ -1630,9 +2913,10 @@ func_convert_path_check ()
 # and appending REPL if ORIG matches BACKPAT.
 func_convert_path_front_back_pathsep ()
 {
-  $opt_debug
+  $debug_cmd
+
   case $4 in
-  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+  $1 ) func_to_host_path_result=$3$func_to_host_path_result
     ;;
   esac
   case $4 in
@@ -1646,7 +2930,7 @@ func_convert_path_front_back_pathsep ()
 ##################################################
 # $build to $host FILE NAME CONVERSION FUNCTIONS #
 ##################################################
-# invoked via `$to_host_file_cmd ARG'
+# invoked via '$to_host_file_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # Result will be available in $func_to_host_file_result.
@@ -1657,7 +2941,8 @@ func_convert_path_front_back_pathsep ()
 # in func_to_host_file_result.
 func_to_host_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   $to_host_file_cmd "$1"
 }
 # end func_to_host_file
@@ -1669,7 +2954,8 @@ func_to_host_file ()
 # in (the comma separated) LAZY, no conversion takes place.
 func_to_tool_file ()
 {
-  $opt_debug
+  $debug_cmd
+
   case ,$2, in
     *,"$to_tool_file_cmd",*)
       func_to_tool_file_result=$1
@@ -1687,7 +2973,7 @@ func_to_tool_file ()
 # Copy ARG to func_to_host_file_result.
 func_convert_file_noop ()
 {
-  func_to_host_file_result="$1"
+  func_to_host_file_result=$1
 }
 # end func_convert_file_noop
 
@@ -1698,11 +2984,12 @@ func_convert_file_noop ()
 # func_to_host_file_result.
 func_convert_file_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_file_result=$func_convert_core_msys_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1714,8 +3001,9 @@ func_convert_file_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_file_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
     # LT_CYGPATH in this case.
@@ -1731,11 +3019,12 @@ func_convert_file_cygwin_to_w32 ()
 # and a working winepath. Returns result in func_to_host_file_result.
 func_convert_file_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_file_wine_to_w32 "$1"
-    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+    func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1747,12 +3036,13 @@ func_convert_file_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_file_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     func_convert_core_msys_to_w32 "$1"
     func_cygpath -u "$func_convert_core_msys_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1765,13 +3055,14 @@ func_convert_file_msys_to_cygwin ()
 # in func_to_host_file_result.
 func_convert_file_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_file_result="$1"
+  $debug_cmd
+
+  func_to_host_file_result=$1
   if test -n "$1"; then
     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
     func_convert_core_file_wine_to_w32 "$1"
     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
-    func_to_host_file_result="$func_cygpath_result"
+    func_to_host_file_result=$func_cygpath_result
   fi
   func_convert_file_check "$1" "$func_to_host_file_result"
 }
@@ -1781,7 +3072,7 @@ func_convert_file_nix_to_cygwin ()
 #############################################
 # $build to $host PATH CONVERSION FUNCTIONS #
 #############################################
-# invoked via `$to_host_path_cmd ARG'
+# invoked via '$to_host_path_cmd ARG'
 #
 # In each case, ARG is the path to be converted from $build to $host format.
 # The result will be available in $func_to_host_path_result.
@@ -1805,10 +3096,11 @@ func_convert_file_nix_to_cygwin ()
 to_host_path_cmd=
 func_init_to_host_path_cmd ()
 {
-  $opt_debug
+  $debug_cmd
+
   if test -z "$to_host_path_cmd"; then
     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
-    to_host_path_cmd="func_convert_path_${func_stripname_result}"
+    to_host_path_cmd=func_convert_path_$func_stripname_result
   fi
 }
 
@@ -1818,7 +3110,8 @@ func_init_to_host_path_cmd ()
 # in func_to_host_path_result.
 func_to_host_path ()
 {
-  $opt_debug
+  $debug_cmd
+
   func_init_to_host_path_cmd
   $to_host_path_cmd "$1"
 }
@@ -1829,7 +3122,7 @@ func_to_host_path ()
 # Copy ARG to func_to_host_path_result.
 func_convert_path_noop ()
 {
-  func_to_host_path_result="$1"
+  func_to_host_path_result=$1
 }
 # end func_convert_path_noop
 
@@ -1840,8 +3133,9 @@ func_convert_path_noop ()
 # func_to_host_path_result.
 func_convert_path_msys_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from ARG.  MSYS
     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
@@ -1849,7 +3143,7 @@ func_convert_path_msys_to_w32 ()
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+    func_to_host_path_result=$func_convert_core_msys_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1863,8 +3157,9 @@ func_convert_path_msys_to_w32 ()
 # func_to_host_file_result.
 func_convert_path_cygwin_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
@@ -1883,14 +3178,15 @@ func_convert_path_cygwin_to_w32 ()
 # a working winepath.  Returns result in func_to_host_file_result.
 func_convert_path_nix_to_w32 ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
-    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+    func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
     func_convert_path_check : ";" \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
@@ -1904,15 +3200,16 @@ func_convert_path_nix_to_w32 ()
 # Returns result in func_to_host_file_result.
 func_convert_path_msys_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1927,8 +3224,9 @@ func_convert_path_msys_to_cygwin ()
 # func_to_host_file_result.
 func_convert_path_nix_to_cygwin ()
 {
-  $opt_debug
-  func_to_host_path_result="$1"
+  $debug_cmd
+
+  func_to_host_path_result=$1
   if test -n "$1"; then
     # Remove leading and trailing path separator characters from
     # ARG. msys behavior is inconsistent here, cygpath turns them
@@ -1937,7 +3235,7 @@ func_convert_path_nix_to_cygwin ()
     func_to_host_path_tmp1=$func_stripname_result
     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
-    func_to_host_path_result="$func_cygpath_result"
+    func_to_host_path_result=$func_cygpath_result
     func_convert_path_check : : \
       "$func_to_host_path_tmp1" "$func_to_host_path_result"
     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
@@ -1946,13 +3244,31 @@ func_convert_path_nix_to_cygwin ()
 # end func_convert_path_nix_to_cygwin
 
 
+# func_dll_def_p FILE
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with _LT_DLL_DEF_P in libtool.m4
+func_dll_def_p ()
+{
+  $debug_cmd
+
+  func_dll_def_p_tmp=`$SED -n \
+    -e 's/^[	 ]*//' \
+    -e '/^\(;.*\)*$/d' \
+    -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
+    -e q \
+    "$1"`
+  test DEF = "$func_dll_def_p_tmp"
+}
+
+
 # func_mode_compile arg...
 func_mode_compile ()
 {
-    $opt_debug
+    $debug_cmd
+
     # Get the compilation command and the source file.
     base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
     suppress_opt=yes
     suppress_output=
     arg_mode=normal
@@ -1965,12 +3281,12 @@ func_mode_compile ()
       case $arg_mode in
       arg  )
 	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
+	lastarg=$arg
 	arg_mode=normal
 	;;
 
       target )
-	libobj="$arg"
+	libobj=$arg
 	arg_mode=normal
 	continue
 	;;
@@ -1980,7 +3296,7 @@ func_mode_compile ()
 	case $arg in
 	-o)
 	  test -n "$libobj" && \
-	    func_fatal_error "you cannot specify \`-o' more than once"
+	    func_fatal_error "you cannot specify '-o' more than once"
 	  arg_mode=target
 	  continue
 	  ;;
@@ -2009,12 +3325,12 @@ func_mode_compile ()
 	  func_stripname '-Wc,' '' "$arg"
 	  args=$func_stripname_result
 	  lastarg=
-	  save_ifs="$IFS"; IFS=','
+	  save_ifs=$IFS; IFS=,
 	  for arg in $args; do
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 	    func_append_quoted lastarg "$arg"
 	  done
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
 	  func_stripname ' ' '' "$lastarg"
 	  lastarg=$func_stripname_result
 
@@ -2027,8 +3343,8 @@ func_mode_compile ()
 	  # Accept the current argument as the source file.
 	  # The previous "srcfile" becomes the current argument.
 	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
+	  lastarg=$srcfile
+	  srcfile=$arg
 	  ;;
 	esac  #  case $arg
 	;;
@@ -2043,13 +3359,13 @@ func_mode_compile ()
       func_fatal_error "you must specify an argument for -Xcompile"
       ;;
     target)
-      func_fatal_error "you must specify a target with \`-o'"
+      func_fatal_error "you must specify a target with '-o'"
       ;;
     *)
       # Get the name of the library object.
       test -z "$libobj" && {
 	func_basename "$srcfile"
-	libobj="$func_basename_result"
+	libobj=$func_basename_result
       }
       ;;
     esac
@@ -2069,7 +3385,7 @@ func_mode_compile ()
     case $libobj in
     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
     *)
-      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      func_fatal_error "cannot determine name of library object from '$libobj'"
       ;;
     esac
 
@@ -2078,8 +3394,8 @@ func_mode_compile ()
     for arg in $later; do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes = "$build_libtool_libs" \
+	  || func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	continue
 	;;
@@ -2105,17 +3421,17 @@ func_mode_compile ()
     func_quote_for_eval "$libobj"
     test "X$libobj" != "X$func_quote_for_eval_result" \
       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
-      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+      && func_warning "libobj name '$libobj' may not contain shell special characters."
     func_dirname_and_basename "$obj" "/" ""
-    objname="$func_basename_result"
-    xdir="$func_dirname_result"
-    lobj=${xdir}$objdir/$objname
+    objname=$func_basename_result
+    xdir=$func_dirname_result
+    lobj=$xdir$objdir/$objname
 
     test -z "$base_compile" && \
       func_fatal_help "you must specify a compilation command"
 
     # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
+    if test yes = "$build_old_libs"; then
       removelist="$obj $lobj $libobj ${libobj}T"
     else
       removelist="$lobj $libobj ${libobj}T"
@@ -2127,16 +3443,16 @@ func_mode_compile ()
       pic_mode=default
       ;;
     esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+    if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
       # non-PIC code in shared libraries is not supported
       pic_mode=default
     fi
 
     # Calculate the filename of the output object if compiler does
     # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
+    if test no = "$compiler_c_o"; then
+      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
+      lockfile=$output_obj.lock
     else
       output_obj=
       need_locks=no
@@ -2145,12 +3461,12 @@ func_mode_compile ()
 
     # Lock this critical section if it is needed
     # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
+    if test yes = "$need_locks"; then
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
 	sleep 2
       done
-    elif test "$need_locks" = warn; then
+    elif test warn = "$need_locks"; then
       if test -f "$lockfile"; then
 	$ECHO "\
 *** ERROR, $lockfile exists and contains:
@@ -2158,7 +3474,7 @@ func_mode_compile ()
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2180,11 +3496,11 @@ compiler."
     qsrcfile=$func_quote_for_eval_result
 
     # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
+    if test yes = "$build_libtool_libs"; then
       # Without this assignment, base_compile gets emptied.
       fbsd_hideous_sh_bug=$base_compile
 
-      if test "$pic_mode" != no; then
+      if test no != "$pic_mode"; then
 	command="$base_compile $qsrcfile $pic_flag"
       else
 	# Don't build PIC code
@@ -2201,7 +3517,7 @@ compiler."
       func_show_eval_locale "$command"	\
           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2212,7 +3528,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2228,20 +3544,20 @@ compiler."
       fi
 
       # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
+      if test yes = "$suppress_opt"; then
 	suppress_output=' >/dev/null 2>&1'
       fi
     fi
 
     # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
+    if test yes = "$build_old_libs"; then
+      if test yes != "$pic_mode"; then
 	# Don't build PIC code
 	command="$base_compile $qsrcfile$pie_flag"
       else
 	command="$base_compile $qsrcfile $pic_flag"
       fi
-      if test "$compiler_c_o" = yes; then
+      if test yes = "$compiler_c_o"; then
 	func_append command " -o $obj"
       fi
 
@@ -2250,7 +3566,7 @@ compiler."
       func_show_eval_locale "$command" \
         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 
-      if test "$need_locks" = warn &&
+      if test warn = "$need_locks" &&
 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
 	$ECHO "\
 *** ERROR, $lockfile contains:
@@ -2261,7 +3577,7 @@ $srcfile
 
 This indicates that another process is trying to use the same
 temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
+your compiler does not support '-c' and '-o' together.  If you
 repeat this compilation, it may succeed, by chance, but you had better
 avoid parallel builds (make -j) in this platform, or get a better
 compiler."
@@ -2281,7 +3597,7 @@ compiler."
       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
 
       # Unlock the critical section if it was locked
-      if test "$need_locks" != no; then
+      if test no != "$need_locks"; then
 	removelist=$lockfile
         $RM "$lockfile"
       fi
@@ -2291,7 +3607,7 @@ compiler."
 }
 
 $opt_help || {
-  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+  test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
 }
 
 func_mode_help ()
@@ -2311,7 +3627,7 @@ func_mode_help ()
 Remove files from the build directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, object or program, all the files associated
@@ -2330,16 +3646,16 @@ This mode accepts the following additional options:
   -no-suppress      do not suppress compiler output for multiple passes
   -prefer-pic       try to build PIC objects only
   -prefer-non-pic   try to build non-PIC objects only
-  -shared           do not build a \`.o' file suitable for static linking
-  -static           only build a \`.o' file suitable for static linking
+  -shared           do not build a '.o' file suitable for static linking
+  -static           only build a '.o' file suitable for static linking
   -Wc,FLAG          pass FLAG directly to the compiler
 
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+COMPILE-COMMAND is a command to be used in creating a 'standard' object file
 from the given SOURCEFILE.
 
 The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
+SOURCEFILE, then substituting the C source code suffix '.c' with the
+library object suffix, '.lo'."
         ;;
 
       execute)
@@ -2352,7 +3668,7 @@ This mode accepts the following additional options:
 
   -dlopen FILE      add the directory containing FILE to the library path
 
-This mode sets the library path environment variable according to \`-dlopen'
+This mode sets the library path environment variable according to '-dlopen'
 flags.
 
 If any of the ARGS are libtool executable wrappers, then they are translated
@@ -2371,7 +3687,7 @@ Complete the installation of libtool libraries.
 Each LIBDIR is a directory that contains libtool libraries.
 
 The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
+the '--dry-run' option if you just want to see what would be executed."
         ;;
 
       install)
@@ -2381,7 +3697,7 @@ the \`--dry-run' option if you just want to see what would be executed."
 Install executables or libraries.
 
 INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
+either the 'install' or 'cp' program.
 
 The following components of INSTALL-COMMAND are treated specially:
 
@@ -2407,7 +3723,7 @@ The following components of LINK-COMMAND are treated specially:
   -avoid-version    do not add a version suffix if possible
   -bindir BINDIR    specify path to binaries directory (for systems where
                     libraries must be found in the PATH setting at runtime)
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
@@ -2421,7 +3737,8 @@ The following components of LINK-COMMAND are treated specially:
   -no-install       link a not-installable executable
   -no-undefined     declare that a library does not refer to external symbols
   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -objectlist FILE  use a list of object files found in FILE to specify objects
+  -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
   -precious-files-regex REGEX
                     don't remove output files matching REGEX
   -release RELEASE  specify package release information
@@ -2441,20 +3758,20 @@ The following components of LINK-COMMAND are treated specially:
   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
 
-All other options (arguments beginning with \`-') are ignored.
+All other options (arguments beginning with '-') are ignored.
 
-Every other argument is treated as a filename.  Files ending in \`.la' are
+Every other argument is treated as a filename.  Files ending in '.la' are
 treated as uninstalled libtool libraries, other files are standard or library
 object files.
 
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
+If the OUTPUT-FILE ends in '.la', then a libtool library is created,
+only library objects ('.lo' files) may be specified, and '-rpath' is
 required, except when creating a convenience library.
 
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
+If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
+using 'ar' and 'ranlib', or on Windows using 'lib'.
 
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
 is created, otherwise an executable program is created."
         ;;
 
@@ -2465,7 +3782,7 @@ is created, otherwise an executable program is created."
 Remove libraries from an installation directory.
 
 RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+(typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
 to RM.
 
 If FILE is a libtool library, all the files associated with it are deleted.
@@ -2473,17 +3790,17 @@ Otherwise, only FILE itself is deleted using RM."
         ;;
 
       *)
-        func_fatal_help "invalid operation mode \`$opt_mode'"
+        func_fatal_help "invalid operation mode '$opt_mode'"
         ;;
     esac
 
     echo
-    $ECHO "Try \`$progname --help' for more information about other modes."
+    $ECHO "Try '$progname --help' for more information about other modes."
 }
 
 # Now that we've collected a possible --mode arg, show help if necessary
 if $opt_help; then
-  if test "$opt_help" = :; then
+  if test : = "$opt_help"; then
     func_mode_help
   else
     {
@@ -2491,7 +3808,7 @@ if $opt_help; then
       for opt_mode in compile link execute install finish uninstall clean; do
 	func_mode_help
       done
-    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
+    } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
     {
       func_help noexit
       for opt_mode in compile link execute install finish uninstall clean; do
@@ -2499,7 +3816,7 @@ if $opt_help; then
 	func_mode_help
       done
     } |
-    sed '1d
+    $SED '1d
       /^When reporting/,/^Report/{
 	H
 	d
@@ -2516,16 +3833,17 @@ fi
 # func_mode_execute arg...
 func_mode_execute ()
 {
-    $opt_debug
+    $debug_cmd
+
     # The first argument is the command name.
-    cmd="$nonopt"
+    cmd=$nonopt
     test -z "$cmd" && \
       func_fatal_help "you must specify a COMMAND"
 
     # Handle -dlopen flags immediately.
     for file in $opt_dlopen; do
       test -f "$file" \
-	|| func_fatal_help "\`$file' is not a file"
+	|| func_fatal_help "'$file' is not a file"
 
       dir=
       case $file in
@@ -2535,7 +3853,7 @@ func_mode_execute ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+	  || func_fatal_help "'$lib' is not a valid libtool archive"
 
 	# Read the libtool library.
 	dlname=
@@ -2546,18 +3864,18 @@ func_mode_execute ()
 	if test -z "$dlname"; then
 	  # Warn if it was a shared library.
 	  test -n "$library_names" && \
-	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	    func_warning "'$file' was not linked with '-export-dynamic'"
 	  continue
 	fi
 
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 
 	if test -f "$dir/$objdir/$dlname"; then
 	  func_append dir "/$objdir"
 	else
 	  if test ! -f "$dir/$dlname"; then
-	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
 	  fi
 	fi
 	;;
@@ -2565,18 +3883,18 @@ func_mode_execute ()
       *.lo)
 	# Just add the directory containing the .lo file.
 	func_dirname "$file" "" "."
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	;;
 
       *)
-	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
 	continue
 	;;
       esac
 
       # Get the absolute pathname.
       absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
+      test -n "$absdir" && dir=$absdir
 
       # Now add the directory to shlibpath_var.
       if eval "test -z \"\$$shlibpath_var\""; then
@@ -2588,7 +3906,7 @@ func_mode_execute ()
 
     # This variable tells wrapper scripts just to set shlibpath_var
     # rather than running their programs.
-    libtool_execute_magic="$magic"
+    libtool_execute_magic=$magic
 
     # Check if any of the arguments is a wrapper script.
     args=
@@ -2601,12 +3919,12 @@ func_mode_execute ()
 	if func_ltwrapper_script_p "$file"; then
 	  func_source "$file"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	elif func_ltwrapper_executable_p "$file"; then
 	  func_ltwrapper_scriptname "$file"
 	  func_source "$func_ltwrapper_scriptname_result"
 	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
+	  file=$progdir/$program
 	fi
 	;;
       esac
@@ -2614,7 +3932,15 @@ func_mode_execute ()
       func_append_quoted args "$file"
     done
 
-    if test "X$opt_dry_run" = Xfalse; then
+    if $opt_dry_run; then
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	echo "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    else
       if test -n "$shlibpath_var"; then
 	# Export the shlibpath_var.
 	eval "export $shlibpath_var"
@@ -2631,25 +3957,18 @@ func_mode_execute ()
       done
 
       # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
-	echo "export $shlibpath_var"
-      fi
-      $ECHO "$cmd$args"
-      exit $EXIT_SUCCESS
+      exec_cmd=\$cmd$args
     fi
 }
 
-test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
 
 
 # func_mode_finish arg...
 func_mode_finish ()
 {
-    $opt_debug
+    $debug_cmd
+
     libs=
     libdirs=
     admincmds=
@@ -2663,11 +3982,11 @@ func_mode_finish ()
 	if func_lalib_unsafe_p "$opt"; then
 	  func_append libs " $opt"
 	else
-	  func_warning "\`$opt' is not a valid libtool archive"
+	  func_warning "'$opt' is not a valid libtool archive"
 	fi
 
       else
-	func_fatal_error "invalid argument \`$opt'"
+	func_fatal_error "invalid argument '$opt'"
       fi
     done
 
@@ -2682,12 +4001,12 @@ func_mode_finish ()
       # Remove sysroot references
       if $opt_dry_run; then
         for lib in $libs; do
-          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+          echo "removing references to $lt_sysroot and '=' prefixes from $lib"
         done
       else
         tmpdir=`func_mktempdir`
         for lib in $libs; do
-	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
 	    > $tmpdir/tmp-la
 	  mv -f $tmpdir/tmp-la $lib
 	done
@@ -2712,7 +4031,7 @@ func_mode_finish ()
     fi
 
     # Exit here if they wanted silent mode.
-    $opt_silent && exit $EXIT_SUCCESS
+    $opt_quiet && exit $EXIT_SUCCESS
 
     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
       echo "----------------------------------------------------------------------"
@@ -2723,27 +4042,27 @@ func_mode_finish ()
       echo
       echo "If you ever happen to want to link against installed libraries"
       echo "in a given directory, LIBDIR, you must either use libtool, and"
-      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+      echo "specify the full pathname of the library, or use the '-LLIBDIR'"
       echo "flag during linking and do at least one of the following:"
       if test -n "$shlibpath_var"; then
-	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
 	echo "     during execution"
       fi
       if test -n "$runpath_var"; then
-	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+	echo "   - add LIBDIR to the '$runpath_var' environment variable"
 	echo "     during linking"
       fi
       if test -n "$hardcode_libdir_flag_spec"; then
 	libdir=LIBDIR
 	eval flag=\"$hardcode_libdir_flag_spec\"
 
-	$ECHO "   - use the \`$flag' linker flag"
+	$ECHO "   - use the '$flag' linker flag"
       fi
       if test -n "$admincmds"; then
 	$ECHO "   - have your system administrator run these commands:$admincmds"
       fi
       if test -f /etc/ld.so.conf; then
-	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
       fi
       echo
 
@@ -2762,18 +4081,20 @@ func_mode_finish ()
     exit $EXIT_SUCCESS
 }
 
-test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
 
 
 # func_mode_install arg...
 func_mode_install ()
 {
-    $opt_debug
+    $debug_cmd
+
     # There may be an optional sh(1) argument at the beginning of
     # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+    if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
        # Allow the use of GNU shtool's install command.
-       case $nonopt in *shtool*) :;; *) false;; esac; then
+       case $nonopt in *shtool*) :;; *) false;; esac
+    then
       # Aesthetically quote it.
       func_quote_for_eval "$nonopt"
       install_prog="$func_quote_for_eval_result "
@@ -2800,7 +4121,7 @@ func_mode_install ()
     opts=
     prev=
     install_type=
-    isdir=no
+    isdir=false
     stripme=
     no_mode=:
     for arg
@@ -2813,7 +4134,7 @@ func_mode_install ()
       fi
 
       case $arg in
-      -d) isdir=yes ;;
+      -d) isdir=: ;;
       -f)
 	if $install_cp; then :; else
 	  prev=$arg
@@ -2831,7 +4152,7 @@ func_mode_install ()
       *)
 	# If the previous option needed an argument, then skip it.
 	if test -n "$prev"; then
-	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
+	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
 	    arg2=$install_override_mode
 	    no_mode=false
 	  fi
@@ -2856,7 +4177,7 @@ func_mode_install ()
       func_fatal_help "you must specify an install program"
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prev' option requires an argument"
+      func_fatal_help "the '$prev' option requires an argument"
 
     if test -n "$install_override_mode" && $no_mode; then
       if $install_cp; then :; else
@@ -2878,19 +4199,19 @@ func_mode_install ()
     dest=$func_stripname_result
 
     # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
+    test -d "$dest" && isdir=:
+    if $isdir; then
+      destdir=$dest
       destname=
     else
       func_dirname_and_basename "$dest" "" "."
-      destdir="$func_dirname_result"
-      destname="$func_basename_result"
+      destdir=$func_dirname_result
+      destname=$func_basename_result
 
       # Not a directory, so check to see that there is only one file specified.
       set dummy $files; shift
       test "$#" -gt 1 && \
-	func_fatal_help "\`$dest' is not a directory"
+	func_fatal_help "'$dest' is not a directory"
     fi
     case $destdir in
     [\\/]* | [A-Za-z]:[\\/]*) ;;
@@ -2899,7 +4220,7 @@ func_mode_install ()
 	case $file in
 	*.lo) ;;
 	*)
-	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  func_fatal_help "'$destdir' must be an absolute directory name"
 	  ;;
 	esac
       done
@@ -2908,7 +4229,7 @@ func_mode_install ()
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     staticlibs=
     future_libdirs=
@@ -2928,7 +4249,7 @@ func_mode_install ()
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$file" \
-	  || func_fatal_help "\`$file' is not a valid libtool archive"
+	  || func_fatal_help "'$file' is not a valid libtool archive"
 
 	library_names=
 	old_library=
@@ -2950,7 +4271,7 @@ func_mode_install ()
 	fi
 
 	func_dirname "$file" "/" ""
-	dir="$func_dirname_result"
+	dir=$func_dirname_result
 	func_append dir "$objdir"
 
 	if test -n "$relink_command"; then
@@ -2964,7 +4285,7 @@ func_mode_install ()
 	  # are installed into $libdir/../bin (currently, that works fine)
 	  # but it's something to keep an eye on.
 	  test "$inst_prefix_dir" = "$destdir" && \
-	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
@@ -2973,29 +4294,36 @@ func_mode_install ()
 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
 	  fi
 
-	  func_warning "relinking \`$file'"
+	  func_warning "relinking '$file'"
 	  func_show_eval "$relink_command" \
-	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
 	fi
 
 	# See the names of the shared library.
 	set dummy $library_names; shift
 	if test -n "$1"; then
-	  realname="$1"
+	  realname=$1
 	  shift
 
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
+	  srcname=$realname
+	  test -n "$relink_command" && srcname=${realname}T
 
 	  # Install the shared library and build the symlinks.
 	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
 	      'exit $?'
-	  tstripme="$stripme"
+	  tstripme=$stripme
 	  case $host_os in
 	  cygwin* | mingw* | pw32* | cegcc*)
 	    case $realname in
 	    *.dll.a)
-	      tstripme=""
+	      tstripme=
+	      ;;
+	    esac
+	    ;;
+	  os2*)
+	    case $realname in
+	    *_dll.a)
+	      tstripme=
 	      ;;
 	    esac
 	    ;;
@@ -3006,7 +4334,7 @@ func_mode_install ()
 
 	  if test "$#" -gt 0; then
 	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # Try 'ln -sf' first, because the 'ln' binary might depend on
 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
 	    # so we also need to try rm && ln -s.
 	    for linkname
@@ -3017,14 +4345,14 @@ func_mode_install ()
 	  fi
 
 	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
+	  lib=$destdir/$realname
 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
 	fi
 
 	# Install the pseudo-library for information purposes.
 	func_basename "$file"
-	name="$func_basename_result"
-	instname="$dir/$name"i
+	name=$func_basename_result
+	instname=$dir/${name}i
 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
 
 	# Maybe install the static library, too.
@@ -3036,11 +4364,11 @@ func_mode_install ()
 
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# Deduce the name of the destination old-style object file.
@@ -3050,11 +4378,11 @@ func_mode_install ()
 	  staticdest=$func_lo2o_result
 	  ;;
 	*.$objext)
-	  staticdest="$destfile"
+	  staticdest=$destfile
 	  destfile=
 	  ;;
 	*)
-	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  func_fatal_help "cannot copy a libtool object to '$destfile'"
 	  ;;
 	esac
 
@@ -3063,7 +4391,7 @@ func_mode_install ()
 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
 
 	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
+	if test yes = "$build_old_libs"; then
 	  # Deduce the name of the old-style object file.
 	  func_lo2o "$file"
 	  staticobj=$func_lo2o_result
@@ -3075,23 +4403,23 @@ func_mode_install ()
       *)
 	# Figure out destination file name, if it wasn't already specified.
 	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
+	  destfile=$destdir/$destname
 	else
 	  func_basename "$file"
-	  destfile="$func_basename_result"
-	  destfile="$destdir/$destfile"
+	  destfile=$func_basename_result
+	  destfile=$destdir/$destfile
 	fi
 
 	# If the file is missing, and there is a .exe on the end, strip it
 	# because it is most likely a libtool script we actually want to
 	# install
-	stripped_ext=""
+	stripped_ext=
 	case $file in
 	  *.exe)
 	    if test ! -f "$file"; then
 	      func_stripname '' '.exe' "$file"
 	      file=$func_stripname_result
-	      stripped_ext=".exe"
+	      stripped_ext=.exe
 	    fi
 	    ;;
 	esac
@@ -3119,19 +4447,19 @@ func_mode_install ()
 
 	  # Check the variables that should have been set.
 	  test -z "$generated_by_libtool_version" && \
-	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
 
-	  finalize=yes
+	  finalize=:
 	  for lib in $notinst_deplibs; do
 	    # Check to see that each library is installed.
 	    libdir=
 	    if test -f "$lib"; then
 	      func_source "$lib"
 	    fi
-	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
 	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      func_warning "\`$lib' has not been installed in \`$libdir'"
-	      finalize=no
+	      func_warning "'$lib' has not been installed in '$libdir'"
+	      finalize=false
 	    fi
 	  done
 
@@ -3139,29 +4467,29 @@ func_mode_install ()
 	  func_source "$wrapper"
 
 	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
+	  if test no = "$fast_install" && test -n "$relink_command"; then
 	    $opt_dry_run || {
-	      if test "$finalize" = yes; then
+	      if $finalize; then
 	        tmpdir=`func_mktempdir`
 		func_basename "$file$stripped_ext"
-		file="$func_basename_result"
-	        outputname="$tmpdir/$file"
+		file=$func_basename_result
+	        outputname=$tmpdir/$file
 	        # Replace the output file specification.
 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
 
-	        $opt_silent || {
+	        $opt_quiet || {
 	          func_quote_for_expand "$relink_command"
 		  eval "func_echo $func_quote_for_expand_result"
 	        }
 	        if eval "$relink_command"; then :
 	          else
-		  func_error "error: relink \`$file' with the above command before installing it"
+		  func_error "error: relink '$file' with the above command before installing it"
 		  $opt_dry_run || ${RM}r "$tmpdir"
 		  continue
 	        fi
-	        file="$outputname"
+	        file=$outputname
 	      else
-	        func_warning "cannot relink \`$file'"
+	        func_warning "cannot relink '$file'"
 	      fi
 	    }
 	  else
@@ -3198,10 +4526,10 @@ func_mode_install ()
 
     for file in $staticlibs; do
       func_basename "$file"
-      name="$func_basename_result"
+      name=$func_basename_result
 
       # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
+      oldlib=$destdir/$name
       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
       tool_oldlib=$func_to_tool_file_result
 
@@ -3216,18 +4544,18 @@ func_mode_install ()
     done
 
     test -n "$future_libdirs" && \
-      func_warning "remember to run \`$progname --finish$future_libdirs'"
+      func_warning "remember to run '$progname --finish$future_libdirs'"
 
     if test -n "$current_libdirs"; then
       # Maybe just do a dry run.
       $opt_dry_run && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+      exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
     else
       exit $EXIT_SUCCESS
     fi
 }
 
-test "$opt_mode" = install && func_mode_install ${1+"$@"}
+test install = "$opt_mode" && func_mode_install ${1+"$@"}
 
 
 # func_generate_dlsyms outputname originator pic_p
@@ -3235,16 +4563,17 @@ test "$opt_mode" = install && func_mode_install ${1+"$@"}
 # a dlpreopen symbol table.
 func_generate_dlsyms ()
 {
-    $opt_debug
-    my_outputname="$1"
-    my_originator="$2"
-    my_pic_p="${3-no}"
-    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    $debug_cmd
+
+    my_outputname=$1
+    my_originator=$2
+    my_pic_p=${3-false}
+    my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
     my_dlsyms=
 
-    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+    if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
       if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	my_dlsyms="${my_outputname}S.c"
+	my_dlsyms=${my_outputname}S.c
       else
 	func_error "not configured to extract global symbols from dlpreopened files"
       fi
@@ -3255,7 +4584,7 @@ func_generate_dlsyms ()
       "") ;;
       *.c)
 	# Discover the nlist of each of the dlfiles.
-	nlist="$output_objdir/${my_outputname}.nm"
+	nlist=$output_objdir/$my_outputname.nm
 
 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
 
@@ -3263,34 +4592,36 @@ func_generate_dlsyms ()
 	func_verbose "creating $output_objdir/$my_dlsyms"
 
 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
-/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
-/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
 
 #ifdef __cplusplus
 extern \"C\" {
 #endif
 
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
 #endif
 
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
 # define LT_DLSYM_CONST const
 #endif
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* External symbol declarations for the compiler. */\
 "
 
-	if test "$dlself" = yes; then
-	  func_verbose "generating symbol list for \`$output'"
+	if test yes = "$dlself"; then
+	  func_verbose "generating symbol list for '$output'"
 
 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
 
@@ -3298,7 +4629,7 @@ extern \"C\" {
 	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	  for progfile in $progfiles; do
 	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
-	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
 	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
 	  done
 
@@ -3318,10 +4649,10 @@ extern \"C\" {
 
 	  # Prepare the list of exported symbols
 	  if test -z "$export_symbols"; then
-	    export_symbols="$output_objdir/$outputname.exp"
+	    export_symbols=$output_objdir/$outputname.exp
 	    $opt_dry_run || {
 	      $RM $export_symbols
-	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
 	      case $host in
 	      *cygwin* | *mingw* | *cegcc* )
                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
@@ -3331,7 +4662,7 @@ extern \"C\" {
 	    }
 	  else
 	    $opt_dry_run || {
-	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
 	      eval '$MV "$nlist"T "$nlist"'
 	      case $host in
@@ -3345,22 +4676,22 @@ extern \"C\" {
 	fi
 
 	for dlprefile in $dlprefiles; do
-	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_verbose "extracting global C symbols from '$dlprefile'"
 	  func_basename "$dlprefile"
-	  name="$func_basename_result"
+	  name=$func_basename_result
           case $host in
 	    *cygwin* | *mingw* | *cegcc* )
 	      # if an import library, we need to obtain dlname
 	      if func_win32_import_lib_p "$dlprefile"; then
 	        func_tr_sh "$dlprefile"
 	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
-	        dlprefile_dlbasename=""
+	        dlprefile_dlbasename=
 	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
 	          # Use subshell, to avoid clobbering current variable values
 	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
-	          if test -n "$dlprefile_dlname" ; then
+	          if test -n "$dlprefile_dlname"; then
 	            func_basename "$dlprefile_dlname"
-	            dlprefile_dlbasename="$func_basename_result"
+	            dlprefile_dlbasename=$func_basename_result
 	          else
 	            # no lafile. user explicitly requested -dlpreopen <import library>.
 	            $sharedlib_from_linklib_cmd "$dlprefile"
@@ -3368,7 +4699,7 @@ extern \"C\" {
 	          fi
 	        fi
 	        $opt_dry_run || {
-	          if test -n "$dlprefile_dlbasename" ; then
+	          if test -n "$dlprefile_dlbasename"; then
 	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
 	          else
 	            func_warning "Could not compute DLL name from $name"
@@ -3424,6 +4755,11 @@ extern \"C\" {
 	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
 	  fi
 
+	  func_show_eval '$RM "${nlist}I"'
+	  if test -n "$global_symbol_to_import"; then
+	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
+	  fi
+
 	  echo >> "$output_objdir/$my_dlsyms" "\
 
 /* The mapping between symbol names and symbols.  */
@@ -3432,11 +4768,30 @@ typedef struct {
   void *address;
 } lt_dlsymlist;
 extern LT_DLSYM_CONST lt_dlsymlist
-lt_${my_prefix}_LTX_preloaded_symbols[];
+lt_${my_prefix}_LTX_preloaded_symbols[];\
+"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+static void lt_syminit(void)
+{
+  LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
+  for (; symbol->name; ++symbol)
+    {"
+	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
+	    echo >> "$output_objdir/$my_dlsyms" "\
+    }
+}"
+	  fi
+	  echo >> "$output_objdir/$my_dlsyms" "\
 LT_DLSYM_CONST lt_dlsymlist
 lt_${my_prefix}_LTX_preloaded_symbols[] =
-{\
-  { \"$my_originator\", (void *) 0 },"
+{ {\"$my_originator\", (void *) 0},"
+
+	  if test -s "$nlist"I; then
+	    echo >> "$output_objdir/$my_dlsyms" "\
+  {\"@INIT@\", (void *) &lt_syminit},"
+	  fi
 
 	  case $need_lib_prefix in
 	  no)
@@ -3478,9 +4833,7 @@ static const void *lt_preloaded_setup() {
 	  *-*-hpux*)
 	    pic_flag_for_symtable=" $pic_flag"  ;;
 	  *)
-	    if test "X$my_pic_p" != Xno; then
-	      pic_flag_for_symtable=" $pic_flag"
-	    fi
+	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
 	    ;;
 	  esac
 	  ;;
@@ -3497,10 +4850,10 @@ static const void *lt_preloaded_setup() {
 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
 
 	# Clean up the generated files.
-	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
 
 	# Transform the symbol file into the correct name.
-	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	symfileobj=$output_objdir/${my_outputname}S.$objext
 	case $host in
 	*cygwin* | *mingw* | *cegcc* )
 	  if test -f "$output_objdir/$my_outputname.def"; then
@@ -3518,7 +4871,7 @@ static const void *lt_preloaded_setup() {
 	esac
 	;;
       *)
-	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	func_fatal_error "unknown suffix for '$my_dlsyms'"
 	;;
       esac
     else
@@ -3532,6 +4885,32 @@ static const void *lt_preloaded_setup() {
     fi
 }
 
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+  test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+  $debug_cmd
+
+  func_to_tool_file "$1" func_convert_file_msys_to_w32
+  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+  test -n "$func_cygming_ms_implib_tmp"
+}
+
 # func_win32_libid arg
 # return the library type of file 'arg'
 #
@@ -3541,8 +4920,9 @@ static const void *lt_preloaded_setup() {
 # Despite the name, also deal with 64 bit binaries.
 func_win32_libid ()
 {
-  $opt_debug
-  win32_libid_type="unknown"
+  $debug_cmd
+
+  win32_libid_type=unknown
   win32_fileres=`file -L $1 2>/dev/null`
   case $win32_fileres in
   *ar\ archive\ import\ library*) # definitely import
@@ -3552,16 +4932,29 @@ func_win32_libid ()
     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
-      func_to_tool_file "$1" func_convert_file_msys_to_w32
-      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
-	$SED -n -e '
+      case $nm_interface in
+      "MS dumpbin")
+	if func_cygming_ms_implib_p "$1" ||
+	   func_cygming_gnu_implib_p "$1"
+	then
+	  win32_nmres=import
+	else
+	  win32_nmres=
+	fi
+	;;
+      *)
+	func_to_tool_file "$1" func_convert_file_msys_to_w32
+	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+	  $SED -n -e '
 	    1,100{
 		/ I /{
-		    s,.*,import,
+		    s|.*|import|
 		    p
 		    q
 		}
 	    }'`
+	;;
+      esac
       case $win32_nmres in
       import*)  win32_libid_type="x86 archive import";;
       *)        win32_libid_type="x86 archive static";;
@@ -3593,7 +4986,8 @@ func_win32_libid ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib ()
 {
-  $opt_debug
+  $debug_cmd
+
   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
 }
 
@@ -3610,7 +5004,8 @@ func_cygming_dll_for_implib ()
 # specified import library.
 func_cygming_dll_for_implib_fallback_core ()
 {
-  $opt_debug
+  $debug_cmd
+
   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
     $SED '/^Contents of section '"$match_literal"':/{
@@ -3646,8 +5041,8 @@ func_cygming_dll_for_implib_fallback_core ()
       /./p' |
     # we now have a list, one entry per line, of the stringified
     # contents of the appropriate section of all members of the
-    # archive which possess that section. Heuristic: eliminate
-    # all those which have a first or second character that is
+    # archive that possess that section. Heuristic: eliminate
+    # all those that have a first or second character that is
     # a '.' (that is, objdump's representation of an unprintable
     # character.) This should work for all archives with less than
     # 0x302f exports -- but will fail for DLLs whose name actually
@@ -3658,30 +5053,6 @@ func_cygming_dll_for_implib_fallback_core ()
     $SED -e '/^\./d;/^.\./d;q'
 }
 
-# func_cygming_gnu_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is a GNU/binutils-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_gnu_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
-  test -n "$func_cygming_gnu_implib_tmp"
-}
-
-# func_cygming_ms_implib_p ARG
-# This predicate returns with zero status (TRUE) if
-# ARG is an MS-style import library. Returns
-# with nonzero status (FALSE) otherwise.
-func_cygming_ms_implib_p ()
-{
-  $opt_debug
-  func_to_tool_file "$1" func_convert_file_msys_to_w32
-  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
-  test -n "$func_cygming_ms_implib_tmp"
-}
-
 # func_cygming_dll_for_implib_fallback ARG
 # Platform-specific function to extract the
 # name of the DLL associated with the specified
@@ -3695,16 +5066,17 @@ func_cygming_ms_implib_p ()
 #    $sharedlib_from_linklib_result
 func_cygming_dll_for_implib_fallback ()
 {
-  $opt_debug
-  if func_cygming_gnu_implib_p "$1" ; then
+  $debug_cmd
+
+  if func_cygming_gnu_implib_p "$1"; then
     # binutils import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
-  elif func_cygming_ms_implib_p "$1" ; then
+  elif func_cygming_ms_implib_p "$1"; then
     # ms-generated import library
     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
   else
     # unknown
-    sharedlib_from_linklib_result=""
+    sharedlib_from_linklib_result=
   fi
 }
 
@@ -3712,10 +5084,11 @@ func_cygming_dll_for_implib_fallback ()
 # func_extract_an_archive dir oldlib
 func_extract_an_archive ()
 {
-    $opt_debug
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-    if test "$lock_old_archive_extraction" = yes; then
+    $debug_cmd
+
+    f_ex_an_ar_dir=$1; shift
+    f_ex_an_ar_oldlib=$1
+    if test yes = "$lock_old_archive_extraction"; then
       lockfile=$f_ex_an_ar_oldlib.lock
       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
 	func_echo "Waiting for $lockfile to be removed"
@@ -3724,7 +5097,7 @@ func_extract_an_archive ()
     fi
     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
 		   'stat=$?; rm -f "$lockfile"; exit $stat'
-    if test "$lock_old_archive_extraction" = yes; then
+    if test yes = "$lock_old_archive_extraction"; then
       $opt_dry_run || rm -f "$lockfile"
     fi
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
@@ -3738,22 +5111,23 @@ func_extract_an_archive ()
 # func_extract_archives gentop oldlib ...
 func_extract_archives ()
 {
-    $opt_debug
-    my_gentop="$1"; shift
+    $debug_cmd
+
+    my_gentop=$1; shift
     my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
+    my_oldobjs=
+    my_xlib=
+    my_xabs=
+    my_xdir=
 
     for my_xlib in $my_oldlibs; do
       # Extract the objects.
       case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       func_basename "$my_xlib"
-      my_xlib="$func_basename_result"
+      my_xlib=$func_basename_result
       my_xlib_u=$my_xlib
       while :; do
         case " $extracted_archives " in
@@ -3765,7 +5139,7 @@ func_extract_archives ()
 	esac
       done
       extracted_archives="$extracted_archives $my_xlib_u"
-      my_xdir="$my_gentop/$my_xlib_u"
+      my_xdir=$my_gentop/$my_xlib_u
 
       func_mkdir_p "$my_xdir"
 
@@ -3778,22 +5152,23 @@ func_extract_archives ()
 	  cd $my_xdir || exit $?
 	  darwin_archive=$my_xabs
 	  darwin_curdir=`pwd`
-	  darwin_base_archive=`basename "$darwin_archive"`
+	  func_basename "$darwin_archive"
+	  darwin_base_archive=$func_basename_result
 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
 	  if test -n "$darwin_arches"; then
 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
 	    darwin_arch=
 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	    for darwin_arch in  $darwin_arches; do
+	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
+	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
+	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
 	      cd "$darwin_curdir"
-	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
 	    done # $darwin_arches
             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
 	    darwin_file=
 	    darwin_files=
 	    for darwin_file in $darwin_filelist; do
@@ -3815,7 +5190,7 @@ func_extract_archives ()
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
     done
 
-    func_extract_archives_result="$my_oldobjs"
+    func_extract_archives_result=$my_oldobjs
 }
 
 
@@ -3830,7 +5205,7 @@ func_extract_archives ()
 #
 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
 # variable will take.  If 'yes', then the emitted script
-# will assume that the directory in which it is stored is
+# will assume that the directory where it is stored is
 # the $objdir directory.  This is a cygwin/mingw-specific
 # behavior.
 func_emit_wrapper ()
@@ -3841,7 +5216,7 @@ func_emit_wrapper ()
 #! $SHELL
 
 # $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # The $output program cannot be directly executed until all the libtool
 # libraries that it depends on are installed.
@@ -3898,9 +5273,9 @@ _LTECHO_EOF'
 
 # Very basic option parsing. These options are (a) specific to
 # the libtool wrapper, (b) are identical between the wrapper
-# /script/ and the wrapper /executable/ which is used only on
+# /script/ and the wrapper /executable/ that is used only on
 # windows platforms, and (c) all begin with the string "--lt-"
-# (application programs are unlikely to have options which match
+# (application programs are unlikely to have options that match
 # this pattern).
 #
 # There are only two supported options: --lt-debug and
@@ -3933,7 +5308,7 @@ func_parse_lt_options ()
 
   # Print the debug banner immediately:
   if test -n \"\$lt_option_debug\"; then
-    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+    echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
   fi
 }
 
@@ -3944,7 +5319,7 @@ func_lt_dump_args ()
   lt_dump_args_N=1;
   for lt_arg
   do
-    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+    \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
   done
 }
@@ -3958,7 +5333,7 @@ func_exec_program_core ()
   *-*-mingw | *-*-os2* | *-cegcc*)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
@@ -3968,7 +5343,7 @@ func_exec_program_core ()
   *)
     $ECHO "\
       if test -n \"\$lt_option_debug\"; then
-        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+        \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
         func_lt_dump_args \${1+\"\$@\"} 1>&2
       fi
       exec \"\$progdir/\$program\" \${1+\"\$@\"}
@@ -4043,13 +5418,13 @@ func_exec_program ()
   test -n \"\$absdir\" && thisdir=\"\$absdir\"
 "
 
-	if test "$fast_install" = yes; then
+	if test yes = "$fast_install"; then
 	  $ECHO "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
 
   if test ! -f \"\$progdir/\$program\" ||
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
 
     file=\"\$\$-\$program\"
@@ -4066,7 +5441,7 @@ func_exec_program ()
     if test -n \"\$relink_command\"; then
       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
       else
-	$ECHO \"\$relink_command_output\" >&2
+	\$ECHO \"\$relink_command_output\" >&2
 	$RM \"\$progdir/\$file\"
 	exit 1
       fi
@@ -4101,7 +5476,7 @@ func_exec_program ()
 	fi
 
 	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
 	  $ECHO "\
     # Add our own library path to $shlibpath_var
     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
@@ -4121,7 +5496,7 @@ func_exec_program ()
     fi
   else
     # The program doesn't exist.
-    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
     exit 1
@@ -4140,7 +5515,7 @@ func_emit_cwrapperexe_src ()
 	cat <<EOF
 
 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+   Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 
    The $output program cannot be directly executed until all the libtool
    libraries that it depends on are installed.
@@ -4175,47 +5550,45 @@ EOF
 #include <fcntl.h>
 #include <sys/stat.h>
 
+#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
+
 /* declarations of non-ANSI functions */
-#if defined(__MINGW32__)
+#if defined __MINGW32__
 # ifdef __STRICT_ANSI__
 int _putenv (const char *);
 # endif
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # ifdef __STRICT_ANSI__
 char *realpath (const char *, char *);
 int putenv (char *);
 int setenv (const char *, const char *, int);
 # endif
-/* #elif defined (other platforms) ... */
+/* #elif defined other_platform || defined ... */
 #endif
 
 /* portability defines, excluding path handling macros */
-#if defined(_MSC_VER)
+#if defined _MSC_VER
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
 # define S_IXUSR _S_IEXEC
-# ifndef _INTPTR_T_DEFINED
-#  define _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#elif defined(__MINGW32__)
+#elif defined __MINGW32__
 # define setmode _setmode
 # define stat    _stat
 # define chmod   _chmod
 # define getcwd  _getcwd
 # define putenv  _putenv
-#elif defined(__CYGWIN__)
+#elif defined __CYGWIN__
 # define HAVE_SETENV
 # define FOPEN_WB "wb"
-/* #elif defined (other platforms) ... */
+/* #elif defined other platforms ... */
 #endif
 
-#if defined(PATH_MAX)
+#if defined PATH_MAX
 # define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
+#elif defined MAXPATHLEN
 # define LT_PATHMAX MAXPATHLEN
 #else
 # define LT_PATHMAX 1024
@@ -4234,8 +5607,8 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
+  defined __OS2__
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"
 # ifndef DIR_SEPARATOR_2
@@ -4268,10 +5641,10 @@ int setenv (const char *, const char *, int);
 
 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
 #define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
+  if (stale) { free (stale); stale = 0; } \
 } while (0)
 
-#if defined(LT_DEBUGWRAPPER)
+#if defined LT_DEBUGWRAPPER
 static int lt_debug = 1;
 #else
 static int lt_debug = 0;
@@ -4300,11 +5673,16 @@ void lt_dump_script (FILE *f);
 EOF
 
 	    cat <<EOF
-volatile const char * MAGIC_EXE = "$magic_exe";
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
+# define externally_visible volatile
+#else
+# define externally_visible __attribute__((externally_visible)) volatile
+#endif
+externally_visible const char * MAGIC_EXE = "$magic_exe";
 const char * LIB_PATH_VARNAME = "$shlibpath_var";
 EOF
 
-	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
               func_to_host_path "$temp_rpath"
 	      cat <<EOF
 const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
@@ -4328,7 +5706,7 @@ const char * EXE_PATH_VALUE   = "";
 EOF
 	    fi
 
-	    if test "$fast_install" = yes; then
+	    if test yes = "$fast_install"; then
 	      cat <<EOF
 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
 EOF
@@ -4357,12 +5735,12 @@ main (int argc, char *argv[])
   char *actual_cwrapper_name;
   char *target_name;
   char *lt_argv_zero;
-  intptr_t rval = 127;
+  int rval = 127;
 
   int i;
 
   program_name = (char *) xstrdup (base_name (argv[0]));
-  newargz = XMALLOC (char *, argc + 1);
+  newargz = XMALLOC (char *, (size_t) argc + 1);
 
   /* very simple arg parsing; don't want to rely on getopt
    * also, copy all non cwrapper options to newargz, except
@@ -4371,10 +5749,10 @@ main (int argc, char *argv[])
   newargc=0;
   for (i = 1; i < argc; i++)
     {
-      if (strcmp (argv[i], dumpscript_opt) == 0)
+      if (STREQ (argv[i], dumpscript_opt))
 	{
 EOF
-	    case "$host" in
+	    case $host in
 	      *mingw* | *cygwin* )
 		# make stdout use "unix" line endings
 		echo "          setmode(1,_O_BINARY);"
@@ -4385,12 +5763,12 @@ EOF
 	  lt_dump_script (stdout);
 	  return 0;
 	}
-      if (strcmp (argv[i], debug_opt) == 0)
+      if (STREQ (argv[i], debug_opt))
 	{
           lt_debug = 1;
           continue;
 	}
-      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+      if (STREQ (argv[i], ltwrapper_option_prefix))
         {
           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
              namespace, but it is not one of the ones we know about and
@@ -4413,7 +5791,7 @@ EOF
 EOF
 	    cat <<EOF
   /* The GNU banner must be the first non-error debug message */
-  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
 EOF
 	    cat <<"EOF"
   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
@@ -4524,7 +5902,7 @@ EOF
 		cat <<"EOF"
   /* execv doesn't actually work on mingw as expected on unix */
   newargz = prepare_spawn (newargz);
-  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
   if (rval == -1)
     {
       /* failed to start process */
@@ -4569,7 +5947,7 @@ base_name (const char *name)
 {
   const char *base;
 
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   /* Skip over the disk name in MSDOS pathnames. */
   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
     name += 2;
@@ -4628,7 +6006,7 @@ find_executable (const char *wrapper)
   const char *p_next;
   /* static buffer for getcwd */
   char tmp[LT_PATHMAX + 1];
-  int tmp_len;
+  size_t tmp_len;
   char *concat_name;
 
   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
@@ -4638,7 +6016,7 @@ find_executable (const char *wrapper)
     return NULL;
 
   /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
     {
       concat_name = xstrdup (wrapper);
@@ -4656,7 +6034,7 @@ find_executable (const char *wrapper)
 	    return concat_name;
 	  XFREE (concat_name);
 	}
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+#if defined HAVE_DOS_BASED_FILE_SYSTEM
     }
 #endif
 
@@ -4679,7 +6057,7 @@ find_executable (const char *wrapper)
 	      for (q = p; *q; q++)
 		if (IS_PATH_SEPARATOR (*q))
 		  break;
-	      p_len = q - p;
+	      p_len = (size_t) (q - p);
 	      p_next = (*q == '\0' ? q : q + 1);
 	      if (p_len == 0)
 		{
@@ -4798,7 +6176,7 @@ strendzap (char *str, const char *pat)
   if (patlen <= len)
     {
       str += len - patlen;
-      if (strcmp (str, pat) == 0)
+      if (STREQ (str, pat))
 	*str = '\0';
     }
   return str;
@@ -4863,7 +6241,7 @@ lt_setenv (const char *name, const char *value)
     char *str = xstrdup (value);
     setenv (name, str, 1);
 #else
-    int len = strlen (name) + 1 + strlen (value) + 1;
+    size_t len = strlen (name) + 1 + strlen (value) + 1;
     char *str = XMALLOC (char, len);
     sprintf (str, "%s=%s", name, value);
     if (putenv (str) != EXIT_SUCCESS)
@@ -4880,8 +6258,8 @@ lt_extend_str (const char *orig_value, const char *add, int to_end)
   char *new_value;
   if (orig_value && *orig_value)
     {
-      int orig_value_len = strlen (orig_value);
-      int add_len = strlen (add);
+      size_t orig_value_len = strlen (orig_value);
+      size_t add_len = strlen (add);
       new_value = XMALLOC (char, add_len + orig_value_len + 1);
       if (to_end)
         {
@@ -4912,10 +6290,10 @@ lt_update_exe_path (const char *name, const char *value)
     {
       char *new_value = lt_extend_str (getenv (name), value, 0);
       /* some systems can't cope with a ':'-terminated path #' */
-      int len = strlen (new_value);
-      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+      size_t len = strlen (new_value);
+      while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
         {
-          new_value[len-1] = '\0';
+          new_value[--len] = '\0';
         }
       lt_setenv (name, new_value);
       XFREE (new_value);
@@ -5082,27 +6460,47 @@ EOF
 # True if ARG is an import lib, as indicated by $file_magic_cmd
 func_win32_import_lib_p ()
 {
-    $opt_debug
+    $debug_cmd
+
     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
     *import*) : ;;
     *) false ;;
     esac
 }
 
+# func_suncc_cstd_abi
+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
+# Several compiler flags select an ABI that is incompatible with the
+# Cstd library. Avoid specifying it if any are in CXXFLAGS.
+func_suncc_cstd_abi ()
+{
+    $debug_cmd
+
+    case " $compile_command " in
+    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
+      suncc_use_cstd_abi=no
+      ;;
+    *)
+      suncc_use_cstd_abi=yes
+      ;;
+    esac
+}
+
 # func_mode_link arg...
 func_mode_link ()
 {
-    $opt_debug
+    $debug_cmd
+
     case $host in
     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
       # It is impossible to link a dll without this setting, and
       # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
+      # what system we are compiling for in order to pass an extra
       # flag for every libtool invocation.
       # allow_undefined=no
 
       # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
+      # to make a dll that has undefined symbols, in which case not
       # even a static library is built.  For now, we need to specify
       # -no-undefined on the libtool link line when we can be certain
       # that all symbols are satisfied, otherwise we get a static library.
@@ -5146,10 +6544,11 @@ func_mode_link ()
     module=no
     no_install=no
     objs=
+    os2dllname=
     non_pic_objects=
     precious_files_regex=
     prefer_static_libs=no
-    preload=no
+    preload=false
     prev=
     prevarg=
     release=
@@ -5161,7 +6560,7 @@ func_mode_link ()
     vinfo=
     vinfo_number=no
     weak_libs=
-    single_module="${wl}-single_module"
+    single_module=$wl-single_module
     func_infer_tag $base_compile
 
     # We need to know -static, to get the right output filenames.
@@ -5169,15 +6568,15 @@ func_mode_link ()
     do
       case $arg in
       -shared)
-	test "$build_libtool_libs" != yes && \
-	  func_fatal_configuration "can not build a shared library"
+	test yes != "$build_libtool_libs" \
+	  && func_fatal_configuration "cannot build a shared library"
 	build_old_libs=no
 	break
 	;;
       -all-static | -static | -static-libtool-libs)
 	case $arg in
 	-all-static)
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
 	    func_warning "complete static linking is impossible in this configuration"
 	  fi
 	  if test -n "$link_static_flag"; then
@@ -5210,7 +6609,7 @@ func_mode_link ()
 
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
-      arg="$1"
+      arg=$1
       shift
       func_quote_for_eval "$arg"
       qarg=$func_quote_for_eval_unquoted_result
@@ -5227,21 +6626,21 @@ func_mode_link ()
 
 	case $prev in
 	bindir)
-	  bindir="$arg"
+	  bindir=$arg
 	  prev=
 	  continue
 	  ;;
 	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
+	  $preload || {
 	    # Add the symbol object into the linking commands.
 	    func_append compile_command " @SYMFILE@"
 	    func_append finalize_command " @SYMFILE@"
-	    preload=yes
-	  fi
+	    preload=:
+	  }
 	  case $arg in
 	  *.la | *.lo) ;;  # We handle these cases below.
 	  force)
-	    if test "$dlself" = no; then
+	    if test no = "$dlself"; then
 	      dlself=needless
 	      export_dynamic=yes
 	    fi
@@ -5249,9 +6648,9 @@ func_mode_link ()
 	    continue
 	    ;;
 	  self)
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
 	      dlself=yes
 	    else
 	      dlself=needless
@@ -5261,7 +6660,7 @@ func_mode_link ()
 	    continue
 	    ;;
 	  *)
-	    if test "$prev" = dlfiles; then
+	    if test dlfiles = "$prev"; then
 	      func_append dlfiles " $arg"
 	    else
 	      func_append dlprefiles " $arg"
@@ -5272,14 +6671,14 @@ func_mode_link ()
 	  esac
 	  ;;
 	expsyms)
-	  export_symbols="$arg"
+	  export_symbols=$arg
 	  test -f "$arg" \
-	    || func_fatal_error "symbol file \`$arg' does not exist"
+	    || func_fatal_error "symbol file '$arg' does not exist"
 	  prev=
 	  continue
 	  ;;
 	expsyms_regex)
-	  export_symbols_regex="$arg"
+	  export_symbols_regex=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5297,7 +6696,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	inst_prefix)
-	  inst_prefix_dir="$arg"
+	  inst_prefix_dir=$arg
+	  prev=
+	  continue
+	  ;;
+	mllvm)
+	  # Clang does not use LLVM to link, so we can simply discard any
+	  # '-mllvm $arg' options when doing the link step.
 	  prev=
 	  continue
 	  ;;
@@ -5321,21 +6726,21 @@ func_mode_link ()
 
 		if test -z "$pic_object" ||
 		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none &&
-		   test "$non_pic_object" = none; then
-		  func_fatal_error "cannot find name of object for \`$arg'"
+		   test none = "$pic_object" &&
+		   test none = "$non_pic_object"; then
+		  func_fatal_error "cannot find name of object for '$arg'"
 		fi
 
 		# Extract subdirectory from the argument.
 		func_dirname "$arg" "/" ""
-		xdir="$func_dirname_result"
+		xdir=$func_dirname_result
 
-		if test "$pic_object" != none; then
+		if test none != "$pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
+		  pic_object=$xdir$pic_object
 
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		  if test dlfiles = "$prev"; then
+		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		      func_append dlfiles " $pic_object"
 		      prev=
 		      continue
@@ -5346,7 +6751,7 @@ func_mode_link ()
 		  fi
 
 		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
+		  if test dlprefiles = "$prev"; then
 		    # Preload the old-style object.
 		    func_append dlprefiles " $pic_object"
 		    prev=
@@ -5354,23 +6759,23 @@ func_mode_link ()
 
 		  # A PIC object.
 		  func_append libobjs " $pic_object"
-		  arg="$pic_object"
+		  arg=$pic_object
 		fi
 
 		# Non-PIC object.
-		if test "$non_pic_object" != none; then
+		if test none != "$non_pic_object"; then
 		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
+		  non_pic_object=$xdir$non_pic_object
 
 		  # A standard non-PIC object
 		  func_append non_pic_objects " $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
+		  if test -z "$pic_object" || test none = "$pic_object"; then
+		    arg=$non_pic_object
 		  fi
 		else
 		  # If the PIC object exists, use it instead.
 		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
+		  non_pic_object=$pic_object
 		  func_append non_pic_objects " $non_pic_object"
 		fi
 	      else
@@ -5378,7 +6783,7 @@ func_mode_link ()
 		if $opt_dry_run; then
 		  # Extract subdirectory from the argument.
 		  func_dirname "$arg" "/" ""
-		  xdir="$func_dirname_result"
+		  xdir=$func_dirname_result
 
 		  func_lo2o "$arg"
 		  pic_object=$xdir$objdir/$func_lo2o_result
@@ -5386,24 +6791,29 @@ func_mode_link ()
 		  func_append libobjs " $pic_object"
 		  func_append non_pic_objects " $non_pic_object"
 	        else
-		  func_fatal_error "\`$arg' is not a valid libtool object"
+		  func_fatal_error "'$arg' is not a valid libtool object"
 		fi
 	      fi
 	    done
 	  else
-	    func_fatal_error "link input file \`$arg' does not exist"
+	    func_fatal_error "link input file '$arg' does not exist"
 	  fi
 	  arg=$save_arg
 	  prev=
 	  continue
 	  ;;
+	os2dllname)
+	  os2dllname=$arg
+	  prev=
+	  continue
+	  ;;
 	precious_regex)
-	  precious_files_regex="$arg"
+	  precious_files_regex=$arg
 	  prev=
 	  continue
 	  ;;
 	release)
-	  release="-$arg"
+	  release=-$arg
 	  prev=
 	  continue
 	  ;;
@@ -5415,7 +6825,7 @@ func_mode_link ()
 	    func_fatal_error "only absolute run-paths are allowed"
 	    ;;
 	  esac
-	  if test "$prev" = rpath; then
+	  if test rpath = "$prev"; then
 	    case "$rpath " in
 	    *" $arg "*) ;;
 	    *) func_append rpath " $arg" ;;
@@ -5430,7 +6840,7 @@ func_mode_link ()
 	  continue
 	  ;;
 	shrext)
-	  shrext_cmds="$arg"
+	  shrext_cmds=$arg
 	  prev=
 	  continue
 	  ;;
@@ -5470,7 +6880,7 @@ func_mode_link ()
 	esac
       fi # test -n "$prev"
 
-      prevarg="$arg"
+      prevarg=$arg
 
       case $arg in
       -all-static)
@@ -5484,7 +6894,7 @@ func_mode_link ()
 
       -allow-undefined)
 	# FIXME: remove this flag sometime in the future.
-	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	func_fatal_error "'-allow-undefined' must not be used because it is the default"
 	;;
 
       -avoid-version)
@@ -5516,7 +6926,7 @@ func_mode_link ()
 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
 	fi
-	if test "X$arg" = "X-export-symbols"; then
+	if test X-export-symbols = "X$arg"; then
 	  prev=expsyms
 	else
 	  prev=expsyms_regex
@@ -5550,9 +6960,9 @@ func_mode_link ()
 	func_stripname "-L" '' "$arg"
 	if test -z "$func_stripname_result"; then
 	  if test "$#" -gt 0; then
-	    func_fatal_error "require no space between \`-L' and \`$1'"
+	    func_fatal_error "require no space between '-L' and '$1'"
 	  else
-	    func_fatal_error "need path for \`-L' option"
+	    func_fatal_error "need path for '-L' option"
 	  fi
 	fi
 	func_resolve_sysroot "$func_stripname_result"
@@ -5563,8 +6973,8 @@ func_mode_link ()
 	*)
 	  absdir=`cd "$dir" && pwd`
 	  test -z "$absdir" && \
-	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
-	  dir="$absdir"
+	    func_fatal_error "cannot determine absolute directory name of '$dir'"
+	  dir=$absdir
 	  ;;
 	esac
 	case "$deplibs " in
@@ -5599,7 +7009,7 @@ func_mode_link ()
 	;;
 
       -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
 	    # These systems don't actually have a C or math library (as such)
@@ -5607,11 +7017,11 @@ func_mode_link ()
 	    ;;
 	  *-*-os2*)
 	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-rhapsody* | *-*-darwin1.[012])
 	    # Rhapsody C and math libraries are in the System framework
@@ -5620,16 +7030,16 @@ func_mode_link ()
 	    ;;
 	  *-*-sco3.2v5* | *-*-sco5v6*)
 	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
 	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
+	    test X-lc = "X$arg" && continue
 	    ;;
 	  esac
-	elif test "X$arg" = "X-lc_r"; then
+	elif test X-lc_r = "X$arg"; then
 	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
 	   # Do not include libc_r directly, use -pthread flag.
 	   continue
 	   ;;
@@ -5639,6 +7049,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -mllvm)
+	prev=mllvm
+	continue
+	;;
+
       -module)
 	module=yes
 	continue
@@ -5668,7 +7083,7 @@ func_mode_link ()
 	;;
 
       -multi_module)
-	single_module="${wl}-multi_module"
+	single_module=$wl-multi_module
 	continue
 	;;
 
@@ -5682,8 +7097,8 @@ func_mode_link ()
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
 	  # The PATH hackery in wrapper scripts is required on Windows
 	  # and Darwin in order for the loader to find any dlls it needs.
-	  func_warning "\`-no-install' is ignored for $host"
-	  func_warning "assuming \`-no-fast-install' instead"
+	  func_warning "'-no-install' is ignored for $host"
+	  func_warning "assuming '-no-fast-install' instead"
 	  fast_install=no
 	  ;;
 	*) no_install=yes ;;
@@ -5701,6 +7116,11 @@ func_mode_link ()
 	continue
 	;;
 
+      -os2dllname)
+	prev=os2dllname
+	continue
+	;;
+
       -o) prev=output ;;
 
       -precious-files-regex)
@@ -5788,14 +7208,14 @@ func_mode_link ()
 	func_stripname '-Wc,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $func_quote_for_eval_result"
 	  func_append compiler_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5804,15 +7224,15 @@ func_mode_link ()
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
 	arg=
-	save_ifs="$IFS"; IFS=','
+	save_ifs=$IFS; IFS=,
 	for flag in $args; do
-	  IFS="$save_ifs"
+	  IFS=$save_ifs
           func_quote_for_eval "$flag"
 	  func_append arg " $wl$func_quote_for_eval_result"
 	  func_append compiler_flags " $wl$func_quote_for_eval_result"
 	  func_append linker_flags " $func_quote_for_eval_result"
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 	func_stripname ' ' '' "$arg"
 	arg=$func_stripname_result
 	;;
@@ -5835,7 +7255,7 @@ func_mode_link ()
       # -msg_* for osf cc
       -msg_*)
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       # Flags to be passed through unchanged, with rationale:
@@ -5847,25 +7267,49 @@ func_mode_link ()
       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
       # -F/path              path to uninstalled frameworks, gcc on darwin
       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
+      # -fstack-protector*   stack protector flags for GCC
       # @file                GCC response files
       # -tp=*                Portland pgcc target processor selection
       # --sysroot=*          for sysroot support
-      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+      # -specs=*             GCC specs files
+      # -stdlib=*            select c++ std lib with clang
+      # -fsanitize=*         Clang/GCC memory and address sanitizer
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
+      -specs=*|-fsanitize=*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
         func_append finalize_command " $arg"
         func_append compiler_flags " $arg"
         continue
         ;;
 
+      -Z*)
+        if test os2 = "`expr $host : '.*\(os2\)'`"; then
+          # OS/2 uses -Zxxx to specify OS/2-specific options
+	  compiler_flags="$compiler_flags $arg"
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  case $arg in
+	  -Zlinker | -Zstack)
+	    prev=xcompiler
+	    ;;
+	  esac
+	  continue
+        else
+	  # Otherwise treat like 'Some other compiler flag' below
+	  func_quote_for_eval "$arg"
+	  arg=$func_quote_for_eval_result
+        fi
+	;;
+
       # Some other compiler flag.
       -* | +*)
         func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
 
       *.$objext)
@@ -5886,21 +7330,21 @@ func_mode_link ()
 
 	  if test -z "$pic_object" ||
 	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none &&
-	     test "$non_pic_object" = none; then
-	    func_fatal_error "cannot find name of object for \`$arg'"
+	     test none = "$pic_object" &&
+	     test none = "$non_pic_object"; then
+	    func_fatal_error "cannot find name of object for '$arg'"
 	  fi
 
 	  # Extract subdirectory from the argument.
 	  func_dirname "$arg" "/" ""
-	  xdir="$func_dirname_result"
+	  xdir=$func_dirname_result
 
-	  if test "$pic_object" != none; then
+	  test none = "$pic_object" || {
 	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
+	    pic_object=$xdir$pic_object
 
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+	    if test dlfiles = "$prev"; then
+	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
 		func_append dlfiles " $pic_object"
 		prev=
 		continue
@@ -5911,7 +7355,7 @@ func_mode_link ()
 	    fi
 
 	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
+	    if test dlprefiles = "$prev"; then
 	      # Preload the old-style object.
 	      func_append dlprefiles " $pic_object"
 	      prev=
@@ -5919,23 +7363,23 @@ func_mode_link ()
 
 	    # A PIC object.
 	    func_append libobjs " $pic_object"
-	    arg="$pic_object"
-	  fi
+	    arg=$pic_object
+	  }
 
 	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
+	  if test none != "$non_pic_object"; then
 	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
+	    non_pic_object=$xdir$non_pic_object
 
 	    # A standard non-PIC object
 	    func_append non_pic_objects " $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
+	    if test -z "$pic_object" || test none = "$pic_object"; then
+	      arg=$non_pic_object
 	    fi
 	  else
 	    # If the PIC object exists, use it instead.
 	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
+	    non_pic_object=$pic_object
 	    func_append non_pic_objects " $non_pic_object"
 	  fi
 	else
@@ -5943,7 +7387,7 @@ func_mode_link ()
 	  if $opt_dry_run; then
 	    # Extract subdirectory from the argument.
 	    func_dirname "$arg" "/" ""
-	    xdir="$func_dirname_result"
+	    xdir=$func_dirname_result
 
 	    func_lo2o "$arg"
 	    pic_object=$xdir$objdir/$func_lo2o_result
@@ -5951,7 +7395,7 @@ func_mode_link ()
 	    func_append libobjs " $pic_object"
 	    func_append non_pic_objects " $non_pic_object"
 	  else
-	    func_fatal_error "\`$arg' is not a valid libtool object"
+	    func_fatal_error "'$arg' is not a valid libtool object"
 	  fi
 	fi
 	;;
@@ -5967,11 +7411,11 @@ func_mode_link ()
 	# A libtool-controlled library.
 
 	func_resolve_sysroot "$arg"
-	if test "$prev" = dlfiles; then
+	if test dlfiles = "$prev"; then
 	  # This library was specified with -dlopen.
 	  func_append dlfiles " $func_resolve_sysroot_result"
 	  prev=
-	elif test "$prev" = dlprefiles; then
+	elif test dlprefiles = "$prev"; then
 	  # The library was specified with -dlpreopen.
 	  func_append dlprefiles " $func_resolve_sysroot_result"
 	  prev=
@@ -5986,7 +7430,7 @@ func_mode_link ()
 	# Unknown arguments in both finalize_command and compile_command need
 	# to be aesthetically quoted because they are evaled later.
 	func_quote_for_eval "$arg"
-	arg="$func_quote_for_eval_result"
+	arg=$func_quote_for_eval_result
 	;;
       esac # arg
 
@@ -5998,9 +7442,9 @@ func_mode_link ()
     done # argument parsing loop
 
     test -n "$prev" && \
-      func_fatal_help "the \`$prevarg' option requires an argument"
+      func_fatal_help "the '$prevarg' option requires an argument"
 
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+    if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
       eval arg=\"$export_dynamic_flag_spec\"
       func_append compile_command " $arg"
       func_append finalize_command " $arg"
@@ -6009,20 +7453,23 @@ func_mode_link ()
     oldlibs=
     # calculate the name of the file, without its directory
     func_basename "$output"
-    outputname="$func_basename_result"
-    libobjs_save="$libobjs"
+    outputname=$func_basename_result
+    libobjs_save=$libobjs
 
     if test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
     else
       shlib_search_path=
     fi
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    # Definition is injected by LT_CONFIG during libtool generation.
+    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
-    output_objdir="$func_dirname_result$objdir"
+    output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
     tool_output_objdir=$func_to_tool_file_result
     # Create the object directory.
@@ -6045,7 +7492,7 @@ func_mode_link ()
     # Find all interdependent deplibs by searching for libraries
     # that are linked more than once (e.g. -la -lb -la)
     for deplib in $deplibs; do
-      if $opt_preserve_dup_deps ; then
+      if $opt_preserve_dup_deps; then
 	case "$libs " in
 	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	esac
@@ -6053,7 +7500,7 @@ func_mode_link ()
       func_append libs " $deplib"
     done
 
-    if test "$linkmode" = lib; then
+    if test lib = "$linkmode"; then
       libs="$predeps $libs $compiler_lib_search_path $postdeps"
 
       # Compute libraries that are listed more than once in $predeps
@@ -6085,7 +7532,7 @@ func_mode_link ()
 	  case $file in
 	  *.la) ;;
 	  *)
-	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
 	    ;;
 	  esac
 	done
@@ -6093,7 +7540,7 @@ func_mode_link ()
     prog)
 	compile_deplibs=
 	finalize_deplibs=
-	alldeplibs=no
+	alldeplibs=false
 	newdlfiles=
 	newdlprefiles=
 	passes="conv scan dlopen dlpreopen link"
@@ -6105,32 +7552,32 @@ func_mode_link ()
     for pass in $passes; do
       # The preopen pass in lib mode reverses $deplibs; put it back here
       # so that -L comes before libs that need it for instance...
-      if test "$linkmode,$pass" = "lib,link"; then
+      if test lib,link = "$linkmode,$pass"; then
 	## FIXME: Find the place where the list is rebuilt in the wrong
 	##        order, and fix it there properly
         tmp_deplibs=
 	for deplib in $deplibs; do
 	  tmp_deplibs="$deplib $tmp_deplibs"
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
       fi
 
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
+      if test lib,link = "$linkmode,$pass" ||
+	 test prog,scan = "$linkmode,$pass"; then
+	libs=$deplibs
 	deplibs=
       fi
-      if test "$linkmode" = prog; then
+      if test prog = "$linkmode"; then
 	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
+	dlopen) libs=$dlfiles ;;
+	dlpreopen) libs=$dlprefiles ;;
 	link)
 	  libs="$deplibs %DEPLIBS%"
 	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
 	  ;;
 	esac
       fi
-      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+      if test lib,dlpreopen = "$linkmode,$pass"; then
 	# Collect and forward deplibs of preopened libtool libs
 	for lib in $dlprefiles; do
 	  # Ignore non-libtool-libs
@@ -6151,26 +7598,26 @@ func_mode_link ()
 	    esac
 	  done
 	done
-	libs="$dlprefiles"
+	libs=$dlprefiles
       fi
-      if test "$pass" = dlopen; then
+      if test dlopen = "$pass"; then
 	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
+	save_deplibs=$deplibs
 	deplibs=
       fi
 
       for deplib in $libs; do
 	lib=
-	found=no
+	found=false
 	case $deplib in
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    func_append compiler_flags " $deplib"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6180,13 +7627,13 @@ func_mode_link ()
 	  continue
 	  ;;
 	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    func_warning "\`-l' is ignored for archives/objects"
+	  if test lib != "$linkmode" && test prog != "$linkmode"; then
+	    func_warning "'-l' is ignored for archives/objects"
 	    continue
 	  fi
 	  func_stripname '-l' '' "$deplib"
 	  name=$func_stripname_result
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
 	  else
 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
@@ -6194,31 +7641,22 @@ func_mode_link ()
 	  for searchdir in $searchdirs; do
 	    for search_ext in .la $std_shrext .so .a; do
 	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
+	      lib=$searchdir/lib$name$search_ext
 	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
+		if test .la = "$search_ext"; then
+		  found=:
 		else
-		  found=no
+		  found=false
 		fi
 		break 2
 	      fi
 	    done
 	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
+	  if $found; then
+	    # deplib is a libtool library
 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
 	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 	      case " $predeps $postdeps " in
 	      *" $deplib "*)
 		if func_lalib_p "$lib"; then
@@ -6226,19 +7664,19 @@ func_mode_link ()
 		  old_library=
 		  func_source "$lib"
 		  for l in $old_library $library_names; do
-		    ll="$l"
+		    ll=$l
 		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
+		  if test "X$ll" = "X$old_library"; then # only static version available
+		    found=false
 		    func_dirname "$lib" "" "."
-		    ladir="$func_dirname_result"
+		    ladir=$func_dirname_result
 		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
+		    if test prog,link = "$linkmode,$pass"; then
 		      compile_deplibs="$deplib $compile_deplibs"
 		      finalize_deplibs="$deplib $finalize_deplibs"
 		    else
 		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
 		    fi
 		    continue
 		  fi
@@ -6247,15 +7685,25 @@ func_mode_link ()
 	      *) ;;
 	      esac
 	    fi
+	  else
+	    # deplib doesn't seem to be a libtool library
+	    if test prog,link = "$linkmode,$pass"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
 	  fi
 	  ;; # -l
 	*.ltframework)
-	  if test "$linkmode,$pass" = "prog,link"; then
+	  if test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$deplib $compile_deplibs"
 	    finalize_deplibs="$deplib $finalize_deplibs"
 	  else
 	    deplibs="$deplib $deplibs"
-	    if test "$linkmode" = lib ; then
+	    if test lib = "$linkmode"; then
 		case "$new_inherited_linker_flags " in
 		    *" $deplib "*) ;;
 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
@@ -6268,18 +7716,18 @@ func_mode_link ()
 	  case $linkmode in
 	  lib)
 	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
+	    test conv = "$pass" && continue
 	    newdependency_libs="$deplib $newdependency_libs"
 	    func_stripname '-L' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  prog)
-	    if test "$pass" = conv; then
+	    if test conv = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	      continue
 	    fi
-	    if test "$pass" = scan; then
+	    if test scan = "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6290,13 +7738,13 @@ func_mode_link ()
 	    func_append newlib_search_path " $func_resolve_sysroot_result"
 	    ;;
 	  *)
-	    func_warning "\`-L' is ignored for archives/objects"
+	    func_warning "'-L' is ignored for archives/objects"
 	    ;;
 	  esac # linkmode
 	  continue
 	  ;; # -L
 	-R*)
-	  if test "$pass" = link; then
+	  if test link = "$pass"; then
 	    func_stripname '-R' '' "$deplib"
 	    func_resolve_sysroot "$func_stripname_result"
 	    dir=$func_resolve_sysroot_result
@@ -6314,7 +7762,7 @@ func_mode_link ()
 	  lib=$func_resolve_sysroot_result
 	  ;;
 	*.$libext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
 	    continue
 	  fi
@@ -6325,21 +7773,26 @@ func_mode_link ()
 	    case " $dlpreconveniencelibs " in
 	    *" $deplib "*) ;;
 	    *)
-	      valid_a_lib=no
+	      valid_a_lib=false
 	      case $deplibs_check_method in
 		match_pattern*)
 		  set dummy $deplibs_check_method; shift
 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
 		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
 		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		    valid_a_lib=yes
+		    valid_a_lib=:
 		  fi
 		;;
 		pass_all)
-		  valid_a_lib=yes
+		  valid_a_lib=:
 		;;
 	      esac
-	      if test "$valid_a_lib" != yes; then
+	      if $valid_a_lib; then
+		echo
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      else
 		echo
 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
 		echo "*** I have the capability to make that library automatically link in when"
@@ -6347,18 +7800,13 @@ func_mode_link ()
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because the file extensions .$libext of this argument makes me believe"
 		echo "*** that it is just a static archive that I should not use here."
-	      else
-		echo
-		$ECHO "*** Warning: Linking the shared library $output against the"
-		$ECHO "*** static library $deplib is not portable!"
-		deplibs="$deplib $deplibs"
 	      fi
 	      ;;
 	    esac
 	    continue
 	    ;;
 	  prog)
-	    if test "$pass" != link; then
+	    if test link != "$pass"; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      compile_deplibs="$deplib $compile_deplibs"
@@ -6369,10 +7817,10 @@ func_mode_link ()
 	  esac # linkmode
 	  ;; # *.$libext
 	*.lo | *.$objext)
-	  if test "$pass" = conv; then
+	  if test conv = "$pass"; then
 	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	  elif test prog = "$linkmode"; then
+	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
 	      # If there is no dlopen support or we're linking statically,
 	      # we need to preload.
 	      func_append newdlprefiles " $deplib"
@@ -6385,22 +7833,20 @@ func_mode_link ()
 	  continue
 	  ;;
 	%DEPLIBS%)
-	  alldeplibs=yes
+	  alldeplibs=:
 	  continue
 	  ;;
 	esac # case $deplib
 
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
-	fi
+	$found || test -f "$lib" \
+	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
 
 	# Check to see that this really is a libtool archive.
 	func_lalib_unsafe_p "$lib" \
-	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+	  || func_fatal_error "'$lib' is not a valid libtool archive"
 
 	func_dirname "$lib" "" "."
-	ladir="$func_dirname_result"
+	ladir=$func_dirname_result
 
 	dlname=
 	dlopen=
@@ -6430,19 +7876,19 @@ func_mode_link ()
 	  done
 	fi
 	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	if test lib,link = "$linkmode,$pass" ||
+	   test prog,scan = "$linkmode,$pass" ||
+	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
 	  test -n "$dlopen" && func_append dlfiles " $dlopen"
 	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
 	fi
 
-	if test "$pass" = conv; then
+	if test conv = "$pass"; then
 	  # Only check for convenience libraries
 	  deplibs="$lib $deplibs"
 	  if test -z "$libdir"; then
 	    if test -z "$old_library"; then
-	      func_fatal_error "cannot find name of link library for \`$lib'"
+	      func_fatal_error "cannot find name of link library for '$lib'"
 	    fi
 	    # It is a libtool convenience library, so add in its objects.
 	    func_append convenience " $ladir/$objdir/$old_library"
@@ -6450,15 +7896,15 @@ func_mode_link ()
 	    tmp_libs=
 	    for deplib in $dependency_libs; do
 	      deplibs="$deplib $deplibs"
-	      if $opt_preserve_dup_deps ; then
+	      if $opt_preserve_dup_deps; then
 		case "$tmp_libs " in
 		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
 		esac
 	      fi
 	      func_append tmp_libs " $deplib"
 	    done
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    func_fatal_error "\`$lib' is not a convenience library"
+	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
+	    func_fatal_error "'$lib' is not a convenience library"
 	  fi
 	  continue
 	fi # $pass = conv
@@ -6467,26 +7913,26 @@ func_mode_link ()
 	# Get the name of the library we link against.
 	linklib=
 	if test -n "$old_library" &&
-	   { test "$prefer_static_libs" = yes ||
-	     test "$prefer_static_libs,$installed" = "built,no"; }; then
+	   { test yes = "$prefer_static_libs" ||
+	     test built,no = "$prefer_static_libs,$installed"; }; then
 	  linklib=$old_library
 	else
 	  for l in $old_library $library_names; do
-	    linklib="$l"
+	    linklib=$l
 	  done
 	fi
 	if test -z "$linklib"; then
-	  func_fatal_error "cannot find name of link library for \`$lib'"
+	  func_fatal_error "cannot find name of link library for '$lib'"
 	fi
 
 	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
-	  fi
+	if test dlopen = "$pass"; then
+	  test -z "$libdir" \
+	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
 	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
+	     test yes != "$dlopen_support" ||
+	     test no = "$build_libtool_libs"
+	  then
 	    # If there is no dlname, no dlopen support or we're linking
 	    # statically, we need to preload.  We also need to preload any
 	    # dependent libraries so libltdl's deplib preloader doesn't
@@ -6500,40 +7946,40 @@ func_mode_link ()
 
 	# We need an absolute path.
 	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
 	*)
 	  abs_ladir=`cd "$ladir" && pwd`
 	  if test -z "$abs_ladir"; then
-	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "cannot determine absolute directory name of '$ladir'"
 	    func_warning "passing it literally to the linker, although it might fail"
-	    abs_ladir="$ladir"
+	    abs_ladir=$ladir
 	  fi
 	  ;;
 	esac
 	func_basename "$lib"
-	laname="$func_basename_result"
+	laname=$func_basename_result
 
 	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
+	if test yes = "$installed"; then
 	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    func_warning "library \`$lib' was moved."
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
+	    func_warning "library '$lib' was moved."
+	    dir=$ladir
+	    absdir=$abs_ladir
+	    libdir=$abs_ladir
 	  else
-	    dir="$lt_sysroot$libdir"
-	    absdir="$lt_sysroot$libdir"
+	    dir=$lt_sysroot$libdir
+	    absdir=$lt_sysroot$libdir
 	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
 	else
 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
+	    dir=$ladir
+	    absdir=$abs_ladir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
+	    dir=$ladir/$objdir
+	    absdir=$abs_ladir/$objdir
 	    # Remove this search path later
 	    func_append notinst_path " $abs_ladir"
 	  fi
@@ -6542,11 +7988,11 @@ func_mode_link ()
 	name=$func_stripname_result
 
 	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir" && test "$linkmode" = prog; then
-	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	if test dlpreopen = "$pass"; then
+	  if test -z "$libdir" && test prog = "$linkmode"; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
 	  fi
-	  case "$host" in
+	  case $host in
 	    # special handling for platforms with PE-DLLs.
 	    *cygwin* | *mingw* | *cegcc* )
 	      # Linker will automatically link against shared library if both
@@ -6590,9 +8036,9 @@ func_mode_link ()
 
 	if test -z "$libdir"; then
 	  # Link the convenience library
-	  if test "$linkmode" = lib; then
+	  if test lib = "$linkmode"; then
 	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
+	  elif test prog,link = "$linkmode,$pass"; then
 	    compile_deplibs="$dir/$old_library $compile_deplibs"
 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
 	  else
@@ -6602,14 +8048,14 @@ func_mode_link ()
 	fi
 
 
-	if test "$linkmode" = prog && test "$pass" != link; then
+	if test prog = "$linkmode" && test link != "$pass"; then
 	  func_append newlib_search_path " $ladir"
 	  deplibs="$lib $deplibs"
 
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
+	  linkalldeplibs=false
+	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
+	     test no = "$build_libtool_libs"; then
+	    linkalldeplibs=:
 	  fi
 
 	  tmp_libs=
@@ -6621,14 +8067,14 @@ func_mode_link ()
 		 ;;
 	    esac
 	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
+	    if $linkalldeplibs; then
 	      deplibs="$deplib $deplibs"
 	    else
 	      # Need to hardcode shared library paths
 	      # or/and link against static libraries
 	      newdependency_libs="$deplib $newdependency_libs"
 	    fi
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
 	      esac
@@ -6638,15 +8084,15 @@ func_mode_link ()
 	  continue
 	fi # $linkmode = prog...
 
-	if test "$linkmode,$pass" = "prog,link"; then
+	if test prog,link = "$linkmode,$pass"; then
 	  if test -n "$library_names" &&
-	     { { test "$prefer_static_libs" = no ||
-	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	     { { test no = "$prefer_static_libs" ||
+	         test built,yes = "$prefer_static_libs,$installed"; } ||
 	       test -z "$old_library"; }; then
 	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath:" in
+	      case $temp_rpath: in
 	      *"$absdir:"*) ;;
 	      *) func_append temp_rpath "$absdir:" ;;
 	      esac
@@ -6675,9 +8121,9 @@ func_mode_link ()
 	    esac
 	  fi # $linkmode,$pass = prog,link...
 
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
+	  if $alldeplibs &&
+	     { test pass_all = "$deplibs_check_method" ||
+	       { test yes = "$build_libtool_libs" &&
 		 test -n "$library_names"; }; }; then
 	    # We only need to search for static libraries
 	    continue
@@ -6686,19 +8132,19 @@ func_mode_link ()
 
 	link_static=no # Whether the deplib will be linked statically
 	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes; then
+	if test built = "$use_static_libs" && test yes = "$installed"; then
 	  use_static_libs=no
 	fi
 	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
 	  case $host in
-	  *cygwin* | *mingw* | *cegcc*)
+	  *cygwin* | *mingw* | *cegcc* | *os2*)
 	      # No point in relinking DLLs because paths are not encoded
 	      func_append notinst_deplibs " $lib"
 	      need_relink=no
 	    ;;
 	  *)
-	    if test "$installed" = no; then
+	    if test no = "$installed"; then
 	      func_append notinst_deplibs " $lib"
 	      need_relink=yes
 	    fi
@@ -6708,24 +8154,24 @@ func_mode_link ()
 
 	  # Warn about portability, can't link against -module's on some
 	  # systems (darwin).  Don't bleat about dlopened modules though!
-	  dlopenmodule=""
+	  dlopenmodule=
 	  for dlpremoduletest in $dlprefiles; do
 	    if test "X$dlpremoduletest" = "X$lib"; then
-	      dlopenmodule="$dlpremoduletest"
+	      dlopenmodule=$dlpremoduletest
 	      break
 	    fi
 	  done
-	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
 	    echo
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
 	    else
 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
 	    fi
 	    $ECHO "*** $linklib is not portable!"
 	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
+	  if test lib = "$linkmode" &&
+	     test yes = "$hardcode_into_libs"; then
 	    # Hardcode the library path.
 	    # Skip directories that are in the system default run-time
 	    # search path.
@@ -6753,43 +8199,43 @@ func_mode_link ()
 	    # figure out the soname
 	    set dummy $library_names
 	    shift
-	    realname="$1"
+	    realname=$1
 	    shift
 	    libname=`eval "\\$ECHO \"$libname_spec\""`
 	    # use dlname if we got it. it's perfectly good, no?
 	    if test -n "$dlname"; then
-	      soname="$dlname"
+	      soname=$dlname
 	    elif test -n "$soname_spec"; then
 	      # bleh windows
 	      case $host in
-	      *cygwin* | mingw* | *cegcc*)
+	      *cygwin* | mingw* | *cegcc* | *os2*)
 	        func_arith $current - $age
 		major=$func_arith_result
-		versuffix="-$major"
+		versuffix=-$major
 		;;
 	      esac
 	      eval soname=\"$soname_spec\"
 	    else
-	      soname="$realname"
+	      soname=$realname
 	    fi
 
 	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
+	    soroot=$soname
 	    func_basename "$soroot"
-	    soname="$func_basename_result"
+	    soname=$func_basename_result
 	    func_stripname 'lib' '.dll' "$soname"
 	    newlib=libimp-$func_stripname_result.a
 
 	    # If the library has no export list, then create one now
 	    if test -f "$output_objdir/$soname-def"; then :
 	    else
-	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_verbose "extracting exported symbol list from '$soname'"
 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
 	    fi
 
 	    # Create $newlib
 	    if test -f "$output_objdir/$newlib"; then :; else
-	      func_verbose "generating import library for \`$soname'"
+	      func_verbose "generating import library for '$soname'"
 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
 	    fi
 	    # make sure the library variables are pointing to the new library
@@ -6797,58 +8243,58 @@ func_mode_link ()
 	    linklib=$newlib
 	  fi # test -n "$old_archive_from_expsyms_cmds"
 
-	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
+	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    lib_linked=yes
 	    case $hardcode_action in
 	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
+	      if test no = "$hardcode_direct"; then
+		add=$dir/$linklib
 		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
+		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
+		    *-*-unixware7*) add_dir=-L$dir ;;
 		  *-*-darwin* )
-		    # if the lib is a (non-dlopened) module then we can not
+		    # if the lib is a (non-dlopened) module then we cannot
 		    # link against it, someone is ignoring the earlier warnings
 		    if /usr/bin/file -L $add 2> /dev/null |
-			 $GREP ": [^:]* bundle" >/dev/null ; then
+			 $GREP ": [^:]* bundle" >/dev/null; then
 		      if test "X$dlopenmodule" != "X$lib"; then
 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
-			if test -z "$old_library" ; then
+			if test -z "$old_library"; then
 			  echo
 			  echo "*** And there doesn't seem to be a static archive available"
 			  echo "*** The link will probably fail, sorry"
 			else
-			  add="$dir/$old_library"
+			  add=$dir/$old_library
 			fi
 		      elif test -n "$old_library"; then
-			add="$dir/$old_library"
+			add=$dir/$old_library
 		      fi
 		    fi
 		esac
-	      elif test "$hardcode_minus_L" = no; then
+	      elif test no = "$hardcode_minus_L"; then
 		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
+		*-*-sunos*) add_shlibpath=$dir ;;
 		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add_dir=-L$dir
+		add=-l$name
+	      elif test no = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
 	      ;;
 	    relink)
-	      if test "$hardcode_direct" = yes &&
-	         test "$hardcode_direct_absolute" = no; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$absdir"
+	      if test yes = "$hardcode_direct" &&
+	         test no = "$hardcode_direct_absolute"; then
+		add=$dir/$linklib
+	      elif test yes = "$hardcode_minus_L"; then
+		add_dir=-L$absdir
 		# Try looking first in the location we're being installed to.
 		if test -n "$inst_prefix_dir"; then
 		  case $libdir in
@@ -6857,10 +8303,10 @@ func_mode_link ()
 		      ;;
 		  esac
 		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
+		add=-l$name
+	      elif test yes = "$hardcode_shlibpath_var"; then
+		add_shlibpath=$dir
+		add=-l$name
 	      else
 		lib_linked=no
 	      fi
@@ -6868,7 +8314,7 @@ func_mode_link ()
 	    *) lib_linked=no ;;
 	    esac
 
-	    if test "$lib_linked" != yes; then
+	    if test yes != "$lib_linked"; then
 	      func_fatal_configuration "unsupported hardcode properties"
 	    fi
 
@@ -6878,15 +8324,15 @@ func_mode_link ()
 	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
 	      esac
 	    fi
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
 	    else
 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
 	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes &&
-		 test "$hardcode_minus_L" != yes &&
-		 test "$hardcode_shlibpath_var" = yes; then
+	      if test yes != "$hardcode_direct" &&
+		 test yes != "$hardcode_minus_L" &&
+		 test yes = "$hardcode_shlibpath_var"; then
 		case :$finalize_shlibpath: in
 		*":$libdir:"*) ;;
 		*) func_append finalize_shlibpath "$libdir:" ;;
@@ -6895,33 +8341,33 @@ func_mode_link ()
 	    fi
 	  fi
 
-	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
+	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
 	    add_shlibpath=
 	    add_dir=
 	    add=
 	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes &&
-	       test "$hardcode_direct_absolute" = no; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
+	    if test yes = "$hardcode_direct" &&
+	       test no = "$hardcode_direct_absolute"; then
+	      add=$libdir/$linklib
+	    elif test yes = "$hardcode_minus_L"; then
+	      add_dir=-L$libdir
+	      add=-l$name
+	    elif test yes = "$hardcode_shlibpath_var"; then
 	      case :$finalize_shlibpath: in
 	      *":$libdir:"*) ;;
 	      *) func_append finalize_shlibpath "$libdir:" ;;
 	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
+	      add=-l$name
+	    elif test yes = "$hardcode_automatic"; then
 	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-		add="$inst_prefix_dir$libdir/$linklib"
+		 test -f "$inst_prefix_dir$libdir/$linklib"; then
+		add=$inst_prefix_dir$libdir/$linklib
 	      else
-		add="$libdir/$linklib"
+		add=$libdir/$linklib
 	      fi
 	    else
 	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
+	      add_dir=-L$libdir
 	      # Try looking first in the location we're being installed to.
 	      if test -n "$inst_prefix_dir"; then
 		case $libdir in
@@ -6930,10 +8376,10 @@ func_mode_link ()
 		    ;;
 		esac
 	      fi
-	      add="-l$name"
+	      add=-l$name
 	    fi
 
-	    if test "$linkmode" = prog; then
+	    if test prog = "$linkmode"; then
 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
 	    else
@@ -6941,43 +8387,43 @@ func_mode_link ()
 	      test -n "$add" && deplibs="$add $deplibs"
 	    fi
 	  fi
-	elif test "$linkmode" = prog; then
+	elif test prog = "$linkmode"; then
 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
 	  # is not unsupported.  This is valid on all known static and
 	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
+	  if test unsupported != "$hardcode_direct"; then
+	    test -n "$old_library" && linklib=$old_library
 	    compile_deplibs="$dir/$linklib $compile_deplibs"
 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
 	  else
 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
 	  fi
-	elif test "$build_libtool_libs" = yes; then
+	elif test yes = "$build_libtool_libs"; then
 	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
+	  if test pass_all != "$deplibs_check_method"; then
 	    # We're trying link a shared library against a static one
 	    # but the system doesn't support it.
 
 	    # Just print a warning and add the library to dependency_libs so
 	    # that the program can be linked against the static library.
 	    echo
-	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
 	    echo "*** I have the capability to make that library automatically link in when"
 	    echo "*** you link to this library.  But I can only do this if you have a"
 	    echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
+	    if test yes = "$module"; then
 	      echo "*** But as you try to build a module library, libtool will still create "
 	      echo "*** a static module, that should work as long as the dlopening application"
 	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
 	      if test -z "$global_symbol_pipe"; then
 		echo
 		echo "*** However, this would only work if libtool was able to extract symbol"
-		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 		echo "*** not find such a program.  So, this module is probably useless."
-		echo "*** \`nm' from GNU binutils and a full rebuild may help."
+		echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	      fi
-	      if test "$build_old_libs" = no; then
+	      if test no = "$build_old_libs"; then
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -6990,11 +8436,11 @@ func_mode_link ()
 	  fi
 	fi # link shared/static library?
 
-	if test "$linkmode" = lib; then
+	if test lib = "$linkmode"; then
 	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
+	     { test yes != "$hardcode_into_libs" ||
+	       test yes = "$build_old_libs" ||
+	       test yes = "$link_static"; }; then
 	    # Extract -R from dependency_libs
 	    temp_deplibs=
 	    for libdir in $dependency_libs; do
@@ -7008,12 +8454,12 @@ func_mode_link ()
 	      *) func_append temp_deplibs " $libdir";;
 	      esac
 	    done
-	    dependency_libs="$temp_deplibs"
+	    dependency_libs=$temp_deplibs
 	  fi
 
 	  func_append newlib_search_path " $absdir"
 	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
 	  # ... and its dependency_libs
 	  tmp_libs=
 	  for deplib in $dependency_libs; do
@@ -7023,7 +8469,7 @@ func_mode_link ()
                    func_resolve_sysroot "$func_stripname_result";;
               *) func_resolve_sysroot "$deplib" ;;
             esac
-	    if $opt_preserve_dup_deps ; then
+	    if $opt_preserve_dup_deps; then
 	      case "$tmp_libs " in
 	      *" $func_resolve_sysroot_result "*)
                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
@@ -7032,12 +8478,12 @@ func_mode_link ()
 	    func_append tmp_libs " $func_resolve_sysroot_result"
 	  done
 
-	  if test "$link_all_deplibs" != no; then
+	  if test no != "$link_all_deplibs"; then
 	    # Add the search paths of all dependency libraries
 	    for deplib in $dependency_libs; do
 	      path=
 	      case $deplib in
-	      -L*) path="$deplib" ;;
+	      -L*) path=$deplib ;;
 	      *.la)
 	        func_resolve_sysroot "$deplib"
 	        deplib=$func_resolve_sysroot_result
@@ -7045,12 +8491,12 @@ func_mode_link ()
 		dir=$func_dirname_result
 		# We need an absolute path.
 		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
 		*)
 		  absdir=`cd "$dir" && pwd`
 		  if test -z "$absdir"; then
-		    func_warning "cannot determine absolute directory name of \`$dir'"
-		    absdir="$dir"
+		    func_warning "cannot determine absolute directory name of '$dir'"
+		    absdir=$dir
 		  fi
 		  ;;
 		esac
@@ -7058,35 +8504,35 @@ func_mode_link ()
 		case $host in
 		*-*-darwin*)
 		  depdepl=
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
+		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names"; then
+		    for tmp in $deplibrary_names; do
 		      depdepl=$tmp
 		    done
-		    if test -f "$absdir/$objdir/$depdepl" ; then
-		      depdepl="$absdir/$objdir/$depdepl"
-		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+		    if test -f "$absdir/$objdir/$depdepl"; then
+		      depdepl=$absdir/$objdir/$depdepl
+		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
                       if test -z "$darwin_install_name"; then
-                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                          darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
                       fi
-		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
-		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
+		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
 		      path=
 		    fi
 		  fi
 		  ;;
 		*)
-		  path="-L$absdir/$objdir"
+		  path=-L$absdir/$objdir
 		  ;;
 		esac
 		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
 		  test -z "$libdir" && \
-		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		    func_fatal_error "'$deplib' is not a valid libtool archive"
 		  test "$absdir" != "$libdir" && \
-		    func_warning "\`$deplib' seems to be moved"
+		    func_warning "'$deplib' seems to be moved"
 
-		  path="-L$absdir"
+		  path=-L$absdir
 		fi
 		;;
 	      esac
@@ -7098,23 +8544,23 @@ func_mode_link ()
 	  fi # link_all_deplibs != no
 	fi # linkmode = lib
       done # for deplib in $libs
-      if test "$pass" = link; then
-	if test "$linkmode" = "prog"; then
+      if test link = "$pass"; then
+	if test prog = "$linkmode"; then
 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
 	else
 	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
 	fi
       fi
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
+      dependency_libs=$newdependency_libs
+      if test dlpreopen = "$pass"; then
 	# Link the dlpreopened libraries before other libraries
 	for deplib in $save_deplibs; do
 	  deplibs="$deplib $deplibs"
 	done
       fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
+      if test dlopen != "$pass"; then
+	test conv = "$pass" || {
 	  # Make sure lib_search_path contains only unique directories.
 	  lib_search_path=
 	  for dir in $newlib_search_path; do
@@ -7124,12 +8570,12 @@ func_mode_link ()
 	    esac
 	  done
 	  newlib_search_path=
-	fi
+	}
 
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
+	if test prog,link = "$linkmode,$pass"; then
 	  vars="compile_deplibs finalize_deplibs"
+	else
+	  vars=deplibs
 	fi
 	for var in $vars dependency_libs; do
 	  # Add libraries to $var in reverse order
@@ -7187,62 +8633,93 @@ func_mode_link ()
 	  eval $var=\"$tmp_libs\"
 	done # for var
       fi
+
+      # Add Sun CC postdeps if required:
+      test CXX = "$tagname" && {
+        case $host_os in
+        linux*)
+          case `$CC -V 2>&1 | sed 5q` in
+          *Sun\ C*) # Sun C++ 5.9
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+
+        solaris*)
+          func_cc_basename "$CC"
+          case $func_cc_basename_result in
+          CC* | sunCC*)
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+        esac
+      }
+
       # Last step: remove runtime libs from dependency_libs
       # (they stay in deplibs)
       tmp_libs=
-      for i in $dependency_libs ; do
+      for i in $dependency_libs; do
 	case " $predeps $postdeps $compiler_lib_search_path " in
 	*" $i "*)
-	  i=""
+	  i=
 	  ;;
 	esac
-	if test -n "$i" ; then
+	if test -n "$i"; then
 	  func_append tmp_libs " $i"
 	fi
       done
       dependency_libs=$tmp_libs
     done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
+    if test prog = "$linkmode"; then
+      dlfiles=$newdlfiles
     fi
-    if test "$linkmode" = prog || test "$linkmode" = lib; then
-      dlprefiles="$newdlprefiles"
+    if test prog = "$linkmode" || test lib = "$linkmode"; then
+      dlprefiles=$newdlprefiles
     fi
 
     case $linkmode in
     oldlib)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for archives"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for archives"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+	func_warning "'-l' and '-L' are ignored for archives" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for archives"
+	func_warning "'-rpath' is ignored for archives"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for archives"
+	func_warning "'-R' is ignored for archives"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info/-version-number' is ignored for archives"
+	func_warning "'-version-info/-version-number' is ignored for archives"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for archives"
+	func_warning "'-release' is ignored for archives"
 
       test -n "$export_symbols$export_symbols_regex" && \
-	func_warning "\`-export-symbols' is ignored for archives"
+	func_warning "'-export-symbols' is ignored for archives"
 
       # Now set the variables for building old libraries.
       build_libtool_libs=no
-      oldlibs="$output"
+      oldlibs=$output
       func_append objs "$old_deplibs"
       ;;
 
     lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
+      # Make sure we only generate libraries of the form 'libNAME.la'.
       case $outputname in
       lib*)
 	func_stripname 'lib' '.la' "$outputname"
@@ -7251,10 +8728,10 @@ func_mode_link ()
 	eval libname=\"$libname_spec\"
 	;;
       *)
-	test "$module" = no && \
-	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+	test no = "$module" \
+	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
 
-	if test "$need_lib_prefix" != no; then
+	if test no != "$need_lib_prefix"; then
 	  # Add the "lib" prefix for modules if required
 	  func_stripname '' '.la' "$outputname"
 	  name=$func_stripname_result
@@ -7268,8 +8745,8 @@ func_mode_link ()
       esac
 
       if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	if test pass_all != "$deplibs_check_method"; then
+	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
 	else
 	  echo
 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
@@ -7278,21 +8755,21 @@ func_mode_link ()
 	fi
       fi
 
-      test "$dlself" != no && \
-	func_warning "\`-dlopen self' is ignored for libtool libraries"
+      test no = "$dlself" \
+	|| func_warning "'-dlopen self' is ignored for libtool libraries"
 
       set dummy $rpath
       shift
-      test "$#" -gt 1 && \
-	func_warning "ignoring multiple \`-rpath's for a libtool library"
+      test 1 -lt "$#" \
+	&& func_warning "ignoring multiple '-rpath's for a libtool library"
 
-      install_libdir="$1"
+      install_libdir=$1
 
       oldlibs=
       if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
+	if test yes = "$build_libtool_libs"; then
 	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
+	  # Some compilers have problems with a '.al' extension so
 	  # convenience libraries should have the same extension an
 	  # archive normally would.
 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
@@ -7301,20 +8778,20 @@ func_mode_link ()
 	fi
 
 	test -n "$vinfo" && \
-	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
 
 	test -n "$release" && \
-	  func_warning "\`-release' is ignored for convenience libraries"
+	  func_warning "'-release' is ignored for convenience libraries"
       else
 
 	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
+	save_ifs=$IFS; IFS=:
 	set dummy $vinfo 0 0 0
 	shift
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	test -n "$7" && \
-	  func_fatal_help "too many parameters to \`-version-info'"
+	  func_fatal_help "too many parameters to '-version-info'"
 
 	# convert absolute version numbers to libtool ages
 	# this retains compatibility with .la files and attempts
@@ -7322,45 +8799,45 @@ func_mode_link ()
 
 	case $vinfo_number in
 	yes)
-	  number_major="$1"
-	  number_minor="$2"
-	  number_revision="$3"
+	  number_major=$1
+	  number_minor=$2
+	  number_revision=$3
 	  #
 	  # There are really only two kinds -- those that
 	  # use the current revision as the major version
 	  # and those that subtract age and use age as
 	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
+	  # that has an extra 1 added just for fun
 	  #
 	  case $version_type in
 	  # correct linux to gnu/linux during the next big refactor
-	  darwin|linux|osf|windows|none)
+	  darwin|freebsd-elf|linux|osf|windows|none)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_revision"
+	    age=$number_minor
+	    revision=$number_revision
 	    ;;
-	  freebsd-aout|freebsd-elf|qnx|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
+	  freebsd-aout|qnx|sunos)
+	    current=$number_major
+	    revision=$number_minor
+	    age=0
 	    ;;
 	  irix|nonstopux)
 	    func_arith $number_major + $number_minor
 	    current=$func_arith_result
-	    age="$number_minor"
-	    revision="$number_minor"
+	    age=$number_minor
+	    revision=$number_minor
 	    lt_irix_increment=no
 	    ;;
 	  *)
-	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+	    func_fatal_configuration "$modename: unknown library version type '$version_type'"
 	    ;;
 	  esac
 	  ;;
 	no)
-	  current="$1"
-	  revision="$2"
-	  age="$3"
+	  current=$1
+	  revision=$2
+	  age=$3
 	  ;;
 	esac
 
@@ -7368,30 +8845,30 @@ func_mode_link ()
 	case $current in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "CURRENT \`$current' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "CURRENT '$current' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $revision in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "REVISION \`$revision' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "REVISION '$revision' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	case $age in
 	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
-	  func_error "AGE \`$age' must be a nonnegative integer"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' must be a nonnegative integer"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	  ;;
 	esac
 
 	if test "$age" -gt "$current"; then
-	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
-	  func_fatal_error "\`$vinfo' is not valid version information"
+	  func_error "AGE '$age' is greater than the current interface number '$current'"
+	  func_fatal_error "'$vinfo' is not valid version information"
 	fi
 
 	# Calculate the version variables.
@@ -7406,26 +8883,36 @@ func_mode_link ()
 	  # verstring for coding it into the library header
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  # Darwin ld doesn't like 0 for these options...
 	  func_arith $current + 1
 	  minor_current=$func_arith_result
-	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+          # On Darwin other compilers
+          case $CC in
+              nagfor*)
+                  verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
+                  ;;
+              *)
+                  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+                  ;;
+          esac
 	  ;;
 
 	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current"
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	irix | nonstopux)
-	  if test "X$lt_irix_increment" = "Xno"; then
+	  if test no = "$lt_irix_increment"; then
 	    func_arith $current - $age
 	  else
 	    func_arith $current - $age + 1
@@ -7436,69 +8923,74 @@ func_mode_link ()
 	    nonstopux) verstring_prefix=nonstopux ;;
 	    *)         verstring_prefix=sgi ;;
 	  esac
-	  verstring="$verstring_prefix$major.$revision"
+	  verstring=$verstring_prefix$major.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$revision
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $revision - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring_prefix$major.$iface:$verstring"
+	    verstring=$verstring_prefix$major.$iface:$verstring
 	  done
 
-	  # Before this point, $major must not contain `.'.
+	  # Before this point, $major must not contain '.'.
 	  major=.$major
-	  versuffix="$major.$revision"
+	  versuffix=$major.$revision
 	  ;;
 
 	linux) # correct to gnu/linux during the next big refactor
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix="$major.$age.$revision"
+	  versuffix=$major.$age.$revision
 	  ;;
 
 	osf)
 	  func_arith $current - $age
 	  major=.$func_arith_result
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
+	  versuffix=.$current.$age.$revision
+	  verstring=$current.$age.$revision
 
 	  # Add in all the interfaces that we are compatible with.
 	  loop=$age
-	  while test "$loop" -ne 0; do
+	  while test 0 -ne "$loop"; do
 	    func_arith $current - $loop
 	    iface=$func_arith_result
 	    func_arith $loop - 1
 	    loop=$func_arith_result
-	    verstring="$verstring:${iface}.0"
+	    verstring=$verstring:$iface.0
 	  done
 
 	  # Make executables depend on our current version.
-	  func_append verstring ":${current}.0"
+	  func_append verstring ":$current.0"
 	  ;;
 
 	qnx)
-	  major=".$current"
-	  versuffix=".$current"
+	  major=.$current
+	  versuffix=.$current
+	  ;;
+
+	sco)
+	  major=.$current
+	  versuffix=.$current
 	  ;;
 
 	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
+	  major=.$current
+	  versuffix=.$current.$revision
 	  ;;
 
 	windows)
 	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
+	  # extension on DOS 8.3 file systems.
 	  func_arith $current - $age
 	  major=$func_arith_result
-	  versuffix="-$major"
+	  versuffix=-$major
 	  ;;
 
 	*)
-	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  func_fatal_configuration "unknown library version type '$version_type'"
 	  ;;
 	esac
 
@@ -7512,42 +9004,45 @@ func_mode_link ()
 	    verstring=
 	    ;;
 	  *)
-	    verstring="0.0"
+	    verstring=0.0
 	    ;;
 	  esac
-	  if test "$need_version" = no; then
+	  if test no = "$need_version"; then
 	    versuffix=
 	  else
-	    versuffix=".0.0"
+	    versuffix=.0.0
 	  fi
 	fi
 
 	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
+	if test yes,no = "$avoid_version,$need_version"; then
 	  major=
 	  versuffix=
-	  verstring=""
+	  verstring=
 	fi
 
 	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    func_warning "undefined symbols not allowed in $host shared libraries"
-	    build_libtool_libs=no
-	    build_old_libs=yes
+	if test yes = "$allow_undefined"; then
+	  if test unsupported = "$allow_undefined_flag"; then
+	    if test yes = "$build_old_libs"; then
+	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
+	      build_libtool_libs=no
+	    else
+	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
+	    fi
 	  fi
 	else
 	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
+	  allow_undefined_flag=$no_undefined_flag
 	fi
 
       fi
 
-      func_generate_dlsyms "$libname" "$libname" "yes"
+      func_generate_dlsyms "$libname" "$libname" :
       func_append libobjs " $symfileobj"
-      test "X$libobjs" = "X " && libobjs=
+      test " " = "$libobjs" && libobjs=
 
-      if test "$opt_mode" != relink; then
+      if test relink != "$opt_mode"; then
 	# Remove our outputs, but don't remove object files since they
 	# may have been created when compiling PIC objects.
 	removelist=
@@ -7556,8 +9051,8 @@ func_mode_link ()
 	  case $p in
 	    *.$objext | *.gcno)
 	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
+	       if test -n "$precious_files_regex"; then
 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
 		 then
 		   continue
@@ -7573,11 +9068,11 @@ func_mode_link ()
       fi
 
       # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+      if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
 	func_append oldlibs " $output_objdir/$libname.$libext"
 
 	# Transform .lo files to .o files.
-	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
       fi
 
       # Eliminate all temporary directories.
@@ -7598,13 +9093,13 @@ func_mode_link ()
 	  *) func_append finalize_rpath " $libdir" ;;
 	  esac
 	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
 	  dependency_libs="$temp_xrpath $dependency_libs"
 	fi
       fi
 
       # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
+      old_dlfiles=$dlfiles
       dlfiles=
       for lib in $old_dlfiles; do
 	case " $dlprefiles $dlfiles " in
@@ -7614,7 +9109,7 @@ func_mode_link ()
       done
 
       # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
+      old_dlprefiles=$dlprefiles
       dlprefiles=
       for lib in $old_dlprefiles; do
 	case "$dlprefiles " in
@@ -7623,7 +9118,7 @@ func_mode_link ()
 	esac
       done
 
-      if test "$build_libtool_libs" = yes; then
+      if test yes = "$build_libtool_libs"; then
 	if test -n "$rpath"; then
 	  case $host in
 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
@@ -7647,7 +9142,7 @@ func_mode_link ()
 	    ;;
 	  *)
 	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
+	    if test yes = "$build_libtool_need_lc"; then
 	      func_append deplibs " -lc"
 	    fi
 	    ;;
@@ -7663,9 +9158,9 @@ func_mode_link ()
 	# I'm not sure if I'm treating the release correctly.  I think
 	# release should show up in the -l (ie -lgmp5) so we don't want to
 	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
+	release=
+	versuffix=
+	major=
 	newdeplibs=
 	droppeddeps=no
 	case $deplibs_check_method in
@@ -7694,20 +9189,20 @@ EOF
 	      -l*)
 		func_stripname -l '' "$i"
 		name=$func_stripname_result
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
 		    func_append newdeplibs " $i"
-		    i=""
+		    i=
 		    ;;
 		  esac
 		fi
-		if test -n "$i" ; then
+		if test -n "$i"; then
 		  libname=`eval "\\$ECHO \"$libname_spec\""`
 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		  set dummy $deplib_matches; shift
 		  deplib_match=$1
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		    func_append newdeplibs " $i"
 		  else
 		    droppeddeps=yes
@@ -7737,20 +9232,20 @@ EOF
 		$opt_dry_run || $RM conftest
 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		    case " $predeps $postdeps " in
 		    *" $i "*)
 		      func_append newdeplibs " $i"
-		      i=""
+		      i=
 		      ;;
 		    esac
 		  fi
-		  if test -n "$i" ; then
+		  if test -n "$i"; then
 		    libname=`eval "\\$ECHO \"$libname_spec\""`
 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
 		    set dummy $deplib_matches; shift
 		    deplib_match=$1
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
 		      func_append newdeplibs " $i"
 		    else
 		      droppeddeps=yes
@@ -7787,24 +9282,24 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		if test -n "$file_magic_glob"; then
 		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
 		else
 		  libnameglob=$libname
 		fi
-		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  if test "$want_nocaseglob" = yes; then
+		  if test yes = "$want_nocaseglob"; then
 		    shopt -s nocaseglob
 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
 		    $nocaseglob
@@ -7822,25 +9317,25 @@ EOF
 		      # We might still enter an endless loop, since a link
 		      # loop can be closed while we follow links,
 		      # but so what?
-		      potlib="$potent_lib"
+		      potlib=$potent_lib
 		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
 			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
+			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
 			esac
 		      done
 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
 			 $SED -e 10q |
 			 $EGREP "$file_magic_regex" > /dev/null; then
 			func_append newdeplibs " $a_deplib"
-			a_deplib=""
+			a_deplib=
 			break 2
 		      fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7848,7 +9343,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7871,30 +9366,30 @@ EOF
 	    -l*)
 	      func_stripname -l '' "$a_deplib"
 	      name=$func_stripname_result
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
 		case " $predeps $postdeps " in
 		*" $a_deplib "*)
 		  func_append newdeplibs " $a_deplib"
-		  a_deplib=""
+		  a_deplib=
 		  ;;
 		esac
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		libname=`eval "\\$ECHO \"$libname_spec\""`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
 		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    potlib=$potent_lib # see symlink-check above in file_magic test
 		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
 		       $EGREP "$match_pattern_regex" > /dev/null; then
 		      func_append newdeplibs " $a_deplib"
-		      a_deplib=""
+		      a_deplib=
 		      break 2
 		    fi
 		  done
 		done
 	      fi
-	      if test -n "$a_deplib" ; then
+	      if test -n "$a_deplib"; then
 		droppeddeps=yes
 		echo
 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
@@ -7902,7 +9397,7 @@ EOF
 		echo "*** you link to this library.  But I can only do this if you have a"
 		echo "*** shared version of the library, which you do not appear to have"
 		echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
+		if test -z "$potlib"; then
 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
 		else
 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
@@ -7918,18 +9413,18 @@ EOF
 	  done # Gone through all deplibs.
 	  ;;
 	none | unknown | *)
-	  newdeplibs=""
+	  newdeplibs=
 	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
+	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
+	    for i in $predeps $postdeps; do
 	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
 	    done
 	  fi
 	  case $tmp_deplibs in
 	  *[!\	\ ]*)
 	    echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
+	    if test none = "$deplibs_check_method"; then
 	      echo "*** Warning: inter-library dependencies are not supported in this platform."
 	    else
 	      echo "*** Warning: inter-library dependencies are not known to be supported."
@@ -7953,8 +9448,8 @@ EOF
 	  ;;
 	esac
 
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
+	if test yes = "$droppeddeps"; then
+	  if test yes = "$module"; then
 	    echo
 	    echo "*** Warning: libtool could not satisfy all declared inter-library"
 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
@@ -7963,12 +9458,12 @@ EOF
 	    if test -z "$global_symbol_pipe"; then
 	      echo
 	      echo "*** However, this would only work if libtool was able to extract symbol"
-	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
 	      echo "*** not find such a program.  So, this module is probably useless."
-	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
 	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
+	    if test no = "$build_old_libs"; then
+	      oldlibs=$output_objdir/$libname.$libext
 	      build_libtool_libs=module
 	      build_old_libs=yes
 	    else
@@ -7979,14 +9474,14 @@ EOF
 	    echo "*** automatically added whenever a program is linked with this library"
 	    echo "*** or is declared to -dlopen it."
 
-	    if test "$allow_undefined" = no; then
+	    if test no = "$allow_undefined"; then
 	      echo
 	      echo "*** Since this library must not contain undefined symbols,"
 	      echo "*** because either the platform does not support them or"
 	      echo "*** it was explicitly requested with -no-undefined,"
 	      echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
+	      if test no = "$build_old_libs"; then
+		oldlibs=$output_objdir/$libname.$libext
 		build_libtool_libs=module
 		build_old_libs=yes
 	      else
@@ -8032,7 +9527,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      deplibs="$new_libs"
+      deplibs=$new_libs
 
       # All the library-specific variables (install_libdir is set above).
       library_names=
@@ -8040,25 +9535,25 @@ EOF
       dlname=
 
       # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	# Remove ${wl} instances when linking with ld.
+      if test yes = "$build_libtool_libs"; then
+	# Remove $wl instances when linking with ld.
 	# FIXME: should test the right _cmds variable.
 	case $archive_cmds in
 	  *\$LD\ *) wl= ;;
         esac
-	if test "$hardcode_into_libs" = yes; then
+	if test yes = "$hardcode_into_libs"; then
 	  # Hardcode the library paths
 	  hardcode_libdirs=
 	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+	  rpath=$finalize_rpath
+	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
 	  for libdir in $rpath; do
 	    if test -n "$hardcode_libdir_flag_spec"; then
 	      if test -n "$hardcode_libdir_separator"; then
 		func_replace_sysroot "$libdir"
 		libdir=$func_replace_sysroot_result
 		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
+		  hardcode_libdirs=$libdir
 		else
 		  # Just accumulate the unique libdirs.
 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8083,7 +9578,7 @@ EOF
 	  # Substitute the hardcoded libdirs into the rpath.
 	  if test -n "$hardcode_libdir_separator" &&
 	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
+	    libdir=$hardcode_libdirs
 	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
 	  fi
 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
@@ -8097,8 +9592,8 @@ EOF
 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
 	fi
 
-	shlibpath="$finalize_shlibpath"
-	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	shlibpath=$finalize_shlibpath
+	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
 	if test -n "$shlibpath"; then
 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
 	fi
@@ -8108,19 +9603,19 @@ EOF
 	eval library_names=\"$library_names_spec\"
 	set dummy $library_names
 	shift
-	realname="$1"
+	realname=$1
 	shift
 
 	if test -n "$soname_spec"; then
 	  eval soname=\"$soname_spec\"
 	else
-	  soname="$realname"
+	  soname=$realname
 	fi
 	if test -z "$dlname"; then
 	  dlname=$soname
 	fi
 
-	lib="$output_objdir/$realname"
+	lib=$output_objdir/$realname
 	linknames=
 	for link
 	do
@@ -8134,7 +9629,7 @@ EOF
 	delfiles=
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
-	  export_symbols="$output_objdir/$libname.uexp"
+	  export_symbols=$output_objdir/$libname.uexp
 	  func_append delfiles " $export_symbols"
 	fi
 
@@ -8143,31 +9638,31 @@ EOF
 	cygwin* | mingw* | cegcc*)
 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
 	    # exporting using user supplied symfile
-	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	    func_dll_def_p "$export_symbols" || {
 	      # and it's NOT already a .def file. Must figure out
 	      # which of the given symbols are data symbols and tag
 	      # them as such. So, trigger use of export_symbols_cmds.
 	      # export_symbols gets reassigned inside the "prepare
 	      # the list of exported symbols" if statement, so the
 	      # include_expsyms logic still works.
-	      orig_export_symbols="$export_symbols"
+	      orig_export_symbols=$export_symbols
 	      export_symbols=
 	      always_export_symbols=yes
-	    fi
+	    }
 	  fi
 	  ;;
 	esac
 
 	# Prepare the list of exported symbols
 	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    func_verbose "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
+	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for '$libname.la'"
+	    export_symbols=$output_objdir/$libname.exp
 	    $opt_dry_run || $RM $export_symbols
 	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd1 in $cmds; do
-	      IFS="$save_ifs"
+	      IFS=$save_ifs
 	      # Take the normal branch if the nm_file_list_spec branch
 	      # doesn't work or if tool conversion is not needed.
 	      case $nm_file_list_spec~$to_tool_file_cmd in
@@ -8181,7 +9676,7 @@ EOF
 		  try_normal_branch=no
 		  ;;
 	      esac
-	      if test "$try_normal_branch" = yes \
+	      if test yes = "$try_normal_branch" \
 		 && { test "$len" -lt "$max_cmd_len" \
 		      || test "$max_cmd_len" -le -1; }
 	      then
@@ -8192,7 +9687,7 @@ EOF
 		output_la=$func_basename_result
 		save_libobjs=$libobjs
 		save_output=$output
-		output=${output_objdir}/${output_la}.nm
+		output=$output_objdir/$output_la.nm
 		func_to_tool_file "$output"
 		libobjs=$nm_file_list_spec$func_to_tool_file_result
 		func_append delfiles " $output"
@@ -8215,8 +9710,8 @@ EOF
 		break
 	      fi
 	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	    IFS=$save_ifs
+	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
 	    fi
@@ -8224,16 +9719,16 @@ EOF
 	fi
 
 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  tmp_export_symbols="$export_symbols"
-	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  tmp_export_symbols=$export_symbols
+	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	fi
 
-	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
 	  # The given exports_symbols file has to be filtered, so filter it.
-	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # 's' commands, which not all seds can handle. GNU sed should be fine
 	  # though. Also, the filter scales superlinearly with the number of
 	  # global variables. join(1) would be nice here, but unfortunately
 	  # isn't a blessed tool.
@@ -8252,11 +9747,11 @@ EOF
 	    ;;
 	  esac
 	done
-	deplibs="$tmp_deplibs"
+	deplibs=$tmp_deplibs
 
 	if test -n "$convenience"; then
 	  if test -n "$whole_archive_flag_spec" &&
-	    test "$compiler_needs_object" = yes &&
+	    test yes = "$compiler_needs_object" &&
 	    test -z "$libobjs"; then
 	    # extract the archives, so we have objects to list.
 	    # TODO: could optimize this to just extract one archive.
@@ -8267,7 +9762,7 @@ EOF
 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
 	    test "X$libobjs" = "X " && libobjs=
 	  else
-	    gentop="$output_objdir/${outputname}x"
+	    gentop=$output_objdir/${outputname}x
 	    func_append generated " $gentop"
 
 	    func_extract_archives $gentop $convenience
@@ -8276,18 +9771,18 @@ EOF
 	  fi
 	fi
 
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
 	  eval flag=\"$thread_safe_flag_spec\"
 	  func_append linker_flags " $flag"
 	fi
 
 	# Make a backup of the uninstalled library when relinking
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
 	fi
 
 	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
+	if test yes = "$module" && test -n "$module_cmds"; then
 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	    eval test_cmds=\"$module_expsym_cmds\"
 	    cmds=$module_expsym_cmds
@@ -8305,7 +9800,7 @@ EOF
 	  fi
 	fi
 
-	if test "X$skipped_export" != "X:" &&
+	if test : != "$skipped_export" &&
 	   func_len " $test_cmds" &&
 	   len=$func_len_result &&
 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
@@ -8338,8 +9833,8 @@ EOF
 	  last_robj=
 	  k=1
 
-	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
-	    output=${output_objdir}/${output_la}.lnkscript
+	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
+	    output=$output_objdir/$output_la.lnkscript
 	    func_verbose "creating GNU ld script: $output"
 	    echo 'INPUT (' > $output
 	    for obj in $save_libobjs
@@ -8351,14 +9846,14 @@ EOF
 	    func_append delfiles " $output"
 	    func_to_tool_file "$output"
 	    output=$func_to_tool_file_result
-	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
-	    output=${output_objdir}/${output_la}.lnk
+	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
+	    output=$output_objdir/$output_la.lnk
 	    func_verbose "creating linker input file list: $output"
 	    : > $output
 	    set x $save_libobjs
 	    shift
 	    firstobj=
-	    if test "$compiler_needs_object" = yes; then
+	    if test yes = "$compiler_needs_object"; then
 	      firstobj="$1 "
 	      shift
 	    fi
@@ -8373,7 +9868,7 @@ EOF
 	  else
 	    if test -n "$save_libobjs"; then
 	      func_verbose "creating reloadable object files..."
-	      output=$output_objdir/$output_la-${k}.$objext
+	      output=$output_objdir/$output_la-$k.$objext
 	      eval test_cmds=\"$reload_cmds\"
 	      func_len " $test_cmds"
 	      len0=$func_len_result
@@ -8385,13 +9880,13 @@ EOF
 		func_len " $obj"
 		func_arith $len + $func_len_result
 		len=$func_arith_result
-		if test "X$objlist" = X ||
+		if test -z "$objlist" ||
 		   test "$len" -lt "$max_cmd_len"; then
 		  func_append objlist " $obj"
 		else
 		  # The command $test_cmds is almost too long, add a
 		  # command to the queue.
-		  if test "$k" -eq 1 ; then
+		  if test 1 -eq "$k"; then
 		    # The first file doesn't have a previous command to add.
 		    reload_objs=$objlist
 		    eval concat_cmds=\"$reload_cmds\"
@@ -8401,10 +9896,10 @@ EOF
 		    reload_objs="$objlist $last_robj"
 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
 		  fi
-		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  last_robj=$output_objdir/$output_la-$k.$objext
 		  func_arith $k + 1
 		  k=$func_arith_result
-		  output=$output_objdir/$output_la-${k}.$objext
+		  output=$output_objdir/$output_la-$k.$objext
 		  objlist=" $obj"
 		  func_len " $last_robj"
 		  func_arith $len0 + $func_len_result
@@ -8416,9 +9911,9 @@ EOF
 	      # files will link in the last one created.
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
 	      reload_objs="$objlist $last_robj"
-	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
 	      if test -n "$last_robj"; then
-	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
 	      func_append delfiles " $output"
 
@@ -8426,9 +9921,9 @@ EOF
 	      output=
 	    fi
 
-	    if ${skipped_export-false}; then
-	      func_verbose "generating symbol list for \`$libname.la'"
-	      export_symbols="$output_objdir/$libname.exp"
+	    ${skipped_export-false} && {
+	      func_verbose "generating symbol list for '$libname.la'"
+	      export_symbols=$output_objdir/$libname.exp
 	      $opt_dry_run || $RM $export_symbols
 	      libobjs=$output
 	      # Append the command to create the export file.
@@ -8437,16 +9932,16 @@ EOF
 	      if test -n "$last_robj"; then
 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
 	      fi
-	    fi
+	    }
 
 	    test -n "$save_libobjs" &&
 	      func_verbose "creating a temporary reloadable object file: $output"
 
 	    # Loop through the commands generated above and execute them.
-	    save_ifs="$IFS"; IFS='~'
+	    save_ifs=$IFS; IFS='~'
 	    for cmd in $concat_cmds; do
-	      IFS="$save_ifs"
-	      $opt_silent || {
+	      IFS=$save_ifs
+	      $opt_quiet || {
 		  func_quote_for_expand "$cmd"
 		  eval "func_echo $func_quote_for_expand_result"
 	      }
@@ -8454,7 +9949,7 @@ EOF
 		lt_exit=$?
 
 		# Restore the uninstalled library and exit
-		if test "$opt_mode" = relink; then
+		if test relink = "$opt_mode"; then
 		  ( cd "$output_objdir" && \
 		    $RM "${realname}T" && \
 		    $MV "${realname}U" "$realname" )
@@ -8463,7 +9958,7 @@ EOF
 		exit $lt_exit
 	      }
 	    done
-	    IFS="$save_ifs"
+	    IFS=$save_ifs
 
 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
@@ -8471,18 +9966,18 @@ EOF
 	    fi
 	  fi
 
-          if ${skipped_export-false}; then
+          ${skipped_export-false} && {
 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	      tmp_export_symbols="$export_symbols"
-	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      tmp_export_symbols=$export_symbols
+	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
 	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
 	    fi
 
 	    if test -n "$orig_export_symbols"; then
 	      # The given exports_symbols file has to be filtered, so filter it.
-	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
-	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # 's' commands, which not all seds can handle. GNU sed should be fine
 	      # though. Also, the filter scales superlinearly with the number of
 	      # global variables. join(1) would be nice here, but unfortunately
 	      # isn't a blessed tool.
@@ -8491,7 +9986,7 @@ EOF
 	      export_symbols=$output_objdir/$libname.def
 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
 	    fi
-	  fi
+	  }
 
 	  libobjs=$output
 	  # Restore the value of output.
@@ -8505,7 +10000,7 @@ EOF
 	  # value of $libobjs for piecewise linking.
 
 	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test yes = "$module" && test -n "$module_cmds"; then
 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
 	      cmds=$module_expsym_cmds
 	    else
@@ -8527,7 +10022,7 @@ EOF
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -8535,11 +10030,12 @@ EOF
 	  test "X$libobjs" = "X " && libobjs=
 	fi
 
-	save_ifs="$IFS"; IFS='~'
+	save_ifs=$IFS; IFS='~'
 	for cmd in $cmds; do
-	  IFS="$save_ifs"
+	  IFS=$sp$nl
 	  eval cmd=\"$cmd\"
-	  $opt_silent || {
+	  IFS=$save_ifs
+	  $opt_quiet || {
 	    func_quote_for_expand "$cmd"
 	    eval "func_echo $func_quote_for_expand_result"
 	  }
@@ -8547,7 +10043,7 @@ EOF
 	    lt_exit=$?
 
 	    # Restore the uninstalled library and exit
-	    if test "$opt_mode" = relink; then
+	    if test relink = "$opt_mode"; then
 	      ( cd "$output_objdir" && \
 	        $RM "${realname}T" && \
 		$MV "${realname}U" "$realname" )
@@ -8556,10 +10052,10 @@ EOF
 	    exit $lt_exit
 	  }
 	done
-	IFS="$save_ifs"
+	IFS=$save_ifs
 
 	# Restore the uninstalled library and exit
-	if test "$opt_mode" = relink; then
+	if test relink = "$opt_mode"; then
 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
 
 	  if test -n "$convenience"; then
@@ -8579,39 +10075,39 @@ EOF
 	done
 
 	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
+	if test yes = "$module" || test yes = "$export_dynamic"; then
 	  # On all known operating systems, these are identical.
-	  dlname="$soname"
+	  dlname=$soname
 	fi
       fi
       ;;
 
     obj)
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	func_warning "\`-dlopen' is ignored for objects"
+      if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
+	func_warning "'-dlopen' is ignored for objects"
       fi
 
       case " $deplibs" in
       *\ -l* | *\ -L*)
-	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+	func_warning "'-l' and '-L' are ignored for objects" ;;
       esac
 
       test -n "$rpath" && \
-	func_warning "\`-rpath' is ignored for objects"
+	func_warning "'-rpath' is ignored for objects"
 
       test -n "$xrpath" && \
-	func_warning "\`-R' is ignored for objects"
+	func_warning "'-R' is ignored for objects"
 
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for objects"
+	func_warning "'-version-info' is ignored for objects"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for objects"
+	func_warning "'-release' is ignored for objects"
 
       case $output in
       *.lo)
 	test -n "$objs$old_deplibs" && \
-	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
 
 	libobj=$output
 	func_lo2o "$libobj"
@@ -8619,7 +10115,7 @@ EOF
 	;;
       *)
 	libobj=
-	obj="$output"
+	obj=$output
 	;;
       esac
 
@@ -8632,17 +10128,19 @@ EOF
       # the extraction.
       reload_conv_objs=
       gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec and hope we can get by with
-      # turning comma into space..
-      wl=
-
+      # if reload_cmds runs $LD directly, get rid of -Wl from
+      # whole_archive_flag_spec and hope we can get by with turning comma
+      # into space.
+      case $reload_cmds in
+        *\$LD[\ \$]*) wl= ;;
+      esac
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
-	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
 	else
-	  gentop="$output_objdir/${obj}x"
+	  gentop=$output_objdir/${obj}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $convenience
@@ -8651,12 +10149,12 @@ EOF
       fi
 
       # If we're not building shared, we need to use non_pic_objs
-      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+      test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
 
       # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+      reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
 
-      output="$obj"
+      output=$obj
       func_execute_cmds "$reload_cmds" 'exit $?'
 
       # Exit if we aren't doing a library object file.
@@ -8668,7 +10166,7 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$build_libtool_libs" != yes; then
+      test yes = "$build_libtool_libs" || {
 	if test -n "$gentop"; then
 	  func_show_eval '${RM}r "$gentop"'
 	fi
@@ -8678,12 +10176,12 @@ EOF
 	# $show "echo timestamp > $libobj"
 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
 	exit $EXIT_SUCCESS
-      fi
+      }
 
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
+      if test -n "$pic_flag" || test default != "$pic_mode"; then
 	# Only do commands if we really have different PIC objects.
 	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
+	output=$libobj
 	func_execute_cmds "$reload_cmds" 'exit $?'
       fi
 
@@ -8700,16 +10198,14 @@ EOF
 	          output=$func_stripname_result.exe;;
       esac
       test -n "$vinfo" && \
-	func_warning "\`-version-info' is ignored for programs"
+	func_warning "'-version-info' is ignored for programs"
 
       test -n "$release" && \
-	func_warning "\`-release' is ignored for programs"
+	func_warning "'-release' is ignored for programs"
 
-      test "$preload" = yes \
-        && test "$dlopen_support" = unknown \
-	&& test "$dlopen_self" = unknown \
-	&& test "$dlopen_self_static" = unknown && \
-	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+      $preload \
+	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
+	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
 
       case $host in
       *-*-rhapsody* | *-*-darwin1.[012])
@@ -8723,11 +10219,11 @@ EOF
       *-*-darwin*)
 	# Don't allow lazy linking, it breaks C++ global constructors
 	# But is supposedly fixed on 10.4 or later (yay!).
-	if test "$tagname" = CXX ; then
+	if test CXX = "$tagname"; then
 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
 	    10.[0123])
-	      func_append compile_command " ${wl}-bind_at_load"
-	      func_append finalize_command " ${wl}-bind_at_load"
+	      func_append compile_command " $wl-bind_at_load"
+	      func_append finalize_command " $wl-bind_at_load"
 	    ;;
 	  esac
 	fi
@@ -8763,7 +10259,7 @@ EOF
 	*) func_append new_libs " $deplib" ;;
 	esac
       done
-      compile_deplibs="$new_libs"
+      compile_deplibs=$new_libs
 
 
       func_append compile_command " $compile_deplibs"
@@ -8787,7 +10283,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8810,7 +10306,7 @@ EOF
 	fi
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
-	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
 	  case :$dllsearchpath: in
 	  *":$libdir:"*) ;;
 	  ::) dllsearchpath=$libdir;;
@@ -8827,10 +10323,10 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      compile_rpath="$rpath"
+      compile_rpath=$rpath
 
       rpath=
       hardcode_libdirs=
@@ -8838,7 +10334,7 @@ EOF
 	if test -n "$hardcode_libdir_flag_spec"; then
 	  if test -n "$hardcode_libdir_separator"; then
 	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
+	      hardcode_libdirs=$libdir
 	    else
 	      # Just accumulate the unique libdirs.
 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
@@ -8863,45 +10359,43 @@ EOF
       # Substitute the hardcoded libdirs into the rpath.
       if test -n "$hardcode_libdir_separator" &&
 	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
+	libdir=$hardcode_libdirs
 	eval rpath=\" $hardcode_libdir_flag_spec\"
       fi
-      finalize_rpath="$rpath"
+      finalize_rpath=$rpath
 
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+      if test -n "$libobjs" && test yes = "$build_old_libs"; then
 	# Transform all the library objects into standard objects.
 	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
 	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
       fi
 
-      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+      func_generate_dlsyms "$outputname" "@PROGRAM@" false
 
       # template prelinking step
       if test -n "$prelink_cmds"; then
 	func_execute_cmds "$prelink_cmds" 'exit $?'
       fi
 
-      wrappers_required=yes
+      wrappers_required=:
       case $host in
       *cegcc* | *mingw32ce*)
         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
-        wrappers_required=no
+        wrappers_required=false
         ;;
       *cygwin* | *mingw* )
-        if test "$build_libtool_libs" != yes; then
-          wrappers_required=no
-        fi
+        test yes = "$build_libtool_libs" || wrappers_required=false
         ;;
       *)
-        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-          wrappers_required=no
+        if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
+          wrappers_required=false
         fi
         ;;
       esac
-      if test "$wrappers_required" = no; then
+      $wrappers_required || {
 	# Replace the output file specification.
 	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
+	link_command=$compile_command$compile_rpath
 
 	# We have no uninstalled library dependencies, so finalize right now.
 	exit_status=0
@@ -8914,12 +10408,12 @@ EOF
 	fi
 
 	# Delete the generated files.
-	if test -f "$output_objdir/${outputname}S.${objext}"; then
-	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	if test -f "$output_objdir/${outputname}S.$objext"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
 	fi
 
 	exit $exit_status
-      fi
+      }
 
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
@@ -8949,9 +10443,9 @@ EOF
 	fi
       fi
 
-      if test "$no_install" = yes; then
+      if test yes = "$no_install"; then
 	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
+	link_command=$compile_var$compile_command$compile_rpath
 	# Replace the output file specification.
 	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
 	# Delete the old output file.
@@ -8968,27 +10462,28 @@ EOF
 	exit $EXIT_SUCCESS
       fi
 
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
+      case $hardcode_action,$fast_install in
+        relink,*)
+	  # Fast installation is not supported
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
 
-	func_warning "this platform does not like uninstalled shared libraries"
-	func_warning "\`$output' will be relinked during installation"
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
+	  func_warning "this platform does not like uninstalled shared libraries"
+	  func_warning "'$output' will be relinked during installation"
+	  ;;
+        *,yes)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+          ;;
+	*,no)
+	  link_command=$compile_var$compile_command$compile_rpath
+	  relink_command=$finalize_var$finalize_command$finalize_rpath
+          ;;
+	*,needless)
+	  link_command=$finalize_var$compile_command$finalize_rpath
+	  relink_command=
+          ;;
+      esac
 
       # Replace the output file specification.
       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
@@ -9045,8 +10540,8 @@ EOF
 	    func_dirname_and_basename "$output" "" "."
 	    output_name=$func_basename_result
 	    output_path=$func_dirname_result
-	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
-	    cwrapper="$output_path/$output_name.exe"
+	    cwrappersource=$output_path/$objdir/lt-$output_name.c
+	    cwrapper=$output_path/$output_name.exe
 	    $RM $cwrappersource $cwrapper
 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
 
@@ -9067,7 +10562,7 @@ EOF
 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
 	    $opt_dry_run || {
 	      # note: this script will not be executed, so do not chmod.
-	      if test "x$build" = "x$host" ; then
+	      if test "x$build" = "x$host"; then
 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
 	      else
 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
@@ -9090,25 +10585,27 @@ EOF
     # See if we need to build an old-fashioned archive.
     for oldlib in $oldlibs; do
 
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save $symfileobj"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
+      case $build_libtool_libs in
+        convenience)
+	  oldobjs="$libobjs_save $symfileobj"
+	  addlibs=$convenience
 	  build_libtool_libs=no
-	else
+	  ;;
+	module)
+	  oldobjs=$libobjs_save
+	  addlibs=$old_convenience
+	  build_libtool_libs=no
+          ;;
+	*)
 	  oldobjs="$old_deplibs $non_pic_objects"
-	  if test "$preload" = yes && test -f "$symfileobj"; then
-	    func_append oldobjs " $symfileobj"
-	  fi
-	fi
-	addlibs="$old_convenience"
-      fi
+	  $preload && test -f "$symfileobj" \
+	    && func_append oldobjs " $symfileobj"
+	  addlibs=$old_convenience
+	  ;;
+      esac
 
       if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
+	gentop=$output_objdir/${outputname}x
 	func_append generated " $gentop"
 
 	func_extract_archives $gentop $addlibs
@@ -9116,13 +10613,13 @@ EOF
       fi
 
       # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+      if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
 	cmds=$old_archive_from_new_cmds
       else
 
 	# Add any objects from preloaded convenience libraries
 	if test -n "$dlprefiles"; then
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 
 	  func_extract_archives $gentop $dlprefiles
@@ -9143,7 +10640,7 @@ EOF
 	  :
 	else
 	  echo "copying selected object files to avoid basename conflicts..."
-	  gentop="$output_objdir/${outputname}x"
+	  gentop=$output_objdir/${outputname}x
 	  func_append generated " $gentop"
 	  func_mkdir_p "$gentop"
 	  save_oldobjs=$oldobjs
@@ -9152,7 +10649,7 @@ EOF
 	  for obj in $save_oldobjs
 	  do
 	    func_basename "$obj"
-	    objbase="$func_basename_result"
+	    objbase=$func_basename_result
 	    case " $oldobjs " in
 	    " ") oldobjs=$obj ;;
 	    *[\ /]"$objbase "*)
@@ -9221,18 +10718,18 @@ EOF
 	    else
 	      # the above command should be used before it gets too long
 	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
+	      if test "$obj" = "$last_oldobj"; then
 		RANLIB=$save_RANLIB
 	      fi
 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
 	      objlist=
 	      len=$len0
 	    fi
 	  done
 	  RANLIB=$save_RANLIB
 	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
+	  if test -z "$oldobjs"; then
 	    eval cmds=\"\$concat_cmds\"
 	  else
 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
@@ -9249,7 +10746,7 @@ EOF
     case $output in
     *.la)
       old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      test yes = "$build_old_libs" && old_library=$libname.$libext
       func_verbose "creating $output"
 
       # Preserve any variables that may affect compiler behavior
@@ -9264,31 +10761,31 @@ EOF
 	fi
       done
       # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
       relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
+      if test yes = "$hardcode_automatic"; then
 	relink_command=
       fi
 
       # Only create the output if not a dry run.
       $opt_dry_run || {
 	for installed in no yes; do
-	  if test "$installed" = yes; then
+	  if test yes = "$installed"; then
 	    if test -z "$install_libdir"; then
 	      break
 	    fi
-	    output="$output_objdir/$outputname"i
+	    output=$output_objdir/${outputname}i
 	    # Replace all uninstalled libtool libraries with the installed ones
 	    newdependency_libs=
 	    for deplib in $dependency_libs; do
 	      case $deplib in
 	      *.la)
 		func_basename "$deplib"
-		name="$func_basename_result"
+		name=$func_basename_result
 		func_resolve_sysroot "$deplib"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  func_fatal_error "'$deplib' is not a valid libtool archive"
 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      -L*)
@@ -9304,23 +10801,23 @@ EOF
 	      *) func_append newdependency_libs " $deplib" ;;
 	      esac
 	    done
-	    dependency_libs="$newdependency_libs"
+	    dependency_libs=$newdependency_libs
 	    newdlfiles=
 
 	    for lib in $dlfiles; do
 	      case $lib in
 	      *.la)
 	        func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      *) func_append newdlfiles " $lib" ;;
 	      esac
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
@@ -9330,34 +10827,34 @@ EOF
 		# didn't already link the preopened objects directly into
 		# the library:
 		func_basename "$lib"
-		name="$func_basename_result"
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		name=$func_basename_result
+		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
 		test -z "$libdir" && \
-		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		  func_fatal_error "'$lib' is not a valid libtool archive"
 		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
 		;;
 	      esac
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  else
 	    newdlfiles=
 	    for lib in $dlfiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlfiles " $abs"
 	    done
-	    dlfiles="$newdlfiles"
+	    dlfiles=$newdlfiles
 	    newdlprefiles=
 	    for lib in $dlprefiles; do
 	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
 		*) abs=`pwd`"/$lib" ;;
 	      esac
 	      func_append newdlprefiles " $abs"
 	    done
-	    dlprefiles="$newdlprefiles"
+	    dlprefiles=$newdlprefiles
 	  fi
 	  $RM $output
 	  # place dlname in correct position for cygwin
@@ -9373,10 +10870,9 @@ EOF
 	  case $host,$output,$installed,$module,$dlname in
 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
 	      # If a -bindir argument was supplied, place the dll there.
-	      if test "x$bindir" != x ;
-	      then
+	      if test -n "$bindir"; then
 		func_relative_path "$install_libdir" "$bindir"
-		tdlname=$func_relative_path_result$dlname
+		tdlname=$func_relative_path_result/$dlname
 	      else
 		# Otherwise fall back on heuristic.
 		tdlname=../bin/$dlname
@@ -9385,7 +10881,7 @@ EOF
 	  esac
 	  $ECHO > $output "\
 # $outputname - a libtool library file
-# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION
 #
 # Please DO NOT delete this file!
 # It is necessary for linking the library.
@@ -9399,7 +10895,7 @@ library_names='$library_names'
 # The name of the static archive.
 old_library='$old_library'
 
-# Linker flags that can not go in dependency_libs.
+# Linker flags that cannot go in dependency_libs.
 inherited_linker_flags='$new_inherited_linker_flags'
 
 # Libraries that this one depends upon.
@@ -9425,7 +10921,7 @@ dlpreopen='$dlprefiles'
 
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
+	  if test no,yes = "$installed,$need_relink"; then
 	    $ECHO >> $output "\
 relink_command=\"$relink_command\""
 	  fi
@@ -9440,27 +10936,29 @@ relink_command=\"$relink_command\""
     exit $EXIT_SUCCESS
 }
 
-{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
-    func_mode_link ${1+"$@"}
+if test link = "$opt_mode" || test relink = "$opt_mode"; then
+  func_mode_link ${1+"$@"}
+fi
 
 
 # func_mode_uninstall arg...
 func_mode_uninstall ()
 {
-    $opt_debug
-    RM="$nonopt"
+    $debug_cmd
+
+    RM=$nonopt
     files=
-    rmforce=
+    rmforce=false
     exit_status=0
 
     # This variable tells wrapper scripts just to set variables rather
     # than running their programs.
-    libtool_install_magic="$magic"
+    libtool_install_magic=$magic
 
     for arg
     do
       case $arg in
-      -f) func_append RM " $arg"; rmforce=yes ;;
+      -f) func_append RM " $arg"; rmforce=: ;;
       -*) func_append RM " $arg" ;;
       *) func_append files " $arg" ;;
       esac
@@ -9473,18 +10971,18 @@ func_mode_uninstall ()
 
     for file in $files; do
       func_dirname "$file" "" "."
-      dir="$func_dirname_result"
-      if test "X$dir" = X.; then
-	odir="$objdir"
+      dir=$func_dirname_result
+      if test . = "$dir"; then
+	odir=$objdir
       else
-	odir="$dir/$objdir"
+	odir=$dir/$objdir
       fi
       func_basename "$file"
-      name="$func_basename_result"
-      test "$opt_mode" = uninstall && odir="$dir"
+      name=$func_basename_result
+      test uninstall = "$opt_mode" && odir=$dir
 
       # Remember odir for removal later, being careful to avoid duplicates
-      if test "$opt_mode" = clean; then
+      if test clean = "$opt_mode"; then
 	case " $rmdirs " in
 	  *" $odir "*) ;;
 	  *) func_append rmdirs " $odir" ;;
@@ -9499,11 +10997,11 @@ func_mode_uninstall ()
       elif test -d "$file"; then
 	exit_status=1
 	continue
-      elif test "$rmforce" = yes; then
+      elif $rmforce; then
 	continue
       fi
 
-      rmfiles="$file"
+      rmfiles=$file
 
       case $name in
       *.la)
@@ -9517,7 +11015,7 @@ func_mode_uninstall ()
 	  done
 	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
 
-	  case "$opt_mode" in
+	  case $opt_mode in
 	  clean)
 	    case " $library_names " in
 	    *" $dlname "*) ;;
@@ -9528,12 +11026,12 @@ func_mode_uninstall ()
 	  uninstall)
 	    if test -n "$library_names"; then
 	      # Do each command in the postuninstall commands.
-	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 
 	    if test -n "$old_library"; then
 	      # Do each command in the old_postuninstall commands.
-	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
 	    fi
 	    # FIXME: should reinstall the best remaining shared library.
 	    ;;
@@ -9549,21 +11047,19 @@ func_mode_uninstall ()
 	  func_source $dir/$name
 
 	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" &&
-	     test "$pic_object" != none; then
+	  if test -n "$pic_object" && test none != "$pic_object"; then
 	    func_append rmfiles " $dir/$pic_object"
 	  fi
 
 	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" &&
-	     test "$non_pic_object" != none; then
+	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
 	    func_append rmfiles " $dir/$non_pic_object"
 	  fi
 	fi
 	;;
 
       *)
-	if test "$opt_mode" = clean ; then
+	if test clean = "$opt_mode"; then
 	  noexename=$name
 	  case $file in
 	  *.exe)
@@ -9590,12 +11086,12 @@ func_mode_uninstall ()
 
 	    # note $name still contains .exe if it was in $file originally
 	    # as does the version of $file that was added into $rmfiles
-	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
+	    if test yes = "$fast_install" && test -n "$relink_command"; then
 	      func_append rmfiles " $odir/lt-$name"
 	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      func_append rmfiles " $odir/lt-${noexename}.c"
+	    if test "X$noexename" != "X$name"; then
+	      func_append rmfiles " $odir/lt-$noexename.c"
 	    fi
 	  fi
 	fi
@@ -9604,7 +11100,7 @@ func_mode_uninstall ()
       func_show_eval "$RM $rmfiles" 'exit_status=1'
     done
 
-    # Try to remove the ${objdir}s in the directories where we deleted files
+    # Try to remove the $objdir's in the directories where we deleted files
     for dir in $rmdirs; do
       if test -d "$dir"; then
 	func_show_eval "rmdir $dir >/dev/null 2>&1"
@@ -9614,16 +11110,17 @@ func_mode_uninstall ()
     exit $exit_status
 }
 
-{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
-    func_mode_uninstall ${1+"$@"}
+if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
+  func_mode_uninstall ${1+"$@"}
+fi
 
 test -z "$opt_mode" && {
-  help="$generic_help"
+  help=$generic_help
   func_fatal_help "you must specify a MODE"
 }
 
 test -z "$exec_cmd" && \
-  func_fatal_help "invalid operation mode \`$opt_mode'"
+  func_fatal_help "invalid operation mode '$opt_mode'"
 
 if test -n "$exec_cmd"; then
   eval exec "$exec_cmd"
@@ -9634,7 +11131,7 @@ exit $exit_status
 
 
 # The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
+# where we disable both kinds of libraries.  Given conflicting
 # choices, we go for a static library, that is the most portable,
 # since we can't tell whether shared libraries were disabled because
 # the user asked for that or because the platform doesn't support
@@ -9657,5 +11154,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
 # mode:shell-script
 # sh-indentation:2
 # End:
-# vi:sw=2
-
diff --git a/src/gmock/gtest/build-aux/missing b/src/gmock/gtest/build-aux/missing
index db98974..f62bbae 100755
--- a/src/gmock/gtest/build-aux/missing
+++ b/src/gmock/gtest/build-aux/missing
@@ -3,7 +3,7 @@
 
 scriptversion=2013-10-28.13; # UTC
 
-# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
diff --git a/src/gmock/gtest/build-aux/test-driver b/src/gmock/gtest/build-aux/test-driver
index d306056..8e575b0 100755
--- a/src/gmock/gtest/build-aux/test-driver
+++ b/src/gmock/gtest/build-aux/test-driver
@@ -3,7 +3,7 @@
 
 scriptversion=2013-07-13.22; # UTC
 
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -106,11 +106,14 @@ trap "st=143; $do_exit" 15
 # Test script is run here.
 "$@" >$log_file 2>&1
 estatus=$?
+
 if test $enable_hard_errors = no && test $estatus -eq 99; then
-  estatus=1
+  tweaked_estatus=1
+else
+  tweaked_estatus=$estatus
 fi
 
-case $estatus:$expect_failure in
+case $tweaked_estatus:$expect_failure in
   0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
   0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
   77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
@@ -119,6 +122,12 @@ case $estatus:$expect_failure in
   *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
 esac
 
+# Report the test outcome and exit status in the logs, so that one can
+# know whether the test passed or failed simply by looking at the '.log'
+# file, without the need of also peaking into the corresponding '.trs'
+# file (automake bug#11814).
+echo "$res $test_name (exit status: $estatus)" >>$log_file
+
 # Report outcome to console.
 echo "${col}${res}${std}: $test_name"
 
diff --git a/src/gmock/gtest/configure b/src/gmock/gtest/configure
index efd9c87..40b2ed0 100755
--- a/src/gmock/gtest/configure
+++ b/src/gmock/gtest/configure
@@ -647,6 +647,7 @@ HAVE_PYTHON_TRUE
 PYTHON
 CXXCPP
 CPP
+LT_SYS_LIBRARY_PATH
 OTOOL64
 OTOOL
 LIPO
@@ -745,6 +746,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -773,6 +775,7 @@ enable_shared
 enable_static
 with_pic
 enable_fast_install
+with_aix_soname
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -789,6 +792,7 @@ CPPFLAGS
 CXX
 CXXFLAGS
 CCC
+LT_SYS_LIBRARY_PATH
 CPP
 CXXCPP'
 
@@ -829,6 +833,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1081,6 +1086,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1218,7 +1232,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1371,6 +1385,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1426,9 +1441,12 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                           both]
+  --with-aix-soname=aix|svr4|both
+                          shared library versioning (aka "SONAME") variant to
+                          provide on AIX, [default=aix].
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
-  --with-sysroot=DIR Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).
+  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
+                          compiler's sysroot if not specified).
   --with-pthreads         use pthreads (default is yes)
 
 Some influential environment variables:
@@ -1441,6 +1459,8 @@ Some influential environment variables:
               you have headers in a nonstandard directory <include dir>
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  LT_SYS_LIBRARY_PATH
+              User-defined run-time library search path.
   CPP         C preprocessor
   CXXCPP      C++ preprocessor
 
@@ -2301,7 +2321,7 @@ ac_config_files="$ac_config_files scripts/gtest-config"
 # Initialize Automake with various options. We require at least v1.9, prevent
 # pedantic complaints about package files, and enable various distribution
 # targets.
-am__api_version='1.14'
+am__api_version='1.15'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -2473,8 +2493,8 @@ test "$program_suffix" != NONE &&
 ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 if test x"${MISSING+set}" != xset; then
   case $am_aux_dir in
@@ -2493,7 +2513,7 @@ else
 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
-if test x"${install_sh}" != xset; then
+if test x"${install_sh+set}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -2821,8 +2841,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 mkdir_p='$(MKDIR_P)'
 
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
+# We need awk for the "check" target (and possibly the TAP driver).  The
+# system "awk" is bad on some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
@@ -2880,6 +2900,7 @@ END
   fi
 fi
 
+
 # Check for programs used in building Google Test.
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -4319,8 +4340,8 @@ esac
 
 
 
-macro_version='2.4.2'
-macro_revision='1.3337'
+macro_version='2.4.6'
+macro_revision='2.4.6'
 
 
 
@@ -4334,7 +4355,7 @@ macro_revision='1.3337'
 
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@@ -4454,7 +4475,7 @@ func_echo_all ()
     $ECHO ""
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
 $as_echo "printf" >&6; } ;;
   print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
@@ -4777,19 +4798,19 @@ test -z "$GREP" && GREP=grep
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -4803,7 +4824,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -4814,7 +4835,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -4825,32 +4846,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -4893,33 +4914,38 @@ if ${lt_cv_path_NM+:} false; then :
 else
   if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -4930,15 +4956,15 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
@@ -5044,9 +5070,9 @@ esac
   fi
 fi
 
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -5054,8 +5080,8 @@ fi
     esac
   fi
 
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -5106,7 +5132,7 @@ if ${lt_cv_sys_max_cmd_len+:} false; then :
   $as_echo_n "(cached) " >&6
 else
     i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -5146,7 +5172,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -5197,22 +5223,22 @@ else
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -5230,7 +5256,7 @@ else
 
 fi
 
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 else
@@ -5248,30 +5274,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len
 : ${MV="mv -f"}
 : ${RM="rm -f"}
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
-$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
-$as_echo "$xsi_shell" >&6; }
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
-$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
-$as_echo "$lt_shell_append" >&6; }
-
-
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
@@ -5394,13 +5396,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -5528,13 +5530,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[4-9]*)
@@ -5561,8 +5563,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -5658,8 +5659,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
@@ -5712,6 +5713,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 
 fi
@@ -5869,8 +5873,8 @@ else
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -5882,7 +5886,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 
@@ -6037,7 +6041,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
@@ -6045,7 +6049,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -6058,7 +6062,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
 $as_echo "$lt_cv_ar_at_file" >&6; }
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -6275,7 +6279,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -6365,7 +6369,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[ABCDGISTW]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[ABCDEGRST]'
   fi
   ;;
@@ -6398,14 +6402,44 @@ case `$NM -V 2>&1` in
   symcode='[ABCDGIRSTW]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -6423,21 +6457,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK '"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -6485,11 +6522,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT_DLSYM_CONST
 #else
@@ -6515,7 +6552,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -6535,13 +6572,13 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
 	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+  test $ac_status = 0; } && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -6562,7 +6599,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -6615,6 +6652,16 @@ fi
 
 
 
+
+
+
+
+
+
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
 $as_echo_n "checking for sysroot... " >&6; }
 
@@ -6627,9 +6674,9 @@ fi
 
 
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -6639,8 +6686,8 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
-$as_echo "${with_sysroot}" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5
+$as_echo "$with_sysroot" >&6; }
    as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
    ;;
 esac
@@ -6652,19 +6699,100 @@ $as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5
+$as_echo_n "checking for a working dd... " >&6; }
+if ${ac_cv_path_lt_DD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+if test -z "$lt_DD"; then
+  ac_path_lt_DD_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in dd; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_lt_DD" || continue
+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi
+      $ac_path_lt_DD_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_lt_DD"; then
+    :
+  fi
+else
+  ac_cv_path_lt_DD=$lt_DD
+fi
+
+rm -f conftest.i conftest2.i conftest.out
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5
+$as_echo "$ac_cv_path_lt_DD" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5
+$as_echo_n "checking how to truncate binary pipes... " >&6; }
+if ${lt_cv_truncate_bin+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5
+$as_echo "$lt_cv_truncate_bin" >&6; }
+
+
+
+
+
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
 
 # Check whether --enable-libtool-lock was given.
 if test "${enable_libtool_lock+set}" = set; then :
   enableval=$enable_libtool_lock;
 fi
 
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -6673,24 +6801,25 @@ ia64-*-hpux*)
   test $ac_status = 0; }; then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '#line '$LINENO' "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -6719,9 +6848,50 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -6744,10 +6914,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -6766,10 +6936,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -6787,7 +6957,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
@@ -6827,13 +6997,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
 $as_echo "$lt_cv_cc_needs_belf" >&6; }
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
@@ -6845,7 +7016,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -6854,7 +7025,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -6870,7 +7041,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; }
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
@@ -6981,7 +7152,7 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
 $as_echo "$lt_cv_path_mainfest_tool" >&6; }
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 
@@ -7484,7 +7655,7 @@ if ${lt_cv_apple_cc_single_mod+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -7502,7 +7673,7 @@ else
 	  cat conftest.err >&5
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&5
@@ -7541,7 +7712,7 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
@@ -7570,7 +7741,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&5
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&5
@@ -7583,32 +7754,32 @@ fi
 $as_echo "$lt_cv_ld_force_load" >&6; }
     case $host_os in
     rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[012]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[012][,.]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -7616,6 +7787,41 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
     ;;
   esac
 
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -7900,9 +8106,9 @@ done
 
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case $2 in
+  .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;;
   esac
 } # func_stripname_cnf
 
@@ -7929,14 +8135,14 @@ if test "${enable_shared+set}" = set; then :
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -7960,14 +8166,14 @@ if test "${enable_static+set}" = set; then :
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -7991,14 +8197,14 @@ if test "${with_pic+set}" = set; then :
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8006,8 +8212,6 @@ else
 fi
 
 
-test -z "$pic_mode" && pic_mode=default
-
 
 
 
@@ -8023,14 +8227,14 @@ if test "${enable_fast_install+set}" = set; then :
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac
 else
@@ -8044,11 +8248,63 @@ fi
 
 
 
+  shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[5-9]*,yes)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5
+$as_echo_n "checking which variant of shared library versioning to provide... " >&6; }
+
+# Check whether --with-aix-soname was given.
+if test "${with_aix_soname+set}" = set; then :
+  withval=$with_aix_soname; case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname
+else
+  if ${lt_cv_with_aix_soname+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_with_aix_soname=aix
+fi
+
+    with_aix_soname=$lt_cv_with_aix_soname
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5
+$as_echo "$with_aix_soname" >&6; }
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+
+
+
+
+
+
 
 
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -8097,7 +8353,7 @@ test -z "$LN_S" && LN_S="ln -s"
 
 
 
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -8136,7 +8392,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -8147,14 +8403,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -8163,15 +8419,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
 test -z "$LD" && LD=ld
 test -z "$ac_objext" && ac_objext=o
 
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
 # Only perform the check for file, if the check method requires it
@@ -8186,22 +8435,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+    if test -f "$ac_dir/${ac_tool_prefix}file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8224,13 +8473,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8252,22 +8501,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then :
 else
   case $MAGIC_CMD in
 [\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+    if test -f "$ac_dir/file"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"file"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -8290,13 +8539,13 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac
 fi
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
 $as_echo "$MAGIC_CMD" >&6; }
@@ -8317,7 +8566,7 @@ esac
 
 # Use C for the default configuration in the libtool script
 
-lt_save_CC="$CC"
+lt_save_CC=$CC
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -8379,7 +8628,7 @@ if test -n "$compiler"; then
 
 lt_prog_compiler_no_builtin_flag=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
@@ -8395,7 +8644,7 @@ else
   lt_cv_prog_compiler_rtti_exceptions=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   lt_compiler_flag="-fno-rtti -fno-exceptions"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -8425,7 +8674,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then
     lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
 else
     :
@@ -8443,17 +8692,18 @@ lt_prog_compiler_pic=
 lt_prog_compiler_static=
 
 
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     lt_prog_compiler_wl='-Wl,'
     lt_prog_compiler_static='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       fi
+      lt_prog_compiler_pic='-fPIC'
       ;;
 
     amigaos*)
@@ -8464,8 +8714,8 @@ lt_prog_compiler_static=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -8481,6 +8731,11 @@ lt_prog_compiler_static=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -8551,7 +8806,7 @@ lt_prog_compiler_static=
     case $host_os in
     aix*)
       lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       else
@@ -8559,10 +8814,29 @@ lt_prog_compiler_static=
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        lt_prog_compiler_wl='-Wl,-Wl,,'
+        lt_prog_compiler_pic='-PIC'
+        lt_prog_compiler_static='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       lt_prog_compiler_pic='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -8578,7 +8852,7 @@ lt_prog_compiler_static=
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      lt_prog_compiler_static='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -8589,7 +8863,7 @@ lt_prog_compiler_static=
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	lt_prog_compiler_wl='-Wl,'
 	lt_prog_compiler_pic='-KPIC'
@@ -8614,6 +8888,12 @@ lt_prog_compiler_static=
 	lt_prog_compiler_pic='-PIC'
 	lt_prog_compiler_static='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -8711,7 +8991,7 @@ lt_prog_compiler_static=
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	lt_prog_compiler_pic='-Kconform_pic'
 	lt_prog_compiler_static='-Bstatic'
       fi
@@ -8740,7 +9020,7 @@ lt_prog_compiler_static=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic=
     ;;
@@ -8772,7 +9052,7 @@ else
   lt_cv_prog_compiler_pic_works=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -8802,7 +9082,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works"; then
     case $lt_prog_compiler_pic in
      "" | " "*) ;;
      *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
@@ -8834,7 +9114,7 @@ if ${lt_cv_prog_compiler_static_works+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -8853,13 +9133,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works"; then
     :
 else
     lt_prog_compiler_static=
@@ -8979,8 +9259,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -8992,9 +9272,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -9037,9 +9317,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # included in the symbol list
   include_expsyms=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -9054,7 +9334,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -9062,7 +9342,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
   linux* | k*bsd*-gnu | gnu*)
@@ -9075,7 +9355,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -9097,24 +9377,24 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
+    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+    export_dynamic_flag_spec='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       whole_archive_flag_spec=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -9127,7 +9407,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
     case $host_os in
     aix[3-9]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
@@ -9146,7 +9426,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -9162,7 +9442,7 @@ _LT_EOF
 	allow_undefined_flag=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9172,7 +9452,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
       # as there is no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      export_dynamic_flag_spec='$wl--export-all-symbols'
       allow_undefined_flag=unsupported
       always_export_symbols=no
       enable_shared_with_static_runtimes=yes
@@ -9180,61 +9460,89 @@ _LT_EOF
       exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	ld_shlibs=no
       fi
       ;;
 
     haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       link_all_deplibs=yes
       ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
     interix[3-9]*)
       hardcode_direct=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
+      hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+      export_dynamic_flag_spec='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -9245,42 +9553,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  whole_archive_flag_spec=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  compiler_needs_object=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  export_dynamic_flag_spec='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	  hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
 	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -9294,8 +9607,8 @@ _LT_EOF
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -9313,8 +9626,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
@@ -9326,7 +9639,7 @@ _LT_EOF
 	ld_shlibs=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -9341,9 +9654,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    ld_shlibs=no
 	  fi
@@ -9360,15 +9673,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	ld_shlibs=no
       fi
       ;;
     esac
 
-    if test "$ld_shlibs" = no; then
+    if test no = "$ld_shlibs"; then
       runpath_var=
       hardcode_libdir_flag_spec=
       export_dynamic_flag_spec=
@@ -9384,7 +9697,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	hardcode_direct=unsupported
@@ -9392,34 +9705,57 @@ _LT_EOF
       ;;
 
     aix[4-9]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -9438,13 +9774,21 @@ _LT_EOF
       hardcode_direct_absolute=yes
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      file_list_spec='${wl}-f,'
+      file_list_spec='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	hardcode_direct=no
+	hardcode_direct_absolute=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[012]|aix4.[012].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -9463,36 +9807,42 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	link_all_deplibs=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      export_dynamic_flag_spec='${wl}-bexpall'
+      export_dynamic_flag_spec='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	allow_undefined_flag='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
+        if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -9527,7 +9877,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -9535,17 +9885,17 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'
 	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
+	 if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath_+:} false; then :
@@ -9580,7 +9930,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
+    lt_cv_aix_libpath_=/usr/lib:/lib
   fi
 
 fi
@@ -9588,21 +9938,33 @@ fi
   aix_libpath=$lt_cv_aix_libpath_
 fi
 
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  no_undefined_flag=' $wl-bernotok'
+	  allow_undefined_flag=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    whole_archive_flag_spec='$convenience'
 	  fi
 	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) >  [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    archive_expsym_cmds="$archive_expsym_cmds"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -9611,7 +9973,7 @@ fi
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             archive_expsym_cmds=''
         ;;
       m68k)
@@ -9641,16 +10003,17 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	archive_expsym_cmds='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
 	enable_shared_with_static_runtimes=yes
@@ -9659,18 +10022,18 @@ fi
 	# Don't use ranlib
 	old_postinstall_cmds='chmod 644 $oldlib'
 	postlink_cmds='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -9679,7 +10042,7 @@ fi
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -9698,24 +10061,24 @@ fi
   hardcode_direct=no
   hardcode_automatic=yes
   hardcode_shlibpath_var=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec=''
   fi
   link_all_deplibs=yes
-  allow_undefined_flag="$_lt_dar_allow_undefined"
+  allow_undefined_flag=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
 
   else
   ld_shlibs=no
@@ -9757,33 +10120,33 @@ fi
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl+b $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_direct=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
+      export_dynamic_flag_spec='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 	hardcode_direct=yes
 	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='${wl}-E'
+	export_dynamic_flag_spec='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	hardcode_minus_L=yes
@@ -9791,25 +10154,25 @@ fi
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 
@@ -9821,7 +10184,7 @@ if ${lt_cv_prog_compiler__b+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler__b=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS -b"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -9840,14 +10203,14 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
 $as_echo "$lt_cv_prog_compiler__b" >&6; }
 
-if test x"$lt_cv_prog_compiler__b" = xyes; then
-    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+if test yes = "$lt_cv_prog_compiler__b"; then
+    archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 else
     archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
 fi
@@ -9855,8 +10218,8 @@ fi
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	hardcode_libdir_flag_spec='$wl+b $wl$libdir'
 	hardcode_libdir_separator=:
 
 	case $host_cpu in
@@ -9867,7 +10230,7 @@ fi
 	*)
 	  hardcode_direct=yes
 	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='${wl}-E'
+	  export_dynamic_flag_spec='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -9878,8 +10241,8 @@ fi
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
@@ -9889,8 +10252,8 @@ $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >
 if ${lt_cv_irix_exported_symbol+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+  save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int foo (void) { return 0; }
@@ -9902,24 +10265,35 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
+           LDFLAGS=$save_LDFLAGS
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
 $as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
+	link_all_deplibs=no
       else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       inherit_rpath=yes
       link_all_deplibs=yes
       ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	ld_shlibs=yes
+	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
     netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -9934,7 +10308,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     newsos6)
       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       hardcode_shlibpath_var=no
       ;;
@@ -9942,27 +10316,19 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	hardcode_direct=yes
 	hardcode_shlibpath_var=no
 	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec='${wl}-E'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
+	  export_dynamic_flag_spec='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  hardcode_libdir_flag_spec='$wl-rpath,$libdir'
 	fi
       else
 	ld_shlibs=no
@@ -9973,33 +10339,53 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       hardcode_libdir_flag_spec='-L$libdir'
       hardcode_minus_L=yes
       allow_undefined_flag=unsupported
-      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      enable_shared_with_static_runtimes=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       hardcode_libdir_separator=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	allow_undefined_flag=' $wl-expect_unresolved $wl\*'
+	archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
       else
 	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	hardcode_libdir_flag_spec='-rpath $libdir'
@@ -10010,24 +10396,24 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
     solaris*)
       no_undefined_flag=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -10037,11 +10423,11 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       solaris2.[0-5] | solaris2.[0-5].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
 	fi
@@ -10051,10 +10437,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -10103,43 +10489,43 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='${wl}-z,text'
+      no_undefined_flag='$wl-z,text'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
+      no_undefined_flag='$wl-z,text'
+      allow_undefined_flag='$wl-z,nodefs'
       archive_cmds_need_lc=no
       hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_flag_spec='$wl-R,$libdir'
       hardcode_libdir_separator=':'
       link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
+      export_dynamic_flag_spec='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -10154,10 +10540,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	export_dynamic_flag_spec='$wl-Blargedynsym'
 	;;
       esac
     fi
@@ -10165,7 +10551,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
 $as_echo "$ld_shlibs" >&6; }
-test "$ld_shlibs" = no && can_build_shared=no
+test no = "$ld_shlibs" && can_build_shared=no
 
 with_gnu_ld=$with_gnu_ld
 
@@ -10191,7 +10577,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -10406,14 +10792,14 @@ esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
 $as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -10429,28 +10815,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -10464,7 +10857,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+      $SED 's|/\([A-Za-z]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -10473,7 +10866,7 @@ fi
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -10490,14 +10883,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -10505,41 +10900,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -10549,18 +10994,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -10568,8 +11013,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -10581,7 +11026,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -10590,8 +11035,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -10607,17 +11052,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -10626,8 +11071,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -10654,7 +11099,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -10667,8 +11112,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -10681,7 +11126,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -10694,8 +11139,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -10708,8 +11153,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -10727,12 +11172,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -10762,10 +11208,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -10783,14 +11229,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -10798,8 +11245,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -10808,8 +11255,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -10822,8 +11269,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -10834,7 +11281,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -10842,8 +11289,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -10862,8 +11309,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -10872,13 +11319,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -10922,7 +11389,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -10954,12 +11426,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -10969,7 +11441,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -10978,58 +11450,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -11040,8 +11522,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -11051,11 +11533,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -11063,8 +11545,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -11085,24 +11567,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -11120,7 +11602,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -11128,8 +11610,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -11139,20 +11621,35 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
+
+
+
 
 
 
@@ -11249,15 +11746,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" ||
    test -n "$runpath_var" ||
-   test "X$hardcode_automatic" = "Xyes" ; then
+   test yes = "$hardcode_automatic"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct" != no &&
+  if test no != "$hardcode_direct" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&
+     test no != "$hardcode_minus_L"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action=relink
   else
@@ -11272,12 +11769,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
 $as_echo "$hardcode_action" >&6; }
 
-if test "$hardcode_action" = relink ||
-   test "$inherit_rpath" = yes; then
+if test relink = "$hardcode_action" ||
+   test yes = "$inherit_rpath"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -11287,7 +11784,7 @@ fi
 
 
 
-  if test "x$enable_dlopen" != xyes; then
+  if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -11297,23 +11794,23 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
 if ${ac_cv_lib_dl_dlopen+:} false; then :
@@ -11351,10 +11848,10 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
 
-    lt_cv_dlopen="dyld"
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
 
@@ -11362,10 +11859,18 @@ fi
 
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
 if test "x$ac_cv_func_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load"
+  lt_cv_dlopen=shl_load
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
 $as_echo_n "checking for shl_load in -ldld... " >&6; }
@@ -11404,11 +11909,11 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld
 else
   ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
 if test "x$ac_cv_func_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen"
+  lt_cv_dlopen=dlopen
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
 $as_echo_n "checking for dlopen in -ldl... " >&6; }
@@ -11447,7 +11952,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
@@ -11486,7 +11991,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+  lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
 $as_echo_n "checking for dld_link in -ldld... " >&6; }
@@ -11525,7 +12030,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+  lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld
 fi
 
 
@@ -11546,21 +12051,21 @@ fi
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
@@ -11568,7 +12073,7 @@ $as_echo_n "checking whether a program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -11615,9 +12120,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -11647,7 +12152,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -11667,14 +12172,14 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
 $as_echo "$lt_cv_dlopen_self" >&6; }
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
 if ${lt_cv_dlopen_self_static+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  	  if test "$cross_compiling" = yes; then :
+  	  if test yes = "$cross_compiling"; then :
   lt_cv_dlopen_self_static=cross
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -11721,9 +12226,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -11753,7 +12258,7 @@ _LT_EOF
   (eval $ac_link) 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -11774,9 +12279,9 @@ fi
 $as_echo "$lt_cv_dlopen_self_static" >&6; }
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -11820,7 +12325,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -11848,7 +12353,7 @@ fi
 
 
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
 $as_echo_n "checking if libtool supports shared libraries... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
@@ -11856,13 +12361,13 @@ $as_echo "$can_build_shared" >&6; }
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
 $as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -11870,8 +12375,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; }
     ;;
 
   aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -11881,7 +12390,7 @@ $as_echo "$enable_shared" >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
 $as_echo_n "checking whether to build static libraries... " >&6; }
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
 $as_echo "$enable_static" >&6; }
 
@@ -11895,11 +12404,11 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-CC="$lt_save_CC"
+CC=$lt_save_CC
 
-      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+      if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -12078,7 +12587,7 @@ objext_CXX=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -12139,46 +12648,39 @@ $RM -r conftest*
   CFLAGS=$CXXFLAGS
   compiler=$CC
   compiler_CXX=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+  func_cc_basename $compiler
+cc_basename=$func_cc_basename_result
 
 
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
     else
       lt_prog_compiler_no_builtin_flag_CXX=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
 
 
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+  withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes
 else
   with_gnu_ld=no
 fi
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
 $as_echo_n "checking for ld used by $CC... " >&6; }
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -12192,7 +12694,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -12203,7 +12705,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; }
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
 $as_echo_n "checking for GNU ld... " >&6; }
 else
@@ -12214,32 +12716,32 @@ if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi
 fi
 
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
 $as_echo "$LD" >&6; }
@@ -12275,22 +12777,22 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+        export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           whole_archive_flag_spec_CXX=
         fi
@@ -12327,18 +12829,30 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         ld_shlibs_CXX=no
         ;;
       aix[4-9]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -12348,6 +12862,13 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -12366,13 +12887,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
         hardcode_direct_absolute_CXX=yes
         hardcode_libdir_separator_CXX=':'
         link_all_deplibs_CXX=yes
-        file_list_spec_CXX='${wl}-f,'
+        file_list_spec_CXX='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          hardcode_direct_CXX=no
+          hardcode_direct_absolute_CXX=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[012]|aix4.[012].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -12390,36 +12919,44 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        export_dynamic_flag_spec_CXX='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         always_export_symbols_CXX=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          allow_undefined_flag_CXX='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          no_undefined_flag_CXX='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
-          if test "${lt_cv_aix_libpath+set}" = set; then
+          if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -12454,7 +12991,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -12462,18 +12999,18 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+          hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib'
 	    allow_undefined_flag_CXX="-z nodefs"
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
-	    if test "${lt_cv_aix_libpath+set}" = set; then
+	    if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   if ${lt_cv_aix_libpath__CXX+:} false; then :
@@ -12508,7 +13045,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+    lt_cv_aix_libpath__CXX=/usr/lib:/lib
   fi
 
 fi
@@ -12516,22 +13053,34 @@ fi
   aix_libpath=$lt_cv_aix_libpath__CXX
 fi
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    no_undefined_flag_CXX=' ${wl}-bernotok'
-	    allow_undefined_flag_CXX=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    no_undefined_flag_CXX=' $wl-bernotok'
+	    allow_undefined_flag_CXX=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      whole_archive_flag_spec_CXX='$convenience'
 	    fi
 	    archive_cmds_need_lc_CXX=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_sy [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -12541,7 +13090,7 @@ fi
 	  allow_undefined_flag_CXX=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  ld_shlibs_CXX=no
 	fi
@@ -12569,57 +13118,58 @@ fi
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
 	  enable_shared_with_static_runtimes_CXX=yes
 	  # Don't use ranlib
 	  old_postinstall_cmds_CXX='chmod 644 $oldlib'
 	  postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  hardcode_libdir_flag_spec_CXX='-L$libdir'
-	  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+	  export_dynamic_flag_spec_CXX='$wl--export-all-symbols'
 	  allow_undefined_flag_CXX=unsupported
 	  always_export_symbols_CXX=no
 	  enable_shared_with_static_runtimes_CXX=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    archive_expsym_cmds_CXX='if   test DEF = "`$SED -n     -e '\''s/^[	 ]*//'\''     -e '\''/^\(;.*\)*$/d'\''     -e '\''s/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p'\''     -e q     $export_symbols`" ; then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    ld_shlibs_CXX=no
 	  fi
@@ -12633,27 +13183,27 @@ fi
   hardcode_direct_CXX=no
   hardcode_automatic_CXX=yes
   hardcode_shlibpath_var_CXX=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
   else
     whole_archive_flag_spec_CXX=''
   fi
   link_all_deplibs_CXX=yes
-  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  allow_undefined_flag_CXX=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
+       if test yes != "$lt_cv_apple_cc_single_mod"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 
   else
@@ -12662,6 +13212,34 @@ fi
 
 	;;
 
+      os2*)
+	hardcode_libdir_flag_spec_CXX='-L$libdir'
+	hardcode_minus_L_CXX=yes
+	allow_undefined_flag_CXX=unsupported
+	shrext_cmds=.dll
+	archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	enable_shared_with_static_runtimes_CXX=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -12697,14 +13275,14 @@ fi
         ;;
 
       haiku*)
-        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         link_all_deplibs_CXX=yes
         ;;
 
       hpux9*)
-        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
         hardcode_libdir_separator_CXX=:
-        export_dynamic_flag_spec_CXX='${wl}-E'
+        export_dynamic_flag_spec_CXX='$wl-E'
         hardcode_direct_CXX=yes
         hardcode_minus_L_CXX=yes # Not in the search PATH,
 				             # but as the default
@@ -12716,7 +13294,7 @@ fi
             ld_shlibs_CXX=no
             ;;
           aCC*)
-            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -12725,11 +13303,11 @@ fi
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               ld_shlibs_CXX=no
@@ -12739,15 +13317,15 @@ fi
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir'
 	  hardcode_libdir_separator_CXX=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      export_dynamic_flag_spec_CXX='${wl}-E'
+	      export_dynamic_flag_spec_CXX='$wl-E'
               ;;
           esac
         fi
@@ -12773,13 +13351,13 @@ fi
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -12790,20 +13368,20 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -12818,22 +13396,22 @@ fi
       interix[3-9]*)
 	hardcode_direct_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}-E'
+	hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -12842,17 +13420,17 @@ fi
 	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    link_all_deplibs_CXX=yes
 	    ;;
         esac
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
         hardcode_libdir_separator_CXX=:
         inherit_rpath_CXX=yes
         ;;
@@ -12865,8 +13443,8 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -12875,10 +13453,10 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -12892,59 +13470,59 @@ fi
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    archive_cmds_need_lc_CXX=no
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
 	      prelink_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      old_archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      archive_expsym_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
@@ -12958,18 +13536,18 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
+	    export_dynamic_flag_spec_CXX='$wl--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -12977,10 +13555,10 @@ fi
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      no_undefined_flag_CXX=' -zdefs'
-	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      hardcode_libdir_flag_spec_CXX='-R$libdir'
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      compiler_needs_object_CXX=yes
 
 	      # Not sure whether something based on
@@ -13038,22 +13616,17 @@ fi
         ld_shlibs_CXX=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	ld_shlibs_CXX=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  hardcode_direct_CXX=yes
 	  hardcode_shlibpath_var_CXX=no
 	  hardcode_direct_absolute_CXX=yes
 	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    export_dynamic_flag_spec_CXX='${wl}-E'
-	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='$wl-E'
+	    whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -13069,9 +13642,9 @@ fi
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir'
 	    hardcode_libdir_separator_CXX=:
 
 	    # Archives containing C++ object files must be created using
@@ -13089,17 +13662,17 @@ fi
           cxx*)
 	    case $host in
 	      osf3*)
-	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	        allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        allow_undefined_flag_CXX=' -expect_unresolved \*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
 		;;
 	    esac
@@ -13114,21 +13687,21 @@ fi
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir'
 	      hardcode_libdir_separator_CXX=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -13174,9 +13747,9 @@ fi
 	    # Sun C++ 4.2, 5.x and Centerline C++
             archive_cmds_need_lc_CXX=yes
 	    no_undefined_flag_CXX=' -zdefs'
-	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    hardcode_libdir_flag_spec_CXX='-R$libdir'
 	    hardcode_shlibpath_var_CXX=no
@@ -13184,7 +13757,7 @@ fi
 	      solaris2.[0-5] | solaris2.[0-5].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -13201,30 +13774,30 @@ fi
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      no_undefined_flag_CXX=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -13232,11 +13805,11 @@ fi
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[0-5] | solaris2.[0-5].*) ;;
 		*)
-		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -13245,52 +13818,52 @@ fi
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_CXX='${wl}-z,text'
+      no_undefined_flag_CXX='$wl-z,text'
       archive_cmds_need_lc_CXX=no
       hardcode_shlibpath_var_CXX=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	no_undefined_flag_CXX='${wl}-z,text'
-	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	no_undefined_flag_CXX='$wl-z,text'
+	allow_undefined_flag_CXX='$wl-z,nodefs'
 	archive_cmds_need_lc_CXX=no
 	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_flag_spec_CXX='$wl-R,$libdir'
 	hardcode_libdir_separator_CXX=':'
 	link_all_deplibs_CXX=yes
-	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	export_dynamic_flag_spec_CXX='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
-	      '"$old_archive_cmds_CXX"
+              '"$old_archive_cmds_CXX"
 	    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
-	      '"$reload_cmds_CXX"
+              '"$reload_cmds_CXX"
 	    ;;
 	  *)
-	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -13322,10 +13895,10 @@ fi
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-    test "$ld_shlibs_CXX" = no && can_build_shared=no
+    test no = "$ld_shlibs_CXX" && can_build_shared=no
 
-    GCC_CXX="$GXX"
-    LD_CXX="$LD"
+    GCC_CXX=$GXX
+    LD_CXX=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -13369,13 +13942,13 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -13391,16 +13964,16 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$compiler_lib_search_path_CXX"; then
-	     compiler_lib_search_path_CXX="${prev}${p}"
+	     compiler_lib_search_path_CXX=$prev$p
 	   else
-	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -13408,9 +13981,9 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 esac
        else
 	 if test -z "$postdeps_CXX"; then
-	   postdeps_CXX="${prev}${p}"
+	   postdeps_CXX=$prev$p
 	 else
-	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	   postdeps_CXX="${postdeps_CXX} $prev$p"
 	 fi
        fi
        prev=
@@ -13425,15 +13998,15 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$predep_objects_CXX"; then
-	   predep_objects_CXX="$p"
+	   predep_objects_CXX=$p
 	 else
 	   predep_objects_CXX="$predep_objects_CXX $p"
 	 fi
        else
 	 if test -z "$postdep_objects_CXX"; then
-	   postdep_objects_CXX="$p"
+	   postdep_objects_CXX=$p
 	 else
 	   postdep_objects_CXX="$postdep_objects_CXX $p"
 	 fi
@@ -13463,51 +14036,6 @@ interix[3-9]*)
   postdep_objects_CXX=
   postdeps_CXX=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 
 
@@ -13516,7 +14044,7 @@ case " $postdeps_CXX " in
 esac
  compiler_lib_search_dirs_CXX=
 if test -n "${compiler_lib_search_path_CXX}"; then
- compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 
 
@@ -13555,17 +14083,18 @@ lt_prog_compiler_static_CXX=
 
 
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     lt_prog_compiler_wl_CXX='-Wl,'
     lt_prog_compiler_static_CXX='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static_CXX='-Bstatic'
       fi
+      lt_prog_compiler_pic_CXX='-fPIC'
       ;;
 
     amigaos*)
@@ -13576,8 +14105,8 @@ lt_prog_compiler_static_CXX=
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -13592,6 +14121,11 @@ lt_prog_compiler_static_CXX=
       # Although the cygwin gcc ignores -fPIC, still need this for old-style
       # (--disable-auto-import) libraries
       lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      case $host_os in
+      os2*)
+	lt_prog_compiler_static_CXX='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -13641,7 +14175,7 @@ lt_prog_compiler_static_CXX=
     case $host_os in
       aix[4-9]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  lt_prog_compiler_static_CXX='-Bstatic'
 	else
@@ -13681,14 +14215,14 @@ lt_prog_compiler_static_CXX=
 	case $cc_basename in
 	  CC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      lt_prog_compiler_pic_CXX='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    lt_prog_compiler_static_CXX='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -13725,7 +14259,7 @@ lt_prog_compiler_static_CXX=
 	    lt_prog_compiler_pic_CXX='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    lt_prog_compiler_wl_CXX='-Wl,'
 	    lt_prog_compiler_pic_CXX='-KPIC'
 	    lt_prog_compiler_static_CXX='-static'
@@ -13870,7 +14404,7 @@ lt_prog_compiler_static_CXX=
   fi
 
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     lt_prog_compiler_pic_CXX=
     ;;
@@ -13902,7 +14436,7 @@ else
   lt_cv_prog_compiler_pic_works_CXX=no
    ac_outfile=conftest.$ac_objext
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -13932,7 +14466,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then
     case $lt_prog_compiler_pic_CXX in
      "" | " "*) ;;
      *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
@@ -13958,7 +14492,7 @@ if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   lt_cv_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -13977,13 +14511,13 @@ else
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then
     :
 else
     lt_prog_compiler_static_CXX=
@@ -14097,8 +14631,8 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
 $as_echo_n "checking if we can lock with hard links... " >&6; }
@@ -14110,9 +14644,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; }
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
 $as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+  if test no = "$hard_links"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}
     need_locks=warn
   fi
 else
@@ -14129,17 +14663,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   case $host_os in
   aix[4-9]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    export_symbols_cmds_CXX="$ltdll_cmds"
+    export_symbols_cmds_CXX=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -14162,7 +14700,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
 $as_echo "$ld_shlibs_CXX" >&6; }
-test "$ld_shlibs_CXX" = no && can_build_shared=no
+test no = "$ld_shlibs_CXX" && can_build_shared=no
 
 with_gnu_ld_CXX=$with_gnu_ld
 
@@ -14179,7 +14717,7 @@ x|xyes)
   # Assume -lc should be added
   archive_cmds_need_lc_CXX=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $archive_cmds_CXX in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -14307,7 +14845,7 @@ $as_echo_n "checking dynamic linker characteristics... " >&6; }
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -14324,14 +14862,16 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[4-9]*)
@@ -14339,41 +14879,91 @@ aix[4-9]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[01] | aix4.[01].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a(lib.so.V)'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -14383,18 +14973,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -14402,8 +14992,8 @@ beos*)
 bsdi[45]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -14415,7 +15005,7 @@ bsdi[45]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -14424,8 +15014,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -14441,16 +15031,16 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
 
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -14459,8 +15049,8 @@ cygwin* | mingw* | pw32* | cegcc*)
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -14487,7 +15077,7 @@ cygwin* | mingw* | pw32* | cegcc*)
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -14500,8 +15090,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -14514,7 +15104,7 @@ cygwin* | mingw* | pw32* | cegcc*)
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -14527,8 +15117,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -14540,8 +15130,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -14559,12 +15149,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -14594,10 +15185,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -14615,14 +15206,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -14630,8 +15222,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -14640,8 +15232,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -14654,8 +15246,8 @@ interix[3-9]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -14666,7 +15258,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -14674,8 +15266,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -14694,8 +15286,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -14704,13 +15296,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  hardcode_libdir_flag_spec_CXX='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -14754,7 +15366,12 @@ fi
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -14786,12 +15403,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -14801,7 +15418,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -14810,58 +15427,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -14872,8 +15499,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -14883,11 +15510,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -14895,8 +15522,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -14917,24 +15544,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -14952,7 +15579,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -14960,8 +15587,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -14971,20 +15598,32 @@ uts4*)
 esac
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
 $as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
+
+
 
 
 
@@ -15027,15 +15666,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" ||
    test -n "$runpath_var_CXX" ||
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+   test yes = "$hardcode_automatic_CXX"; then
 
   # We can hardcode non-existent directories.
-  if test "$hardcode_direct_CXX" != no &&
+  if test no != "$hardcode_direct_CXX" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
-     test "$hardcode_minus_L_CXX" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" &&
+     test no != "$hardcode_minus_L_CXX"; then
     # Linking always hardcodes the temporary library directory.
     hardcode_action_CXX=relink
   else
@@ -15050,12 +15689,12 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
 $as_echo "$hardcode_action_CXX" >&6; }
 
-if test "$hardcode_action_CXX" = relink ||
-   test "$inherit_rpath_CXX" = yes; then
+if test relink = "$hardcode_action_CXX" ||
+   test yes = "$inherit_rpath_CXX"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -15078,7 +15717,7 @@ fi
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
@@ -16486,6 +17125,7 @@ enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`'
 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
 PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
@@ -16535,10 +17175,13 @@ compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
 GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`'
 nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
 lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`'
 objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
 MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
@@ -16603,7 +17246,8 @@ finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
 finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
 hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
 sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
-sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`'
+configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`'
 hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
 enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
 enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
@@ -16708,9 +17352,12 @@ CFLAGS \
 compiler \
 lt_cv_sys_global_symbol_pipe \
 lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_import \
 lt_cv_sys_global_symbol_to_c_name_address \
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+lt_cv_nm_interface \
 nm_file_list_spec \
+lt_cv_truncate_bin \
 lt_prog_compiler_no_builtin_flag \
 lt_prog_compiler_pic \
 lt_prog_compiler_wl \
@@ -16776,7 +17423,7 @@ postdeps_CXX \
 compiler_lib_search_path_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -16803,7 +17450,8 @@ postinstall_cmds \
 postuninstall_cmds \
 finish_cmds \
 sys_lib_search_path_spec \
-sys_lib_dlsearch_path_spec \
+configure_time_dlsearch_path \
+configure_time_lt_sys_library_path \
 reload_cmds_CXX \
 old_archive_cmds_CXX \
 old_archive_from_new_cmds_CXX \
@@ -16817,7 +17465,7 @@ prelink_cmds_CXX \
 postlink_cmds_CXX; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -16826,19 +17474,16 @@ postlink_cmds_CXX; do
 done
 
 ac_aux_dir='$ac_aux_dir'
-xsi_shell='$xsi_shell'
-lt_shell_append='$lt_shell_append'
 
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
 
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'
 
@@ -17551,55 +18196,53 @@ $as_echo X"$file" |
  ;;
     "libtool":C)
 
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # The names of the tagged configurations supported by this script.
-available_tags="CXX "
+available_tags='CXX '
+
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
 
 # ### BEGIN LIBTOOL CONFIG
 
@@ -17619,6 +18262,9 @@ pic_mode=$pic_mode
 # Whether or not to optimize for fast installation.
 fast_install=$enable_fast_install
 
+# Shared archive member basename,for filename based shared library versioning on AIX.
+shared_archive_member_spec=$shared_archive_member_spec
+
 # Shell to use when invoking shell scripts.
 SHELL=$lt_SHELL
 
@@ -17736,18 +18382,27 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 # Transform the output of nm in a proper C declaration.
 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
+# Transform the output of nm into a list of symbols to manually relocate.
+global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import
+
 # Transform the output of nm in a C name address pair.
 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
 # Transform the output of nm in a C name address pair when lib prefix is needed.
 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 
+# The name lister interface.
+nm_interface=$lt_lt_cv_nm_interface
+
 # Specify filename containing input files for \$NM.
 nm_file_list_spec=$lt_nm_file_list_spec
 
-# The root where to search for dependent libraries,and in which our libraries should be installed.
+# The root where to search for dependent libraries,and where our libraries should be installed.
 lt_sysroot=$lt_sysroot
 
+# Command to truncate a binary pipe.
+lt_truncate_bin=$lt_lt_cv_truncate_bin
+
 # The name of the directory that contains temporary libtool files.
 objdir=$objdir
 
@@ -17838,8 +18493,11 @@ hardcode_into_libs=$hardcode_into_libs
 # Compile-time system search path for libraries.
 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
-# Run-time system search path for libraries.
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+# Detected run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path
+
+# Explicit LT_SYS_LIBRARY_PATH set during ./configure time.
+configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path
 
 # Whether dlopen is supported.
 dlopen_support=$enable_dlopen
@@ -17932,13 +18590,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute
 
@@ -18004,13 +18662,72 @@ compiler_lib_search_path=$lt_compiler_lib_search_path
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x$2 in
+    x)
+        ;;
+    *:)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
+        ;;
+    x:*)
+        eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
+        ;;
+    *)
+        eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+
+
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in $*""; do
+      case $cc_temp in
+        compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+        distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -18019,7 +18736,7 @@ _LT_EOF
   esac
 
 
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 
 
   # We use sed instead of cat because bash on DJGPP gets confused if
@@ -18029,165 +18746,6 @@ ltmain="$ac_aux_dir/ltmain.sh"
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  if test x"$xsi_shell" = xyes; then
-  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
-func_dirname ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_basename ()$/,/^} # func_basename /c\
-func_basename ()\
-{\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
-func_dirname_and_basename ()\
-{\
-\    case ${1} in\
-\      */*) func_dirname_result="${1%/*}${2}" ;;\
-\      *  ) func_dirname_result="${3}" ;;\
-\    esac\
-\    func_basename_result="${1##*/}"\
-} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
-func_stripname ()\
-{\
-\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
-\    # positional parameters, so assign one to ordinary parameter first.\
-\    func_stripname_result=${3}\
-\    func_stripname_result=${func_stripname_result#"${1}"}\
-\    func_stripname_result=${func_stripname_result%"${2}"}\
-} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
-func_split_long_opt ()\
-{\
-\    func_split_long_opt_name=${1%%=*}\
-\    func_split_long_opt_arg=${1#*=}\
-} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
-func_split_short_opt ()\
-{\
-\    func_split_short_opt_arg=${1#??}\
-\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
-} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
-func_lo2o ()\
-{\
-\    case ${1} in\
-\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
-\      *)    func_lo2o_result=${1} ;;\
-\    esac\
-} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_xform ()$/,/^} # func_xform /c\
-func_xform ()\
-{\
-    func_xform_result=${1%.*}.lo\
-} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_arith ()$/,/^} # func_arith /c\
-func_arith ()\
-{\
-    func_arith_result=$(( $* ))\
-} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_len ()$/,/^} # func_len /c\
-func_len ()\
-{\
-    func_len_result=${#1}\
-} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  sed -e '/^func_append ()$/,/^} # func_append /c\
-func_append ()\
-{\
-    eval "${1}+=\\${2}"\
-} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
-func_append_quoted ()\
-{\
-\    func_quote_for_eval "${2}"\
-\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
-} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
-$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
-fi
-
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -18274,13 +18832,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary.
 hardcode_direct=$hardcode_direct_CXX
 
-# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
-# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# "absolute",i.e impossible to change by setting \$shlibpath_var if the
 # library is relocated.
 hardcode_direct_absolute=$hardcode_direct_absolute_CXX
 
diff --git a/src/gmock/gtest/m4/libtool.m4 b/src/gmock/gtest/m4/libtool.m4
index d7c043f..10ab284 100644
--- a/src/gmock/gtest/m4/libtool.m4
+++ b/src/gmock/gtest/m4/libtool.m4
@@ -1,8 +1,6 @@
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
+#   Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -10,36 +8,30 @@
 # modifications, as long as this notice is preserved.
 
 m4_define([_LT_COPYING], [dnl
-#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-#                 Foundation, Inc.
-#   Written by Gordon Matzigkeit, 1996
-#
-#   This file is part of GNU Libtool.
-#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
 #
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the  same
+# distribution terms that you use for the rest of that program.
 #
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING.  If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ])
 
-# serial 57 LT_INIT
+# serial 58 LT_INIT
 
 
 # LT_PREREQ(VERSION)
@@ -67,7 +59,7 @@ esac
 # LT_INIT([OPTIONS])
 # ------------------
 AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 AC_BEFORE([$0], [LT_LANG])dnl
 AC_BEFORE([$0], [LT_OUTPUT])dnl
@@ -91,7 +83,7 @@ dnl Parse OPTIONS
 _LT_SET_OPTIONS([$0], [$1])
 
 # This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
 
 # Always use our own libtool.
 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -111,26 +103,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in @S|@*""; do
+      case $cc_temp in
+        compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+        distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
 # _LT_CC_BASENAME(CC)
 # -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
 m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
 ])
 
 
 # _LT_FILEUTILS_DEFAULTS
 # ----------------------
 # It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
 m4_defun([_LT_FILEUTILS_DEFAULTS],
 [: ${CP="cp -f"}
 : ${MV="mv -f"}
@@ -177,15 +186,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
 m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
 
 _LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
 # commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 ])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
    setopt NO_GLOB_SUBST
 fi
 
@@ -198,7 +208,7 @@ aix3*)
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
+  if test set != "${COLLECT_NAMES+set}"; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -209,14 +219,14 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
 # which needs '.lib').
 libext=a
 
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
 
 # Set sane defaults for various variables
 test -z "$CC" && CC=cc
@@ -269,14 +279,14 @@ no_glob_subst='s/\*/\\\*/g'
 
 # _LT_PROG_LTMAIN
 # ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
 # now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
 # so we pass a copy along to make sure it has a sensible value anyway.
 m4_defun([_LT_PROG_LTMAIN],
 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
 ])# _LT_PROG_LTMAIN
 
 
@@ -286,7 +296,7 @@ ltmain="$ac_aux_dir/ltmain.sh"
 
 # So that we can recreate a full libtool script including additional
 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
 # label.
 
 
@@ -421,8 +431,8 @@ m4_define([_lt_decl_all_varnames],
 
 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
 # ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'.  VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'.  VARNAME
 # must have a single quote delimited value for this to work.
 m4_define([_LT_CONFIG_STATUS_DECLARE],
 [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
@@ -446,7 +456,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
 # Output comment and list of tags supported by the script
 m4_defun([_LT_LIBTOOL_TAGS],
 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
 ])
 
 
@@ -474,7 +484,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
 # _LT_LIBTOOL_CONFIG_VARS
 # -----------------------
 # Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
 # script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
 # section) are produced by _LT_LIBTOOL_TAG_VARS.
 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -500,8 +510,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
 # Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
 # variables for single and double quote escaping we saved from calls
 # to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'.  Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'.  Finally, any additional code accumulated
 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
 m4_defun([_LT_CONFIG_COMMANDS],
 [AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -547,7 +557,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_quote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -560,7 +570,7 @@ for var in lt_decl_all_varnames([[ \
 ]], lt_decl_dquote_varnames); do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[[\\\\\\\`\\"\\\$]]*)
-      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
       ;;
     *)
       eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -576,7 +586,7 @@ _LT_OUTPUT_LIBTOOL_INIT
 # Generate a child script FILE with all initialization necessary to
 # reuse the environment learned by the parent script, and make the
 # file executable.  If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins.  After this
+# '#!' sequence but before initialization text begins.  After this
 # macro, additional text can be appended to FILE to form the body of
 # the child script.  The macro ends with non-zero status if the
 # file could not be fully written (such as if the disk is full).
@@ -598,7 +608,7 @@ AS_SHELL_SANITIZE
 _AS_PREPARE
 exec AS_MESSAGE_FD>&1
 _ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
 m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
 
 # LT_OUTPUT
@@ -621,7 +631,7 @@ exec AS_MESSAGE_LOG_FD>>config.log
 } >&AS_MESSAGE_LOG_FD
 
 lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
 for use in further configure time tests before the real libtool is
 generated.
 
@@ -643,7 +653,7 @@ Copyright (C) 2011 Free Software Foundation, Inc.
 This config.lt script is free software; the Free Software Foundation
 gives unlimited permision to copy, distribute and modify it."
 
-while test $[#] != 0
+while test 0 != $[#]
 do
   case $[1] in
     --version | --v* | -V )
@@ -656,10 +666,10 @@ do
       lt_cl_silent=: ;;
 
     -*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
 
     *) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
   esac
   shift
 done
@@ -685,7 +695,7 @@ chmod +x "$CONFIG_LT"
 # open by configure.  Here we exec the FD to /dev/null, effectively closing
 # config.log, so it can be properly (re)opened and appended to by config.lt.
 lt_cl_success=:
-test "$silent" = yes &&
+test yes = "$silent" &&
   lt_config_lt_args="$lt_config_lt_args --quiet"
 exec AS_MESSAGE_LOG_FD>/dev/null
 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
@@ -705,27 +715,31 @@ m4_defun([_LT_CONFIG],
 _LT_CONFIG_SAVE_COMMANDS([
   m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
   m4_if(_LT_TAG, [C], [
-    # See if we are running on zsh, and set the options which allow our
+    # See if we are running on zsh, and set the options that allow our
     # commands through without removal of \ escapes.
-    if test -n "${ZSH_VERSION+set}" ; then
+    if test -n "${ZSH_VERSION+set}"; then
       setopt NO_GLOB_SUBST
     fi
 
-    cfgfile="${ofile}T"
+    cfgfile=${ofile}T
     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
     $RM "$cfgfile"
 
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
 _LT_COPYING
 _LT_LIBTOOL_TAGS
 
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
 # ### BEGIN LIBTOOL CONFIG
 _LT_LIBTOOL_CONFIG_VARS
 _LT_LIBTOOL_TAG_VARS
@@ -733,13 +747,24 @@ _LT_LIBTOOL_TAG_VARS
 
 _LT_EOF
 
+    cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
   case $host_os in
   aix3*)
     cat <<\_LT_EOF >> "$cfgfile"
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -756,8 +781,6 @@ _LT_EOF
   sed '$q' "$ltmain" >> "$cfgfile" \
      || (rm -f "$cfgfile"; exit 1)
 
-  _LT_PROG_REPLACE_SHELLFNS
-
    mv -f "$cfgfile" "$ofile" ||
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
@@ -775,7 +798,6 @@ _LT_EOF
 [m4_if([$1], [], [
     PACKAGE='$PACKAGE'
     VERSION='$VERSION'
-    TIMESTAMP='$TIMESTAMP'
     RM='$RM'
     ofile='$ofile'], [])
 ])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -974,7 +996,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 
     AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
       [lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
+      if test -z "$LT_MULTI_MODULE"; then
 	# By default we will add the -single_module flag. You can override
 	# by either setting the environment variable LT_MULTI_MODULE
 	# non-empty at configure time, or by adding -multi_module to the
@@ -992,7 +1014,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
 	# Otherwise, if the output was created with a 0 exit code from
 	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
 	  lt_cv_apple_cc_single_mod=yes
 	else
 	  cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1010,7 +1032,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
 	[lt_cv_ld_exported_symbols_list=yes],
 	[lt_cv_ld_exported_symbols_list=no])
-	LDFLAGS="$save_LDFLAGS"
+	LDFLAGS=$save_LDFLAGS
     ])
 
     AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
@@ -1032,7 +1054,7 @@ _LT_EOF
       _lt_result=$?
       if test -s conftest.err && $GREP force_load conftest.err; then
 	cat conftest.err >&AS_MESSAGE_LOG_FD
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+      elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
 	lt_cv_ld_force_load=yes
       else
 	cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1042,32 +1064,32 @@ _LT_EOF
     ])
     case $host_os in
     rhapsody* | darwin1.[[012]])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
     darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+      _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
     darwin*) # darwin 5.x on
       # if running on 10.5 or later, the deployment target defaults
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
 	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[[012]]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]][[,.]]*)
+	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
 	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
   esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+    if test yes = "$lt_cv_apple_cc_single_mod"; then
       _lt_dar_single_mod='$single_module'
     fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    if test yes = "$lt_cv_ld_exported_symbols_list"; then
+      _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
     else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
     fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+    if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
       _lt_dsymutil='~$DSYMUTIL $lib || :'
     else
       _lt_dsymutil=
@@ -1087,29 +1109,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_automatic, $1)=yes
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  if test yes = "$lt_cv_ld_force_load"; then
+    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
     m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
                   [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])
   else
     _LT_TAGVAR(whole_archive_flag_spec, $1)=''
   fi
   _LT_TAGVAR(link_all_deplibs, $1)=yes
-  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
   case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
+     ifort*|nagfor*) _lt_dar_can_shared=yes ;;
      *) _lt_dar_can_shared=$GCC ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
+  if test yes = "$_lt_dar_can_shared"; then
     output_verbose_link_cmd=func_echo_all
-    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
     m4_if([$1], [CXX],
-[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[   if test yes != "$lt_cv_apple_cc_single_mod"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
     fi
 ],[])
   else
@@ -1129,7 +1151,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
 # Allow to override them for all tags through lt_cv_aix_libpath.
 m4_defun([_LT_SYS_MODULE_PATH_AIX],
 [m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
+if test set = "${lt_cv_aix_libpath+set}"; then
   aix_libpath=$lt_cv_aix_libpath
 else
   AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
@@ -1147,7 +1169,7 @@ else
     _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
   fi],[])
   if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
-    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
   fi
   ])
   aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
@@ -1167,8 +1189,8 @@ m4_define([_LT_SHELL_INIT],
 # -----------------------
 # Find how we can fake an echo command that does not interpret backslash.
 # In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
 m4_defun([_LT_PROG_ECHO_BACKSLASH],
 [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
@@ -1196,10 +1218,10 @@ fi
 # Invoke $ECHO with all args, space-separated.
 func_echo_all ()
 {
-    $ECHO "$*" 
+    $ECHO "$*"
 }
 
-case "$ECHO" in
+case $ECHO in
   printf*) AC_MSG_RESULT([printf]) ;;
   print*) AC_MSG_RESULT([print -r]) ;;
   *) AC_MSG_RESULT([cat]) ;;
@@ -1225,16 +1247,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
 AC_DEFUN([_LT_WITH_SYSROOT],
 [AC_MSG_CHECKING([for sysroot])
 AC_ARG_WITH([sysroot],
-[  --with-sysroot[=DIR] Search for dependent libraries within DIR
-                        (or the compiler's sysroot if not specified).],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+  [Search for dependent libraries within DIR (or the compiler's sysroot
+   if not specified).])],
 [], [with_sysroot=no])
 
 dnl lt_sysroot will always be passed unquoted.  We quote it here
 dnl in case the user passed a directory name.
 lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
  yes)
-   if test "$GCC" = yes; then
+   if test yes = "$GCC"; then
      lt_sysroot=`$CC --print-sysroot 2>/dev/null`
    fi
    ;; #(
@@ -1244,14 +1267,14 @@ case ${with_sysroot} in #(
  no|'')
    ;; #(
  *)
-   AC_MSG_RESULT([${with_sysroot}])
+   AC_MSG_RESULT([$with_sysroot])
    AC_MSG_ERROR([The sysroot must be an absolute path.])
    ;;
 esac
 
  AC_MSG_RESULT([${lt_sysroot:-no}])
 _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+[dependent libraries, and where our libraries should be installed.])])
 
 # _LT_ENABLE_LOCK
 # ---------------
@@ -1259,31 +1282,33 @@ m4_defun([_LT_ENABLE_LOCK],
 [AC_ARG_ENABLE([libtool-lock],
   [AS_HELP_STRING([--disable-libtool-lock],
     [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
 case $host in
 ia64-*-hpux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set mode
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.$ac_objext` in
       *ELF-32*)
-	HPUX_IA64_MODE="32"
+	HPUX_IA64_MODE=32
 	;;
       *ELF-64*)
-	HPUX_IA64_MODE="64"
+	HPUX_IA64_MODE=64
 	;;
     esac
   fi
   rm -rf conftest*
   ;;
 *-*-irix6*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
+    if test yes = "$lt_cv_prog_gnu_ld"; then
       case `/usr/bin/file conftest.$ac_objext` in
 	*32-bit*)
 	  LD="${LD-ld} -melf32bsmip"
@@ -1312,9 +1337,46 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
+mips64*-*linux*)
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
+  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    emul=elf
+    case `/usr/bin/file conftest.$ac_objext` in
+      *32-bit*)
+	emul="${emul}32"
+	;;
+      *64-bit*)
+	emul="${emul}64"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *MSB*)
+	emul="${emul}btsmip"
+	;;
+      *LSB*)
+	emul="${emul}ltsmip"
+	;;
+    esac
+    case `/usr/bin/file conftest.$ac_objext` in
+      *N32*)
+	emul="${emul}n32"
+	;;
+    esac
+    LD="${LD-ld} -m $emul"
+  fi
+  rm -rf conftest*
+  ;;
+
 x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.  Note that the listed cases only cover the
+  # situations where additional linker options are needed (such as when
+  # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+  # vice versa); the common cases where no linker options are needed do
+  # not appear in the list.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1333,10 +1395,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  powerpc64le-*)
+	  powerpc64le-*linux*)
 	    LD="${LD-ld} -m elf32lppclinux"
 	    ;;
-	  powerpc64-*)
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1355,10 +1417,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
+	  powerpcle-*linux*)
 	    LD="${LD-ld} -m elf64lppc"
 	    ;;
-	  powerpc-*)
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -1376,19 +1438,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
 *-*-sco3.2v5*)
   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
+  SAVE_CFLAGS=$CFLAGS
   CFLAGS="$CFLAGS -belf"
   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
     [AC_LANG_PUSH(C)
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
      AC_LANG_POP])
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+  if test yes != "$lt_cv_cc_needs_belf"; then
     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
+    CFLAGS=$SAVE_CFLAGS
   fi
   ;;
 *-*solaris*)
-  # Find out which ABI we are using.
+  # Find out what ABI is being produced by ac_compile, and set linker
+  # options accordingly.
   echo 'int i;' > conftest.$ac_ext
   if AC_TRY_EVAL(ac_compile); then
     case `/usr/bin/file conftest.o` in
@@ -1396,7 +1459,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
       case $lt_cv_prog_gnu_ld in
       yes*)
         case $host in
-        i?86-*-solaris*)
+        i?86-*-solaris*|x86_64-*-solaris*)
           LD="${LD-ld} -m elf_x86_64"
           ;;
         sparc*-*-solaris*)
@@ -1405,7 +1468,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
         esac
         # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
         if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
+          LD=${LD-ld}_sol2
         fi
         ;;
       *)
@@ -1421,7 +1484,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
 ])# _LT_ENABLE_LOCK
 
 
@@ -1440,11 +1503,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      [echo conftest.$ac_objext > conftest.lst
       lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
       AC_TRY_EVAL([lt_ar_try])
-      if test "$ac_status" -eq 0; then
+      if test 0 -eq "$ac_status"; then
 	# Ensure the archiver fails upon bogus file names.
 	rm -f conftest.$ac_objext libconftest.a
 	AC_TRY_EVAL([lt_ar_try])
-	if test "$ac_status" -ne 0; then
+	if test 0 -ne "$ac_status"; then
           lt_cv_ar_at_file=@
         fi
       fi
@@ -1452,7 +1515,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
      ])
   ])
 
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
   archiver_list_spec=
 else
   archiver_list_spec=$lt_cv_ar_at_file
@@ -1483,7 +1546,7 @@ old_postuninstall_cmds=
 
 if test -n "$RANLIB"; then
   case $host_os in
-  openbsd*)
+  bitrig* | openbsd*)
     old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
     ;;
   *)
@@ -1519,7 +1582,7 @@ AC_CACHE_CHECK([$1], [$2],
   [$2=no
    m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
    echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$3"
+   lt_compiler_flag="$3"  ## exclude from sc_useless_quotes_in_assignment
    # Insert the option either (1) after the last *FLAGS variable, or
    # (2) before a word containing "conftest.", or (3) at the end.
    # Note that $ac_compile itself does not contain backslashes and begins
@@ -1546,7 +1609,7 @@ AC_CACHE_CHECK([$1], [$2],
    $RM conftest*
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$5], , :, [$5])
 else
     m4_if([$6], , :, [$6])
@@ -1568,7 +1631,7 @@ AC_DEFUN([_LT_LINKER_OPTION],
 m4_require([_LT_DECL_SED])dnl
 AC_CACHE_CHECK([$1], [$2],
   [$2=no
-   save_LDFLAGS="$LDFLAGS"
+   save_LDFLAGS=$LDFLAGS
    LDFLAGS="$LDFLAGS $3"
    echo "$lt_simple_link_test_code" > conftest.$ac_ext
    if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1587,10 +1650,10 @@ AC_CACHE_CHECK([$1], [$2],
      fi
    fi
    $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+   LDFLAGS=$save_LDFLAGS
 ])
 
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
     m4_if([$4], , :, [$4])
 else
     m4_if([$5], , :, [$5])
@@ -1611,7 +1674,7 @@ AC_DEFUN([LT_CMD_MAX_LEN],
 AC_MSG_CHECKING([the maximum length of command line arguments])
 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   i=0
-  teststring="ABCD"
+  teststring=ABCD
 
   case $build_os in
   msdosdjgpp*)
@@ -1651,7 +1714,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1702,22 +1765,22 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
     if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+       test undefined != "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
       # Make teststring a little bigger before we do anything with it.
       # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
+      for i in 1 2 3 4 5 6 7 8; do
         teststring=$teststring$teststring
       done
       SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
       # If test is not a shell built-in, we'll probably end up computing a
       # maximum length that is only half of the actual maximum length, but
       # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+      while { test X`env echo "$teststring$teststring" 2>/dev/null` \
 	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
+	      test 17 != "$i" # 1/2 MB should be enough
       do
         i=`expr $i + 1`
         teststring=$teststring$teststring
@@ -1733,7 +1796,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     ;;
   esac
 ])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
   AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
 else
   AC_MSG_RESULT(none)
@@ -1761,7 +1824,7 @@ m4_defun([_LT_HEADER_DLFCN],
 # ----------------------------------------------------------------
 m4_defun([_LT_TRY_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
   [$4]
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -1808,9 +1871,9 @@ else
 #  endif
 #endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
    correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
 int fnord () __attribute__((visibility("default")));
 #endif
 
@@ -1836,7 +1899,7 @@ int main ()
   return status;
 }]
 _LT_EOF
-  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+  if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
     (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -1857,7 +1920,7 @@ rm -fr conftest*
 # ------------------
 AC_DEFUN([LT_SYS_DLOPEN_SELF],
 [m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
   enable_dlopen=unknown
   enable_dlopen_self=unknown
   enable_dlopen_self_static=unknown
@@ -1867,44 +1930,52 @@ else
 
   case $host_os in
   beos*)
-    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen=load_add_on
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ;;
 
   mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen=LoadLibrary
     lt_cv_dlopen_libs=
     ;;
 
   cygwin*)
-    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen=dlopen
     lt_cv_dlopen_libs=
     ;;
 
   darwin*)
-  # if libdl is installed we need to link against it
+    # if libdl is installed we need to link against it
     AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
-    lt_cv_dlopen="dyld"
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+    lt_cv_dlopen=dyld
     lt_cv_dlopen_libs=
     lt_cv_dlopen_self=yes
     ])
     ;;
 
+  tpf*)
+    # Don't try to run any link tests for TPF.  We know it's impossible
+    # because TPF is a cross-compiler, and we know how we open DSOs.
+    lt_cv_dlopen=dlopen
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=no
+    ;;
+
   *)
     AC_CHECK_FUNC([shl_load],
-	  [lt_cv_dlopen="shl_load"],
+	  [lt_cv_dlopen=shl_load],
       [AC_CHECK_LIB([dld], [shl_load],
-	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	    [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
 	[AC_CHECK_FUNC([dlopen],
-	      [lt_cv_dlopen="dlopen"],
+	      [lt_cv_dlopen=dlopen],
 	  [AC_CHECK_LIB([dl], [dlopen],
-		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+		[lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
 	    [AC_CHECK_LIB([svld], [dlopen],
-		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+		  [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
 	      [AC_CHECK_LIB([dld], [dld_link],
-		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+		    [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
 	      ])
 	    ])
 	  ])
@@ -1913,21 +1984,21 @@ else
     ;;
   esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
+  if test no = "$lt_cv_dlopen"; then
     enable_dlopen=no
+  else
+    enable_dlopen=yes
   fi
 
   case $lt_cv_dlopen in
   dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    save_CPPFLAGS=$CPPFLAGS
+    test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
+    save_LDFLAGS=$LDFLAGS
     wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
+    save_LIBS=$LIBS
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1937,7 +2008,7 @@ else
 	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
     ])
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
+    if test yes = "$lt_cv_dlopen_self"; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
 	  lt_cv_dlopen_self_static, [dnl
@@ -1947,9 +2018,9 @@ else
       ])
     fi
 
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS=$save_CPPFLAGS
+    LDFLAGS=$save_LDFLAGS
+    LIBS=$save_LIBS
     ;;
   esac
 
@@ -2041,8 +2112,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS],
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 _LT_COMPILER_C_O([$1])
 
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
   # do not overwrite the value of need_locks provided by the user
   AC_MSG_CHECKING([if we can lock with hard links])
   hard_links=yes
@@ -2052,8 +2123,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" !=
   ln conftest.a conftest.b 2>&5 || hard_links=no
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
   AC_MSG_RESULT([$hard_links])
-  if test "$hard_links" = no; then
-    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+  if test no = "$hard_links"; then
+    AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
     need_locks=warn
   fi
 else
@@ -2080,8 +2151,8 @@ objdir=$lt_cv_objdir
 _LT_DECL([], [objdir], [0],
          [The name of the directory that contains temporary libtool files])dnl
 m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
-  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+  [Define to the sub-directory where libtool stores uninstalled libraries.])
 ])# _LT_CHECK_OBJDIR
 
 
@@ -2093,15 +2164,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
 _LT_TAGVAR(hardcode_action, $1)=
 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
    test -n "$_LT_TAGVAR(runpath_var, $1)" ||
-   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+   test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
 
   # We can hardcode non-existent directories.
-  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+  if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
      # If the only mechanism to avoid hardcoding is shlibpath_var, we
      # have to relink, otherwise we might link with an installed library
      # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
-     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+     ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+     test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
     # Linking always hardcodes the temporary library directory.
     _LT_TAGVAR(hardcode_action, $1)=relink
   else
@@ -2115,12 +2186,12 @@ else
 fi
 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
 
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
-   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+   test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
   # Fast installation is not supported
   enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+     test no = "$enable_shared"; then
   # Fast installation is not necessary
   enable_fast_install=needless
 fi
@@ -2144,7 +2215,7 @@ else
 # FIXME - insert some real tests, host_os isn't really good enough
   case $host_os in
   darwin*)
-    if test -n "$STRIP" ; then
+    if test -n "$STRIP"; then
       striplib="$STRIP -x"
       old_striplib="$STRIP -S"
       AC_MSG_RESULT([yes])
@@ -2162,6 +2233,47 @@ _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
 
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x at S|@2 in
+    x)
+        ;;
+    *:)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+        ;;
+    x:*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+        ;;
+    *)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
@@ -2172,17 +2284,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_OBJDUMP])dnl
 m4_require([_LT_DECL_SED])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
 	[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
+    darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+    *) lt_awk_arg='/^libraries:/' ;;
   esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
+    mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+    *) lt_sed_strip_eq='s|=/|/|g' ;;
   esac
   lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
   case $lt_search_path_spec in
@@ -2198,28 +2311,35 @@ if test "$GCC" = yes; then
     ;;
   esac
   # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
+  # and add multilib dir if necessary...
   lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  # ...but if some path component already ends with the multilib dir we assume
+  # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+  case "$lt_multi_os_dir; $lt_search_path_spec " in
+  "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+    lt_multi_os_dir=
+    ;;
+  esac
   for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
+    if test -d "$lt_sys_path$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+    elif test -n "$lt_multi_os_dir"; then
       test -d "$lt_sys_path" && \
 	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
     fi
   done
   lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+  lt_foo = "";
+  lt_count = 0;
   for (lt_i = NF; lt_i > 0; lt_i--) {
     if ($lt_i != "" && $lt_i != ".") {
       if ($lt_i == "..") {
         lt_count++;
       } else {
         if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
+          lt_foo = "/" $lt_i lt_foo;
         } else {
           lt_count--;
         }
@@ -2233,7 +2353,7 @@ BEGIN {RS=" "; FS="/|\n";} {
   # for these hosts.
   case $host_os in
     mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+      $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
   esac
   sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
 else
@@ -2242,7 +2362,7 @@ fi])
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
 postinstall_cmds=
 postuninstall_cmds=
 finish_cmds=
@@ -2259,14 +2379,17 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
   shlibpath_var=LIBPATH
 
   # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
+  soname_spec='$libname$release$shared_ext$major'
   ;;
 
 aix[[4-9]]*)
@@ -2274,41 +2397,91 @@ aix[[4-9]]*)
   need_lib_prefix=no
   need_version=no
   hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
     shlibpath_var=LD_LIBRARY_PATH
   else
     # With GCC up to 2.95.x, collect2 would create an import file
     # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
+    # the line '#! .'.  This would cause the generated library to
+    # depend on '.', always an invalid library.  This was fixed in
     # development snapshots of GCC prior to 3.0.
     case $host_os in
       aix4 | aix4.[[01]] | aix4.[[01]].*)
       if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
 	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	   echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
 	:
       else
 	can_build_shared=no
       fi
       ;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # Using Import Files as archive members, it is possible to support
+    # filename-based versioning of shared library archives on AIX. While
+    # this would work for both with and without runtime linking, it will
+    # prevent static linking of such archives. So we do filename-based
+    # shared library versioning with .so extension only, which is used
+    # when both runtime linking and shared linking is enabled.
+    # Unfortunately, runtime linking may impact performance, so we do
+    # not want this to be the default eventually. Also, we use the
+    # versioned .so libs for executables only if there is the -brtl
+    # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+    # To allow for filename-based versioning support, we need to create
+    # libNAME.so.V as an archive file, containing:
+    # *) an Import File, referring to the versioned filename of the
+    #    archive as well as the shared archive member, telling the
+    #    bitwidth (32 or 64) of that shared object, and providing the
+    #    list of exported symbols of that shared object, eventually
+    #    decorated with the 'weak' keyword
+    # *) the shared object with the F_LOADONLY flag set, to really avoid
+    #    it being seen by the linker.
+    # At run time we better use the real file rather than another symlink,
+    # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+    case $with_aix_soname,$aix_use_runtimelinking in
+    # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
     # soname into executable. Probably we can add versioning support to
     # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
+    aix,yes) # traditional libtool
+      dynamic_linker='AIX unversionable lib.so'
       # If using run time linking (on AIX 4.2 or later) use lib<name>.so
       # instead of lib<name>.a to let people know that these are not
       # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      ;;
+    aix,no) # traditional AIX only
+      dynamic_linker='AIX lib.a[(]lib.so.V[)]'
       # We preserve .a as extension for shared libraries through AIX4.2
       # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      ;;
+    svr4,*) # full svr4 only
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,yes) # both, prefer svr4
+      dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+      library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+      # unpreferred sharedlib libNAME.a needs extra handling
+      postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+      postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+      # We do not specify a path in Import Files, so LIBPATH fires.
+      shlibpath_overrides_runpath=yes
+      ;;
+    *,no) # both, prefer aix
+      dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+      library_names_spec='$libname$release.a $libname.a'
+      soname_spec='$libname$release$shared_ext$major'
+      # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+      postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+      postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+      ;;
+    esac
     shlibpath_var=LIBPATH
   fi
   ;;
@@ -2318,18 +2491,18 @@ amigaos*)
   powerpc)
     # Since July 2007 AmigaOS4 officially supports .so libraries.
     # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
     ;;
   m68k)
     library_names_spec='$libname.ixlibrary $libname.a'
     # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
     ;;
   esac
   ;;
 
 beos*)
-  library_names_spec='${libname}${shared_ext}'
+  library_names_spec='$libname$shared_ext'
   dynamic_linker="$host_os ld.so"
   shlibpath_var=LIBRARY_PATH
   ;;
@@ -2337,8 +2510,8 @@ beos*)
 bsdi[[45]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2350,7 +2523,7 @@ bsdi[[45]]*)
 
 cygwin* | mingw* | pw32* | cegcc*)
   version_type=windows
-  shrext_cmds=".dll"
+  shrext_cmds=.dll
   need_version=no
   need_lib_prefix=no
 
@@ -2359,8 +2532,8 @@ cygwin* | mingw* | pw32* | cegcc*)
     # gcc
     library_names_spec='$libname.dll.a'
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname~
@@ -2376,17 +2549,17 @@ cygwin* | mingw* | pw32* | cegcc*)
     case $host_os in
     cygwin*)
       # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
 m4_if([$1], [],[
       sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
       ;;
     mingw* | cegcc*)
       # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     pw32*)
       # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
       ;;
     esac
     dynamic_linker='Win32 ld.exe'
@@ -2395,8 +2568,8 @@ m4_if([$1], [],[
   *,cl*)
     # Native MSVC
     libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+    soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+    library_names_spec='$libname.dll.lib'
 
     case $build_os in
     mingw*)
@@ -2423,7 +2596,7 @@ m4_if([$1], [],[
       sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
       ;;
     *)
-      sys_lib_search_path_spec="$LIB"
+      sys_lib_search_path_spec=$LIB
       if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
         # It is most probably a Windows format PATH.
         sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -2436,8 +2609,8 @@ m4_if([$1], [],[
     esac
 
     # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+    postinstall_cmds='base_file=`basename \$file`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
       dldir=$destdir/`dirname \$dlpath`~
       test -d \$dldir || mkdir -p \$dldir~
       $install_prog $dir/$dlname \$dldir/$dlname'
@@ -2450,7 +2623,7 @@ m4_if([$1], [],[
 
   *)
     # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
     dynamic_linker='Win32 ld.exe'
     ;;
   esac
@@ -2463,8 +2636,8 @@ darwin* | rhapsody*)
   version_type=darwin
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
+  library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$major$shared_ext'
   shlibpath_overrides_runpath=yes
   shlibpath_var=DYLD_LIBRARY_PATH
   shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2477,8 +2650,8 @@ dgux*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2496,12 +2669,13 @@ freebsd* | dragonfly*)
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+      soname_spec='$libname$release$shared_ext$major'
       need_version=no
       need_lib_prefix=no
       ;;
     freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
       need_version=yes
       ;;
   esac
@@ -2531,10 +2705,10 @@ haiku*)
   need_lib_prefix=no
   need_version=no
   dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
+  shlibpath_overrides_runpath=no
   sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
   hardcode_into_libs=yes
   ;;
@@ -2552,14 +2726,15 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.so"
     shlibpath_var=LD_LIBRARY_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
+    if test 32 = "$HPUX_IA64_MODE"; then
       sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux32
     else
       sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+      sys_lib_dlsearch_path_spec=/usr/lib/hpux64
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
   hppa*64*)
     shrext_cmds='.sl'
@@ -2567,8 +2742,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
     ;;
@@ -2577,8 +2752,8 @@ hpux9* | hpux10* | hpux11*)
     dynamic_linker="$host_os dld.sl"
     shlibpath_var=SHLIB_PATH
     shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     ;;
   esac
   # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -2591,8 +2766,8 @@ interix[[3-9]]*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2603,7 +2778,7 @@ irix5* | irix6* | nonstopux*)
   case $host_os in
     nonstopux*) version_type=nonstopux ;;
     *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
+	if test yes = "$lt_cv_prog_gnu_ld"; then
 		version_type=linux # correct to gnu/linux during the next big refactor
 	else
 		version_type=irix
@@ -2611,8 +2786,8 @@ irix5* | irix6* | nonstopux*)
   esac
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
   case $host_os in
   irix5* | nonstopux*)
     libsuff= shlibsuff=
@@ -2631,8 +2806,8 @@ irix5* | irix6* | nonstopux*)
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
   shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+  sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
   hardcode_into_libs=yes
   ;;
 
@@ -2641,13 +2816,33 @@ linux*oldld* | linux*aout* | linux*coff*)
   dynamic_linker=no
   ;;
 
+linux*android*)
+  version_type=none # Android doesn't support versioned libraries.
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='$libname$release$shared_ext'
+  soname_spec='$libname$release$shared_ext'
+  finish_cmds=
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  dynamic_linker='Android linker'
+  # Don't embed -rpath directories since the linker doesn't support them.
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  ;;
+
 # This must be glibc/ELF.
 linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
@@ -2672,7 +2867,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -2704,12 +2904,12 @@ netbsd*)
   need_lib_prefix=no
   need_version=no
   if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
     finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
     dynamic_linker='NetBSD (a.out) ld.so'
   else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
+    library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+    soname_spec='$libname$release$shared_ext$major'
     dynamic_linker='NetBSD ld.elf_so'
   fi
   shlibpath_var=LD_LIBRARY_PATH
@@ -2719,7 +2919,7 @@ netbsd*)
 
 newsos6)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   ;;
@@ -2728,58 +2928,68 @@ newsos6)
   version_type=qnx
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
   dynamic_linker='ldqnx.so'
   ;;
 
-openbsd*)
+openbsd* | bitrig*)
   version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
+  sys_lib_dlsearch_path_spec=/usr/lib
   need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[[89]] | openbsd2.[[89]].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+    need_version=no
   else
-    shlibpath_overrides_runpath=yes
+    need_version=yes
   fi
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
   ;;
 
 os2*)
   libname_spec='$name'
-  shrext_cmds=".dll"
+  version_type=windows
+  shrext_cmds=.dll
+  need_version=no
   need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
+  # OS/2 can only load a DLL with a base name of 8 characters or less.
+  soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+    v=$($ECHO $release$versuffix | tr -d .-);
+    n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+    $ECHO $n$v`$shared_ext'
+  library_names_spec='${libname}_dll.$libext'
   dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
+  shlibpath_var=BEGINLIBPATH
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+  postinstall_cmds='base_file=`basename \$file`~
+    dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+    dldir=$destdir/`dirname \$dlpath`~
+    test -d \$dldir || mkdir -p \$dldir~
+    $install_prog $dir/$dlname \$dldir/$dlname~
+    chmod a+x \$dldir/$dlname~
+    if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+      eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+    fi'
+  postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+    dlpath=$dir/\$dldll~
+    $RM \$dlpath'
   ;;
 
 osf3* | osf4* | osf5*)
   version_type=osf
   need_lib_prefix=no
   need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='$libname$release$shared_ext$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
   ;;
 
 rdos*)
@@ -2790,8 +3000,8 @@ solaris*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
@@ -2801,11 +3011,11 @@ solaris*)
 
 sunos4*)
   version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
   finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     need_lib_prefix=no
   fi
   need_version=yes
@@ -2813,8 +3023,8 @@ sunos4*)
 
 sysv4 | sysv4.3*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   case $host_vendor in
     sni)
@@ -2835,24 +3045,24 @@ sysv4 | sysv4.3*)
   ;;
 
 sysv4*MP*)
-  if test -d /usr/nec ;then
+  if test -d /usr/nec; then
     version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
+    library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+    soname_spec='$libname$shared_ext.$major'
     shlibpath_var=LD_LIBRARY_PATH
   fi
   ;;
 
 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
+  version_type=sco
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=yes
   hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
   else
     sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2870,7 +3080,7 @@ tpf*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
@@ -2878,8 +3088,8 @@ tpf*)
 
 uts4*)
   version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+  soname_spec='$libname$release$shared_ext$major'
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
@@ -2888,20 +3098,30 @@ uts4*)
   ;;
 esac
 AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
 
 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+  sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+  sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi
 
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
 _LT_DECL([], [variables_saved_for_relink], [1],
     [Variables whose values should be saved in libtool wrapper scripts and
     restored at link time])
@@ -2934,39 +3154,41 @@ _LT_DECL([], [hardcode_into_libs], [0],
     [Whether we should hardcode library paths into libraries])
 _LT_DECL([], [sys_lib_search_path_spec], [2],
     [Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
-    [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+    [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+    [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
 ])# _LT_SYS_DYNAMIC_LINKER
 
 
 # _LT_PATH_TOOL_PREFIX(TOOL)
 # --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
 [m4_require([_LT_DECL_EGREP])dnl
 AC_MSG_CHECKING([for $1])
 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
 [case $MAGIC_CMD in
 [[\\/*] |  ?:[\\/]*])
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
   ;;
 *)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_MAGIC_CMD=$MAGIC_CMD
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
 dnl $ac_dummy forces splitting on constant user-supplied paths.
 dnl POSIX.2 word splitting is done only on the output of word expansions,
 dnl not every word.  This closes a longstanding sh security hole.
   ac_dummy="m4_if([$2], , $PATH, [$2])"
   for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$1; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+    if test -f "$ac_dir/$1"; then
+      lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
       if test -n "$file_magic_test_file"; then
 	case $deplibs_check_method in
 	"file_magic "*)
 	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
 	    $EGREP "$file_magic_regex" > /dev/null; then
 	    :
@@ -2989,11 +3211,11 @@ _LT_EOF
       break
     fi
   done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  IFS=$lt_save_ifs
+  MAGIC_CMD=$lt_save_MAGIC_CMD
   ;;
 esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
 if test -n "$MAGIC_CMD"; then
   AC_MSG_RESULT($MAGIC_CMD)
 else
@@ -3011,7 +3233,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
 
 # _LT_PATH_MAGIC
 # --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
 m4_defun([_LT_PATH_MAGIC],
 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
 if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -3038,16 +3260,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
 AC_ARG_WITH([gnu-ld],
     [AS_HELP_STRING([--with-gnu-ld],
 	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
-    [test "$withval" = no || with_gnu_ld=yes],
+    [test no = "$withval" || with_gnu_ld=yes],
     [with_gnu_ld=no])dnl
 
 ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   # Check if gcc -print-prog-name=ld gives a path.
   AC_MSG_CHECKING([for ld used by $CC])
   case $host in
   *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
+    # gcc leaves a trailing carriage return, which upsets mingw
     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
   *)
     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -3061,7 +3283,7 @@ if test "$GCC" = yes; then
       while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
 	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
       done
-      test -z "$LD" && LD="$ac_prog"
+      test -z "$LD" && LD=$ac_prog
       ;;
   "")
     # If it fails, then pretend we aren't using GCC.
@@ -3072,37 +3294,37 @@ if test "$GCC" = yes; then
     with_gnu_ld=unknown
     ;;
   esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
   AC_MSG_CHECKING([for GNU ld])
 else
   AC_MSG_CHECKING([for non-GNU ld])
 fi
 AC_CACHE_VAL(lt_cv_path_LD,
 [if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
   for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
+      lt_cv_path_LD=$ac_dir/$ac_prog
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some variants of GNU ld only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
       *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
+	test no != "$with_gnu_ld" && break
 	;;
       *)
-	test "$with_gnu_ld" != yes && break
+	test yes != "$with_gnu_ld" && break
 	;;
       esac
     fi
   done
-  IFS="$lt_save_ifs"
+  IFS=$lt_save_ifs
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  lt_cv_path_LD=$LD # Let the user override the test with a path.
 fi])
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
 if test -n "$LD"; then
   AC_MSG_RESULT($LD)
 else
@@ -3156,13 +3378,13 @@ esac
 reload_cmds='$LD$reload_flag -o $output$reload_objs'
 case $host_os in
   cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       reload_cmds=false
     fi
     ;;
   darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    if test yes = "$GCC"; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
     else
       reload_cmds='$LD$reload_flag -o $output$reload_objs'
     fi
@@ -3173,6 +3395,43 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl
 ])# _LT_CMD_RELOAD
 
 
+# _LT_PATH_DD
+# -----------
+# find a working dd
+m4_defun([_LT_PATH_DD],
+[AC_CACHE_CHECK([for a working dd], [ac_cv_path_lt_DD],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+  cmp -s conftest.i conftest.out \
+  && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+  [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
 # _LT_CHECK_MAGIC_METHOD
 # ----------------------
 # how to check for library dependencies
@@ -3188,13 +3447,13 @@ lt_cv_deplibs_check_method='unknown'
 # Need to set the preceding variable on all platforms that support
 # interlibrary dependencies.
 # 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
 # 'pass_all' -- all dependencies passed with no checks.
 # 'test_compile' -- check by making test program.
 # 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
 
 case $host_os in
 aix[[4-9]]*)
@@ -3221,8 +3480,7 @@ mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
   # func_win32_libid shell function, so use a weaker test based on 'objdump',
   # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+  if ( file / ) >/dev/null 2>&1; then
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
@@ -3318,8 +3576,8 @@ newos6*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
   else
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3372,6 +3630,9 @@ sysv4 | sysv4.3*)
 tpf*)
   lt_cv_deplibs_check_method=pass_all
   ;;
+os2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 esac
 ])
 
@@ -3412,33 +3673,38 @@ AC_DEFUN([LT_PATH_NM],
 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
 [if test -n "$NM"; then
   # Let the user override the test.
-  lt_cv_path_NM="$NM"
+  lt_cv_path_NM=$NM
 else
-  lt_nm_to_check="${ac_tool_prefix}nm"
+  lt_nm_to_check=${ac_tool_prefix}nm
   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
     lt_nm_to_check="$lt_nm_to_check nm"
   fi
   for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
     for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      tmp_nm=$ac_dir/$lt_tmp_nm
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
 	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	# Adding the 'sed 1q' prevents false positives on HP-UX, which says:
 	#   nm: unknown option "B" ignored
 	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
+	# MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+	case $build_os in
+	mingw*) lt_bad_file=conftest.nm/nofile ;;
+	*) lt_bad_file=/dev/null ;;
+	esac
+	case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+	*$lt_bad_file* | *'Invalid file or object type'*)
 	  lt_cv_path_NM="$tmp_nm -B"
-	  break
+	  break 2
 	  ;;
 	*)
 	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
 	  */dev/null*)
 	    lt_cv_path_NM="$tmp_nm -p"
-	    break
+	    break 2
 	    ;;
 	  *)
 	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3449,21 +3715,21 @@ else
 	esac
       fi
     done
-    IFS="$lt_save_ifs"
+    IFS=$lt_save_ifs
   done
   : ${lt_cv_path_NM=no}
 fi])
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+  NM=$lt_cv_path_NM
 else
   # Didn't find any BSD compatible name lister, look for dumpbin.
   if test -n "$DUMPBIN"; then :
     # Let the user override the test.
   else
     AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
     *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
+      DUMPBIN="$DUMPBIN -symbols -headers"
       ;;
     *)
       DUMPBIN=:
@@ -3471,8 +3737,8 @@ else
     esac
   fi
   AC_SUBST([DUMPBIN])
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
+  if test : != "$DUMPBIN"; then
+    NM=$DUMPBIN
   fi
 fi
 test -z "$NM" && NM=nm
@@ -3518,8 +3784,8 @@ lt_cv_sharedlib_from_linklib_cmd,
 
 case $host_os in
 cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
+  # two different shell functions defined in ltmain.sh;
+  # decide which one to use based on capabilities of $DLLTOOL
   case `$DLLTOOL --help 2>&1` in
   *--identify-strict*)
     lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -3531,7 +3797,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   ;;
 *)
   # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  lt_cv_sharedlib_from_linklib_cmd=$ECHO
   ;;
 esac
 ])
@@ -3558,13 +3824,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool
     lt_cv_path_mainfest_tool=yes
   fi
   rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
   MANIFEST_TOOL=:
 fi
 _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
 ])# _LT_PATH_MANIFEST_TOOL
 
 
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+  test DEF = "`$SED -n dnl
+    -e '\''s/^[[	 ]]*//'\'' dnl Strip leading whitespace
+    -e '\''/^\(;.*\)*$/d'\'' dnl      Delete empty lines and comments
+    -e '\''s/^\(EXPORTS\|LIBRARY\)\([[	 ]].*\)*$/DEF/p'\'' dnl
+    -e q dnl                          Only consider the first "real" line
+    $1`" dnl
+])# _LT_DLL_DEF_P
+
+
 # LT_LIB_M
 # --------
 # check for math library
@@ -3576,11 +3857,11 @@ case $host in
   # These system don't have libm, or don't need it
   ;;
 *-ncr-sysv4.3*)
-  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
   AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
   ;;
 *)
-  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  AC_CHECK_LIB(m, cos, LIBM=-lm)
   ;;
 esac
 AC_SUBST([LIBM])
@@ -3599,7 +3880,7 @@ m4_defun([_LT_COMPILER_NO_RTTI],
 
 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
 
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
   case $cc_basename in
   nvcc*)
     _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
@@ -3651,7 +3932,7 @@ cygwin* | mingw* | pw32* | cegcc*)
   symcode='[[ABCDGISTW]]'
   ;;
 hpux*)
-  if test "$host_cpu" = ia64; then
+  if test ia64 = "$host_cpu"; then
     symcode='[[ABCDEGRST]]'
   fi
   ;;
@@ -3684,14 +3965,44 @@ case `$NM -V 2>&1` in
   symcode='[[ABCDGIRSTW]]' ;;
 esac
 
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  # Gets list of data symbols to import.
+  lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+  # Adjust the below global symbol transforms to fixup imported variables.
+  lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+  lt_c_name_hook=" -e 's/^I .* \(.*\)$/  {\"\1\", (void *) 0},/p'"
+  lt_c_name_lib_hook="\
+  -e 's/^I .* \(lib.*\)$/  {\"\1\", (void *) 0},/p'\
+  -e 's/^I .* \(.*\)$/  {\"lib\1\", (void *) 0},/p'"
+else
+  # Disable hooks by default.
+  lt_cv_sys_global_symbol_to_import=
+  lt_cdecl_hook=
+  lt_c_name_hook=
+  lt_c_name_lib_hook=
+fi
+
 # Transform an extracted symbol line into a proper C declaration.
 # Some systems (esp. on ia64) link data and code symbols differently,
 # so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
 
 # Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/  {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/  {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/  {\"lib\1\", (void *) \&\1},/p'"
 
 # Handle CRLF in mingw tool chain
 opt_cr=
@@ -3709,21 +4020,24 @@ for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
   if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
+    # Fake it for dumpbin and say T for any non-static function,
+    # D for any global variable and I for any imported variable.
     # Also find C++ and __fastcall symbols from MSVC++,
     # which start with @ or ?.
     lt_cv_sys_global_symbol_pipe="$AWK ['"\
 "     {last_section=section; section=\$ 3};"\
 "     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
 "     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+"     /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+"     /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
 "     \$ 0!~/External *\|/{next};"\
 "     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
 "     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+"     {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+"     s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
 "     ' prfx=^$ac_symprfx]"
   else
     lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -3763,11 +4077,11 @@ _LT_EOF
 	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
 	  cat <<_LT_EOF > conftest.$ac_ext
 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
    relocations are performed -- see ld's documentation on pseudo-relocs.  */
 # define LT@&t at _DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
 /* This system does not cope well with relocations in const data.  */
 # define LT@&t at _DLSYM_CONST
 #else
@@ -3793,7 +4107,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] =
 {
   { "@PROGRAM@", (void *) 0 },
 _LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  $SED "s/^$symcode$symcode* .* \(.*\)$/  {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
 	  cat <<\_LT_EOF >> conftest.$ac_ext
   {0, (void *) 0}
 };
@@ -3813,9 +4127,9 @@ _LT_EOF
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  lt_globsym_save_LIBS=$LIBS
 	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
+	  LIBS=conftstm.$ac_objext
 	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
-	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	  if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
 	    pipe_works=yes
 	  fi
 	  LIBS=$lt_globsym_save_LIBS
@@ -3836,7 +4150,7 @@ _LT_EOF
   rm -rf conftest* conftst*
 
   # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
+  if test yes = "$pipe_works"; then
     break
   else
     lt_cv_sys_global_symbol_pipe=
@@ -3863,12 +4177,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
     [Take the output of nm and produce a listing of raw symbols and C names])
 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
     [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+    [Transform the output of nm into a list of symbols to manually relocate])
 _LT_DECL([global_symbol_to_c_name_address],
     [lt_cv_sys_global_symbol_to_c_name_address], [1],
     [Transform the output of nm in a C name address pair])
 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
     [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
     [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+    [The name lister interface])
 _LT_DECL([], [nm_file_list_spec], [1],
     [Specify filename containing input files for $NM])
 ]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3884,17 +4202,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)=
 
 m4_if([$1], [CXX], [
   # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
+  if test yes = "$GXX"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
     aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -3905,8 +4224,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -3922,6 +4241,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
     darwin* | rhapsody*)
       # PIC is the default on this platform
@@ -3971,7 +4295,7 @@ m4_if([$1], [CXX], [
     case $host_os in
       aix[[4-9]]*)
 	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	  # AIX 5 now supports IA64 processor
 	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	else
@@ -4012,14 +4336,14 @@ m4_if([$1], [CXX], [
 	case $cc_basename in
 	  CC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+	    if test ia64 != "$host_cpu"; then
 	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
 	    fi
 	    ;;
 	  aCC*)
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
 	    case $host_cpu in
 	    hppa*64*|ia64*)
 	      # +Z the default
@@ -4056,7 +4380,7 @@ m4_if([$1], [CXX], [
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
 	    ;;
 	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    # old Intel C++ for x86_64, which still supported -KPIC.
 	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -4201,17 +4525,18 @@ m4_if([$1], [CXX], [
   fi
 ],
 [
-  if test "$GCC" = yes; then
+  if test yes = "$GCC"; then
     _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
     _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 
     case $host_os in
       aix*)
       # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;
 
     amigaos*)
@@ -4222,8 +4547,8 @@ m4_if([$1], [CXX], [
         ;;
       m68k)
             # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
+            # adding the '-m68020' flag to GCC prevents building anything better,
+            # like '-m68040'.
             _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         ;;
       esac
@@ -4240,6 +4565,11 @@ m4_if([$1], [CXX], [
       # (--disable-auto-import) libraries
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     darwin* | rhapsody*)
@@ -4310,7 +4640,7 @@ m4_if([$1], [CXX], [
     case $host_os in
     aix*)
       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# AIX 5 now supports IA64 processor
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       else
@@ -4318,11 +4648,30 @@ m4_if([$1], [CXX], [
       fi
       ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      case $cc_basename in
+      nagfor*)
+        # NAG Fortran compiler
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      esac
+      ;;
+
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       # This hack is so that the source file can tell whether it is being
       # built for inclusion in a dll (and should export symbols for example).
       m4_if([$1], [GCJ], [],
 	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      case $host_os in
+      os2*)
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+	;;
+      esac
       ;;
 
     hpux9* | hpux10* | hpux11*)
@@ -4338,7 +4687,7 @@ m4_if([$1], [CXX], [
 	;;
       esac
       # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
       ;;
 
     irix5* | irix6* | nonstopux*)
@@ -4349,7 +4698,7 @@ m4_if([$1], [CXX], [
 
     linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
       case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
+      # old Intel for x86_64, which still supported -KPIC.
       ecc*)
 	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -4374,6 +4723,12 @@ m4_if([$1], [CXX], [
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
 	;;
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
 	# which looks to be a dead project)
@@ -4471,7 +4826,7 @@ m4_if([$1], [CXX], [
       ;;
 
     sysv4*MP*)
-      if test -d /usr/nec ;then
+      if test -d /usr/nec; then
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
@@ -4500,7 +4855,7 @@ m4_if([$1], [CXX], [
   fi
 ])
 case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
+  # For platforms that do not support PIC, -DPIC is meaningless:
   *djgpp*)
     _LT_TAGVAR(lt_prog_compiler_pic, $1)=
     ;;
@@ -4566,17 +4921,21 @@ m4_if([$1], [CXX], [
   case $host_os in
   aix[[4-9]]*)
     # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
+    # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+    # Without the "-l" option, or with the "-B" option, AIX nm treats
+    # weak defined symbols like other global defined symbols, whereas
+    # GNU nm marks them as "W".
+    # While the 'weak' keyword is ignored in the Export File, we need
+    # it in the Import File for the 'aix-soname' feature, so we have
+    # to replace the "-B" option with "-P" for AIX nm.
     if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
     else
-      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+      _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
     fi
     ;;
   pw32*)
-    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+    _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
     ;;
   cygwin* | mingw* | cegcc*)
     case $cc_basename in
@@ -4625,9 +4984,9 @@ m4_if([$1], [CXX], [
   # included in the symbol list
   _LT_TAGVAR(include_expsyms, $1)=
   # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
+  # it will be wrapped by ' (' and ')$', so one must not match beginning or
+  # end of line.  Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+  # as well as any symbol that contains 'd'.
   _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
   # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
   # platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4643,7 +5002,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
-    if test "$GCC" != yes; then
+    if test yes != "$GCC"; then
       with_gnu_ld=no
     fi
     ;;
@@ -4651,7 +5010,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     # we just hope/assume this is gcc and not c89 (= MSVC++)
     with_gnu_ld=yes
     ;;
-  openbsd*)
+  openbsd* | bitrig*)
     with_gnu_ld=no
     ;;
   linux* | k*bsd*-gnu | gnu*)
@@ -4664,7 +5023,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
   # On some targets, GNU ld is compatible enough with the native linker
   # that we're better off using the native interface for both.
   lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
+  if test yes = "$with_gnu_ld"; then
     case $host_os in
       aix*)
 	# The AIX port of GNU ld has always aspired to compatibility
@@ -4686,24 +5045,24 @@ dnl Note also adjust exclude_expsyms for C++ above.
     esac
   fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
+  if test yes = "$lt_use_gnu_ld_interface"; then
     # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    wlarc='$wl'
 
     # Set some defaults for GNU ld with shared library support. These
     # are reset later if shared libraries are not supported. Putting them
     # here allows them to be overridden if necessary.
     runpath_var=LD_RUN_PATH
-    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
     # ancient GNU ld didn't support --whole-archive et. al.
     if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
     else
       _LT_TAGVAR(whole_archive_flag_spec, $1)=
     fi
     supports_anon_versioning=no
-    case `$LD -v 2>&1` in
+    case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
       *GNU\ gold*) supports_anon_versioning=yes ;;
       *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
       *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -4716,7 +5075,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
     case $host_os in
     aix[[3-9]]*)
       # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
+      if test ia64 != "$host_cpu"; then
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
@@ -4735,7 +5094,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -4751,7 +5110,7 @@ _LT_EOF
 	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	# support --undefined.  This deserves some investigation.  FIXME
-	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4761,7 +5120,7 @@ _LT_EOF
       # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_TAGVAR(always_export_symbols, $1)=no
       _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -4769,61 +5128,89 @@ _LT_EOF
       _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
 
       if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file, use it as
+	# is; otherwise, prepend EXPORTS...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+          cp $export_symbols $output_objdir/$soname.def;
+        else
+          echo EXPORTS > $output_objdir/$soname.def;
+          cat $export_symbols >> $output_objdir/$soname.def;
+        fi~
+        $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
 
     haiku*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
     interix[[3-9]]*)
       _LT_TAGVAR(hardcode_direct, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
       # consuming and fragmenting process.  To avoid this, we pick a random,
       # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
       # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
       ;;
 
     gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
+      if test linux-dietlibc = "$host_os"; then
 	case $cc_basename in
 	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
 	esac
       fi
       if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
+	 && test no = "$tmp_diet"
       then
 	tmp_addflag=' $pic_flag'
 	tmp_sharedflag='-shared'
 	case $cc_basename,$host_cpu in
         pgcc*)				# Portland Group C compiler
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag'
 	  ;;
 	pgf77* | pgf90* | pgf95* | pgfortran*)
 					# Portland Group f77 and f90 compilers
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  tmp_addflag=' $pic_flag -Mnomain' ;;
 	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
 	  tmp_addflag=' -i_dynamic' ;;
@@ -4834,42 +5221,47 @@ _LT_EOF
 	lf95*)				# Lahey Fortran 8.1
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
 	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
 	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
 	  tmp_sharedflag='-qmkshrobj'
 	  tmp_addflag= ;;
 	nvcc*)	# Cuda Compiler Driver 2.2
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  ;;
 	esac
 	case `$CC -V 2>&1 | sed 5q` in
 	*Sun\ C*)			# Sun C 5.9
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	  _LT_TAGVAR(compiler_needs_object, $1)=yes
 	  tmp_sharedflag='-G' ;;
 	*Sun\ F*)			# Sun Fortran 8.3
 	  tmp_sharedflag='-G' ;;
 	esac
-	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 
-        if test "x$supports_anon_versioning" = xyes; then
+        if test yes = "$supports_anon_versioning"; then
           _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+            cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+            echo "local: *; };" >> $output_objdir/$libname.ver~
+            $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
         fi
 
 	case $cc_basename in
+	tcc*)
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
+	  if test yes = "$supports_anon_versioning"; then
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+              cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+              echo "local: *; };" >> $output_objdir/$libname.ver~
+              $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
 	  fi
 	  ;;
 	esac
@@ -4883,8 +5275,8 @@ _LT_EOF
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -4902,8 +5294,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4915,7 +5307,7 @@ _LT_EOF
 	_LT_TAGVAR(ld_shlibs, $1)=no
 	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
 *** reliably create shared libraries on SCO systems.  Therefore, libtool
 *** is disabling shared libraries support.  We urge you to upgrade GNU
 *** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
@@ -4930,9 +5322,9 @@ _LT_EOF
 	  # DT_RUNPATH tag from executables and libraries.  But doing so
 	  # requires that you compile everything twice, which is a pain.
 	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -4949,15 +5341,15 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
     esac
 
-    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+    if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
       runpath_var=
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
       _LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4973,7 +5365,7 @@ _LT_EOF
       # Note: this linker hardcodes the directories in LIBPATH if there
       # are no directories specified by -L.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+      if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
 	# Neither direct hardcoding nor static linking is supported with a
 	# broken collect2.
 	_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4981,34 +5373,57 @@ _LT_EOF
       ;;
 
     aix[[4-9]]*)
-      if test "$host_cpu" = ia64; then
+      if test ia64 = "$host_cpu"; then
 	# On IA64, the linker does run time linking by default, so we don't
 	# have to do anything special.
 	aix_use_runtimelinking=no
 	exp_sym_flag='-Bexport'
-	no_entry_flag=""
+	no_entry_flag=
       else
 	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
+	# -C means demangle to GNU nm, but means don't demangle to AIX nm.
+	# Without the "-l" option, or with the "-B" option, AIX nm treats
+	# weak defined symbols like other global defined symbols, whereas
+	# GNU nm marks them as "W".
+	# While the 'weak' keyword is ignored in the Export File, we need
+	# it in the Import File for the 'aix-soname' feature, so we have
+	# to replace the "-B" option with "-P" for AIX nm.
 	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
 	else
-	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	  _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
 	fi
 	aix_use_runtimelinking=no
 
 	# Test if we are trying to use run time linking or normal
 	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
+	# have runtime linking enabled, and use it for executables.
+	# For shared libraries, we enable/disable runtime linking
+	# depending on the kind of the shared library created -
+	# when "with_aix_soname,aix_use_runtimelinking" is:
+	# "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "aix,yes"  lib.so          shared, rtl:yes, for executables
+	#            lib.a           static archive
+	# "both,no"  lib.so.V(shr.o) shared, rtl:yes
+	#            lib.a(lib.so.V) shared, rtl:no,  for executables
+	# "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a(lib.so.V) shared, rtl:no
+	# "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+	#            lib.a           static archive
 	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	  if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
 	    aix_use_runtimelinking=yes
 	    break
 	  fi
 	  done
+	  if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	    # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	    # so we don't have lib.a shared libs to link our executables.
+	    # We have to force runtime linking in this case.
+	    aix_use_runtimelinking=yes
+	    LDFLAGS="$LDFLAGS -Wl,-brtl"
+	  fi
 	  ;;
 	esac
 
@@ -5027,13 +5442,21 @@ _LT_EOF
       _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+      _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+      case $with_aix_soname,$aix_use_runtimelinking in
+      aix,*) ;; # traditional, no import file
+      svr4,* | *,yes) # use import file
+	# The Import File defines what to hardcode.
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+	;;
+      esac
 
-      if test "$GCC" = yes; then
+      if test yes = "$GCC"; then
 	case $host_os in aix4.[[012]]|aix4.[[012]].*)
 	# We only want to do this on AIX 4.2 and lower, the check
 	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -5052,62 +5475,80 @@ _LT_EOF
 	  ;;
 	esac
 	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
+	if test yes = "$aix_use_runtimelinking"; then
+	  shared_flag="$shared_flag "'$wl-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
+	# Need to ensure runtime linking is disabled for the traditional
+	# shared library, or the linker may eventually find shared libraries
+	# /with/ Import File - we do not want to mix them.
+	shared_flag_aix='-shared'
+	shared_flag_svr4='-shared $wl-G'
       else
 	# not using gcc
-	if test "$host_cpu" = ia64; then
+	if test ia64 = "$host_cpu"; then
 	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	# chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
 	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag='$wl-G'
 	  else
-	    shared_flag='${wl}-bM:SRE'
+	    shared_flag='$wl-bM:SRE'
 	  fi
+	  shared_flag_aix='$wl-bM:SRE'
+	  shared_flag_svr4='$wl-G'
 	fi
       fi
 
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
       # It seems that -bexpall does not export symbols beginning with
       # underscore (_), so it is better to generate a list of symbols to export.
       _LT_TAGVAR(always_export_symbols, $1)=yes
-      if test "$aix_use_runtimelinking" = yes; then
+      if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
 	# Warning - without using the other runtime loading flags (-brtl),
 	# -berok will link without error, but may produce a broken library.
 	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         # Determine the default libpath from the value encoded in an
         # empty executable.
         _LT_SYS_MODULE_PATH_AIX([$1])
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
       else
-	if test "$host_cpu" = ia64; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	if test ia64 = "$host_cpu"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
 	else
 	 # Determine the default libpath from the value encoded in an
 	 # empty executable.
 	 _LT_SYS_MODULE_PATH_AIX([$1])
-	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	  # Warning - without using the other run time loading flags,
 	  # -berok will link without error, but may produce a broken library.
-	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
+	  _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	  if test yes = "$with_gnu_ld"; then
 	    # We only use this code for GNU lds that support --whole-archive.
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	  else
 	    # Exported symbols can be pulled into shared objects from archives
 	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	  fi
 	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	  # -brtl affects multiple linker settings, -berok does not and is overridden later
+	  compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	  if test svr4 != "$with_aix_soname"; then
+	    # This is similar to how AIX traditionally builds its shared libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	  fi
+	  if test aix != "$with_aix_soname"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 3 [...]
+	  else
+	    # used by -dlpreopen to get the symbols
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	  fi
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
 	fi
       fi
       ;;
@@ -5116,7 +5557,7 @@ _LT_EOF
       case $host_cpu in
       powerpc)
             # see comment about AmigaOS4 .so support
-            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
             _LT_TAGVAR(archive_expsym_cmds, $1)=''
         ;;
       m68k)
@@ -5146,16 +5587,17 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
+	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+            cp "$export_symbols" "$output_objdir/$soname.def";
+            echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+          else
+            $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+          fi~
+          $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+          linknames='
 	# The linker will not automatically build a static lib if we build a DLL.
 	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -5164,18 +5606,18 @@ _LT_EOF
 	# Don't use ranlib
 	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
+          lt_tool_outputfile="@TOOL_OUTPUT@"~
+          case $lt_outputfile in
+            *.exe|*.EXE) ;;
+            *)
+              lt_outputfile=$lt_outputfile.exe
+              lt_tool_outputfile=$lt_tool_outputfile.exe
+              ;;
+          esac~
+          if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+            $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+            $RM "$lt_outputfile.manifest";
+          fi'
 	;;
       *)
 	# Assume MSVC wrapper
@@ -5184,7 +5626,7 @@ _LT_EOF
 	# Tell ltmain to make .lib files, not .a files.
 	libext=lib
 	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
+	shrext_cmds=.dll
 	# FIXME: Setting linknames here is a bad hack.
 	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
 	# The linker will automatically build a .lib file if we build a DLL.
@@ -5234,33 +5676,33 @@ _LT_EOF
       ;;
 
     hpux9*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
       fi
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_direct, $1)=yes
 
       # hardcode_minus_L: Not really in the search PATH,
       # but as the default location of the library.
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
       ;;
 
     hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes,no = "$GCC,$with_gnu_ld"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# hardcode_minus_L: Not really in the search PATH,
 	# but as the default location of the library.
 	_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5268,25 +5710,25 @@ _LT_EOF
       ;;
 
     hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+      if test yes,no = "$GCC,$with_gnu_ld"; then
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	esac
       else
 	case $host_cpu in
 	hppa*64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	ia64*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
 	m4_if($1, [], [
@@ -5294,14 +5736,14 @@ _LT_EOF
 	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
 	  _LT_LINKER_OPTION([if $CC understands -b],
 	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
-	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
 	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
-	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
 	  ;;
 	esac
       fi
-      if test "$with_gnu_ld" = no; then
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      if test no = "$with_gnu_ld"; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	case $host_cpu in
@@ -5312,7 +5754,7 @@ _LT_EOF
 	*)
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 
 	  # hardcode_minus_L: Not really in the search PATH,
 	  # but as the default location of the library.
@@ -5323,16 +5765,16 @@ _LT_EOF
       ;;
 
     irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	# Try to use the -exported_symbol ld option, if it does not
 	# work, assume that -exports_file does not work either and
 	# implicitly export all symbols.
 	# This should be the same for all languages, so no per-tag cache variable.
 	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
 	  [lt_cv_irix_exported_symbol],
-	  [save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	  [save_LDFLAGS=$LDFLAGS
+	   LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
 	   AC_LINK_IFELSE(
 	     [AC_LANG_SOURCE(
 	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
@@ -5345,21 +5787,32 @@ _LT_EOF
       end]])])],
 	      [lt_cv_irix_exported_symbol=yes],
 	      [lt_cv_irix_exported_symbol=no])
-           LDFLAGS="$save_LDFLAGS"])
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+           LDFLAGS=$save_LDFLAGS])
+	if test yes = "$lt_cv_irix_exported_symbol"; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
 	fi
+	_LT_TAGVAR(link_all_deplibs, $1)=no
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(inherit_rpath, $1)=yes
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    linux*)
+      case $cc_basename in
+      tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      esac
+      ;;
+
     netbsd* | netbsdelf*-gnu)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -5374,7 +5827,7 @@ _LT_EOF
     newsos6)
       _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
       _LT_TAGVAR(hardcode_direct, $1)=yes
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       ;;
@@ -5382,27 +5835,19 @@ _LT_EOF
     *nto* | *qnx*)
       ;;
 
-    openbsd*)
+    openbsd* | bitrig*)
       if test -f /usr/libexec/ld.so; then
 	_LT_TAGVAR(hardcode_direct, $1)=yes
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	else
-	  case $host_os in
-	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
-	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	     ;;
-	   *)
-	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	     ;;
-	  esac
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	fi
       else
 	_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5413,33 +5858,53 @@ _LT_EOF
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_TAGVAR(hardcode_minus_L, $1)=yes
       _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
-      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      shrext_cmds=.dll
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	$ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	$ECHO EXPORTS >> $output_objdir/$libname.def~
+	prefix_cmds="$SED"~
+	if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	  prefix_cmds="$prefix_cmds -e 1d";
+	fi~
+	prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	$CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	emximp -o $lib $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     osf3*)
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
       fi
       _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=:
       ;;
 
     osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
       else
 	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+          $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
 
 	# Both c and cxx compiler support -rpath directly
 	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5450,24 +5915,24 @@ _LT_EOF
 
     solaris*)
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	wlarc='$wl'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
 	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+          $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
 	case `$CC -V 2>&1` in
 	*"Compilers 5.0"*)
 	  wlarc=''
-	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+            $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  wlarc='${wl}'
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  wlarc='$wl'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
 	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+            $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
       fi
@@ -5477,11 +5942,11 @@ _LT_EOF
       solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
       *)
 	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but understands '-z linker_flag'.  GCC discards it without '$wl',
 	# but is careful enough not to reorder.
 	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	if test yes = "$GCC"; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 	else
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	fi
@@ -5491,10 +5956,10 @@ _LT_EOF
       ;;
 
     sunos4*)
-      if test "x$host_vendor" = xsequent; then
+      if test sequent = "$host_vendor"; then
 	# Use $CC to link under sequent, because it throws in some extra .o
 	# files that make .init and .fini sections work.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
       else
 	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
       fi
@@ -5543,43 +6008,43 @@ _LT_EOF
       ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
     sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
+      # Note: We CANNOT use -z defs as we might desire, because we do not
       # link with -lc, and that would cause any symbols used from libc to
       # always be unresolved, which means just about no library would
       # ever link correctly.  If we're not using GNU ld we use -z text
       # though, which does catch some bad symbols but isn't as heavy-handed
       # as -z defs.
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
       _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
       _LT_TAGVAR(link_all_deplibs, $1)=yes
-      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
       runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      if test yes = "$GCC"; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       else
-	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
       fi
       ;;
 
@@ -5594,17 +6059,17 @@ _LT_EOF
       ;;
     esac
 
-    if test x$host_vendor = xsni; then
+    if test sni = "$host_vendor"; then
       case $host in
       sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
 	;;
       esac
     fi
   fi
 ])
 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
 
@@ -5621,7 +6086,7 @@ x|xyes)
   # Assume -lc should be added
   _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
+  if test yes,yes = "$GCC,$enable_shared"; then
     case $_LT_TAGVAR(archive_cmds, $1) in
     *'~'*)
       # FIXME: we may have to deal with multi-command sequences.
@@ -5701,12 +6166,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
     [Whether we need a single "-rpath" flag with a separated argument])
 _LT_TAGDECL([], [hardcode_direct], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary])
 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
-    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
     DIR into the resulting binary and the resulting library dependency is
-    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    "absolute", i.e impossible to change by setting $shlibpath_var if the
     library is relocated])
 _LT_TAGDECL([], [hardcode_minus_L], [0],
     [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5747,10 +6212,10 @@ dnl    [Compiler flag to generate thread safe objects])
 # ------------------------
 # Ensure that the configuration variables for a C compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_C_CONFIG],
 [m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
 AC_LANG_PUSH(C)
 
 # Source file extension for C test sources.
@@ -5790,18 +6255,18 @@ if test -n "$compiler"; then
   LT_SYS_DLOPEN_SELF
   _LT_CMD_STRIPLIB
 
-  # Report which library types will actually be built
+  # Report what library types will actually be built
   AC_MSG_CHECKING([if libtool supports shared libraries])
   AC_MSG_RESULT([$can_build_shared])
 
   AC_MSG_CHECKING([whether to build shared libraries])
-  test "$can_build_shared" = "no" && enable_shared=no
+  test no = "$can_build_shared" && enable_shared=no
 
   # On AIX, shared libraries and static libraries use the same namespace, and
   # are all built from PIC.
   case $host_os in
   aix3*)
-    test "$enable_shared" = yes && enable_static=no
+    test yes = "$enable_shared" && enable_static=no
     if test -n "$RANLIB"; then
       archive_cmds="$archive_cmds~\$RANLIB \$lib"
       postinstall_cmds='$RANLIB $lib'
@@ -5809,8 +6274,12 @@ if test -n "$compiler"; then
     ;;
 
   aix[[4-9]]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
+    if test ia64 != "$host_cpu"; then
+      case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+      yes,aix,yes) ;;			# shared object as lib.so file only
+      yes,svr4,*) ;;			# shared object as lib.so archive member only
+      yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+      esac
     fi
     ;;
   esac
@@ -5818,13 +6287,13 @@ if test -n "$compiler"; then
 
   AC_MSG_CHECKING([whether to build static libraries])
   # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
+  test yes = "$enable_shared" || enable_static=yes
   AC_MSG_RESULT([$enable_static])
 
   _LT_CONFIG($1)
 fi
 AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
 ])# _LT_LANG_C_CONFIG
 
 
@@ -5832,14 +6301,14 @@ CC="$lt_save_CC"
 # --------------------------
 # Ensure that the configuration variables for a C++ compiler are suitably
 # defined.  These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_CXX_CONFIG],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_EGREP])dnl
 m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
+if test -n "$CXX" && ( test no != "$CXX" &&
+    ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+    (test g++ != "$CXX"))); then
   AC_PROG_CXXCPP
 else
   _lt_caught_CXX_error=yes
@@ -5881,7 +6350,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the CXX compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="int some_variable = 0;"
 
@@ -5923,35 +6392,35 @@ if test "$_lt_caught_CXX_error" != yes; then
   if test -n "$compiler"; then
     # We don't want -fno-exception when compiling C++ code, so set the
     # no_builtin_flag separately
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
     else
       _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
     fi
 
-    if test "$GXX" = yes; then
+    if test yes = "$GXX"; then
       # Set up default GNU C++ configuration
 
       LT_PATH_LD
 
       # Check if GNU C++ uses GNU ld as the underlying linker, since the
       # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      if test yes = "$with_gnu_ld"; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
         # If archive_cmds runs LD, not CC, wlarc should be empty
         # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+        wlarc='$wl'
 
         # ancient GNU ld didn't support --whole-archive et. al.
         if eval "`$CC -print-prog-name=ld` --help 2>&1" |
 	  $GREP 'no-whole-archive' > /dev/null; then
-          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
         else
           _LT_TAGVAR(whole_archive_flag_spec, $1)=
         fi
@@ -5987,18 +6456,30 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=no
         ;;
       aix[[4-9]]*)
-        if test "$host_cpu" = ia64; then
+        if test ia64 = "$host_cpu"; then
           # On IA64, the linker does run time linking by default, so we don't
           # have to do anything special.
           aix_use_runtimelinking=no
           exp_sym_flag='-Bexport'
-          no_entry_flag=""
+          no_entry_flag=
         else
           aix_use_runtimelinking=no
 
           # Test if we are trying to use run time linking or normal
           # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
+          # have runtime linking enabled, and use it for executables.
+          # For shared libraries, we enable/disable runtime linking
+          # depending on the kind of the shared library created -
+          # when "with_aix_soname,aix_use_runtimelinking" is:
+          # "aix,no"   lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "aix,yes"  lib.so          shared, rtl:yes, for executables
+          #            lib.a           static archive
+          # "both,no"  lib.so.V(shr.o) shared, rtl:yes
+          #            lib.a(lib.so.V) shared, rtl:no,  for executables
+          # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a(lib.so.V) shared, rtl:no
+          # "svr4,*"   lib.so.V(shr.o) shared, rtl:yes, for executables
+          #            lib.a           static archive
           case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
 	    for ld_flag in $LDFLAGS; do
 	      case $ld_flag in
@@ -6008,6 +6489,13 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        ;;
 	      esac
 	    done
+	    if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+	      # With aix-soname=svr4, we create the lib.so.V shared archives only,
+	      # so we don't have lib.a shared libs to link our executables.
+	      # We have to force runtime linking in this case.
+	      aix_use_runtimelinking=yes
+	      LDFLAGS="$LDFLAGS -Wl,-brtl"
+	    fi
 	    ;;
           esac
 
@@ -6026,13 +6514,21 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
-        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+        _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+        case $with_aix_soname,$aix_use_runtimelinking in
+        aix,*) ;;	# no import file
+        svr4,* | *,yes) # use import file
+          # The Import File defines what to hardcode.
+          _LT_TAGVAR(hardcode_direct, $1)=no
+          _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+          ;;
+        esac
 
-        if test "$GXX" = yes; then
+        if test yes = "$GXX"; then
           case $host_os in aix4.[[012]]|aix4.[[012]].*)
           # We only want to do this on AIX 4.2 and lower, the check
           # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
+	  collect2name=`$CC -print-prog-name=collect2`
 	  if test -f "$collect2name" &&
 	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
 	  then
@@ -6050,64 +6546,84 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  fi
           esac
           shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
+	  if test yes = "$aix_use_runtimelinking"; then
+	    shared_flag=$shared_flag' $wl-G'
 	  fi
+	  # Need to ensure runtime linking is disabled for the traditional
+	  # shared library, or the linker may eventually find shared libraries
+	  # /with/ Import File - we do not want to mix them.
+	  shared_flag_aix='-shared'
+	  shared_flag_svr4='-shared $wl-G'
         else
           # not using gcc
-          if test "$host_cpu" = ia64; then
+          if test ia64 = "$host_cpu"; then
 	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
 	  # chokes on -Wl,-G. The following line is correct:
 	  shared_flag='-G'
           else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
+	    if test yes = "$aix_use_runtimelinking"; then
+	      shared_flag='$wl-G'
 	    else
-	      shared_flag='${wl}-bM:SRE'
+	      shared_flag='$wl-bM:SRE'
 	    fi
+	    shared_flag_aix='$wl-bM:SRE'
+	    shared_flag_svr4='$wl-G'
           fi
         fi
 
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
         # It seems that -bexpall does not export symbols beginning with
         # underscore (_), so it is better to generate a list of symbols to
 	# export.
         _LT_TAGVAR(always_export_symbols, $1)=yes
-        if test "$aix_use_runtimelinking" = yes; then
+	if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
           # Warning - without using the other runtime loading flags (-brtl),
           # -berok will link without error, but may produce a broken library.
-          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # The "-G" linker flag allows undefined symbols.
+          _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
           # Determine the default libpath from the value encoded in an empty
           # executable.
           _LT_SYS_MODULE_PATH_AIX([$1])
-          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
         else
-          if test "$host_cpu" = ia64; then
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+          if test ia64 = "$host_cpu"; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
 	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
           else
 	    # Determine the default libpath from the value encoded in an
 	    # empty executable.
 	    _LT_SYS_MODULE_PATH_AIX([$1])
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
 	    # Warning - without using the other run time loading flags,
 	    # -berok will link without error, but may produce a broken library.
-	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
-	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
+	    _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+	    if test yes = "$with_gnu_ld"; then
 	      # We only use this code for GNU lds that support --whole-archive.
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    else
 	      # Exported symbols can be pulled into shared objects from archives
 	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
 	    fi
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+	    # -brtl affects multiple linker settings, -berok does not and is overridden later
+	    compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+	    if test svr4 != "$with_aix_soname"; then
+	      # This is similar to how AIX traditionally builds its shared
+	      # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+	    fi
+	    if test aix != "$with_aix_soname"; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# [...]
+	    else
+	      # used by -dlpreopen to get the symbols
+	      _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV  $output_objdir/$realname.d/$soname $output_objdir'
+	    fi
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
           fi
         fi
         ;;
@@ -6117,7 +6633,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
 	  # support --undefined.  This deserves some investigation.  FIXME
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
 	else
 	  _LT_TAGVAR(ld_shlibs, $1)=no
 	fi
@@ -6145,57 +6661,58 @@ if test "$_lt_caught_CXX_error" != yes; then
 	  # Tell ltmain to make .lib files, not .a files.
 	  libext=lib
 	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
+	  shrext_cmds=.dll
 	  # FIXME: Setting linknames here is a bad hack.
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp "$export_symbols" "$output_objdir/$soname.def";
+              echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+            else
+              $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+            fi~
+            $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+            linknames='
 	  # The linker will not automatically build a static lib if we build a DLL.
 	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 	  # Don't use ranlib
 	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
 	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+            lt_tool_outputfile="@TOOL_OUTPUT@"~
+            case $lt_outputfile in
+              *.exe|*.EXE) ;;
+              *)
+                lt_outputfile=$lt_outputfile.exe
+                lt_tool_outputfile=$lt_tool_outputfile.exe
+                ;;
+            esac~
+            func_to_tool_file "$lt_outputfile"~
+            if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+              $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+              $RM "$lt_outputfile.manifest";
+            fi'
 	  ;;
 	*)
 	  # g++
 	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
 	  # as there is no search path for DLLs.
 	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
 	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
 	  _LT_TAGVAR(always_export_symbols, $1)=no
 	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
 	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file, use it as
+	    # is; otherwise, prepend EXPORTS...
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+              cp $export_symbols $output_objdir/$soname.def;
+            else
+              echo EXPORTS > $output_objdir/$soname.def;
+              cat $export_symbols >> $output_objdir/$soname.def;
+            fi~
+            $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
 	  else
 	    _LT_TAGVAR(ld_shlibs, $1)=no
 	  fi
@@ -6206,6 +6723,34 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_DARWIN_LINKER_FEATURES($1)
 	;;
 
+      os2*)
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	shrext_cmds=.dll
+	_LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+	  $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+	  $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+	  $ECHO EXPORTS >> $output_objdir/$libname.def~
+	  prefix_cmds="$SED"~
+	  if test EXPORTS = "`$SED 1q $export_symbols`"; then
+	    prefix_cmds="$prefix_cmds -e 1d";
+	  fi~
+	  prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+	  cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+	  $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+	  emximp -o $lib $output_objdir/$libname.def'
+	_LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+	;;
+
       dgux*)
         case $cc_basename in
           ec++*)
@@ -6241,14 +6786,14 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       haiku*)
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
         ;;
 
       hpux9*)
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
-        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
         _LT_TAGVAR(hardcode_direct, $1)=yes
         _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
 				             # but as the default
@@ -6260,7 +6805,7 @@ if test "$_lt_caught_CXX_error" != yes; then
             _LT_TAGVAR(ld_shlibs, $1)=no
             ;;
           aCC*)
-            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             # Commands to make compiler produce verbose output that lists
             # what "hidden" libraries, object files and flags are used when
             # linking a shared library.
@@ -6269,11 +6814,11 @@ if test "$_lt_caught_CXX_error" != yes; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
-            if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            if test yes = "$GXX"; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
             else
               # FIXME: insert proper C++ library support
               _LT_TAGVAR(ld_shlibs, $1)=no
@@ -6283,15 +6828,15 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
       hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        if test no = "$with_gnu_ld"; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
 	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
           case $host_cpu in
             hppa*64*|ia64*)
               ;;
             *)
-	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
               ;;
           esac
         fi
@@ -6317,13 +6862,13 @@ if test "$_lt_caught_CXX_error" != yes; then
           aCC*)
 	    case $host_cpu in
 	      hppa*64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      ia64*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	      *)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	        ;;
 	    esac
 	    # Commands to make compiler produce verbose output that lists
@@ -6334,20 +6879,20 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
 	        case $host_cpu in
 	          hppa*64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          ia64*)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	          *)
-	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	            ;;
 	        esac
 	      fi
@@ -6362,22 +6907,22 @@ if test "$_lt_caught_CXX_error" != yes; then
       interix[[3-9]]*)
 	_LT_TAGVAR(hardcode_direct, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
 	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
 	# Instead, shared libraries are loaded at an image base (0x10000000 by
 	# default) and relocated if they conflict, which is a slow very memory
 	# consuming and fragmenting process.  To avoid this, we pick a random,
 	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
 	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
       irix5* | irix6*)
         case $cc_basename in
           CC*)
 	    # SGI C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
@@ -6386,17 +6931,17 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
 	    ;;
           *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	    if test yes = "$GXX"; then
+	      if test no = "$with_gnu_ld"; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 	      else
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
 	      fi
 	    fi
 	    _LT_TAGVAR(link_all_deplibs, $1)=yes
 	    ;;
         esac
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
         _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         _LT_TAGVAR(inherit_rpath, $1)=yes
         ;;
@@ -6409,8 +6954,8 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
 	    # Commands to make compiler produce verbose output that lists
 	    # what "hidden" libraries, object files and flags are used when
 	    # linking a shared library.
@@ -6419,10 +6964,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
 
 	    # Archives containing C++ object files must be created using
 	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -6436,59 +6981,59 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # earlier do not add the objects themselves.
 	    case `$CC -V 2>&1` in
 	      *"Version 7."*)
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	      *)  # Version 8.0 or newer
 	        tmp_idyn=
 	        case $host_cpu in
 		  ia64*) tmp_idyn=' -i_dynamic';;
 		esac
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 		;;
 	    esac
 	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
 	    ;;
           pgCC* | pgcpp*)
             # Portland Group C++ compiler
 	    case `$CC -V` in
 	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
 	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+               rm -rf $tpldir~
+               $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+               compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
 	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+                $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+                $RANLIB $oldlib'
 	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+                rm -rf $tpldir~
+                $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+                $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    *) # Version 6 and above use weak symbols
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
 	      ;;
 	    esac
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
             ;;
 	  cxx*)
 	    # Compaq C++
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname  -o $lib $wl-retain-symbols-file $wl$export_symbols'
 
 	    runpath_var=LD_RUN_PATH
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6502,18 +7047,18 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
 	    ;;
 	  xl* | mpixl* | bgxl*)
 	    # IBM XL 8.0 on PPC, with GNU ld
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+	    if test yes = "$supports_anon_versioning"; then
 	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+                cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+                echo "local: *; };" >> $output_objdir/$libname.ver~
+                $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
 	    fi
 	    ;;
 	  *)
@@ -6521,10 +7066,10 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    *Sun\ C*)
 	      # Sun C++ 5.9
 	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
 	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
 	      _LT_TAGVAR(compiler_needs_object, $1)=yes
 
 	      # Not sure whether something based on
@@ -6582,22 +7127,17 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=yes
 	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	_LT_TAGVAR(ld_shlibs, $1)=no
-	;;
-
-      openbsd*)
+      openbsd* | bitrig*)
 	if test -f /usr/libexec/ld.so; then
 	  _LT_TAGVAR(hardcode_direct, $1)=yes
 	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
 	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
 	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
 	  fi
 	  output_verbose_link_cmd=func_echo_all
 	else
@@ -6613,9 +7153,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # KCC will only create a shared library if the output file
 	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
 	    # to its proper name (with version) after linking.
-	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
 	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	    # Archives containing C++ object files must be created using
@@ -6633,17 +7173,17 @@ if test "$_lt_caught_CXX_error" != yes; then
           cxx*)
 	    case $host in
 	      osf3*)
-	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 		;;
 	      *)
 	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
+                  echo "-hidden">> $lib.exp~
+                  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+                  $RM $lib.exp'
 	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
 		;;
 	    esac
@@ -6658,21 +7198,21 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
 	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
 	      case $host in
 	        osf3*)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	        *)
-	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
 		  ;;
 	      esac
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
 	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
 
 	      # Commands to make compiler produce verbose output that lists
@@ -6718,9 +7258,9 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    # Sun C++ 4.2, 5.x and Centerline C++
             _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
 	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
 	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+              $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
 	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6728,7 +7268,7 @@ if test "$_lt_caught_CXX_error" != yes; then
 	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 	      *)
 		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
+		# but understands '-z linker_flag'.
 	        # Supported since Solaris 2.6 (maybe 2.5.1?)
 		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
 	        ;;
@@ -6745,30 +7285,30 @@ if test "$_lt_caught_CXX_error" != yes; then
 	    ;;
           gcx*)
 	    # Green Hills C++ Compiler
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 
 	    # The C++ compiler must be used to create the archive.
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
 	    ;;
           *)
 	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	    if test yes,no = "$GXX,$with_gnu_ld"; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
 	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
 	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
-	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
 	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                  $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
@@ -6776,11 +7316,11 @@ if test "$_lt_caught_CXX_error" != yes; then
 	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 	      fi
 
-	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
 	      case $host_os in
 		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
 		*)
-		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
 		  ;;
 	      esac
 	    fi
@@ -6789,52 +7329,52 @@ if test "$_lt_caught_CXX_error" != yes; then
         ;;
 
     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
-      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
       _LT_TAGVAR(archive_cmds_need_lc, $1)=no
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
       runpath_var='LD_RUN_PATH'
 
       case $cc_basename in
         CC*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
 	*)
-	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	  ;;
       esac
       ;;
 
       sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
+	# Note: We CANNOT use -z defs as we might desire, because we do not
 	# link with -lc, and that would cause any symbols used from libc to
 	# always be unresolved, which means just about no library would
 	# ever link correctly.  If we're not using GNU ld we use -z text
 	# though, which does catch some bad symbols but isn't as heavy-handed
 	# as -z defs.
-	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
-	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
 	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
 	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
 	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
 	_LT_TAGVAR(link_all_deplibs, $1)=yes
-	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
 	runpath_var='LD_RUN_PATH'
 
 	case $cc_basename in
           CC*)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
-	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
+              '"$_LT_TAGVAR(old_archive_cmds, $1)"
 	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
-	      '"$_LT_TAGVAR(reload_cmds, $1)"
+              '"$_LT_TAGVAR(reload_cmds, $1)"
 	    ;;
 	  *)
-	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
 	    ;;
 	esac
       ;;
@@ -6865,10 +7405,10 @@ if test "$_lt_caught_CXX_error" != yes; then
     esac
 
     AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+    test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
 
-    _LT_TAGVAR(GCC, $1)="$GXX"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$GXX
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -6895,7 +7435,7 @@ if test "$_lt_caught_CXX_error" != yes; then
   lt_cv_path_LD=$lt_save_path_LD
   lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
   lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
 
 AC_LANG_POP
 ])# _LT_LANG_CXX_CONFIG
@@ -6917,13 +7457,14 @@ AC_REQUIRE([_LT_DECL_SED])
 AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
 func_stripname_cnf ()
 {
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  case @S|@2 in
+  .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+  *)  func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
   esac
 } # func_stripname_cnf
 ])# _LT_FUNC_STRIPNAME_CNF
 
+
 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
 # ---------------------------------
 # Figure out "hidden" library dependencies from verbose
@@ -7007,13 +7548,13 @@ if AC_TRY_EVAL(ac_compile); then
   pre_test_object_deps_done=no
 
   for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+    case $prev$p in
 
     -L* | -R* | -l*)
        # Some compilers place space between "-{L,R}" and the path.
        # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
+       if test x-L = "$p" ||
+          test x-R = "$p"; then
 	 prev=$p
 	 continue
        fi
@@ -7029,16 +7570,16 @@ if AC_TRY_EVAL(ac_compile); then
        case $p in
        =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
        esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
+       if test no = "$pre_test_object_deps_done"; then
+	 case $prev in
 	 -L | -R)
 	   # Internal compiler library paths should come after those
 	   # provided the user.  The postdeps already come after the
 	   # user supplied libs so there is no need to process them.
 	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
 	   else
-	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
 	   fi
 	   ;;
 	 # The "-l" case would never come before the object being
@@ -7046,9 +7587,9 @@ if AC_TRY_EVAL(ac_compile); then
 	 esac
        else
 	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
-	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)=$prev$p
 	 else
-	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
 	 fi
        fi
        prev=
@@ -7063,15 +7604,15 @@ if AC_TRY_EVAL(ac_compile); then
 	 continue
        fi
 
-       if test "$pre_test_object_deps_done" = no; then
+       if test no = "$pre_test_object_deps_done"; then
 	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
-	   _LT_TAGVAR(predep_objects, $1)="$p"
+	   _LT_TAGVAR(predep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
 	 fi
        else
 	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
-	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	   _LT_TAGVAR(postdep_objects, $1)=$p
 	 else
 	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
 	 fi
@@ -7102,51 +7643,6 @@ interix[[3-9]]*)
   _LT_TAGVAR(postdep_objects,$1)=
   _LT_TAGVAR(postdeps,$1)=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
-
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
-    esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 ])
 
@@ -7155,7 +7651,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in
 esac
  _LT_TAGVAR(compiler_lib_search_dirs, $1)=
 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
 fi
 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
     [The directories searched by this compiler when creating a shared library])
@@ -7175,10 +7671,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1],
 # --------------------------
 # Ensure that the configuration variables for a Fortran 77 compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_F77_CONFIG],
 [AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
+if test -z "$F77" || test no = "$F77"; then
   _lt_disable_F77=yes
 fi
 
@@ -7215,7 +7711,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the F77 compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7237,7 +7733,7 @@ if test "$_lt_disable_F77" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${F77-"f77"}
@@ -7251,21 +7747,25 @@ if test "$_lt_disable_F77" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7273,11 +7773,11 @@ if test "$_lt_disable_F77" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$G77"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$G77
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7294,9 +7794,9 @@ if test "$_lt_disable_F77" != yes; then
   fi # test -n "$compiler"
 
   GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
 
 AC_LANG_POP
 ])# _LT_LANG_F77_CONFIG
@@ -7306,11 +7806,11 @@ AC_LANG_POP
 # -------------------------
 # Ensure that the configuration variables for a Fortran compiler are
 # suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_FC_CONFIG],
 [AC_LANG_PUSH(Fortran)
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
+if test -z "$FC" || test no = "$FC"; then
   _lt_disable_FC=yes
 fi
 
@@ -7347,7 +7847,7 @@ _LT_TAGVAR(objext, $1)=$objext
 # the FC compiler isn't working.  Some variables (like enable_shared)
 # are currently assumed to apply to all compilers on this platform,
 # and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
   # Code to be used in simple compile tests
   lt_simple_compile_test_code="\
       subroutine t
@@ -7369,7 +7869,7 @@ if test "$_lt_disable_FC" != yes; then
   _LT_LINKER_BOILERPLATE
 
   # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
+  lt_save_CC=$CC
   lt_save_GCC=$GCC
   lt_save_CFLAGS=$CFLAGS
   CC=${FC-"f95"}
@@ -7385,21 +7885,25 @@ if test "$_lt_disable_FC" != yes; then
     AC_MSG_RESULT([$can_build_shared])
 
     AC_MSG_CHECKING([whether to build shared libraries])
-    test "$can_build_shared" = "no" && enable_shared=no
+    test no = "$can_build_shared" && enable_shared=no
 
     # On AIX, shared libraries and static libraries use the same namespace, and
     # are all built from PIC.
     case $host_os in
       aix3*)
-        test "$enable_shared" = yes && enable_static=no
+        test yes = "$enable_shared" && enable_static=no
         if test -n "$RANLIB"; then
           archive_cmds="$archive_cmds~\$RANLIB \$lib"
           postinstall_cmds='$RANLIB $lib'
         fi
         ;;
       aix[[4-9]]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
+	if test ia64 != "$host_cpu"; then
+	  case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+	  yes,aix,yes) ;;		# shared object as lib.so file only
+	  yes,svr4,*) ;;		# shared object as lib.so archive member only
+	  yes,*) enable_static=no ;;	# shared object in lib.a archive as well
+	  esac
 	fi
         ;;
     esac
@@ -7407,11 +7911,11 @@ if test "$_lt_disable_FC" != yes; then
 
     AC_MSG_CHECKING([whether to build static libraries])
     # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
+    test yes = "$enable_shared" || enable_static=yes
     AC_MSG_RESULT([$enable_static])
 
-    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
-    _LT_TAGVAR(LD, $1)="$LD"
+    _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+    _LT_TAGVAR(LD, $1)=$LD
 
     ## CAVEAT EMPTOR:
     ## There is no encapsulation within the following macros, do not change
@@ -7431,7 +7935,7 @@ if test "$_lt_disable_FC" != yes; then
   GCC=$lt_save_GCC
   CC=$lt_save_CC
   CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+fi # test yes != "$_lt_disable_FC"
 
 AC_LANG_POP
 ])# _LT_LANG_FC_CONFIG
@@ -7441,7 +7945,7 @@ AC_LANG_POP
 # --------------------------
 # Ensure that the configuration variables for the GNU Java Compiler compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GCJ_CONFIG],
 [AC_REQUIRE([LT_PROG_GCJ])dnl
 AC_LANG_SAVE
@@ -7475,7 +7979,7 @@ CC=${GCJ-"gcj"}
 CFLAGS=$GCJFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # GCJ did not exist at the time GCC didn't implicitly link libc in.
@@ -7512,7 +8016,7 @@ CFLAGS=$lt_save_CFLAGS
 # --------------------------
 # Ensure that the configuration variables for the GNU Go compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_GO_CONFIG],
 [AC_REQUIRE([LT_PROG_GO])dnl
 AC_LANG_SAVE
@@ -7546,7 +8050,7 @@ CC=${GOC-"gccgo"}
 CFLAGS=$GOFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
 _LT_CC_BASENAME([$compiler])
 
 # Go did not exist at the time GCC didn't implicitly link libc in.
@@ -7583,7 +8087,7 @@ CFLAGS=$lt_save_CFLAGS
 # -------------------------
 # Ensure that the configuration variables for the Windows resource compiler
 # are suitably defined.  These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
 m4_defun([_LT_LANG_RC_CONFIG],
 [AC_REQUIRE([LT_PROG_RC])dnl
 AC_LANG_SAVE
@@ -7599,7 +8103,7 @@ _LT_TAGVAR(objext, $1)=$objext
 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
 
 # Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
@@ -7609,7 +8113,7 @@ _LT_COMPILER_BOILERPLATE
 _LT_LINKER_BOILERPLATE
 
 # Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
 lt_save_GCC=$GCC
 GCC=
@@ -7638,7 +8142,7 @@ AC_DEFUN([LT_PROG_GCJ],
 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
   [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
     [AC_CHECK_TOOL(GCJ, gcj,)
-      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
       AC_SUBST(GCJFLAGS)])])[]dnl
 ])
 
@@ -7749,7 +8253,7 @@ lt_ac_count=0
 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
 # along with /bin/sed that truncates output.
 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
+  test ! -f "$lt_ac_sed" && continue
   cat /dev/null > conftest.in
   lt_ac_count=0
   echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7766,9 +8270,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
     $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
     cmp -s conftest.out conftest.nl || break
     # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
+    test 10 -lt "$lt_ac_count" && break
     lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
+    if test "$lt_ac_count" -gt "$lt_ac_max"; then
       lt_ac_max=$lt_ac_count
       lt_cv_path_SED=$lt_ac_sed
     fi
@@ -7792,27 +8296,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], [])
 # Find out whether the shell is Bourne or XSI compatible,
 # or has some other useful features.
 m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   lt_unset=unset
 else
   lt_unset=false
@@ -7836,102 +8320,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
 ])# _LT_CHECK_SHELL_FEATURES
 
 
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
-  && mv -f "$cfgfile.tmp" "$cfgfile" \
-    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
-    case ${1} in
-      */*) func_dirname_result="${1%/*}${2}" ;;
-      *  ) func_dirname_result="${3}" ;;
-    esac
-    func_basename_result="${1##*/}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
-    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
-    # positional parameters, so assign one to ordinary parameter first.
-    func_stripname_result=${3}
-    func_stripname_result=${func_stripname_result#"${1}"}
-    func_stripname_result=${func_stripname_result%"${2}"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
-    func_split_long_opt_name=${1%%=*}
-    func_split_long_opt_arg=${1#*=}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
-    func_split_short_opt_arg=${1#??}
-    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
-  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
-    case ${1} in
-      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
-      *)    func_lo2o_result=${1} ;;
-    esac])
-
-  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
-
-  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
-
-  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
-  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
-
-  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
-    func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
-    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
-  # Save a `func_append' function call where possible by direct use of '+='
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-else
-  # Save a `func_append' function call even when '+=' is not available
-  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
-    && mv -f "$cfgfile.tmp" "$cfgfile" \
-      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-  test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
-  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
 # _LT_PATH_CONVERSION_FUNCTIONS
 # -----------------------------
-# Determine which file name conversion functions should be used by
+# Determine what file name conversion functions should be used by
 # func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
 # for certain cross-compile configurations and native mingw.
 m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
diff --git a/src/gmock/gtest/m4/ltoptions.m4 b/src/gmock/gtest/m4/ltoptions.m4
index 5d9acd8..94b0829 100644
--- a/src/gmock/gtest/m4/ltoptions.m4
+++ b/src/gmock/gtest/m4/ltoptions.m4
@@ -1,14 +1,14 @@
 # Helper functions for option handling.                    -*- Autoconf -*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
+#   Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 7 ltoptions.m4
+# serial 8 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
+    [m4_warning([Unknown $1 option '$2'])])[]dnl
 ])
 
 
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
   dnl
   dnl If no reference was made to various pairs of opposing options, then
   dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
   dnl archives by default:
   _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
   _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
+		   [_LT_ENABLE_FAST_INSTALL])
+  _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+		   [_LT_WITH_AIX_SONAME([aix])])
   ])
 ])# _LT_SET_OPTIONS
 
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
 [_LT_SET_OPTION([LT_INIT], [dlopen])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 _LT_SET_OPTION([LT_INIT], [win32-dll])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
 # _LT_ENABLE_SHARED([DEFAULT])
 # ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_SHARED],
 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([shared],
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
 # _LT_ENABLE_STATIC([DEFAULT])
 # ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_STATIC],
 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([static],
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
 # ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_FAST_INSTALL],
 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([fast-install],
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
 ])
 
 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
 
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'.  If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+  AC_MSG_CHECKING([which variant of shared library versioning to provide])
+  AC_ARG_WITH([aix-soname],
+    [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+      [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+    [case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname],
+    [AC_CACHE_VAL([lt_cv_with_aix_soname],
+      [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+    with_aix_soname=$lt_cv_with_aix_soname])
+  AC_MSG_RESULT([$with_aix_soname])
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+    [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'.  If omitted, it defaults to 'both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
     [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+    [pic_mode=m4_default([$1], [default])])
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
 [_LT_SET_OPTION([LT_INIT], [pic-only])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
diff --git a/src/gmock/gtest/m4/ltsugar.m4 b/src/gmock/gtest/m4/ltsugar.m4
index 9000a05..48bc934 100644
--- a/src/gmock/gtest/m4/ltsugar.m4
+++ b/src/gmock/gtest/m4/ltsugar.m4
@@ -1,6 +1,7 @@
 # ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
 #
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
 # Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -33,7 +34,7 @@ m4_define([_lt_join],
 # ------------
 # Manipulate m4 lists.
 # These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
 m4_define([lt_car], [[$1]])
 m4_define([lt_cdr],
 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
 
 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
 # ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
 # Note that neither SEPARATOR nor STRING are expanded; they are appended
 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
diff --git a/src/gmock/gtest/m4/ltversion.m4 b/src/gmock/gtest/m4/ltversion.m4
index 07a8602..fa04b52 100644
--- a/src/gmock/gtest/m4/ltversion.m4
+++ b/src/gmock/gtest/m4/ltversion.m4
@@ -1,6 +1,6 @@
 # ltversion.m4 -- version numbers			-*- Autoconf -*-
 #
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
 #   Written by Scott James Remnant, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -9,15 +9,15 @@
 
 # @configure_input@
 
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])
diff --git a/src/gmock/gtest/m4/lt~obsolete.m4 b/src/gmock/gtest/m4/lt~obsolete.m4
index c573da9..c6b26f8 100644
--- a/src/gmock/gtest/m4/lt~obsolete.m4
+++ b/src/gmock/gtest/m4/lt~obsolete.m4
@@ -1,6 +1,7 @@
 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
@@ -11,7 +12,7 @@
 
 # These exist entirely to fool aclocal when bootstrapping libtool.
 #
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
 # which have later been changed to m4_define as they aren't part of the
 # exported API, or moved to Autoconf or Automake where they belong.
 #
@@ -25,7 +26,7 @@
 # included after everything else.  This provides aclocal with the
 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
 # because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
 #
 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
 # Yes, that means every name once taken will need to remain here until
diff --git a/src/include/assert.h b/src/include/assert.h
index e13ab9d..94f9d74 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -26,12 +26,6 @@ class CephContext;
 namespace ceph {
 
 struct BackTrace;
-
-struct FailedAssertion {
-  BackTrace *backtrace;
-  FailedAssertion(BackTrace *bt) : backtrace(bt) {}
-};
-
 #endif
 
 
diff --git a/src/include/buffer.h b/src/include/buffer.h
index 2962357..5a8b05f 100644
--- a/src/include/buffer.h
+++ b/src/include/buffer.h
@@ -154,7 +154,7 @@ namespace buffer CEPH_BUFFER_API {
   raw* create_unshareable(unsigned len);
 
 #if defined(HAVE_XIO)
-  static raw* create_msg(unsigned len, char *buf, XioDispatchHook *m_hook);
+  raw* create_msg(unsigned len, char *buf, XioDispatchHook *m_hook);
 #endif
 
   /*
@@ -197,6 +197,7 @@ namespace buffer CEPH_BUFFER_API {
       return (length() % align) == 0;
     }
     bool is_n_page_sized() const { return is_n_align_sized(CEPH_PAGE_SIZE); }
+    bool is_partial() const { return start() > 0 || end() < raw_length(); }
 
     // accessors
     raw *get_raw() const { return _raw; }
diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h
index 4e15563..adf597a 100755
--- a/src/include/ceph_features.h
+++ b/src/include/ceph_features.h
@@ -72,6 +72,7 @@
 #define CEPH_FEATURE_NEW_OSDOP_ENCODING   (1ULL<<56) /* New, v7 encoding */
 #define CEPH_FEATURE_MON_STATEFUL_SUB (1ULL<<57) /* stateful mon subscription */
 #define CEPH_FEATURE_MON_ROUTE_OSDMAP (1ULL<<57) /* peon sends osdmaps */
+#define CEPH_FEATURE_CRUSH_TUNABLES5	(1ULL<<58) /* chooseleaf stable mode */
 
 #define CEPH_FEATURE_RESERVED2 (1ULL<<61)  /* slow down, we are almost out... */
 #define CEPH_FEATURE_RESERVED  (1ULL<<62)  /* DO NOT USE THIS ... last bit! */
@@ -166,6 +167,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
 	 CEPH_FEATURE_HAMMER_0_94_4 |		 \
 	 CEPH_FEATURE_MON_STATEFUL_SUB |	 \
 	 CEPH_FEATURE_MON_ROUTE_OSDMAP |	 \
+	 CEPH_FEATURE_CRUSH_TUNABLES5 |	    \
 	 0ULL)
 
 #define CEPH_FEATURES_SUPPORTED_DEFAULT  CEPH_FEATURES_ALL
@@ -177,6 +179,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
 	(CEPH_FEATURE_CRUSH_TUNABLES |		\
 	 CEPH_FEATURE_CRUSH_TUNABLES2 |		\
 	 CEPH_FEATURE_CRUSH_TUNABLES3 |		\
+	 CEPH_FEATURE_CRUSH_TUNABLES5 |		\
 	 CEPH_FEATURE_CRUSH_V2 |		\
 	 CEPH_FEATURE_CRUSH_V4)
 
diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h
index 1dd333e..af49a78 100644
--- a/src/include/ceph_fs.h
+++ b/src/include/ceph_fs.h
@@ -294,6 +294,9 @@ enum {
 	CEPH_SESSION_FLUSHMSG,
 	CEPH_SESSION_FLUSHMSG_ACK,
 	CEPH_SESSION_FORCE_RO,
+    // A response to REQUEST_OPEN indicating that the client should
+    // permanently desist from contacting the MDS
+	CEPH_SESSION_REJECT
 };
 
 extern const char *ceph_session_op_name(int op);
@@ -358,13 +361,15 @@ enum {
 extern const char *ceph_mds_op_name(int op);
 
 
-#define CEPH_SETATTR_MODE   1
-#define CEPH_SETATTR_UID    2
-#define CEPH_SETATTR_GID    4
-#define CEPH_SETATTR_MTIME  8
-#define CEPH_SETATTR_ATIME 16
-#define CEPH_SETATTR_SIZE  32
-#define CEPH_SETATTR_CTIME 64
+#define CEPH_SETATTR_MODE	(1 << 0)
+#define CEPH_SETATTR_UID	(1 << 1)
+#define CEPH_SETATTR_GID	(1 << 2)
+#define CEPH_SETATTR_MTIME	(1 << 3)
+#define CEPH_SETATTR_ATIME	(1 << 4)
+#define CEPH_SETATTR_SIZE	(1 << 5)
+#define CEPH_SETATTR_CTIME	(1 << 6)
+#define CEPH_SETATTR_MTIME_NOW	(1 << 7)
+#define CEPH_SETATTR_ATIME_NOW	(1 << 8)
 
 /*
  * Ceph setxattr request flags.
diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h
index acdfa13..ba55c35 100644
--- a/src/include/cephfs/libcephfs.h
+++ b/src/include/cephfs/libcephfs.h
@@ -158,6 +158,19 @@ int ceph_create(struct ceph_mount_info **cmount, const char * const id);
  */
 int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf);
 
+
+typedef void *rados_t;
+
+/**
+ * Create a mount handle from a rados_t, for using libcephfs in the
+ * same process as librados.
+ *
+ * @param cmount the mount info handle to initialize
+ * @param cluster reference to already-initialized librados handle
+ * @returns 0 on success, negative error code on failure
+ */
+int ceph_create_from_rados(struct ceph_mount_info **cmount, rados_t cluster);
+
 /**
  * Initialize the filesystem client (but do not mount the filesystem yet)
  *
diff --git a/src/include/interval_set.h b/src/include/interval_set.h
index 00ead9d..3759f77 100644
--- a/src/include/interval_set.h
+++ b/src/include/interval_set.h
@@ -267,12 +267,16 @@ class interval_set {
     _size = 0;
   }
 
-  bool contains(T i) const {
+  bool contains(T i, T *pstart=0, T *plen=0) const {
     typename map<T,T>::const_iterator p = find_inc(i);
     if (p == m.end()) return false;
     if (p->first > i) return false;
     if (p->first+p->second <= i) return false;
     assert(p->first <= i && p->first+p->second > i);
+    if (pstart)
+      *pstart = p->first;
+    if (plen)
+      *plen = p->second;
     return true;
   }
   bool contains(T start, T len) const {
@@ -333,13 +337,17 @@ class interval_set {
     insert(val, 1);
   }
 
-  void insert(T start, T len) {
+  void insert(T start, T len, T *pstart=0, T *plen=0) {
     //cout << "insert " << start << "~" << len << endl;
     assert(len > 0);
     _size += len;
     typename map<T,T>::iterator p = find_adj_m(start);
     if (p == m.end()) {
       m[start] = len;                  // new interval
+      if (pstart)
+	*pstart = start;
+      if (plen)
+	*plen = len;
     } else {
       if (p->first < start) {
         
@@ -358,13 +366,25 @@ class interval_set {
           p->second += n->second;
           m.erase(n);
         }
+	if (pstart)
+	  *pstart = p->first;
+	if (plen)
+	  *plen = p->second;
       } else {
         if (start+len == p->first) {
           m[start] = len + p->second;  // append to front 
+	  if (pstart)
+	    *pstart = start;
+	  if (plen)
+	    *plen = len + p->second;
           m.erase(p);
         } else {
           assert(p->first > start+len);
           m[start] = len;              // new interval
+	  if (pstart)
+	    *pstart = start;
+	  if (plen)
+	    *plen = len;
         }
       }
     }
diff --git a/src/include/rados/buffer.h b/src/include/rados/buffer.h
index 2962357..5a8b05f 100644
--- a/src/include/rados/buffer.h
+++ b/src/include/rados/buffer.h
@@ -154,7 +154,7 @@ namespace buffer CEPH_BUFFER_API {
   raw* create_unshareable(unsigned len);
 
 #if defined(HAVE_XIO)
-  static raw* create_msg(unsigned len, char *buf, XioDispatchHook *m_hook);
+  raw* create_msg(unsigned len, char *buf, XioDispatchHook *m_hook);
 #endif
 
   /*
@@ -197,6 +197,7 @@ namespace buffer CEPH_BUFFER_API {
       return (length() % align) == 0;
     }
     bool is_n_page_sized() const { return is_n_align_sized(CEPH_PAGE_SIZE); }
+    bool is_partial() const { return start() > 0 || end() < raw_length(); }
 
     // accessors
     raw *get_raw() const { return _raw; }
diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h
index bda583a..e9b5c91 100644
--- a/src/include/rados/librados.h
+++ b/src/include/rados/librados.h
@@ -190,6 +190,25 @@ typedef void *rados_ioctx_t;
 typedef void *rados_list_ctx_t;
 
 /**
+ * @typedef rados_object_list_cursor
+ *
+ * The cursor used with rados_enumerate_objects
+ * and accompanying methods.
+ */
+typedef void * rados_object_list_cursor;
+
+typedef struct rados_object_list_item {
+  size_t oid_length;
+  char *oid;
+
+  size_t nspace_length;
+  char *nspace;
+
+  size_t locator_length;
+  char *locator;
+} rados_object_list_item;
+
+/**
  * @typedef rados_snap_t
  * The id of a snapshot.
  */
@@ -956,6 +975,54 @@ CEPH_RADOS_API int rados_nobjects_list_next(rados_list_ctx_t ctx,
  */
 CEPH_RADOS_API void rados_nobjects_list_close(rados_list_ctx_t ctx);
 
+CEPH_RADOS_API rados_object_list_cursor rados_object_list_begin(rados_ioctx_t io);
+CEPH_RADOS_API rados_object_list_cursor rados_object_list_end(rados_ioctx_t io);
+
+CEPH_RADOS_API int rados_object_list_is_end(rados_ioctx_t io,
+    rados_object_list_cursor cur);
+
+CEPH_RADOS_API void rados_object_list_cursor_free(rados_ioctx_t io,
+    rados_object_list_cursor cur);
+
+CEPH_RADOS_API int rados_object_list_cursor_cmp(rados_ioctx_t io,
+    rados_object_list_cursor lhs, rados_object_list_cursor rhs);
+
+/**
+ * @return the number of items set in the result array
+ */
+CEPH_RADOS_API int rados_object_list(rados_ioctx_t io,
+    const rados_object_list_cursor start,
+    const rados_object_list_cursor finish,
+    const size_t result_size,
+    rados_object_list_item *results,
+    rados_object_list_cursor *next);
+
+CEPH_RADOS_API void rados_object_list_free(
+    const size_t result_size,
+    rados_object_list_item *results);
+
+/**
+ * Obtain cursors delineating a subset of a range.  Use this
+ * when you want to split up the work of iterating over the
+ * global namespace.  Expected use case is when you are iterating
+ * in parallel, with `m` workers, and each worker taking an id `n`.
+ *
+ * @param start start of the range to be sliced up (inclusive)
+ * @param finish end of the range to be sliced up (exclusive)
+ * @param m how many chunks to divide start-finish into
+ * @param n which of the m chunks you would like to get cursors for
+ * @param split_start cursor populated with start of the subrange (inclusive)
+ * @param split_finish cursor populated with end of the subrange (exclusive)
+ */
+CEPH_RADOS_API void rados_object_list_slice(rados_ioctx_t io,
+    const rados_object_list_cursor start,
+    const rados_object_list_cursor finish,
+    const size_t n,
+    const size_t m,
+    rados_object_list_cursor *split_start,
+    rados_object_list_cursor *split_finish);
+
+
 /** @} New Listing Objects */
 
 /**
diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp
index a184fe1..9173bf5 100644
--- a/src/include/rados/librados.hpp
+++ b/src/include/rados/librados.hpp
@@ -151,6 +151,29 @@ namespace librados
     std::pair<std::string, std::string> cur_obj;
   };
 
+  class CEPH_RADOS_API ObjectCursor
+  {
+    public:
+    ObjectCursor();
+    ObjectCursor(const ObjectCursor &rhs);
+    ~ObjectCursor();
+    bool operator<(const ObjectCursor &rhs);
+    void set(rados_object_list_cursor c);
+
+    friend class IoCtx;
+
+    protected:
+    rados_object_list_cursor c_cursor;
+  };
+
+  class CEPH_RADOS_API ObjectItem
+  {
+    public:
+    std::string oid;
+    std::string nspace;
+    std::string locator;
+  };
+
   /// DEPRECATED; do not use
   class CEPH_RADOS_API WatchCtx {
   public:
@@ -679,6 +702,7 @@ namespace librados
                    size_t len);
     int read(const std::string& oid, bufferlist& bl, size_t len, uint64_t off);
     int remove(const std::string& oid);
+    int remove(const std::string& oid, int flags);
     int trunc(const std::string& oid, uint64_t size);
     int mapext(const std::string& o, uint64_t off, size_t len, std::map<uint64_t,uint64_t>& m);
     int sparse_read(const std::string& o, std::map<uint64_t,uint64_t>& m, bufferlist& bl, size_t len, uint64_t off);
@@ -803,6 +827,21 @@ namespace librados
     /// Iterator indicating the end of a pool
     const ObjectIterator& objects_end() const __attribute__ ((deprecated));
 
+    ObjectCursor object_list_begin();
+    ObjectCursor object_list_end();
+    bool object_list_is_end(const ObjectCursor &oc);
+    int object_list(const ObjectCursor &start, const ObjectCursor &finish,
+                    const size_t result_count,
+                    std::vector<ObjectItem> *result,
+                    ObjectCursor *next);
+    void object_list_slice(
+        const ObjectCursor start,
+        const ObjectCursor finish,
+        const size_t n,
+        const size_t m,
+        ObjectCursor *split_start,
+        ObjectCursor *split_finish);
+
     /**
      * List available hit set objects
      *
@@ -1123,6 +1162,10 @@ namespace librados
 
     int mon_command(std::string cmd, const bufferlist& inbl,
 		    bufferlist *outbl, std::string *outs);
+    int osd_command(int osdid, std::string cmd, const bufferlist& inbl,
+                    bufferlist *outbl, std::string *outs);
+    int pg_command(const char *pgstr, std::string cmd, const bufferlist& inbl,
+                   bufferlist *outbl, std::string *outs);
 
     int ioctx_create(const char *name, IoCtx &pioctx);
     int ioctx_create2(int64_t pool_id, IoCtx &pioctx);
diff --git a/src/include/radosstriper/libradosstriper.hpp b/src/include/radosstriper/libradosstriper.hpp
index 05179ff..6352d58 100644
--- a/src/include/radosstriper/libradosstriper.hpp
+++ b/src/include/radosstriper/libradosstriper.hpp
@@ -190,7 +190,7 @@ namespace libradosstriper
      * during deletion (same EBUSY return code)
      */
     int remove(const std::string& soid);
-
+    int remove(const std::string& soid, int flags);
     /**
      * Resizes a striped object
      * the truncation can not happen if any I/O is ongoing (it
diff --git a/src/include/rbd/librbd.hpp b/src/include/rbd/librbd.hpp
index 288e450..d9bf1de 100644
--- a/src/include/rbd/librbd.hpp
+++ b/src/include/rbd/librbd.hpp
@@ -206,7 +206,9 @@ public:
 
   /* snapshots */
   int snap_list(std::vector<snap_info_t>& snaps);
-  bool snap_exists(const char *snapname);
+  /* DEPRECATED; use snap_exists2 */
+  bool snap_exists(const char *snapname) __attribute__ ((deprecated));
+  int snap_exists2(const char *snapname, bool *exists);
   int snap_create(const char *snapname);
   int snap_remove(const char *snapname);
   int snap_rollback(const char *snap_name);
diff --git a/src/include/rbd_types.h b/src/include/rbd_types.h
index 2cee7ee..6ac5ed0 100644
--- a/src/include/rbd_types.h
+++ b/src/include/rbd_types.h
@@ -65,8 +65,6 @@
  */
 #define RBD_POOL_SETTINGS       "rbd_pool_settings"
 
-#define RBD_DEFAULT_OBJ_ORDER	22   /* 4MB */
-
 #define RBD_MAX_OBJ_NAME_SIZE	96
 #define RBD_MAX_BLOCK_NAME_SIZE 24
 
diff --git a/src/include/util.h b/src/include/util.h
index c453440..fa8dd24 100644
--- a/src/include/util.h
+++ b/src/include/util.h
@@ -14,13 +14,9 @@
 #ifndef CEPH_UTIL_H
 #define CEPH_UTIL_H
 
-// is buf~len completely zero (in 8-byte chunks)
-
 #include "common/Formatter.h"
 #include "include/types.h"
 
-bool buf_is_zero(const char *buf, size_t len);
-
 int64_t unit_to_bytesize(string val, ostream *pss);
 
 struct ceph_data_stats
diff --git a/src/include/utime.h b/src/include/utime.h
index 27241e0..a60501a 100644
--- a/src/include/utime.h
+++ b/src/include/utime.h
@@ -28,6 +28,11 @@
 // --------
 // utime_t
 
+/* WARNING: If add member in utime_t, please make sure the encode/decode funtion
+ * work well. For little-endian machine, we should make sure there is no padding
+ * in 32-bit machine and 64-bit machine.
+ * You should also modify the padding_check function.
+ */
 class utime_t {
 public:
   struct {
@@ -95,14 +100,29 @@ public:
     tv.tv_sec = v->tv_sec;
     tv.tv_nsec = v->tv_usec*1000;
   }
-
+  void padding_check() {
+    static_assert(
+      sizeof(utime_t) ==
+        sizeof(tv.tv_sec) +
+        sizeof(tv.tv_nsec)
+      ,
+      "utime_t have padding");
+  }
   void encode(bufferlist &bl) const {
+#if defined(CEPH_LITTLE_ENDIAN)
+    bl.append((char *)(this), sizeof(__u32) + sizeof(__u32));
+#else
     ::encode(tv.tv_sec, bl);
     ::encode(tv.tv_nsec, bl);
+#endif
   }
   void decode(bufferlist::iterator &p) {
+#if defined(CEPH_LITTLE_ENDIAN)
+    p.copy(sizeof(__u32) + sizeof(__u32), (char *)(this));
+#else
     ::decode(tv.tv_sec, p);
     ::decode(tv.tv_nsec, p);
+#endif
   }
 
   void encode_timeval(struct ceph_timespec *t) const {
diff --git a/src/java/Makefile.in b/src/java/Makefile.in
index a8e9497..959fe08 100644
--- a/src/java/Makefile.in
+++ b/src/java/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,17 @@
 # automake technique adapted from OpenMPI Java
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -84,7 +94,6 @@ target_triplet = @target@
 @ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@HAVE_JUNIT4_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_1 = libcephfs-test.jar
 @ENABLE_CEPHFS_JAVA_TRUE@@ENABLE_CLIENT_TRUE@@HAVE_JUNIT4_TRUE@@WITH_CEPHFS_TRUE@@WITH_RADOS_TRUE at am__append_2 = test/com/ceph/fs/*.class libcephfs-test.jar
 subdir = src/java
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/ac_prog_jar.m4 \
@@ -103,6 +112,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/acconfig.h
 CONFIG_CLEAN_FILES =
@@ -156,6 +166,7 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(javadir)"
 DATA = $(java_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -246,6 +257,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -342,6 +354,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -417,7 +430,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/java/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign src/java/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -620,6 +632,8 @@ uninstall-am: uninstall-javaDATA
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags-am uninstall uninstall-am uninstall-javaDATA
 
+.PRECIOUS: Makefile
+
 
 # note: for the -source 1.5 builds, we add
 #   -Xlint:-options
diff --git a/src/java/test/com/ceph/fs/CephMountCreateTest.java b/src/java/test/com/ceph/fs/CephMountCreateTest.java
index 9df9342..fc2bafd 100644
--- a/src/java/test/com/ceph/fs/CephMountCreateTest.java
+++ b/src/java/test/com/ceph/fs/CephMountCreateTest.java
@@ -44,6 +44,7 @@ public class CephMountCreateTest {
     CephMount mount = new CephMount("admin");
     if (conf_file != null)
       mount.conf_read_file(conf_file);
+    mount.conf_set("client_permissions", "0");
     mount.mount(root);
     return mount;
   }
diff --git a/src/java/test/com/ceph/fs/CephMountTest.java b/src/java/test/com/ceph/fs/CephMountTest.java
index 1a3e568..c952c0c 100644
--- a/src/java/test/com/ceph/fs/CephMountTest.java
+++ b/src/java/test/com/ceph/fs/CephMountTest.java
@@ -47,6 +47,7 @@ public class CephMountTest {
     String conf_file = System.getProperty("CEPH_CONF_FILE");
     if (conf_file != null)
       mount.conf_read_file(conf_file);
+    mount.conf_set("client_permissions", "0");
 
     mount.mount(null);
 
diff --git a/src/kv/KeyValueDB.cc b/src/kv/KeyValueDB.cc
index 65ce487..9437958 100644
--- a/src/kv/KeyValueDB.cc
+++ b/src/kv/KeyValueDB.cc
@@ -11,7 +11,8 @@
 #endif
 
 KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
-			       const string& dir)
+			       const string& dir,
+			       void *p)
 {
   if (type == "leveldb") {
     return new LevelDBStore(cct, dir);
@@ -25,7 +26,7 @@ KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
 #ifdef HAVE_LIBROCKSDB
   if (type == "rocksdb" &&
       cct->check_experimental_feature_enabled("rocksdb")) {
-    return new RocksDBStore(cct, dir);
+    return new RocksDBStore(cct, dir, p);
   }
 #endif
   return NULL;
diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h
index 347169a..f20b799 100644
--- a/src/kv/KeyValueDB.h
+++ b/src/kv/KeyValueDB.h
@@ -99,7 +99,8 @@ public:
 
   /// create a new instance
   static KeyValueDB *create(CephContext *cct, const std::string& type,
-			    const std::string& dir);
+			    const std::string& dir,
+			    void *p = NULL);
 
   /// test whether we can successfully initialize; may have side effects (e.g., create)
   static int test_init(const std::string& type, const std::string& dir);
@@ -163,6 +164,14 @@ public:
     virtual std::pair<std::string,std::string> raw_key() = 0;
     virtual bool raw_key_is_prefixed(const std::string &prefix) = 0;
     virtual bufferlist value() = 0;
+    virtual bufferptr value_as_ptr() {
+      bufferlist bl = value();
+      if (bl.length()) {
+        return *bl.buffers().begin();
+      } else {
+        return bufferptr();
+      }
+    }
     virtual int status() = 0;
     virtual ~WholeSpaceIteratorImpl() { }
   };
@@ -223,6 +232,9 @@ public:
     bufferlist value() {
       return generic_iter->value();
     }
+    bufferptr value_as_ptr() {
+      return generic_iter->value_as_ptr();
+    }
     int status() {
       return generic_iter->status();
     }
diff --git a/src/kv/LevelDBStore.cc b/src/kv/LevelDBStore.cc
index 2db6dc9..5ea75b9 100644
--- a/src/kv/LevelDBStore.cc
+++ b/src/kv/LevelDBStore.cc
@@ -11,6 +11,34 @@ using std::string;
 #include "common/debug.h"
 #include "common/perf_counters.h"
 
+#define dout_subsys ceph_subsys_leveldb
+#undef dout_prefix
+#define dout_prefix *_dout << "leveldb: "
+
+class CephLevelDBLogger : public leveldb::Logger {
+  CephContext *cct;
+public:
+  CephLevelDBLogger(CephContext *c) : cct(c) {
+    cct->get();
+  }
+  ~CephLevelDBLogger() {
+    cct->put();
+  }
+
+  // Write an entry to the log file with the specified format.
+  void Logv(const char* format, va_list ap) {
+    dout(1);
+    char buf[65536];
+    vsnprintf(buf, sizeof(buf), format, ap);
+    *_dout << buf << dendl;
+  }
+};
+
+leveldb::Logger *create_leveldb_ceph_logger()
+{
+  return new CephLevelDBLogger(g_ceph_context);
+}
+
 int LevelDBStore::init(string option_str)
 {
   // init defaults.  caller can override these if they want
@@ -62,6 +90,11 @@ int LevelDBStore::do_open(ostream &out, bool create_if_missing)
   ldoptions.paranoid_checks = options.paranoid_checks;
   ldoptions.create_if_missing = create_if_missing;
 
+  if (g_conf->leveldb_log_to_ceph_log) {
+    ceph_logger = new CephLevelDBLogger(g_ceph_context);
+    ldoptions.info_log = ceph_logger;
+  }
+  
   if (options.log_file.length()) {
     leveldb::Env *env = leveldb::Env::Default();
     env->NewLogger(options.log_file, &ldoptions.info_log);
@@ -110,6 +143,7 @@ LevelDBStore::~LevelDBStore()
 {
   close();
   delete logger;
+  delete ceph_logger;
 
   // Ensure db is destroyed before dependent db_cache and filterpolicy
   db.reset();
@@ -233,12 +267,13 @@ int LevelDBStore::get(const string &prefix,
 		  const string &key,
 		  bufferlist *value)
 {
+  assert(value && (value->length() == 0));
   utime_t start = ceph_clock_now(g_ceph_context);
   int r = 0;
   KeyValueDB::Iterator it = get_iterator(prefix);
   it->lower_bound(key);
   if (it->valid() && it->key() == key) {
-    *value = it->value();
+    value->append(it->value_as_ptr());
   } else {
     r = -ENOENT;
   }
@@ -344,6 +379,6 @@ void LevelDBStore::compact_range_async(const string& start, const string& end)
   }
   compact_queue_cond.Signal();
   if (!compact_thread.is_started()) {
-    compact_thread.create();
+    compact_thread.create("levdbst_compact");
   }
 }
diff --git a/src/kv/LevelDBStore.h b/src/kv/LevelDBStore.h
index 2ce421c..8a201df 100644
--- a/src/kv/LevelDBStore.h
+++ b/src/kv/LevelDBStore.h
@@ -45,12 +45,17 @@ enum {
   l_leveldb_last,
 };
 
+extern leveldb::Logger *create_leveldb_ceph_logger();
+
+class CephLevelDBLogger;
+
 /**
  * Uses LevelDB to implement the KeyValueDB interface
  */
 class LevelDBStore : public KeyValueDB {
   CephContext *cct;
   PerfCounters *logger;
+  CephLevelDBLogger *ceph_logger;
   string path;
   boost::scoped_ptr<leveldb::Cache> db_cache;
 #ifdef HAVE_LEVELDB_FILTER_POLICY
@@ -148,6 +153,7 @@ public:
   LevelDBStore(CephContext *c, const string &path) :
     cct(c),
     logger(NULL),
+    ceph_logger(NULL),
     path(path),
     db_cache(NULL),
 #ifdef HAVE_LEVELDB_FILTER_POLICY
@@ -292,6 +298,12 @@ public:
     bufferlist value() {
       return to_bufferlist(dbiter->value());
     }
+
+    bufferptr value_as_ptr() {
+      leveldb::Slice data = dbiter->value();
+      return bufferptr(data.data(), data.size());
+    }
+
     int status() {
       return dbiter->status().ok() ? 0 : -1;
     }
diff --git a/src/kv/Makefile.am b/src/kv/Makefile.am
index e5e4878..060305e 100644
--- a/src/kv/Makefile.am
+++ b/src/kv/Makefile.am
@@ -3,7 +3,7 @@ if ENABLE_SERVER
 libkv_a_SOURCES = \
 	kv/KeyValueDB.cc \
 	kv/LevelDBStore.cc
-libkv_a_CXXFLAGS = ${AM_CXXFLAGS} -I rocksdb/include
+libkv_a_CXXFLAGS = ${AM_CXXFLAGS}
 libkv_a_LIBADD =
 
 noinst_LIBRARIES += libkv.a
@@ -18,7 +18,7 @@ if WITH_SLIBROCKSDB
 # PORTABLE=1 fixes the aarch64 build (-march=native doesn't work there)
 rocksdb/librocksdb.a:
 	cd rocksdb && EXTRA_CXXFLAGS=-fPIC PORTABLE=1 make -j$(shell nproc) static_lib
-libkv_a_CXXFLAGS +=  -I rocksdb/include -fPIC
+libkv_a_CXXFLAGS += -I rocksdb/include -fPIC
 libkv_a_SOURCES += kv/RocksDBStore.cc
 libkv_a_LIBADD += rocksdb/librocksdb.a
 noinst_HEADERS += kv/RocksDBStore.h
diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc
index a6d071e..794a254 100644
--- a/src/kv/RocksDBStore.cc
+++ b/src/kv/RocksDBStore.cc
@@ -21,10 +21,51 @@
 using std::string;
 #include "common/perf_counters.h"
 #include "common/debug.h"
+#include "include/str_list.h"
 #include "include/str_map.h"
 #include "KeyValueDB.h"
 #include "RocksDBStore.h"
 
+#include "common/debug.h"
+
+#define dout_subsys ceph_subsys_rocksdb
+#undef dout_prefix
+#define dout_prefix *_dout << "rocksdb: "
+
+class CephRocksdbLogger : public rocksdb::Logger {
+  CephContext *cct;
+public:
+  CephRocksdbLogger(CephContext *c) : cct(c) {
+    cct->get();
+  }
+  ~CephRocksdbLogger() {
+    cct->put();
+  }
+
+  // Write an entry to the log file with the specified format.
+  void Logv(const char* format, va_list ap) {
+    Logv(rocksdb::INFO_LEVEL, format, ap);
+  }
+
+  // Write an entry to the log file with the specified log level
+  // and format.  Any log with level under the internal log level
+  // of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be
+  // printed.
+  void Logv(const rocksdb::InfoLogLevel log_level, const char* format,
+	    va_list ap) {
+    int v = rocksdb::NUM_INFO_LOG_LEVELS - log_level - 1;
+    dout(v);
+    char buf[65536];
+    vsnprintf(buf, sizeof(buf), format, ap);
+    *_dout << buf << dendl;
+  }
+};
+
+rocksdb::Logger *create_rocksdb_ceph_logger()
+{
+  return new CephRocksdbLogger(g_ceph_context);
+}
+
 int string2bool(string val, bool &b_val)
 {
   if (strcasecmp(val.c_str(), "false") == 0) {
@@ -103,28 +144,28 @@ int RocksDBStore::init(string _options_str)
   options_str = _options_str;
   rocksdb::Options opt;
   //try parse options
-  int r = ParseOptionsFromString(options_str, opt); 
-  if (r != 0) {
-    return -EINVAL;
+  if (options_str.length()) {
+    int r = ParseOptionsFromString(options_str, opt);
+    if (r != 0) {
+      return -EINVAL;
+    }
   }
   return 0;
 }
 
 int RocksDBStore::create_and_open(ostream &out)
 {
-  // create tertiary paths
-  string wal_path = path + ".wal";
-  struct stat st;
-  int r = ::stat(wal_path.c_str(), &st);
-  if (r < 0)
-    r = -errno;
-  if (r == -ENOENT) {
-    unsigned slashoff = path.rfind('/');
-    string target = path.substr(slashoff + 1);
-    r = ::symlink(target.c_str(), wal_path.c_str());
-    if (r < 0) {
-      out << "failed to symlink " << wal_path << " to " << target;
-      return -errno;
+  if (env) {
+    unique_ptr<rocksdb::Directory> dir;
+    env->NewDirectory(path, &dir);
+  } else {
+    int r = ::mkdir(path.c_str(), 0755);
+    if (r < 0)
+      r = -errno;
+    if (r < 0 && r != -EEXIST) {
+      derr << __func__ << " failed to create " << path << ": " << cpp_strerror(r)
+	   << dendl;
+      return r;
     }
   }
   return do_open(out, true);
@@ -135,12 +176,47 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
   rocksdb::Options opt;
   rocksdb::Status status;
 
-  int r = ParseOptionsFromString(options_str, opt); 
-  if (r != 0) {
-    return -EINVAL;
+  if (options_str.length()) {
+    int r = ParseOptionsFromString(options_str, opt);
+    if (r != 0) {
+      return -EINVAL;
+    }
   }
   opt.create_if_missing = create_if_missing;
-  opt.wal_dir = path + ".wal";
+  if (g_conf->rocksdb_separate_wal_dir) {
+    opt.wal_dir = path + ".wal";
+  }
+  if (g_conf->rocksdb_db_paths.length()) {
+    list<string> paths;
+    get_str_list(g_conf->rocksdb_db_paths, "; \t", paths);
+    for (auto& p : paths) {
+      size_t pos = p.find(',');
+      if (pos == std::string::npos) {
+	derr << __func__ << " invalid db path item " << p << " in "
+	     << g_conf->rocksdb_db_paths << dendl;
+	return -EINVAL;
+      }
+      string path = p.substr(0, pos);
+      string size_str = p.substr(pos + 1);
+      uint64_t size = atoll(size_str.c_str());
+      if (!size) {
+	derr << __func__ << " invalid db path item " << p << " in "
+	     << g_conf->rocksdb_db_paths << dendl;
+	return -EINVAL;
+      }
+      opt.db_paths.push_back(rocksdb::DbPath(path, size));
+      dout(10) << __func__ << " db_path " << path << " size " << size << dendl;
+    }
+  }
+
+  if (g_conf->rocksdb_log_to_ceph_log) {
+    opt.info_log.reset(new CephRocksdbLogger(g_ceph_context));
+  }
+
+  if (priv) {
+    dout(10) << __func__ << " using custom Env " << priv << dendl;
+    opt.env = static_cast<rocksdb::Env*>(priv);
+  }
 
   status = rocksdb::DB::Open(opt, path, &db);
   if (!status.ok()) {
@@ -186,6 +262,10 @@ RocksDBStore::~RocksDBStore()
 
   // Ensure db is destroyed before dependent db_cache and filterpolicy
   delete db;
+
+  if (priv) {
+    delete static_cast<rocksdb::Env*>(priv);
+  }
 }
 
 void RocksDBStore::close()
@@ -322,12 +402,13 @@ int RocksDBStore::get(
     const string &key,
     bufferlist *out)
 {
+  assert(out && (out->length() == 0));
   utime_t start = ceph_clock_now(g_ceph_context);
   int r = 0;
   KeyValueDB::Iterator it = get_iterator(prefix);
   it->lower_bound(key);
   if (it->valid() && it->key() == key) {
-    *out = it->value();
+    out->append(it->value_as_ptr());
   } else {
     r = -ENOENT;
   }
@@ -434,7 +515,7 @@ void RocksDBStore::compact_range_async(const string& start, const string& end)
   }
   compact_queue_cond.Signal();
   if (!compact_thread.is_started()) {
-    compact_thread.create();
+    compact_thread.create("rstore_commpact");
   }
 }
 bool RocksDBStore::check_omap_dir(string &omap_dir)
@@ -545,6 +626,13 @@ bufferlist RocksDBStore::RocksDBWholeSpaceIteratorImpl::value()
 {
   return to_bufferlist(dbiter->value());
 }
+
+bufferptr RocksDBStore::RocksDBWholeSpaceIteratorImpl::value_as_ptr()
+{
+  rocksdb::Slice val = dbiter->value();
+  return bufferptr(val.data(), val.size());
+}
+
 int RocksDBStore::RocksDBWholeSpaceIteratorImpl::status()
 {
   return dbiter->status().ok() ? 0 : -1;
@@ -557,7 +645,6 @@ string RocksDBStore::past_prefix(const string &prefix)
   return limit;
 }
 
-
 RocksDBStore::WholeSpaceIterator RocksDBStore::_get_iterator()
 {
   return std::shared_ptr<KeyValueDB::WholeSpaceIteratorImpl>(
diff --git a/src/kv/RocksDBStore.h b/src/kv/RocksDBStore.h
index eb2f157..d2caf8a 100644
--- a/src/kv/RocksDBStore.h
+++ b/src/kv/RocksDBStore.h
@@ -38,14 +38,19 @@ enum {
 
 namespace rocksdb{
   class DB;
+  class Env;
   class Cache;
   class FilterPolicy;
   class Snapshot;
   class Slice;
   class WriteBatch;
   class Iterator;
+  class Logger;
   struct Options;
 }
+
+extern rocksdb::Logger *create_rocksdb_ceph_logger();
+
 /**
  * Uses RocksDB to implement the KeyValueDB interface
  */
@@ -53,7 +58,9 @@ class RocksDBStore : public KeyValueDB {
   CephContext *cct;
   PerfCounters *logger;
   string path;
+  void *priv;
   rocksdb::DB *db;
+  rocksdb::Env *env;
   string options_str;
   int do_open(ostream &out, bool create_if_missing);
 
@@ -104,11 +111,13 @@ public:
   }
   int get_info_log_level(string info_log_level);
 
-  RocksDBStore(CephContext *c, const string &path) :
+  RocksDBStore(CephContext *c, const string &path, void *p) :
     cct(c),
     logger(NULL),
     path(path),
+    priv(p),
     db(NULL),
+    env(static_cast<rocksdb::Env*>(p)),
     compact_queue_lock("RocksDBStore::compact_thread_lock"),
     compact_queue_stop(false),
     compact_thread(this),
@@ -188,6 +197,7 @@ public:
     pair<string,string> raw_key();
     bool raw_key_is_prefixed(const string &prefix);
     bufferlist value();
+    bufferptr value_as_ptr();
     int status();
   };
 
diff --git a/src/libcephfs.cc b/src/libcephfs.cc
index 849b1c0..c5bb2d4 100644
--- a/src/libcephfs.cc
+++ b/src/libcephfs.cc
@@ -19,7 +19,7 @@
 
 #include "auth/Crypto.h"
 #include "client/Client.h"
-#include "include/cephfs/libcephfs.h"
+#include "librados/RadosClient.h"
 #include "common/Mutex.h"
 #include "common/ceph_argparse.h"
 #include "common/common_init.h"
@@ -31,6 +31,9 @@
 #include "msg/Messenger.h"
 #include "include/assert.h"
 
+#include "include/cephfs/libcephfs.h"
+
+
 struct ceph_mount_info
 {
 public:
@@ -292,6 +295,15 @@ extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephCon
   return 0;
 }
 
+extern "C" int ceph_create_from_rados(struct ceph_mount_info **cmount,
+    rados_t cluster)
+{
+  auto rados = (librados::RadosClient *) cluster;
+  auto cct = rados->cct;
+  cct->get();
+  return ceph_create_with_context(cmount, cct);
+}
+
 extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id)
 {
   CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
@@ -1528,8 +1540,8 @@ extern "C" int ceph_ll_opendir(class ceph_mount_info *cmount,
 			       struct ceph_dir_result **dirpp,
 			       int uid, int gid)
 {
-  return (cmount->get_client()->ll_opendir(in, (dir_result_t**) dirpp, uid,
-					   gid));
+  return (cmount->get_client()->ll_opendir(in, O_RDONLY, (dir_result_t**) dirpp,
+					   uid, gid));
 }
 
 extern "C" int ceph_ll_releasedir(class ceph_mount_info *cmount,
diff --git a/src/librados-config.cc b/src/librados-config.cc
index 210c14d..83f9704 100644
--- a/src/librados-config.cc
+++ b/src/librados-config.cc
@@ -42,14 +42,9 @@ int main(int argc, const char **argv)
   bool opt_version = false;
   bool opt_vernum = false;
 
-  try {
-    global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
-		CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-    common_init_finish(g_ceph_context);
-  } catch (ceph::FailedAssertion &a) {
-    cout << "ceph::FailedAssertion thrown, exit." << std::endl;
-    exit(1);
-  }
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
+	      CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+  common_init_finish(g_ceph_context);
   for (std::vector<const char*>::iterator i = args.begin();
        i != args.end(); ) {
     if (strcmp(*i, "--") == 0) {
diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc
index 3e68212..24eda4f 100644
--- a/src/librados/IoCtxImpl.cc
+++ b/src/librados/IoCtxImpl.cc
@@ -20,6 +20,7 @@
 #include "librados/PoolAsyncCompletionImpl.h"
 #include "librados/RadosClient.h"
 #include "include/assert.h"
+#include "common/valgrind.h"
 
 #define dout_subsys ceph_subsys_rados
 #undef dout_prefix
@@ -348,7 +349,6 @@ int librados::IoCtxImpl::selfmanaged_snap_rollback_object(const object_t& oid,
 							  ::SnapContext& snapc,
 							  uint64_t snapid)
 {
-  utime_t ut = ceph_clock_now(client->cct);
   int reply;
 
   Mutex mylock("IoCtxImpl::snap_rollback::mylock");
@@ -360,8 +360,8 @@ int librados::IoCtxImpl::selfmanaged_snap_rollback_object(const object_t& oid,
   prepare_assert_ops(&op);
   op.rollback(snapid);
   objecter->mutate(oid, oloc,
-	           op, snapc, ut, 0,
-	           onack, NULL, NULL);
+		   op, snapc, ceph::real_clock::now(client->cct), 0,
+		   onack, NULL, NULL);
 
   mylock.Lock();
   while (!done) cond.Wait(mylock);
@@ -605,12 +605,10 @@ int librados::IoCtxImpl::clone_range(const object_t& dst_oid,
 int librados::IoCtxImpl::operate(const object_t& oid, ::ObjectOperation *o,
 				 time_t *pmtime, int flags)
 {
-  utime_t ut;
-  if (pmtime) {
-    ut = utime_t(*pmtime, 0);
-  } else {
-    ut = ceph_clock_now(client->cct);
-  }
+  ceph::real_time ut =
+    pmtime ?
+    ceph::real_clock::from_time_t(*pmtime) :
+    ceph::real_clock::now(client->cct);
 
   /* can't write to a snapshot */
   if (snap_seq != CEPH_NOSNAP)
@@ -630,8 +628,8 @@ int librados::IoCtxImpl::operate(const object_t& oid, ::ObjectOperation *o,
   int op = o->ops[0].op.op;
   ldout(client->cct, 10) << ceph_osd_op_name(op) << " oid=" << oid << " nspace=" << oloc.nspace << dendl;
   Objecter::Op *objecter_op = objecter->prepare_mutate_op(oid, oloc,
-	                                                  *o, snapc, ut, flags,
-	                                                  NULL, oncommit, &ver);
+							  *o, snapc, ut, flags,
+							  NULL, oncommit, &ver);
   objecter->op_submit(objecter_op);
 
   mylock.Lock();
@@ -703,7 +701,7 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid,
 				     ::ObjectOperation *o, AioCompletionImpl *c,
 				     const SnapContext& snap_context, int flags)
 {
-  utime_t ut = ceph_clock_now(client->cct);
+  auto ut = ceph::real_clock::now(client->cct);
   /* can't write to a snapshot */
   if (snap_seq != CEPH_NOSNAP)
     return -EROFS;
@@ -714,8 +712,8 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid,
   c->io = this;
   queue_aio_write(c);
 
-  c->tid = objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack, oncommit,
-		            &c->objver);
+  c->tid = objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack,
+			    oncommit, &c->objver);
 
   return 0;
 }
@@ -799,7 +797,7 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c,
 				   const bufferlist& bl, size_t len,
 				   uint64_t off)
 {
-  utime_t ut = ceph_clock_now(client->cct);
+  auto ut = ceph::real_clock::now(client->cct);
   ldout(client->cct, 20) << "aio_write " << oid << " " << off << "~" << len << " snapc=" << snapc << " snap_seq=" << snap_seq << dendl;
 
   if (len > UINT_MAX/2)
@@ -824,7 +822,7 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c,
 int librados::IoCtxImpl::aio_append(const object_t &oid, AioCompletionImpl *c,
 				    const bufferlist& bl, size_t len)
 {
-  utime_t ut = ceph_clock_now(client->cct);
+  auto ut = ceph::real_clock::now(client->cct);
 
   if (len > UINT_MAX/2)
     return -E2BIG;
@@ -849,7 +847,7 @@ int librados::IoCtxImpl::aio_write_full(const object_t &oid,
 					AioCompletionImpl *c,
 					const bufferlist& bl)
 {
-  utime_t ut = ceph_clock_now(client->cct);
+  auto ut = ceph::real_clock::now(client->cct);
 
   if (bl.length() > UINT_MAX/2)
     return -E2BIG;
@@ -872,7 +870,7 @@ int librados::IoCtxImpl::aio_write_full(const object_t &oid,
 
 int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c)
 {
-  utime_t ut = ceph_clock_now(client->cct);
+  auto ut = ceph::real_clock::now(client->cct);
 
   /* can't write to a snapshot */
   if (snap_seq != CEPH_NOSNAP)
@@ -899,8 +897,8 @@ int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c,
 
   c->io = this;
   c->tid = objecter->stat(oid, oloc,
-		 snap_seq, psize, &onack->mtime, 0,
-		 onack, &c->objver);
+			  snap_seq, psize, &onack->mtime, 0,
+			  onack, &c->objver);
 
   return 0;
 }
@@ -934,7 +932,7 @@ int librados::IoCtxImpl::hit_set_get(uint32_t hash, AioCompletionImpl *c,
   c->io = this;
 
   ::ObjectOperation rd;
-  rd.hit_set_get(utime_t(stamp, 0), pbl, 0);
+  rd.hit_set_get(ceph::real_clock::from_time_t(stamp), pbl, 0);
   object_locator_t oloc(poolid);
   c->tid = objecter->pg_read(hash, oloc, rd, NULL, 0, onack, NULL, NULL);
   return 0;
@@ -948,6 +946,14 @@ int librados::IoCtxImpl::remove(const object_t& oid)
   return operate(oid, &op, NULL);
 }
 
+int librados::IoCtxImpl::remove(const object_t& oid, int flags)
+{
+  ::ObjectOperation op;
+  prepare_assert_ops(&op);
+  op.remove();
+  return operate(oid, &op, NULL, flags);
+}
+
 int librados::IoCtxImpl::trunc(const object_t& oid, uint64_t size)
 {
   ::ObjectOperation op;
@@ -1089,7 +1095,7 @@ int librados::IoCtxImpl::sparse_read(const object_t& oid,
 int librados::IoCtxImpl::stat(const object_t& oid, uint64_t *psize, time_t *pmtime)
 {
   uint64_t size;
-  utime_t mtime;
+  real_time mtime;
 
   if (!psize)
     psize = &size;
@@ -1100,7 +1106,7 @@ int librados::IoCtxImpl::stat(const object_t& oid, uint64_t *psize, time_t *pmti
   int r = operate_read(oid, &rd, NULL);
 
   if (r >= 0 && pmtime) {
-    *pmtime = mtime.sec();
+    *pmtime = real_clock::to_time_t(mtime);
   }
 
   return r;
@@ -1159,6 +1165,8 @@ int librados::IoCtxImpl::getxattrs(const object_t& oid,
 
 void librados::IoCtxImpl::set_sync_op_version(version_t ver)
 {
+  ANNOTATE_BENIGN_RACE_SIZED(&last_objver, sizeof(last_objver),
+                             "IoCtxImpl last_objver");
   last_objver = ver;
 }
 
@@ -1224,7 +1232,7 @@ int librados::IoCtxImpl::watch(const object_t& oid,
   wr.watch(*handle, CEPH_OSD_WATCH_OP_WATCH);
   bufferlist bl;
   objecter->linger_watch(linger_op, wr,
-			 snapc, ceph_clock_now(NULL), bl,
+			 snapc, ceph::real_clock::now(), bl,
 			 &onfinish,
 			 &objver);
 
@@ -1271,7 +1279,8 @@ int librados::IoCtxImpl::unwatch(uint64_t cookie)
   prepare_assert_ops(&wr);
   wr.watch(cookie, CEPH_OSD_WATCH_OP_UNWATCH);
   objecter->mutate(linger_op->target.base_oid, oloc, wr,
-		   snapc, ceph_clock_now(client->cct), 0, NULL, &onfinish, &ver);
+		   snapc, ceph::real_clock::now(client->cct), 0, NULL,
+		   &onfinish, &ver);
   objecter->linger_cancel(linger_op);
 
   int r = onfinish.wait();
@@ -1459,7 +1468,7 @@ void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r)
   c->cond.Signal();
 
   if (r >= 0 && pmtime) {
-    *pmtime = mtime.sec();
+    *pmtime = real_clock::to_time_t(mtime);
   }
 
   if (c->callback_complete) {
@@ -1494,3 +1503,44 @@ void librados::IoCtxImpl::C_aio_Safe::finish(int r)
 
   c->put_unlock();
 }
+
+void librados::IoCtxImpl::object_list_slice(
+  const hobject_t start,
+  const hobject_t finish,
+  const size_t n,
+  const size_t m,
+  hobject_t *split_start,
+  hobject_t *split_finish)
+{
+  if (start.is_max()) {
+    *split_start = hobject_t::get_max();
+    *split_finish = hobject_t::get_max();
+    return;
+  }
+
+  uint64_t start_hash = hobject_t::_reverse_bits(start.get_hash());
+  uint64_t finish_hash =
+    finish.is_max() ? 0x100000000 :
+    hobject_t::_reverse_bits(finish.get_hash());
+
+  uint64_t diff = finish_hash - start_hash;
+  uint64_t rev_start = start_hash + (diff * n / m);
+  uint64_t rev_finish = start_hash + (diff * (n + 1) / m);
+  if (n == 0) {
+    *split_start = start;
+  } else {
+    *split_start = hobject_t(
+      object_t(), string(), CEPH_NOSNAP,
+      hobject_t::_reverse_bits(rev_start), poolid, string());
+  }
+
+  if (n == m - 1)
+    *split_finish = finish;
+  else if (rev_finish >= 0x100000000)
+    *split_finish = hobject_t::get_max();
+  else
+    *split_finish = hobject_t(
+      object_t(), string(), CEPH_NOSNAP,
+      hobject_t::_reverse_bits(rev_finish), poolid, string());
+}
+
diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h
index b0a1b19..25166c0 100644
--- a/src/librados/IoCtxImpl.h
+++ b/src/librados/IoCtxImpl.h
@@ -115,6 +115,14 @@ struct librados::IoCtxImpl {
   uint32_t nlist_seek(Objecter::NListContext *context, uint32_t pos);
   int list(Objecter::ListContext *context, int max_entries);
   uint32_t list_seek(Objecter::ListContext *context, uint32_t pos);
+  void object_list_slice(
+    const hobject_t start,
+    const hobject_t finish,
+    const size_t n,
+    const size_t m,
+    hobject_t *split_start,
+    hobject_t *split_finish);
+
   int create(const object_t& oid, bool exclusive);
   int write(const object_t& oid, bufferlist& bl, size_t len, uint64_t off);
   int append(const object_t& oid, bufferlist& bl, size_t len);
@@ -127,6 +135,7 @@ struct librados::IoCtxImpl {
   int sparse_read(const object_t& oid, std::map<uint64_t,uint64_t>& m,
 		  bufferlist& bl, size_t len, uint64_t off);
   int remove(const object_t& oid);
+  int remove(const object_t& oid, int flags);
   int stat(const object_t& oid, uint64_t *psize, time_t *pmtime);
   int trunc(const object_t& oid, uint64_t size);
 
@@ -159,7 +168,7 @@ struct librados::IoCtxImpl {
   struct C_aio_stat_Ack : public Context {
     librados::AioCompletionImpl *c;
     time_t *pmtime;
-    utime_t mtime;
+    ceph::real_time mtime;
     C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm);
     void finish(int r);
   };
diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc
index 1acde03..09dd64a 100644
--- a/src/librados/RadosClient.cc
+++ b/src/librados/RadosClient.cc
@@ -256,7 +256,6 @@ int librados::RadosClient::connect()
 
   ldout(cct, 1) << "starting objecter" << dendl;
 
-  err = -ENOMEM;
   objecter = new (std::nothrow) Objecter(cct, messenger, &monclient,
 			  &finisher,
 			  cct->_conf->rados_mon_op_timeout,
@@ -409,6 +408,7 @@ bool librados::RadosClient::ms_dispatch(Message *m)
 {
   bool ret;
 
+  Mutex::Locker l(lock);
   if (state == DISCONNECTED) {
     ldout(cct, 10) << "disconnected, discarding " << *m << dendl;
     m->put();
@@ -435,12 +435,11 @@ void librados::RadosClient::ms_handle_remote_reset(Connection *con)
 
 bool librados::RadosClient::_dispatch(Message *m)
 {
+  assert(lock.is_locked());
   switch (m->get_type()) {
   // OSD
   case CEPH_MSG_OSD_MAP:
-    lock.Lock();
     cond.Signal();
-    lock.Unlock();
     m->put();
     break;
 
@@ -873,7 +872,7 @@ int librados::RadosClient::monitor_log(const string& level, rados_log_callback_t
 
 void librados::RadosClient::handle_log(MLog *m)
 {
-  Mutex::Locker l(lock);
+  assert(lock.is_locked());
   ldout(cct, 10) << __func__ << " version " << m->version << dendl;
 
   if (log_last_version < m->version) {
diff --git a/src/librados/librados.cc b/src/librados/librados.cc
index ab3486d..90a89c0 100644
--- a/src/librados/librados.cc
+++ b/src/librados/librados.cc
@@ -19,6 +19,7 @@
 #include "common/ceph_argparse.h"
 #include "common/common_init.h"
 #include "common/TracepointProvider.h"
+#include "common/hobject.h"
 #include "include/rados/librados.h"
 #include "include/rados/librados.hpp"
 #include "include/types.h"
@@ -168,7 +169,7 @@ void librados::ObjectOperation::assert_version(uint64_t ver)
 void librados::ObjectOperation::assert_exists()
 {
   ::ObjectOperation *o = (::ObjectOperation *)impl;
-  o->stat(NULL, (utime_t*)NULL, NULL);
+  o->stat(NULL, (ceph::real_time*) NULL, NULL);
 }
 
 void librados::ObjectOperation::exec(const char *cls, const char *method, bufferlist& inbl)
@@ -1169,6 +1170,12 @@ int librados::IoCtx::remove(const std::string& oid)
   return io_ctx_impl->remove(obj);
 }
 
+int librados::IoCtx::remove(const std::string& oid, int flags)
+{
+  object_t obj(oid);
+  return io_ctx_impl->remove(obj, flags); 
+}
+
 int librados::IoCtx::trunc(const std::string& oid, uint64_t size)
 {
   object_t obj(oid);
@@ -2143,6 +2150,27 @@ int librados::Rados::mon_command(string cmd, const bufferlist& inbl,
   return client->mon_command(cmdvec, inbl, outbl, outs);
 }
 
+int librados::Rados::osd_command(int osdid, std::string cmd, const bufferlist& inbl,
+                                 bufferlist *outbl, std::string *outs)
+{
+  vector<string> cmdvec;
+  cmdvec.push_back(cmd);
+  return client->osd_command(osdid, cmdvec, inbl, outbl, outs);
+}
+
+int librados::Rados::pg_command(const char *pgstr, std::string cmd, const bufferlist& inbl,
+                                bufferlist *outbl, std::string *outs)
+{
+  vector<string> cmdvec;
+  cmdvec.push_back(cmd);
+
+  pg_t pgid;
+  if (!pgid.parse(pgstr))
+    return -EINVAL;
+
+  return client->pg_command(pgid, cmdvec, inbl, outbl, outs);
+}
+
 int librados::Rados::ioctx_create(const char *name, IoCtx &io)
 {
   rados_ioctx_t p;
@@ -3583,6 +3611,112 @@ extern "C" int rados_exec(rados_ioctx_t io, const char *o, const char *cls, cons
   return ret;
 }
 
+extern "C" rados_object_list_cursor rados_object_list_begin(rados_ioctx_t io)
+{
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+
+  hobject_t *result = new hobject_t(ctx->objecter->enumerate_objects_begin());
+  return (rados_object_list_cursor)result;
+}
+
+extern "C" rados_object_list_cursor rados_object_list_end(rados_ioctx_t io)
+{
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+
+  hobject_t *result = new hobject_t(ctx->objecter->enumerate_objects_end());
+  return (rados_object_list_cursor)result;
+}
+
+extern "C" int rados_object_list_is_end(
+    rados_ioctx_t io, rados_object_list_cursor cur)
+{
+  hobject_t *hobj = (hobject_t*)cur;
+  return hobj->is_max();
+}
+
+extern "C" void rados_object_list_cursor_free(
+    rados_ioctx_t io, rados_object_list_cursor cur)
+{
+  hobject_t *hobj = (hobject_t*)cur;
+  delete hobj;
+}
+
+extern "C" int rados_object_list_cursor_cmp(
+    rados_ioctx_t io,
+    rados_object_list_cursor lhs_cur,
+    rados_object_list_cursor rhs_cur)
+{
+  hobject_t *lhs = (hobject_t*)lhs_cur;
+  hobject_t *rhs = (hobject_t*)rhs_cur;
+  return cmp_bitwise(*lhs, *rhs);
+}
+
+extern "C" int rados_object_list(rados_ioctx_t io,
+    const rados_object_list_cursor start,
+    const rados_object_list_cursor finish,
+    const size_t result_item_count,
+    rados_object_list_item *result_items,
+    rados_object_list_cursor *next)
+{
+  assert(next);
+
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+
+  // Zero out items so that they will be safe to free later
+  memset(result_items, 0, sizeof(rados_object_list_item) * result_item_count);
+
+  std::list<librados::ListObjectImpl> result;
+  hobject_t next_hash;
+
+  C_SaferCond cond;
+  ctx->objecter->enumerate_objects(
+      ctx->poolid,
+      ctx->oloc.nspace,
+      *((hobject_t*)start),
+      *((hobject_t*)finish),
+      result_item_count,
+      &result,
+      &next_hash,
+      &cond);
+
+  hobject_t *next_hobj = (hobject_t*)(*next);
+  assert(next_hobj);
+
+  int r = cond.wait();
+  if (r < 0) {
+    *next_hobj = hobject_t::get_max();
+    return r;
+  }
+
+  assert(result.size() <= result_item_count);  // Don't overflow!
+
+  int k = 0;
+  for (std::list<librados::ListObjectImpl>::iterator i = result.begin();
+       i != result.end(); ++i) {
+    rados_object_list_item &item = result_items[k++];
+    do_out_buffer(i->oid, &item.oid, &item.oid_length);
+    do_out_buffer(i->nspace, &item.nspace, &item.nspace_length);
+    do_out_buffer(i->locator, &item.locator, &item.locator_length);
+  }
+
+  *next_hobj = next_hash;
+
+  return result.size();
+}
+
+extern "C" void rados_object_list_free(
+    const size_t result_size,
+    rados_object_list_item *results)
+{
+  assert(results);
+
+  for (unsigned int i = 0; i < result_size; ++i) {
+    rados_buffer_free(results[i].oid);
+    rados_buffer_free(results[i].locator);
+    rados_buffer_free(results[i].nspace);
+  }
+}
+
 /* list objects */
 
 extern "C" int rados_nobjects_list_open(rados_ioctx_t io, rados_list_ctx_t *listh)
@@ -4331,7 +4465,7 @@ extern "C" void rados_write_op_assert_version(rados_write_op_t write_op, uint64_
 extern "C" void rados_write_op_assert_exists(rados_write_op_t write_op)
 {
   tracepoint(librados, rados_write_op_assert_exists_enter, write_op);
-  ((::ObjectOperation *)write_op)->stat(NULL, (utime_t *)NULL, NULL);
+  ((::ObjectOperation *)write_op)->stat(NULL, (ceph::real_time *)NULL, NULL);
   tracepoint(librados, rados_write_op_assert_exists_exit);
 }
 
@@ -4593,7 +4727,7 @@ extern "C" void rados_read_op_assert_version(rados_read_op_t read_op, uint64_t v
 extern "C" void rados_read_op_assert_exists(rados_read_op_t read_op)
 {
   tracepoint(librados, rados_read_op_assert_exists_enter, read_op);
-  ((::ObjectOperation *)read_op)->stat(NULL, (utime_t *)NULL, NULL);
+  ((::ObjectOperation *)read_op)->stat(NULL, (ceph::real_time *)NULL, NULL);
   tracepoint(librados, rados_read_op_assert_exists_exit);
 }
 
@@ -4975,3 +5109,154 @@ std::ostream& librados::operator<<(std::ostream& out, const librados::ListObject
   out << *(lop.impl);
   return out;
 }
+
+CEPH_RADOS_API void rados_object_list_slice(
+    rados_ioctx_t io,
+    const rados_object_list_cursor start,
+    const rados_object_list_cursor finish,
+    const size_t n,
+    const size_t m,
+    rados_object_list_cursor *split_start,
+    rados_object_list_cursor *split_finish)
+{
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+
+  assert(split_start);
+  assert(split_finish);
+  hobject_t *split_start_hobj = (hobject_t*)(*split_start);
+  hobject_t *split_finish_hobj = (hobject_t*)(*split_finish);
+  assert(split_start_hobj);
+  assert(split_finish_hobj);
+  hobject_t *start_hobj = (hobject_t*)(start);
+  hobject_t *finish_hobj = (hobject_t*)(finish);
+
+  ctx->object_list_slice(
+      *start_hobj,
+      *finish_hobj,
+      n,
+      m,
+      split_start_hobj,
+      split_finish_hobj);
+}
+
+librados::ObjectCursor::ObjectCursor()
+{
+  c_cursor = new hobject_t();
+}
+
+librados::ObjectCursor::~ObjectCursor()
+{
+  hobject_t *h = (hobject_t *)c_cursor;
+  delete h;
+}
+
+bool librados::ObjectCursor::operator<(const librados::ObjectCursor &rhs)
+{
+  const hobject_t lhs_hobj = (c_cursor == nullptr) ? hobject_t() : *((hobject_t*)c_cursor);
+  const hobject_t rhs_hobj = (rhs.c_cursor == nullptr) ? hobject_t() : *((hobject_t*)(rhs.c_cursor));
+  return cmp_bitwise(lhs_hobj, rhs_hobj) == -1;
+}
+
+librados::ObjectCursor::ObjectCursor(const librados::ObjectCursor &rhs)
+{
+  if (rhs.c_cursor != nullptr) {
+    hobject_t *h = (hobject_t*)rhs.c_cursor;
+    c_cursor = (rados_object_list_cursor)(new hobject_t(*h));
+  } else {
+    c_cursor = nullptr;
+  }
+}
+
+librados::ObjectCursor librados::IoCtx::object_list_begin()
+{
+  hobject_t *h = new hobject_t(io_ctx_impl->objecter->enumerate_objects_begin());
+  ObjectCursor oc;
+  oc.c_cursor = (rados_object_list_cursor)h;
+  return oc;
+}
+
+
+librados::ObjectCursor librados::IoCtx::object_list_end()
+{
+  hobject_t *h = new hobject_t(io_ctx_impl->objecter->enumerate_objects_end());
+  librados::ObjectCursor oc;
+  oc.c_cursor = (rados_object_list_cursor)h;
+  return oc;
+}
+
+
+void librados::ObjectCursor::set(rados_object_list_cursor c)
+{
+  delete (hobject_t*)c_cursor;
+  c_cursor = c;
+}
+
+bool librados::IoCtx::object_list_is_end(const ObjectCursor &oc)
+{
+  hobject_t *h = (hobject_t *)oc.c_cursor;
+  return h->is_max();
+}
+
+int librados::IoCtx::object_list(const ObjectCursor &start,
+                const ObjectCursor &finish,
+                const size_t result_item_count,
+                std::vector<ObjectItem> *result,
+                ObjectCursor *next)
+{
+  assert(result != nullptr);
+  assert(next != nullptr);
+  result->clear();
+
+  C_SaferCond cond;
+  hobject_t next_hash;
+  std::list<librados::ListObjectImpl> obj_result;
+  io_ctx_impl->objecter->enumerate_objects(
+      io_ctx_impl->poolid,
+      io_ctx_impl->oloc.nspace,
+      *((hobject_t*)start.c_cursor),
+      *((hobject_t*)finish.c_cursor),
+      result_item_count,
+      &obj_result,
+      &next_hash,
+      &cond);
+
+  int r = cond.wait();
+  if (r < 0) {
+    next->set((rados_object_list_cursor)(new hobject_t(hobject_t::get_max())));
+    return r;
+  }
+
+  next->set((rados_object_list_cursor)(new hobject_t(next_hash)));
+
+  for (std::list<librados::ListObjectImpl>::iterator i = obj_result.begin();
+       i != obj_result.end(); ++i) {
+    ObjectItem oi;
+    oi.oid = i->oid;
+    oi.nspace = i->nspace;
+    oi.locator = i->locator;
+    result->push_back(oi);
+  }
+
+  return obj_result.size();
+}
+
+void librados::IoCtx::object_list_slice(
+    const ObjectCursor start,
+    const ObjectCursor finish,
+    const size_t n,
+    const size_t m,
+    ObjectCursor *split_start,
+    ObjectCursor *split_finish)
+{
+  assert(split_start != nullptr);
+  assert(split_finish != nullptr);
+
+  io_ctx_impl->object_list_slice(
+      *((hobject_t*)(start.c_cursor)),
+      *((hobject_t*)(finish.c_cursor)),
+      n,
+      m,
+      (hobject_t*)(split_start->c_cursor),
+      (hobject_t*)(split_finish->c_cursor));
+}
+
diff --git a/src/libradosstriper/RadosStriperImpl.cc b/src/libradosstriper/RadosStriperImpl.cc
index 3544cac..e9b3bd5 100644
--- a/src/libradosstriper/RadosStriperImpl.cc
+++ b/src/libradosstriper/RadosStriperImpl.cc
@@ -550,7 +550,7 @@ int libradosstriper::RadosStriperImpl::stat(const std::string& soid, uint64_t *p
   return 0;
 }
 
-int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
+int libradosstriper::RadosStriperImpl::remove(const std::string& soid, int flags)
 {
   std::string firstObjOid = getObjectId(soid, 0);
   try {
@@ -591,11 +591,15 @@ int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
     // delete rados objects in reverse order
     int rcr = 0;
     for (int i = nb_objects-1; i >= 0; i--) {
-      rcr = m_ioCtx.remove(getObjectId(soid, i));
+      if (flags == 0) {
+        rcr = m_ioCtx.remove(getObjectId(soid, i));
+      } else {
+        rcr = m_ioCtx.remove(getObjectId(soid, i), flags);  
+      }
       if (rcr < 0 and -ENOENT != rcr) {
         lderr(cct()) << "RadosStriperImpl::remove : deletion incomplete for " << soid
-  		   << ", as " << getObjectId(soid, i) << " could not be deleted (rc=" << rc << ")"
-  		   << dendl;
+		     << ", as " << getObjectId(soid, i) << " could not be deleted (rc=" << rc << ")"
+		     << dendl;
         break;
       }
     }
@@ -605,6 +609,7 @@ int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
     // errror caught when trying to take the exclusive lock
     return e.m_code;
   }
+
 }
 
 int libradosstriper::RadosStriperImpl::trunc(const std::string& soid, uint64_t size)
diff --git a/src/libradosstriper/RadosStriperImpl.h b/src/libradosstriper/RadosStriperImpl.h
index 7862f05..c2bb8ba 100644
--- a/src/libradosstriper/RadosStriperImpl.h
+++ b/src/libradosstriper/RadosStriperImpl.h
@@ -187,7 +187,7 @@ struct libradosstriper::RadosStriperImpl {
 
   // stat, deletion and truncation
   int stat(const std::string& soid, uint64_t *psize, time_t *pmtime);
-  int remove(const std::string& soid);
+  int remove(const std::string& soid, int flags=0);
   int trunc(const std::string& soid, uint64_t size);
 
   // reference counting
diff --git a/src/libradosstriper/libradosstriper.cc b/src/libradosstriper/libradosstriper.cc
index 44079b5..969f2d8 100644
--- a/src/libradosstriper/libradosstriper.cc
+++ b/src/libradosstriper/libradosstriper.cc
@@ -273,6 +273,10 @@ int libradosstriper::RadosStriper::remove(const std::string& soid)
 {
   return rados_striper_impl->remove(soid);
 }
+int libradosstriper::RadosStriper::remove(const std::string& soid, int flags)
+{
+  return rados_striper_impl->remove(soid, flags); 
+}
 
 int libradosstriper::RadosStriper::trunc(const std::string& soid, uint64_t size)
 {
diff --git a/src/librbd/AioImageRequest.cc b/src/librbd/AioImageRequest.cc
index 104148b..cba7dde 100644
--- a/src/librbd/AioImageRequest.cc
+++ b/src/librbd/AioImageRequest.cc
@@ -10,7 +10,7 @@
 #include "librbd/ImageWatcher.h"
 #include "librbd/internal.h"
 #include "librbd/Journal.h"
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
 #include "include/rados/librados.hpp"
 #include "osdc/Striper.h"
 
@@ -77,39 +77,46 @@ struct C_FlushJournalCommit : public Context {
 
 } // anonymous namespace
 
-void AioImageRequest::aio_read(
-    ImageCtx *ictx, AioCompletion *c,
+template <typename I>
+void AioImageRequest<I>::aio_read(
+    I *ictx, AioCompletion *c,
     const std::vector<std::pair<uint64_t,uint64_t> > &extents,
     char *buf, bufferlist *pbl, int op_flags) {
   AioImageRead req(*ictx, c, extents, buf, pbl, op_flags);
   req.send();
 }
 
-void AioImageRequest::aio_read(ImageCtx *ictx, AioCompletion *c, uint64_t off,
-                               size_t len, char *buf, bufferlist *pbl,
-                               int op_flags) {
+template <typename I>
+void AioImageRequest<I>::aio_read(I *ictx, AioCompletion *c,
+                                  uint64_t off, size_t len, char *buf,
+                                  bufferlist *pbl, int op_flags) {
   AioImageRead req(*ictx, c, off, len, buf, pbl, op_flags);
   req.send();
 }
 
-void AioImageRequest::aio_write(ImageCtx *ictx, AioCompletion *c, uint64_t off,
-                                size_t len, const char *buf, int op_flags) {
+template <typename I>
+void AioImageRequest<I>::aio_write(I *ictx, AioCompletion *c,
+                                   uint64_t off, size_t len, const char *buf,
+                                   int op_flags) {
   AioImageWrite req(*ictx, c, off, len, buf, op_flags);
   req.send();
 }
 
-void AioImageRequest::aio_discard(ImageCtx *ictx, AioCompletion *c,
-                                  uint64_t off, uint64_t len) {
+template <typename I>
+void AioImageRequest<I>::aio_discard(I *ictx, AioCompletion *c,
+                                     uint64_t off, uint64_t len) {
   AioImageDiscard req(*ictx, c, off, len);
   req.send();
 }
 
-void AioImageRequest::aio_flush(ImageCtx *ictx, AioCompletion *c) {
+template <typename I>
+void AioImageRequest<I>::aio_flush(I *ictx, AioCompletion *c) {
   AioImageFlush req(*ictx, c);
   req.send();
 }
 
-void AioImageRequest::send() {
+template <typename I>
+void AioImageRequest<I>::send() {
   assert(m_image_ctx.owner_lock.is_locked());
 
   CephContext *cct = m_image_ctx.cct;
@@ -120,7 +127,8 @@ void AioImageRequest::send() {
   send_request();
 }
 
-void AioImageRequest::fail(int r) {
+template <typename I>
+void AioImageRequest<I>::fail(int r) {
   m_aio_comp->get();
   m_aio_comp->fail(m_image_ctx.cct, r);
 }
@@ -311,7 +319,8 @@ uint64_t AioImageWrite::append_journal_event(
   bl.append(m_buf, m_len);
 
   journal::EventEntry event_entry(journal::AioWriteEvent(m_off, m_len, bl));
-  uint64_t tid = m_image_ctx.journal->append_io_event(m_aio_comp, event_entry,
+  uint64_t tid = m_image_ctx.journal->append_io_event(m_aio_comp,
+                                                      std::move(event_entry),
                                                       requests, m_off, m_len,
                                                       synchronous);
   if (m_image_ctx.object_cacher == NULL) {
@@ -371,7 +380,8 @@ void AioImageWrite::update_stats(size_t length) {
 uint64_t AioImageDiscard::append_journal_event(
     const AioObjectRequests &requests, bool synchronous) {
   journal::EventEntry event_entry(journal::AioDiscardEvent(m_off, m_len));
-  uint64_t tid = m_image_ctx.journal->append_io_event(m_aio_comp, event_entry,
+  uint64_t tid = m_image_ctx.journal->append_io_event(m_aio_comp,
+                                                      std::move(event_entry),
                                                       requests, m_off, m_len,
                                                       synchronous);
   m_aio_comp->associate_journal_event(tid);
@@ -464,3 +474,5 @@ void AioImageFlush::send_request() {
 }
 
 } // namespace librbd
+
+template class librbd::AioImageRequest<librbd::ImageCtx>;
diff --git a/src/librbd/AioImageRequest.h b/src/librbd/AioImageRequest.h
index 6ee6d64..e8a3fd5 100644
--- a/src/librbd/AioImageRequest.h
+++ b/src/librbd/AioImageRequest.h
@@ -18,22 +18,23 @@ namespace librbd {
 class AioObjectRequest;
 class ImageCtx;
 
+template <typename ImageCtxT = ImageCtx>
 class AioImageRequest {
 public:
   typedef std::vector<std::pair<uint64_t,uint64_t> > Extents;
 
   virtual ~AioImageRequest() {}
 
-  static void aio_read(ImageCtx *ictx, AioCompletion *c,
+  static void aio_read(ImageCtxT *ictx, AioCompletion *c,
                        const std::vector<std::pair<uint64_t,uint64_t> > &extents,
                        char *buf, bufferlist *pbl, int op_flags);
-  static void aio_read(ImageCtx *ictx, AioCompletion *c, uint64_t off,
+  static void aio_read(ImageCtxT *ictx, AioCompletion *c, uint64_t off,
                        size_t len, char *buf, bufferlist *pbl, int op_flags);
-  static void aio_write(ImageCtx *ictx, AioCompletion *c, uint64_t off,
+  static void aio_write(ImageCtxT *ictx, AioCompletion *c, uint64_t off,
                         size_t len, const char *buf, int op_flags);
-  static void aio_discard(ImageCtx *ictx, AioCompletion *c, uint64_t off,
+  static void aio_discard(ImageCtxT *ictx, AioCompletion *c, uint64_t off,
                           uint64_t len);
-  static void aio_flush(ImageCtx *ictx, AioCompletion *c);
+  static void aio_flush(ImageCtxT *ictx, AioCompletion *c);
 
   virtual bool is_write_op() const {
     return false;
@@ -45,17 +46,17 @@ public:
 protected:
   typedef std::list<AioObjectRequest *> AioObjectRequests;
 
-  ImageCtx &m_image_ctx;
+  ImageCtxT &m_image_ctx;
   AioCompletion *m_aio_comp;
 
-  AioImageRequest(ImageCtx &image_ctx, AioCompletion *aio_comp)
+  AioImageRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp)
     : m_image_ctx(image_ctx), m_aio_comp(aio_comp) {}
 
   virtual void send_request() = 0;
   virtual const char *get_request_type() const = 0;
 };
 
-class AioImageRead : public AioImageRequest {
+class AioImageRead : public AioImageRequest<> {
 public:
   AioImageRead(ImageCtx &image_ctx, AioCompletion *aio_comp, uint64_t off,
                size_t len, char *buf, bufferlist *pbl, int op_flags)
@@ -83,7 +84,7 @@ private:
   int m_op_flags;
 };
 
-class AbstractAioImageWrite : public AioImageRequest {
+class AbstractAioImageWrite : public AioImageRequest<> {
 public:
   virtual bool is_write_op() const {
     return true;
@@ -194,7 +195,7 @@ protected:
   virtual void update_stats(size_t length);
 };
 
-class AioImageFlush : public AioImageRequest {
+class AioImageFlush : public AioImageRequest<> {
 public:
   AioImageFlush(ImageCtx &image_ctx, AioCompletion *aio_comp)
     : AioImageRequest(image_ctx, aio_comp) {
@@ -213,4 +214,6 @@ protected:
 
 } // namespace librbd
 
+extern template class librbd::AioImageRequest<librbd::ImageCtx>;
+
 #endif // CEPH_LIBRBD_AIO_IMAGE_REQUEST_H
diff --git a/src/librbd/AioImageRequestWQ.cc b/src/librbd/AioImageRequestWQ.cc
index 9871bb0..2de18d3 100644
--- a/src/librbd/AioImageRequestWQ.cc
+++ b/src/librbd/AioImageRequestWQ.cc
@@ -19,7 +19,7 @@ namespace librbd {
 
 AioImageRequestWQ::AioImageRequestWQ(ImageCtx *image_ctx, const string &name,
                                      time_t ti, ThreadPool *tp)
-  : ThreadPool::PointerWQ<AioImageRequest>(name, ti, 0, tp),
+  : ThreadPool::PointerWQ<AioImageRequest<> >(name, ti, 0, tp),
     m_image_ctx(*image_ctx),
     m_lock(util::unique_lock_name("AioImageRequestWQ::m_lock", this)),
     m_write_blockers(0), m_in_progress_writes(0), m_queued_writes(0),
@@ -27,6 +27,7 @@ AioImageRequestWQ::AioImageRequestWQ(ImageCtx *image_ctx, const string &name,
     m_shutdown(false), m_on_shutdown(nullptr) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 5) << this << " " << ": ictx=" << image_ctx << dendl;
+  tp->add_work_queue(this);
 }
 
 ssize_t AioImageRequestWQ::read(uint64_t off, uint64_t len, char *buf,
@@ -54,6 +55,7 @@ ssize_t AioImageRequestWQ::write(uint64_t off, uint64_t len, const char *buf,
   int r = clip_io(&m_image_ctx, off, &len);
   m_image_ctx.snap_lock.put_read();
   if (r < 0) {
+    lderr(cct) << "invalid IO request: " << cpp_strerror(r) << dendl;
     return r;
   }
 
@@ -77,6 +79,7 @@ int AioImageRequestWQ::discard(uint64_t off, uint64_t len) {
   int r = clip_io(&m_image_ctx, off, &len);
   m_image_ctx.snap_lock.put_read();
   if (r < 0) {
+    lderr(cct) << "invalid IO request: " << cpp_strerror(r) << dendl;
     return r;
   }
 
@@ -112,7 +115,7 @@ void AioImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len,
   if (m_image_ctx.non_blocking_aio || writes_blocked() || !writes_empty()) {
     queue(new AioImageRead(m_image_ctx, c, off, len, buf, pbl, op_flags));
   } else {
-    AioImageRequest::aio_read(&m_image_ctx, c, off, len, buf, pbl, op_flags);
+    AioImageRequest<>::aio_read(&m_image_ctx, c, off, len, buf, pbl, op_flags);
     finish_in_flight_op();
   }
 }
@@ -139,7 +142,7 @@ void AioImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len,
       writes_blocked()) {
     queue(new AioImageWrite(m_image_ctx, c, off, len, buf, op_flags));
   } else {
-    AioImageRequest::aio_write(&m_image_ctx, c, off, len, buf, op_flags);
+    AioImageRequest<>::aio_write(&m_image_ctx, c, off, len, buf, op_flags);
     finish_in_flight_op();
   }
 }
@@ -165,7 +168,7 @@ void AioImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off,
       writes_blocked()) {
     queue(new AioImageDiscard(m_image_ctx, c, off, len));
   } else {
-    AioImageRequest::aio_discard(&m_image_ctx, c, off, len);
+    AioImageRequest<>::aio_discard(&m_image_ctx, c, off, len);
     finish_in_flight_op();
   }
 }
@@ -189,7 +192,7 @@ void AioImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) {
       writes_blocked() || !writes_empty()) {
     queue(new AioImageFlush(m_image_ctx, c));
   } else {
-    AioImageRequest::aio_flush(&m_image_ctx, c);
+    AioImageRequest<>::aio_flush(&m_image_ctx, c);
     finish_in_flight_op();
   }
 }
@@ -262,7 +265,7 @@ void AioImageRequestWQ::unblock_writes() {
 }
 
 void *AioImageRequestWQ::_void_dequeue() {
-  AioImageRequest *peek_item = front();
+  AioImageRequest<> *peek_item = front();
   if (peek_item == NULL || m_refresh_in_progress) {
     return NULL;
   }
@@ -275,8 +278,8 @@ void *AioImageRequestWQ::_void_dequeue() {
     m_in_progress_writes.inc();
   }
 
-  AioImageRequest *item = reinterpret_cast<AioImageRequest *>(
-    ThreadPool::PointerWQ<AioImageRequest>::_void_dequeue());
+  AioImageRequest<> *item = reinterpret_cast<AioImageRequest<> *>(
+    ThreadPool::PointerWQ<AioImageRequest<> >::_void_dequeue());
   assert(peek_item == item);
 
   if (m_image_ctx.state->is_refresh_required()) {
@@ -292,7 +295,7 @@ void *AioImageRequestWQ::_void_dequeue() {
   return item;
 }
 
-void AioImageRequestWQ::process(AioImageRequest *req) {
+void AioImageRequestWQ::process(AioImageRequest<> *req) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << __func__ << ": ictx=" << &m_image_ctx << ", "
                  << "req=" << req << dendl;
@@ -373,7 +376,7 @@ bool AioImageRequestWQ::is_lock_required() const {
   return (!m_image_ctx.exclusive_lock->is_lock_owner());
 }
 
-void AioImageRequestWQ::queue(AioImageRequest *req) {
+void AioImageRequestWQ::queue(AioImageRequest<> *req) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << __func__ << ": ictx=" << &m_image_ctx << ", "
                  << "req=" << req << dendl;
@@ -384,14 +387,14 @@ void AioImageRequestWQ::queue(AioImageRequest *req) {
     m_queued_writes.inc();
   }
 
-  ThreadPool::PointerWQ<AioImageRequest>::queue(req);
+  ThreadPool::PointerWQ<AioImageRequest<> >::queue(req);
 
   if (write_op && is_lock_required()) {
     m_image_ctx.exclusive_lock->request_lock(nullptr);
   }
 }
 
-void AioImageRequestWQ::handle_refreshed(int r, AioImageRequest *req) {
+void AioImageRequestWQ::handle_refreshed(int r, AioImageRequest<> *req) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 15) << "resuming IO after image refresh: r=" << r << ", "
                  << "req=" << req << dendl;
diff --git a/src/librbd/AioImageRequestWQ.h b/src/librbd/AioImageRequestWQ.h
index c845489..1573e72 100644
--- a/src/librbd/AioImageRequestWQ.h
+++ b/src/librbd/AioImageRequestWQ.h
@@ -14,10 +14,10 @@
 namespace librbd {
 
 class AioCompletion;
-class AioImageRequest;
+template <typename> class AioImageRequest;
 class ImageCtx;
 
-class AioImageRequestWQ : protected ThreadPool::PointerWQ<AioImageRequest> {
+class AioImageRequestWQ : protected ThreadPool::PointerWQ<AioImageRequest<ImageCtx> > {
 public:
   AioImageRequestWQ(ImageCtx *image_ctx, const string &name, time_t ti,
                     ThreadPool *tp);
@@ -30,11 +30,12 @@ public:
                 bufferlist *pbl, int op_flags, bool native_async=true);
   void aio_write(AioCompletion *c, uint64_t off, uint64_t len, const char *buf,
                  int op_flags, bool native_async=true);
-  void aio_discard(AioCompletion *c, uint64_t off, uint64_t len, bool native_async=true);
+  void aio_discard(AioCompletion *c, uint64_t off, uint64_t len,
+                   bool native_async=true);
   void aio_flush(AioCompletion *c, bool native_async=true);
 
-  using ThreadPool::PointerWQ<AioImageRequest>::drain;
-  using ThreadPool::PointerWQ<AioImageRequest>::empty;
+  using typename ThreadPool::PointerWQ<AioImageRequest<ImageCtx> >::drain;
+  using typename ThreadPool::PointerWQ<AioImageRequest<ImageCtx> >::empty;
 
   inline bool writes_empty() const {
     RWLock::RLocker locker(m_lock);
@@ -54,17 +55,17 @@ public:
 
 protected:
   virtual void *_void_dequeue();
-  virtual void process(AioImageRequest *req);
+  virtual void process(AioImageRequest<ImageCtx> *req);
 
 private:
   typedef std::list<Context *> Contexts;
 
   struct C_RefreshFinish : public Context {
     AioImageRequestWQ *aio_work_queue;
-    AioImageRequest *aio_image_request;
+    AioImageRequest<ImageCtx> *aio_image_request;
 
     C_RefreshFinish(AioImageRequestWQ *aio_work_queue,
-                    AioImageRequest *aio_image_request)
+                    AioImageRequest<ImageCtx> *aio_image_request)
       : aio_work_queue(aio_work_queue), aio_image_request(aio_image_request) {
     }
     virtual void finish(int r) override {
@@ -101,9 +102,9 @@ private:
 
   bool is_journal_required() const;
   bool is_lock_required() const;
-  void queue(AioImageRequest *req);
+  void queue(AioImageRequest<ImageCtx> *req);
 
-  void handle_refreshed(int r, AioImageRequest *req);
+  void handle_refreshed(int r, AioImageRequest<ImageCtx> *req);
   void handle_blocked_writes(int r);
 };
 
diff --git a/src/librbd/AioObjectRequest.cc b/src/librbd/AioObjectRequest.cc
index 34a1c11..96669ea 100644
--- a/src/librbd/AioObjectRequest.cc
+++ b/src/librbd/AioObjectRequest.cc
@@ -281,8 +281,8 @@ namespace librbd {
 			   << " extents " << parent_extents
 			   << dendl;
     RWLock::RLocker owner_locker(m_ictx->parent->owner_lock);
-    AioImageRequest::aio_read(m_ictx->parent, m_parent_completion,
-                              parent_extents, NULL, &m_read_data, 0);
+    AioImageRequest<>::aio_read(m_ictx->parent, m_parent_completion,
+                                parent_extents, NULL, &m_read_data, 0);
   }
 
   /** write **/
diff --git a/src/librbd/AsyncRequest.h b/src/librbd/AsyncRequest.h
index 96802f8..8ca84f5 100644
--- a/src/librbd/AsyncRequest.h
+++ b/src/librbd/AsyncRequest.h
@@ -24,8 +24,6 @@ public:
     if (should_complete(r)) {
       r = filter_return_code(r);
       finish(r);
-      finish_request();
-      m_on_finish->complete(r);
       delete this;
     }
   }
@@ -41,7 +39,6 @@ public:
 
 protected:
   ImageCtxT &m_image_ctx;
-  Context *m_on_finish;
 
   librados::AioCompletion *create_callback_completion();
   Context *create_callback_context();
@@ -55,8 +52,12 @@ protected:
   }
 
   virtual void finish(int r) {
+    finish_request();
+    m_on_finish->complete(r);
   }
+
 private:
+  Context *m_on_finish;
   bool m_canceled;
   typename xlist<AsyncRequest<ImageCtxT> *>::item m_xlist_item;
 
diff --git a/src/librbd/CopyupRequest.cc b/src/librbd/CopyupRequest.cc
index d7713ad..29d8a4a 100644
--- a/src/librbd/CopyupRequest.cc
+++ b/src/librbd/CopyupRequest.cc
@@ -191,8 +191,8 @@ private:
                            << ", extents " << m_image_extents
                            << dendl;
     RWLock::RLocker owner_locker(m_ictx->parent->owner_lock);
-    AioImageRequest::aio_read(m_ictx->parent, comp, m_image_extents, NULL,
-                              &m_copyup_data, 0);
+    AioImageRequest<>::aio_read(m_ictx->parent, comp, m_image_extents, NULL,
+                                &m_copyup_data, 0);
   }
 
   void CopyupRequest::complete(int r)
diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc
index fd362ef..cef72cc 100644
--- a/src/librbd/ExclusiveLock.cc
+++ b/src/librbd/ExclusiveLock.cc
@@ -339,8 +339,8 @@ void ExclusiveLock<I>::send_acquire_lock() {
 
 template <typename I>
 void ExclusiveLock<I>::handle_acquiring_lock(int r) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 10) << this << " " << __func__ << dendl;
+  Mutex::Locker locker(m_lock);
+  ldout(m_image_ctx.cct, 10) << this << " " << __func__ << dendl;
 
   assert(r == 0);
   assert(m_state == STATE_ACQUIRING);
diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc
index 154c15a..e432d63 100644
--- a/src/librbd/ImageCtx.cc
+++ b/src/librbd/ImageCtx.cc
@@ -21,6 +21,7 @@
 #include "librbd/Journal.h"
 #include "librbd/LibrbdAdminSocketHook.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/Operations.h"
 #include "librbd/operation/ResizeRequest.h"
 #include "librbd/Utils.h"
 
@@ -47,7 +48,7 @@ namespace {
 class ThreadPoolSingleton : public ThreadPool {
 public:
   ThreadPoolSingleton(CephContext *cct)
-    : ThreadPool(cct, "librbd::thread_pool", cct->_conf->rbd_op_threads,
+    : ThreadPool(cct, "librbd::thread_pool", "tp_librbd", cct->_conf->rbd_op_threads,
                  "rbd_op_threads") {
     start();
   }
@@ -162,15 +163,19 @@ struct C_InvalidateCache : public Context {
       object_cacher(NULL), writeback_handler(NULL), object_set(NULL),
       readahead(),
       total_bytes_read(0),
-      state(new ImageState<>(this)), exclusive_lock(nullptr),
-      object_map(nullptr), aio_work_queue(NULL), op_work_queue(NULL),
-      asok_hook(new LibrbdAdminSocketHook(this))
+      state(new ImageState<>(this)),
+      operations(new Operations<>(*this)),
+      exclusive_lock(nullptr), object_map(nullptr),
+      aio_work_queue(nullptr), op_work_queue(nullptr),
+      asok_hook(nullptr)
   {
     md_ctx.dup(p);
     data_ctx.dup(p);
     if (snap)
       snap_name = snap;
 
+    asok_hook = new LibrbdAdminSocketHook(this);
+
     memset(&header, 0, sizeof(header));
     memset(&layout, 0, sizeof(layout));
 
@@ -216,6 +221,7 @@ struct C_InvalidateCache : public Context {
     delete op_work_queue;
     delete aio_work_queue;
     delete asok_hook;
+    delete operations;
     delete state;
   }
 
@@ -671,10 +677,8 @@ struct C_InvalidateCache : public Context {
 				uint64_t off, Context *onfinish,
 				int fadvise_flags, uint64_t journal_tid) {
     snap_lock.get_read();
-    ObjectCacher::OSDWrite *wr = object_cacher->prepare_write(snapc, bl,
-							      utime_t(),
-                                                              fadvise_flags,
-                                                              journal_tid);
+    ObjectCacher::OSDWrite *wr = object_cacher->prepare_write(
+      snapc, bl, ceph::real_time::min(), fadvise_flags, journal_tid);
     snap_lock.put_read();
     ObjectExtent extent(o, 0, off, len, 0);
     extent.oloc.pool = data_ctx.get_id();
@@ -1005,7 +1009,7 @@ struct C_InvalidateCache : public Context {
     return new ObjectMap(*this, snap_id);
   }
 
-  Journal *ImageCtx::create_journal() {
-    return new Journal(*this);
+  Journal<ImageCtx> *ImageCtx::create_journal() {
+    return new Journal<ImageCtx>(*this);
   }
 }
diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h
index 715fcbb..7606f6f 100644
--- a/src/librbd/ImageCtx.h
+++ b/src/librbd/ImageCtx.h
@@ -47,9 +47,10 @@ namespace librbd {
   template <typename> class ExclusiveLock;
   template <typename> class ImageState;
   class ImageWatcher;
-  class Journal;
+  template <typename> class Journal;
   class LibrbdAdminSocketHook;
   class ObjectMap;
+  template <typename> class Operations;
 
   namespace operation {
   template <typename> class ResizeRequest;
@@ -79,7 +80,7 @@ namespace librbd {
     std::string snap_name;
     IoCtx data_ctx, md_ctx;
     ImageWatcher *image_watcher;
-    Journal *journal;
+    Journal<ImageCtx> *journal;
 
     /**
      * Lock ordering:
@@ -137,11 +138,11 @@ namespace librbd {
     std::list<Context*> async_requests_waiters;
 
     ImageState<ImageCtx> *state;
+    Operations<ImageCtx> *operations;
+
     ExclusiveLock<ImageCtx> *exclusive_lock;
     ObjectMap *object_map;
 
-    atomic_t async_request_seq;
-
     xlist<operation::ResizeRequest<ImageCtx>*> resize_reqs;
 
     AioImageRequestWQ *aio_work_queue;
@@ -270,7 +271,7 @@ namespace librbd {
     void apply_metadata_confs();
 
     ObjectMap *create_object_map(uint64_t snap_id);
-    Journal *create_journal();
+    Journal<ImageCtx> *create_journal();
 
     void clear_pending_completions();
   };
diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc
index ea3dbe0..b97d502 100644
--- a/src/librbd/ImageWatcher.cc
+++ b/src/librbd/ImageWatcher.cc
@@ -7,6 +7,7 @@
 #include "librbd/ImageState.h"
 #include "librbd/internal.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/Operations.h"
 #include "librbd/TaskFinisher.h"
 #include "librbd/Utils.h"
 #include "include/encoding.h"
@@ -630,7 +631,7 @@ bool ImageWatcher::handle_payload(const FlattenPayload &payload,
     if (new_request) {
       ldout(m_image_ctx.cct, 10) << this << " remote flatten request: "
 				 << payload.async_request_id << dendl;
-      librbd::async_flatten(&m_image_ctx, ctx, *prog_ctx);
+      m_image_ctx.operations->flatten(*prog_ctx, ctx);
     }
 
     ::encode(ResponseMessage(r), ack_ctx->out);
@@ -652,7 +653,7 @@ bool ImageWatcher::handle_payload(const ResizePayload &payload,
       ldout(m_image_ctx.cct, 10) << this << " remote resize request: "
 				 << payload.async_request_id << " "
 				 << payload.size << dendl;
-      librbd::async_resize(&m_image_ctx, ctx, payload.size, *prog_ctx);
+      m_image_ctx.operations->resize(payload.size, *prog_ctx, ctx, 0);
     }
 
     ::encode(ResponseMessage(r), ack_ctx->out);
@@ -668,8 +669,8 @@ bool ImageWatcher::handle_payload(const SnapCreatePayload &payload,
     ldout(m_image_ctx.cct, 10) << this << " remote snap_create request: "
 			       << payload.snap_name << dendl;
 
-    librbd::snap_create_helper(&m_image_ctx, new C_ResponseMessage(ack_ctx),
-                               payload.snap_name.c_str());
+    m_image_ctx.operations->snap_create(payload.snap_name.c_str(),
+                                        new C_ResponseMessage(ack_ctx), 0);
     return false;
   }
   return true;
@@ -684,8 +685,9 @@ bool ImageWatcher::handle_payload(const SnapRenamePayload &payload,
 			       << payload.snap_id << " to "
 			       << payload.snap_name << dendl;
 
-    librbd::snap_rename_helper(&m_image_ctx, new C_ResponseMessage(ack_ctx),
-                               payload.snap_id, payload.snap_name.c_str());
+    m_image_ctx.operations->snap_rename(payload.snap_id,
+                                        payload.snap_name.c_str(),
+                                        new C_ResponseMessage(ack_ctx));
     return false;
   }
   return true;
@@ -699,8 +701,8 @@ bool ImageWatcher::handle_payload(const SnapRemovePayload &payload,
     ldout(m_image_ctx.cct, 10) << this << " remote snap_remove request: "
 			       << payload.snap_name << dendl;
 
-    librbd::snap_remove_helper(&m_image_ctx, new C_ResponseMessage(ack_ctx),
-                               payload.snap_name.c_str());
+    m_image_ctx.operations->snap_remove(payload.snap_name.c_str(),
+                                        new C_ResponseMessage(ack_ctx));
     return false;
   }
   return true;
@@ -714,8 +716,8 @@ bool ImageWatcher::handle_payload(const SnapProtectPayload& payload,
     ldout(m_image_ctx.cct, 10) << this << " remote snap_protect request: "
                                << payload.snap_name << dendl;
 
-    librbd::snap_protect_helper(&m_image_ctx, new C_ResponseMessage(ack_ctx),
-                                payload.snap_name.c_str());
+    m_image_ctx.operations->snap_protect(payload.snap_name.c_str(),
+                                         new C_ResponseMessage(ack_ctx));
     return false;
   }
   return true;
@@ -729,8 +731,8 @@ bool ImageWatcher::handle_payload(const SnapUnprotectPayload& payload,
     ldout(m_image_ctx.cct, 10) << this << " remote snap_unprotect request: "
                                << payload.snap_name << dendl;
 
-    librbd::snap_unprotect_helper(&m_image_ctx, new C_ResponseMessage(ack_ctx),
-                                  payload.snap_name.c_str());
+    m_image_ctx.operations->snap_unprotect(payload.snap_name.c_str(),
+                                           new C_ResponseMessage(ack_ctx));
     return false;
   }
   return true;
@@ -750,7 +752,7 @@ bool ImageWatcher::handle_payload(const RebuildObjectMapPayload& payload,
       ldout(m_image_ctx.cct, 10) << this
                                  << " remote rebuild object map request: "
                                  << payload.async_request_id << dendl;
-      librbd::async_rebuild_object_map(&m_image_ctx, ctx, *prog_ctx);
+      m_image_ctx.operations->rebuild_object_map(*prog_ctx, ctx);
     }
 
     ::encode(ResponseMessage(r), ack_ctx->out);
@@ -766,8 +768,8 @@ bool ImageWatcher::handle_payload(const RenamePayload& payload,
     ldout(m_image_ctx.cct, 10) << this << " remote rename request: "
                                << payload.image_name << dendl;
 
-    librbd::rename_helper(&m_image_ctx, new C_ResponseMessage(ack_ctx),
-                          payload.image_name.c_str());
+    m_image_ctx.operations->rename(payload.image_name.c_str(),
+                                   new C_ResponseMessage(ack_ctx));
     return false;
   }
   return true;
diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc
index 903a458..3b52f52 100644
--- a/src/librbd/Journal.cc
+++ b/src/librbd/Journal.cc
@@ -7,14 +7,12 @@
 #include "librbd/AioObjectRequest.h"
 #include "librbd/ExclusiveLock.h"
 #include "librbd/ImageCtx.h"
-#include "librbd/JournalReplay.h"
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
+#include "librbd/journal/Replay.h"
 #include "librbd/Utils.h"
 #include "journal/Journaler.h"
 #include "journal/ReplayEntry.h"
 #include "common/errno.h"
-#include <boost/utility/enable_if.hpp>
-#include <boost/type_traits/is_base_of.hpp>
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -22,72 +20,86 @@
 
 namespace librbd {
 
+using util::create_async_context_callback;
+using util::create_context_callback;
+
 namespace {
 
 const std::string CLIENT_DESCRIPTION = "master image";
 
-struct SetOpRequestTid : public boost::static_visitor<void> {
-  uint64_t tid;
-
-  SetOpRequestTid(uint64_t _tid) : tid(_tid) {
-  }
-
-  template <typename Event>
-  typename boost::enable_if<boost::is_base_of<journal::OpEventBase, Event>,
-                            void>::type
-  operator()(Event &event) const {
-    event.tid = tid;
-  }
-
-  template <typename Event>
-  typename boost::disable_if<boost::is_base_of<journal::OpEventBase, Event>,
-                            void>::type
-  operator()(Event &event) const {
-    assert(false);
-  }
-};
-
-struct C_ReplayCommitted : public Context {
-  ::journal::Journaler *journaler;
-  ::journal::ReplayEntry replay_entry;
+} // anonymous namespace
 
-  C_ReplayCommitted(::journal::Journaler *journaler,
-		    ::journal::ReplayEntry &&replay_entry) :
-    journaler(journaler), replay_entry(std::move(replay_entry)) {
-  }
-  virtual void finish(int r) {
-    journaler->committed(replay_entry);
+template <typename I>
+std::ostream &operator<<(std::ostream &os,
+                         const typename Journal<I>::State &state) {
+  switch (state) {
+  case Journal<I>::STATE_UNINITIALIZED:
+    os << "Uninitialized";
+    break;
+  case Journal<I>::STATE_INITIALIZING:
+    os << "Initializing";
+    break;
+  case Journal<I>::STATE_REPLAYING:
+    os << "Replaying";
+    break;
+  case Journal<I>::STATE_FLUSHING_RESTART:
+    os << "FlushingRestart";
+    break;
+  case Journal<I>::STATE_RESTARTING_REPLAY:
+    os << "RestartingReplay";
+    break;
+  case Journal<I>::STATE_FLUSHING_REPLAY:
+    os << "FlushingReplay";
+    break;
+  case Journal<I>::STATE_READY:
+    os << "Ready";
+    break;
+  case Journal<I>::STATE_STOPPING:
+    os << "Stopping";
+    break;
+  case Journal<I>::STATE_CLOSING:
+    os << "Closing";
+    break;
+  case Journal<I>::STATE_CLOSED:
+    os << "Closed";
+    break;
+  default:
+    os << "Unknown (" << static_cast<uint32_t>(state) << ")";
+    break;
   }
-};
-
-} // anonymous namespace
+  return os;
+}
 
-Journal::Journal(ImageCtx &image_ctx)
+template <typename I>
+Journal<I>::Journal(I &image_ctx)
   : m_image_ctx(image_ctx), m_journaler(NULL),
-    m_lock("Journal::m_lock"), m_state(STATE_UNINITIALIZED),
+    m_lock("Journal<I>::m_lock"), m_state(STATE_UNINITIALIZED),
     m_error_result(0), m_replay_handler(this), m_close_pending(false),
-    m_event_lock("Journal::m_event_lock"), m_event_tid(0),
+    m_event_lock("Journal<I>::m_event_lock"), m_event_tid(0),
     m_blocking_writes(false), m_journal_replay(NULL) {
 
   ldout(m_image_ctx.cct, 5) << this << ": ictx=" << &m_image_ctx << dendl;
 }
 
-Journal::~Journal() {
+template <typename I>
+Journal<I>::~Journal() {
   assert(m_state == STATE_UNINITIALIZED || m_state == STATE_CLOSED);
   assert(m_journaler == NULL);
   assert(m_journal_replay == NULL);
   assert(m_wait_for_state_contexts.empty());
 }
 
-bool Journal::is_journal_supported(ImageCtx &image_ctx) {
+template <typename I>
+bool Journal<I>::is_journal_supported(I &image_ctx) {
   assert(image_ctx.snap_lock.is_locked());
   return ((image_ctx.features & RBD_FEATURE_JOURNALING) &&
           !image_ctx.read_only && image_ctx.snap_id == CEPH_NOSNAP);
 }
 
-int Journal::create(librados::IoCtx &io_ctx, const std::string &image_id,
-		    uint8_t order, uint8_t splay_width,
-		    const std::string &object_pool) {
+template <typename I>
+int Journal<I>::create(librados::IoCtx &io_ctx, const std::string &image_id,
+		       uint8_t order, uint8_t splay_width,
+		       const std::string &object_pool) {
   CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
   ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
 
@@ -105,8 +117,7 @@ int Journal::create(librados::IoCtx &io_ctx, const std::string &image_id,
     pool_id = data_io_ctx.get_id();
   }
 
-  ::journal::Journaler journaler(io_ctx, image_id, "",
-				 cct->_conf->rbd_journal_commit_age);
+  Journaler journaler(io_ctx, image_id, "", cct->_conf->rbd_journal_commit_age);
 
   int r = journaler.create(order, splay_width, pool_id);
   if (r < 0) {
@@ -122,12 +133,12 @@ int Journal::create(librados::IoCtx &io_ctx, const std::string &image_id,
   return 0;
 }
 
-int Journal::remove(librados::IoCtx &io_ctx, const std::string &image_id) {
+template <typename I>
+int Journal<I>::remove(librados::IoCtx &io_ctx, const std::string &image_id) {
   CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
   ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
 
-  ::journal::Journaler journaler(io_ctx, image_id, "",
-				 cct->_conf->rbd_journal_commit_age);
+  Journaler journaler(io_ctx, image_id, "", cct->_conf->rbd_journal_commit_age);
 
   bool journal_exists;
   int r = journaler.exists(&journal_exists);
@@ -157,12 +168,12 @@ int Journal::remove(librados::IoCtx &io_ctx, const std::string &image_id) {
   return 0;
 }
 
-int Journal::reset(librados::IoCtx &io_ctx, const std::string &image_id) {
+template <typename I>
+int Journal<I>::reset(librados::IoCtx &io_ctx, const std::string &image_id) {
   CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
   ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
 
-  ::journal::Journaler journaler(io_ctx, image_id, "",
-				 cct->_conf->rbd_journal_commit_age);
+  Journaler journaler(io_ctx, image_id, "", cct->_conf->rbd_journal_commit_age);
 
   C_SaferCond cond;
   journaler.init(&cond);
@@ -197,18 +208,23 @@ int Journal::reset(librados::IoCtx &io_ctx, const std::string &image_id) {
   return 0;
 }
 
-bool Journal::is_journal_ready() const {
+template <typename I>
+bool Journal<I>::is_journal_ready() const {
   Mutex::Locker locker(m_lock);
   return (m_state == STATE_READY);
 }
 
-bool Journal::is_journal_replaying() const {
+template <typename I>
+bool Journal<I>::is_journal_replaying() const {
   Mutex::Locker locker(m_lock);
-  return (m_state == STATE_REPLAYING);
+  return (m_state == STATE_REPLAYING ||
+          m_state == STATE_FLUSHING_REPLAY ||
+          m_state == STATE_RESTARTING_REPLAY);
 }
 
-void Journal::wait_for_journal_ready(Context *on_ready) {
-  on_ready = util::create_async_context_callback(m_image_ctx, on_ready);
+template <typename I>
+void Journal<I>::wait_for_journal_ready(Context *on_ready) {
+  on_ready = create_async_context_callback(m_image_ctx, on_ready);
 
   Mutex::Locker locker(m_lock);
   if (m_state == STATE_READY) {
@@ -218,11 +234,12 @@ void Journal::wait_for_journal_ready(Context *on_ready) {
   }
 }
 
-void Journal::open(Context *on_finish) {
+template <typename I>
+void Journal<I>::open(Context *on_finish) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << dendl;
 
-  on_finish = util::create_async_context_callback(m_image_ctx, on_finish);
+  on_finish = create_async_context_callback(m_image_ctx, on_finish);
 
   Mutex::Locker locker(m_lock);
   assert(m_state == STATE_UNINITIALIZED);
@@ -230,11 +247,12 @@ void Journal::open(Context *on_finish) {
   create_journaler();
 }
 
-void Journal::close(Context *on_finish) {
+template <typename I>
+void Journal<I>::close(Context *on_finish) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << dendl;
 
-  on_finish = util::create_async_context_callback(m_image_ctx, on_finish);
+  on_finish = create_async_context_callback(m_image_ctx, on_finish);
 
   Mutex::Locker locker(m_lock);
   assert(m_state != STATE_UNINITIALIZED);
@@ -251,28 +269,28 @@ void Journal::close(Context *on_finish) {
   wait_for_steady_state(on_finish);
 }
 
-uint64_t Journal::append_io_event(AioCompletion *aio_comp,
-                                  const journal::EventEntry &event_entry,
-                                  const AioObjectRequests &requests,
-                                  uint64_t offset, size_t length,
-                                  bool flush_entry) {
+template <typename I>
+uint64_t Journal<I>::append_io_event(AioCompletion *aio_comp,
+                                     journal::EventEntry &&event_entry,
+                                     const AioObjectRequests &requests,
+                                     uint64_t offset, size_t length,
+                                     bool flush_entry) {
   assert(m_image_ctx.owner_lock.is_locked());
 
   bufferlist bl;
   ::encode(event_entry, bl);
 
-  ::journal::Future future;
+  Future future;
   uint64_t tid;
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
 
-    future = m_journaler->append("", bl);
-
     Mutex::Locker event_locker(m_event_lock);
     tid = ++m_event_tid;
     assert(tid != 0);
 
+    future = m_journaler->append("", bl);
     m_events[tid] = Event(future, aio_comp, requests, offset, length);
   }
 
@@ -284,7 +302,7 @@ uint64_t Journal::append_io_event(AioCompletion *aio_comp,
                  << "length=" << length << ", "
                  << "flush=" << flush_entry << ", tid=" << tid << dendl;
 
-  Context *on_safe = new C_EventSafe(this, tid);
+  Context *on_safe = new C_IOEventSafe(this, tid);
   if (flush_entry) {
     future.flush(on_safe);
   } else {
@@ -293,21 +311,23 @@ uint64_t Journal::append_io_event(AioCompletion *aio_comp,
   return tid;
 }
 
-void Journal::commit_io_event(uint64_t tid, int r) {
+template <typename I>
+void Journal<I>::commit_io_event(uint64_t tid, int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": tid=" << tid << ", "
                  "r=" << r << dendl;
 
   Mutex::Locker event_locker(m_event_lock);
-  Events::iterator it = m_events.find(tid);
+  typename Events::iterator it = m_events.find(tid);
   if (it == m_events.end()) {
     return;
   }
   complete_event(it, r);
 }
 
-void Journal::commit_io_event_extent(uint64_t tid, uint64_t offset,
-                                     uint64_t length, int r) {
+template <typename I>
+void Journal<I>::commit_io_event_extent(uint64_t tid, uint64_t offset,
+                                        uint64_t length, int r) {
   assert(length > 0);
 
   CephContext *cct = m_image_ctx.cct;
@@ -317,7 +337,7 @@ void Journal::commit_io_event_extent(uint64_t tid, uint64_t offset,
                  << "r=" << r << dendl;
 
   Mutex::Locker event_locker(m_event_lock);
-  Events::iterator it = m_events.find(tid);
+  typename Events::iterator it = m_events.find(tid);
   if (it == m_events.end()) {
     return;
   }
@@ -341,56 +361,71 @@ void Journal::commit_io_event_extent(uint64_t tid, uint64_t offset,
   complete_event(it, event.ret_val);
 }
 
-uint64_t Journal::append_op_event(journal::EventEntry &event_entry) {
+template <typename I>
+void Journal<I>::append_op_event(uint64_t op_tid,
+                                 journal::EventEntry &&event_entry,
+                                 Context *on_safe) {
   assert(m_image_ctx.owner_lock.is_locked());
 
-  uint64_t tid;
+  bufferlist bl;
+  ::encode(event_entry, bl);
+
+  Future future;
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
-
-    Mutex::Locker event_locker(m_event_lock);
-    tid = ++m_event_tid;
-    assert(tid != 0);
-
-    // inject the generated tid into the provided event entry
-    boost::apply_visitor(SetOpRequestTid(tid), event_entry.event);
-
-    bufferlist bl;
-    ::encode(event_entry, bl);
-    m_journaler->committed(m_journaler->append("", bl));
+    future = m_journaler->append("", bl);
   }
 
+  on_safe = create_async_context_callback(m_image_ctx, on_safe);
+  future.flush(new C_OpEventSafe(this, op_tid, future, on_safe));
+
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 10) << this << " " << __func__ << ": "
-                 << "event=" << event_entry.get_event_type() << ", "
-                 << "tid=" << tid << dendl;
-  return tid;
+                 << "op_tid=" << op_tid << ", "
+                 << "event=" << event_entry.get_event_type() << dendl;
 }
 
-void Journal::commit_op_event(uint64_t tid, int r) {
+template <typename I>
+void Journal<I>::commit_op_event(uint64_t op_tid, int r) {
   CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 10) << this << " " << __func__ << ": tid=" << tid << dendl;
+  ldout(cct, 10) << this << " " << __func__ << ": op_tid=" << op_tid << ", "
+                 << "r=" << r << dendl;
 
-  journal::EventEntry event_entry((journal::OpFinishEvent(tid, r)));
+  journal::EventEntry event_entry((journal::OpFinishEvent(op_tid, r)));
 
   bufferlist bl;
   ::encode(event_entry, bl);
 
+  Future future;
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
+    future = m_journaler->append("", bl);
+  }
+
+  future.flush(new C_OpEventSafe(this, op_tid, future, nullptr));
+}
+
+template <typename I>
+void Journal<I>::replay_op_ready(uint64_t op_tid, Context *on_resume) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 10) << this << " " << __func__ << ": op_tid=" << op_tid << dendl;
 
-    m_journaler->committed(m_journaler->append("", bl));
+  {
+    Mutex::Locker locker(m_lock);
+    assert(m_journal_replay != nullptr);
+    m_journal_replay->replay_op_ready(op_tid, on_resume);
   }
 }
 
-void Journal::flush_event(uint64_t tid, Context *on_safe) {
+template <typename I>
+void Journal<I>::flush_event(uint64_t tid, Context *on_safe) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": tid=" << tid << ", "
                  << "on_safe=" << on_safe << dendl;
 
-  ::journal::Future future;
+  Future future;
   {
     Mutex::Locker event_locker(m_event_lock);
     future = wait_event(m_lock, tid, on_safe);
@@ -401,7 +436,8 @@ void Journal::flush_event(uint64_t tid, Context *on_safe) {
   }
 }
 
-void Journal::wait_event(uint64_t tid, Context *on_safe) {
+template <typename I>
+void Journal<I>::wait_event(uint64_t tid, Context *on_safe) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": tid=" << tid << ", "
                  << "on_safe=" << on_safe << dendl;
@@ -410,25 +446,30 @@ void Journal::wait_event(uint64_t tid, Context *on_safe) {
   wait_event(m_lock, tid, on_safe);
 }
 
-::journal::Future Journal::wait_event(Mutex &lock, uint64_t tid,
-                                      Context *on_safe) {
+template <typename I>
+typename Journal<I>::Future Journal<I>::wait_event(Mutex &lock, uint64_t tid,
+                                                   Context *on_safe) {
   assert(m_event_lock.is_locked());
   CephContext *cct = m_image_ctx.cct;
 
-  Events::iterator it = m_events.find(tid);
-  if (it == m_events.end() || it->second.safe) {
+  typename Events::iterator it = m_events.find(tid);
+  assert(it != m_events.end());
+
+  Event &event = it->second;
+  if (event.safe) {
     // journal entry already safe
     ldout(cct, 20) << "journal entry already safe" << dendl;
-    m_image_ctx.op_work_queue->queue(on_safe, 0);
-    return ::journal::Future();
+    m_image_ctx.op_work_queue->queue(on_safe, event.ret_val);
+    return Future();
   }
 
-  Event &event = it->second;
-  event.on_safe_contexts.push_back(on_safe);
+  event.on_safe_contexts.push_back(create_async_context_callback(m_image_ctx,
+                                                                 on_safe));
   return event.future;
 }
 
-void Journal::create_journaler() {
+template <typename I>
+void Journal<I>::create_journaler() {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << dendl;
 
@@ -437,12 +478,15 @@ void Journal::create_journaler() {
   assert(m_journaler == NULL);
 
   transition_state(STATE_INITIALIZING, 0);
-  m_journaler = new ::journal::Journaler(m_image_ctx.md_ctx, m_image_ctx.id, "",
-                                         m_image_ctx.journal_commit_age);
-  m_journaler->init(new C_InitJournal(this));
+  m_journaler = new Journaler(m_image_ctx.md_ctx, m_image_ctx.id, "",
+                              m_image_ctx.journal_commit_age);
+  m_journaler->init(create_async_context_callback(
+    m_image_ctx, create_context_callback<
+      Journal<I>, &Journal<I>::handle_initialized>(this)));
 }
 
-void Journal::destroy_journaler(int r) {
+template <typename I>
+void Journal<I>::destroy_journaler(int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
 
@@ -452,24 +496,29 @@ void Journal::destroy_journaler(int r) {
   m_journal_replay = NULL;
 
   transition_state(STATE_CLOSING, r);
-  m_image_ctx.op_work_queue->queue(new C_DestroyJournaler(this), 0);
+  m_image_ctx.op_work_queue->queue(create_context_callback<
+    Journal<I>, &Journal<I>::handle_journal_destroyed>(this), 0);
 }
 
-void Journal::recreate_journaler(int r) {
+template <typename I>
+void Journal<I>::recreate_journaler(int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
 
   assert(m_lock.is_locked());
-  assert(m_state == STATE_REPLAYING);
+  assert(m_state == STATE_FLUSHING_RESTART ||
+         m_state == STATE_FLUSHING_REPLAY);
 
   delete m_journal_replay;
   m_journal_replay = NULL;
 
   transition_state(STATE_RESTARTING_REPLAY, r);
-  m_image_ctx.op_work_queue->queue(new C_DestroyJournaler(this), 0);
+  m_image_ctx.op_work_queue->queue(create_context_callback<
+    Journal<I>, &Journal<I>::handle_journal_destroyed>(this), 0);
 }
 
-void Journal::complete_event(Events::iterator it, int r) {
+template <typename I>
+void Journal<I>::complete_event(typename Events::iterator it, int r) {
   assert(m_event_lock.is_locked());
   assert(m_state == STATE_READY);
 
@@ -477,13 +526,26 @@ void Journal::complete_event(Events::iterator it, int r) {
   ldout(cct, 20) << this << " " << __func__ << ": tid=" << it->first << " "
                  << "r=" << r << dendl;
 
-  m_journaler->committed(it->second.future);
-  if (it->second.safe) {
+  Event &event = it->second;
+  if (r < 0) {
+    // event recorded to journal but failed to update disk, we cannot
+    // commit this IO event. this event must be replayed.
+    assert(event.safe);
+    lderr(cct) << "failed to commit IO to disk, replay required: "
+               << cpp_strerror(r) << dendl;
+  }
+
+  event.committed_io = true;
+  if (event.safe) {
+    if (r >= 0) {
+      m_journaler->committed(event.future);
+    }
     m_events.erase(it);
   }
 }
 
-void Journal::handle_initialized(int r) {
+template <typename I>
+void Journal<I>::handle_initialized(int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
 
@@ -498,86 +560,148 @@ void Journal::handle_initialized(int r) {
   }
 
   transition_state(STATE_REPLAYING, 0);
-  m_journal_replay = new JournalReplay(m_image_ctx);
+  m_journal_replay = journal::Replay<I>::create(m_image_ctx);
   m_journaler->start_replay(&m_replay_handler);
 }
 
-void Journal::handle_replay_ready() {
+template <typename I>
+void Journal<I>::handle_replay_ready() {
+  ReplayEntry replay_entry;
+  {
+    Mutex::Locker locker(m_lock);
+    if (m_state != STATE_REPLAYING) {
+      return;
+    }
+
+    CephContext *cct = m_image_ctx.cct;
+    ldout(cct, 20) << this << " " << __func__ << dendl;
+    if (!m_journaler->try_pop_front(&replay_entry)) {
+      return;
+    }
+  }
+
+  bufferlist data = replay_entry.get_data();
+  bufferlist::iterator it = data.begin();
+  Context *on_ready = create_context_callback<
+    Journal<I>, &Journal<I>::handle_replay_process_ready>(this);
+  Context *on_commit = new C_ReplayProcessSafe(this, std::move(replay_entry));
+
+  m_journal_replay->process(&it, on_ready, on_commit);
+}
+
+template <typename I>
+void Journal<I>::handle_replay_complete(int r) {
   CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << dendl;
 
-  Mutex::Locker locker(m_lock);
+  m_lock.Lock();
   if (m_state != STATE_REPLAYING) {
+    m_lock.Unlock();
     return;
   }
 
-  while (true) {
-    ::journal::ReplayEntry replay_entry;
-    if (!m_journaler->try_pop_front(&replay_entry)) {
-      return;
-    }
-
+  ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
+  m_journaler->stop_replay();
+  if (r < 0) {
+    transition_state(STATE_FLUSHING_RESTART, r);
     m_lock.Unlock();
-    bufferlist data = replay_entry.get_data();
-    bufferlist::iterator it = data.begin();
-    int r = m_journal_replay->process(
-      it, new C_ReplayCommitted(m_journaler, std::move(replay_entry)));
-    m_lock.Lock();
-
-    if (r < 0) {
-      lderr(cct) << "failed to replay journal entry: " << cpp_strerror(r)
-                 << dendl;
-      m_journaler->stop_replay();
 
-      if (m_close_pending) {
-        destroy_journaler(r);
-        return;
-      }
+    m_journal_replay->flush(create_context_callback<
+      Journal<I>, &Journal<I>::handle_flushing_restart>(this));
+  } else {
+    transition_state(STATE_FLUSHING_REPLAY, 0);
+    m_lock.Unlock();
 
-      recreate_journaler(r);
-    }
+    m_journal_replay->flush(create_context_callback<
+      Journal<I>, &Journal<I>::handle_flushing_replay>(this));
   }
 }
 
-void Journal::handle_replay_complete(int r) {
+template <typename I>
+void Journal<I>::handle_replay_process_ready(int r) {
+  // journal::Replay is ready for more events -- attempt to pop another
   CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << dendl;
 
-  {
-    Mutex::Locker locker(m_lock);
-    if (m_state != STATE_REPLAYING) {
-      return;
-    }
+  assert(r == 0);
+  handle_replay_ready();
+}
 
-    ldout(cct, 20) << this << " " << __func__ << dendl;
-    m_journaler->stop_replay();
+template <typename I>
+void Journal<I>::handle_replay_process_safe(ReplayEntry replay_entry, int r) {
+  Mutex::Locker locker(m_lock);
 
-    if (r == 0) {
-      r = m_journal_replay->flush();
-    }
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
+  if (r < 0) {
+    lderr(cct) << "failed to commit journal event to disk: " << cpp_strerror(r)
+               << dendl;
 
-    if (r < 0) {
-      lderr(cct) << this << " " << __func__ << ": r=" << r << dendl;
-      recreate_journaler(r);
+    if (m_state == STATE_REPLAYING) {
+      // abort the replay if we have an error
+      m_journaler->stop_replay();
+      transition_state(STATE_FLUSHING_RESTART, r);
+
+      m_journal_replay->flush(create_context_callback<
+        Journal<I>, &Journal<I>::handle_flushing_restart>(this));
+      return;
+    } else if (m_state == STATE_FLUSHING_REPLAY) {
+      // end-of-replay flush in-progress -- we need to restart replay
+      transition_state(STATE_FLUSHING_RESTART, r);
       return;
     }
+  } else {
+    // only commit the entry if written successfully
+    m_journaler->committed(replay_entry);
+  }
+}
 
-    delete m_journal_replay;
-    m_journal_replay = NULL;
+template <typename I>
+void Journal<I>::handle_flushing_restart(int r) {
+  Mutex::Locker locker(m_lock);
 
-    if (m_close_pending) {
-      destroy_journaler(0);
-      return;
-    }
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << dendl;
+
+  assert(r == 0);
+  assert(m_state == STATE_FLUSHING_RESTART);
+  if (m_close_pending) {
+    destroy_journaler(r);
+    return;
+  }
+
+  recreate_journaler(r);
+}
+
+template <typename I>
+void Journal<I>::handle_flushing_replay(int r) {
+  Mutex::Locker locker(m_lock);
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
 
-    m_error_result = 0;
-    m_journaler->start_append(m_image_ctx.journal_object_flush_interval,
-			      m_image_ctx.journal_object_flush_bytes,
-			      m_image_ctx.journal_object_flush_age);
-    transition_state(STATE_READY, 0);
+  assert(r == 0);
+  assert(m_state == STATE_FLUSHING_REPLAY || m_state == STATE_FLUSHING_RESTART);
+  if (m_close_pending) {
+    destroy_journaler(r);
+    return;
+  } else if (m_state == STATE_FLUSHING_RESTART) {
+    // failed to replay one-or-more events -- restart
+    recreate_journaler(0);
+    return;
   }
+
+  delete m_journal_replay;
+  m_journal_replay = NULL;
+
+  m_error_result = 0;
+  m_journaler->start_append(m_image_ctx.journal_object_flush_interval,
+			    m_image_ctx.journal_object_flush_bytes,
+			    m_image_ctx.journal_object_flush_age);
+  transition_state(STATE_READY, 0);
 }
 
-void Journal::handle_recording_stopped(int r) {
+template <typename I>
+void Journal<I>::handle_recording_stopped(int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
 
@@ -587,7 +711,8 @@ void Journal::handle_recording_stopped(int r) {
   destroy_journaler(r);
 }
 
-void Journal::handle_journal_destroyed(int r) {
+template <typename I>
+void Journal<I>::handle_journal_destroyed(int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": r=" << r << dendl;
 
@@ -610,18 +735,24 @@ void Journal::handle_journal_destroyed(int r) {
   transition_state(STATE_CLOSED, r);
 }
 
-void Journal::handle_event_safe(int r, uint64_t tid) {
+template <typename I>
+void Journal<I>::handle_io_event_safe(int r, uint64_t tid) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": r=" << r << ", "
                  << "tid=" << tid << dendl;
 
-  // TODO: ensure this callback never sees a failure
+  // journal will be flushed before closing
+  assert(m_state == STATE_READY || m_state == STATE_STOPPING);
+  if (r < 0) {
+    lderr(cct) << "failed to commit IO event: "  << cpp_strerror(r) << dendl;
+  }
+
   AioCompletion *aio_comp;
   AioObjectRequests aio_object_requests;
   Contexts on_safe_contexts;
   {
     Mutex::Locker event_locker(m_event_lock);
-    Events::iterator it = m_events.find(tid);
+    typename Events::iterator it = m_events.find(tid);
     assert(it != m_events.end());
 
     Event &event = it->second;
@@ -629,7 +760,14 @@ void Journal::handle_event_safe(int r, uint64_t tid) {
     aio_object_requests.swap(event.aio_object_requests);
     on_safe_contexts.swap(event.on_safe_contexts);
 
-    if (event.pending_extents.empty()) {
+    if (r < 0 || event.committed_io) {
+      // failed journal write so IO won't be sent -- or IO extent was
+      // overwritten by future IO operations so this was a no-op IO event
+      event.ret_val = r;
+      m_journaler->committed(event.future);
+    }
+
+    if (event.committed_io) {
       m_events.erase(it);
     } else {
       event.safe = true;
@@ -657,7 +795,27 @@ void Journal::handle_event_safe(int r, uint64_t tid) {
   }
 }
 
-void Journal::stop_recording() {
+template <typename I>
+void Journal<I>::handle_op_event_safe(int r, uint64_t tid, const Future &future,
+                                      Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": r=" << r << ", "
+                 << "tid=" << tid << dendl;
+
+  // journal will be flushed before closing
+  assert(m_state == STATE_READY || m_state == STATE_STOPPING);
+  if (r < 0) {
+    lderr(cct) << "failed to commit op event: "  << cpp_strerror(r) << dendl;
+  }
+
+  m_journaler->committed(future);
+  if (on_safe != nullptr) {
+    on_safe->complete(r);
+  }
+}
+
+template <typename I>
+void Journal<I>::stop_recording() {
   assert(m_lock.is_locked());
   assert(m_journaler != NULL);
 
@@ -665,26 +823,12 @@ void Journal::stop_recording() {
   transition_state(STATE_STOPPING, 0);
 
   m_journaler->stop_append(util::create_async_context_callback(
-    m_image_ctx, new C_StopRecording(this)));
-}
-
-void Journal::block_writes() {
-  assert(m_lock.is_locked());
-  if (!m_blocking_writes) {
-    m_blocking_writes = true;
-    m_image_ctx.aio_work_queue->block_writes();
-  }
-}
-
-void Journal::unblock_writes() {
-  assert(m_lock.is_locked());
-  if (m_blocking_writes) {
-    m_blocking_writes = false;
-    m_image_ctx.aio_work_queue->unblock_writes();
-  }
+    m_image_ctx, create_context_callback<
+      Journal<I>, &Journal<I>::handle_recording_stopped>(this)));
 }
 
-void Journal::transition_state(State state, int r) {
+template <typename I>
+void Journal<I>::transition_state(State state, int r) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 20) << this << " " << __func__ << ": new state=" << state << dendl;
   assert(m_lock.is_locked());
@@ -702,7 +846,8 @@ void Journal::transition_state(State state, int r) {
   }
 }
 
-bool Journal::is_steady_state() const {
+template <typename I>
+bool Journal<I>::is_steady_state() const {
   assert(m_lock.is_locked());
   switch (m_state) {
   case STATE_READY:
@@ -711,7 +856,9 @@ bool Journal::is_steady_state() const {
   case STATE_UNINITIALIZED:
   case STATE_INITIALIZING:
   case STATE_REPLAYING:
+  case STATE_FLUSHING_RESTART:
   case STATE_RESTARTING_REPLAY:
+  case STATE_FLUSHING_REPLAY:
   case STATE_STOPPING:
   case STATE_CLOSING:
     break;
@@ -719,7 +866,8 @@ bool Journal::is_steady_state() const {
   return false;
 }
 
-void Journal::wait_for_steady_state(Context *on_state) {
+template <typename I>
+void Journal<I>::wait_for_steady_state(Context *on_state) {
   assert(m_lock.is_locked());
   assert(!is_steady_state());
 
@@ -729,37 +877,6 @@ void Journal::wait_for_steady_state(Context *on_state) {
   m_wait_for_state_contexts.push_back(on_state);
 }
 
-std::ostream &operator<<(std::ostream &os, const Journal::State &state) {
-  switch (state) {
-  case Journal::STATE_UNINITIALIZED:
-    os << "Uninitialized";
-    break;
-  case Journal::STATE_INITIALIZING:
-    os << "Initializing";
-    break;
-  case Journal::STATE_REPLAYING:
-    os << "Replaying";
-    break;
-  case Journal::STATE_RESTARTING_REPLAY:
-    os << "RestartingReplay";
-    break;
-  case Journal::STATE_READY:
-    os << "Ready";
-    break;
-  case Journal::STATE_STOPPING:
-    os << "Stopping";
-    break;
-  case Journal::STATE_CLOSING:
-    os << "Closing";
-    break;
-  case Journal::STATE_CLOSED:
-    os << "Closed";
-    break;
-  default:
-    os << "Unknown (" << static_cast<uint32_t>(state) << ")";
-    break;
-  }
-  return os;
-}
-
 } // namespace librbd
+
+template class librbd::Journal<librbd::ImageCtx>;
diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h
index 0ea9ae4..2a03907 100644
--- a/src/librbd/Journal.h
+++ b/src/librbd/Journal.h
@@ -5,14 +5,17 @@
 #define CEPH_LIBRBD_JOURNAL_H
 
 #include "include/int_types.h"
+#include "include/atomic.h"
 #include "include/Context.h"
 #include "include/interval_set.h"
 #include "include/unordered_map.h"
 #include "include/rados/librados.hpp"
 #include "common/Mutex.h"
 #include "journal/Future.h"
+#include "journal/ReplayEntry.h"
 #include "journal/ReplayHandler.h"
 #include <algorithm>
+#include <iosfwd>
 #include <list>
 #include <string>
 
@@ -26,20 +29,75 @@ namespace librbd {
 class AioCompletion;
 class AioObjectRequest;
 class ImageCtx;
-class JournalReplay;
 
 namespace journal {
+
 class EventEntry;
-}
+template <typename> class Replay;
+
+template <typename ImageCtxT>
+struct TypeTraits {
+  typedef ::journal::Journaler Journaler;
+  typedef ::journal::Future Future;
+  typedef ::journal::ReplayEntry ReplayEntry;
+};
+
+} // namespace journal
 
+
+template <typename ImageCtxT = ImageCtx>
 class Journal {
 public:
+  /**
+   * @verbatim
+   *
+   * <start>
+   *    |
+   *    v
+   * UNINITIALIZED ---> INITIALIZING ---> REPLAYING ------> FLUSHING ---> READY
+   *    |                 *  .  ^             *  .              *           |
+   *    |                 *  .  |             *  .              *           |
+   *    |                 *  .  |    (error)  *  . . . . . . .  *           |
+   *    |                 *  .  |             *              .  *           |
+   *    |                 *  .  |             v              .  *           |
+   *    |                 *  .  |         FLUSHING_RESTART   .  *           |
+   *    |                 *  .  |             |              .  *           |
+   *    |                 *  .  |             |              .  *           |
+   *    |                 *  .  |             v              .  *           v
+   *    |                 *  .  |         RESTARTING  < * * * * *       STOPPING
+   *    |                 *  .  |             |              .              |
+   *    |                 *  .  |             |              .              |
+   *    |       * * * * * *  .  \-------------/              .              |
+   *    |       * (error)    .                               .              |
+   *    |       *            .   . . . . . . . . . . . . . . .              |
+   *    |       *            .   .                                          |
+   *    |       v            v   v                                          |
+   *    |     CLOSED <----- CLOSING <---------------------------------------/
+   *    |       |
+   *    |       v
+   *    \---> <finish>
+   *
+   * @endverbatim
+   */
+  enum State {
+    STATE_UNINITIALIZED,
+    STATE_INITIALIZING,
+    STATE_REPLAYING,
+    STATE_FLUSHING_RESTART,
+    STATE_RESTARTING_REPLAY,
+    STATE_FLUSHING_REPLAY,
+    STATE_READY,
+    STATE_STOPPING,
+    STATE_CLOSING,
+    STATE_CLOSED
+  };
+
   typedef std::list<AioObjectRequest *> AioObjectRequests;
 
-  Journal(ImageCtx &image_ctx);
+  Journal(ImageCtxT &image_ctx);
   ~Journal();
 
-  static bool is_journal_supported(ImageCtx &image_ctx);
+  static bool is_journal_supported(ImageCtxT &image_ctx);
   static int create(librados::IoCtx &io_ctx, const std::string &image_id,
 		    uint8_t order, uint8_t splay_width,
 		    const std::string &object_pool);
@@ -55,7 +113,7 @@ public:
   void close(Context *on_finish);
 
   uint64_t append_io_event(AioCompletion *aio_comp,
-                           const journal::EventEntry &event_entry,
+                           journal::EventEntry &&event_entry,
                            const AioObjectRequests &requests,
                            uint64_t offset, size_t length,
                            bool flush_entry);
@@ -63,119 +121,93 @@ public:
   void commit_io_event_extent(uint64_t tid, uint64_t offset, uint64_t length,
                               int r);
 
-  uint64_t append_op_event(journal::EventEntry &event_entry);
+  void append_op_event(uint64_t op_tid, journal::EventEntry &&event_entry,
+                       Context *on_safe);
   void commit_op_event(uint64_t tid, int r);
+  void replay_op_ready(uint64_t op_tid, Context *on_resume);
 
   void flush_event(uint64_t tid, Context *on_safe);
   void wait_event(uint64_t tid, Context *on_safe);
 
+  uint64_t allocate_op_tid() {
+    uint64_t op_tid = m_op_tid.inc();
+    assert(op_tid != 0);
+    return op_tid;
+  }
+
 private:
+  ImageCtxT &m_image_ctx;
+
+  // mock unit testing support
+  typedef journal::TypeTraits<ImageCtxT> TypeTraits;
+  typedef typename TypeTraits::Journaler Journaler;
+  typedef typename TypeTraits::Future Future;
+  typedef typename TypeTraits::ReplayEntry ReplayEntry;
+
   typedef std::list<Context *> Contexts;
   typedef interval_set<uint64_t> ExtentInterval;
 
-  /**
-   * @verbatim
-   *
-   * <start>
-   *    |
-   *    v
-   * UNINITIALIZED ---> INITIALIZING ---> REPLAYING ------> READY
-   *    |                 *  .  ^             *  .            |
-   *    |                 *  .  |             *  .            |
-   *    |                 *  .  |    (error)  *  . . . .      |
-   *    |                 *  .  |             *        .      |
-   *    |                 *  .  |             v        .      v
-   *    |                 *  .  |         RESTARTING   .    STOPPING
-   *    |                 *  .  |             |        .      |
-   *    |                 *  .  |             |        .      |
-   *    |       * * * * * *  .  \-------------/        .      |
-   *    |       * (error)    .                         .      |
-   *    |       *            .   . . . . . . . . . . . .      |
-   *    |       *            .   .                            |
-   *    |       v            v   v                            |
-   *    |     CLOSED <----- CLOSING <-------------------------/
-   *    |       |
-   *    |       v
-   *    \---> <finish>
-   *
-   * @endverbatim
-   */
-  enum State {
-    STATE_UNINITIALIZED,
-    STATE_INITIALIZING,
-    STATE_REPLAYING,
-    STATE_RESTARTING_REPLAY,
-    STATE_READY,
-    STATE_STOPPING,
-    STATE_CLOSING,
-    STATE_CLOSED
-  };
-
   struct Event {
-    ::journal::Future future;
-    AioCompletion *aio_comp;
+    Future future;
+    AioCompletion *aio_comp = nullptr;
     AioObjectRequests aio_object_requests;
     Contexts on_safe_contexts;
     ExtentInterval pending_extents;
-    bool safe;
-    int ret_val;
+    bool committed_io = false;
+    bool safe = false;
+    int ret_val = 0;
 
-    Event() : aio_comp(NULL) {
+    Event() {
     }
-    Event(const ::journal::Future &_future, AioCompletion *_aio_comp,
+    Event(const Future &_future, AioCompletion *_aio_comp,
           const AioObjectRequests &_requests, uint64_t offset, size_t length)
-      : future(_future), aio_comp(_aio_comp), aio_object_requests(_requests),
-        safe(false), ret_val(0) {
+      : future(_future), aio_comp(_aio_comp), aio_object_requests(_requests) {
       if (length > 0) {
         pending_extents.insert(offset, length);
       }
     }
   };
-  typedef ceph::unordered_map<uint64_t, Event> Events;
-
-  struct C_InitJournal : public Context {
-    Journal *journal;
-
-    C_InitJournal(Journal *_journal) : journal(_journal) {
-    }
 
-    virtual void finish(int r) {
-      journal->handle_initialized(r);
-    }
-  };
+  typedef ceph::unordered_map<uint64_t, Event> Events;
 
-  struct C_StopRecording : public Context {
+  struct C_IOEventSafe : public Context {
     Journal *journal;
+    uint64_t tid;
 
-    C_StopRecording(Journal *_journal) : journal(_journal) {
+    C_IOEventSafe(Journal *_journal, uint64_t _tid)
+      : journal(_journal), tid(_tid) {
     }
 
     virtual void finish(int r) {
-      journal->handle_recording_stopped(r);
+      journal->handle_io_event_safe(r, tid);
     }
   };
 
-  struct C_DestroyJournaler : public Context {
+  struct C_OpEventSafe : public Context {
     Journal *journal;
+    uint64_t tid;
+    Future future;
+    Context *on_safe;
 
-    C_DestroyJournaler(Journal *_journal) : journal(_journal) {
+    C_OpEventSafe(Journal *journal, uint64_t tid, const Future &future,
+                  Context *on_safe)
+      : journal(journal), tid(tid), future(future), on_safe(on_safe) {
     }
 
     virtual void finish(int r) {
-      journal->handle_journal_destroyed(r);
+      journal->handle_op_event_safe(r, tid, future, on_safe);
     }
   };
 
-  struct C_EventSafe : public Context {
+  struct C_ReplayProcessSafe : public Context {
     Journal *journal;
-    uint64_t tid;
+    ReplayEntry replay_entry;
 
-    C_EventSafe(Journal *_journal, uint64_t _tid)
-      : journal(_journal), tid(_tid) {
+    C_ReplayProcessSafe(Journal *journal, ReplayEntry &&replay_entry) :
+      journal(journal), replay_entry(std::move(replay_entry)) {
     }
-
     virtual void finish(int r) {
-      journal->handle_event_safe(r, tid);
+      journal->handle_replay_process_safe(replay_entry, r);
     }
   };
 
@@ -199,9 +231,7 @@ private:
     }
   };
 
-  ImageCtx &m_image_ctx;
-
-  ::journal::Journaler *m_journaler;
+  Journaler *m_journaler;
   mutable Mutex m_lock;
   State m_state;
 
@@ -215,42 +245,48 @@ private:
   uint64_t m_event_tid;
   Events m_events;
 
+  atomic_t m_op_tid;
+
   bool m_blocking_writes;
 
-  JournalReplay *m_journal_replay;
+  journal::Replay<ImageCtxT> *m_journal_replay;
 
-  ::journal::Future wait_event(Mutex &lock, uint64_t tid, Context *on_safe);
+  Future wait_event(Mutex &lock, uint64_t tid, Context *on_safe);
 
   void create_journaler();
   void destroy_journaler(int r);
   void recreate_journaler(int r);
 
-  void complete_event(Events::iterator it, int r);
+  void complete_event(typename Events::iterator it, int r);
 
   void handle_initialized(int r);
 
   void handle_replay_ready();
   void handle_replay_complete(int r);
+  void handle_replay_process_ready(int r);
+  void handle_replay_process_safe(ReplayEntry replay_entry, int r);
+
+  void handle_flushing_restart(int r);
+  void handle_flushing_replay(int r);
 
   void handle_recording_stopped(int r);
 
   void handle_journal_destroyed(int r);
 
-  void handle_event_safe(int r, uint64_t tid);
+  void handle_io_event_safe(int r, uint64_t tid);
+  void handle_op_event_safe(int r, uint64_t tid, const Future &future,
+                            Context *on_safe);
 
   void stop_recording();
 
-  void block_writes();
-  void unblock_writes();
-
   void transition_state(State state, int r);
 
   bool is_steady_state() const;
   void wait_for_steady_state(Context *on_state);
-
-  friend std::ostream &operator<<(std::ostream &os, const State &state);
 };
 
 } // namespace librbd
 
+extern template class librbd::Journal<librbd::ImageCtx>;
+
 #endif // CEPH_LIBRBD_JOURNAL_H
diff --git a/src/librbd/JournalReplay.cc b/src/librbd/JournalReplay.cc
deleted file mode 100644
index 3379f11..0000000
--- a/src/librbd/JournalReplay.cc
+++ /dev/null
@@ -1,192 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "librbd/JournalReplay.h"
-#include "librbd/AioCompletion.h"
-#include "librbd/AioImageRequest.h"
-#include "librbd/ImageCtx.h"
-#include "librbd/internal.h"
-
-#define dout_subsys ceph_subsys_rbd
-#undef dout_prefix
-#define dout_prefix *_dout << "librbd::JournalReplay: "
-
-namespace librbd {
-
-JournalReplay::JournalReplay(ImageCtx &image_ctx)
-  : m_image_ctx(image_ctx), m_lock("JournalReplay::m_lock"), m_ret_val(0) {
-}
-
-JournalReplay::~JournalReplay() {
-  assert(m_aio_completions.empty());
-}
-
-int JournalReplay::process(bufferlist::iterator it, Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << dendl;
-
-  RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
-  journal::EventEntry event_entry;
-  try {
-    ::decode(event_entry, it);
-  } catch (const buffer::error &err) {
-    lderr(cct) << "failed to decode event entry: " << err.what() << dendl;
-    return -EINVAL;
-  }
-
-  boost::apply_visitor(EventVisitor(this, on_safe), event_entry.event);
-  return 0;
-}
-
-int JournalReplay::flush() {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << dendl;
-
-  Mutex::Locker locker(m_lock);
-  while (!m_aio_completions.empty()) {
-    m_cond.Wait(m_lock);
-  }
-  return m_ret_val;
-}
-
-void JournalReplay::handle_event(const journal::AioDiscardEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": AIO discard event" << dendl;
-
-  AioCompletion *aio_comp = create_aio_completion(on_safe);
-  AioImageRequest::aio_discard(&m_image_ctx, aio_comp, event.offset,
-                               event.length);
-}
-
-void JournalReplay::handle_event(const journal::AioWriteEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": AIO write event" << dendl;
-
-  bufferlist data = event.data;
-  AioCompletion *aio_comp = create_aio_completion(on_safe);
-  AioImageRequest::aio_write(&m_image_ctx, aio_comp, event.offset, event.length,
-                             data.c_str(), 0);
-}
-
-void JournalReplay::handle_event(const journal::AioFlushEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": AIO flush event" << dendl;
-
-  AioCompletion *aio_comp = create_aio_completion(on_safe);
-  AioImageRequest::aio_flush(&m_image_ctx, aio_comp);
-}
-
-  void JournalReplay::handle_event(const journal::OpFinishEvent &event,
-				   Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Op finish event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::SnapCreateEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Snap create event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::SnapRemoveEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Snap remove event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::SnapRenameEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Snap rename event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::SnapProtectEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Snap protect event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::SnapUnprotectEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Snap unprotect event"
-                 << dendl;
-}
-
-void JournalReplay::handle_event(const journal::SnapRollbackEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Snap rollback start event"
-                 << dendl;
-}
-
-void JournalReplay::handle_event(const journal::RenameEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Rename event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::ResizeEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Resize start event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::FlattenEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": Flatten start event" << dendl;
-}
-
-void JournalReplay::handle_event(const journal::UnknownEvent &event,
-				 Context *on_safe) {
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": unknown event" << dendl;
-  on_safe->complete(0);
-}
-
-AioCompletion *JournalReplay::create_aio_completion(Context *on_safe) {
-  Mutex::Locker locker(m_lock);
-  AioCompletion *aio_comp = AioCompletion::create(this, aio_completion_callback,
-                                                  nullptr);
-  m_aio_completions.insert(std::pair<AioCompletion*,Context*>(
-			     aio_comp, on_safe));
-  return aio_comp;
-}
-
-void JournalReplay::handle_aio_completion(AioCompletion *aio_comp) {
-  Mutex::Locker locker(m_lock);
-
-  AioCompletions::iterator it = m_aio_completions.find(aio_comp);
-  assert(it != m_aio_completions.end());
-
-  int r = aio_comp->get_return_value();
-
-  CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 20) << this << " " << __func__ << ": aio_comp=" << aio_comp << ", "
-                 << "r=" << r << dendl;
-
-  Context *on_safe = it->second;
-  on_safe->complete(r);
-
-  if (r < 0 && m_ret_val == 0) {
-    m_ret_val = r;
-  }
-
-  m_aio_completions.erase(it);
-  if (m_aio_completions.empty())
-    m_cond.Signal();
-}
-
-void JournalReplay::aio_completion_callback(completion_t cb, void *arg) {
-  JournalReplay *journal_replay = reinterpret_cast<JournalReplay *>(arg);
-  AioCompletion *aio_comp = reinterpret_cast<AioCompletion *>(cb);
-
-  journal_replay->handle_aio_completion(aio_comp);
-  aio_comp->release();
-}
-
-} // namespace librbd
diff --git a/src/librbd/JournalReplay.h b/src/librbd/JournalReplay.h
deleted file mode 100644
index 6b5711a..0000000
--- a/src/librbd/JournalReplay.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_LIBRBD_JOURNAL_REPLAY_H
-#define CEPH_LIBRBD_JOURNAL_REPLAY_H
-
-#include "include/int_types.h"
-#include "include/buffer_fwd.h"
-#include "include/rbd/librbd.hpp"
-#include "common/Cond.h"
-#include "common/Mutex.h"
-#include "librbd/JournalTypes.h"
-#include <boost/variant.hpp>
-#include <map>
-
-namespace librbd {
-
-class AioCompletion;
-class ImageCtx;
-
-class JournalReplay {
-public:
-  JournalReplay(ImageCtx &image_ctx);
-  ~JournalReplay();
-
-  int process(bufferlist::iterator it, Context *on_safe = NULL);
-  int flush();
-
-private:
-  typedef std::map<AioCompletion*,Context*> AioCompletions;
-
-  struct EventVisitor : public boost::static_visitor<void> {
-    JournalReplay *journal_replay;
-    Context *on_safe;
-
-    EventVisitor(JournalReplay *_journal_replay, Context *_on_safe)
-      : journal_replay(_journal_replay), on_safe(_on_safe) {
-    }
-
-    template <typename Event>
-    inline void operator()(const Event &event) const {
-      journal_replay->handle_event(event, on_safe);
-    }
-  };
-
-  ImageCtx &m_image_ctx;
-
-  Mutex m_lock;
-  Cond m_cond;
-
-  AioCompletions m_aio_completions;
-  int m_ret_val;
-
-  void handle_event(const journal::AioDiscardEvent &event, Context *on_safe);
-  void handle_event(const journal::AioWriteEvent &event, Context *on_safe);
-  void handle_event(const journal::AioFlushEvent &event, Context *on_safe);
-  void handle_event(const journal::OpFinishEvent &event, Context *on_safe);
-  void handle_event(const journal::SnapCreateEvent &event, Context *on_safe);
-  void handle_event(const journal::SnapRemoveEvent &event, Context *on_safe);
-  void handle_event(const journal::SnapRenameEvent &event, Context *on_safe);
-  void handle_event(const journal::SnapProtectEvent &event, Context *on_safe);
-  void handle_event(const journal::SnapUnprotectEvent &event, Context *on_safe);
-  void handle_event(const journal::SnapRollbackEvent &event, Context *on_safe);
-  void handle_event(const journal::RenameEvent &event, Context *on_safe);
-  void handle_event(const journal::ResizeEvent &event, Context *on_safe);
-  void handle_event(const journal::FlattenEvent &event, Context *on_safe);
-  void handle_event(const journal::UnknownEvent &event, Context *on_safe);
-
-  AioCompletion *create_aio_completion(Context *on_safe);
-  void handle_aio_completion(AioCompletion *aio_comp);
-
-  static void aio_completion_callback(completion_t cb, void *arg);
-};
-
-} // namespace librbd
-
-#endif // CEPH_LIBRBD_JOURNAL_REPLAY_H
diff --git a/src/librbd/LibrbdAdminSocketHook.cc b/src/librbd/LibrbdAdminSocketHook.cc
index ca7d64a..719d656 100644
--- a/src/librbd/LibrbdAdminSocketHook.cc
+++ b/src/librbd/LibrbdAdminSocketHook.cc
@@ -57,19 +57,22 @@ LibrbdAdminSocketHook::LibrbdAdminSocketHook(ImageCtx *ictx) :
   admin_socket(ictx->cct->get_admin_socket()) {
 
   std::string command;
+  std::string imagename;
   int r;
 
-  command = "rbd cache flush " + ictx->name;
+  imagename = ictx->md_ctx.get_pool_name() + "/" + ictx->name;
+  command = "rbd cache flush " + imagename;
+
   r = admin_socket->register_command(command, command, this,
-				     "flush rbd image " + ictx->name +
+				     "flush rbd image " + imagename +
 				     " cache");
   if (r == 0) {
     commands[command] = new FlushCacheCommand(ictx);
   }
 
-  command = "rbd cache invalidate " + ictx->name;
+  command = "rbd cache invalidate " + imagename;
   r = admin_socket->register_command(command, command, this,
-				     "invalidate rbd image " + ictx->name +
+				     "invalidate rbd image " + imagename + 
 				     " cache");
   if (r == 0) {
     commands[command] = new InvalidateCacheCommand(ictx);
diff --git a/src/librbd/LibrbdWriteback.cc b/src/librbd/LibrbdWriteback.cc
index 763860b..7a02e6a 100644
--- a/src/librbd/LibrbdWriteback.cc
+++ b/src/librbd/LibrbdWriteback.cc
@@ -222,17 +222,19 @@ namespace librbd {
 			  objectx);
     uint64_t object_overlap = m_ictx->prune_parent_extents(objectx, overlap);
     bool may = object_overlap > 0;
-    ldout(m_ictx->cct, 10) << "may_copy_on_write " << oid << " " << read_off << "~" << read_len << " = " << may << dendl;
+    ldout(m_ictx->cct, 10) << "may_copy_on_write " << oid << " " << read_off
+			   << "~" << read_len << " = " << may << dendl;
     return may;
   }
 
   ceph_tid_t LibrbdWriteback::write(const object_t& oid,
-			       const object_locator_t& oloc,
-			       uint64_t off, uint64_t len,
-			       const SnapContext& snapc,
-			       const bufferlist &bl, utime_t mtime,
-			       uint64_t trunc_size, __u32 trunc_seq,
-			       ceph_tid_t journal_tid, Context *oncommit)
+				    const object_locator_t& oloc,
+				    uint64_t off, uint64_t len,
+				    const SnapContext& snapc,
+				    const bufferlist &bl,
+				    ceph::real_time mtime, uint64_t trunc_size,
+				    __u32 trunc_seq, ceph_tid_t journal_tid,
+				    Context *oncommit)
   {
     assert(m_ictx->owner_lock.is_locked());
     uint64_t object_no = oid_to_object_no(oid.name, m_ictx->object_prefix);
@@ -246,12 +248,12 @@ namespace librbd {
     assert(journal_tid == 0 || m_ictx->journal != NULL);
     if (journal_tid != 0) {
       m_ictx->journal->flush_event(
-        journal_tid, new C_WriteJournalCommit(m_ictx, oid.name, object_no, off,
-                                              bl, snapc, req_comp,
-                                              journal_tid));
+	journal_tid, new C_WriteJournalCommit(m_ictx, oid.name, object_no, off,
+					      bl, snapc, req_comp,
+					      journal_tid));
     } else {
-      AioObjectWrite *req = new AioObjectWrite(m_ictx, oid.name, object_no, off,
-                                               bl, snapc, req_comp);
+      AioObjectWrite *req = new AioObjectWrite(m_ictx, oid.name, object_no,
+					       off, bl, snapc, req_comp);
       req->send();
     }
     return ++m_tid;
@@ -259,7 +261,8 @@ namespace librbd {
 
 
   void LibrbdWriteback::overwrite_extent(const object_t& oid, uint64_t off,
-                                         uint64_t len, ceph_tid_t journal_tid) {
+					 uint64_t len,
+					 ceph_tid_t journal_tid) {
     typedef std::vector<std::pair<uint64_t,uint64_t> > Extents;
 
     assert(m_ictx->owner_lock.is_locked());
@@ -270,11 +273,11 @@ namespace librbd {
 
     Extents file_extents;
     Striper::extent_to_file(m_ictx->cct, &m_ictx->layout, object_no, off,
-                            len, file_extents);
+			    len, file_extents);
     for (Extents::iterator it = file_extents.begin();
-         it != file_extents.end(); ++it) {
+	 it != file_extents.end(); ++it) {
       m_ictx->journal->commit_io_event_extent(journal_tid, it->first,
-                                              it->second, 0);
+					      it->second, 0);
     }
   }
 
diff --git a/src/librbd/LibrbdWriteback.h b/src/librbd/LibrbdWriteback.h
index 11b46cf..d4cb341 100644
--- a/src/librbd/LibrbdWriteback.h
+++ b/src/librbd/LibrbdWriteback.h
@@ -27,19 +27,21 @@ namespace librbd {
 		      snapid_t snapid, bufferlist *pbl, uint64_t trunc_size,
 		      __u32 trunc_seq, int op_flags, Context *onfinish);
 
-    // Determine whether a read to this extent could be affected by a write-triggered copy-on-write
-    virtual bool may_copy_on_write(const object_t& oid, uint64_t read_off, uint64_t read_len, snapid_t snapid);
+    // Determine whether a read to this extent could be affected by a
+    // write-triggered copy-on-write
+    virtual bool may_copy_on_write(const object_t& oid, uint64_t read_off,
+				   uint64_t read_len, snapid_t snapid);
 
     // Note that oloc, trunc_size, and trunc_seq are ignored
     virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
-                             uint64_t off, uint64_t len,
-                             const SnapContext& snapc, const bufferlist &bl,
-                             utime_t mtime, uint64_t trunc_size,
-                             __u32 trunc_seq, ceph_tid_t journal_tid,
-                             Context *oncommit);
+			     uint64_t off, uint64_t len,
+			     const SnapContext& snapc, const bufferlist &bl,
+			     ceph::real_time mtime, uint64_t trunc_size,
+			     __u32 trunc_seq, ceph_tid_t journal_tid,
+			     Context *oncommit);
 
     virtual void overwrite_extent(const object_t& oid, uint64_t off,
-                                  uint64_t len, ceph_tid_t journal_tid);
+				  uint64_t len, ceph_tid_t journal_tid);
 
     virtual void get_client_lock();
     virtual void put_client_lock();
diff --git a/src/librbd/Makefile.am b/src/librbd/Makefile.am
index 153b69e..775d702 100644
--- a/src/librbd/Makefile.am
+++ b/src/librbd/Makefile.am
@@ -1,5 +1,5 @@
 librbd_types_la_SOURCES = \
-	librbd/JournalTypes.cc \
+	librbd/journal/Entries.cc \
 	librbd/WatchNotifyTypes.cc
 noinst_LTLIBRARIES += librbd_types.la
 
@@ -23,10 +23,10 @@ librbd_internal_la_SOURCES = \
 	librbd/ImageWatcher.cc \
 	librbd/internal.cc \
 	librbd/Journal.cc \
-	librbd/JournalReplay.cc \
 	librbd/LibrbdAdminSocketHook.cc \
 	librbd/LibrbdWriteback.cc \
 	librbd/ObjectMap.cc \
+	librbd/Operations.cc \
 	librbd/Utils.cc \
 	librbd/exclusive_lock/AcquireRequest.cc \
 	librbd/exclusive_lock/ReleaseRequest.cc \
@@ -35,6 +35,7 @@ librbd_internal_la_SOURCES = \
 	librbd/image/RefreshParentRequest.cc \
 	librbd/image/RefreshRequest.cc \
 	librbd/image/SetSnapRequest.cc \
+	librbd/journal/Replay.cc \
 	librbd/object_map/InvalidateRequest.cc \
 	librbd/object_map/LockRequest.cc \
 	librbd/object_map/Request.cc \
@@ -97,11 +98,10 @@ noinst_HEADERS += \
 	librbd/ImageWatcher.h \
 	librbd/internal.h \
 	librbd/Journal.h \
-	librbd/JournalReplay.h \
-	librbd/JournalTypes.h \
 	librbd/LibrbdAdminSocketHook.h \
 	librbd/LibrbdWriteback.h \
 	librbd/ObjectMap.h \
+	librbd/Operations.h \
 	librbd/parent_types.h \
 	librbd/SnapInfo.h \
 	librbd/TaskFinisher.h \
@@ -114,6 +114,8 @@ noinst_HEADERS += \
 	librbd/image/RefreshParentRequest.h \
 	librbd/image/RefreshRequest.h \
 	librbd/image/SetSnapRequest.h \
+	librbd/journal/Replay.h \
+	librbd/journal/Entries.h \
 	librbd/object_map/InvalidateRequest.h \
 	librbd/object_map/LockRequest.h \
 	librbd/object_map/Request.h \
diff --git a/src/librbd/Operations.cc b/src/librbd/Operations.cc
new file mode 100644
index 0000000..563c9de
--- /dev/null
+++ b/src/librbd/Operations.cc
@@ -0,0 +1,811 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "librbd/Operations.h"
+#include "common/dout.h"
+#include "common/errno.h"
+#include "librbd/ExclusiveLock.h"
+#include "librbd/ImageCtx.h"
+#include "librbd/ImageState.h"
+#include "librbd/ImageWatcher.h"
+#include "librbd/operation/FlattenRequest.h"
+#include "librbd/operation/RebuildObjectMapRequest.h"
+#include "librbd/operation/RenameRequest.h"
+#include "librbd/operation/ResizeRequest.h"
+#include "librbd/operation/SnapshotCreateRequest.h"
+#include "librbd/operation/SnapshotProtectRequest.h"
+#include "librbd/operation/SnapshotRemoveRequest.h"
+#include "librbd/operation/SnapshotRenameRequest.h"
+#include "librbd/operation/SnapshotRollbackRequest.h"
+#include "librbd/operation/SnapshotUnprotectRequest.h"
+#include <boost/bind.hpp>
+
+#define dout_subsys ceph_subsys_rbd
+#undef dout_prefix
+#define dout_prefix *_dout << "librbd::Operations: "
+
+namespace librbd {
+
+template <typename I>
+Operations<I>::Operations(I &image_ctx) : m_image_ctx(image_ctx) {
+}
+
+template <typename I>
+int Operations<I>::flatten(ProgressContext &prog_ctx) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << "flatten" << dendl;
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0) {
+    return r;
+  }
+
+  if (m_image_ctx.read_only) {
+    return -EROFS;
+  }
+
+  {
+    RWLock::RLocker parent_locker(m_image_ctx.parent_lock);
+    if (m_image_ctx.parent_md.spec.pool_id == -1) {
+      lderr(cct) << "image has no parent" << dendl;
+      return -EINVAL;
+    }
+  }
+
+  uint64_t request_id = m_async_request_seq.inc();
+  r = invoke_async_request("flatten", false,
+                           boost::bind(&Operations<I>::flatten, this,
+                                       boost::ref(prog_ctx), _1),
+                           boost::bind(&ImageWatcher::notify_flatten,
+                                       m_image_ctx.image_watcher, request_id,
+                                       boost::ref(prog_ctx)));
+
+  if (r < 0 && r != -EINVAL) {
+    return r;
+  }
+
+  notify_change();
+  ldout(cct, 20) << "flatten finished" << dendl;
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::flatten(ProgressContext &prog_ctx, Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  assert(m_image_ctx.exclusive_lock == nullptr ||
+         m_image_ctx.exclusive_lock->is_lock_owner());
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << "flatten" << dendl;
+
+  uint64_t object_size;
+  uint64_t overlap_objects;
+  ::SnapContext snapc;
+
+  {
+    uint64_t overlap;
+    RWLock::RLocker l(m_image_ctx.snap_lock);
+    RWLock::RLocker l2(m_image_ctx.parent_lock);
+
+    if (m_image_ctx.read_only) {
+      on_finish->complete(-EROFS);
+      return;
+    }
+
+    // can't flatten a non-clone
+    if (m_image_ctx.parent_md.spec.pool_id == -1) {
+      lderr(cct) << "image has no parent" << dendl;
+      on_finish->complete(-EINVAL);
+      return;
+    }
+    if (m_image_ctx.snap_id != CEPH_NOSNAP) {
+      lderr(cct) << "snapshots cannot be flattened" << dendl;
+      on_finish->complete(-EROFS);
+      return;
+    }
+
+    snapc = m_image_ctx.snapc;
+    assert(m_image_ctx.parent != NULL);
+    int r = m_image_ctx.get_parent_overlap(CEPH_NOSNAP, &overlap);
+    assert(r == 0);
+    assert(overlap <= m_image_ctx.size);
+
+    object_size = m_image_ctx.get_object_size();
+    overlap_objects = Striper::get_num_objects(m_image_ctx.layout, overlap);
+  }
+
+  operation::FlattenRequest<I> *req = new operation::FlattenRequest<I>(
+    m_image_ctx, on_finish, object_size, overlap_objects, snapc, prog_ctx);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::rebuild_object_map(ProgressContext &prog_ctx) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 10) << "rebuild_object_map" << dendl;
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0) {
+    return r;
+  }
+
+  uint64_t request_id = m_async_request_seq.inc();
+  r = invoke_async_request("rebuild object map", true,
+                           boost::bind(&Operations<I>::rebuild_object_map, this,
+                                       boost::ref(prog_ctx), _1),
+                           boost::bind(&ImageWatcher::notify_rebuild_object_map,
+                                       m_image_ctx.image_watcher, request_id,
+                                       boost::ref(prog_ctx)));
+
+  ldout(cct, 10) << "rebuild object map finished" << dendl;
+  if (r < 0) {
+    return r;
+  }
+
+  notify_change();
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::rebuild_object_map(ProgressContext &prog_ctx,
+                                       Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  assert(m_image_ctx.exclusive_lock == nullptr ||
+         m_image_ctx.exclusive_lock->is_lock_owner());
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+
+  if (m_image_ctx.read_only) {
+    on_finish->complete(-EROFS);
+    return;
+  }
+  if (!m_image_ctx.test_features(RBD_FEATURE_OBJECT_MAP)) {
+    on_finish->complete(-EINVAL);
+    return;
+  }
+
+  operation::RebuildObjectMapRequest<I> *req =
+    new operation::RebuildObjectMapRequest<I>(m_image_ctx, on_finish, prog_ctx);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::rename(const char *dstname) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": dest_name=" << dstname
+                << dendl;
+
+  int r = librbd::detect_format(m_image_ctx.md_ctx, dstname, NULL, NULL);
+  if (r < 0 && r != -ENOENT) {
+    lderr(cct) << "error checking for existing image called "
+               << dstname << ":" << cpp_strerror(r) << dendl;
+    return r;
+  }
+  if (r == 0) {
+    lderr(cct) << "rbd image " << dstname << " already exists" << dendl;
+    return -EEXIST;
+  }
+
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    r = invoke_async_request("rename", true,
+                             boost::bind(&Operations<I>::rename, this,
+                                         dstname, _1),
+                             boost::bind(&ImageWatcher::notify_rename,
+                                         m_image_ctx.image_watcher, dstname));
+    if (r < 0 && r != -EEXIST) {
+      return r;
+    }
+  } else {
+    RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+    C_SaferCond cond_ctx;
+    rename(dstname, &cond_ctx);
+
+    r = cond_ctx.wait();
+    if (r < 0) {
+      return r;
+    }
+  }
+
+  if (m_image_ctx.old_format) {
+    notify_change();
+  }
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::rename(const char *dstname, Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    assert(m_image_ctx.exclusive_lock == nullptr ||
+           m_image_ctx.exclusive_lock->is_lock_owner());
+  }
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": dest_name=" << dstname
+                << dendl;
+
+  operation::RenameRequest<I> *req =
+    new operation::RenameRequest<I>(m_image_ctx, on_finish, dstname);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::resize(uint64_t size, ProgressContext& prog_ctx) {
+  CephContext *cct = m_image_ctx.cct;
+
+  m_image_ctx.snap_lock.get_read();
+  ldout(cct, 5) << this << " " << __func__ << ": "
+                << "size=" << m_image_ctx.size << ", "
+                << "new_size=" << size << dendl;
+  m_image_ctx.snap_lock.put_read();
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0) {
+    return r;
+  }
+
+  uint64_t request_id = m_async_request_seq.inc();
+  r = invoke_async_request("resize", false,
+                           boost::bind(&Operations<I>::resize, this,
+                                       size, boost::ref(prog_ctx), _1, 0),
+                           boost::bind(&ImageWatcher::notify_resize,
+                                       m_image_ctx.image_watcher, request_id,
+                                       size, boost::ref(prog_ctx)));
+
+  m_image_ctx.perfcounter->inc(l_librbd_resize);
+  notify_change();
+  ldout(cct, 2) << "resize finished" << dendl;
+  return r;
+}
+
+template <typename I>
+void Operations<I>::resize(uint64_t size, ProgressContext &prog_ctx,
+                           Context *on_finish, uint64_t journal_op_tid) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  assert(m_image_ctx.exclusive_lock == nullptr ||
+         m_image_ctx.exclusive_lock->is_lock_owner());
+
+  CephContext *cct = m_image_ctx.cct;
+  m_image_ctx.snap_lock.get_read();
+  ldout(cct, 5) << this << " " << __func__ << ": "
+                << "size=" << m_image_ctx.size << ", "
+                << "new_size=" << size << dendl;
+  m_image_ctx.snap_lock.put_read();
+
+  {
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    if (m_image_ctx.snap_id != CEPH_NOSNAP || m_image_ctx.read_only) {
+      on_finish->complete(-EROFS);
+      return;
+    }
+  }
+
+  operation::ResizeRequest<I> *req = new operation::ResizeRequest<I>(
+    m_image_ctx, on_finish, size, prog_ctx, journal_op_tid, false);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::snap_create(const char *snap_name) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  if (m_image_ctx.read_only) {
+    return -EROFS;
+  }
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0)
+    return r;
+
+  {
+    RWLock::RLocker l(m_image_ctx.snap_lock);
+    if (m_image_ctx.get_snap_id(snap_name) != CEPH_NOSNAP) {
+      return -EEXIST;
+    }
+  }
+
+  r = invoke_async_request("snap_create", true,
+                           boost::bind(&Operations<I>::snap_create, this,
+                                       snap_name, _1, 0),
+                           boost::bind(&ImageWatcher::notify_snap_create,
+                                       m_image_ctx.image_watcher, snap_name));
+  if (r < 0 && r != -EEXIST) {
+    return r;
+  }
+
+  m_image_ctx.perfcounter->inc(l_librbd_snap_create);
+  notify_change();
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::snap_create(const char *snap_name, Context *on_finish,
+                                uint64_t journal_op_tid) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  assert(m_image_ctx.exclusive_lock == nullptr ||
+         m_image_ctx.exclusive_lock->is_lock_owner());
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  operation::SnapshotCreateRequest<I> *req =
+    new operation::SnapshotCreateRequest<I>(m_image_ctx, on_finish, snap_name,
+                                            journal_op_tid);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::snap_rollback(const char *snap_name,
+                                 ProgressContext& prog_ctx) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0)
+    return r;
+
+  RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
+  {
+    // need to drop snap_lock before invalidating cache
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    if (!m_image_ctx.snap_exists) {
+      return -ENOENT;
+    }
+
+    if (m_image_ctx.snap_id != CEPH_NOSNAP || m_image_ctx.read_only) {
+      return -EROFS;
+    }
+
+    uint64_t snap_id = m_image_ctx.get_snap_id(snap_name);
+    if (snap_id == CEPH_NOSNAP) {
+      lderr(cct) << "No such snapshot found." << dendl;
+      return -ENOENT;
+    }
+  }
+
+  r = prepare_image_update();
+  if (r < 0) {
+    return -EROFS;
+  }
+  if (m_image_ctx.exclusive_lock != nullptr &&
+      !m_image_ctx.exclusive_lock->is_lock_owner()) {
+    return -EROFS;
+  }
+
+  C_SaferCond cond_ctx;
+  snap_rollback(snap_name, prog_ctx, &cond_ctx);
+  r = cond_ctx.wait();
+  if (r < 0) {
+    return r;
+  }
+
+  m_image_ctx.perfcounter->inc(l_librbd_snap_rollback);
+  notify_change();
+  return r;
+}
+
+template <typename I>
+void Operations<I>::snap_rollback(const char *snap_name,
+                                  ProgressContext& prog_ctx,
+                                  Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  uint64_t snap_id;
+  uint64_t new_size;
+  {
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    snap_id = m_image_ctx.get_snap_id(snap_name);
+    if (snap_id == CEPH_NOSNAP) {
+      lderr(cct) << "No such snapshot found." << dendl;
+      on_finish->complete(-ENOENT);
+      return;
+    }
+
+    new_size = m_image_ctx.get_image_size(snap_id);
+  }
+
+  // async mode used for journal replay
+  operation::SnapshotRollbackRequest<I> *request =
+    new operation::SnapshotRollbackRequest<I>(m_image_ctx, on_finish, snap_name,
+                                              snap_id, new_size, prog_ctx);
+  request->send();
+}
+
+template <typename I>
+int Operations<I>::snap_remove(const char *snap_name) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  if (m_image_ctx.read_only)
+    return -EROFS;
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0)
+    return r;
+
+  bool proxy_op = false;
+  {
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    if (m_image_ctx.get_snap_id(snap_name) == CEPH_NOSNAP) {
+      return -ENOENT;
+    }
+    proxy_op = ((m_image_ctx.features & RBD_FEATURE_FAST_DIFF) != 0 ||
+                (m_image_ctx.features & RBD_FEATURE_JOURNALING) != 0);
+  }
+
+  if (proxy_op) {
+    r = invoke_async_request("snap_remove", true,
+                             boost::bind(&Operations<I>::snap_remove, this,
+                                         snap_name, _1),
+                             boost::bind(&ImageWatcher::notify_snap_remove,
+                                         m_image_ctx.image_watcher, snap_name));
+    if (r < 0 && r != -ENOENT) {
+      return r;
+    }
+  } else {
+    RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+    C_SaferCond cond_ctx;
+    snap_remove(snap_name, &cond_ctx);
+
+    r = cond_ctx.wait();
+    if (r < 0) {
+      return r;
+    }
+  }
+
+  m_image_ctx.perfcounter->inc(l_librbd_snap_remove);
+  notify_change();
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::snap_remove(const char *snap_name, Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  {
+    if ((m_image_ctx.features & RBD_FEATURE_FAST_DIFF) != 0) {
+      assert(m_image_ctx.exclusive_lock == nullptr ||
+             m_image_ctx.exclusive_lock->is_lock_owner());
+    }
+  }
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  uint64_t snap_id;
+  {
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    snap_id = m_image_ctx.get_snap_id(snap_name);
+    if (snap_id == CEPH_NOSNAP) {
+      lderr(m_image_ctx.cct) << "No such snapshot found." << dendl;
+      on_finish->complete(-ENOENT);
+      return;
+    }
+
+    bool is_protected;
+    int r = m_image_ctx.is_snap_protected(snap_id, &is_protected);
+    if (r < 0) {
+      on_finish->complete(r);
+      return;
+    } else if (is_protected) {
+      lderr(m_image_ctx.cct) << "snapshot is protected" << dendl;
+      on_finish->complete(-EBUSY);
+      return;
+    }
+  }
+
+  operation::SnapshotRemoveRequest<I> *req =
+    new operation::SnapshotRemoveRequest<I>(m_image_ctx, on_finish, snap_name,
+                                            snap_id);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::snap_rename(const char *srcname, const char *dstname) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": "
+                << "snap_name=" << srcname << ", "
+                << "new_snap_name=" << dstname << dendl;
+
+  snapid_t snap_id;
+  if (m_image_ctx.read_only) {
+    return -EROFS;
+  }
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0)
+    return r;
+
+  {
+    RWLock::RLocker l(m_image_ctx.snap_lock);
+    snap_id = m_image_ctx.get_snap_id(srcname);
+    if (snap_id == CEPH_NOSNAP) {
+      return -ENOENT;
+    }
+    if (m_image_ctx.get_snap_id(dstname) != CEPH_NOSNAP) {
+      return -EEXIST;
+    }
+  }
+
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    r = invoke_async_request("snap_rename", true,
+                             boost::bind(&Operations<I>::snap_rename, this,
+                                         snap_id, dstname, _1),
+                             boost::bind(&ImageWatcher::notify_snap_rename,
+                                         m_image_ctx.image_watcher, snap_id,
+                                         dstname));
+    if (r < 0 && r != -EEXIST) {
+      return r;
+    }
+  } else {
+    RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+    C_SaferCond cond_ctx;
+    snap_rename(snap_id, dstname, &cond_ctx);
+
+    r = cond_ctx.wait();
+    if (r < 0) {
+      return r;
+    }
+  }
+
+  m_image_ctx.perfcounter->inc(l_librbd_snap_rename);
+  notify_change();
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::snap_rename(const uint64_t src_snap_id,
+                                const char *dst_name, Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  if ((m_image_ctx.features & RBD_FEATURE_JOURNALING) != 0) {
+    assert(m_image_ctx.exclusive_lock == nullptr ||
+           m_image_ctx.exclusive_lock->is_lock_owner());
+  }
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": "
+                << "snap_id=" << src_snap_id << ", "
+                << "new_snap_name=" << dst_name << dendl;
+
+  operation::SnapshotRenameRequest<I> *req =
+    new operation::SnapshotRenameRequest<I>(m_image_ctx, on_finish, src_snap_id,
+                                            dst_name);
+  req->send();
+}
+
+template <typename I>
+int Operations<I>::snap_protect(const char *snap_name) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  if (m_image_ctx.read_only) {
+    return -EROFS;
+  }
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0) {
+    return r;
+  }
+
+  {
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    bool is_protected;
+    r = m_image_ctx.is_snap_protected(m_image_ctx.get_snap_id(snap_name),
+                                      &is_protected);
+    if (r < 0) {
+      return r;
+    }
+
+    if (is_protected) {
+      return -EBUSY;
+    }
+  }
+
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    r = invoke_async_request("snap_protect", true,
+                             boost::bind(&Operations<I>::snap_protect, this,
+                                         snap_name, _1),
+                             boost::bind(&ImageWatcher::notify_snap_protect,
+                                         m_image_ctx.image_watcher, snap_name));
+    if (r < 0 && r != -EBUSY) {
+      return r;
+    }
+  } else {
+    RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+    C_SaferCond cond_ctx;
+    snap_protect(snap_name, &cond_ctx);
+
+    r = cond_ctx.wait();
+    if (r < 0) {
+      return r;
+    }
+  }
+
+  notify_change();
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::snap_protect(const char *snap_name, Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    assert(m_image_ctx.exclusive_lock == nullptr ||
+           m_image_ctx.exclusive_lock->is_lock_owner());
+  }
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  operation::SnapshotProtectRequest<I> *request =
+    new operation::SnapshotProtectRequest<I>(m_image_ctx, on_finish, snap_name);
+  request->send();
+}
+
+template <typename I>
+int Operations<I>::snap_unprotect(const char *snap_name) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  if (m_image_ctx.read_only) {
+    return -EROFS;
+  }
+
+  int r = m_image_ctx.state->refresh_if_required();
+  if (r < 0) {
+    return r;
+  }
+
+  {
+    RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+    bool is_unprotected;
+    r = m_image_ctx.is_snap_unprotected(m_image_ctx.get_snap_id(snap_name),
+                                  &is_unprotected);
+    if (r < 0) {
+      return r;
+    }
+
+    if (is_unprotected) {
+      return -EINVAL;
+    }
+  }
+
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    r = invoke_async_request("snap_unprotect", true,
+                             boost::bind(&Operations<I>::snap_unprotect, this,
+                                         snap_name, _1),
+                             boost::bind(&ImageWatcher::notify_snap_unprotect,
+                                         m_image_ctx.image_watcher, snap_name));
+    if (r < 0 && r != -EINVAL) {
+      return r;
+    }
+  } else {
+    RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+    C_SaferCond cond_ctx;
+    snap_unprotect(snap_name, &cond_ctx);
+
+    r = cond_ctx.wait();
+    if (r < 0) {
+      return r;
+    }
+  }
+
+  notify_change();
+  return 0;
+}
+
+template <typename I>
+void Operations<I>::snap_unprotect(const char *snap_name, Context *on_finish) {
+  assert(m_image_ctx.owner_lock.is_locked());
+  if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
+    assert(m_image_ctx.exclusive_lock == nullptr ||
+           m_image_ctx.exclusive_lock->is_lock_owner());
+  }
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
+                << dendl;
+
+  operation::SnapshotUnprotectRequest<I> *request =
+    new operation::SnapshotUnprotectRequest<I>(m_image_ctx, on_finish,
+                                               snap_name);
+  request->send();
+}
+
+template <typename I>
+int Operations<I>::prepare_image_update() {
+  assert(m_image_ctx.owner_lock.is_locked() &&
+         !m_image_ctx.owner_lock.is_wlocked());
+  if (m_image_ctx.image_watcher == NULL) {
+    return -EROFS;
+  }
+
+  // need to upgrade to a write lock
+  int r = 0;
+  bool trying_lock = false;
+  C_SaferCond ctx;
+  m_image_ctx.owner_lock.put_read();
+  {
+    RWLock::WLocker owner_locker(m_image_ctx.owner_lock);
+    if (m_image_ctx.exclusive_lock != nullptr &&
+        !m_image_ctx.exclusive_lock->is_lock_owner()) {
+      m_image_ctx.exclusive_lock->try_lock(&ctx);
+      trying_lock = true;
+    }
+  }
+
+  if (trying_lock) {
+    r = ctx.wait();
+  }
+  m_image_ctx.owner_lock.get_read();
+
+  return r;
+}
+
+template <typename I>
+int Operations<I>::invoke_async_request(const std::string& request_type,
+                                        bool permit_snapshot,
+                                        const boost::function<void(Context*)>& local_request,
+                                        const boost::function<int()>& remote_request) {
+  CephContext *cct = m_image_ctx.cct;
+  int r;
+  do {
+    C_SaferCond ctx;
+    {
+      RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
+      {
+        RWLock::RLocker snap_locker(m_image_ctx.snap_lock);
+        if (m_image_ctx.read_only ||
+            (!permit_snapshot && m_image_ctx.snap_id != CEPH_NOSNAP)) {
+          return -EROFS;
+        }
+      }
+
+      while (m_image_ctx.exclusive_lock != nullptr) {
+        r = prepare_image_update();
+        if (r < 0) {
+          return -EROFS;
+        } else if (m_image_ctx.exclusive_lock->is_lock_owner()) {
+          break;
+        }
+
+        r = remote_request();
+        if (r != -ETIMEDOUT && r != -ERESTART) {
+          return r;
+        }
+        ldout(cct, 5) << request_type << " timed out notifying lock owner"
+                      << dendl;
+      }
+
+      local_request(&ctx);
+    }
+
+    r = ctx.wait();
+    if (r == -ERESTART) {
+      ldout(cct, 5) << request_type << " interrupted: restarting" << dendl;
+    }
+  } while (r == -ERESTART);
+  return r;
+}
+
+template <typename I>
+void Operations<I>::notify_change() {
+  m_image_ctx.state->handle_update_notification();
+  ImageWatcher::notify_header_update(m_image_ctx.md_ctx,
+                                     m_image_ctx.header_oid);
+}
+
+} // namespace librbd
+
+template class librbd::Operations<librbd::ImageCtx>;
diff --git a/src/librbd/Operations.h b/src/librbd/Operations.h
new file mode 100644
index 0000000..70eefde
--- /dev/null
+++ b/src/librbd/Operations.h
@@ -0,0 +1,75 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_LIBRBD_OPERATIONS_H
+#define CEPH_LIBRBD_OPERATIONS_H
+
+#include "include/int_types.h"
+#include "include/atomic.h"
+#include <string>
+#include <boost/function.hpp>
+
+class Context;
+
+namespace librbd {
+
+class ImageCtx;
+class ProgressContext;
+
+template <typename ImageCtxT = ImageCtx>
+class Operations {
+public:
+  Operations(ImageCtxT &image_ctx);
+
+  int flatten(ProgressContext &prog_ctx);
+  void flatten(ProgressContext &prog_ctx, Context *on_finish);
+
+  int rebuild_object_map(ProgressContext &prog_ctx);
+  void rebuild_object_map(ProgressContext &prog_ctx, Context *on_finish);
+
+  int rename(const char *dstname);
+  void rename(const char *dstname, Context *on_finish);
+
+  int resize(uint64_t size, ProgressContext& prog_ctx);
+  void resize(uint64_t size, ProgressContext &prog_ctx, Context *on_finish,
+              uint64_t journal_op_tid);
+
+  int snap_create(const char *snap_name);
+  void snap_create(const char *snap_name, Context *on_finish,
+                   uint64_t journal_op_tid);
+
+  int snap_rollback(const char *snap_name, ProgressContext& prog_ctx);
+  void snap_rollback(const char *snap_name, ProgressContext& prog_ctx,
+                     Context *on_finish);
+
+  int snap_remove(const char *snap_name);
+  void snap_remove(const char *snap_name, Context *on_finish);
+
+  int snap_rename(const char *srcname, const char *dstname);
+  void snap_rename(const uint64_t src_snap_id, const char *dst_name,
+                   Context *on_finish);
+
+  int snap_protect(const char *snap_name);
+  void snap_protect(const char *snap_name, Context *on_finish);
+
+  int snap_unprotect(const char *snap_name);
+  void snap_unprotect(const char *snap_name, Context *on_finish);
+
+  int prepare_image_update();
+
+private:
+  ImageCtxT &m_image_ctx;
+  atomic_t m_async_request_seq;
+
+  int invoke_async_request(const std::string& request_type,
+                           bool permit_snapshot,
+                           const boost::function<void(Context*)>& local_request,
+                           const boost::function<int()>& remote_request);
+  void notify_change();
+};
+
+} // namespace librbd
+
+extern template class librbd::Operations<librbd::ImageCtx>;
+
+#endif // CEPH_LIBRBD_OPERATIONS_H
diff --git a/src/librbd/exclusive_lock/AcquireRequest.h b/src/librbd/exclusive_lock/AcquireRequest.h
index 865b3c6..d7b717b 100644
--- a/src/librbd/exclusive_lock/AcquireRequest.h
+++ b/src/librbd/exclusive_lock/AcquireRequest.h
@@ -16,7 +16,7 @@ class Context;
 
 namespace librbd {
 
-class Journal;
+template <typename> class Journal;
 
 namespace exclusive_lock {
 
diff --git a/src/librbd/exclusive_lock/ReleaseRequest.h b/src/librbd/exclusive_lock/ReleaseRequest.h
index b23e6c7..056d4e7 100644
--- a/src/librbd/exclusive_lock/ReleaseRequest.h
+++ b/src/librbd/exclusive_lock/ReleaseRequest.h
@@ -13,7 +13,7 @@ class Context;
 namespace librbd {
 
 class ImageCtx;
-class Journal;
+template <typename> class Journal;
 
 namespace exclusive_lock {
 
diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc
index c06dc14..d58bced 100644
--- a/src/librbd/image/RefreshRequest.cc
+++ b/src/librbd/image/RefreshRequest.cc
@@ -460,7 +460,7 @@ Context *RefreshRequest<I>::send_v2_open_journal() {
     klass, &klass::handle_v2_open_journal>(this);
 
   // TODO need safe close
-  m_journal = new Journal(m_image_ctx);
+  m_journal = m_image_ctx.create_journal();
   m_journal->open(ctx);
   return nullptr;
 }
diff --git a/src/librbd/image/RefreshRequest.h b/src/librbd/image/RefreshRequest.h
index 25eda66..58451f5 100644
--- a/src/librbd/image/RefreshRequest.h
+++ b/src/librbd/image/RefreshRequest.h
@@ -18,10 +18,7 @@ class Context;
 
 namespace librbd {
 
-template <typename> class ExclusiveLock;
 class ImageCtx;
-class Journal;
-class ObjectMap;
 
 namespace image {
 
diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc
index 4172f45..eb77456 100644
--- a/src/librbd/internal.cc
+++ b/src/librbd/internal.cc
@@ -32,18 +32,9 @@
 #include "librbd/internal.h"
 #include "librbd/Journal.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/Operations.h"
 #include "librbd/parent_types.h"
 #include "librbd/Utils.h"
-#include "librbd/operation/FlattenRequest.h"
-#include "librbd/operation/RebuildObjectMapRequest.h"
-#include "librbd/operation/RenameRequest.h"
-#include "librbd/operation/ResizeRequest.h"
-#include "librbd/operation/SnapshotCreateRequest.h"
-#include "librbd/operation/SnapshotProtectRequest.h"
-#include "librbd/operation/SnapshotRemoveRequest.h"
-#include "librbd/operation/SnapshotRenameRequest.h"
-#include "librbd/operation/SnapshotRollbackRequest.h"
-#include "librbd/operation/SnapshotUnprotectRequest.h"
 #include "librbd/operation/TrimRequest.h"
 #include "include/util.h"
 
@@ -93,6 +84,7 @@ int remove_object_map(ImageCtx *ictx) {
   r = ictx->md_ctx.remove(ObjectMap::object_map_name(ictx->id, CEPH_NOSNAP));
   if (r < 0 && r != -ENOENT) {
     lderr(cct) << "failed to remove object map: " << cpp_strerror(r) << dendl;
+    return r;
   }
   return 0;
 }
@@ -126,7 +118,6 @@ int create_object_map(ImageCtx *ictx) {
   return 0;
 }
 
-
 int update_all_flags(ImageCtx *ictx, uint64_t flags, uint64_t mask) {
   assert(ictx->snap_lock.is_locked());
   CephContext *cct = ictx->cct;
@@ -151,79 +142,6 @@ int update_all_flags(ImageCtx *ictx, uint64_t flags, uint64_t mask) {
   return 0;
 }
 
-int prepare_image_update(ImageCtx *ictx) {
-  assert(ictx->owner_lock.is_locked() && !ictx->owner_lock.is_wlocked());
-  if (ictx->image_watcher == NULL) {
-    return -EROFS;
-  }
-
-  // need to upgrade to a write lock
-  int r = 0;
-  bool trying_lock = false;
-  C_SaferCond ctx;
-  ictx->owner_lock.put_read();
-  {
-    RWLock::WLocker owner_locker(ictx->owner_lock);
-    if (ictx->exclusive_lock != nullptr &&
-        !ictx->exclusive_lock->is_lock_owner()) {
-      ictx->exclusive_lock->try_lock(&ctx);
-      trying_lock = true;
-    }
-  }
-
-  if (trying_lock) {
-    r = ctx.wait();
-  }
-  ictx->owner_lock.get_read();
-
-  return r;
-}
-
-int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
-                         bool permit_snapshot,
-                         const boost::function<void(Context*)>& local_request,
-                         const boost::function<int()>& remote_request) {
-  int r;
-  do {
-    C_SaferCond ctx;
-    {
-      RWLock::RLocker l(ictx->owner_lock);
-      {
-        RWLock::RLocker snap_locker(ictx->snap_lock);
-        if (ictx->read_only ||
-            (!permit_snapshot && ictx->snap_id != CEPH_NOSNAP)) {
-          return -EROFS;
-        }
-      }
-
-      while (ictx->exclusive_lock != nullptr) {
-        r = prepare_image_update(ictx);
-        if (r < 0) {
-          return -EROFS;
-        } else if (ictx->exclusive_lock->is_lock_owner()) {
-          break;
-        }
-
-        r = remote_request();
-        if (r != -ETIMEDOUT && r != -ERESTART) {
-          return r;
-        }
-        ldout(ictx->cct, 5) << request_type << " timed out notifying lock owner"
-                            << dendl;
-      }
-
-      local_request(&ctx);
-    }
-
-    r = ctx.wait();
-    if (r == -ERESTART) {
-      ldout(ictx->cct, 5) << request_type << " interrupted: restarting"
-                          << dendl;
-    }
-  } while (r == -ERESTART);
-  return r;
-}
-
 int validate_pool(IoCtx &io_ctx, CephContext *cct) {
   if (!cct->_conf->rbd_validate_pool) {
     return 0;
@@ -350,7 +268,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
     C_SaferCond ctx;
     ictx->snap_lock.get_read();
-    operation::TrimRequest<> *req = new operation::TrimRequest<>(
+    operation::TrimRequest<> *req = operation::TrimRequest<>::create(
       *ictx, &ctx, ictx->size, newsize, prog_ctx);
     ictx->snap_lock.put_read();
     req->send();
@@ -676,8 +594,13 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     string last_read = "";
     do {
       map<string, string> images;
-      cls_client::dir_list(&io_ctx, RBD_DIRECTORY,
+      r = cls_client::dir_list(&io_ctx, RBD_DIRECTORY,
 			   last_read, max_read, &images);
+      if (r < 0) {
+        lderr(cct) << "error listing image in directory: " 
+                   << cpp_strerror(r) << dendl;   
+        return r;
+      }
       for (map<string, string>::const_iterator it = images.begin();
 	   it != images.end(); ++it) {
 	names.push_back(it->first);
@@ -710,7 +633,11 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     // search all pools for children depending on this snapshot
     Rados rados(ictx->md_ctx);
     std::list<std::pair<int64_t, string> > pools;
-    rados.pool_list2(pools);
+    r = rados.pool_list2(pools);
+    if (r < 0) {
+      lderr(cct) << "error listing pools: " << cpp_strerror(r) << dendl; 
+      return r;
+    }
 
     for (std::list<std::pair<int64_t, string> >::const_iterator it =
          pools.begin(); it != pools.end(); ++it) {
@@ -766,340 +693,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     return 0;
   }
 
-  int snap_create(ImageCtx *ictx, const char *snap_name)
-  {
-    ldout(ictx->cct, 20) << "snap_create " << ictx << " " << snap_name << dendl;
-
-    if (ictx->read_only) {
-      return -EROFS;
-    }
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0)
-      return r;
-
-    {
-      RWLock::RLocker l(ictx->snap_lock);
-      if (ictx->get_snap_id(snap_name) != CEPH_NOSNAP) {
-        return -EEXIST;
-      }
-    }
-
-    r = invoke_async_request(ictx, "snap_create", true,
-                             boost::bind(&snap_create_helper, ictx, _1,
-                                         snap_name),
-                             boost::bind(&ImageWatcher::notify_snap_create,
-                                         ictx->image_watcher, snap_name));
-    if (r < 0 && r != -EEXIST) {
-      return r;
-    }
-
-    ictx->perfcounter->inc(l_librbd_snap_create);
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    return 0;
-  }
-
-  void snap_create_helper(ImageCtx* ictx, Context* ctx, const char* snap_name) {
-    assert(ictx->owner_lock.is_locked());
-    assert(ictx->exclusive_lock == nullptr ||
-	   ictx->exclusive_lock->is_lock_owner());
-
-    ldout(ictx->cct, 20) << "snap_create_helper " << ictx << " " << snap_name
-                         << dendl;
-
-    operation::SnapshotCreateRequest<> *req =
-      new operation::SnapshotCreateRequest<>(*ictx, ctx, snap_name);
-    req->send();
-  }
-
-  int snap_remove(ImageCtx *ictx, const char *snap_name)
-  {
-    ldout(ictx->cct, 20) << "snap_remove " << ictx << " " << snap_name << dendl;
-
-    if (ictx->read_only)
-      return -EROFS;
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0)
-      return r;
-
-    bool proxy_op = false;
-    {
-      RWLock::RLocker snap_locker(ictx->snap_lock);
-      if (ictx->get_snap_id(snap_name) == CEPH_NOSNAP) {
-        return -ENOENT;
-      }
-      proxy_op = ((ictx->features & RBD_FEATURE_FAST_DIFF) != 0 ||
-                  (ictx->features & RBD_FEATURE_JOURNALING) != 0);
-    }
-
-    if (proxy_op) {
-      r = invoke_async_request(ictx, "snap_remove", true,
-                               boost::bind(&snap_remove_helper, ictx, _1,
-                                           snap_name),
-                               boost::bind(&ImageWatcher::notify_snap_remove,
-                                           ictx->image_watcher, snap_name));
-      if (r < 0 && r != -ENOENT) {
-        return r;
-      }
-    } else {
-      RWLock::RLocker owner_lock(ictx->owner_lock);
-      C_SaferCond cond_ctx;
-      snap_remove_helper(ictx, &cond_ctx, snap_name);
-
-      r = cond_ctx.wait();
-      if (r < 0) {
-        return r;
-      }
-    }
-
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-
-    ictx->perfcounter->inc(l_librbd_snap_remove);
-    return 0;
-  }
-
-  void snap_remove_helper(ImageCtx *ictx, Context *ctx, const char *snap_name)
-  {
-    assert(ictx->owner_lock.is_locked());
-    {
-      if ((ictx->features & RBD_FEATURE_FAST_DIFF) != 0) {
-        assert(ictx->exclusive_lock == nullptr ||
-	       ictx->exclusive_lock->is_lock_owner());
-      }
-    }
-
-    ldout(ictx->cct, 20) << "snap_remove_helper " << ictx << " " << snap_name
-                         << dendl;
-
-    uint64_t snap_id;
-    {
-      RWLock::RLocker snap_locker(ictx->snap_lock);
-      snap_id = ictx->get_snap_id(snap_name);
-      if (snap_id == CEPH_NOSNAP) {
-        lderr(ictx->cct) << "No such snapshot found." << dendl;
-        ctx->complete(-ENOENT);
-        return;
-      }
-
-      bool is_protected;
-      int r = ictx->is_snap_protected(snap_id, &is_protected);
-      if (r < 0) {
-        ctx->complete(r);
-        return;
-      } else if (is_protected) {
-        lderr(ictx->cct) << "snapshot is protected" << dendl;
-        ctx->complete(-EBUSY);
-        return;
-      }
-    }
-
-    operation::SnapshotRemoveRequest<> *req =
-      new operation::SnapshotRemoveRequest<>(*ictx, ctx, snap_name, snap_id);
-    req->send();
-  }
-
-  int snap_rename(ImageCtx *ictx, const char *srcname, const char *dstname)
-  {
-    ldout(ictx->cct, 20) << "snap_rename " << ictx << " from " << srcname << " to " << dstname << dendl;
-
-    snapid_t snap_id;
-    if (ictx->read_only) {
-      return -EROFS;
-    }
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0)
-      return r;
-
-    {
-      RWLock::RLocker l(ictx->snap_lock);
-      snap_id = ictx->get_snap_id(srcname);
-      if (snap_id == CEPH_NOSNAP) {
-        return -ENOENT;
-      }
-      if (ictx->get_snap_id(dstname) != CEPH_NOSNAP) {
-        return -EEXIST;
-      }
-    }
-
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      r = invoke_async_request(ictx, "snap_rename", true,
-                               boost::bind(&snap_rename_helper, ictx, _1,
-                                           snap_id, dstname),
-                               boost::bind(&ImageWatcher::notify_snap_rename,
-                                           ictx->image_watcher, snap_id,
-                                           dstname));
-      if (r < 0 && r != -EEXIST) {
-        return r;
-      }
-    } else {
-      RWLock::RLocker owner_lock(ictx->owner_lock);
-      C_SaferCond cond_ctx;
-      snap_rename_helper(ictx, &cond_ctx, snap_id, dstname);
-
-      r = cond_ctx.wait();
-      if (r < 0) {
-        return r;
-      }
-    }
-
-    ictx->perfcounter->inc(l_librbd_snap_rename);
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    return 0;
-  }
-
-  void snap_rename_helper(ImageCtx* ictx, Context* ctx,
-                          const uint64_t src_snap_id, const char* dst_name) {
-    assert(ictx->owner_lock.is_locked());
-    if ((ictx->features & RBD_FEATURE_JOURNALING) != 0) {
-      assert(ictx->exclusive_lock == nullptr ||
-	     ictx->exclusive_lock->is_lock_owner());
-    }
-    ldout(ictx->cct, 20) << __func__ << " " << ictx << " from "
-                         << src_snap_id << " to " << dst_name << dendl;
-
-    operation::SnapshotRenameRequest<> *req =
-      new operation::SnapshotRenameRequest<>(*ictx, ctx, src_snap_id, dst_name);
-    req->send();
-  }
-
-  int snap_protect(ImageCtx *ictx, const char *snap_name)
-  {
-    ldout(ictx->cct, 20) << "snap_protect " << ictx << " " << snap_name
-			 << dendl;
-
-    if (ictx->read_only) {
-      return -EROFS;
-    }
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0) {
-      return r;
-    }
-
-    {
-      RWLock::RLocker snap_locker(ictx->snap_lock);
-      bool is_protected;
-      r = ictx->is_snap_protected(ictx->get_snap_id(snap_name), &is_protected);
-      if (r < 0) {
-        return r;
-      }
-
-      if (is_protected) {
-        return -EBUSY;
-      }
-    }
-
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      r = invoke_async_request(ictx, "snap_protect", true,
-                               boost::bind(&snap_protect_helper, ictx, _1,
-                                           snap_name),
-                               boost::bind(&ImageWatcher::notify_snap_protect,
-                                           ictx->image_watcher, snap_name));
-      if (r < 0 && r != -EBUSY) {
-        return r;
-      }
-    } else {
-      RWLock::RLocker owner_lock(ictx->owner_lock);
-      C_SaferCond cond_ctx;
-      snap_protect_helper(ictx, &cond_ctx, snap_name);
-
-      r = cond_ctx.wait();
-      if (r < 0) {
-        return r;
-      }
-    }
-
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    return 0;
-  }
-
-  void snap_protect_helper(ImageCtx *ictx, Context* ctx, const char *snap_name)
-  {
-    assert(ictx->owner_lock.is_locked());
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      assert(ictx->exclusive_lock == nullptr ||
-	     ictx->exclusive_lock->is_lock_owner());
-    }
-
-    ldout(ictx->cct, 20) << "snap_protect_helper " << ictx << " " << snap_name
-                         << dendl;
-
-    operation::SnapshotProtectRequest<> *request =
-      new operation::SnapshotProtectRequest<>(*ictx, ctx, snap_name);
-    request->send();
-  }
-
-  int snap_unprotect(ImageCtx *ictx, const char *snap_name)
-  {
-    ldout(ictx->cct, 20) << "snap_unprotect " << ictx << " " << snap_name
-			 << dendl;
-
-    if (ictx->read_only) {
-      return -EROFS;
-    }
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0) {
-      return r;
-    }
-
-    {
-      RWLock::RLocker snap_locker(ictx->snap_lock);
-      bool is_unprotected;
-      r = ictx->is_snap_unprotected(ictx->get_snap_id(snap_name),
-                                    &is_unprotected);
-      if (r < 0) {
-        return r;
-      }
-
-      if (is_unprotected) {
-        return -EINVAL;
-      }
-    }
-
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      r = invoke_async_request(ictx, "snap_unprotect", true,
-                               boost::bind(&snap_unprotect_helper, ictx, _1,
-                                           snap_name),
-                               boost::bind(&ImageWatcher::notify_snap_unprotect,
-                                           ictx->image_watcher, snap_name));
-      if (r < 0 && r != -EINVAL) {
-        return r;
-      }
-    } else {
-      RWLock::RLocker owner_lock(ictx->owner_lock);
-      C_SaferCond cond_ctx;
-      snap_unprotect_helper(ictx, &cond_ctx, snap_name);
-
-      r = cond_ctx.wait();
-      if (r < 0) {
-        return r;
-      }
-    }
-
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    return 0;
-  }
-
-  void snap_unprotect_helper(ImageCtx *ictx, Context* ctx,
-                             const char *snap_name)
-  {
-    assert(ictx->owner_lock.is_locked());
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      assert(ictx->exclusive_lock == nullptr ||
-	     ictx->exclusive_lock->is_lock_owner());
-    }
-
-    ldout(ictx->cct, 20) << "snap_unprotect_helper " << ictx << " " << snap_name
-                         << dendl;
-
-    operation::SnapshotUnprotectRequest<> *request =
-      new operation::SnapshotUnprotectRequest<>(*ictx, ctx, snap_name);
-    request->send();
-  }
-
   int snap_is_protected(ImageCtx *ictx, const char *snap_name,
 			bool *is_protected)
   {
@@ -1156,7 +749,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       if (remove_r < 0) {
 	lderr(cct) << "Could not remove image from directory after "
 		   << "header creation failed: "
-		   << cpp_strerror(r) << dendl;
+		   << cpp_strerror(remove_r) << dendl;
       }
       return r;
     }
@@ -1268,8 +861,8 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
         goto err_remove_object_map;
       }
 
-      r = Journal::create(io_ctx, id, journal_order, journal_splay_width,
-			  journal_pool);
+      r = Journal<>::create(io_ctx, id, journal_order, journal_splay_width,
+			    journal_pool);
       if (r < 0) {
         lderr(cct) << "error creating journal: " << cpp_strerror(r) << dendl;
         goto err_remove_object_map;
@@ -1292,7 +885,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     remove_r = io_ctx.remove(header_oid);
     if (remove_r < 0) {
       lderr(cct) << "error cleaning up image header after creation failed: "
-		 << dendl;
+		 << cpp_strerror(remove_r) << dendl;
     }
   err_remove_from_dir:
     remove_r = cls_client::dir_remove_image(&io_ctx, RBD_DIRECTORY,
@@ -1399,8 +992,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
     if (!order)
       order = cct->_conf->rbd_default_order;
-    if (!order)
-      order = RBD_DEFAULT_OBJ_ORDER;
 
     if (order > 25 || order < 12) {
       lderr(cct) << "order must be in the range [12, 25]" << dendl;
@@ -1529,6 +1120,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     if (r < 0) {
       lderr(cct) << "error opening parent image: "
 		 << cpp_strerror(-r) << dendl;
+      delete p_imctx;
       return r;
     }
 
@@ -1544,7 +1136,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     p_imctx->snap_lock.get_read();
     p_features = p_imctx->features;
     size = p_imctx->get_image_size(p_imctx->snap_id);
-    p_imctx->is_snap_protected(p_imctx->snap_id, &snap_protected);
+    r = p_imctx->is_snap_protected(p_imctx->snap_id, &snap_protected);
     p_imctx->snap_lock.put_read();
 
     if ((p_features & RBD_FEATURE_LAYERING) != RBD_FEATURE_LAYERING) {
@@ -1552,6 +1144,12 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       r = -ENOSYS;
       goto err_close_parent;
     }
+    
+    if (r < 0) {
+      // we lost the race with snap removal?
+      lderr(cct) << "unable to locate parent's snapshot" << dendl;
+      goto err_close_parent;
+    }
 
     if (!snap_protected) {
       lderr(cct) << "parent snapshot must be protected" << dendl;
@@ -1574,6 +1172,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     r = c_imctx->state->open();
     if (r < 0) {
       lderr(cct) << "Error opening new image: " << cpp_strerror(r) << dendl;
+      delete c_imctx;
       goto err_remove;
     }
 
@@ -1603,7 +1202,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
     r = cls_client::metadata_list(&p_ioctx, p_imctx->header_oid, "", 0, &pairs);
     if (r < 0 && r != -EOPNOTSUPP && r != -EIO) {
-      lderr(cct) << "couldn't list metadata: " << r << dendl;
+      lderr(cct) << "couldn't list metadata: " << cpp_strerror(r) << dendl;
       goto err_remove_child;
     } else if (r == 0 && !pairs.empty()) {
       r = cls_client::metadata_set(&c_ioctx, c_imctx->header_oid, pairs);
@@ -1653,63 +1252,14 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     if (r < 0) {
       lderr(ictx->cct) << "error opening source image: " << cpp_strerror(r)
 		       << dendl;
+      delete ictx;
       return r;
     }
     BOOST_SCOPE_EXIT((ictx)) {
       ictx->state->close();
     } BOOST_SCOPE_EXIT_END
 
-    r = detect_format(io_ctx, dstname, NULL, NULL);
-    if (r < 0 && r != -ENOENT) {
-      lderr(cct) << "error checking for existing image called "
-		 << dstname << ":" << cpp_strerror(r) << dendl;
-      return r;
-    }
-    if (r == 0) {
-      lderr(cct) << "rbd image " << dstname << " already exists" << dendl;
-      return -EEXIST;
-    }
-
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      r = invoke_async_request(ictx, "rename", true,
-                               boost::bind(&rename_helper, ictx, _1,
-                                           dstname),
-                               boost::bind(&ImageWatcher::notify_rename,
-                                           ictx->image_watcher, dstname));
-      if (r < 0 && r != -EEXIST) {
-        return r;
-      }
-    } else {
-      RWLock::RLocker owner_lock(ictx->owner_lock);
-      C_SaferCond cond_ctx;
-      rename_helper(ictx, &cond_ctx, dstname);
-
-      r = cond_ctx.wait();
-      if (r < 0) {
-        return r;
-      }
-    }
-
-    if (ictx->old_format) {
-      notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    }
-    return 0;
-  }
-
-  void rename_helper(ImageCtx *ictx, Context *ctx, const char *dstname)
-  {
-    assert(ictx->owner_lock.is_locked());
-    if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
-      assert(ictx->exclusive_lock == nullptr ||
-	     ictx->exclusive_lock->is_lock_owner());
-    }
-
-    ldout(ictx->cct, 20) << "rename_helper " << ictx << " " << dstname
-                         << dendl;
-
-    operation::RenameRequest<> *req =
-      new operation::RenameRequest<>(*ictx, ctx, dstname);
-    req->send();
+    return ictx->operations->rename(dstname);
   }
 
   int info(ImageCtx *ictx, image_info_t& info, size_t infosize)
@@ -1826,9 +1376,9 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
           }
           features_mask |= RBD_FEATURE_EXCLUSIVE_LOCK;
 
-          r = Journal::create(ictx->md_ctx, ictx->id, ictx->journal_order,
-  			    ictx->journal_splay_width,
-  			    ictx->journal_pool);
+          r = Journal<>::create(ictx->md_ctx, ictx->id, ictx->journal_order,
+  			        ictx->journal_splay_width,
+  			        ictx->journal_pool);
           if (r < 0) {
             lderr(cct) << "error creating image journal: " << cpp_strerror(r)
                        << dendl;
@@ -1868,7 +1418,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
           disable_flags = RBD_FLAG_FAST_DIFF_INVALID;
         }
         if ((features & RBD_FEATURE_JOURNALING) != 0) {
-          r = Journal::remove(ictx->md_ctx, ictx->id);
+          r = Journal<>::remove(ictx->md_ctx, ictx->id);
           if (r < 0) {
             lderr(cct) << "error removing image journal: " << cpp_strerror(r)
                        << dendl;
@@ -1933,13 +1483,11 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     parent_spec parent_spec;
 
     if (ictx->snap_id == CEPH_NOSNAP) {
-      if (!ictx->parent)
-	return -ENOENT;
       parent_spec = ictx->parent_md.spec;
     } else {
       r = ictx->get_parent_spec(ictx->snap_id, &parent_spec);
       if (r < 0) {
-	lderr(ictx->cct) << "Can't find snapshot id" << ictx->snap_id << dendl;
+	lderr(ictx->cct) << "Can't find snapshot id = " << ictx->snap_id << dendl;
 	return r;
       }
       if (parent_spec.pool_id == -1)
@@ -1950,7 +1498,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       r = rados.pool_reverse_lookup(parent_spec.pool_id,
 				    parent_pool_name);
       if (r < 0) {
-	lderr(ictx->cct) << "error looking up pool name" << cpp_strerror(r)
+	lderr(ictx->cct) << "error looking up pool name: " << cpp_strerror(r)
 			 << dendl;
 	return r;
       }
@@ -2026,6 +1574,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     int r = ictx->state->open();
     if (r < 0) {
       ldout(cct, 2) << "error opening image: " << cpp_strerror(-r) << dendl;
+      delete ictx;
     } else {
       string header_oid = ictx->header_oid;
       old_format = ictx->old_format;
@@ -2034,7 +1583,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
       ictx->owner_lock.get_read();
       if (ictx->exclusive_lock != nullptr) {
-        r = prepare_image_update(ictx);
+        r = ictx->operations->prepare_image_update();
         if (r < 0 || !ictx->exclusive_lock->is_lock_owner()) {
 	  lderr(cct) << "cannot obtain exclusive lock - not removing" << dendl;
 	  ictx->owner_lock.put_read();
@@ -2105,7 +1654,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       }
     }
     if (!old_format) {
-      r = Journal::remove(io_ctx, id);
+      r = Journal<>::remove(io_ctx, id);
       if (r < 0 && r != -ENOENT) {
         lderr(cct) << "error removing image journal" << dendl;
         return r;
@@ -2145,60 +1694,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     return 0;
   }
 
-  int resize(ImageCtx *ictx, uint64_t size, ProgressContext& prog_ctx)
-  {
-    CephContext *cct = ictx->cct;
-
-    ictx->snap_lock.get_read();
-    ldout(cct, 20) << "resize " << ictx << " " << ictx->size << " -> "
-		   << size << dendl;
-    ictx->snap_lock.put_read();
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0) {
-      return r;
-    }
-
-    uint64_t request_id = ictx->async_request_seq.inc();
-    r = invoke_async_request(ictx, "resize", false,
-                             boost::bind(&async_resize, ictx, _1, size,
-                                         boost::ref(prog_ctx)),
-                             boost::bind(&ImageWatcher::notify_resize,
-                                         ictx->image_watcher, request_id, size,
-                                         boost::ref(prog_ctx)));
-
-    ictx->perfcounter->inc(l_librbd_resize);
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    ldout(cct, 2) << "resize finished" << dendl;
-    return r;
-  }
-
-  void async_resize(ImageCtx *ictx, Context *ctx, uint64_t size,
-                    ProgressContext &prog_ctx)
-  {
-    assert(ictx->owner_lock.is_locked());
-    assert(ictx->exclusive_lock == nullptr ||
-	   ictx->exclusive_lock->is_lock_owner());
-
-    CephContext *cct = ictx->cct;
-    ictx->snap_lock.get_read();
-    ldout(cct, 20) << "async_resize " << ictx << " " << ictx->size << " -> "
-		   << size << dendl;
-    ictx->snap_lock.put_read();
-
-    {
-      RWLock::RLocker snap_locker(ictx->snap_lock);
-      if (ictx->snap_id != CEPH_NOSNAP || ictx->read_only) {
-        ctx->complete(-EROFS);
-        return;
-      }
-    }
-
-    operation::ResizeRequest<> *req = new operation::ResizeRequest<>(
-      *ictx, ctx, size, prog_ctx);
-    req->send();
-  }
-
   int snap_list(ImageCtx *ictx, vector<snap_info_t>& snaps)
   {
     ldout(ictx->cct, 20) << "snap_list " << ictx << dendl;
@@ -2220,7 +1715,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     return 0;
   }
 
-  bool snap_exists(ImageCtx *ictx, const char *snap_name)
+  int snap_exists(ImageCtx *ictx, const char *snap_name, bool *exists)
   {
     ldout(ictx->cct, 20) << "snap_exists " << ictx << " " << snap_name << dendl;
 
@@ -2229,86 +1724,8 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       return r;
 
     RWLock::RLocker l(ictx->snap_lock);
-    return ictx->get_snap_id(snap_name) != CEPH_NOSNAP;
-  }
-
-  int snap_rollback(ImageCtx *ictx, const char *snap_name,
-		    ProgressContext& prog_ctx)
-  {
-    CephContext *cct = ictx->cct;
-    ldout(cct, 20) << "snap_rollback " << ictx << " snap = " << snap_name
-		   << dendl;
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0)
-      return r;
-
-    RWLock::RLocker owner_locker(ictx->owner_lock);
-    snap_t snap_id;
-    uint64_t new_size;
-    {
-      {
-	// need to drop snap_lock before invalidating cache
-	RWLock::RLocker snap_locker(ictx->snap_lock);
-	if (!ictx->snap_exists) {
-	  return -ENOENT;
-	}
-
-	if (ictx->snap_id != CEPH_NOSNAP || ictx->read_only) {
-	  return -EROFS;
-	}
-
-	snap_id = ictx->get_snap_id(snap_name);
-	if (snap_id == CEPH_NOSNAP) {
-	  lderr(cct) << "No such snapshot found." << dendl;
-	  return -ENOENT;
-	}
-      }
-
-      r = prepare_image_update(ictx);
-      if (r < 0) {
-	return -EROFS;
-      }
-      if (ictx->exclusive_lock != nullptr &&
-	  !ictx->exclusive_lock->is_lock_owner()) {
-	return -EROFS;
-      }
-
-      ictx->snap_lock.get_read();
-      if (ictx->journal != NULL) {
-        C_SaferCond journal_ctx;
-        ictx->journal->wait_for_journal_ready(&journal_ctx);
-
-        ictx->snap_lock.put_read();
-        r = journal_ctx.wait();
-        if (r < 0) {
-          lderr(cct) << "Failed to initialize journal: " << cpp_strerror(r)
-                     << dendl;
-          return r;
-        }
-
-        ictx->snap_lock.get_read();
-      }
-
-      new_size = ictx->get_image_size(snap_id);
-      ictx->snap_lock.put_read();
-    }
-
-    // TODO need to wait for journal replay to complete (if enabled)
-    C_SaferCond cond_ctx;
-    operation::SnapshotRollbackRequest<> *request =
-      new operation::SnapshotRollbackRequest<>(*ictx, &cond_ctx, snap_name,
-                                               snap_id, new_size, prog_ctx);
-    request->send();
-    r = cond_ctx.wait();
-    if (r < 0) {
-      return r;
-    }
-
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-
-    ictx->perfcounter->inc(l_librbd_snap_rollback);
-    return r;
+    *exists = ictx->get_snap_id(snap_name) != CEPH_NOSNAP; 
+    return 0;
   }
 
   struct CopyProgressCtx {
@@ -2368,6 +1785,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 					  dest_md_ctx, false);
     r = dest->state->open();
     if (r < 0) {
+      delete dest;
       lderr(cct) << "failed to read newly created header" << dendl;
       return r;
     }
@@ -2444,7 +1862,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
     CephContext *cct = src->cct;
     if (dest_size < src_size) {
-      lderr(cct) << " src size " << src_size << " >= dest size "
+      lderr(cct) << " src size " << src_size << " > dest size "
 		 << dest_size << dendl;
       return -EINVAL;
     }
@@ -2453,12 +1871,12 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
     r = cls_client::metadata_list(&src->md_ctx, src->header_oid, "", 0, &pairs);
     if (r < 0 && r != -EOPNOTSUPP && r != -EIO) {
-      lderr(cct) << "couldn't list metadata: " << r << dendl;
+      lderr(cct) << "couldn't list metadata: " << cpp_strerror(r) << dendl;
       return r;
     } else if (r == 0 && !pairs.empty()) {
       r = cls_client::metadata_set(&dest->md_ctx, dest->header_oid, pairs);
       if (r < 0) {
-        lderr(cct) << "couldn't set metadata: " << r << dendl;
+        lderr(cct) << "couldn't set metadata: " << cpp_strerror(r) << dendl;
         return r;
       }
     }
@@ -2476,8 +1894,8 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       bufferlist *bl = new bufferlist();
       Context *ctx = new C_CopyRead(&throttle, dest, offset, bl);
       AioCompletion *comp = AioCompletion::create(ctx);
-      AioImageRequest::aio_read(src, comp, offset, len, NULL, bl,
-                                fadvise_flags);
+      AioImageRequest<>::aio_read(src, comp, offset, len, NULL, bl,
+                                  fadvise_flags);
       prog_ctx.update_progress(offset, src_size);
     }
 
@@ -2512,143 +1930,6 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     return 0;
   }
 
-  // 'flatten' child image by copying all parent's blocks
-  int flatten(ImageCtx *ictx, ProgressContext &prog_ctx)
-  {
-    CephContext *cct = ictx->cct;
-    ldout(cct, 20) << "flatten" << dendl;
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0) {
-      return r;
-    }
-
-    if (ictx->read_only) {
-      return -EROFS;
-    }
-
-    {
-      RWLock::RLocker parent_locker(ictx->parent_lock);
-      if (ictx->parent_md.spec.pool_id == -1) {
-	lderr(cct) << "image has no parent" << dendl;
-	return -EINVAL;
-      }
-    }
-
-    uint64_t request_id = ictx->async_request_seq.inc();
-    r = invoke_async_request(ictx, "flatten", false,
-                             boost::bind(&async_flatten, ictx, _1,
-                                         boost::ref(prog_ctx)),
-                             boost::bind(&ImageWatcher::notify_flatten,
-                                         ictx->image_watcher, request_id,
-                                         boost::ref(prog_ctx)));
-
-    if (r < 0 && r != -EINVAL) {
-      return r;
-    }
-
-    notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    ldout(cct, 20) << "flatten finished" << dendl;
-    return 0;
-  }
-
-  void async_flatten(ImageCtx *ictx, Context *ctx, ProgressContext &prog_ctx)
-  {
-    assert(ictx->owner_lock.is_locked());
-    assert(ictx->exclusive_lock == nullptr ||
-	   ictx->exclusive_lock->is_lock_owner());
-
-    CephContext *cct = ictx->cct;
-    ldout(cct, 20) << "flatten" << dendl;
-
-    uint64_t object_size;
-    uint64_t overlap_objects;
-    ::SnapContext snapc;
-
-    {
-      uint64_t overlap;
-      RWLock::RLocker l(ictx->snap_lock);
-      RWLock::RLocker l2(ictx->parent_lock);
-
-      if (ictx->read_only) {
-        ctx->complete(-EROFS);
-        return;
-      }
-
-      // can't flatten a non-clone
-      if (ictx->parent_md.spec.pool_id == -1) {
-	lderr(cct) << "image has no parent" << dendl;
-        ctx->complete(-EINVAL);
-	return;
-      }
-      if (ictx->snap_id != CEPH_NOSNAP) {
-	lderr(cct) << "snapshots cannot be flattened" << dendl;
-        ctx->complete(-EROFS);
-	return;
-      }
-
-      snapc = ictx->snapc;
-      assert(ictx->parent != NULL);
-      int r = ictx->get_parent_overlap(CEPH_NOSNAP, &overlap);
-      assert(r == 0);
-      assert(overlap <= ictx->size);
-
-      object_size = ictx->get_object_size();
-      overlap_objects = Striper::get_num_objects(ictx->layout, overlap);
-    }
-
-    operation::FlattenRequest<> *req = new operation::FlattenRequest<>(
-      *ictx, ctx, object_size, overlap_objects, snapc, prog_ctx);
-    req->send();
-  }
-
-  int rebuild_object_map(ImageCtx *ictx, ProgressContext &prog_ctx) {
-    CephContext *cct = ictx->cct;
-    ldout(cct, 10) << "rebuild_object_map" << dendl;
-
-    int r = ictx->state->refresh_if_required();
-    if (r < 0) {
-      return r;
-    }
-
-    uint64_t request_id = ictx->async_request_seq.inc();
-    r = invoke_async_request(ictx, "rebuild object map", true,
-                             boost::bind(&async_rebuild_object_map, ictx, _1,
-                                         boost::ref(prog_ctx)),
-                             boost::bind(&ImageWatcher::notify_rebuild_object_map,
-                                         ictx->image_watcher, request_id,
-                                         boost::ref(prog_ctx)));
-
-    ldout(cct, 10) << "rebuild object map finished" << dendl;
-    if (r < 0) {
-      notify_change(ictx->md_ctx, ictx->header_oid, ictx);
-    }
-    return r;
-  }
-
-  void async_rebuild_object_map(ImageCtx *ictx, Context *ctx,
-                                ProgressContext &prog_ctx) {
-    assert(ictx->owner_lock.is_locked());
-    assert(ictx->exclusive_lock == nullptr ||
-	   ictx->exclusive_lock->is_lock_owner());
-
-    CephContext *cct = ictx->cct;
-    ldout(cct, 20) << "async_rebuild_object_map " << ictx << dendl;
-
-    if (ictx->read_only) {
-      ctx->complete(-EROFS);
-      return;
-    }
-    if (!ictx->test_features(RBD_FEATURE_OBJECT_MAP)) {
-      ctx->complete(-EINVAL);
-      return;
-    }
-
-    operation::RebuildObjectMapRequest<> *req =
-      new operation::RebuildObjectMapRequest<>(*ictx, ctx, prog_ctx);
-    req->send();
-  }
-
   int list_lockers(ImageCtx *ictx,
 		   std::list<locker_t> *lockers,
 		   bool *exclusive,
@@ -2838,7 +2119,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
       C_SaferCond ctx;
       AioCompletion *c = AioCompletion::create(&ctx);
-      AioImageRequest::aio_read(ictx, c, off, read_len, NULL, &bl, 0);
+      AioImageRequest<>::aio_read(ictx, c, off, read_len, NULL, &bl, 0);
 
       int ret = ctx.wait();
       if (ret < 0) {
@@ -3178,17 +2459,20 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 	 ++p) {
       total_bytes += p->second;
     }
+    
     ictx->md_lock.get_write();
     bool abort = ictx->readahead_disable_after_bytes != 0 &&
       ictx->total_bytes_read > ictx->readahead_disable_after_bytes;
+    if (abort) {
+      ictx->md_lock.put_write();
+      return;
+    }
     ictx->total_bytes_read += total_bytes;
     ictx->snap_lock.get_read();
     uint64_t image_size = ictx->get_image_size(ictx->snap_id);
     ictx->snap_lock.put_read();
     ictx->md_lock.put_write();
-    if (abort) {
-      return;
-    }
+    
     pair<uint64_t, uint64_t> readahead_extent = ictx->readahead.update(image_extents, image_size);
     uint64_t readahead_offset = readahead_extent.first;
     uint64_t readahead_length = readahead_extent.second;
diff --git a/src/librbd/internal.h b/src/librbd/internal.h
index 81368a8..9fac1c1 100644
--- a/src/librbd/internal.h
+++ b/src/librbd/internal.h
@@ -47,10 +47,6 @@ enum {
   l_librbd_last,
 };
 
-class Context;
-class RWLock;
-class SimpleThrottle;
-
 namespace librbd {
 
   struct AioCompletion;
@@ -107,7 +103,6 @@ namespace librbd {
   int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name,
 	    IoCtx& c_ioctx, const char *c_name, ImageOptions& c_opts);
   int rename(librados::IoCtx& io_ctx, const char *srcname, const char *dstname);
-  void rename_helper(ImageCtx *ictx, Context *ctx, const char *dstname);
   int info(ImageCtx *ictx, image_info_t& info, size_t image_size);
   int get_old_format(ImageCtx *ictx, uint8_t *old);
   int get_size(ImageCtx *ictx, uint64_t *size);
@@ -122,33 +117,14 @@ namespace librbd {
 
   int remove(librados::IoCtx& io_ctx, const char *imgname,
 	     ProgressContext& prog_ctx);
-  int resize(ImageCtx *ictx, uint64_t size, ProgressContext& prog_ctx);
-  int snap_create(ImageCtx *ictx, const char *snap_name);
-  void snap_create_helper(ImageCtx *ictx, Context* ctx, const char *snap_name);
   int snap_list(ImageCtx *ictx, std::vector<snap_info_t>& snaps);
-  bool snap_exists(ImageCtx *ictx, const char *snap_name);
-  int snap_rollback(ImageCtx *ictx, const char *snap_name,
-		    ProgressContext& prog_ctx);
-  int snap_remove(ImageCtx *ictx, const char *snap_name);
-  void snap_remove_helper(ImageCtx *ictx, Context* ctx, const char *snap_name);
-  int snap_rename(ImageCtx *ictx, const char *srcname, const char *dstname);
-  void snap_rename_helper(ImageCtx *ictx, Context* ctx,
-                          const uint64_t src_snap_id, const char *dst_name);
-  int snap_protect(ImageCtx *ictx, const char *snap_name);
-  void snap_protect_helper(ImageCtx *ictx, Context* ctx, const char *snap_name);
-  int snap_unprotect(ImageCtx *ictx, const char *snap_name);
-  void snap_unprotect_helper(ImageCtx *ictx, Context* ctx,
-                             const char *snap_name);
+  int snap_exists(ImageCtx *ictx, const char *snap_name, bool *exists);
   int snap_is_protected(ImageCtx *ictx, const char *snap_name,
 			bool *is_protected);
   int copy(ImageCtx *ictx, IoCtx& dest_md_ctx, const char *destname,
 	   ImageOptions& opts, ProgressContext &prog_ctx);
   int copy(ImageCtx *src, ImageCtx *dest, ProgressContext &prog_ctx);
 
-  int flatten(ImageCtx *ictx, ProgressContext &prog_ctx);
-
-  int rebuild_object_map(ImageCtx *ictx, ProgressContext &prog_ctx);
-
   /* cooperative locking */
   int list_lockers(ImageCtx *ictx,
 		   std::list<locker_t> *locks,
@@ -189,12 +165,6 @@ namespace librbd {
   void readahead(ImageCtx *ictx,
                  const vector<pair<uint64_t,uint64_t> >& image_extents);
 
-  void async_flatten(ImageCtx *ictx, Context *ctx, ProgressContext &prog_ctx);
-  void async_resize(ImageCtx *ictx, Context *ctx, uint64_t size,
-                    ProgressContext &prog_ctx);
-  void async_rebuild_object_map(ImageCtx *ictx, Context *ctx,
-                                ProgressContext &prog_ctx);
-
   int flush(ImageCtx *ictx);
   int invalidate_cache(ImageCtx *ictx);
   int poll_io_events(ImageCtx *ictx, AioCompletion **comps, int numcomp);
diff --git a/src/librbd/JournalTypes.cc b/src/librbd/journal/Entries.cc
similarity index 86%
rename from src/librbd/JournalTypes.cc
rename to src/librbd/journal/Entries.cc
index cda35aa..be350af 100644
--- a/src/librbd/JournalTypes.cc
+++ b/src/librbd/journal/Entries.cc
@@ -1,7 +1,7 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
 #include "include/assert.h"
 #include "include/stringify.h"
 #include "common/Formatter.h"
@@ -106,29 +106,47 @@ void AioFlushEvent::dump(Formatter *f) const {
 }
 
 void OpEventBase::encode(bufferlist& bl) const {
-  ::encode(tid, bl);
+  ::encode(op_tid, bl);
 }
 
 void OpEventBase::decode(__u8 version, bufferlist::iterator& it) {
-  ::decode(tid, it);
+  ::decode(op_tid, it);
 }
 
 void OpEventBase::dump(Formatter *f) const {
-  f->dump_unsigned("tid", tid);
+  f->dump_unsigned("op_tid", op_tid);
+}
+
+void OpFinishEvent::encode(bufferlist& bl) const {
+  OpEventBase::encode(bl);
+  ::encode(op_tid, bl);
+  ::encode(r, bl);
+}
+
+void OpFinishEvent::decode(__u8 version, bufferlist::iterator& it) {
+  OpEventBase::decode(version, it);
+  ::decode(op_tid, it);
+  ::decode(r, it);
+}
+
+void OpFinishEvent::dump(Formatter *f) const {
+  OpEventBase::dump(f);
+  f->dump_unsigned("op_tid", op_tid);
+  f->dump_int("result", r);
 }
 
 void SnapEventBase::encode(bufferlist& bl) const {
-  OpStartEventBase::encode(bl);
+  OpEventBase::encode(bl);
   ::encode(snap_name, bl);
 }
 
 void SnapEventBase::decode(__u8 version, bufferlist::iterator& it) {
-  OpStartEventBase::decode(version, it);
+  OpEventBase::decode(version, it);
   ::decode(snap_name, it);
 }
 
 void SnapEventBase::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  OpEventBase::dump(f);
   f->dump_string("snap_name", snap_name);
 }
 
@@ -143,38 +161,38 @@ void SnapRenameEvent::decode(__u8 version, bufferlist::iterator& it) {
 }
 
 void SnapRenameEvent::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  SnapEventBase::dump(f);
   f->dump_unsigned("src_snap_id", snap_id);
   f->dump_string("dest_snap_name", snap_name);
 }
 
 void RenameEvent::encode(bufferlist& bl) const {
-  OpStartEventBase::encode(bl);
+  OpEventBase::encode(bl);
   ::encode(image_name, bl);
 }
 
 void RenameEvent::decode(__u8 version, bufferlist::iterator& it) {
-  OpStartEventBase::decode(version, it);
+  OpEventBase::decode(version, it);
   ::decode(image_name, it);
 }
 
 void RenameEvent::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  OpEventBase::dump(f);
   f->dump_string("image_name", image_name);
 }
 
 void ResizeEvent::encode(bufferlist& bl) const {
-  OpStartEventBase::encode(bl);
+  OpEventBase::encode(bl);
   ::encode(size, bl);
 }
 
 void ResizeEvent::decode(__u8 version, bufferlist::iterator& it) {
-  OpStartEventBase::decode(version, it);
+  OpEventBase::decode(version, it);
   ::decode(size, it);
 }
 
 void ResizeEvent::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  OpEventBase::dump(f);
   f->dump_unsigned("size", size);
 }
 
@@ -278,24 +296,24 @@ void EventEntry::generate_test_instances(std::list<EventEntry *> &o) {
   o.push_back(new EventEntry(SnapRemoveEvent(345, "snap")));
 
   o.push_back(new EventEntry(SnapRenameEvent()));
-  o.push_back(new EventEntry(SnapRenameEvent(345, 1, "snap")));
+  o.push_back(new EventEntry(SnapRenameEvent(456, 1, "snap")));
 
   o.push_back(new EventEntry(SnapProtectEvent()));
-  o.push_back(new EventEntry(SnapProtectEvent(456, "snap")));
+  o.push_back(new EventEntry(SnapProtectEvent(567, "snap")));
 
   o.push_back(new EventEntry(SnapUnprotectEvent()));
-  o.push_back(new EventEntry(SnapUnprotectEvent(567, "snap")));
+  o.push_back(new EventEntry(SnapUnprotectEvent(678, "snap")));
 
   o.push_back(new EventEntry(SnapRollbackEvent()));
-  o.push_back(new EventEntry(SnapRollbackEvent(678, "snap")));
+  o.push_back(new EventEntry(SnapRollbackEvent(789, "snap")));
 
   o.push_back(new EventEntry(RenameEvent()));
-  o.push_back(new EventEntry(RenameEvent(789, "image name")));
+  o.push_back(new EventEntry(RenameEvent(890, "image name")));
 
   o.push_back(new EventEntry(ResizeEvent()));
-  o.push_back(new EventEntry(ResizeEvent(890, 1234)));
+  o.push_back(new EventEntry(ResizeEvent(901, 1234)));
 
-  o.push_back(new EventEntry(FlattenEvent(901)));
+  o.push_back(new EventEntry(FlattenEvent(123)));
 }
 
 } // namespace journal
diff --git a/src/librbd/JournalTypes.h b/src/librbd/journal/Entries.h
similarity index 63%
rename from src/librbd/JournalTypes.h
rename to src/librbd/journal/Entries.h
index ce8ff03..09218be 100644
--- a/src/librbd/JournalTypes.h
+++ b/src/librbd/journal/Entries.h
@@ -1,8 +1,8 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
-#ifndef CEPH_LIBRBD_JOURNAL_TYPES_H
-#define CEPH_LIBRBD_JOURNAL_TYPES_H
+#ifndef CEPH_LIBRBD_JOURNAL_ENTRIES_H
+#define CEPH_LIBRBD_JOURNAL_ENTRIES_H
 
 #include "include/int_types.h"
 #include "include/buffer.h"
@@ -78,26 +78,17 @@ struct AioFlushEvent {
 };
 
 struct OpEventBase {
-  uint64_t tid;
-
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  uint64_t op_tid;
 
 protected:
-  OpEventBase() : tid(0) {
+  OpEventBase() : op_tid(0) {
   }
-  OpEventBase(uint64_t _tid) : tid(_tid) {
+  OpEventBase(uint64_t op_tid) : op_tid(op_tid) {
   }
-  virtual ~OpEventBase() {}
-};
 
-struct OpStartEventBase : public OpEventBase {
-protected:
-  OpStartEventBase() {
-  }
-  OpStartEventBase(uint64_t tid) : OpEventBase(tid) {
-  }
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
 struct OpFinishEvent : public OpEventBase {
@@ -107,22 +98,27 @@ struct OpFinishEvent : public OpEventBase {
 
   OpFinishEvent() : r(0) {
   }
-  OpFinishEvent(uint64_t tid, int _r) : OpEventBase(tid), r(_r) {
+  OpFinishEvent(uint64_t op_tid, int r) : OpEventBase(op_tid), r(r) {
   }
+
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
-struct SnapEventBase : public OpStartEventBase {
+struct SnapEventBase : public OpEventBase {
   std::string snap_name;
 
+protected:
   SnapEventBase() {
   }
-  SnapEventBase(uint64_t tid, const std::string &_snap_name)
-    : OpStartEventBase(tid), snap_name(_snap_name) {
+  SnapEventBase(uint64_t op_tid, const std::string &_snap_name)
+    : OpEventBase(op_tid), snap_name(_snap_name) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
 struct SnapCreateEvent : public SnapEventBase {
@@ -130,9 +126,13 @@ struct SnapCreateEvent : public SnapEventBase {
 
   SnapCreateEvent() {
   }
-  SnapCreateEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapCreateEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapRemoveEvent : public SnapEventBase {
@@ -140,9 +140,13 @@ struct SnapRemoveEvent : public SnapEventBase {
 
   SnapRemoveEvent() {
   }
-  SnapRemoveEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapRemoveEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapRenameEvent : public SnapEventBase {
@@ -152,14 +156,14 @@ struct SnapRenameEvent : public SnapEventBase {
 
   SnapRenameEvent() : snap_id(CEPH_NOSNAP) {
   }
-  SnapRenameEvent(uint64_t tid, uint64_t src_snap_id,
+  SnapRenameEvent(uint64_t op_tid, uint64_t src_snap_id,
                   const std::string &dest_snap_name)
-    : SnapEventBase(tid, dest_snap_name), snap_id(src_snap_id) {
+    : SnapEventBase(op_tid, dest_snap_name), snap_id(src_snap_id) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
 struct SnapProtectEvent : public SnapEventBase {
@@ -167,9 +171,13 @@ struct SnapProtectEvent : public SnapEventBase {
 
   SnapProtectEvent() {
   }
-  SnapProtectEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapProtectEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapUnprotectEvent : public SnapEventBase {
@@ -177,9 +185,13 @@ struct SnapUnprotectEvent : public SnapEventBase {
 
   SnapUnprotectEvent() {
   }
-  SnapUnprotectEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapUnprotectEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapRollbackEvent : public SnapEventBase {
@@ -187,50 +199,58 @@ struct SnapRollbackEvent : public SnapEventBase {
 
   SnapRollbackEvent() {
   }
-  SnapRollbackEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapRollbackEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
-struct RenameEvent : public OpStartEventBase {
+struct RenameEvent : public OpEventBase {
   static const EventType EVENT_TYPE = EVENT_TYPE_RENAME;
 
   std::string image_name;
 
   RenameEvent() {
   }
-  RenameEvent(uint64_t tid, const std::string &_image_name)
-    : OpStartEventBase(tid), image_name(_image_name) {
+  RenameEvent(uint64_t op_tid, const std::string &_image_name)
+    : OpEventBase(op_tid), image_name(_image_name) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
-struct ResizeEvent : public OpStartEventBase {
+struct ResizeEvent : public OpEventBase {
   static const EventType EVENT_TYPE = EVENT_TYPE_RESIZE;
 
   uint64_t size;
 
   ResizeEvent() : size(0) {
   }
-  ResizeEvent(uint64_t tid, uint64_t _size)
-    : OpStartEventBase(tid), size(_size) {
+  ResizeEvent(uint64_t op_tid, uint64_t _size)
+    : OpEventBase(op_tid), size(_size) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
-struct FlattenEvent : public OpStartEventBase {
+struct FlattenEvent : public OpEventBase {
   static const EventType EVENT_TYPE = EVENT_TYPE_FLATTEN;
 
   FlattenEvent() {
   }
-  FlattenEvent(uint64_t tid) : OpStartEventBase(tid) {
+  FlattenEvent(uint64_t op_tid) : OpEventBase(op_tid) {
   }
+
+  using OpEventBase::encode;
+  using OpEventBase::decode;
+  using OpEventBase::dump;
 };
 
 struct UnknownEvent {
@@ -281,4 +301,4 @@ std::ostream &operator<<(std::ostream &out,
 
 WRITE_CLASS_ENCODER(librbd::journal::EventEntry);
 
-#endif // CEPH_LIBRBD_JOURNAL_TYPES_H
+#endif // CEPH_LIBRBD_JOURNAL_ENTRIES_H
diff --git a/src/librbd/journal/Replay.cc b/src/librbd/journal/Replay.cc
new file mode 100644
index 0000000..c2cddde
--- /dev/null
+++ b/src/librbd/journal/Replay.cc
@@ -0,0 +1,606 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "librbd/journal/Replay.h"
+#include "common/dout.h"
+#include "common/errno.h"
+#include "common/WorkQueue.h"
+#include "librbd/AioCompletion.h"
+#include "librbd/AioImageRequest.h"
+#include "librbd/ImageCtx.h"
+#include "librbd/internal.h"
+#include "librbd/Operations.h"
+#include "librbd/Utils.h"
+
+#define dout_subsys ceph_subsys_rbd
+#undef dout_prefix
+#define dout_prefix *_dout << "librbd::journal::Replay: "
+
+namespace librbd {
+namespace journal {
+
+namespace {
+
+static const uint64_t IN_FLIGHT_IO_LOW_WATER_MARK(32);
+static const uint64_t IN_FLIGHT_IO_HIGH_WATER_MARK(64);
+
+static NoOpProgressContext no_op_progress_callback;
+
+} // anonymous namespace
+
+template <typename I>
+Replay<I>::Replay(I &image_ctx)
+  : m_image_ctx(image_ctx), m_lock("Replay<I>::m_lock") {
+}
+
+template <typename I>
+Replay<I>::~Replay() {
+  assert(m_in_flight_aio == 0);
+  assert(m_aio_modify_unsafe_contexts.empty());
+  assert(m_aio_modify_safe_contexts.empty());
+  assert(m_op_events.empty());
+}
+
+template <typename I>
+void Replay<I>::process(bufferlist::iterator *it, Context *on_ready,
+                        Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << dendl;
+
+  on_ready = util::create_async_context_callback(m_image_ctx, on_ready);
+
+  journal::EventEntry event_entry;
+  try {
+    ::decode(event_entry, *it);
+  } catch (const buffer::error &err) {
+    lderr(cct) << "failed to decode event entry: " << err.what() << dendl;
+    on_ready->complete(-EINVAL);
+    return;
+  }
+
+  RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+  boost::apply_visitor(EventVisitor(this, on_ready, on_safe),
+                       event_entry.event);
+}
+
+template <typename I>
+void Replay<I>::flush(Context *on_finish) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << dendl;
+
+  AioCompletion *flush_comp = nullptr;
+  OpTids cancel_op_tids;
+  on_finish = util::create_async_context_callback(
+    m_image_ctx, on_finish);
+
+  {
+    Mutex::Locker locker(m_lock);
+
+    // safely commit any remaining AIO modify operations
+    if (m_in_flight_aio != 0) {
+      flush_comp = create_aio_flush_completion(nullptr, nullptr);;
+    }
+
+    // cancel ops that are waiting to start
+    for (auto &op_event_pair : m_op_events) {
+      const OpEvent &op_event = op_event_pair.second;
+      if (op_event.on_start_ready == nullptr) {
+        cancel_op_tids.push_back(op_event_pair.first);
+      }
+    }
+
+    assert(m_flush_ctx == nullptr);
+    if (!m_op_events.empty() || m_in_flight_aio != 0) {
+      std::swap(m_flush_ctx, on_finish);
+    }
+  }
+
+  // execute the following outside of lock scope
+  if (flush_comp != nullptr) {
+    RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
+    AioImageRequest<I>::aio_flush(&m_image_ctx, flush_comp);
+  }
+  for (auto op_tid : cancel_op_tids) {
+    handle_op_complete(op_tid, -ERESTART);
+  }
+  if (on_finish != nullptr) {
+    on_finish->complete(0);
+  }
+}
+
+template <typename I>
+void Replay<I>::replay_op_ready(uint64_t op_tid, Context *on_resume) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": op_tid=" << op_tid << dendl;
+
+  auto op_it = m_op_events.find(op_tid);
+  assert(op_it != m_op_events.end());
+
+  OpEvent &op_event = op_it->second;
+  assert(op_event.op_in_progress &&
+         op_event.on_op_finish_event == nullptr &&
+         op_event.on_finish_ready == nullptr &&
+         op_event.on_finish_safe == nullptr);
+
+  // resume processing replay events
+  Context *on_start_ready = nullptr;
+  std::swap(on_start_ready, op_event.on_start_ready);
+  on_start_ready->complete(0);
+
+  // cancel has been requested -- send error to paused state machine
+  if (m_flush_ctx != nullptr) {
+    m_image_ctx.op_work_queue->queue(on_resume, -ERESTART);
+    return;
+  }
+
+  // resume the op state machine once the associated OpFinishEvent
+  // is processed
+  op_event.on_op_finish_event = new FunctionContext(
+    [on_resume](int r) {
+      on_resume->complete(r);
+    });
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::AioDiscardEvent &event,
+                             Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": AIO discard event" << dendl;
+
+  bool flush_required;
+  AioCompletion *aio_comp = create_aio_modify_completion(on_ready, on_safe,
+                                                         &flush_required);
+  AioImageRequest<I>::aio_discard(&m_image_ctx, aio_comp, event.offset,
+                                  event.length);
+  if (flush_required) {
+    m_lock.Lock();
+    AioCompletion *flush_comp = create_aio_flush_completion(nullptr, nullptr);
+    m_lock.Unlock();
+
+    AioImageRequest<I>::aio_flush(&m_image_ctx, flush_comp);
+  }
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::AioWriteEvent &event,
+                             Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": AIO write event" << dendl;
+
+  bufferlist data = event.data;
+  bool flush_required;
+  AioCompletion *aio_comp = create_aio_modify_completion(on_ready, on_safe,
+                                                         &flush_required);
+  AioImageRequest<I>::aio_write(&m_image_ctx, aio_comp, event.offset,
+                                event.length, data.c_str(), 0);
+  if (flush_required) {
+    m_lock.Lock();
+    AioCompletion *flush_comp = create_aio_flush_completion(nullptr, nullptr);
+    m_lock.Unlock();
+
+    AioImageRequest<I>::aio_flush(&m_image_ctx, flush_comp);
+  }
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::AioFlushEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": AIO flush event" << dendl;
+
+  AioCompletion *aio_comp;
+  {
+    Mutex::Locker locker(m_lock);
+    aio_comp = create_aio_flush_completion(on_ready, on_safe);
+  }
+  AioImageRequest<I>::aio_flush(&m_image_ctx, aio_comp);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::OpFinishEvent &event,
+                             Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Op finish event: "
+                 << "op_tid=" << event.op_tid << dendl;
+
+  bool op_in_progress;
+  Context *on_op_finish_event = nullptr;
+  {
+    Mutex::Locker locker(m_lock);
+    auto op_it = m_op_events.find(event.op_tid);
+    if (op_it == m_op_events.end()) {
+      ldout(cct, 10) << "unable to locate associated op: assuming previously "
+                     << "committed." << dendl;
+      on_ready->complete(0);
+      m_image_ctx.op_work_queue->queue(on_safe, 0);
+      return;
+    }
+
+    OpEvent &op_event = op_it->second;
+    assert(op_event.on_finish_safe == nullptr);
+    op_event.on_finish_ready = on_ready;
+    op_event.on_finish_safe = on_safe;
+    op_in_progress = op_event.op_in_progress;
+    std::swap(on_op_finish_event, op_event.on_op_finish_event);
+  }
+
+  if (event.r < 0) {
+    if (op_in_progress) {
+      // bubble the error up to the in-progress op to cancel it
+      on_op_finish_event->complete(event.r);
+    } else {
+      // op hasn't been started -- no-op the event
+      delete on_op_finish_event;
+      handle_op_complete(event.op_tid, 0);
+    }
+    return;
+  }
+
+  // journal recorded success -- apply the op now
+  on_op_finish_event->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::SnapCreateEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Snap create event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+
+  m_image_ctx.operations->snap_create(event.snap_name.c_str(), on_op_complete,
+                                      event.op_tid);
+
+  // do not process more events until the state machine is ready
+  // since it will affect IO
+  op_event->op_in_progress = true;
+  op_event->on_start_ready = on_ready;
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::SnapRemoveEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Snap remove event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->snap_remove(event.snap_name.c_str(),
+                                          on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::SnapRenameEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Snap rename event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->snap_rename(event.snap_id,
+                                          event.snap_name.c_str(),
+                                          on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::SnapProtectEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Snap protect event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->snap_protect(event.snap_name.c_str(),
+                                           on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::SnapUnprotectEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Snap unprotect event"
+                 << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->snap_unprotect(event.snap_name.c_str(),
+                                             on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::SnapRollbackEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Snap rollback start event"
+                 << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->snap_rollback(event.snap_name.c_str(),
+                                            no_op_progress_callback,
+                                            on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::RenameEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Rename event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->rename(event.image_name.c_str(), on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::ResizeEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Resize start event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+
+  m_image_ctx.operations->resize(event.size, no_op_progress_callback,
+                                 on_op_complete, event.op_tid);
+
+  // do not process more events until the state machine is ready
+  // since it will affect IO
+  op_event->op_in_progress = true;
+  op_event->on_start_ready = on_ready;
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::FlattenEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": Flatten start event" << dendl;
+
+  Mutex::Locker locker(m_lock);
+  OpEvent *op_event;
+  Context *on_op_complete = create_op_context_callback(event.op_tid, on_safe,
+                                                       &op_event);
+  op_event->on_op_finish_event = new FunctionContext(
+    [this, event, on_op_complete](int r) {
+      m_image_ctx.operations->flatten(no_op_progress_callback, on_op_complete);
+    });
+
+  on_ready->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_event(const journal::UnknownEvent &event,
+			     Context *on_ready, Context *on_safe) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": unknown event" << dendl;
+  on_ready->complete(0);
+  on_safe->complete(0);
+}
+
+template <typename I>
+void Replay<I>::handle_aio_modify_complete(Context *on_safe, int r) {
+  Mutex::Locker locker(m_lock);
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": on_safe=" << on_safe << ", "
+                 << "r=" << r << dendl;
+
+  if (r < 0) {
+    lderr(cct) << "AIO modify op failed: " << cpp_strerror(r) << dendl;
+    on_safe->complete(r);
+    return;
+  }
+
+  // will be completed after next flush operation completes
+  m_aio_modify_safe_contexts.insert(on_safe);
+}
+
+template <typename I>
+void Replay<I>::handle_aio_flush_complete(Context *on_flush_safe,
+                                          Contexts &on_safe_ctxs, int r) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": " << "r=" << r << dendl;
+
+  if (r < 0) {
+    lderr(cct) << "AIO flush failed: " << cpp_strerror(r) << dendl;
+  }
+
+  Context *on_aio_ready = nullptr;
+  Context *on_flush = nullptr;
+  {
+    Mutex::Locker locker(m_lock);
+    assert(m_in_flight_aio >= on_safe_ctxs.size());
+    m_in_flight_aio -= on_safe_ctxs.size();
+
+    std::swap(on_aio_ready, m_on_aio_ready);
+    if (m_op_events.empty() && m_in_flight_aio == 0) {
+      on_flush = m_flush_ctx;
+    }
+
+    // strip out previously failed on_safe contexts
+    for (auto it = on_safe_ctxs.begin(); it != on_safe_ctxs.end(); ) {
+      if (m_aio_modify_safe_contexts.erase(*it)) {
+        ++it;
+      } else {
+        it = on_safe_ctxs.erase(it);
+      }
+    }
+  }
+
+  if (on_aio_ready != nullptr) {
+    ldout(cct, 10) << "resuming paused AIO" << dendl;
+    on_aio_ready->complete(0);
+  }
+  for (auto ctx : on_safe_ctxs) {
+    ctx->complete(r);
+  }
+  if (on_flush_safe != nullptr) {
+    on_flush_safe->complete(r);
+  }
+  if (on_flush != nullptr) {
+    on_flush->complete(r);
+  }
+}
+
+template <typename I>
+Context *Replay<I>::create_op_context_callback(uint64_t op_tid,
+                                               Context *on_safe,
+                                               OpEvent **op_event) {
+  assert(m_lock.is_locked());
+
+  *op_event = &m_op_events[op_tid];
+  (*op_event)->on_start_safe = on_safe;
+  return new C_OpOnComplete(this, op_tid);
+}
+
+template <typename I>
+void Replay<I>::handle_op_complete(uint64_t op_tid, int r) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 20) << this << " " << __func__ << ": op_tid=" << op_tid << ", "
+                 << "r=" << r << dendl;
+
+  OpEvent op_event;
+  Context *on_flush = nullptr;
+  {
+    Mutex::Locker locker(m_lock);
+    auto op_it = m_op_events.find(op_tid);
+    assert(op_it != m_op_events.end());
+
+    op_event = std::move(op_it->second);
+    m_op_events.erase(op_it);
+
+    if (m_op_events.empty() && m_in_flight_aio == 0) {
+      on_flush = m_flush_ctx;
+    }
+  }
+
+  assert(op_event.on_start_ready == nullptr);
+  assert((op_event.on_finish_ready != nullptr &&
+          op_event.on_finish_safe != nullptr) || r == -ERESTART);
+
+  // skipped upon error -- so clean up if non-null
+  delete op_event.on_op_finish_event;
+
+  if (op_event.on_finish_ready != nullptr) {
+    op_event.on_finish_ready->complete(0);
+  }
+
+  op_event.on_start_safe->complete(r);
+  if (op_event.on_finish_safe != nullptr) {
+    op_event.on_finish_safe->complete(r);
+  }
+  if (on_flush != nullptr) {
+    on_flush->complete(0);
+  }
+}
+
+template <typename I>
+AioCompletion *Replay<I>::create_aio_modify_completion(Context *on_ready,
+                                                       Context *on_safe,
+                                                       bool *flush_required) {
+  Mutex::Locker locker(m_lock);
+  CephContext *cct = m_image_ctx.cct;
+  assert(m_on_aio_ready == nullptr);
+
+  ++m_in_flight_aio;
+  m_aio_modify_unsafe_contexts.push_back(on_safe);
+
+  // FLUSH if we hit the low-water mark -- on_safe contexts are
+  // completed by flushes-only so that we don't move the journal
+  // commit position until safely on-disk
+
+  // when safe, the completion of the next flush will fire the on_safe
+  // callback
+  AioCompletion *aio_comp = AioCompletion::create<Context>(
+    new C_AioModifyComplete(this, on_safe));
+
+  *flush_required = (m_aio_modify_unsafe_contexts.size() ==
+                       IN_FLIGHT_IO_LOW_WATER_MARK);
+  if (*flush_required) {
+    ldout(cct, 10) << "hit AIO replay low-water mark: scheduling flush"
+                   << dendl;
+  }
+
+  // READY for more events if:
+  // * not at high-water mark for IO
+  // * in-flight ops are at a consistent point (snap create has IO flushed,
+  //   shrink has adjusted clip boundary, etc) -- should have already been
+  //   flagged not-ready
+  if (m_in_flight_aio == IN_FLIGHT_IO_HIGH_WATER_MARK) {
+    ldout(cct, 10) << "hit AIO replay high-water mark: pausing replay"
+                   << dendl;
+    m_on_aio_ready = on_ready;
+  } else {
+    on_ready->complete(0);
+  }
+
+  return aio_comp;
+}
+
+template <typename I>
+AioCompletion *Replay<I>::create_aio_flush_completion(Context *on_ready,
+                                                      Context *on_safe) {
+  assert(m_lock.is_locked());
+
+  // associate all prior write/discard ops to this flush request
+  AioCompletion *aio_comp = AioCompletion::create<Context>(
+      new C_AioFlushComplete(this, on_safe,
+                             std::move(m_aio_modify_unsafe_contexts)));
+  m_aio_modify_unsafe_contexts.clear();
+
+  if (on_ready != nullptr) {
+    on_ready->complete(0);
+  }
+  return aio_comp;
+}
+
+} // namespace journal
+} // namespace librbd
+
+template class librbd::journal::Replay<librbd::ImageCtx>;
diff --git a/src/librbd/journal/Replay.h b/src/librbd/journal/Replay.h
new file mode 100644
index 0000000..96333e3
--- /dev/null
+++ b/src/librbd/journal/Replay.h
@@ -0,0 +1,171 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_LIBRBD_JOURNAL_REPLAY_H
+#define CEPH_LIBRBD_JOURNAL_REPLAY_H
+
+#include "include/int_types.h"
+#include "include/buffer_fwd.h"
+#include "include/Context.h"
+#include "include/rbd/librbd.hpp"
+#include "common/Mutex.h"
+#include "librbd/journal/Entries.h"
+#include <boost/variant.hpp>
+#include <list>
+#include <set>
+#include <unordered_set>
+#include <unordered_map>
+
+namespace librbd {
+
+class AioCompletion;
+class ImageCtx;
+
+namespace journal {
+
+template <typename ImageCtxT = ImageCtx>
+class Replay {
+public:
+  static Replay *create(ImageCtxT &image_ctx) {
+    return new Replay(image_ctx);
+  }
+
+  Replay(ImageCtxT &image_ctx);
+  ~Replay();
+
+  void process(bufferlist::iterator *it, Context *on_ready, Context *on_safe);
+  void flush(Context *on_finish);
+
+  void replay_op_ready(uint64_t op_tid, Context *on_resume);
+
+private:
+  struct OpEvent {
+    bool op_in_progress = false;
+    Context *on_op_finish_event = nullptr;
+    Context *on_start_ready = nullptr;
+    Context *on_start_safe = nullptr;
+    Context *on_finish_ready = nullptr;
+    Context *on_finish_safe = nullptr;
+  };
+
+  typedef std::list<uint64_t> OpTids;
+  typedef std::list<Context *> Contexts;
+  typedef std::unordered_set<Context *> ContextSet;
+  typedef std::unordered_map<uint64_t, OpEvent> OpEvents;
+
+  struct C_OpOnComplete : public Context {
+    Replay *replay;
+    uint64_t op_tid;
+    C_OpOnComplete(Replay *replay, uint64_t op_tid)
+      : replay(replay), op_tid(op_tid) {
+    }
+    virtual void finish(int r) override {
+      replay->handle_op_complete(op_tid, r);
+    }
+  };
+
+  struct C_AioModifyComplete : public Context {
+    Replay *replay;
+    Context *on_safe;
+    C_AioModifyComplete(Replay *replay, Context *on_safe)
+      : replay(replay), on_safe(on_safe) {
+    }
+    virtual void finish(int r) {
+      replay->handle_aio_modify_complete(on_safe, r);
+    }
+  };
+
+  struct C_AioFlushComplete : public Context {
+    Replay *replay;
+    Context *on_flush_safe;
+    Contexts on_safe_ctxs;
+    C_AioFlushComplete(Replay *replay, Context *on_flush_safe,
+                       Contexts &&on_safe_ctxs)
+      : replay(replay), on_flush_safe(on_flush_safe),
+        on_safe_ctxs(on_safe_ctxs) {
+    }
+    virtual void finish(int r) {
+      replay->handle_aio_flush_complete(on_flush_safe, on_safe_ctxs, r);
+    }
+  };
+
+  struct EventVisitor : public boost::static_visitor<void> {
+    Replay *replay;
+    Context *on_ready;
+    Context *on_safe;
+
+    EventVisitor(Replay *_replay, Context *_on_ready, Context *_on_safe)
+      : replay(_replay), on_ready(_on_ready), on_safe(_on_safe) {
+    }
+
+    template <typename Event>
+    inline void operator()(const Event &event) const {
+      replay->handle_event(event, on_ready, on_safe);
+    }
+  };
+
+  ImageCtxT &m_image_ctx;
+
+  Mutex m_lock;
+
+  uint64_t m_in_flight_aio = 0;
+  Contexts m_aio_modify_unsafe_contexts;
+  ContextSet m_aio_modify_safe_contexts;
+
+  OpEvents m_op_events;
+
+  Context *m_flush_ctx = nullptr;
+  Context *m_on_aio_ready = nullptr;
+
+  void handle_event(const AioDiscardEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const AioWriteEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const AioFlushEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const OpFinishEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const SnapCreateEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const SnapRemoveEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const SnapRenameEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const SnapProtectEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const SnapUnprotectEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const SnapRollbackEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const RenameEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const ResizeEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const FlattenEvent &event, Context *on_ready,
+                    Context *on_safe);
+  void handle_event(const UnknownEvent &event, Context *on_ready,
+                    Context *on_safe);
+
+  void handle_aio_modify_complete(Context *on_safe, int r);
+  void handle_aio_flush_complete(Context *on_flush_safe, Contexts &on_safe_ctxs,
+                                 int r);
+
+  Context *create_op_context_callback(uint64_t op_tid, Context *on_safe,
+                                      OpEvent **op_event);
+  void handle_op_complete(uint64_t op_tid, int r);
+
+  AioCompletion *create_aio_modify_completion(Context *on_ready,
+                                              Context *on_safe,
+                                              bool *flush_required);
+  AioCompletion *create_aio_flush_completion(Context *on_ready,
+                                             Context *on_safe);
+  void handle_aio_completion(AioCompletion *aio_comp);
+
+};
+
+} // namespace journal
+} // namespace librbd
+
+extern template class librbd::journal::Replay<librbd::ImageCtx>;
+
+#endif // CEPH_LIBRBD_JOURNAL_REPLAY_H
diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc
index d4edc22..3fda9db 100644
--- a/src/librbd/librbd.cc
+++ b/src/librbd/librbd.cc
@@ -30,7 +30,7 @@
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageState.h"
 #include "librbd/internal.h"
-#include "librbd/LibrbdWriteback.h"
+#include "librbd/Operations.h"
 
 #include <algorithm>
 #include <string>
@@ -439,7 +439,7 @@ namespace librbd {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
     librbd::NoOpProgressContext prog_ctx;
-    int r = librbd::resize(ictx, size, prog_ctx);
+    int r = ictx->operations->resize(size, prog_ctx);
     tracepoint(librbd, resize_exit, r);
     return r;
   }
@@ -448,7 +448,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
-    int r = librbd::resize(ictx, size, pctx);
+    int r = ictx->operations->resize(size, pctx);
     tracepoint(librbd, resize_exit, r);
     return r;
   }
@@ -566,7 +566,7 @@ namespace librbd {
   int Image::rebuild_object_map(ProgressContext &prog_ctx)
   {
     ImageCtx *ictx = reinterpret_cast<ImageCtx*>(ctx);
-    return librbd::rebuild_object_map(ictx, prog_ctx);
+    return ictx->operations->rebuild_object_map(prog_ctx);
   }
 
   int Image::copy(IoCtx& dest_io_ctx, const char *destname)
@@ -638,7 +638,7 @@ namespace librbd {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, flatten_enter, ictx, ictx->name.c_str(), ictx->id.c_str());
     librbd::NoOpProgressContext prog_ctx;
-    int r = librbd::flatten(ictx, prog_ctx);
+    int r = ictx->operations->flatten(prog_ctx);
     tracepoint(librbd, flatten_exit, r);
     return r;
   }
@@ -647,7 +647,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, flatten_enter, ictx, ictx->name.c_str(), ictx->id.c_str());
-    int r = librbd::flatten(ictx, prog_ctx);
+    int r = ictx->operations->flatten(prog_ctx);
     tracepoint(librbd, flatten_exit, r);
     return r;
   }
@@ -723,7 +723,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = librbd::snap_create(ictx, snap_name);
+    int r = ictx->operations->snap_create(snap_name);
     tracepoint(librbd, snap_create_exit, r);
     return r;
   }
@@ -732,7 +732,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_remove_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = librbd::snap_remove(ictx, snap_name);
+    int r = ictx->operations->snap_remove(snap_name);
     tracepoint(librbd, snap_remove_exit, r);
     return r;
   }
@@ -742,7 +742,7 @@ namespace librbd {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_rollback_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
     librbd::NoOpProgressContext prog_ctx;
-    int r = librbd::snap_rollback(ictx, snap_name, prog_ctx);
+    int r = ictx->operations->snap_rollback(snap_name, prog_ctx);
     tracepoint(librbd, snap_rollback_exit, r);
     return r;
   }
@@ -751,7 +751,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_rename_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, srcname, dstname);
-    int r = librbd::snap_rename(ictx, srcname, dstname);
+    int r = ictx->operations->snap_rename(srcname, dstname);
     tracepoint(librbd, snap_rename_exit, r);
     return r;
   }
@@ -761,7 +761,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_rollback_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = librbd::snap_rollback(ictx, snap_name, prog_ctx);
+    int r = ictx->operations->snap_rollback(snap_name, prog_ctx);
     tracepoint(librbd, snap_rollback_exit, r);
     return r;
   }
@@ -770,7 +770,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_protect_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = librbd::snap_protect(ictx, snap_name);
+    int r = ictx->operations->snap_protect(snap_name);
     tracepoint(librbd, snap_protect_exit, r);
     return r;
   }
@@ -779,7 +779,7 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_unprotect_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = librbd::snap_unprotect(ictx, snap_name);
+    int r = ictx->operations->snap_unprotect(snap_name);
     tracepoint(librbd, snap_unprotect_exit, r);
     return r;
   }
@@ -816,7 +816,27 @@ namespace librbd {
   bool Image::snap_exists(const char *snap_name)
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
-    return librbd::snap_exists(ictx, snap_name);
+    tracepoint(librbd, snap_exists_enter, ictx, ictx->name.c_str(), 
+      ictx->snap_name.c_str(), ictx->read_only, snap_name);
+    bool exists; 
+    int r = librbd::snap_exists(ictx, snap_name, &exists);
+    tracepoint(librbd, snap_exists_exit, r, exists);
+    if (r < 0) {
+      // lie to caller since we don't know the real answer yet.
+      return false;
+    }
+    return exists;
+  }
+
+  // A safer verion of snap_exists.
+  int Image::snap_exists2(const char *snap_name, bool *exists)
+  {
+    ImageCtx *ictx = (ImageCtx *)ctx;
+    tracepoint(librbd, snap_exists_enter, ictx, ictx->name.c_str(), 
+      ictx->snap_name.c_str(), ictx->read_only, snap_name);
+    int r = librbd::snap_exists(ictx, snap_name, exists);
+    tracepoint(librbd, snap_exists_exit, r, *exists);
+    return r;
   }
 
   int Image::snap_set(const char *snap_name)
@@ -1507,7 +1527,7 @@ extern "C" int rbd_flatten(rbd_image_t image)
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, flatten_enter, ictx, ictx->name.c_str(), ictx->id.c_str());
   librbd::NoOpProgressContext prog_ctx;
-  int r = librbd::flatten(ictx, prog_ctx);
+  int r = ictx->operations->flatten(prog_ctx);
   tracepoint(librbd, flatten_exit, r);
   return r;
 }
@@ -1518,7 +1538,7 @@ extern "C" int rbd_flatten_with_progress(rbd_image_t image,
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, flatten_enter, ictx, ictx->name.c_str(), ictx->id.c_str());
   librbd::CProgressContext prog_ctx(cb, cbdata);
-  int r = librbd::flatten(ictx, prog_ctx);
+  int r = ictx->operations->flatten(prog_ctx);
   tracepoint(librbd, flatten_exit, r);
   return r;
 }
@@ -1591,7 +1611,7 @@ extern "C" int rbd_resize(rbd_image_t image, uint64_t size)
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
   librbd::NoOpProgressContext prog_ctx;
-  int r = librbd::resize(ictx, size, prog_ctx);
+  int r = ictx->operations->resize(size, prog_ctx);
   tracepoint(librbd, resize_exit, r);
   return r;
 }
@@ -1602,7 +1622,7 @@ extern "C" int rbd_resize_with_progress(rbd_image_t image, uint64_t size,
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, resize_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, size);
   librbd::CProgressContext prog_ctx(cb, cbdata);
-  int r = librbd::resize(ictx, size, prog_ctx);
+  int r = ictx->operations->resize(size, prog_ctx);
   tracepoint(librbd, resize_exit, r);
   return r;
 }
@@ -1759,7 +1779,7 @@ extern "C" int rbd_rebuild_object_map(rbd_image_t image,
 {
   librbd::ImageCtx *ictx = reinterpret_cast<librbd::ImageCtx*>(image);
   librbd::CProgressContext prog_ctx(cb, cbdata);
-  return librbd::rebuild_object_map(ictx, prog_ctx);
+  return ictx->operations->rebuild_object_map(prog_ctx);
 }
 
 /* snapshots */
@@ -1767,7 +1787,7 @@ extern "C" int rbd_snap_create(rbd_image_t image, const char *snap_name)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-  int r = librbd::snap_create(ictx, snap_name);
+  int r = ictx->operations->snap_create(snap_name);
   tracepoint(librbd, snap_create_exit, r);
   return r;
 }
@@ -1776,7 +1796,7 @@ extern "C" int rbd_snap_rename(rbd_image_t image, const char *srcname, const cha
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_rename_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, srcname, dstname);
-  int r = librbd::snap_rename(ictx, srcname, dstname);
+  int r = ictx->operations->snap_rename(srcname, dstname);
   tracepoint(librbd, snap_rename_exit, r);
   return r;
 }
@@ -1785,7 +1805,7 @@ extern "C" int rbd_snap_remove(rbd_image_t image, const char *snap_name)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_remove_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-  int r = librbd::snap_remove(ictx, snap_name);
+  int r = ictx->operations->snap_remove(snap_name);
   tracepoint(librbd, snap_remove_exit, r);
   return r;
 }
@@ -1795,7 +1815,7 @@ extern "C" int rbd_snap_rollback(rbd_image_t image, const char *snap_name)
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_rollback_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
   librbd::NoOpProgressContext prog_ctx;
-  int r = librbd::snap_rollback(ictx, snap_name, prog_ctx);
+  int r = ictx->operations->snap_rollback(snap_name, prog_ctx);
   tracepoint(librbd, snap_rollback_exit, r);
   return r;
 }
@@ -1808,7 +1828,7 @@ extern "C" int rbd_snap_rollback_with_progress(rbd_image_t image,
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_rollback_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
   librbd::CProgressContext prog_ctx(cb, cbdata);
-  int r = librbd::snap_rollback(ictx, snap_name, prog_ctx);
+  int r = ictx->operations->snap_rollback(snap_name, prog_ctx);
   tracepoint(librbd, snap_rollback_exit, r);
   return r;
 }
@@ -1877,7 +1897,7 @@ extern "C" int rbd_snap_protect(rbd_image_t image, const char *snap_name)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_protect_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-  int r = librbd::snap_protect(ictx, snap_name);
+  int r = ictx->operations->snap_protect(snap_name);
   tracepoint(librbd, snap_protect_exit, r);
   return r;
 }
@@ -1886,7 +1906,7 @@ extern "C" int rbd_snap_unprotect(rbd_image_t image, const char *snap_name)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_unprotect_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-  int r = librbd::snap_unprotect(ictx, snap_name);
+  int r = ictx->operations->snap_unprotect(snap_name);
   tracepoint(librbd, snap_unprotect_exit, r);
   return r;
 }
diff --git a/src/librbd/object_map/Request.cc b/src/librbd/object_map/Request.cc
index 8a731e1..e95c22a 100644
--- a/src/librbd/object_map/Request.cc
+++ b/src/librbd/object_map/Request.cc
@@ -33,7 +33,7 @@ bool Request::should_complete(int r) {
 
     {
       RWLock::WLocker l2(m_image_ctx.object_map_lock);
-      finish();
+      finish_request();
     }
     return true;
 
diff --git a/src/librbd/object_map/Request.h b/src/librbd/object_map/Request.h
index fdc22de..6629ad9 100644
--- a/src/librbd/object_map/Request.h
+++ b/src/librbd/object_map/Request.h
@@ -33,7 +33,8 @@ protected:
     // never propagate an error back to the caller
     return 0;
   }
-  virtual void finish() = 0;
+  virtual void finish_request() {
+  }
 
 private:
   /**
diff --git a/src/librbd/object_map/ResizeRequest.cc b/src/librbd/object_map/ResizeRequest.cc
index afbde42..fcc6ec6 100644
--- a/src/librbd/object_map/ResizeRequest.cc
+++ b/src/librbd/object_map/ResizeRequest.cc
@@ -46,7 +46,7 @@ void ResizeRequest::send() {
   rados_completion->release();
 }
 
-void ResizeRequest::finish() {
+void ResizeRequest::finish_request() {
   CephContext *cct = m_image_ctx.cct;
 
   ldout(cct, 5) << &m_image_ctx << " resizing in-memory object map: "
diff --git a/src/librbd/object_map/ResizeRequest.h b/src/librbd/object_map/ResizeRequest.h
index ca95393..dfe0bcc 100644
--- a/src/librbd/object_map/ResizeRequest.h
+++ b/src/librbd/object_map/ResizeRequest.h
@@ -33,7 +33,7 @@ public:
   virtual void send();
 
 protected:
-  virtual void finish();
+  virtual void finish_request() override;
 
 private:
   ceph::BitVector<2> *m_object_map;
diff --git a/src/librbd/object_map/SnapshotCreateRequest.h b/src/librbd/object_map/SnapshotCreateRequest.h
index f814332..e68b78a 100644
--- a/src/librbd/object_map/SnapshotCreateRequest.h
+++ b/src/librbd/object_map/SnapshotCreateRequest.h
@@ -55,9 +55,6 @@ public:
 protected:
   virtual bool should_complete(int r);
 
-  virtual void finish() {
-  }
-
 private:
   State m_state;
   ceph::BitVector<2> &m_object_map;
diff --git a/src/librbd/object_map/SnapshotRemoveRequest.h b/src/librbd/object_map/SnapshotRemoveRequest.h
index 75fbdc8..6469678 100644
--- a/src/librbd/object_map/SnapshotRemoveRequest.h
+++ b/src/librbd/object_map/SnapshotRemoveRequest.h
@@ -64,9 +64,6 @@ protected:
     return r;
   }
 
-  virtual void finish() {
-  }
-
 private:
   State m_state;
   ceph::BitVector<2> &m_object_map;
diff --git a/src/librbd/object_map/SnapshotRollbackRequest.h b/src/librbd/object_map/SnapshotRollbackRequest.h
index 4717166..dd94300 100644
--- a/src/librbd/object_map/SnapshotRollbackRequest.h
+++ b/src/librbd/object_map/SnapshotRollbackRequest.h
@@ -55,9 +55,6 @@ public:
 protected:
   virtual bool should_complete(int r);
 
-  virtual void finish() {
-  }
-
 private:
   State m_state;
   uint64_t m_snap_id;
diff --git a/src/librbd/object_map/UpdateRequest.cc b/src/librbd/object_map/UpdateRequest.cc
index fc651ab..e8a5f47 100644
--- a/src/librbd/object_map/UpdateRequest.cc
+++ b/src/librbd/object_map/UpdateRequest.cc
@@ -61,7 +61,7 @@ void UpdateRequest::send() {
   rados_completion->release();
 }
 
-void UpdateRequest::finish() {
+void UpdateRequest::finish_request() {
   ldout(m_image_ctx.cct, 20) << &m_image_ctx << " on-disk object map updated"
                              << dendl;
 }
diff --git a/src/librbd/object_map/UpdateRequest.h b/src/librbd/object_map/UpdateRequest.h
index 6c277b0..d1ce407 100644
--- a/src/librbd/object_map/UpdateRequest.h
+++ b/src/librbd/object_map/UpdateRequest.h
@@ -33,7 +33,7 @@ public:
   virtual void send();
 
 protected:
-  virtual void finish();
+  virtual void finish_request() override;
 
 private:
   ceph::BitVector<2> &m_object_map;
diff --git a/src/librbd/operation/FlattenRequest.h b/src/librbd/operation/FlattenRequest.h
index 693b051..55e33f4 100644
--- a/src/librbd/operation/FlattenRequest.h
+++ b/src/librbd/operation/FlattenRequest.h
@@ -31,8 +31,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::FlattenEvent(0);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::FlattenEvent(op_tid);
   }
 
 private:
diff --git a/src/librbd/operation/RebuildObjectMapRequest.cc b/src/librbd/operation/RebuildObjectMapRequest.cc
index ce7f911..cfb1c11 100644
--- a/src/librbd/operation/RebuildObjectMapRequest.cc
+++ b/src/librbd/operation/RebuildObjectMapRequest.cc
@@ -283,9 +283,9 @@ void RebuildObjectMapRequest<I>::send_trim_image() {
     orig_size = m_image_ctx.get_object_size() *
                 m_image_ctx.object_map->size();
   }
-  TrimRequest<I> *req = new TrimRequest<I>(m_image_ctx,
-                                           this->create_callback_context(),
-                                           orig_size, new_size, m_prog_ctx);
+  TrimRequest<I> *req = TrimRequest<I>::create(m_image_ctx,
+                                               this->create_callback_context(),
+                                               orig_size, new_size, m_prog_ctx);
   req->send();
 }
 
diff --git a/src/librbd/operation/RenameRequest.h b/src/librbd/operation/RenameRequest.h
index 474ce50..6b47d07 100644
--- a/src/librbd/operation/RenameRequest.h
+++ b/src/librbd/operation/RenameRequest.h
@@ -59,8 +59,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::RenameEvent(0, m_dest_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::RenameEvent(op_tid, m_dest_name);
   }
 
 private:
diff --git a/src/librbd/operation/Request.cc b/src/librbd/operation/Request.cc
index 6a96d85..d3e8bf6 100644
--- a/src/librbd/operation/Request.cc
+++ b/src/librbd/operation/Request.cc
@@ -2,15 +2,22 @@
 // vim: ts=8 sw=2 smarttab
 
 #include "librbd/operation/Request.h"
+#include "common/dout.h"
+#include "common/errno.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/Journal.h"
+#include "librbd/Utils.h"
+
+#define dout_subsys ceph_subsys_rbd
+#undef dout_prefix
+#define dout_prefix *_dout << "librbd::Request: "
 
 namespace librbd {
 namespace operation {
 
 template <typename I>
-Request<I>::Request(I &image_ctx, Context *on_finish)
-  : AsyncRequest<I>(image_ctx, on_finish), m_tid(0) {
+Request<I>::Request(I &image_ctx, Context *on_finish, uint64_t journal_op_tid)
+  : AsyncRequest<I>(image_ctx, on_finish), m_op_tid(journal_op_tid) {
 }
 
 template <typename I>
@@ -18,47 +25,97 @@ void Request<I>::send() {
   I &image_ctx = this->m_image_ctx;
   assert(image_ctx.owner_lock.is_locked());
 
-  {
-    RWLock::RLocker snap_locker(image_ctx.snap_lock);
-    if (image_ctx.journal != NULL &&
-        !image_ctx.journal->is_journal_replaying()) {
-      // journal might be replaying -- wait for it to complete
-      if (!image_ctx.journal->is_journal_ready()) {
-        image_ctx.journal->wait_for_journal_ready(
-          new C_WaitForJournalReady(this));
-        return;
-      }
-
-      journal::EventEntry event_entry(create_event());
-      m_tid = image_ctx.journal->append_op_event(event_entry);
-    }
+  // automatically create the event if we don't need to worry
+  // about affecting concurrent IO ops
+  if (can_affect_io() || !append_op_event()) {
+    send_op();
   }
-
-  send_op();
 }
 
 template <typename I>
 void Request<I>::finish(int r) {
-  {
-    I &image_ctx = this->m_image_ctx;
-    RWLock::RLocker snap_locker(image_ctx.snap_lock);
-    if (m_tid != 0 && image_ctx.journal != NULL &&
-        !image_ctx.journal->is_journal_replaying()) {
-      // ops will be canceled / completed before closing journal
-      assert(image_ctx.journal->is_journal_ready());
-
-      image_ctx.journal->commit_op_event(m_tid, r);
-    }
+  // automatically commit the event if we don't need to worry
+  // about affecting concurrent IO ops
+  if (r < 0 || !can_affect_io()) {
+    commit_op_event(r);
   }
 
+  assert(!m_appended_op_event || m_committed_op_event);
   AsyncRequest<I>::finish(r);
 }
 
 template <typename I>
-void Request<I>::handle_journal_ready() {
+bool Request<I>::append_op_event() {
   I &image_ctx = this->m_image_ctx;
-  RWLock::RLocker owner_locker(image_ctx.owner_lock);
-  send();
+
+  assert(image_ctx.owner_lock.is_locked());
+  RWLock::RLocker snap_locker(image_ctx.snap_lock);
+  if (image_ctx.journal != NULL &&
+      !image_ctx.journal->is_journal_replaying()) {
+    append_op_event(util::create_context_callback<
+      Request<I>, &Request<I>::handle_op_event_safe>(this));
+    return true;
+  }
+  return false;
+}
+
+template <typename I>
+void Request<I>::commit_op_event(int r) {
+  I &image_ctx = this->m_image_ctx;
+  RWLock::RLocker snap_locker(image_ctx.snap_lock);
+
+  if (!m_appended_op_event) {
+    return;
+  }
+
+  assert(m_op_tid != 0);
+  assert(!m_committed_op_event);
+  m_committed_op_event = true;
+
+  if (image_ctx.journal != NULL &&
+      !image_ctx.journal->is_journal_replaying()) {
+    CephContext *cct = image_ctx.cct;
+    ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
+
+    // ops will be canceled / completed before closing journal
+    assert(image_ctx.journal->is_journal_ready());
+    image_ctx.journal->commit_op_event(m_op_tid, r);
+  }
+}
+
+template <typename I>
+void Request<I>::append_op_event(Context *on_safe) {
+  I &image_ctx = this->m_image_ctx;
+  assert(image_ctx.owner_lock.is_locked());
+  assert(image_ctx.snap_lock.is_locked());
+
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 10) << this << " " << __func__ << dendl;
+
+  m_op_tid = image_ctx.journal->allocate_op_tid();
+  image_ctx.journal->append_op_event(
+    m_op_tid, journal::EventEntry{create_event(m_op_tid)},
+    new C_OpEventSafe(this, on_safe));
+}
+
+template <typename I>
+void Request<I>::handle_op_event_safe(int r) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
+
+  if (r < 0) {
+    lderr(cct) << "failed to commit op event to journal: " << cpp_strerror(r)
+               << dendl;
+    this->finish(r);
+    delete this;
+  } else {
+    assert(!can_affect_io());
+
+    // haven't started the request state machine yet
+    RWLock::RLocker owner_locker(image_ctx.owner_lock);
+    send_op();
+  }
 }
 
 } // namespace operation
diff --git a/src/librbd/operation/Request.h b/src/librbd/operation/Request.h
index c0dd3cb..54d8281 100644
--- a/src/librbd/operation/Request.h
+++ b/src/librbd/operation/Request.h
@@ -6,7 +6,10 @@
 
 #include "librbd/AsyncRequest.h"
 #include "include/Context.h"
-#include "librbd/JournalTypes.h"
+#include "common/RWLock.h"
+#include "librbd/Utils.h"
+#include "librbd/Journal.h"
+#include "librbd/journal/Entries.h"
 
 namespace librbd {
 
@@ -17,31 +20,72 @@ namespace operation {
 template <typename ImageCtxT = ImageCtx>
 class Request : public AsyncRequest<ImageCtxT> {
 public:
-  Request(ImageCtxT &image_ctx, Context *on_finish);
+  Request(ImageCtxT &image_ctx, Context *on_finish,
+          uint64_t journal_op_tid = 0);
 
   virtual void send();
 
 protected:
-  virtual void finish(int r);
+  virtual void finish(int r) override;
   virtual void send_op() = 0;
 
-  virtual journal::Event create_event() const = 0;
+  virtual bool can_affect_io() const {
+    return false;
+  }
+  virtual journal::Event create_event(uint64_t op_tid) const = 0;
+
+  template <typename T, Context*(T::*MF)(int*)>
+  bool append_op_event(T *request) {
+    ImageCtxT &image_ctx = this->m_image_ctx;
+
+    assert(can_affect_io());
+    RWLock::RLocker owner_locker(image_ctx.owner_lock);
+    RWLock::RLocker snap_locker(image_ctx.snap_lock);
+    if (image_ctx.journal != NULL) {
+      Context *ctx = util::create_context_callback<T, MF>(request);
+      if (image_ctx.journal->is_journal_replaying()) {
+        assert(m_op_tid != 0);
+        m_appended_op_event = true;
+        image_ctx.journal->replay_op_ready(m_op_tid, ctx);
+      } else {
+        append_op_event(ctx);
+      }
+      return true;
+    }
+    return false;
+  }
+
+  bool append_op_event();
+  void commit_op_event(int r);
+
+  // NOTE: temporary until converted to new state machine format
+  Context *create_context_finisher() {
+    return util::create_context_callback<
+      Request<ImageCtxT>, &Request<ImageCtxT>::finish>(this);
+  }
 
 private:
-  struct C_WaitForJournalReady : public Context {
+  struct C_OpEventSafe : public Context {
     Request *request;
-
-    C_WaitForJournalReady(Request *_request) : request(_request) {
+    Context *on_safe;
+    C_OpEventSafe(Request *request, Context *on_safe)
+      : request(request), on_safe(on_safe) {
     }
-
-    virtual void finish(int r) {
-      request->handle_journal_ready();
+    virtual void finish(int r) override {
+      if (r >= 0) {
+        request->m_appended_op_event = true;
+      }
+      on_safe->complete(r);
     }
   };
 
-  uint64_t m_tid;
+  uint64_t m_op_tid = 0;
+  bool m_appended_op_event = false;
+  bool m_committed_op_event = false;
+
+  void append_op_event(Context *on_safe);
+  void handle_op_event_safe(int r);
 
-  void handle_journal_ready();
 };
 
 } // namespace operation
diff --git a/src/librbd/operation/ResizeRequest.cc b/src/librbd/operation/ResizeRequest.cc
index dc92dbe..300fa8b 100644
--- a/src/librbd/operation/ResizeRequest.cc
+++ b/src/librbd/operation/ResizeRequest.cc
@@ -2,11 +2,13 @@
 // vim: ts=8 sw=2 smarttab
 
 #include "librbd/operation/ResizeRequest.h"
+#include "librbd/AioImageRequestWQ.h"
 #include "librbd/ExclusiveLock.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageWatcher.h"
 #include "librbd/internal.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/Utils.h"
 #include "librbd/operation/TrimRequest.h"
 #include "common/dout.h"
 #include "common/errno.h"
@@ -18,12 +20,18 @@
 namespace librbd {
 namespace operation {
 
+using util::create_async_context_callback;
+using util::create_context_callback;
+using util::create_rados_safe_callback;
+
 template <typename I>
 ResizeRequest<I>::ResizeRequest(I &image_ctx, Context *on_finish,
-                                uint64_t new_size, ProgressContext &prog_ctx)
-  : Request<I>(image_ctx, on_finish),
+                                uint64_t new_size, ProgressContext &prog_ctx,
+                                uint64_t journal_op_tid, bool disable_journal)
+  : Request<I>(image_ctx, on_finish, journal_op_tid),
     m_original_size(0), m_new_size(new_size), m_prog_ctx(prog_ctx),
-    m_new_parent_overlap(0), m_xlist_item(this)
+    m_new_parent_overlap(0), m_disable_journal(disable_journal),
+    m_xlist_item(this)
 {
 }
 
@@ -46,64 +54,6 @@ ResizeRequest<I>::~ResizeRequest() {
 }
 
 template <typename I>
-bool ResizeRequest<I>::should_complete(int r) {
-  I &image_ctx = this->m_image_ctx;
-  CephContext *cct = image_ctx.cct;
-  ldout(cct, 5) << this << " should_complete: " << " r=" << r << dendl;
-
-  if (r < 0) {
-    lderr(cct) << "resize encountered an error: " << cpp_strerror(r) << dendl;
-    return true;
-  }
-  if (m_state == STATE_FINISHED) {
-    ldout(cct, 5) << "FINISHED" << dendl;
-    return true;
-  }
-
-  RWLock::RLocker owner_lock(image_ctx.owner_lock);
-  switch (m_state) {
-  case STATE_FLUSH:
-    ldout(cct, 5) << "FLUSH" << dendl;
-    send_invalidate_cache();
-    break;
-
-  case STATE_INVALIDATE_CACHE:
-    ldout(cct, 5) << "INVALIDATE_CACHE" << dendl;
-    send_trim_image();
-    break;
-
-  case STATE_TRIM_IMAGE:
-    ldout(cct, 5) << "TRIM_IMAGE" << dendl;
-    send_update_header();
-    break;
-
-  case STATE_GROW_OBJECT_MAP:
-    ldout(cct, 5) << "GROW_OBJECT_MAP" << dendl;
-    send_update_header();
-    break;
-
-  case STATE_UPDATE_HEADER:
-    ldout(cct, 5) << "UPDATE_HEADER" << dendl;
-    if (send_shrink_object_map()) {
-      update_size_and_overlap();
-      return true;
-    }
-    break;
-
-  case STATE_SHRINK_OBJECT_MAP:
-    ldout(cct, 5) << "SHRINK_OBJECT_MAP" << dendl;
-    update_size_and_overlap();
-    return true;
-
-  default:
-    lderr(cct) << "invalid state: " << m_state << dendl;
-    assert(false);
-    break;
-  }
-  return false;
-}
-
-template <typename I>
 void ResizeRequest<I>::send() {
   I &image_ctx = this->m_image_ctx;
   assert(image_ctx.owner_lock.is_locked());
@@ -130,132 +80,262 @@ void ResizeRequest<I>::send_op() {
   I &image_ctx = this->m_image_ctx;
   assert(image_ctx.owner_lock.is_locked());
 
-  CephContext *cct = image_ctx.cct;
   if (this->is_canceled()) {
     this->async_complete(-ERESTART);
-  } else if (m_original_size == m_new_size) {
-    ldout(cct, 2) << this << " no change in size (" << m_original_size
-		  << " -> " << m_new_size << ")" << dendl;
-    m_state = STATE_FINISHED;
-    this->async_complete(0);
-  } else if (m_new_size > m_original_size) {
-    ldout(cct, 2) << this << " expanding image (" << m_original_size
-		  << " -> " << m_new_size << ")" << dendl;
-    send_grow_object_map();
   } else {
-    ldout(cct, 2) << this << " shrinking image (" << m_original_size
-		  << " -> " << m_new_size << ")" << dendl;
-    send_flush();
+    send_pre_block_writes();
   }
 }
 
 template <typename I>
-void ResizeRequest<I>::send_flush() {
+void ResizeRequest<I>::send_pre_block_writes() {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+
+  image_ctx.aio_work_queue->block_writes(create_context_callback<
+    ResizeRequest<I>, &ResizeRequest<I>::handle_pre_block_writes>(this));
+}
+
+template <typename I>
+Context *ResizeRequest<I>::handle_pre_block_writes(int *result) {
   I &image_ctx = this->m_image_ctx;
-  ldout(image_ctx.cct, 5) << this << " send_flush: "
-                          << " original_size=" << m_original_size
-                          << " new_size=" << m_new_size << dendl;
-  m_state = STATE_FLUSH;
-
-  // with clipping adjusted, ensure that write / copy-on-read operations won't
-  // (re-)create objects that we just removed. need async callback to ensure
-  // we don't have cache_lock already held
-  image_ctx.flush_async_operations(this->create_async_callback_context());
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to block writes: " << cpp_strerror(*result) << dendl;
+    image_ctx.aio_work_queue->unblock_writes();
+    return this->create_context_finisher();
+  }
+
+  return send_append_op_event();
+}
+
+template <typename I>
+Context *ResizeRequest<I>::send_append_op_event() {
+  I &image_ctx = this->m_image_ctx;
+  if (m_disable_journal || !this->template append_op_event<
+        ResizeRequest<I>, &ResizeRequest<I>::handle_append_op_event>(this)) {
+    return send_grow_object_map();
+  }
+
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+  return nullptr;
+}
+
+template <typename I>
+Context *ResizeRequest<I>::handle_append_op_event(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to commit journal entry: " << cpp_strerror(*result)
+               << dendl;
+    image_ctx.aio_work_queue->unblock_writes();
+    return this->create_context_finisher();
+  }
+
+  return send_grow_object_map();
+}
+
+template <typename I>
+void ResizeRequest<I>::send_trim_image() {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
+  TrimRequest<I> *req = TrimRequest<I>::create(
+    image_ctx, create_context_callback<
+      ResizeRequest<I>, &ResizeRequest<I>::handle_trim_image>(this),
+    m_original_size, m_new_size, m_prog_ctx);
+  req->send();
+}
+
+template <typename I>
+Context *ResizeRequest<I>::handle_trim_image(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to trim image: " << cpp_strerror(*result) << dendl;
+    return this->create_context_finisher();
+  }
+
+  send_invalidate_cache();
+  return nullptr;
 }
 
 template <typename I>
 void ResizeRequest<I>::send_invalidate_cache() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
-  ldout(image_ctx.cct, 5) << this << " send_invalidate_cache: "
-                          << " original_size=" << m_original_size
-                          << " new_size=" << m_new_size << dendl;
-  m_state = STATE_INVALIDATE_CACHE;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
 
   // need to invalidate since we're deleting objects, and
   // ObjectCacher doesn't track non-existent objects
-  image_ctx.invalidate_cache(this->create_callback_context());
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
+  image_ctx.invalidate_cache(create_async_context_callback(
+    image_ctx, create_context_callback<
+      ResizeRequest<I>, &ResizeRequest<I>::handle_invalidate_cache>(this)));
 }
 
 template <typename I>
-void ResizeRequest<I>::send_trim_image() {
+Context *ResizeRequest<I>::handle_invalidate_cache(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
-  ldout(image_ctx.cct, 5) << this << " send_trim_image: "
-                          << " original_size=" << m_original_size
-                          << " new_size=" << m_new_size << dendl;
-  m_state = STATE_TRIM_IMAGE;
-
-  TrimRequest<I> *req = new TrimRequest<I>(image_ctx,
-                                           this->create_callback_context(),
-				           m_original_size, m_new_size,
-                                           m_prog_ctx);
-  req->send();
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to invalidate cache: " << cpp_strerror(*result)
+               << dendl;
+    return this->create_context_finisher();
+  }
+
+  send_post_block_writes();
+  return nullptr;
 }
 
 template <typename I>
-void ResizeRequest<I>::send_grow_object_map() {
+Context *ResizeRequest<I>::send_grow_object_map() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
 
+  {
+    RWLock::WLocker snap_locker(image_ctx.snap_lock);
+    m_shrink_size_visible = true;
+  }
+  image_ctx.aio_work_queue->unblock_writes();
+
+  if (m_original_size == m_new_size) {
+    if (!m_disable_journal) {
+      this->commit_op_event(0);
+    }
+    return this->create_context_finisher();
+  } else if (m_new_size < m_original_size) {
+    send_trim_image();
+    return nullptr;
+  }
+
+  image_ctx.owner_lock.get_read();
   image_ctx.snap_lock.get_read();
   if (image_ctx.object_map == nullptr) {
     image_ctx.snap_lock.put_read();
-    send_update_header();
-    return;
+    image_ctx.owner_lock.put_read();
+
+    send_post_block_writes();
+    return nullptr;
   }
 
-  ldout(image_ctx.cct, 5) << this << " send_grow_object_map: "
-                          << " original_size=" << m_original_size
-                          << " new_size=" << m_new_size << dendl;
-  m_state = STATE_GROW_OBJECT_MAP;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
 
   // should have been canceled prior to releasing lock
   assert(image_ctx.exclusive_lock == nullptr ||
          image_ctx.exclusive_lock->is_lock_owner());
 
-  image_ctx.object_map->aio_resize(m_new_size, OBJECT_NONEXISTENT,
-				   this->create_callback_context());
+  image_ctx.object_map->aio_resize(
+    m_new_size, OBJECT_NONEXISTENT, create_context_callback<
+      ResizeRequest<I>, &ResizeRequest<I>::handle_grow_object_map>(this));
   image_ctx.snap_lock.put_read();
+  image_ctx.owner_lock.put_read();
+  return nullptr;
 }
 
 template <typename I>
-bool ResizeRequest<I>::send_shrink_object_map() {
+Context *ResizeRequest<I>::handle_grow_object_map(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  assert(*result == 0);
+  send_post_block_writes();
+  return nullptr;
+}
 
+template <typename I>
+Context *ResizeRequest<I>::send_shrink_object_map() {
+  I &image_ctx = this->m_image_ctx;
+
+  image_ctx.owner_lock.get_read();
   image_ctx.snap_lock.get_read();
   if (image_ctx.object_map == nullptr || m_new_size > m_original_size) {
     image_ctx.snap_lock.put_read();
-    return true;
+    image_ctx.owner_lock.put_read();
+
+    update_size_and_overlap();
+    return this->create_context_finisher();
   }
 
-  ldout(image_ctx.cct, 5) << this << " send_shrink_object_map: "
-		            << " original_size=" << m_original_size
-			    << " new_size=" << m_new_size << dendl;
-  m_state = STATE_SHRINK_OBJECT_MAP;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << " "
+                << "original_size=" << m_original_size << ", "
+                << "new_size=" << m_new_size << dendl;
 
   // should have been canceled prior to releasing lock
   assert(image_ctx.exclusive_lock == nullptr ||
          image_ctx.exclusive_lock->is_lock_owner());
 
-  image_ctx.object_map->aio_resize(m_new_size, OBJECT_NONEXISTENT,
-				   this->create_callback_context());
+  image_ctx.object_map->aio_resize(
+    m_new_size, OBJECT_NONEXISTENT, create_context_callback<
+      ResizeRequest<I>, &ResizeRequest<I>::handle_shrink_object_map>(this));
   image_ctx.snap_lock.put_read();
-  return false;
+  image_ctx.owner_lock.put_read();
+  return nullptr;
 }
 
 template <typename I>
-void ResizeRequest<I>::send_update_header() {
+Context *ResizeRequest<I>::handle_shrink_object_map(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  update_size_and_overlap();
+  assert(*result == 0);
+  return this->create_context_finisher();
+}
 
-  ldout(image_ctx.cct, 5) << this << " send_update_header: "
-                            << " original_size=" << m_original_size
-                            << " new_size=" << m_new_size << dendl;
-  m_state = STATE_UPDATE_HEADER;
+template <typename I>
+void ResizeRequest<I>::send_post_block_writes() {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
+  image_ctx.aio_work_queue->block_writes(create_context_callback<
+    ResizeRequest<I>, &ResizeRequest<I>::handle_post_block_writes>(this));
+}
+
+template <typename I>
+Context *ResizeRequest<I>::handle_post_block_writes(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    image_ctx.aio_work_queue->unblock_writes();
+    lderr(cct) << "failed to block writes prior to header update: "
+               << cpp_strerror(*result) << dendl;
+    return this->create_context_finisher();
+  }
+
+  send_update_header();
+  return nullptr;
+}
+
+template <typename I>
+void ResizeRequest<I>::send_update_header() {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << " "
+                << "original_size=" << m_original_size << ", "
+                << "new_size=" << m_new_size << dendl;;
 
   // should have been canceled prior to releasing lock
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
   assert(image_ctx.exclusive_lock == nullptr ||
          image_ctx.exclusive_lock->is_lock_owner());
 
@@ -273,8 +353,8 @@ void ResizeRequest<I>::send_update_header() {
     cls_client::set_size(&op, m_new_size);
   }
 
-  librados::AioCompletion *rados_completion =
-    this->create_callback_completion();
+  librados::AioCompletion *rados_completion = create_rados_safe_callback<
+    ResizeRequest<I>, &ResizeRequest<I>::handle_update_header>(this);
   int r = image_ctx.md_ctx.aio_operate(image_ctx.header_oid,
     				       rados_completion, &op);
   assert(r == 0);
@@ -282,6 +362,25 @@ void ResizeRequest<I>::send_update_header() {
 }
 
 template <typename I>
+Context *ResizeRequest<I>::handle_update_header(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to update image header: " << cpp_strerror(*result)
+               << dendl;
+    image_ctx.aio_work_queue->unblock_writes();
+    return this->create_context_finisher();
+  }
+
+  if (!m_disable_journal) {
+    this->commit_op_event(0);
+  }
+  return send_shrink_object_map();
+}
+
+template <typename I>
 void ResizeRequest<I>::compute_parent_overlap() {
   I &image_ctx = this->m_image_ctx;
   RWLock::RLocker l2(image_ctx.parent_lock);
@@ -295,13 +394,18 @@ void ResizeRequest<I>::compute_parent_overlap() {
 template <typename I>
 void ResizeRequest<I>::update_size_and_overlap() {
   I &image_ctx = this->m_image_ctx;
-  RWLock::WLocker snap_locker(image_ctx.snap_lock);
-  image_ctx.size = m_new_size;
+  {
+    RWLock::WLocker snap_locker(image_ctx.snap_lock);
+    image_ctx.size = m_new_size;
 
-  RWLock::WLocker parent_locker(image_ctx.parent_lock);
-  if (image_ctx.parent != NULL && m_new_size < m_original_size) {
-    image_ctx.parent_md.overlap = m_new_parent_overlap;
+    RWLock::WLocker parent_locker(image_ctx.parent_lock);
+    if (image_ctx.parent != NULL && m_new_size < m_original_size) {
+      image_ctx.parent_md.overlap = m_new_parent_overlap;
+    }
   }
+
+  // blocked by POST_BLOCK_WRITES state
+  image_ctx.aio_work_queue->unblock_writes();
 }
 
 } // namespace operation
diff --git a/src/librbd/operation/ResizeRequest.h b/src/librbd/operation/ResizeRequest.h
index dc36ae3..bd5019f 100644
--- a/src/librbd/operation/ResizeRequest.h
+++ b/src/librbd/operation/ResizeRequest.h
@@ -17,12 +17,20 @@ namespace operation {
 template <typename ImageCtxT = ImageCtx>
 class ResizeRequest : public Request<ImageCtxT> {
 public:
+  static ResizeRequest *create(ImageCtxT &image_ctx, Context *on_finish,
+                               uint64_t new_size, ProgressContext &prog_ctx,
+                               uint64_t journal_op_tid, bool disable_journal) {
+    return new ResizeRequest(image_ctx, on_finish, new_size, prog_ctx,
+                             journal_op_tid, disable_journal);
+  }
+
   ResizeRequest(ImageCtxT &image_ctx, Context *on_finish, uint64_t new_size,
-                ProgressContext &prog_ctx);
+                ProgressContext &prog_ctx, uint64_t journal_op_tid,
+                bool disable_journal);
   virtual ~ResizeRequest();
 
   inline bool shrinking() const {
-    return m_new_size < m_original_size;
+    return (m_shrink_size_visible && m_new_size < m_original_size);
   }
 
   inline uint64_t get_image_size() const {
@@ -33,10 +41,14 @@ public:
 
 protected:
   virtual void send_op();
-  virtual bool should_complete(int r);
-
-  virtual journal::Event create_event() const {
-    return journal::ResizeEvent(0, m_new_size);
+  virtual bool should_complete(int r) {
+    return true;
+  }
+  virtual bool can_affect_io() const override {
+    return true;
+  }
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::ResizeEvent(op_tid, m_new_size);
   }
 
 private:
@@ -46,27 +58,44 @@ private:
    *
    * @verbatim
    *
-   * <start> -------------> STATE_FINISHED -----------------------------\
-   *  |  .    (no change)                                               |
-   *  |  .                                                              |
-   *  |  . . . . . . . . . . . . . . . . . . . . .                      |
-   *  |                                          .                      |
-   *  |                                          v                      |
-   *  |----------> STATE_GROW_OBJECT_MAP ---> STATE_UPDATE_HEADER ------|
-   *  | (grow)                                                          |
-   *  |                                                                 |
-   *  |                                                                 |
-   *  \----------> STATE_FLUSH -------------> STATE_INVALIDATE_CACHE    |
-   *    (shrink)                                 |                      |
-   *                                             |                      |
-   *                      /----------------------/                      |
-   *                      |                                             |
-   *                      v                                             |
-   *              STATE_TRIM_IMAGE --------> STATE_UPDATE_HEADER . . .  |
-   *                                             |                   .  |
-   *                                             |                   .  |
-   *                                             v                   v  v
-   *                                  STATE_SHRINK_OBJECT_MAP ---> <finish>
+   * <start>
+   *    |
+   *    v
+   * STATE_PRE_BLOCK_WRITES
+   *    |
+   *    v
+   * STATE_APPEND_OP_EVENT (skip if journaling
+   *    |                   disabled)
+   *    | (unblock writes)
+   *    |
+   *    |
+   *    | (grow)
+   *    |\--------> STATE_GROW_OBJECT_MAP (skip if object map
+   *    |                 |                disabled)
+   *    |                 v
+   *    |           STATE_POST_BLOCK_WRITES
+   *    |                 |
+   *    |                 v
+   *    |           STATE_UPDATE_HEADER ----------------------------\
+   *    |                                                           |
+   *    | (shrink)                                                  |
+   *    |\--------> STATE_TRIM_IMAGE                                |
+   *    |                 |                                         |
+   *    |                 v                                         |
+   *    |           STATE_INVALIDATE_CACHE                          |
+   *    |                 |                                         |
+   *    |                 v                                         |
+   *    |           STATE_POST_BLOCK_WRITES                         |
+   *    |                 |                                         |
+   *    |                 v                                         |
+   *    |           STATE_UPDATE_HEADER                             |
+   *    |                 |                                         |
+   *    |                 v                                         |
+   *    |           STATE_SHRINK_OBJECT_MAP (skip if object map     |
+   *    |                 |                  disabled)              |
+   *    |                 | (unblock writes)                        |
+   *    | (no change)     v                                         |
+   *    \------------> <finish> <-----------------------------------/
    *
    * @endverbatim
    *
@@ -74,30 +103,39 @@ private:
    * The state machine will immediately transition to _FINISHED if there
    * are no objects to trim.
    */
-  enum State {
-    STATE_FLUSH,
-    STATE_INVALIDATE_CACHE,
-    STATE_TRIM_IMAGE,
-    STATE_GROW_OBJECT_MAP,
-    STATE_UPDATE_HEADER,
-    STATE_SHRINK_OBJECT_MAP,
-    STATE_FINISHED
-  };
-
-  State m_state;
+
   uint64_t m_original_size;
   uint64_t m_new_size;
   ProgressContext &m_prog_ctx;
   uint64_t m_new_parent_overlap;
+  bool m_shrink_size_visible = false;
+  bool m_disable_journal = false;
 
   typename xlist<ResizeRequest<ImageCtxT>*>::item m_xlist_item;
 
-  void send_flush();
+  void send_pre_block_writes();
+  Context *handle_pre_block_writes(int *result);
+
+  Context *send_append_op_event();
+  Context *handle_append_op_event(int *result);
+
   void send_invalidate_cache();
+  Context *handle_invalidate_cache(int *result);
+
   void send_trim_image();
-  void send_grow_object_map();
-  bool send_shrink_object_map();
+  Context *handle_trim_image(int *result);
+
+  Context *send_grow_object_map();
+  Context *handle_grow_object_map(int *result);
+
+  Context *send_shrink_object_map();
+  Context *handle_shrink_object_map(int *result);
+
+  void send_post_block_writes();
+  Context *handle_post_block_writes(int *result);
+
   void send_update_header();
+  Context *handle_update_header(int *result);
 
   void compute_parent_overlap();
   void update_size_and_overlap();
diff --git a/src/librbd/operation/SnapshotCreateRequest.cc b/src/librbd/operation/SnapshotCreateRequest.cc
index 63f19d4..39257a7 100644
--- a/src/librbd/operation/SnapshotCreateRequest.cc
+++ b/src/librbd/operation/SnapshotCreateRequest.cc
@@ -9,6 +9,7 @@
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageWatcher.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/Utils.h"
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -17,46 +18,53 @@
 namespace librbd {
 namespace operation {
 
+using util::create_async_context_callback;
+using util::create_context_callback;
+using util::create_rados_safe_callback;
+
 namespace {
 
-template <typename I>
-std::ostream& operator<<(std::ostream& os,
-                         const typename SnapshotCreateRequest<I>::State& state) {
-  switch(state) {
-  case SnapshotCreateRequest<I>::STATE_SUSPEND_REQUESTS:
-    os << "SUSPEND_REQUESTS";
-    break;
-  case SnapshotCreateRequest<I>::STATE_SUSPEND_AIO:
-    os << "SUSPEND_AIO";
-    break;
-  case SnapshotCreateRequest<I>::STATE_ALLOCATE_SNAP_ID:
-    os << "ALLOCATE_SNAP_ID";
-    break;
-  case SnapshotCreateRequest<I>::STATE_CREATE_SNAP:
-    os << "CREATE_SNAP";
-    break;
-  case SnapshotCreateRequest<I>::STATE_CREATE_OBJECT_MAP:
-    os << "CREATE_OBJECT_MAP";
-    break;
-  case SnapshotCreateRequest<I>::STATE_RELEASE_SNAP_ID:
-    os << "RELEASE_SNAP_ID";
-    break;
-  default:
-    os << "UNKNOWN (" << static_cast<uint32_t>(state) << ")";
-    break;
+template <typename ImageCtxT>
+struct C_CreateSnapId: public Context {
+  ImageCtxT &image_ctx;
+  uint64_t *snap_id;
+  Context *on_finish;
+
+  C_CreateSnapId(ImageCtxT &image_ctx, uint64_t *snap_id, Context *on_finish)
+    : image_ctx(image_ctx), snap_id(snap_id), on_finish(on_finish) {
   }
-  return os;
-}
+
+  virtual void finish(int r) {
+    r = image_ctx.md_ctx.selfmanaged_snap_create(snap_id);
+    on_finish->complete(r);
+  }
+};
+
+template <typename ImageCtxT>
+struct C_RemoveSnapId: public Context {
+  ImageCtxT &image_ctx;
+  uint64_t snap_id;
+  Context *on_finish;
+
+  C_RemoveSnapId(ImageCtxT &image_ctx, uint64_t snap_id, Context *on_finish)
+    : image_ctx(image_ctx), snap_id(snap_id), on_finish(on_finish) {
+  }
+
+  virtual void finish(int r) {
+    r = image_ctx.md_ctx.selfmanaged_snap_remove(snap_id);
+    on_finish->complete(r);
+  }
+};
 
 } // anonymous namespace
 
 template <typename I>
 SnapshotCreateRequest<I>::SnapshotCreateRequest(I &image_ctx,
                                                 Context *on_finish,
-                                                const std::string &snap_name)
-  : Request<I>(image_ctx, on_finish), m_snap_name(snap_name), m_ret_val(0),
-    m_aio_suspended(false), m_requests_suspended(false),
-    m_snap_id(CEPH_NOSNAP), m_snap_created(false) {
+                                                const std::string &snap_name,
+                                                uint64_t journal_op_tid)
+  : Request<I>(image_ctx, on_finish, journal_op_tid), m_snap_name(snap_name),
+    m_ret_val(0), m_snap_id(CEPH_NOSNAP) {
 }
 
 template <typename I>
@@ -65,128 +73,126 @@ void SnapshotCreateRequest<I>::send_op() {
 }
 
 template <typename I>
-bool SnapshotCreateRequest<I>::should_complete(int r) {
+void SnapshotCreateRequest<I>::send_suspend_requests() {
   I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
-  ldout(cct, 5) << this << " " << __func__ << ": state=" << m_state << ", "
-                << "r=" << r << dendl;
-  int orig_result = r;
-  r = filter_state_return_code(r);
-  if (r < 0) {
-    lderr(cct) << "encountered error: " << cpp_strerror(r) << dendl;
-    if (m_ret_val == 0) {
-      m_ret_val = r;
-    }
-  }
+  ldout(cct, 5) << this << " " << __func__ << dendl;
 
-  if (m_ret_val < 0) {
-    return should_complete_error();
-  }
+  // TODO suspend (shrink) resize to ensure consistent RBD mirror
+  send_suspend_aio();
+}
 
-  RWLock::RLocker owner_lock(image_ctx.owner_lock);
-  bool finished = false;
-  switch (m_state) {
-  case STATE_SUSPEND_REQUESTS:
-    send_suspend_aio();
-    break;
-  case STATE_SUSPEND_AIO:
-    send_allocate_snap_id();
-    break;
-  case STATE_ALLOCATE_SNAP_ID:
-    send_create_snap();
-    break;
-  case STATE_CREATE_SNAP:
-    if (orig_result == 0) {
-      update_snap_context();
-      finished = send_create_object_map();
-    } else {
-      assert(orig_result == -ESTALE);
-      send_allocate_snap_id();
-    }
-    break;
-  case STATE_CREATE_OBJECT_MAP:
-    finished = true;
-    break;
-  default:
-    assert(false);
-    break;
-  }
+template <typename I>
+Context *SnapshotCreateRequest<I>::handle_suspend_requests(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
 
-  if (finished) {
-    resume_aio();
-    resume_requests();
-  }
-  return finished;
+  // TODO
+  send_suspend_aio();
+  return nullptr;
 }
 
 template <typename I>
-bool SnapshotCreateRequest<I>::should_complete_error() {
+void SnapshotCreateRequest<I>::send_suspend_aio() {
   I &image_ctx = this->m_image_ctx;
-  CephContext *cct = image_ctx.cct;
-  lderr(cct) << this << " " << __func__ << ": "
-             << "ret_val=" << m_ret_val << dendl;
+  assert(image_ctx.owner_lock.is_locked());
 
-  // only valid exit points during error recovery
-  bool finished = true;
-  if (m_state != STATE_RELEASE_SNAP_ID) {
-    finished = send_release_snap_id();
-  }
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
 
-  if (finished) {
-    resume_aio();
-    resume_requests();
-  }
-  return finished;
+  image_ctx.aio_work_queue->block_writes(create_context_callback<
+    SnapshotCreateRequest<I>,
+    &SnapshotCreateRequest<I>::handle_suspend_aio>(this));
 }
 
 template <typename I>
-void SnapshotCreateRequest<I>::send_suspend_requests() {
+Context *SnapshotCreateRequest<I>::handle_suspend_aio(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
 
-  // TODO suspend (shrink) resize to ensure consistent RBD mirror
-  send_suspend_aio();
+  if (*result < 0) {
+    lderr(cct) << "failed to block writes: " << cpp_strerror(*result) << dendl;
+    image_ctx.aio_work_queue->unblock_writes();
+    return this->create_context_finisher();
+  }
+
+  send_append_op_event();
+  return nullptr;
 }
 
 template <typename I>
-void SnapshotCreateRequest<I>::send_suspend_aio() {
+void SnapshotCreateRequest<I>::send_append_op_event() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  if (!this->template append_op_event<
+        SnapshotCreateRequest<I>,
+        &SnapshotCreateRequest<I>::handle_append_op_event>(this)) {
+    send_allocate_snap_id();
+    return;
+  }
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
+}
+
+template <typename I>
+Context *SnapshotCreateRequest<I>::handle_append_op_event(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
 
-  m_state = STATE_SUSPEND_AIO;
-  m_aio_suspended = true;
+  if (*result < 0) {
+    image_ctx.aio_work_queue->unblock_writes();
+    lderr(cct) << "failed to commit journal entry: " << cpp_strerror(*result)
+               << dendl;
+    return this->create_context_finisher();
+  }
 
-  // can issue a re-entrant callback if no IO in-progress
-  image_ctx.aio_work_queue->block_writes(this->create_async_callback_context());
+  send_allocate_snap_id();
+  return nullptr;
 }
 
 template <typename I>
 void SnapshotCreateRequest<I>::send_allocate_snap_id() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
-
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
-  m_state = STATE_ALLOCATE_SNAP_ID;
 
   // TODO create an async version of selfmanaged_snap_create
-  int r = image_ctx.md_ctx.selfmanaged_snap_create(&m_snap_id);
-  this->async_complete(r);
+  image_ctx.op_work_queue->queue(new C_CreateSnapId<I>(
+    image_ctx, &m_snap_id, create_context_callback<
+      SnapshotCreateRequest<I>,
+      &SnapshotCreateRequest<I>::handle_allocate_snap_id>(this)), 0);
 }
 
 template <typename I>
-void SnapshotCreateRequest<I>::send_create_snap() {
+Context *SnapshotCreateRequest<I>::handle_allocate_snap_id(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
-  RWLock::RLocker snap_locker(image_ctx.snap_lock);
-  RWLock::RLocker parent_locker(image_ctx.parent_lock);
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    save_result(result);
+    finalize(*result);
+    lderr(cct) << "failed to allocate snapshot id: " << cpp_strerror(*result)
+               << dendl;
+    return this->create_context_finisher();
+  }
+
+  send_create_snap();
+  return nullptr;
+}
 
+template <typename I>
+void SnapshotCreateRequest<I>::send_create_snap() {
+  I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
-  m_state = STATE_CREATE_SNAP;
+
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
+  RWLock::RLocker snap_locker(image_ctx.snap_lock);
+  RWLock::RLocker parent_locker(image_ctx.parent_lock);
 
   // should have been canceled prior to releasing lock
   assert(image_ctx.exclusive_lock == nullptr ||
@@ -206,84 +212,118 @@ void SnapshotCreateRequest<I>::send_create_snap() {
     cls_client::snapshot_add(&op, m_snap_id, m_snap_name);
   }
 
-  librados::AioCompletion *rados_completion =
-    this->create_callback_completion();
+  librados::AioCompletion *rados_completion = create_rados_safe_callback<
+    SnapshotCreateRequest<I>,
+    &SnapshotCreateRequest<I>::handle_create_snap>(this);
   int r = image_ctx.md_ctx.aio_operate(image_ctx.header_oid,
-                                         rados_completion, &op);
+                                       rados_completion, &op);
   assert(r == 0);
   rados_completion->release();
 }
 
 template <typename I>
-bool SnapshotCreateRequest<I>::send_create_object_map() {
+Context *SnapshotCreateRequest<I>::handle_create_snap(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result == -ESTALE) {
+    send_allocate_snap_id();
+    return nullptr;
+  } else if (*result < 0) {
+    save_result(result);
+    send_release_snap_id();
+    return nullptr;
+  }
+
+  return send_create_object_map();
+}
+
+template <typename I>
+Context *SnapshotCreateRequest<I>::send_create_object_map() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+
+  update_snap_context();
+
+  image_ctx.snap_lock.get_read();
+  if (image_ctx.object_map == nullptr) {
+    image_ctx.snap_lock.put_read();
+
+    finalize(0);
+    return this->create_context_finisher();
+  }
+
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
 
   {
-    RWLock::RLocker snap_locker(image_ctx.snap_lock);
     RWLock::RLocker object_map_lock(image_ctx.object_map_lock);
-    if (image_ctx.object_map != nullptr) {
-      CephContext *cct = image_ctx.cct;
-      ldout(cct, 5) << this << " " << __func__ << dendl;
-      m_state = STATE_CREATE_OBJECT_MAP;
-
-      image_ctx.object_map->snapshot_add(m_snap_id,
-                                         this->create_callback_context());
-      return false;
-    }
+    image_ctx.object_map->snapshot_add(
+      m_snap_id, create_context_callback<
+        SnapshotCreateRequest<I>,
+        &SnapshotCreateRequest<I>::handle_create_object_map>(this));
   }
-  return true;
+  image_ctx.snap_lock.put_read();
+  return nullptr;
 }
 
 template <typename I>
-bool SnapshotCreateRequest<I>::send_release_snap_id() {
+Context *SnapshotCreateRequest<I>::handle_create_object_map(int *result) {
   I &image_ctx = this->m_image_ctx;
-  if (m_snap_id != CEPH_NOSNAP && !m_snap_created) {
-    CephContext *cct = image_ctx.cct;
-    ldout(cct, 5) << this << " " << __func__ << ": snap_id=" << m_snap_id
-                  << dendl;
-    m_state = STATE_RELEASE_SNAP_ID;
-
-    // TODO add async version of selfmanaged_snap_remove
-    int r = image_ctx.md_ctx.selfmanaged_snap_remove(m_snap_id);
-    m_snap_id = CEPH_NOSNAP;
-
-    this->async_complete(r);
-    return false;
-  }
-  return true;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  assert(*result == 0);
+
+  finalize(0);
+  return this->create_context_finisher();
+}
+
+template <typename I>
+void SnapshotCreateRequest<I>::send_release_snap_id() {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+
+  assert(m_snap_id != CEPH_NOSNAP);
+
+  // TODO create an async version of selfmanaged_snap_remove
+  image_ctx.op_work_queue->queue(new C_RemoveSnapId<I>(
+    image_ctx, m_snap_id, create_context_callback<
+      SnapshotCreateRequest<I>,
+      &SnapshotCreateRequest<I>::handle_release_snap_id>(this)), 0);
 }
 
 template <typename I>
-void SnapshotCreateRequest<I>::resume_aio() {
+Context *SnapshotCreateRequest<I>::handle_release_snap_id(int *result) {
   I &image_ctx = this->m_image_ctx;
-  if (m_aio_suspended) {
-    CephContext *cct = image_ctx.cct;
-    ldout(cct, 5) << this << " " << __func__ << dendl;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
 
-    image_ctx.aio_work_queue->unblock_writes();
-    m_aio_suspended = false;
-  }
+  assert(m_ret_val < 0);
+  *result = m_ret_val;
+
+  finalize(m_ret_val);
+  return this->create_context_finisher();
 }
 
 template <typename I>
-void SnapshotCreateRequest<I>::resume_requests() {
+void SnapshotCreateRequest<I>::finalize(int r) {
   I &image_ctx = this->m_image_ctx;
-  if (m_requests_suspended) {
-    CephContext *cct = image_ctx.cct;
-    ldout(cct, 5) << this << " " << __func__ << dendl;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << r << dendl;
 
-    // TODO
-    m_requests_suspended = false;
+  if (r == 0) {
+    this->commit_op_event(0);
   }
+  image_ctx.aio_work_queue->unblock_writes();
 }
 
 template <typename I>
 void SnapshotCreateRequest<I>::update_snap_context() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
-  m_snap_created = true;
 
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
   RWLock::WLocker snap_locker(image_ctx.snap_lock);
   if (image_ctx.old_format) {
     return;
diff --git a/src/librbd/operation/SnapshotCreateRequest.h b/src/librbd/operation/SnapshotCreateRequest.h
index 249bcaf..6b52681 100644
--- a/src/librbd/operation/SnapshotCreateRequest.h
+++ b/src/librbd/operation/SnapshotCreateRequest.h
@@ -33,17 +33,20 @@ public:
    *               v
    *           STATE_SUSPEND_AIO * * * * * * * * * * * * *
    *               |                                     *
+   *               v                                     *
+   *           STATE_APPEND_OP_EVENT (skip if journal    *
+   *               |                  disabled)          *
    *   (retry)     v                                     *
-   *   . . . > STATE_ALLOCATE_SNAP_ID  * *               *
-   *   .           |                     *               *
-   *   .           v                     *               *
-   *   . . . . STATE_CREATE_SNAP * * * * *               *
-   *               |                     *               *
-   *               v                     *               *
-   *           STATE_CREATE_OBJECT_MAP   *               *
-   *               |                     *               *
-   *               |                     *               *
-   *               |                     v               *
+   *   . . . > STATE_ALLOCATE_SNAP_ID                    *
+   *   .           |                                     *
+   *   .           v                                     *
+   *   . . . . STATE_CREATE_SNAP * * * * * * * * * *     *
+   *               |                               *     *
+   *               v                               *     *
+   *           STATE_CREATE_OBJECT_MAP (skip if    *     *
+   *               |                    disabled)  *     *
+   *               |                               *     *
+   *               |                               v     *
    *               |              STATE_RELEASE_SNAP_ID  *
    *               |                     |               *
    *               |                     v               *
@@ -56,67 +59,59 @@ public:
    * to abort, the error path is followed to record the result in the journal
    * (if enabled) and bubble the originating error code back to the client.
    */
-  enum State {
-    STATE_SUSPEND_REQUESTS,
-    STATE_SUSPEND_AIO,
-    STATE_ALLOCATE_SNAP_ID,
-    STATE_CREATE_SNAP,
-    STATE_CREATE_OBJECT_MAP,
-    STATE_RELEASE_SNAP_ID
-  };
-
   SnapshotCreateRequest(ImageCtxT &image_ctx, Context *on_finish,
-		        const std::string &snap_name);
+		        const std::string &snap_name, uint64_t journal_op_tid);
 
 protected:
   virtual void send_op();
-  virtual bool should_complete(int r);
-
-  virtual int filter_return_code(int r) const {
-    if (m_ret_val < 0) {
-      return m_ret_val;
-    }
-    return r;
+  virtual bool should_complete(int r) {
+    return true;
   }
-
-  virtual journal::Event create_event() const {
-    return journal::SnapCreateEvent(0, m_snap_name);
+  virtual bool can_affect_io() const override {
+    return true;
+  }
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapCreateEvent(op_tid, m_snap_name);
   }
 
 private:
   std::string m_snap_name;
-  State m_state;
 
   int m_ret_val;
 
-  bool m_aio_suspended;
-  bool m_requests_suspended;
-
   uint64_t m_snap_id;
-  bool m_snap_created;
-
   uint64_t m_size;
   parent_info m_parent_info;
 
-  int filter_state_return_code(int r) const {
-    if (m_state == STATE_CREATE_SNAP && r == -ESTALE) {
-      return 0;
-    }
-    return r;
-  }
-
-  bool should_complete_error();
-
   void send_suspend_requests();
+  Context *handle_suspend_requests(int *result);
+
   void send_suspend_aio();
+  Context *handle_suspend_aio(int *result);
+
+  void send_append_op_event();
+  Context *handle_append_op_event(int *result);
+
   void send_allocate_snap_id();
+  Context *handle_allocate_snap_id(int *result);
+
   void send_create_snap();
-  bool send_create_object_map();
-  bool send_release_snap_id();
+  Context *handle_create_snap(int *result);
 
-  void resume_aio();
-  void resume_requests();
+  Context *send_create_object_map();
+  Context *handle_create_object_map(int *result);
+
+  void send_release_snap_id();
+  Context *handle_release_snap_id(int *result);
+
+  void finalize(int r);
   void update_snap_context();
+
+  void save_result(int *result) {
+    if (m_ret_val == 0 && *result < 0) {
+      m_ret_val = *result;
+    }
+  }
 };
 
 } // namespace operation
diff --git a/src/librbd/operation/SnapshotProtectRequest.h b/src/librbd/operation/SnapshotProtectRequest.h
index 02484e9..e8abfb2 100644
--- a/src/librbd/operation/SnapshotProtectRequest.h
+++ b/src/librbd/operation/SnapshotProtectRequest.h
@@ -46,8 +46,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapProtectEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapProtectEvent(op_tid, m_snap_name);
   }
 
 private:
diff --git a/src/librbd/operation/SnapshotRemoveRequest.cc b/src/librbd/operation/SnapshotRemoveRequest.cc
index 81e0b96..1bdba71 100644
--- a/src/librbd/operation/SnapshotRemoveRequest.cc
+++ b/src/librbd/operation/SnapshotRemoveRequest.cc
@@ -34,6 +34,9 @@ std::ostream& operator<<(std::ostream& os,
   case SnapshotRemoveRequest<I>::STATE_RELEASE_SNAP_ID:
     os << "RELEASE_SNAP_ID";
     break;
+  case SnapshotRemoveRequest<I>::STATE_ERROR:
+    os << "STATE_ERROR";
+    break;
   default:
     os << "UNKNOWN (" << static_cast<uint32_t>(state) << ")";
     break;
@@ -127,6 +130,8 @@ void SnapshotRemoveRequest<I>::send_remove_child() {
     int r = image_ctx.get_parent_spec(m_snap_id, &our_pspec);
     if (r < 0) {
       lderr(cct) << "failed to retrieve parent spec" << dendl;
+      m_state = STATE_ERROR;
+
       this->async_complete(r);
       return;
     }
diff --git a/src/librbd/operation/SnapshotRemoveRequest.h b/src/librbd/operation/SnapshotRemoveRequest.h
index ea950a5..39123ff 100644
--- a/src/librbd/operation/SnapshotRemoveRequest.h
+++ b/src/librbd/operation/SnapshotRemoveRequest.h
@@ -52,7 +52,8 @@ public:
     STATE_REMOVE_OBJECT_MAP,
     STATE_REMOVE_CHILD,
     STATE_REMOVE_SNAP,
-    STATE_RELEASE_SNAP_ID
+    STATE_RELEASE_SNAP_ID,
+    STATE_ERROR
   };
 
   SnapshotRemoveRequest(ImageCtxT &image_ctx, Context *on_finish,
@@ -62,8 +63,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapRemoveEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapRemoveEvent(op_tid, m_snap_name);
   }
 
 private:
diff --git a/src/librbd/operation/SnapshotRenameRequest.h b/src/librbd/operation/SnapshotRenameRequest.h
index 19a72c7..503058d 100644
--- a/src/librbd/operation/SnapshotRenameRequest.h
+++ b/src/librbd/operation/SnapshotRenameRequest.h
@@ -42,8 +42,8 @@ public:
   SnapshotRenameRequest(ImageCtxT &image_ctx, Context *on_finish,
                         uint64_t snap_id, const std::string &snap_name);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapRenameEvent(0, m_snap_id, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapRenameEvent(op_tid, m_snap_id, m_snap_name);
   }
 
 protected:
diff --git a/src/librbd/operation/SnapshotRollbackRequest.cc b/src/librbd/operation/SnapshotRollbackRequest.cc
index f7df78b..e1e472e 100644
--- a/src/librbd/operation/SnapshotRollbackRequest.cc
+++ b/src/librbd/operation/SnapshotRollbackRequest.cc
@@ -5,6 +5,7 @@
 #include "include/rados/librados.hpp"
 #include "common/dout.h"
 #include "common/errno.h"
+#include "librbd/AioImageRequestWQ.h"
 #include "librbd/AsyncObjectThrottle.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/ObjectMap.h"
@@ -21,40 +22,17 @@
 namespace librbd {
 namespace operation {
 
-namespace {
+using util::create_context_callback;
+using util::create_rados_safe_callback;
 
-template <typename I>
-std::ostream& operator<<(std::ostream& os,
-                         const typename SnapshotRollbackRequest<I>::State& state) {
-  switch(state) {
-  case SnapshotRollbackRequest<I>::STATE_RESIZE_IMAGE:
-    os << "RESIZE_IMAGE";
-    break;
-  case SnapshotRollbackRequest<I>::STATE_ROLLBACK_OBJECT_MAP:
-    os << "ROLLBACK_OBJECT_MAP";
-    break;
-  case SnapshotRollbackRequest<I>::STATE_ROLLBACK_OBJECTS:
-    os << "ROLLBACK_OBJECTS";
-    break;
-  case SnapshotRollbackRequest<I>::STATE_REFRESH_OBJECT_MAP:
-    os << "REFRESH_OBJECT_MAP";
-    break;
-  case SnapshotRollbackRequest<I>::STATE_INVALIDATE_CACHE:
-    os << "INVALIDATE_CACHE";
-    break;
-  default:
-    os << "UNKNOWN (" << static_cast<uint32_t>(state) << ")";
-    break;
-  }
-  return os;
-}
+namespace {
 
 template <typename I>
-class C_RollbackObject : public C_AsyncObjectThrottle<> {
+class C_RollbackObject : public C_AsyncObjectThrottle<I> {
 public:
-  C_RollbackObject(AsyncObjectThrottle<> &throttle, I *image_ctx,
+  C_RollbackObject(AsyncObjectThrottle<I> &throttle, I *image_ctx,
                    uint64_t snap_id, uint64_t object_num)
-    : C_AsyncObjectThrottle(throttle, *image_ctx), m_snap_id(snap_id),
+    : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_snap_id(snap_id),
       m_object_num(object_num) {
   }
 
@@ -97,57 +75,52 @@ SnapshotRollbackRequest<I>::SnapshotRollbackRequest(I &image_ctx,
 
 template <typename I>
 SnapshotRollbackRequest<I>::~SnapshotRollbackRequest() {
+  I &image_ctx = this->m_image_ctx;
+  if (m_blocking_writes) {
+    image_ctx.aio_work_queue->unblock_writes();
+  }
   delete m_object_map;
 }
 
 template <typename I>
 void SnapshotRollbackRequest<I>::send_op() {
-  send_resize_image();
+  send_block_writes();
 }
 
 template <typename I>
-bool SnapshotRollbackRequest<I>::should_complete(int r) {
+void SnapshotRollbackRequest<I>::send_block_writes() {
   I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
-  ldout(cct, 5) << this << " " << __func__ << ": state=" << m_state << ", "
-                << "r=" << r << dendl;
-  if (r < 0) {
-    lderr(cct) << "encountered error: " << cpp_strerror(r) << dendl;
-    return true;
-  }
+  ldout(cct, 5) << this << " " << __func__ << dendl;
 
-  RWLock::RLocker owner_lock(image_ctx.owner_lock);
-  bool finished = false;
-  switch (m_state) {
-  case STATE_RESIZE_IMAGE:
-    send_rollback_object_map();
-    break;
-  case STATE_ROLLBACK_OBJECT_MAP:
-    send_rollback_objects();
-    break;
-  case STATE_ROLLBACK_OBJECTS:
-    finished = send_refresh_object_map();
-    break;
-  case STATE_REFRESH_OBJECT_MAP:
-    finished = send_invalidate_cache();
-    break;
-  case STATE_INVALIDATE_CACHE:
-    finished = true;
-    break;
-  default:
-    assert(false);
-    break;
+  m_blocking_writes = true;
+  image_ctx.aio_work_queue->block_writes(create_context_callback<
+    SnapshotRollbackRequest<I>,
+    &SnapshotRollbackRequest<I>::handle_block_writes>(this));
+}
+
+template <typename I>
+Context *SnapshotRollbackRequest<I>::handle_block_writes(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to block writes: " << cpp_strerror(*result) << dendl;
+    return this->create_context_finisher();
   }
-  return finished;
+
+  send_resize_image();
+  return nullptr;
 }
 
 template <typename I>
 void SnapshotRollbackRequest<I>::send_resize_image() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
 
   uint64_t current_size;
   {
+    RWLock::RLocker owner_locker(image_ctx.owner_lock);
     RWLock::RLocker snap_locker(image_ctx.snap_lock);
     current_size = image_ctx.get_image_size(CEPH_NOSNAP);
   }
@@ -159,29 +132,47 @@ void SnapshotRollbackRequest<I>::send_resize_image() {
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
-  m_state = STATE_RESIZE_IMAGE;
 
-  ResizeRequest<I> *req = new ResizeRequest<I>(image_ctx,
-                                               this->create_callback_context(),
-                                               m_snap_size, m_no_op_prog_ctx);
+  Context *ctx = create_context_callback<
+    SnapshotRollbackRequest<I>,
+    &SnapshotRollbackRequest<I>::handle_resize_image>(this);
+  ResizeRequest<I> *req = ResizeRequest<I>::create(image_ctx, ctx, m_snap_size,
+                                                   m_no_op_prog_ctx, 0, true);
   req->send();
 }
 
 template <typename I>
+Context *SnapshotRollbackRequest<I>::handle_resize_image(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to resize image for rollback: "
+               << cpp_strerror(*result) << dendl;
+    return this->create_context_finisher();
+  }
+
+  send_rollback_object_map();
+  return nullptr;
+}
+
+template <typename I>
 void SnapshotRollbackRequest<I>::send_rollback_object_map() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
 
   {
+    RWLock::RLocker owner_locker(image_ctx.owner_lock);
     RWLock::RLocker snap_locker(image_ctx.snap_lock);
     RWLock::WLocker object_map_lock(image_ctx.object_map_lock);
     if (image_ctx.object_map != nullptr) {
       CephContext *cct = image_ctx.cct;
       ldout(cct, 5) << this << " " << __func__ << dendl;
-      m_state = STATE_ROLLBACK_OBJECT_MAP;
 
-      image_ctx.object_map->rollback(m_snap_id,
-                                     this->create_callback_context());
+      Context *ctx = create_context_callback<
+        SnapshotRollbackRequest<I>,
+        &SnapshotRollbackRequest<I>::handle_rollback_object_map>(this);
+      image_ctx.object_map->rollback(m_snap_id, ctx);
       return;
     }
   }
@@ -190,14 +181,23 @@ void SnapshotRollbackRequest<I>::send_rollback_object_map() {
 }
 
 template <typename I>
-void SnapshotRollbackRequest<I>::send_rollback_objects() {
+Context *SnapshotRollbackRequest<I>::handle_rollback_object_map(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
 
+  assert(*result == 0);
+  send_rollback_objects();
+  return nullptr;
+}
+
+template <typename I>
+void SnapshotRollbackRequest<I>::send_rollback_objects() {
+  I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
-  m_state = STATE_ROLLBACK_OBJECTS;
 
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
   uint64_t num_objects;
   {
     RWLock::RLocker snap_locker(image_ctx.snap_lock);
@@ -205,62 +205,105 @@ void SnapshotRollbackRequest<I>::send_rollback_objects() {
                                            image_ctx.get_current_size());
   }
 
-  Context *ctx = this->create_callback_context();
+  Context *ctx = create_context_callback<
+    SnapshotRollbackRequest<I>,
+    &SnapshotRollbackRequest<I>::handle_rollback_objects>(this);
   typename AsyncObjectThrottle<I>::ContextFactory context_factory(
     boost::lambda::bind(boost::lambda::new_ptr<C_RollbackObject<I> >(),
       boost::lambda::_1, &image_ctx, m_snap_id, boost::lambda::_2));
-  AsyncObjectThrottle<I> *throttle = new AsyncObjectThrottle<>(
+  AsyncObjectThrottle<I> *throttle = new AsyncObjectThrottle<I>(
     this, image_ctx, context_factory, ctx, &m_prog_ctx, 0, num_objects);
   throttle->start_ops(image_ctx.concurrent_management_ops);
 }
 
 template <typename I>
-bool SnapshotRollbackRequest<I>::send_refresh_object_map() {
+Context *SnapshotRollbackRequest<I>::handle_rollback_objects(int *result) {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to rollback objects: " << cpp_strerror(*result)
+               << dendl;
+    return this->create_context_finisher();
+  }
 
-  if (image_ctx.object_map == nullptr) {
+  return send_refresh_object_map();
+}
+
+template <typename I>
+Context *SnapshotRollbackRequest<I>::send_refresh_object_map() {
+  I &image_ctx = this->m_image_ctx;
+
+  bool object_map_enabled;
+  {
+    RWLock::RLocker owner_locker(image_ctx.owner_lock);
+    RWLock::RLocker snap_locker(image_ctx.snap_lock);
+    object_map_enabled = (image_ctx.object_map != nullptr);
+  }
+  if (!object_map_enabled) {
     return send_invalidate_cache();
   }
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
-  m_state = STATE_REFRESH_OBJECT_MAP;
 
   m_object_map = image_ctx.create_object_map(CEPH_NOSNAP);
 
-  image_ctx.owner_lock.put_read();
-  Context *ctx = this->create_callback_context();
+  Context *ctx = create_context_callback<
+    SnapshotRollbackRequest<I>,
+    &SnapshotRollbackRequest<I>::handle_refresh_object_map>(this);
   m_object_map->open(ctx);
-  image_ctx.owner_lock.get_read();
+  return nullptr;
+}
 
-  return false;
+template <typename I>
+Context *SnapshotRollbackRequest<I>::handle_refresh_object_map(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  assert(*result == 0);
+  return send_invalidate_cache();
 }
 
 template <typename I>
-bool SnapshotRollbackRequest<I>::send_invalidate_cache() {
+Context *SnapshotRollbackRequest<I>::send_invalidate_cache() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
 
   apply();
-
   if (image_ctx.object_cacher == NULL) {
-    return true;
+    return this->create_context_finisher();
   }
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
-  m_state = STATE_INVALIDATE_CACHE;
 
-  image_ctx.invalidate_cache(this->create_callback_context());
-  return false;
+  Context *ctx = create_context_callback<
+    SnapshotRollbackRequest<I>,
+    &SnapshotRollbackRequest<I>::handle_invalidate_cache>(this);
+  image_ctx.invalidate_cache(ctx);
+  return nullptr;
+}
+
+template <typename I>
+Context *SnapshotRollbackRequest<I>::handle_invalidate_cache(int *result) {
+  I &image_ctx = this->m_image_ctx;
+  CephContext *cct = image_ctx.cct;
+  ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  if (*result < 0) {
+    lderr(cct) << "failed to invalidate cache: " << cpp_strerror(*result)
+               << dendl;
+  }
+  return this->create_context_finisher();
 }
 
 template <typename I>
 void SnapshotRollbackRequest<I>::apply() {
   I &image_ctx = this->m_image_ctx;
 
-  assert(image_ctx.owner_lock.is_locked());
+  RWLock::RLocker owner_locker(image_ctx.owner_lock);
   RWLock::WLocker snap_locker(image_ctx.snap_lock);
   if (image_ctx.object_map != nullptr) {
     std::swap(m_object_map, image_ctx.object_map);
diff --git a/src/librbd/operation/SnapshotRollbackRequest.h b/src/librbd/operation/SnapshotRollbackRequest.h
index 54dd742..53fb85b 100644
--- a/src/librbd/operation/SnapshotRollbackRequest.h
+++ b/src/librbd/operation/SnapshotRollbackRequest.h
@@ -27,24 +27,27 @@ public:
    * @verbatim
    *
    * <start> ---------\
-   *  .               |
-   *  .               v
-   *  .         STATE_RESIZE_IMAGE
-   *  .               |
-   *  . (skip path)   v
-   *  . . . . > STATE_ROLLBACK_OBJECT_MAP
-   *  .               |
-   *  .               v
-   *  . . . . > STATE_ROLLBACK_OBJECTS . . . . . . . . . . .
-   *                  |                                    .
-   *                  v                                    .
-   *            STATE_REFRESH_OBJECT_MAP  (skip if object  .
-   *                  |                    map disabled)   .
-   *                  v                                    .
-   *            STATE_INVALIDATE_CACHE                     .
-   *                  |                                    .
-   *                  v                                    .
-   *              <finish> < . . . . . . . . . . . . . . . .
+   *                  |
+   *                  v
+   *            STATE_BLOCK_WRITES
+   *                  |
+   *                  v
+   *            STATE_RESIZE_IMAGE (skip if resize not
+   *                  |             required)
+   *                  v
+   *            STATE_ROLLBACK_OBJECT_MAP (skip if object
+   *                  |                    map disabled)
+   *                  v
+   *            STATE_ROLLBACK_OBJECTS
+   *                  |
+   *                  v
+   *            STATE_REFRESH_OBJECT_MAP  (skip if object
+   *                  |                    map disabled)
+   *                  v
+   *            STATE_INVALIDATE_CACHE (skip if cache
+   *                  |                 disabled)
+   *                  v
+   *              <finish>
    *
    * @endverbatim
    *
@@ -52,13 +55,6 @@ public:
    * The _ROLLBACK_OBJECT_MAP state is skipped if the object map isn't enabled.
    * The _INVALIDATE_CACHE state is skipped if the cache isn't enabled.
    */
-  enum State {
-    STATE_RESIZE_IMAGE,
-    STATE_ROLLBACK_OBJECT_MAP,
-    STATE_ROLLBACK_OBJECTS,
-    STATE_REFRESH_OBJECT_MAP,
-    STATE_INVALIDATE_CACHE
-  };
 
   SnapshotRollbackRequest(ImageCtxT &image_ctx, Context *on_finish,
                           const std::string &snap_name, uint64_t snap_id,
@@ -67,10 +63,12 @@ public:
 
 protected:
   virtual void send_op();
-  virtual bool should_complete(int r);
+  virtual bool should_complete(int r) {
+    return true;
+  }
 
-  virtual journal::Event create_event() const {
-    return journal::SnapRollbackEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapRollbackEvent(op_tid, m_snap_name);
   }
 
 private:
@@ -80,15 +78,27 @@ private:
   ProgressContext &m_prog_ctx;
 
   NoOpProgressContext m_no_op_prog_ctx;
-  State m_state;
 
+  bool m_blocking_writes = false;
   decltype(ImageCtxT::object_map) m_object_map;
 
+  void send_block_writes();
+  Context *handle_block_writes(int *result);
+
   void send_resize_image();
+  Context *handle_resize_image(int *result);
+
   void send_rollback_object_map();
+  Context *handle_rollback_object_map(int *result);
+
   void send_rollback_objects();
-  bool send_refresh_object_map();
-  bool send_invalidate_cache();
+  Context *handle_rollback_objects(int *result);
+
+  Context *send_refresh_object_map();
+  Context *handle_refresh_object_map(int *result);
+
+  Context *send_invalidate_cache();
+  Context *handle_invalidate_cache(int *result);
 
   void apply();
 };
diff --git a/src/librbd/operation/SnapshotUnprotectRequest.h b/src/librbd/operation/SnapshotUnprotectRequest.h
index 3b940c3..62467f2 100644
--- a/src/librbd/operation/SnapshotUnprotectRequest.h
+++ b/src/librbd/operation/SnapshotUnprotectRequest.h
@@ -64,8 +64,8 @@ protected:
     return 0;
   }
 
-  virtual journal::Event create_event() const {
-    return journal::SnapUnprotectEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapUnprotectEvent(op_tid, m_snap_name);
   }
 
 private:
diff --git a/src/librbd/operation/TrimRequest.h b/src/librbd/operation/TrimRequest.h
index 6e6c50c..5831281 100644
--- a/src/librbd/operation/TrimRequest.h
+++ b/src/librbd/operation/TrimRequest.h
@@ -17,9 +17,12 @@ template <typename ImageCtxT = ImageCtx>
 class TrimRequest : public AsyncRequest<ImageCtxT>
 {
 public:
-  TrimRequest(ImageCtxT &image_ctx, Context *on_finish,
-	      uint64_t original_size, uint64_t new_size,
-	      ProgressContext &prog_ctx);
+  static TrimRequest *create(ImageCtxT &image_ctx, Context *on_finish,
+                             uint64_t original_size, uint64_t new_size,
+                             ProgressContext &prog_ctx) {
+    return new TrimRequest(image_ctx, on_finish, original_size, new_size,
+                           prog_ctx);
+  }
 
   virtual void send();
 
@@ -80,6 +83,10 @@ private:
   uint64_t m_new_size;
   ProgressContext &m_prog_ctx;
 
+  TrimRequest(ImageCtxT &image_ctx, Context *on_finish,
+	      uint64_t original_size, uint64_t new_size,
+	      ProgressContext &prog_ctx);
+
   void send_copyup_objects();
   void send_remove_objects();
   void send_pre_remove();
diff --git a/src/log/Log.cc b/src/log/Log.cc
index 860b2c7..eb9c545 100644
--- a/src/log/Log.cc
+++ b/src/log/Log.cc
@@ -12,6 +12,7 @@
 #include "common/errno.h"
 #include "common/safe_io.h"
 #include "common/Clock.h"
+#include "common/valgrind.h"
 #include "include/assert.h"
 #include "include/compat.h"
 #include "include/on_exit.h"
@@ -189,6 +190,8 @@ Entry *Log::create_entry(int level, int subsys)
 Entry *Log::create_entry(int level, int subsys, size_t* expected_size)
 {
   if (true) {
+    ANNOTATE_BENIGN_RACE_SIZED(expected_size, sizeof(*expected_size),
+                               "Log hint");
     size_t size = __atomic_load_n(expected_size, __ATOMIC_RELAXED);
     void *ptr = ::operator new(sizeof(Entry) + size);
     return new(ptr) Entry(ceph_clock_now(NULL),
@@ -343,7 +346,7 @@ void Log::start()
   pthread_mutex_lock(&m_queue_mutex);
   m_stop = false;
   pthread_mutex_unlock(&m_queue_mutex);
-  create();
+  create("log");
 }
 
 void Log::stop()
diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc
index 70a4c7f..119fb32 100644
--- a/src/mds/CDir.cc
+++ b/src/mds/CDir.cc
@@ -2025,7 +2025,7 @@ void CDir::_omap_commit(int op_prio)
 
       // don't create new dirfrag blindly
       if (!is_new() && !state_test(CDir::STATE_FRAGMENTING))
-	op.stat(NULL, (utime_t*)NULL, NULL);
+	op.stat(NULL, (ceph::real_time*) NULL, NULL);
 
       op.tmap_to_omap(true); // convert tmap to omap
 
@@ -2034,7 +2034,8 @@ void CDir::_omap_commit(int op_prio)
       if (!to_remove.empty())
 	op.omap_rm_keys(to_remove);
 
-      cache->mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
+      cache->mds->objecter->mutate(oid, oloc, op, snapc,
+				   ceph::real_clock::now(g_ceph_context),
 				   0, NULL, gather.new_sub());
 
       write_size = 0;
@@ -2048,7 +2049,7 @@ void CDir::_omap_commit(int op_prio)
 
   // don't create new dirfrag blindly
   if (!is_new() && !state_test(CDir::STATE_FRAGMENTING))
-    op.stat(NULL, (utime_t*)NULL, NULL);
+    op.stat(NULL, (ceph::real_time*)NULL, NULL);
 
   op.tmap_to_omap(true); // convert tmap to omap
 
@@ -2069,7 +2070,8 @@ void CDir::_omap_commit(int op_prio)
   if (!to_remove.empty())
     op.omap_rm_keys(to_remove);
 
-  cache->mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
+  cache->mds->objecter->mutate(oid, oloc, op, snapc,
+			       ceph::real_clock::now(g_ceph_context),
 			       0, NULL, gather.new_sub());
 
   gather.activate();
diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc
index 1c95a0d..038de0e 100644
--- a/src/mds/CInode.cc
+++ b/src/mds/CInode.cc
@@ -984,7 +984,7 @@ void CInode::store(MDSInternalContextBase *fin)
     new C_OnFinisher(new C_IO_Inode_Stored(this, get_version(), fin),
 		     mdcache->mds->finisher);
   mdcache->mds->objecter->mutate(oid, oloc, m, snapc,
-				 ceph_clock_now(g_ceph_context), 0,
+				 ceph::real_clock::now(g_ceph_context), 0,
 				 NULL, newfin);
 }
 
@@ -1173,13 +1173,15 @@ void CInode::store_backtrace(MDSInternalContextBase *fin, int op_prio)
 
   if (!state_test(STATE_DIRTYPOOL) || inode.old_pools.empty()) {
     dout(20) << __func__ << ": no dirtypool or no old pools" << dendl;
-    mdcache->mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
+    mdcache->mds->objecter->mutate(oid, oloc, op, snapc,
+				   ceph::real_clock::now(g_ceph_context),
 				   0, NULL, fin2);
     return;
   }
 
   C_GatherBuilder gather(g_ceph_context, fin2);
-  mdcache->mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
+  mdcache->mds->objecter->mutate(oid, oloc, op, snapc,
+				 ceph::real_clock::now(g_ceph_context),
 				 0, NULL, gather.new_sub());
 
   // In the case where DIRTYPOOL is set, we update all old pools backtraces
@@ -1199,7 +1201,8 @@ void CInode::store_backtrace(MDSInternalContextBase *fin, int op_prio)
     op.setxattr("parent", parent_bl);
 
     object_locator_t oloc(*p);
-    mdcache->mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
+    mdcache->mds->objecter->mutate(oid, oloc, op, snapc,
+				   ceph::real_clock::now(g_ceph_context),
 				   0, NULL, gather.new_sub());
   }
   gather.activate();
@@ -3713,9 +3716,10 @@ void CInode::validate_disk_state(CInode::validated_data *results,
         in->mdcache->mds->objecter->read(oid, object_locator_t(pool), fetch, CEPH_NOSNAP,
             NULL, 0, fin);
       } else {
-        SnapContext snapc;
-        in->mdcache->mds->objecter->mutate(oid, object_locator_t(pool), fetch, snapc,
-            ceph_clock_now(g_ceph_context), 0, NULL, fin);
+	SnapContext snapc;
+	in->mdcache->mds->objecter->mutate(oid, object_locator_t(pool), fetch,
+					   snapc,ceph::real_clock::now(
+					     g_ceph_context), 0, NULL, fin);
       }
     }
 
diff --git a/src/mds/JournalPointer.cc b/src/mds/JournalPointer.cc
index 68e8aa4..bf6670f 100644
--- a/src/mds/JournalPointer.cc
+++ b/src/mds/JournalPointer.cc
@@ -90,7 +90,9 @@ int JournalPointer::save(Objecter *objecter) const
 
   C_SaferCond waiter;
   objecter->write_full(object_t(object_id), object_locator_t(pool_id),
-      SnapContext(), data, ceph_clock_now(g_ceph_context), 0, NULL, &waiter);
+		       SnapContext(), data,
+		       ceph::real_clock::now(g_ceph_context), 0, NULL,
+		       &waiter);
   int write_result = waiter.wait();
   if (write_result < 0) {
     derr << "Error writing pointer object '" << object_id << "': " << cpp_strerror(write_result) << dendl;
@@ -111,6 +113,8 @@ void JournalPointer::save(Objecter *objecter, Context *completion) const
   encode(data);
 
   objecter->write_full(object_t(get_object_id()), object_locator_t(pool_id),
-      SnapContext(), data, ceph_clock_now(g_ceph_context), 0, NULL, completion);
+		       SnapContext(), data,
+		       ceph::real_clock::now(g_ceph_context), 0, NULL,
+		       completion);
 }
 
diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc
index eb83299..aea88f5 100644
--- a/src/mds/Locker.cc
+++ b/src/mds/Locker.cc
@@ -2465,7 +2465,7 @@ void Locker::handle_client_caps(MClientCaps *m)
   if (!mds->is_clientreplay() && !mds->is_active() && !mds->is_stopping()) {
     if (mds->is_reconnect() &&
 	m->get_dirty() && m->get_client_tid() > 0 &&
-	session->have_completed_flush(m->get_client_tid())) {
+	!session->have_completed_flush(m->get_client_tid())) {
       mdcache->set_reconnect_dirty_caps(m->get_ino(), m->get_dirty());
     }
     mds->wait_for_replay(new C_MDS_RetryMessage(mds, m));
@@ -2488,8 +2488,14 @@ void Locker::handle_client_caps(MClientCaps *m)
     ack->set_snap_follows(follows);
     ack->set_client_tid(m->get_client_tid());
     mds->send_message_client_counted(ack, m->get_connection());
-    m->put();
-    return;
+    if (m->get_op() == CEPH_CAP_OP_FLUSHSNAP) {
+      m->put();
+      return;
+    } else {
+      // fall-thru because the message may release some caps
+      m->clear_dirty();
+      m->set_op(CEPH_CAP_OP_UPDATE);
+    }
   }
 
   // "oldest flush tid" > 0 means client uses unique TID for each flush
@@ -2517,7 +2523,13 @@ void Locker::handle_client_caps(MClientCaps *m)
 
   CInode *head_in = mdcache->get_inode(m->get_ino());
   if (!head_in) {
-    dout(7) << "handle_client_caps on unknown ino " << m->get_ino() << ", dropping" << dendl;
+    if (mds->is_clientreplay()) {
+      dout(7) << "handle_client_caps on unknown ino " << m->get_ino()
+	<< ", will try again after replayed client requests" << dendl;
+      mdcache->wait_replay_cap_reconnect(m->get_ino(), new C_MDS_RetryMessage(mds, m));
+      return;
+    }
+    dout(1) << "handle_client_caps on unknown ino " << m->get_ino() << ", dropping" << dendl;
     m->put();
     return;
   }
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index eddfcd4..bcf7046 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -2652,6 +2652,13 @@ ESubtreeMap *MDCache::create_subtree_map()
   return le;
 }
 
+void MDCache::dump_resolve_status(Formatter *f) const
+{
+  f->open_object_section("resolve_status");
+  f->dump_stream("resolve_gather") << resolve_gather;
+  f->dump_stream("resolve_ack_gather") << resolve_gather;
+  f->close_section();
+}
 
 void MDCache::resolve_start(MDSInternalContext *resolve_done_)
 {
@@ -3849,6 +3856,15 @@ void MDCache::recalc_auth_bits(bool replay)
  *   after recovery.
  */
 
+void MDCache::dump_rejoin_status(Formatter *f) const
+{
+  f->open_object_section("rejoin_status");
+  f->dump_stream("rejoin_gather") << rejoin_gather;
+  f->dump_stream("rejoin_ack_gather") << rejoin_ack_gather;
+  f->dump_unsigned("num_opening_inodes", cap_imports_num_opening);
+  f->close_section();
+}
+
 void MDCache::rejoin_start(MDSInternalContext *rejoin_done_)
 {
   dout(10) << "rejoin_start" << dendl;
@@ -5524,8 +5540,14 @@ void MDCache::export_remaining_imported_caps()
     }
   }
 
+  for (map<inodeno_t, list<MDSInternalContextBase*> >::iterator p = cap_reconnect_waiters.begin();
+       p != cap_reconnect_waiters.end();
+       ++p)
+    mds->queue_waiters(p->second);
+
   cap_imports.clear();
   cap_imports_dirty.clear();
+  cap_reconnect_waiters.clear();
 
   if (warn_str.peek() != EOF) {
     mds->clog->warn() << "failed to reconnect caps for missing inodes:" << "\n";
@@ -5555,6 +5577,13 @@ void MDCache::try_reconnect_cap(CInode *in, Session *session)
       in->choose_lock_states(dirty_caps);
       dout(15) << " chose lock states on " << *in << dendl;
     }
+
+    map<inodeno_t, list<MDSInternalContextBase*> >::iterator it =
+      cap_reconnect_waiters.find(in->ino());
+    if (it != cap_reconnect_waiters.end()) {
+      mds->queue_waiters(it->second);
+      cap_reconnect_waiters.erase(it);
+    }
   }
 }
 
@@ -6114,7 +6143,7 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls)
   dout(10) << "_truncate_inode  snapc " << snapc << " on " << *in << dendl;
   filer.truncate(in->inode.ino, &in->inode.layout, *snapc,
 		 pi->truncate_size, pi->truncate_from-pi->truncate_size,
-		 pi->truncate_seq, utime_t(), 0,
+		 pi->truncate_seq, ceph::real_time::min(), 0,
 		 0, new C_OnFinisher(new C_IO_MDC_TruncateFinish(this, in,
 								       ls),
 					   mds->finisher));
@@ -11101,7 +11130,8 @@ void MDCache::_fragment_committed(dirfrag_t basedirfrag, list<CDir*>& resultfrag
       dout(10) << " removing orphan dirfrag " << oid << dendl;
       op.remove();
     }
-    mds->objecter->mutate(oid, oloc, op, nullsnapc, ceph_clock_now(g_ceph_context),
+    mds->objecter->mutate(oid, oloc, op, nullsnapc,
+			  ceph::real_clock::now(g_ceph_context),
 			  0, NULL, gather.new_sub());
   }
 
diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h
index 921b03a..10641ea 100644
--- a/src/mds/MDCache.h
+++ b/src/mds/MDCache.h
@@ -493,6 +493,7 @@ protected:
   map<inodeno_t,map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> > > cap_imports;  // ino -> client -> frommds -> capex
   map<inodeno_t,int> cap_imports_dirty;
   set<inodeno_t> cap_imports_missing;
+  map<inodeno_t, list<MDSInternalContextBase*> > cap_reconnect_waiters;
   int cap_imports_num_opening;
   
   set<CInode*> rejoin_undef_inodes;
@@ -551,6 +552,9 @@ public:
   void set_reconnect_dirty_caps(inodeno_t ino, int dirty) {
     cap_imports_dirty[ino] |= dirty;
   }
+  void wait_replay_cap_reconnect(inodeno_t ino, MDSInternalContextBase *c) {
+    cap_reconnect_waiters[ino].push_back(c);
+  }
 
   // [reconnect/rejoin caps]
   map<CInode*,map<client_t, inodeno_t> >  reconnected_caps;   // inode -> client -> realmino
@@ -1105,6 +1109,9 @@ public:
   void dump_cache(const std::string &filename);
   void dump_cache(Formatter *f);
 
+  void dump_resolve_status(Formatter *f) const;
+  void dump_rejoin_status(Formatter *f) const;
+
   // == crap fns ==
  public:
   void show_cache();
diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc
index 43cdc48..bc27661 100644
--- a/src/mds/MDLog.cc
+++ b/src/mds/MDLog.cc
@@ -169,17 +169,18 @@ void MDLog::create(MDSInternalContextBase *c)
   logger->set(l_mdl_expos, journaler->get_expire_pos());
   logger->set(l_mdl_wrpos, journaler->get_write_pos());
 
-  submit_thread.create();
+  submit_thread.create("md_submit");
 }
 
 void MDLog::open(MDSInternalContextBase *c)
 {
   dout(5) << "open discovering log bounds" << dendl;
 
+  assert(!recovery_thread.is_started());
   recovery_thread.set_completion(c);
-  recovery_thread.create();
+  recovery_thread.create("md_recov_open");
 
-  submit_thread.create();
+  submit_thread.create("md_submit");
   // either append() or replay() will follow.
 }
 
@@ -215,8 +216,13 @@ void MDLog::reopen(MDSInternalContextBase *c)
   delete journaler;
   journaler = NULL;
 
+  // recovery_thread was started at some point in the past.  Although
+  // it has called it's completion if we made it back here, it might
+  // still not have been cleaned up: join it.
+  recovery_thread.join();
+
   recovery_thread.set_completion(new C_ReopenComplete(this, c));
-  recovery_thread.create();
+  recovery_thread.create("md_recov_reopen");
 }
 
 void MDLog::append()
@@ -350,6 +356,11 @@ void MDLog::_submit_thread()
   submit_mutex.Lock();
 
   while (!mds->is_daemon_stopping()) {
+    if (g_conf->mds_log_pause) {
+      submit_cond.Wait(submit_mutex);
+      continue;
+    }
+
     map<uint64_t,list<PendingEvent> >::iterator it = pending_events.begin();
     if (it == pending_events.end()) {
       submit_cond.Wait(submit_mutex);
@@ -454,6 +465,12 @@ void MDLog::flush()
     journaler->flush();
 }
 
+void MDLog::kick_submitter()
+{
+  Mutex::Locker l(submit_mutex);
+  submit_cond.Signal();
+}
+
 void MDLog::cap()
 { 
   dout(5) << "cap" << dendl;
@@ -840,9 +857,14 @@ void MDLog::replay(MDSInternalContextBase *c)
 	   << " to " << journaler->get_write_pos() << dendl;
 
   assert(num_events == 0 || already_replayed);
+  if (already_replayed) {
+    // Ensure previous instance of ReplayThread is joined before
+    // we create another one
+    replay_thread.join();
+  }
   already_replayed = true;
 
-  replay_thread.create();
+  replay_thread.create("md_log_replay");
 }
 
 
@@ -1386,3 +1408,14 @@ void MDLog::standby_trim_segments()
   } else
     dout(20) << " removed no segments!" << dendl;
 }
+
+void MDLog::dump_replay_status(Formatter *f) const
+{
+  f->open_object_section("replay_status");
+  f->dump_unsigned("journal_read_pos", journaler ? journaler->get_read_pos() : 0);
+  f->dump_unsigned("journal_write_pos", journaler ? journaler->get_write_pos() : 0);
+  f->dump_unsigned("journal_expire_pos", journaler ? journaler->get_expire_pos() : 0);
+  f->dump_unsigned("num_events", get_num_events());
+  f->dump_unsigned("num_segments", get_num_segments());
+  f->close_section();
+}
diff --git a/src/mds/MDLog.h b/src/mds/MDLog.h
index c8f9e70..558f723 100644
--- a/src/mds/MDLog.h
+++ b/src/mds/MDLog.h
@@ -254,6 +254,7 @@ public:
   bool is_capped() { return capped; }
   void cap();
 
+  void kick_submitter();
   void shutdown();
 
   // -- events --
@@ -315,6 +316,8 @@ public:
   void replay(MDSInternalContextBase *onfinish);
 
   void standby_trim_segments();
+
+  void dump_replay_status(Formatter *f) const;
 };
 
 #endif
diff --git a/src/mds/MDSAuthCaps.cc b/src/mds/MDSAuthCaps.cc
index ccabe00..c888780 100644
--- a/src/mds/MDSAuthCaps.cc
+++ b/src/mds/MDSAuthCaps.cc
@@ -118,6 +118,16 @@ bool MDSCapMatch::match(const std::string &target_path,
     if (std::find(gids.begin(), gids.end(), caller_gid) == gids.end())
       return false;
   }
+
+  if (!match_path(target_path)) {
+    return false;
+  }
+
+  return true;
+}
+
+bool MDSCapMatch::match_path(const std::string &target_path) const
+{
   if (path.length()) {
     if (target_path.find(path) != 0)
       return false;
@@ -128,10 +138,26 @@ bool MDSCapMatch::match(const std::string &target_path,
 	target_path[path.length()] != '/')
       return false;
   }
+
   return true;
 }
 
 /**
+ * Is the client *potentially* able to access this path?  Actual
+ * permission will depend on uids/modes in the full is_capable.
+ */
+bool MDSAuthCaps::path_capable(const std::string &inode_path) const
+{
+  for (const auto &i : grants) {
+    if (i.match.match_path(inode_path)) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+/**
  * For a given filesystem path, query whether this capability carries`
  * authorization to read or write.
  *
diff --git a/src/mds/MDSAuthCaps.h b/src/mds/MDSAuthCaps.h
index e75e7e7..ccf2857 100644
--- a/src/mds/MDSAuthCaps.h
+++ b/src/mds/MDSAuthCaps.h
@@ -94,6 +94,14 @@ struct MDSCapMatch {
   bool match(const std::string &target_path,
 	     const int caller_uid,
 	     const int caller_gid) const;
+
+  /**
+   * Check whether this path *might* be accessible (actual permission
+   * depends on the stronger check in match()).
+   *
+   * @param target_path filesystem path without leading '/'
+   */
+  bool match_path(const std::string &target_path) const;
 };
 
 struct MDSCapGrant {
@@ -126,6 +134,7 @@ public:
 		  uid_t inode_uid, gid_t inode_gid, unsigned inode_mode,
 		  uid_t uid, gid_t gid, unsigned mask,
 		  uid_t new_uid, gid_t new_gid) const;
+  bool path_capable(const std::string &inode_path) const;
 
   friend std::ostream &operator<<(std::ostream &out, const MDSAuthCaps &cap);
 };
diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc
index 4e1f0ff..1e9f4f6 100644
--- a/src/mds/MDSDaemon.cc
+++ b/src/mds/MDSDaemon.cc
@@ -171,28 +171,7 @@ bool MDSDaemon::asok_command(string command, cmdmap_t& cmdmap, string format,
   Formatter *f = Formatter::create(format, "json-pretty", "json-pretty");
   bool handled = false;
   if (command == "status") {
-    const OSDMap *osdmap = objecter->get_osdmap_read();
-    const epoch_t osd_epoch = osdmap->get_epoch();
-    objecter->put_osdmap_read();
-
-    f->open_object_section("status");
-    f->dump_stream("cluster_fsid") << monc->get_fsid();
-    if (mds_rank) {
-      f->dump_unsigned("whoami", mds_rank->get_nodeid());
-    } else {
-      f->dump_unsigned("whoami", MDS_RANK_NONE);
-    }
-
-    f->dump_string("state", ceph_mds_state_name(mdsmap->get_state_gid(mds_gid_t(
-        monc->get_global_id()))));
-    f->dump_unsigned("mdsmap_epoch", mdsmap->get_epoch());
-    f->dump_unsigned("osdmap_epoch", osd_epoch);
-    if (mds_rank) {
-      f->dump_unsigned("osdmap_epoch_barrier", mds_rank->get_osd_epoch_barrier());
-    } else {
-      f->dump_unsigned("osdmap_epoch_barrier", 0);
-    }
-    f->close_section(); // status
+    dump_status(f);
     handled = true;
   } else {
     if (mds_rank == NULL) {
@@ -211,6 +190,38 @@ bool MDSDaemon::asok_command(string command, cmdmap_t& cmdmap, string format,
   return handled;
 }
 
+void MDSDaemon::dump_status(Formatter *f)
+{
+  const OSDMap *osdmap = objecter->get_osdmap_read();
+  const epoch_t osd_epoch = osdmap->get_epoch();
+  objecter->put_osdmap_read();
+
+  f->open_object_section("status");
+  f->dump_stream("cluster_fsid") << monc->get_fsid();
+  if (mds_rank) {
+    f->dump_unsigned("whoami", mds_rank->get_nodeid());
+  } else {
+    f->dump_unsigned("whoami", MDS_RANK_NONE);
+  }
+
+  f->dump_string("want_state", ceph_mds_state_name(beacon.get_want_state()));
+  f->dump_string("state", ceph_mds_state_name(mdsmap->get_state_gid(mds_gid_t(
+	    monc->get_global_id()))));
+  if (mds_rank) {
+    Mutex::Locker l(mds_lock);
+    mds_rank->dump_status(f);
+  }
+
+  f->dump_unsigned("mdsmap_epoch", mdsmap->get_epoch());
+  f->dump_unsigned("osdmap_epoch", osd_epoch);
+  if (mds_rank) {
+    f->dump_unsigned("osdmap_epoch_barrier", mds_rank->get_osd_epoch_barrier());
+  } else {
+    f->dump_unsigned("osdmap_epoch_barrier", 0);
+  }
+  f->close_section(); // status
+}
+
 void MDSDaemon::set_up_admin_socket()
 {
   int r;
@@ -335,6 +346,7 @@ const char** MDSDaemon::get_tracked_conf_keys() const
     "mds_op_complaint_time", "mds_op_log_threshold",
     "mds_op_history_size", "mds_op_history_duration",
     "mds_enable_op_tracker",
+    "mds_log_pause",
     // clog & admin clog
     "clog_to_monitors",
     "clog_to_syslog",
@@ -377,6 +389,10 @@ void MDSDaemon::handle_conf_change(const struct md_config_t *conf,
       mds_rank->update_log_config();
     }
   }
+  if (!g_conf->mds_log_pause && changed.count("mds_log_pause")) {
+    if (mds_rank)
+      mds_rank->mdlog->kick_submitter();
+  }
 }
 
 
@@ -1008,7 +1024,7 @@ void MDSDaemon::_handle_mds_map(MDSMap *oldmap)
 void MDSDaemon::handle_signal(int signum)
 {
   assert(signum == SIGINT || signum == SIGTERM);
-  derr << "*** got signal " << sys_siglist[signum] << " ***" << dendl;
+  derr << "*** got signal " << sig_str(signum) << " ***" << dendl;
   {
     Mutex::Locker l(mds_lock);
     if (stopping) {
diff --git a/src/mds/MDSDaemon.h b/src/mds/MDSDaemon.h
index ba3f456..8c61ea9 100644
--- a/src/mds/MDSDaemon.h
+++ b/src/mds/MDSDaemon.h
@@ -161,11 +161,13 @@ class MDSDaemon : public Dispatcher, public md_config_obs_t {
   // admin socket handling
   friend class MDSSocketHook;
   class MDSSocketHook *asok_hook;
-  bool asok_command(string command, cmdmap_t& cmdmap, string format,
-		    ostream& ss);
   void set_up_admin_socket();
   void clean_up_admin_socket();
   void check_ops_in_flight(); // send off any slow ops to monitor
+  bool asok_command(string command, cmdmap_t& cmdmap, string format,
+		    ostream& ss);
+
+  void dump_status(Formatter *f);
 
   /**
    * Terminate this daemon process.
diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc
index fcb8efd..a836dfb 100644
--- a/src/mds/MDSRank.cc
+++ b/src/mds/MDSRank.cc
@@ -142,7 +142,7 @@ void MDSRankDispatcher::init()
   // who is interested in it.
   handle_osd_map();
 
-  progress_thread.create();
+  progress_thread.create("mds_rank_progr");
 
   finisher->start();
 }
@@ -1236,6 +1236,19 @@ void MDSRank::clientreplay_start()
   queue_one_replay();
 }
 
+bool MDSRank::queue_one_replay()
+{
+  if (replay_queue.empty()) {
+    if (mdcache->get_num_client_requests() == 0) {
+      clientreplay_done();
+    }
+    return false;
+  }
+  queue_waiter(replay_queue.front());
+  replay_queue.pop_front();
+  return true;
+}
+
 void MDSRank::clientreplay_done()
 {
   dout(1) << "clientreplay_done" << dendl;
@@ -1795,8 +1808,14 @@ std::vector<entity_name_t> MDSRankDispatcher::evict_sessions(
     }
   }
 
+  dout(20) << __func__ << " matched " << victims.size() << " sessions" << dendl;
+
   std::vector<entity_name_t> result;
 
+  if (victims.empty()) {
+    return result;
+  }
+
   C_SaferCond on_safe;
   C_GatherBuilder gather(g_ceph_context, &on_safe);
   for (const auto s : victims) {
@@ -2230,6 +2249,30 @@ bool MDSRank::command_dirfrag_ls(
   return true;
 }
 
+void MDSRank::dump_status(Formatter *f) const
+{
+  if (state == MDSMap::STATE_REPLAY ||
+      state == MDSMap::STATE_STANDBY_REPLAY) {
+    mdlog->dump_replay_status(f);
+  } else if (state == MDSMap::STATE_RESOLVE) {
+    mdcache->dump_resolve_status(f);
+  } else if (state == MDSMap::STATE_RECONNECT) {
+    server->dump_reconnect_status(f);
+  } else if (state == MDSMap::STATE_REJOIN) {
+    mdcache->dump_rejoin_status(f);
+  } else if (state == MDSMap::STATE_CLIENTREPLAY) {
+    dump_clientreplay_status(f);
+  }
+}
+
+void MDSRank::dump_clientreplay_status(Formatter *f) const
+{
+  f->open_object_section("clientreplay_status");
+  f->dump_unsigned("clientreplay_queue", replay_queue.size());
+  f->dump_unsigned("active_replay", mdcache->get_num_client_requests());
+  f->close_section();
+}
+
 void MDSRankDispatcher::update_log_config()
 {
   map<string,string> log_to_monitors;
diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h
index 8d2667b..5d334a2 100644
--- a/src/mds/MDSRank.h
+++ b/src/mds/MDSRank.h
@@ -347,13 +347,7 @@ class MDSRank {
       replay_queue.push_back(c);
     }
 
-    bool queue_one_replay() {
-      if (replay_queue.empty())
-        return false;
-      queue_waiter(replay_queue.front());
-      replay_queue.pop_front();
-      return true;
-    }
+    bool queue_one_replay();
 
     void set_osd_epoch_barrier(epoch_t e);
     epoch_t get_osd_epoch_barrier() const {return osd_epoch_barrier;}
@@ -366,7 +360,10 @@ class MDSRank {
 
     int get_req_rate() { return logger->get(l_mds_request); }
 
+    void dump_status(Formatter *f) const;
+
   protected:
+    void dump_clientreplay_status(Formatter *f) const;
     void command_scrub_path(Formatter *f, const string& path);
     void command_tag_path(Formatter *f, const string& path,
                           const string &tag);
@@ -390,7 +387,6 @@ class MDSRank {
     CDir *_command_dirfrag_get(
         const cmdmap_t &cmdmap,
         std::ostream &ss);
-    // <<<
 
   protected:
     Messenger    *messenger;
diff --git a/src/mds/MDSTable.cc b/src/mds/MDSTable.cc
index 1d0c764..5ff0dd0 100644
--- a/src/mds/MDSTable.cc
+++ b/src/mds/MDSTable.cc
@@ -81,7 +81,7 @@ void MDSTable::save(MDSInternalContextBase *onfinish, version_t v)
   object_locator_t oloc(mds->mdsmap->get_metadata_pool());
   mds->objecter->write_full(oid, oloc,
 			    snapc,
-			    bl, ceph_clock_now(g_ceph_context), 0,
+			    bl, ceph::real_clock::now(g_ceph_context), 0,
 			    NULL,
 			    new C_OnFinisher(new C_IO_MT_Save(this, version),
 					     mds->finisher));
diff --git a/src/mds/RecoveryQueue.cc b/src/mds/RecoveryQueue.cc
index 33aabe4..7a8287e 100644
--- a/src/mds/RecoveryQueue.cc
+++ b/src/mds/RecoveryQueue.cc
@@ -99,8 +99,8 @@ void RecoveryQueue::_start(CInode *in)
 
     C_MDC_Recover *fin = new C_MDC_Recover(this, in);
     filer.probe(in->inode.ino, &in->inode.layout, in->last,
-		      pi->get_max_size(), &fin->size, &fin->mtime, false,
-		      0, fin);
+		pi->get_max_size(), &fin->size, &fin->mtime, false,
+		0, fin);
   } else {
     dout(10) << "skipping " << in->inode.size << " " << *in << dendl;
     in->state_clear(CInode::STATE_RECOVERING);
diff --git a/src/mds/Server.cc b/src/mds/Server.cc
index 3887faac..7816460 100644
--- a/src/mds/Server.cc
+++ b/src/mds/Server.cc
@@ -280,6 +280,26 @@ void Server::handle_client_session(MClientSession *m)
       dout(20) << "  " << i->first << ": " << i->second << dendl;
     }
 
+    // Special case for the 'root' metadata path; validate that the claimed
+    // root is actually within the caps of the session
+    if (session->info.client_metadata.count("root")) {
+      const auto claimed_root = session->info.client_metadata.at("root");
+      // claimed_root has a leading "/" which we strip before passing
+      // into caps check
+      if (claimed_root.empty() || claimed_root[0] != '/' ||
+          !session->auth_caps.path_capable(claimed_root.substr(1))) {
+        derr << __func__ << " forbidden path claimed as mount root: "
+             << claimed_root << " by " << m->get_source() << dendl;
+        // Tell the client we're rejecting their open
+        mds->send_message_client(new MClientSession(CEPH_SESSION_REJECT), session);
+        mds->clog->warn() << "client session with invalid root '" <<
+          claimed_root << "' denied (" << session->info.inst << ")";
+        session->clear();
+        // Drop out; don't record this session in SessionMap or journal it.
+        break;
+      }
+    }
+
     if (session->is_closed())
       mds->sessionmap.add_session(session);
 
@@ -1165,8 +1185,7 @@ void Server::reply_client_request(MDRequestRef& mdr, MClientReply *reply)
     client_con->send_message(reply);
   }
 
-  if (mdr->has_completed && mds->is_clientreplay())
-    mds->queue_one_replay();
+  const bool completed = mdr->has_completed;
 
   // clean up request
   mdcache->request_finish(mdr);
@@ -1177,6 +1196,11 @@ void Server::reply_client_request(MDRequestRef& mdr, MClientReply *reply)
       tracedn->get_projected_linkage()->is_remote()) {
     mdcache->eval_remote(tracedn);
   }
+
+  // Advance clientreplay process if we're in it
+  if (completed && mds->is_clientreplay()) {
+    mds->queue_one_replay();
+  }
 }
 
 
@@ -8270,3 +8294,10 @@ bool Server::waiting_for_reconnect(client_t c) const
 {
   return client_reconnect_gather.count(c) > 0;
 }
+
+void Server::dump_reconnect_status(Formatter *f) const
+{
+  f->open_object_section("reconnect_status");
+  f->dump_stream("client_reconnect_gather") << client_reconnect_gather;
+  f->close_section();
+}
diff --git a/src/mds/Server.h b/src/mds/Server.h
index 803dd32..44ee5b7 100644
--- a/src/mds/Server.h
+++ b/src/mds/Server.h
@@ -81,6 +81,7 @@ public:
   utime_t  reconnect_start;
   set<client_t> client_reconnect_gather;  // clients i need a reconnect msg from.
   bool waiting_for_reconnect(client_t c) const;
+  void dump_reconnect_status(Formatter *f) const;
 
   Session *get_session(Message *m);
   void handle_client_session(class MClientSession *m);
diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc
index d6ca0af..4552e5e 100644
--- a/src/mds/SessionMap.cc
+++ b/src/mds/SessionMap.cc
@@ -402,8 +402,10 @@ void SessionMap::save(MDSInternalContextBase *onsave, version_t needv)
   dirty_sessions.clear();
   null_sessions.clear();
 
-  mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
-      0, NULL, new C_OnFinisher(new C_IO_SM_Save(this, version), mds->finisher));
+  mds->objecter->mutate(oid, oloc, op, snapc,
+			ceph::real_clock::now(g_ceph_context),
+      0, NULL, new C_OnFinisher(new C_IO_SM_Save(this, version),
+				mds->finisher));
 }
 
 void SessionMap::_save_finish(version_t v)
@@ -723,8 +725,11 @@ void SessionMap::save_if_dirty(const std::set<entity_name_t> &tgt_sessions,
       object_t oid = get_object_name();
       object_locator_t oloc(mds->mdsmap->get_metadata_pool());
       MDSInternalContextBase *on_safe = gather_bld->new_sub();
-      mds->objecter->mutate(oid, oloc, op, snapc, ceph_clock_now(g_ceph_context),
-          0, NULL, new C_OnFinisher(new C_IO_SM_Save_One(this, on_safe), mds->finisher));
+      mds->objecter->mutate(oid, oloc, op, snapc,
+			    ceph::real_clock::now(g_ceph_context),
+			    0, NULL, new C_OnFinisher(
+			      new C_IO_SM_Save_One(this, on_safe),
+			      mds->finisher));
     }
   }
 }
diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc
index a052d4e..bb9a3ee 100644
--- a/src/mds/StrayManager.cc
+++ b/src/mds/StrayManager.cc
@@ -107,8 +107,9 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance)
          ++p) {
       object_t oid = CInode::get_object_name(in->inode.ino, *p, "");
       dout(10) << __func__ << " remove dirfrag " << oid << dendl;
-      mds->objecter->remove(oid, oloc, nullsnapc, ceph_clock_now(g_ceph_context),
-                            0, NULL, gather.new_sub());
+      mds->objecter->remove(oid, oloc, nullsnapc,
+			    ceph::real_clock::now(g_ceph_context),
+			    0, NULL, gather.new_sub());
     }
     assert(gather.has_subs());
     gather.activate();
@@ -140,8 +141,8 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance)
       dout(10) << __func__ << " 0~" << to << " objects 0~" << num
 	       << " snapc " << snapc << " on " << *in << dendl;
       filer.purge_range(in->inode.ino, &in->inode.layout, *snapc,
-			      0, num, ceph_clock_now(g_ceph_context), 0,
-			      gather.new_sub());
+			0, num, ceph::real_clock::now(g_ceph_context), 0,
+			gather.new_sub());
     }
   }
 
@@ -152,7 +153,8 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance)
     object_locator_t oloc(pi->layout.fl_pg_pool);
     dout(10) << __func__ << " remove backtrace object " << oid
 	     << " pool " << oloc.pool << " snapc " << snapc << dendl;
-    mds->objecter->remove(oid, oloc, *snapc, ceph_clock_now(g_ceph_context), 0,
+    mds->objecter->remove(oid, oloc, *snapc,
+			  ceph::real_clock::now(g_ceph_context), 0,
 			  NULL, gather.new_sub());
   }
   // remove old backtrace objects
@@ -162,7 +164,8 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance)
     object_locator_t oloc(*p);
     dout(10) << __func__ << " remove backtrace object " << oid
 	     << " old pool " << *p << " snapc " << snapc << dendl;
-    mds->objecter->remove(oid, oloc, *snapc, ceph_clock_now(g_ceph_context), 0,
+    mds->objecter->remove(oid, oloc, *snapc,
+			  ceph::real_clock::now(g_ceph_context), 0,
 			  NULL, gather.new_sub());
   }
   assert(gather.has_subs());
@@ -814,15 +817,15 @@ void StrayManager::truncate(CDentry *dn, uint32_t op_allowance)
     dout(10) << __func__ << " 0~" << to << " objects 0~" << num
       << " snapc " << snapc << " on " << *in << dendl;
     filer.purge_range(in->ino(), &in->inode.layout, *snapc,
-			    1, num, ceph_clock_now(g_ceph_context),
-			    0, gather.new_sub());
+		      1, num, ceph::real_clock::now(g_ceph_context),
+		      0, gather.new_sub());
   }
 
   // keep backtrace object
   if (period && to > 0) {
     filer.zero(in->ino(), &in->inode.layout, *snapc,
-		     0, period, ceph_clock_now(g_ceph_context),
-		     0, true, NULL, gather.new_sub());
+	       0, period, ceph::real_clock::now(g_ceph_context),
+	       0, true, NULL, gather.new_sub());
   }
 
   assert(gather.has_subs());
diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h
index c923dd1..1b3f487 100644
--- a/src/messages/MClientCaps.h
+++ b/src/messages/MClientCaps.h
@@ -92,6 +92,8 @@ class MClientCaps : public Message {
   void set_oldest_flush_tid(ceph_tid_t tid) { oldest_flush_tid = tid; }
   ceph_tid_t get_oldest_flush_tid() { return oldest_flush_tid; }
 
+  void clear_dirty() { head.dirty = 0; }
+
   MClientCaps()
     : Message(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION),
       osd_epoch_barrier(0),
diff --git a/src/messages/MOSDOp.h b/src/messages/MOSDOp.h
index 1a9e647..fc087fc 100755
--- a/src/messages/MOSDOp.h
+++ b/src/messages/MOSDOp.h
@@ -179,6 +179,9 @@ private:
 public:
   void set_version(eversion_t v) { reassert_version = v; }
   void set_mtime(utime_t mt) { mtime = mt; }
+  void set_mtime(ceph::real_time mt) {
+    mtime = ceph::real_clock::to_timespec(mt);
+  }
 
   // ops
   void add_simple_op(int o, uint64_t off, uint64_t len) {
diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc
index 730410e..8f217fb 100644
--- a/src/mon/AuthMonitor.cc
+++ b/src/mon/AuthMonitor.cc
@@ -98,11 +98,17 @@ void AuthMonitor::create_initial()
     KeyRing keyring;
     bufferlist bl;
     int ret = mon->store->get("mkfs", "keyring", bl);
-    assert(ret == 0);
-    bufferlist::iterator p = bl.begin();
-    ::decode(keyring, p);
-
-    import_keyring(keyring);
+    // fail hard only if there's an error we're not expecting to see
+    assert((ret == 0) || (ret == -ENOENT));
+    
+    // try importing only if there's a key
+    if (ret == 0) {
+      KeyRing keyring;
+      bufferlist::iterator p = bl.begin();
+
+      ::decode(keyring, p);
+      import_keyring(keyring);
+    }
   }
 
   max_global_id = MIN_GLOBAL_ID;
diff --git a/src/mon/ConfigKeyService.cc b/src/mon/ConfigKeyService.cc
index 64ed42f..84e95ef 100644
--- a/src/mon/ConfigKeyService.cc
+++ b/src/mon/ConfigKeyService.cc
@@ -39,9 +39,6 @@ const string ConfigKeyService::STORE_PREFIX = "mon_config_key";
 
 int ConfigKeyService::store_get(string key, bufferlist &bl)
 {
-  if (!store_exists(key))
-    return -ENOENT;
-
   return mon->store->get(STORE_PREFIX, key, bl);
 }
 
diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc
index b5ab447..eb9f32f 100644
--- a/src/mon/LogMonitor.cc
+++ b/src/mon/LogMonitor.cc
@@ -505,7 +505,11 @@ void LogMonitor::check_sub(Subscription *s)
 	  << " with " << mlog->entries.size() << " entries"
 	  << " (version " << mlog->version << ")" << dendl;
   
-  s->session->con->send_message(mlog);
+  if (!mlog->entries.empty()) {
+    s->session->con->send_message(mlog);
+  } else {
+    mlog->put();
+  }
   if (s->onetime)
     mon->session_map.remove_sub(s);
   else
diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc
index 664af7b..a62cdb9 100644
--- a/src/mon/MDSMonitor.cc
+++ b/src/mon/MDSMonitor.cc
@@ -1567,8 +1567,21 @@ int MDSMonitor::filesystem_command(
     }
     r = 0;
   } else if (prefix == "mds setmap") {
+    string confirm;
+    if (!cmd_getval(g_ceph_context, cmdmap, "confirm", confirm) ||
+	confirm != "--yes-i-really-mean-it") {
+      ss << "WARNING: this can make your filesystem inaccessible! "
+	    "Add --yes-i-really-mean-it if you are sure you wish to continue.";
+      return -EINVAL;;
+    }
+
     MDSMap map;
-    map.decode(m->get_data());
+    try {
+      map.decode(m->get_data());
+    } catch(buffer::error &e) {
+      ss << "invalid mdsmap";
+      return -EINVAL;
+    }
     epoch_t e = 0;
     int64_t epochnum;
     if (cmd_getval(g_ceph_context, cmdmap, "epoch", epochnum))
@@ -1647,6 +1660,13 @@ int MDSMonitor::filesystem_command(
     }
   } else if (prefix == "mds rmfailed") {
     mds_rank_t who;
+    string confirm;
+    if (!cmd_getval(g_ceph_context, cmdmap, "confirm", confirm) ||
+	confirm != "--yes-i-really-mean-it") {
+	  ss << "WARNING: this can make your filesystem inaccessible! "
+		"Add --yes-i-really-mean-it if you are sure you wish to continue.";
+	  return -EPERM;
+    }
     if (!cmd_getval(g_ceph_context, cmdmap, "who", who)) {
       ss << "error parsing 'who' value '"
          << cmd_vartype_stringify(cmdmap["who"]) << "'";
diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h
index 8d09f91..bb5a935 100644
--- a/src/mon/MonCommands.h
+++ b/src/mon/MonCommands.h
@@ -326,7 +326,8 @@ COMMAND("mds set " \
 	"name=confirm,type=CephString,req=false",			\
 	"set mds parameter <var> to <val>", "mds", "rw", "cli,rest")
 COMMAND("mds setmap " \
-	"name=epoch,type=CephInt,range=0", \
+	"name=epoch,type=CephInt,range=0 " \
+	"name=confirm,type=CephString,req=false",
 	"set mds map; must supply correct epoch number", "mds", "rw", "cli,rest")
 // arbitrary limit 0-20 below; worth standing on head to make it
 // relate to actual state definitions?
@@ -342,8 +343,8 @@ COMMAND("mds repaired name=rank,type=CephInt", \
 COMMAND("mds rm " \
 	"name=gid,type=CephInt,range=0", \
 	"remove nonactive mds", "mds", "rw", "cli,rest")
-COMMAND("mds rmfailed name=who,type=CephInt,range=0", "remove failed mds", \
-	"mds", "rw", "cli,rest")
+COMMAND("mds rmfailed name=who,type=CephInt,range=0 name=confirm,type=CephString,req=false", \
+	"remove failed mds", "mds", "rw", "cli,rest")
 COMMAND("mds cluster_down", "take MDS cluster down", "mds", "rw", "cli,rest")
 COMMAND("mds cluster_up", "bring MDS cluster up", "mds", "rw", "cli,rest")
 COMMAND("mds compat rm_compat " \
@@ -456,6 +457,8 @@ COMMAND("osd lspools " \
 	"name=auid,type=CephInt,req=false", \
 	"list pools", "osd", "r", "cli,rest")
 COMMAND("osd blacklist ls", "show blacklisted clients", "osd", "r", "cli,rest")
+COMMAND("osd blacklist clear", "clear all blacklisted clients", "osd", "rw",
+        "cli,rest")
 COMMAND("osd crush rule list", "list crush rules", "osd", "r", "cli,rest")
 COMMAND("osd crush rule ls", "list crush rules", "osd", "r", "cli,rest")
 COMMAND("osd crush rule dump " \
@@ -536,7 +539,7 @@ COMMAND("osd crush reweight-subtree " \
 	"change all leaf items beneath <name> to <weight> in crush map", \
 	"osd", "rw", "cli,rest")
 COMMAND("osd crush tunables " \
-	"name=profile,type=CephChoices,strings=legacy|argonaut|bobtail|firefly|hammer|optimal|default", \
+	"name=profile,type=CephChoices,strings=legacy|argonaut|bobtail|firefly|hammer|jewel|optimal|default", \
 	"set crush tunables values to <profile>", "osd", "rw", "cli,rest")
 COMMAND("osd crush set-tunable "				    \
 	"name=tunable,type=CephChoices,strings=straw_calc_version " \
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index cbf37c2..e54e55e 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -62,6 +62,8 @@
 #include "common/perf_counters.h"
 #include "common/admin_socket.h"
 
+#include "global/signal_handler.h"
+
 #include "include/color.h"
 #include "include/ceph_fs.h"
 #include "include/str_list.h"
@@ -356,7 +358,7 @@ abort:
 void Monitor::handle_signal(int signum)
 {
   assert(signum == SIGINT || signum == SIGTERM);
-  derr << "*** Got Signal " << sys_siglist[signum] << " ***" << dendl;
+  derr << "*** Got Signal " << sig_str(signum) << " ***" << dendl;
   shutdown();
 }
 
@@ -419,10 +421,9 @@ void Monitor::read_features_off_disk(MonitorDBStore *store, CompatSet *features)
     //be made smarter.
     *features = get_legacy_features();
 
-    bufferlist bl;
-    features->encode(bl);
+    features->encode(featuresbl);
     MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction);
-    t->put(MONITOR_NAME, COMPAT_SET_LOC, bl);
+    t->put(MONITOR_NAME, COMPAT_SET_LOC, featuresbl);
     store->apply_transaction(t);
   } else {
     bufferlist::iterator it = featuresbl.begin();
@@ -675,11 +676,14 @@ int Monitor::preinit()
     if (authmon()->get_last_committed() == 0) {
       dout(10) << "loading initial keyring to bootstrap authentication for mkfs" << dendl;
       bufferlist bl;
-      store->get("mkfs", "keyring", bl);
-      KeyRing keyring;
-      bufferlist::iterator p = bl.begin();
-      ::decode(keyring, p);
-      extract_save_mon_key(keyring);
+      int err = store->get("mkfs", "keyring", bl);
+      if (err == 0 && bl.length() > 0) {
+        // Attempt to decode and extract keyring only if it is found.
+        KeyRing keyring;
+        bufferlist::iterator p = bl.begin();
+        ::decode(keyring, p);
+        extract_save_mon_key(keyring);
+      }
     }
 
     string keyring_loc = g_conf->mon_data + "/keyring";
@@ -1086,7 +1090,6 @@ void Monitor::sync_obtain_latest_monmap(bufferlist &bl)
     bufferlist backup_bl;
     int err = store->get("mon_sync", "latest_monmap", backup_bl);
     if (err < 0) {
-      assert(err != -ENOENT);
       derr << __func__
            << " something wrong happened while reading the store: "
            << cpp_strerror(err) << dendl;
@@ -1373,6 +1376,7 @@ void Monitor::handle_sync_get_chunk(MonOpRequestRef op)
     bufferlist bl;
     sp.last_committed++;
     store->get(paxos->get_name(), sp.last_committed, bl);
+    // TODO: what if store->get returns error or empty bl?
     tx->put(paxos->get_name(), sp.last_committed, bl);
     left -= bl.length();
     dout(20) << __func__ << " including paxos state " << sp.last_committed
@@ -3088,19 +3092,19 @@ void Monitor::forward_request_leader(MonOpRequestRef op)
 struct AnonConnection : public Connection {
   AnonConnection(CephContext *cct) : Connection(cct, NULL) {}
 
-  int send_message(Message *m) {
+  int send_message(Message *m) override {
     assert(!"send_message on anonymous connection");
   }
-  void send_keepalive() {
+  void send_keepalive() override {
     assert(!"send_keepalive on anonymous connection");
   }
-  void mark_down() {
+  void mark_down() override {
     // silently ignore
   }
-  void mark_disposable() {
+  void mark_disposable() override {
     // silengtly ignore
   }
-  bool is_connected() { return false; }
+  bool is_connected() override { return false; }
 };
 
 //extract the original message and put it into the regular dispatch function
@@ -4142,6 +4146,18 @@ void Monitor::handle_subscribe(MonOpRequestRef op)
     if ((p->second.flags & CEPH_SUBSCRIBE_ONETIME) == 0)
       reply = true;
 
+    // remove conflicting subscribes
+    if (logmon()->sub_name_to_id(p->first) >= 0) {
+      for (map<string, Subscription*>::iterator it = s->sub_map.begin();
+	   it != s->sub_map.end(); ) {
+	if (it->first != p->first && logmon()->sub_name_to_id(it->first) >= 0) {
+	  session_map.remove_sub((it++)->second);
+	} else {
+	  ++it;
+	}
+      }
+    }
+
     session_map.add_update_sub(s, p->first, p->second.start, 
 			       p->second.flags & CEPH_SUBSCRIBE_ONETIME,
 			       m->get_connection()->has_feature(CEPH_FEATURE_INCSUBOSDMAP));
@@ -4337,7 +4353,7 @@ int Monitor::get_mon_metadata(int mon, Formatter *f, ostream& err)
   assert(f);
   map<int, Metadata> last_metadata;
   if (int r = load_metadata(last_metadata)) {
-    err << "Unable to load metadata";
+    err << "Unable to load metadata: " << cpp_strerror(r);
     return r;
   }
   if (!last_metadata.count(mon)) {
@@ -4533,6 +4549,7 @@ bool Monitor::_scrub(ScrubResult *r,
     }
 
     bufferlist bl;
+    //TODO: what when store->get returns error or empty bl?
     store->get(k.first, k.second, bl);
     uint32_t key_crc = bl.crc32c(0);
     dout(30) << __func__ << " " << k << " bl " << bl.length() << " bytes"
@@ -4762,11 +4779,10 @@ void Monitor::prepare_new_fingerprint(MonitorDBStore::TransactionRef t)
 
 int Monitor::check_fsid()
 {
-  if (!store->exists(MONITOR_NAME, "cluster_uuid"))
-    return -ENOENT;
-
   bufferlist ebl;
   int r = store->get(MONITOR_NAME, "cluster_uuid", ebl);
+  if (r == -ENOENT)
+    return r;
   assert(r == 0);
 
   string es(ebl.c_str(), ebl.length());
diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h
index 15558e3..082e171 100644
--- a/src/mon/MonitorDBStore.h
+++ b/src/mon/MonitorDBStore.h
@@ -507,16 +507,8 @@ class MonitorDBStore
   }
 
   int get(const string& prefix, const string& key, bufferlist& bl) {
-    set<string> k;
-    k.insert(key);
-    map<string,bufferlist> out;
-
-    db->get(prefix, k, &out);
-    if (out.empty())
-      return -ENOENT;
-    bl.append(out[key]);
-
-    return 0;
+    assert(bl.length() == 0);
+    return db->get(prefix, key, &bl);
   }
 
   int get(const string& prefix, const version_t ver, bufferlist& bl) {
@@ -634,7 +626,7 @@ class MonitorDBStore
       do_dump(false),
       dump_fd_binary(-1),
       dump_fmt(true),
-      io_work(g_ceph_context, "monstore"),
+      io_work(g_ceph_context, "monstore", "fn_monstore"),
       is_open(false) {
     string::const_reverse_iterator rit;
     int pos = 0;
diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc
index f60d399..900c291 100644
--- a/src/mon/MonmapMonitor.cc
+++ b/src/mon/MonmapMonitor.cc
@@ -297,6 +297,57 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
     return true;
   }
 
+  /* We should follow the following rules:
+   *
+   * - 'monmap' is the current, consistent version of the monmap
+   * - 'pending_map' is the uncommitted version of the monmap
+   *
+   * All checks for the current state must be made against 'monmap'.
+   * All changes are made against 'pending_map'.
+   *
+   * If there are concurrent operations modifying 'pending_map', please
+   * follow the following rules.
+   *
+   * - if pending_map has already been changed, the second operation must
+   *   wait for the proposal to finish and be run again; This is the easiest
+   *   path to guarantee correctness but may impact performance (i.e., it
+   *   will take longer for the user to get a reply).
+   *
+   * - if the result of the second operation can be guaranteed to be
+   *   idempotent, the operation may reply to the user once the proposal
+   *   finishes; still needs to wait for the proposal to finish.
+   *
+   * - An operation _NEVER_ returns to the user based on pending state.
+   *
+   * If an operation does not modify current stable monmap, it may be
+   * serialized before current pending map, regardless of any change that
+   * has been made to the pending map -- remember, pending is uncommitted
+   * state, thus we are not bound by it.
+   */
+
+  assert(mon->monmap);
+  MonMap &monmap = *mon->monmap;
+
+
+  /* Please note:
+   *
+   * Adding or removing monitors may lead to loss of quorum.
+   *
+   * Because quorum may be lost, it's important to reply something
+   * to the user, lest she end up waiting forever for a reply. And
+   * no reply will ever be sent until quorum is formed again.
+   *
+   * On the other hand, this means we're leaking uncommitted state
+   * to the user. As such, please be mindful of the reply message.
+   *
+   * e.g., 'adding monitor mon.foo' is okay ('adding' is an on-going
+   * operation and conveys its not-yet-permanent nature); whereas
+   * 'added monitor mon.foo' presumes the action has successfully
+   * completed and state has been committed, which may not be true.
+   */
+
+
+  bool propose = false;
   if (prefix == "mon add") {
     string name;
     cmd_getval(g_ceph_context, cmdmap, "name", name);
@@ -308,7 +359,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
     if (!addr.parse(addrstr.c_str())) {
       err = -EINVAL;
       ss << "addr " << addrstr << "does not parse";
-      goto out;
+      goto reply;
     }
 
     if (addr.get_port() == 0) {
@@ -319,8 +370,8 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
     /**
      * If we have a monitor with the same name and different addr, then EEXIST
      * If we have a monitor with the same addr and different name, then EEXIST
-     * If we have a monitor with the same addr and same name, then return as if
-     * we had just added the monitor.
+     * If we have a monitor with the same addr and same name, then wait for
+     * the proposal to finish and return success.
      * If we don't have the monitor, add it.
      */
 
@@ -329,64 +380,106 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
       ss << "; ";
 
     do {
-      if (pending_map.contains(addr)) {
-        string n = pending_map.get_name(addr);
-        if (n == name)
-          break;
-      } else if (pending_map.contains(name)) {
-        entity_addr_t tmp_addr = pending_map.get_addr(name);
-        if (tmp_addr == addr)
-          break;
+      if (monmap.contains(name)) {
+        if (monmap.get_addr(name) == addr) {
+          // stable map contains monitor with the same name at the same address.
+          // serialize before current pending map.
+          err = 0; // for clarity; this has already been set above.
+          ss << "mon." << name << " at " << addr << " already exists";
+          goto reply;
+        } else {
+          ss << "mon." << name
+             << " already exists at address " << monmap.get_addr(name);
+        }
+      } else if (monmap.contains(addr)) {
+        // we established on the previous branch that name is different
+        ss << "mon." << monmap.get_name(addr)
+           << " already exists at address " << addr;
       } else {
+        // go ahead and add
         break;
       }
       err = -EEXIST;
-      ss << "mon." << name << " at " << addr << " already exists";
-      goto out;
+      goto reply;
     } while (false);
 
-    ss << "added mon." << name << " at " << addr;
-    if (pending_map.contains(name)) {
-      goto out;
-    }
+    /* Given there's no delay between proposals on the MonmapMonitor (see
+     * MonmapMonitor::should_propose()), there is no point in checking for
+     * a mismatch between name and addr on pending_map.
+     *
+     * Once we established the monitor does not exist in the committed state,
+     * we can simply go ahead and add the monitor.
+     */
 
     pending_map.add(name, addr);
     pending_map.last_changed = ceph_clock_now(g_ceph_context);
-    getline(ss, rs);
-    wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
-                                                     get_last_committed() + 1));
-    return true;
+    ss << "adding mon." << name << " at " << addr;
+    propose = true;
+    dout(0) << __func__ << " proposing new mon." << name << dendl;
+    goto reply;
 
   } else if (prefix == "mon remove") {
     string name;
     cmd_getval(g_ceph_context, cmdmap, "name", name);
-    if (!pending_map.contains(name)) {
+    if (!monmap.contains(name)) {
       err = 0;
-      ss << "mon " << name << " does not exist or has already been removed";
-      goto out;
+      ss << "mon." << name << " does not exist or has already been removed";
+      goto reply;
     }
 
-    if (pending_map.size() == 1) {
+    if (monmap.size() == 1) {
       err = -EINVAL;
       ss << "error: refusing removal of last monitor " << name;
-      goto out;
+      goto reply;
     }
+
+    /* At the time of writing, there is no risk of races when multiple clients
+     * attempt to use the same name. The reason is simple but may not be
+     * obvious.
+     *
+     * In a nutshell, we do not collate proposals on the MonmapMonitor. As
+     * soon as we return 'true' below, PaxosService::dispatch() will check if
+     * the service should propose, and - if so - the service will be marked as
+     * 'proposing' and a proposal will be triggered. The PaxosService class
+     * guarantees that once a service is marked 'proposing' no further writes
+     * will be handled.
+     *
+     * The decision on whether the service should propose or not is, in this
+     * case, made by MonmapMonitor::should_propose(), which always considers
+     * the proposal delay being 0.0 seconds. This is key for PaxosService to
+     * trigger the proposal immediately.
+     * 0.0 seconds of delay.
+     *
+     * From the above, there's no point in performing further checks on the
+     * pending_map, as we don't ever have multiple proposals in-flight in
+     * this service. As we've established the committed state contains the
+     * monitor, we can simply go ahead and remove it.
+     *
+     * Please note that the code hinges on all of the above to be true. It
+     * has been true since time immemorial and we don't see a good reason
+     * to make it sturdier at this time - mainly because we don't think it's
+     * going to change any time soon, lest for any bug that may be unwillingly
+     * introduced.
+     */
+
     entity_addr_t addr = pending_map.get_addr(name);
     pending_map.remove(name);
     pending_map.last_changed = ceph_clock_now(g_ceph_context);
-    ss << "removed mon." << name << " at " << addr << ", there are now " << pending_map.size() << " monitors" ;
-    getline(ss, rs);
-    // send reply immediately in case we get removed
-    mon->reply_command(op, 0, rs, get_last_committed());
-    return true;
-  }
-  else
+    ss << "removing mon." << name << " at " << addr
+       << ", there will be " << pending_map.size() << " monitors" ;
+    propose = true;
+    goto reply;
+
+  } else {
     ss << "unknown command " << prefix;
+    err = -EINVAL;
+  }
 
-out:
+reply:
   getline(ss, rs);
   mon->reply_command(op, err, rs, get_last_committed());
-  return false;
+  // we are returning to the user; do not propose.
+  return propose;
 }
 
 bool MonmapMonitor::preprocess_join(MonOpRequestRef op)
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc
index 3e7cd35..77e26de 100644
--- a/src/mon/OSDMonitor.cc
+++ b/src/mon/OSDMonitor.cc
@@ -1564,7 +1564,7 @@ bool OSDMonitor::can_mark_down(int i)
   int up = osdmap.get_num_up_osds() - pending_inc.get_net_marked_down(&osdmap);
   float up_ratio = (float)up / (float)num_osds;
   if (up_ratio < g_conf->mon_osd_min_up_ratio) {
-    dout(5) << "can_mark_down current up_ratio " << up_ratio << " < min "
+    dout(2) << "can_mark_down current up_ratio " << up_ratio << " < min "
 	    << g_conf->mon_osd_min_up_ratio
 	    << ", will not mark osd." << i << " down" << dendl;
     return false;
@@ -2067,8 +2067,11 @@ bool OSDMonitor::prepare_boot(MonOpRequestRef op)
       dout(10) << " not laggy, new xi " << xi << dendl;
     } else {
       if (xi.down_stamp.sec()) {
-	int interval = ceph_clock_now(g_ceph_context).sec() - xi.down_stamp.sec();
-	xi.laggy_interval =
+        int interval = ceph_clock_now(g_ceph_context).sec() - xi.down_stamp.sec();
+        if (g_conf->mon_osd_laggy_max_interval && (interval > g_conf->mon_osd_laggy_max_interval)) {
+          interval =  g_conf->mon_osd_laggy_max_interval;
+        }
+        xi.laggy_interval =
 	  interval * g_conf->mon_osd_laggy_weight +
 	  xi.laggy_interval * (1.0 - g_conf->mon_osd_laggy_weight);
       }
@@ -5737,6 +5740,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       newcrush.set_tunables_firefly();
     } else if (profile == "hammer") {
       newcrush.set_tunables_hammer();
+    } else if (profile == "jewel") {
+      newcrush.set_tunables_jewel();
     } else if (profile == "optimal") {
       newcrush.set_tunables_optimal();
     } else if (profile == "default") {
@@ -6551,6 +6556,18 @@ done:
 					      get_last_committed() + 1));
     return true;
 
+  } else if (prefix == "osd blacklist clear") {
+    pending_inc.new_blacklist.clear();
+    std::list<std::pair<entity_addr_t,utime_t > > blacklist;
+    osdmap.get_blacklist(&blacklist);
+    for (const auto &entry : blacklist) {
+      pending_inc.old_blacklist.push_back(entry.first);
+    }
+    ss << " removed all blacklist entries";
+    getline(ss, rs);
+    wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
+                                              get_last_committed() + 1));
+    return true;
   } else if (prefix == "osd blacklist") {
     string addrstr;
     cmd_getval(g_ceph_context, cmdmap, "addr", addrstr);
diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc
index 6eb8b33..ab8f8a9 100644
--- a/src/mon/PGMap.cc
+++ b/src/mon/PGMap.cc
@@ -95,8 +95,8 @@ void PGMap::Incremental::decode(bufferlist::iterator &bl)
     ::decode(osd_epochs, bl);
   } else {
     for (map<int32_t, osd_stat_t>::iterator i = osd_stat_updates.begin();
-	 i != osd_stat_updates.end();
-	 ++i) {
+         i != osd_stat_updates.end();
+         ++i) {
       // This isn't accurate, but will cause trimming to behave like
       // previously.
       osd_epochs.insert(make_pair(i->first, osdmap_epoch));
@@ -210,16 +210,16 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
       pg_stat.insert(v);
       // did we affect the min?
       if (min_last_epoch_clean &&
-	  update_stat.get_effective_last_epoch_clean() < min_last_epoch_clean)
+          update_stat.get_effective_last_epoch_clean() < min_last_epoch_clean)
 	min_last_epoch_clean = 0;
     } else {
       // did we (or might we) affect the min?
       epoch_t lec = update_stat.get_effective_last_epoch_clean();
       if (min_last_epoch_clean &&
-	  (lec < min_last_epoch_clean ||  // we did
-	   (lec > min_last_epoch_clean && // we might
-	    t->second.get_effective_last_epoch_clean() == min_last_epoch_clean)
-	   ))
+          (lec < min_last_epoch_clean ||  // we did
+           (lec > min_last_epoch_clean && // we might
+            t->second.get_effective_last_epoch_clean() == min_last_epoch_clean)
+          ))
 	min_last_epoch_clean = 0;
 
       stat_pg_sub(update_pg, t->second);
@@ -229,7 +229,7 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
   }
   assert(osd_stat.size() == osd_epochs.size());
   for (map<int32_t,osd_stat_t>::const_iterator p =
-	 inc.get_osd_stat_updates().begin();
+         inc.get_osd_stat_updates().begin();
        p != inc.get_osd_stat_updates().end();
        ++p) {
     int osd = p->first;
@@ -249,10 +249,10 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
 
     // will we potentially affect the min?
     if (min_last_epoch_clean &&
-	(i == osd_epochs.end() ||
-	 j->second < min_last_epoch_clean ||
-	 (j->second > min_last_epoch_clean &&
-	  i->second == min_last_epoch_clean)))
+        (i == osd_epochs.end() ||
+         j->second < min_last_epoch_clean ||
+         (j->second > min_last_epoch_clean &&
+          i->second == min_last_epoch_clean)))
       min_last_epoch_clean = 0;
 
     if (i == osd_epochs.end())
@@ -396,8 +396,8 @@ void PGMap::update_pg(pg_t pgid, bufferlist& bl)
   if (min_last_epoch_clean &&
       (lec < min_last_epoch_clean ||  // we did
        (lec > min_last_epoch_clean && // we might
-	old_lec == min_last_epoch_clean)
-       ))
+        old_lec == min_last_epoch_clean)
+      ))
     min_last_epoch_clean = 0;
 }
 
@@ -406,7 +406,7 @@ void PGMap::remove_pg(pg_t pgid)
   ceph::unordered_map<pg_t,pg_stat_t>::iterator s = pg_stat.find(pgid);
   if (s != pg_stat.end()) {
     if (min_last_epoch_clean &&
-	s->second.get_effective_last_epoch_clean() == min_last_epoch_clean)
+        s->second.get_effective_last_epoch_clean() == min_last_epoch_clean)
       min_last_epoch_clean = 0;
     stat_pg_sub(pgid, s->second);
     pg_stat.erase(s);
@@ -437,8 +437,8 @@ void PGMap::update_osd(int osd, bufferlist& bl)
     ::decode(e, p);
 
     if (e < min_last_epoch_clean ||
-	(e > min_last_epoch_clean &&
-	 old_lec == min_last_epoch_clean))
+        (e > min_last_epoch_clean &&
+         old_lec == min_last_epoch_clean))
       min_last_epoch_clean = 0;
   } else {
     // WARNING: we are not refreshing min_last_epoch_clean!  must be old store
@@ -460,7 +460,7 @@ void PGMap::remove_osd(int osd)
 }
 
 void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating,
-			bool sameosds)
+                        bool sameosds)
 {
   pg_pool_sum[pgid.pool()].add(s);
   pg_sum.add(s);
@@ -493,7 +493,7 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating,
 }
 
 void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating,
-			bool sameosds)
+                        bool sameosds)
 {
   pool_stat_t& ps = pg_pool_sum[pgid.pool()];
   ps.sub(s);
@@ -549,7 +549,7 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating,
 }
 
 void PGMap::stat_pg_update(const pg_t pgid, pg_stat_t& s,
-			   bufferlist::iterator& blp)
+                           bufferlist::iterator& blp)
 {
   pg_stat_t n;
   ::decode(n, blp);
@@ -580,6 +580,7 @@ epoch_t PGMap::calc_min_last_epoch_clean() const
 {
   if (pg_stat.empty())
     return 0;
+
   ceph::unordered_map<pg_t,pg_stat_t>::const_iterator p = pg_stat.begin();
   epoch_t min = p->second.get_effective_last_epoch_clean();
   for (++p; p != pg_stat.end(); ++p) {
@@ -656,8 +657,8 @@ void PGMap::decode(bufferlist::iterator &bl)
     ::decode(osd_epochs, bl);
   } else {
     for (ceph::unordered_map<int32_t, osd_stat_t>::iterator i = osd_stat.begin();
-	 i != osd_stat.end();
-	 ++i) {
+         i != osd_stat.end();
+         ++i) {
       // This isn't accurate, but will cause trimming to behave like
       // previously.
       osd_epochs.insert(make_pair(i->first, last_osdmap_epoch));
@@ -681,8 +682,8 @@ void PGMap::dirty_all(Incremental& inc)
   for (ceph::unordered_map<int32_t, osd_stat_t>::const_iterator p = osd_stat.begin(); p != osd_stat.end(); ++p) {
     assert(osd_epochs.count(p->first));
     inc.update_stat(p->first,
-		   inc.get_osd_epochs().find(p->first)->second,
-		   p->second);
+                    inc.get_osd_epochs().find(p->first)->second,
+                    p->second);
   }
 }
 
@@ -703,7 +704,7 @@ void PGMap::dump_basic(Formatter *f) const
   f->dump_unsigned("min_last_epoch_clean", min_last_epoch_clean);
   f->dump_float("full_ratio", full_ratio);
   f->dump_float("near_full_ratio", nearfull_ratio);
-  
+
   f->open_object_section("pg_stats_sum");
   pg_sum.dump(f);
   f->close_section();
@@ -714,7 +715,7 @@ void PGMap::dump_basic(Formatter *f) const
 
   f->open_object_section("osd_epochs");
   for (ceph::unordered_map<int32_t,epoch_t>::const_iterator p =
-	 osd_epochs.begin(); p != osd_epochs.end(); ++p) {
+         osd_epochs.begin(); p != osd_epochs.end(); ++p) {
     f->open_object_section("osd");
     f->dump_unsigned("osd", p->first);
     f->dump_unsigned("epoch", p->second);
@@ -778,47 +779,47 @@ void PGMap::dump_osd_stats(Formatter *f) const
 }
 
 void PGMap::dump_pg_stats_plain(ostream& ss,
-				const ceph::unordered_map<pg_t, pg_stat_t>& pg_stats,
-				bool brief) const
+                                const ceph::unordered_map<pg_t, pg_stat_t>& pg_stats,
+                                bool brief) const
 {
   if (brief)
     ss << "pg_stat\tstate\tup\tup_primary\tacting\tacting_primary" << std::endl;
   else
     ss << "pg_stat\tobjects\tmip\tdegr\tmisp\tunf\tbytes\tlog\tdisklog\tstate\t"
-      "state_stamp\tv\treported\tup\tup_primary\tacting\tacting_primary\t"
-      "last_scrub\tscrub_stamp\tlast_deep_scrub\tdeep_scrub_stamp" << std::endl;
+          "state_stamp\tv\treported\tup\tup_primary\tacting\tacting_primary\t"
+          "last_scrub\tscrub_stamp\tlast_deep_scrub\tdeep_scrub_stamp" << std::endl;
   for (ceph::unordered_map<pg_t, pg_stat_t>::const_iterator i = pg_stats.begin();
        i != pg_stats.end(); ++i) {
     const pg_stat_t &st(i->second);
     if (brief) {
       ss << i->first
-	 << "\t" << pg_state_string(st.state)
-	 << "\t" << st.up
-	 << "\t" << st.up_primary
-	 << "\t" << st.acting
-	 << "\t" << st.acting_primary
-	 << std::endl;
+         << "\t" << pg_state_string(st.state)
+         << "\t" << st.up
+         << "\t" << st.up_primary
+         << "\t" << st.acting
+         << "\t" << st.acting_primary
+         << std::endl;
     } else {
       ss << i->first
-	 << "\t" << st.stats.sum.num_objects
-	 << "\t" << st.stats.sum.num_objects_missing_on_primary
-	 << "\t" << st.stats.sum.num_objects_degraded
-	 << "\t" << st.stats.sum.num_objects_misplaced
-	 << "\t" << st.stats.sum.num_objects_unfound
-	 << "\t" << st.stats.sum.num_bytes
-	 << "\t" << st.log_size
-	 << "\t" << st.ondisk_log_size
-	 << "\t" << pg_state_string(st.state)
-	 << "\t" << st.last_change
-	 << "\t" << st.version
-	 << "\t" << st.reported_epoch << ":" << st.reported_seq
-	 << "\t" << pg_vector_string(st.up)
-	 << "\t" << st.up_primary
-	 << "\t" << pg_vector_string(st.acting)
-	 << "\t" << st.acting_primary
-	 << "\t" << st.last_scrub << "\t" << st.last_scrub_stamp
-	 << "\t" << st.last_deep_scrub << "\t" << st.last_deep_scrub_stamp
-	 << std::endl;
+         << "\t" << st.stats.sum.num_objects
+         << "\t" << st.stats.sum.num_objects_missing_on_primary
+         << "\t" << st.stats.sum.num_objects_degraded
+         << "\t" << st.stats.sum.num_objects_misplaced
+         << "\t" << st.stats.sum.num_objects_unfound
+         << "\t" << st.stats.sum.num_bytes
+         << "\t" << st.log_size
+         << "\t" << st.ondisk_log_size
+         << "\t" << pg_state_string(st.state)
+         << "\t" << st.last_change
+         << "\t" << st.version
+         << "\t" << st.reported_epoch << ":" << st.reported_seq
+         << "\t" << pg_vector_string(st.up)
+         << "\t" << st.up_primary
+         << "\t" << pg_vector_string(st.acting)
+         << "\t" << st.acting_primary
+         << "\t" << st.last_scrub << "\t" << st.last_scrub_stamp
+         << "\t" << st.last_deep_scrub << "\t" << st.last_deep_scrub_stamp
+         << std::endl;
     }
   }
 }
@@ -856,7 +857,7 @@ void PGMap::dump_pool_stats(ostream& ss, bool header) const
        ++p) {
     ss << "pool " << p->first
        << "\t" << p->second.stats.sum.num_objects
-      //<< "\t" << p->second.num_object_copies
+    //<< "\t" << p->second.num_object_copies
        << "\t" << p->second.stats.sum.num_objects_missing_on_primary
        << "\t" << p->second.stats.sum.num_objects_degraded
        << "\t" << p->second.stats.sum.num_objects_misplaced
@@ -873,7 +874,7 @@ void PGMap::dump_pg_sum_stats(ostream& ss, bool header) const
   if (header)
     ss << "pg_stat\tobjects\tmip\tdegr\tmisp\tunf\tbytes\tlog\tdisklog" << std::endl;
   ss << " sum\t" << pg_sum.stats.sum.num_objects
-    //<< "\t" << pg_sum.num_object_copies
+  //<< "\t" << pg_sum.num_object_copies
      << "\t" << pg_sum.stats.sum.num_objects_missing_on_primary
      << "\t" << pg_sum.stats.sum.num_objects_degraded
      << "\t" << pg_sum.stats.sum.num_objects_misplaced
@@ -892,14 +893,14 @@ void PGMap::dump_osd_stats(ostream& ss) const
        ++p) {
     ss << p->first
        << "\t" << p->second.kb_used
-       << "\t" << p->second.kb_avail 
+       << "\t" << p->second.kb_avail
        << "\t" << p->second.kb
        << "\t" << p->second.hb_in
        << "\t" << p->second.hb_out
        << std::endl;
   }
   ss << " sum\t" << osd_sum.kb_used
-     << "\t" << osd_sum.kb_avail 
+     << "\t" << osd_sum.kb_avail
      << "\t" << osd_sum.kb
      << std::endl;
 }
@@ -908,13 +909,13 @@ void PGMap::dump_osd_sum_stats(ostream& ss) const
 {
   ss << "osdstat\tkbused\tkbavail\tkb" << std::endl;
   ss << " sum\t" << osd_sum.kb_used
-     << "\t" << osd_sum.kb_avail 
+     << "\t" << osd_sum.kb_avail
      << "\t" << osd_sum.kb
      << std::endl;
 }
 
 void PGMap::get_stuck_stats(int types, utime_t cutoff,
-			    ceph::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const
+                            ceph::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const
 {
   assert(types != 0);
   for (ceph::unordered_map<pg_t, pg_stat_t>::const_iterator i = pg_stat.begin();
@@ -922,29 +923,29 @@ void PGMap::get_stuck_stats(int types, utime_t cutoff,
        ++i) {
     utime_t val = cutoff; // don't care about >= cutoff so that is infinity
 
-    if ((types & STUCK_INACTIVE) && ! (i->second.state & PG_STATE_ACTIVE)) {
+    if ((types & STUCK_INACTIVE) && !(i->second.state & PG_STATE_ACTIVE)) {
       if (i->second.last_active < val)
-        val = i->second.last_active;
+	val = i->second.last_active;
     }
 
-    if ((types & STUCK_UNCLEAN) && ! (i->second.state & PG_STATE_CLEAN)) {
+    if ((types & STUCK_UNCLEAN) && !(i->second.state & PG_STATE_CLEAN)) {
       if (i->second.last_clean < val)
-        val = i->second.last_clean;
+	val = i->second.last_clean;
     }
 
     if ((types & STUCK_DEGRADED) && (i->second.state & PG_STATE_DEGRADED)) {
       if (i->second.last_undegraded < val)
-        val = i->second.last_undegraded;
+	val = i->second.last_undegraded;
     }
 
     if ((types & STUCK_UNDERSIZED) && (i->second.state & PG_STATE_UNDERSIZED)) {
       if (i->second.last_fullsized < val)
-        val = i->second.last_fullsized;
+	val = i->second.last_fullsized;
     }
 
     if ((types & STUCK_STALE) && (i->second.state & PG_STATE_STALE)) {
       if (i->second.last_unstale < val)
-        val = i->second.last_unstale;
+	val = i->second.last_unstale;
     }
 
     // val is now the earliest any of the requested stuck states began
@@ -1045,7 +1046,7 @@ void PGMap::recovery_summary(Formatter *f, list<string> *psl,
 {
   if (delta_sum.stats.sum.num_objects_degraded && delta_sum.stats.sum.num_object_copies > 0) {
     double pc = (double)delta_sum.stats.sum.num_objects_degraded /
-      (double)delta_sum.stats.sum.num_object_copies * (double)100.0;
+                (double)delta_sum.stats.sum.num_object_copies * (double)100.0;
     char b[20];
     snprintf(b, sizeof(b), "%.3lf", pc);
     if (f) {
@@ -1055,13 +1056,13 @@ void PGMap::recovery_summary(Formatter *f, list<string> *psl,
     } else {
       ostringstream ss;
       ss << delta_sum.stats.sum.num_objects_degraded
-	 << "/" << delta_sum.stats.sum.num_object_copies << " objects degraded (" << b << "%)";
+         << "/" << delta_sum.stats.sum.num_object_copies << " objects degraded (" << b << "%)";
       psl->push_back(ss.str());
     }
   }
   if (delta_sum.stats.sum.num_objects_misplaced && delta_sum.stats.sum.num_object_copies > 0) {
     double pc = (double)delta_sum.stats.sum.num_objects_misplaced /
-      (double)delta_sum.stats.sum.num_object_copies * (double)100.0;
+                (double)delta_sum.stats.sum.num_object_copies * (double)100.0;
     char b[20];
     snprintf(b, sizeof(b), "%.3lf", pc);
     if (f) {
@@ -1071,13 +1072,13 @@ void PGMap::recovery_summary(Formatter *f, list<string> *psl,
     } else {
       ostringstream ss;
       ss << delta_sum.stats.sum.num_objects_misplaced
-	 << "/" << delta_sum.stats.sum.num_object_copies << " objects misplaced (" << b << "%)";
+         << "/" << delta_sum.stats.sum.num_object_copies << " objects misplaced (" << b << "%)";
       psl->push_back(ss.str());
     }
   }
   if (delta_sum.stats.sum.num_objects_unfound && delta_sum.stats.sum.num_objects) {
     double pc = (double)delta_sum.stats.sum.num_objects_unfound /
-      (double)delta_sum.stats.sum.num_objects * (double)100.0;
+                (double)delta_sum.stats.sum.num_objects * (double)100.0;
     char b[20];
     snprintf(b, sizeof(b), "%.3lf", pc);
     if (f) {
@@ -1087,7 +1088,7 @@ void PGMap::recovery_summary(Formatter *f, list<string> *psl,
     } else {
       ostringstream ss;
       ss << delta_sum.stats.sum.num_objects_unfound
-	 << "/" << delta_sum.stats.sum.num_objects << " unfound (" << b << "%)";
+         << "/" << delta_sum.stats.sum.num_objects << " unfound (" << b << "%)";
       psl->push_back(ss.str());
     }
   }
@@ -1138,6 +1139,7 @@ void PGMap::pool_recovery_rate_summary(Formatter *f, ostream *out,
     per_pool_sum_delta.find(poolid);
   if (p == per_pool_sum_delta.end())
     return;
+
   ceph::unordered_map<uint64_t,utime_t>::const_iterator ts =
     per_pool_sum_deltas_stamps.find(p->first);
   assert(ts != per_pool_sum_deltas_stamps.end());
@@ -1151,6 +1153,7 @@ void PGMap::pool_recovery_summary(Formatter *f, list<string> *psl,
     per_pool_sum_delta.find(poolid);
   if (p == per_pool_sum_delta.end())
     return;
+
   recovery_summary(f, psl, p->second.first);
 }
 
@@ -1178,11 +1181,13 @@ void PGMap::client_io_rate_summary(Formatter *f, ostream *out,
 	*out << pretty_si_t(wr) << "B/s wr, ";
       }
     }
-    int64_t iops = (pos_delta.stats.sum.num_rd + pos_delta.stats.sum.num_wr) / (double)delta_stamp;
+    int64_t iops_rd = pos_delta.stats.sum.num_rd / (double)delta_stamp;
+    int64_t iops_wr = pos_delta.stats.sum.num_wr / (double)delta_stamp;
     if (f) {
-      f->dump_int("op_per_sec", iops);
+      f->dump_int("read_op_per_sec", iops_rd);
+      f->dump_int("write_op_per_sec", iops_wr);
     } else {
-      *out << pretty_si_t(iops) << "op/s";
+      *out << pretty_si_t(iops_rd) << "op/s rd, " << pretty_si_t(iops_wr) << "op/s wr";
     }
   }
 }
@@ -1199,6 +1204,7 @@ void PGMap::pool_client_io_rate_summary(Formatter *f, ostream *out,
     per_pool_sum_delta.find(poolid);
   if (p == per_pool_sum_delta.end())
     return;
+
   ceph::unordered_map<uint64_t,utime_t>::const_iterator ts =
     per_pool_sum_deltas_stamps.find(p->first);
   assert(ts != per_pool_sum_deltas_stamps.end());
@@ -1298,6 +1304,7 @@ void PGMap::pool_cache_io_rate_summary(Formatter *f, ostream *out,
     per_pool_sum_delta.find(poolid);
   if (p == per_pool_sum_delta.end())
     return;
+
   ceph::unordered_map<uint64_t,utime_t>::const_iterator ts =
     per_pool_sum_deltas_stamps.find(p->first);
   assert(ts != per_pool_sum_deltas_stamps.end());
@@ -1365,7 +1372,7 @@ void PGMap::update_delta(CephContext *cct,
  * @param pg_sum_old     Old pg_sum
  */
 void PGMap::update_global_delta(CephContext *cct,
-                         const utime_t ts, const pool_stat_t& pg_sum_old)
+                                const utime_t ts, const pool_stat_t& pg_sum_old)
 {
   update_delta(cct, ts, pg_sum_old, &stamp, pg_sum, &pg_sum_delta,
                &stamp_delta, &pg_sum_deltas);
@@ -1443,7 +1450,7 @@ void PGMap::print_summary(Formatter *f, ostream *out) const
     } else {
       ss.setf(std::ios::right);
       ss << "             " << std::setw(7) << p->first
-	 << " " << pg_state_string(p->second) << "\n";
+         << " " << pg_state_string(p->second) << "\n";
       ss.unsetf(std::ios::right);
     }
   }
@@ -1459,13 +1466,13 @@ void PGMap::print_summary(Formatter *f, ostream *out) const
     f->dump_unsigned("bytes_total", osd_sum.kb * 1024ull);
   } else {
     *out << "      pgmap v" << version << ": "
-	 << pg_stat.size() << " pgs, " << pg_pool_sum.size() << " pools, "
-	 << prettybyte_t(pg_sum.stats.sum.num_bytes) << " data, "
-	 << pretty_si_t(pg_sum.stats.sum.num_objects) << "objects\n";
+         << pg_stat.size() << " pgs, " << pg_pool_sum.size() << " pools, "
+         << prettybyte_t(pg_sum.stats.sum.num_bytes) << " data, "
+         << pretty_si_t(pg_sum.stats.sum.num_objects) << "objects\n";
     *out << "            "
-	 << kb_t(osd_sum.kb_used) << " used, "
-	 << kb_t(osd_sum.kb_avail) << " / "
-	 << kb_t(osd_sum.kb) << " avail\n";
+         << kb_t(osd_sum.kb_used) << " used, "
+         << kb_t(osd_sum.kb_avail) << " / "
+         << kb_t(osd_sum.kb) << " avail\n";
   }
 
   list<string> sl;
@@ -1524,12 +1531,12 @@ void PGMap::print_oneline_summary(Formatter *f, ostream *out) const
   string states = ss.str();
   if (out)
     *out << "v" << version << ": "
-	 << pg_stat.size() << " pgs: "
-	 << states << "; "
-	 << prettybyte_t(pg_sum.stats.sum.num_bytes) << " data, "
-	 << kb_t(osd_sum.kb_used) << " used, "
-	 << kb_t(osd_sum.kb_avail) << " / "
-	 << kb_t(osd_sum.kb) << " avail";
+         << pg_stat.size() << " pgs: "
+         << states << "; "
+         << prettybyte_t(pg_sum.stats.sum.num_bytes) << " data, "
+         << kb_t(osd_sum.kb_used) << " used, "
+         << kb_t(osd_sum.kb_avail) << " / "
+         << kb_t(osd_sum.kb) << " avail";
   if (f) {
     f->dump_unsigned("version", version);
     f->dump_unsigned("num_pgs", pg_stat.size());
@@ -1629,14 +1636,14 @@ void PGMap::dump_filtered_pg_stats(Formatter *f, set<pg_t>& pgs)
     f->dump_stream("pgid") << *i;
     st.dump(f);
     f->close_section();
-  } 
+  }
   f->close_section();
-}  
+}
 void PGMap::dump_filtered_pg_stats(ostream& ss, set<pg_t>& pgs)
 {
   ss << "pg_stat\tobjects\tmip\tdegr\tmisp\tunf\tbytes\tlog\tdisklog\tstate\t"
-    "state_stamp\tv\treported\tup\tup_primary\tacting\tacting_primary\t"
-    "last_scrub\tscrub_stamp\tlast_deep_scrub\tdeep_scrub_stamp" << std::endl;
+        "state_stamp\tv\treported\tup\tup_primary\tacting\tacting_primary\t"
+        "last_scrub\tscrub_stamp\tlast_deep_scrub\tdeep_scrub_stamp" << std::endl;
   for (set<pg_t>::iterator i = pgs.begin(); i != pgs.end(); ++i) {
     pg_stat_t& st = pg_stat[*i];
     ss << *i
diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc
index 2f37a56..6cfa82a 100644
--- a/src/mon/PGMonitor.cc
+++ b/src/mon/PGMonitor.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,14 +7,14 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
 #include "json_spirit/json_spirit.h"
-#include "common/debug.h"		// undo damage
+#include "common/debug.h"               // undo damage
 #include "PGMonitor.h"
 #include "Monitor.h"
 #include "MDSMonitor.h"
@@ -55,13 +55,13 @@
 #define dout_prefix _prefix(_dout, mon, pg_map)
 static ostream& _prefix(std::ostream *_dout, const Monitor *mon, const PGMap& pg_map) {
   return *_dout << "mon." << mon->name << "@" << mon->rank
-		<< "(" << mon->get_state_name()
-		<< ").pg v" << pg_map.version << " ";
+                << "(" << mon->get_state_name()
+                << ").pg v" << pg_map.version << " ";
 }
 
 /*
- Tick function to update the map based on performance every N seconds
-*/
+   Tick function to update the map based on performance every N seconds
+ */
 
 void PGMonitor::on_restart()
 {
@@ -89,9 +89,9 @@ void PGMonitor::update_logger()
 
   mon->cluster_logger->set(l_cluster_osd_bytes, pg_map.osd_sum.kb * 1024ull);
   mon->cluster_logger->set(l_cluster_osd_bytes_used,
-			   pg_map.osd_sum.kb_used * 1024ull);
+                           pg_map.osd_sum.kb_used * 1024ull);
   mon->cluster_logger->set(l_cluster_osd_bytes_avail,
-			   pg_map.osd_sum.kb_avail * 1024ull);
+                           pg_map.osd_sum.kb_avail * 1024ull);
 
   mon->cluster_logger->set(l_cluster_num_pool, pg_map.pg_pool_sum.size());
   mon->cluster_logger->set(l_cluster_num_pg, pg_map.pg_stat.size());
@@ -119,7 +119,7 @@ void PGMonitor::update_logger()
   mon->cluster_logger->set(l_cluster_num_bytes, pg_map.pg_sum.stats.sum.num_bytes);
 }
 
-void PGMonitor::tick() 
+void PGMonitor::tick()
 {
   if (!is_active()) return;
 
@@ -127,11 +127,11 @@ void PGMonitor::tick()
 
   if (mon->is_leader()) {
     bool propose = false;
-    
+
     if ((need_check_down_pgs || !need_check_down_pg_osds.empty()) &&
-	check_down_pgs())
+        check_down_pgs())
       propose = true;
-    
+
     if (propose) {
       propose_pending();
     }
@@ -158,14 +158,14 @@ void PGMonitor::tick()
          it != pg_map.per_pool_sum_delta.end(); ) {
       utime_t age = ceph_clock_now(g_ceph_context) - it->second.second;
       if (age > 2*g_conf->mon_delta_reset_interval) {
-        dout(10) << " clearing pg_map delta for pool " << it->first
-                 << " (" << age << " > " << g_conf->mon_delta_reset_interval
-                 << " seconds old)" << dendl;
-        pg_map.per_pool_sum_deltas.erase(it->first);
-        pg_map.per_pool_sum_deltas_stamps.erase(it->first);
-        pg_map.per_pool_sum_delta.erase((it++)->first);
+	dout(10) << " clearing pg_map delta for pool " << it->first
+	         << " (" << age << " > " << g_conf->mon_delta_reset_interval
+	         << " seconds old)" << dendl;
+	pg_map.per_pool_sum_deltas.erase(it->first);
+	pg_map.per_pool_sum_deltas_stamps.erase(it->first);
+	pg_map.per_pool_sum_delta.erase((it++)->first);
       } else {
-        ++it;
+	++it;
       }
     }
   }
@@ -184,6 +184,7 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
   version_t version = get_last_committed();
   if (version == pg_map.version)
     return;
+
   assert(version >= pg_map.version);
 
   if (format_version == 0) {
@@ -198,7 +199,7 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
       int err = get_version_full(latest_full, latest_bl);
       assert(err == 0);
       dout(7) << __func__ << " loading latest full pgmap v"
-	      << latest_full << dendl;
+              << latest_full << dendl;
       try {
 	PGMap tmp_pg_map;
 	bufferlist::iterator p = latest_bl.begin();
@@ -206,7 +207,7 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
 	pg_map = tmp_pg_map;
       } catch (const std::exception& e) {
 	dout(0) << __func__ << ": error parsing update: "
-		<< e.what() << dendl;
+	        << e.what() << dendl;
 	assert(0 == "update_from_paxos: error parsing update");
 	return;
       }
@@ -224,10 +225,9 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
       try {
 	bufferlist::iterator p = bl.begin();
 	inc.decode(p);
-      }
-      catch (const std::exception &e) {
+      } catch (const std::exception &e)   {
 	dout(0) << "update_from_paxos: error parsing "
-		<< "incremental update: " << e.what() << dendl;
+	        << "incremental update: " << e.what() << dendl;
 	assert(0 == "update_from_paxos: error parsing incremental update");
 	return;
       }
@@ -269,7 +269,7 @@ void PGMonitor::update_from_paxos(bool *need_bootstrap)
 
     read_pgmap_meta();
 
-  out:
+out:
     if (last_pg_scan != pg_map.last_pg_scan)
       last_sent_pg_create.clear();  // reset pg_create throttle timer
   }
@@ -313,6 +313,7 @@ void PGMonitor::handle_osd_timeouts()
 {
   if (!mon->is_leader())
     return;
+
   utime_t now(ceph_clock_now(g_ceph_context));
   utime_t timeo(g_conf->mon_osd_report_timeout, 0);
   if (now - mon->get_leader_since() < timeo) {
@@ -440,7 +441,7 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl)
     } else {
       r = mon->store->get(pgmap_pg_prefix, stringify(pgid), pgbl);
       dout(20) << " refreshing pg " << pgid << " got " << r << " len "
-	       << pgbl.length() << dendl;
+               << pgbl.length() << dendl;
 
       if (pg_pool_sum_old.count(pgid.pool()) == 0)
 	pg_pool_sum_old[pgid.pool()] = pg_map.pg_pool_sum[pgid.pool()];
@@ -525,8 +526,8 @@ void PGMonitor::encode_pending(MonitorDBStore::TransactionRef t)
     bufferlist dirty;
     string prefix = pgmap_pg_prefix;
     for (map<pg_t,pg_stat_t>::const_iterator p = pending_inc.pg_stat_updates.begin();
-	 p != pending_inc.pg_stat_updates.end();
-	 ++p) {
+         p != pending_inc.pg_stat_updates.end();
+         ++p) {
       ::encode(p->first, dirty);
       bufferlist bl;
       ::encode(p->second, bl, features);
@@ -542,9 +543,9 @@ void PGMonitor::encode_pending(MonitorDBStore::TransactionRef t)
     bufferlist dirty;
     string prefix = pgmap_osd_prefix;
     for (map<int32_t,osd_stat_t>::const_iterator p =
-	   pending_inc.get_osd_stat_updates().begin();
-	 p != pending_inc.get_osd_stat_updates().end();
-	 ++p) {
+           pending_inc.get_osd_stat_updates().begin();
+         p != pending_inc.get_osd_stat_updates().end();
+         ++p) {
       ::encode(p->first, dirty);
       bufferlist bl;
       ::encode(p->second, bl, features);
@@ -552,9 +553,9 @@ void PGMonitor::encode_pending(MonitorDBStore::TransactionRef t)
       t->put(prefix, stringify(p->first), bl);
     }
     for (set<int32_t>::const_iterator p =
-	   pending_inc.get_osd_stat_rm().begin();
-	 p != pending_inc.get_osd_stat_rm().end();
-	 ++p) {
+           pending_inc.get_osd_stat_rm().begin();
+         p != pending_inc.get_osd_stat_rm().end();
+         ++p) {
       ::encode(*p, dirty);
       t->erase(prefix, stringify(*p));
     }
@@ -572,6 +573,7 @@ version_t PGMonitor::get_trim_to()
   version_t version = get_last_committed();
   if (mon->is_leader() && (version > max))
     return version - max;
+
   return 0;
 }
 
@@ -584,9 +586,10 @@ bool PGMonitor::preprocess_query(MonOpRequestRef op)
   case CEPH_MSG_STATFS:
     handle_statfs(op);
     return true;
+
   case MSG_GETPOOLSTATS:
     return preprocess_getpoolstats(op);
-    
+
   case MSG_PGSTATS:
     return preprocess_pg_stats(op);
 
@@ -626,9 +629,10 @@ void PGMonitor::handle_statfs(MonOpRequestRef op)
   MonSession *session = statfs->get_session();
   if (!session)
     return;
+
   if (!session->is_capable("pg", MON_CAP_R)) {
     dout(0) << "MStatfs received from entity with insufficient privileges "
-	    << session->caps << dendl;
+            << session->caps << dendl;
     return;
   }
   MStatfsReply *reply;
@@ -664,7 +668,7 @@ bool PGMonitor::preprocess_getpoolstats(MonOpRequestRef op)
     goto out;
   if (!session->is_capable("pg", MON_CAP_R)) {
     dout(0) << "MGetPoolStats received from entity with insufficient caps "
-	    << session->caps << dendl;
+            << session->caps << dendl;
     goto out;
   }
 
@@ -672,7 +676,7 @@ bool PGMonitor::preprocess_getpoolstats(MonOpRequestRef op)
     dout(0) << "preprocess_getpoolstats on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
     goto out;
   }
-  
+
   reply = new MGetPoolStatsReply(m->fsid, m->get_tid(), get_last_committed());
 
   for (list<string>::iterator p = m->pools.begin();
@@ -688,7 +692,7 @@ bool PGMonitor::preprocess_getpoolstats(MonOpRequestRef op)
 
   mon->send_reply(op, reply);
 
- out:
+out:
   return true;
 }
 
@@ -711,7 +715,7 @@ bool PGMonitor::preprocess_pg_stats(MonOpRequestRef op)
 
   // First, just see if they need a new osdmap. But
   // only if they've had the map for a while.
-  if (stats->had_map_for > 30.0 && 
+  if (stats->had_map_for > 30.0 &&
       mon->osdmon()->is_readable() &&
       stats->epoch < mon->osdmon()->osdmap.get_epoch())
     mon->osdmon()->send_latest_now_nodelete(op, stats->epoch+1);
@@ -728,6 +732,7 @@ bool PGMonitor::pg_stats_have_changed(int from, const MPGStats *stats) const
   ceph::unordered_map<int,osd_stat_t>::const_iterator s = pg_map.osd_stat.find(from);
   if (s == pg_map.osd_stat.end())
     return true;
+
   if (s->second != stats->osd_stat)
     return true;
 
@@ -737,8 +742,9 @@ bool PGMonitor::pg_stats_have_changed(int from, const MPGStats *stats) const
     ceph::unordered_map<pg_t,pg_stat_t>::const_iterator t = pg_map.pg_stat.find(p->first);
     if (t == pg_map.pg_stat.end())
       return true;
+
     if (t->second.reported_epoch != p->second.reported_epoch ||
-	t->second.reported_seq != p->second.reported_seq)
+        t->second.reported_seq != p->second.reported_seq)
       return true;
   }
 
@@ -765,14 +771,14 @@ bool PGMonitor::prepare_pg_stats(MonOpRequestRef op)
     dout(1) << " ignoring stats from non-active osd." << dendl;
     return false;
   }
-      
+
   if (!pg_stats_have_changed(from, stats)) {
     dout(10) << " message contains no new osd|pg stats" << dendl;
     MPGStatsAck *ack = new MPGStatsAck;
     ack->set_tid(stats->get_tid());
     for (map<pg_t,pg_stat_t>::const_iterator p = stats->pg_stat.begin();
-	 p != stats->pg_stat.end();
-	 ++p) {
+         p != stats->pg_stat.end();
+         ++p) {
       ack->pg_stat[p->first] = make_pair(p->second.reported_seq, p->second.reported_epoch);
     }
     mon->send_reply(op, ack);
@@ -785,7 +791,7 @@ bool PGMonitor::prepare_pg_stats(MonOpRequestRef op)
   } else {
     pending_inc.update_stat(from, stats->epoch, osd_stat_t());
   }
-  
+
   if (pg_map.osd_stat.count(from))
     dout(10) << " got osd." << from << " " << stats->osd_stat << " (was " << pg_map.osd_stat[from] << ")" << dendl;
   else
@@ -804,33 +810,33 @@ bool PGMonitor::prepare_pg_stats(MonOpRequestRef op)
     if (pg_map.pg_stat.count(pgid) &&
         pg_map.pg_stat[pgid].get_version_pair() > p->second.get_version_pair()) {
       dout(15) << " had " << pgid << " from " << pg_map.pg_stat[pgid].reported_epoch << ":"
-	       << pg_map.pg_stat[pgid].reported_seq << dendl;
+               << pg_map.pg_stat[pgid].reported_seq << dendl;
       continue;
     }
-    if (pending_inc.pg_stat_updates.count(pgid) && 
+    if (pending_inc.pg_stat_updates.count(pgid) &&
         pending_inc.pg_stat_updates[pgid].get_version_pair() > p->second.get_version_pair()) {
       dout(15) << " had " << pgid << " from " << pending_inc.pg_stat_updates[pgid].reported_epoch << ":"
-	       << pending_inc.pg_stat_updates[pgid].reported_seq << " (pending)" << dendl;
+               << pending_inc.pg_stat_updates[pgid].reported_seq << " (pending)" << dendl;
       continue;
     }
 
     if (pg_map.pg_stat.count(pgid) == 0) {
       dout(15) << " got " << pgid << " reported at " << p->second.reported_epoch << ":"
-	       << p->second.reported_seq
-	       << " state " << pg_state_string(p->second.state)
-	       << " but DNE in pg_map; pool was probably deleted."
-	       << dendl;
+               << p->second.reported_seq
+               << " state " << pg_state_string(p->second.state)
+               << " but DNE in pg_map; pool was probably deleted."
+               << dendl;
       continue;
     }
-      
+
     dout(15) << " got " << pgid
-	     << " reported at " << p->second.reported_epoch << ":" << p->second.reported_seq
-	     << " state " << pg_state_string(pg_map.pg_stat[pgid].state)
-	     << " -> " << pg_state_string(p->second.state)
-	     << dendl;
+             << " reported at " << p->second.reported_epoch << ":" << p->second.reported_seq
+             << " state " << pg_state_string(pg_map.pg_stat[pgid].state)
+             << " -> " << pg_state_string(p->second.state)
+             << dendl;
     pending_inc.pg_stat_updates[pgid] = p->second;
   }
-  
+
   wait_for_finished_proposal(op, new C_Stats(this, op, ack_op));
   return true;
 }
@@ -847,28 +853,29 @@ void PGMonitor::_updated_stats(MonOpRequestRef op, MonOpRequestRef ack_op)
 }
 
 
-
 // ------------------------
 
 struct RetryCheckOSDMap : public Context {
   PGMonitor *pgmon;
   epoch_t epoch;
-  RetryCheckOSDMap(PGMonitor *p, epoch_t e) : pgmon(p), epoch(e) {}
+  RetryCheckOSDMap(PGMonitor *p, epoch_t e) : pgmon(p), epoch(e) {
+  }
   void finish(int r) {
     if (r == -ECANCELED)
       return;
+
     pgmon->check_osd_map(epoch);
   }
 };
 
 void PGMonitor::check_osd_map(epoch_t epoch)
 {
-  if (mon->is_peon()) 
-    return; // whatever.
+  if (mon->is_peon())
+    return;  // whatever.
 
   if (pg_map.last_osdmap_epoch >= epoch) {
     dout(10) << __func__ << " already seen " << pg_map.last_osdmap_epoch
-	     << " >= " << epoch << dendl;
+             << " >= " << epoch << dendl;
     return;
   }
 
@@ -896,31 +903,32 @@ void PGMonitor::check_osd_map(epoch_t epoch)
     assert(bl.length());
     OSDMap::Incremental inc(bl);
     for (map<int32_t,uint32_t>::iterator p = inc.new_weight.begin();
-	 p != inc.new_weight.end();
-	 ++p)
+         p != inc.new_weight.end();
+         ++p)
       if (p->second == CEPH_OSD_OUT) {
 	dout(10) << __func__ << "  osd." << p->first << " went OUT" << dendl;
 	pending_inc.stat_osd_out(p->first);
       }
 
+
     // this is conservative: we want to know if any osds (maybe) got marked down.
     for (map<int32_t,uint8_t>::iterator p = inc.new_state.begin();
-	 p != inc.new_state.end();
-	 ++p) {
+         p != inc.new_state.end();
+         ++p) {
       if (p->second & CEPH_OSD_UP) {   // true if marked up OR down,
-				       // but we're too lazy to check
-				       // which
+	                               // but we're too lazy to check
+	                               // which
 	need_check_down_pg_osds.insert(p->first);
 
 	// clear out the last_osd_report for this OSD
-        map<int, utime_t>::iterator report = last_osd_report.find(p->first);
-        if (report != last_osd_report.end()) {
-          last_osd_report.erase(report);
-        }
+	map<int, utime_t>::iterator report = last_osd_report.find(p->first);
+	if (report != last_osd_report.end()) {
+	  last_osd_report.erase(report);
+	}
 
 	// clear out osd_stat slow request histogram
 	dout(20) << __func__ << " clearing osd." << p->first
-		 << " request histogram" << dendl;
+	         << " request histogram" << dendl;
 	pending_inc.stat_osd_down_up(p->first, pg_map);
       }
 
@@ -928,7 +936,7 @@ void PGMonitor::check_osd_map(epoch_t epoch)
 	// whether it was created *or* destroyed, we can safely drop
 	// it's osd_stat_t record.
 	dout(10) << __func__ << "  osd." << p->first
-		 << " created or destroyed" << dendl;
+	         << " created or destroyed" << dendl;
 	pending_inc.rm_stat(p->first);
 
 	// and adjust full, nearfull set
@@ -952,14 +960,14 @@ void PGMonitor::check_osd_map(epoch_t epoch)
   if ((need_check_down_pgs || !need_check_down_pg_osds.empty()) &&
       check_down_pgs())
     propose = true;
-  
+
   if (propose)
     propose_pending();
 }
 
 void PGMonitor::register_pg(OSDMap *osdmap,
-			    pg_pool_t& pool, pg_t pgid, epoch_t epoch,
-			    bool new_pool)
+                            pg_pool_t& pool, pg_t pgid, epoch_t epoch,
+                            bool new_pool)
 {
   pg_t parent;
   int split_bits = 0;
@@ -975,14 +983,14 @@ void PGMonitor::register_pg(OSDMap *osdmap,
       split_bits++;
       dout(30) << " is " << pgid << " parent " << parent << " ?" << dendl;
       if (pg_map.pg_stat.count(parent) &&
-	  pg_map.pg_stat[parent].state != PG_STATE_CREATING) {
+          pg_map.pg_stat[parent].state != PG_STATE_CREATING) {
 	dout(10) << "  parent is " << parent << dendl;
 	parent_found = true;
 	break;
       }
     }
   }
- 
+
   pg_stat_t &stats = pending_inc.pg_stat_updates[pgid];
   stats.state = PG_STATE_CREATING;
   stats.created = epoch;
@@ -1010,16 +1018,16 @@ void PGMonitor::register_pg(OSDMap *osdmap,
 
   if (split_bits == 0) {
     dout(10) << __func__ << "  will create " << pgid
-	     << " primary " << stats.acting_primary
-	     << " acting " << stats.acting
-	     << dendl;
+             << " primary " << stats.acting_primary
+             << " acting " << stats.acting
+             << dendl;
   } else {
     dout(10) << __func__ << "  will create " << pgid
-	     << " primary " << stats.acting_primary
-	     << " acting " << stats.acting
-	     << " parent " << parent
-	     << " by " << split_bits << " bits"
-	     << dendl;
+             << " primary " << stats.acting_primary
+             << " acting " << stats.acting
+             << " parent " << parent
+             << " by " << split_bits << " bits"
+             << dendl;
   }
 }
 
@@ -1029,7 +1037,7 @@ bool PGMonitor::register_new_pgs()
   OSDMap *osdmap = &mon->osdmon()->osdmap;
   epoch_t epoch = osdmap->get_epoch();
   dout(10) << __func__ << " checking pg pools for osdmap epoch " << epoch
-	   << ", last_pg_scan " << pg_map.last_pg_scan << dendl;
+           << ", last_pg_scan " << pg_map.last_pg_scan << dendl;
 
   int created = 0;
   for (map<int64_t,pg_pool_t>::iterator p = osdmap->pools.begin();
@@ -1038,18 +1046,18 @@ bool PGMonitor::register_new_pgs()
     int64_t poolid = p->first;
     pg_pool_t &pool = p->second;
     int ruleno = osdmap->crush->find_rule(pool.get_crush_ruleset(),
-					  pool.get_type(), pool.get_size());
+                                          pool.get_type(), pool.get_size());
     if (ruleno < 0 || !osdmap->crush->rule_exists(ruleno))
       continue;
 
     if (pool.get_last_change() <= pg_map.last_pg_scan ||
-	pool.get_last_change() <= pending_inc.pg_scan) {
+        pool.get_last_change() <= pending_inc.pg_scan) {
       dout(10) << " no change in pool " << p->first << " " << pool << dendl;
       continue;
     }
 
     dout(10) << __func__ << " scanning pool " << p->first
-	     << " " << pool << dendl;
+             << " " << pool << dendl;
 
     // first pgs in this pool
     bool new_pool = pg_map.pg_pool_sum.count(poolid) == 0;
@@ -1071,13 +1079,13 @@ bool PGMonitor::register_new_pgs()
        ++p) {
     if (p->preferred() >= 0) {
       dout(20) << " removing creating_pg " << *p
-	       << " because it is localized and obsolete" << dendl;
+               << " because it is localized and obsolete" << dendl;
       pending_inc.pg_remove.insert(*p);
       removed++;
     }
     if (!osdmap->have_pg_pool(p->pool())) {
       dout(20) << " removing creating_pg " << *p
-	       << " because containing pool deleted" << dendl;
+               << " because containing pool deleted" << dendl;
       pending_inc.pg_remove.insert(*p);
       ++removed;
     }
@@ -1085,11 +1093,11 @@ bool PGMonitor::register_new_pgs()
 
   // deleted pools?
   for (ceph::unordered_map<pg_t,pg_stat_t>::const_iterator p =
-	 pg_map.pg_stat.begin();
+         pg_map.pg_stat.begin();
        p != pg_map.pg_stat.end(); ++p) {
     if (!osdmap->have_pg_pool(p->first.pool())) {
       dout(20) << " removing pg_stat " << p->first << " because "
-	       << "containing pool deleted" << dendl;
+               << "containing pool deleted" << dendl;
       pending_inc.pg_remove.insert(p->first);
       ++removed;
     }
@@ -1104,7 +1112,7 @@ bool PGMonitor::register_new_pgs()
   pending_inc.pg_scan = epoch;
 
   dout(10) << "register_new_pgs registered " << created << " new pgs, removed "
-	   << removed << " uncreated pgs" << dendl;
+           << removed << " uncreated pgs" << dendl;
   return (created || removed);
 }
 
@@ -1113,8 +1121,8 @@ bool PGMonitor::map_pg_creates()
   OSDMap *osdmap = &mon->osdmon()->osdmap;
 
   dout(10) << __func__ << " to " << pg_map.creating_pgs.size()
-	   << " pgs, osdmap epoch " << osdmap->get_epoch()
-	   << dendl;
+           << " pgs, osdmap epoch " << osdmap->get_epoch()
+           << dendl;
 
   unsigned changed = 0;
   for (set<pg_t>::const_iterator p = pg_map.creating_pgs.begin();
@@ -1140,16 +1148,16 @@ bool PGMonitor::map_pg_creates()
       &acting_primary);
 
     if (up != s->up ||
-	up_primary != s->up_primary ||
-	acting !=  s->acting ||
-	acting_primary != s->acting_primary) {
+        up_primary != s->up_primary ||
+        acting !=  s->acting ||
+        acting_primary != s->acting_primary) {
       dout(20) << __func__ << "  " << pgid << " "
-	       << " acting_primary: " << s->acting_primary
-	       << " -> " << acting_primary
-	       << " acting: " << s->acting << " -> " << acting
-	       << " up_primary: " << s->up_primary << " -> " << up_primary
-	       << " up: " << s->up << " -> " << up
-	       << dendl;
+               << " acting_primary: " << s->acting_primary
+               << " -> " << acting_primary
+               << " acting: " << s->acting << " -> " << acting
+               << " up_primary: " << s->up_primary << " -> " << up_primary
+               << " up: " << s->up << " -> " << up
+               << dendl;
 
       pg_stat_t *ns = &pending_inc.pg_stat_updates[pgid];
       *ns = *s;
@@ -1182,26 +1190,27 @@ void PGMonitor::send_pg_creates()
   OSDMap& osdmap = mon->osdmon()->osdmap;
   if (osdmap.get_num_up_osds() == 0)
     return;
+
   if (osdmap.get_up_osd_features() & CEPH_FEATURE_MON_STATEFUL_SUB) {
     check_subs();
     return;
   }
 
   dout(10) << "send_pg_creates to " << pg_map.creating_pgs.size()
-	   << " pgs" << dendl;
+           << " pgs" << dendl;
 
   utime_t now = ceph_clock_now(g_ceph_context);
-  for (map<int, map<epoch_t, set<pg_t>> >::iterator p =
-	 pg_map.creating_pgs_by_osd_epoch.begin();
+  for (map<int, map<epoch_t, set<pg_t> > >::iterator p =
+         pg_map.creating_pgs_by_osd_epoch.begin();
        p != pg_map.creating_pgs_by_osd_epoch.end();
        ++p) {
     int osd = p->first;
 
     // throttle?
     if (last_sent_pg_create.count(osd) &&
-	now - g_conf->mon_pg_create_interval < last_sent_pg_create[osd]) 
+        now - g_conf->mon_pg_create_interval < last_sent_pg_create[osd])
       continue;
-      
+
     if (osdmap.is_up(osd))
       send_pg_creates(osd, NULL, 0);
   }
@@ -1214,6 +1223,7 @@ epoch_t PGMonitor::send_pg_creates(int osd, Connection *con, epoch_t next)
     pg_map.creating_pgs_by_osd_epoch.find(osd);
   if (p == pg_map.creating_pgs_by_osd_epoch.end())
     return next;
+
   assert(p->second.size() > 0);
 
   MOSDPGCreate *m = NULL;
@@ -1222,15 +1232,15 @@ epoch_t PGMonitor::send_pg_creates(int osd, Connection *con, epoch_t next)
        q != p->second.end();
        ++q) {
     dout(20) << __func__ << " osd." << osd << " from " << next
-	     << " : epoch " << q->first << " " << q->second.size() << " pgs"
-	     << dendl;
+             << " : epoch " << q->first << " " << q->second.size() << " pgs"
+             << dendl;
     last = q->first;
     for (set<pg_t>::iterator r = q->second.begin(); r != q->second.end(); ++r) {
       if (!m)
 	m = new MOSDPGCreate(pg_map.last_osdmap_epoch);
       m->mkpg[*r] = pg_create_t(pg_map.pg_stat[*r].created,
-				pg_map.pg_stat[*r].parent,
-				pg_map.pg_stat[*r].parent_split_bits);
+                                pg_map.pg_stat[*r].parent,
+                                pg_map.pg_stat[*r].parent_split_bits);
       // Need the create time from the monitor using its clock to set
       // last_scrub_stamp upon pg creation.
       m->ctimes[*r] = pg_map.pg_stat[*r].last_scrub_stamp;
@@ -1238,7 +1248,7 @@ epoch_t PGMonitor::send_pg_creates(int osd, Connection *con, epoch_t next)
   }
   if (!m) {
     dout(20) << "send_pg_creates osd." << osd << " from " << next
-	     << " has nothing to send" << dendl;
+             << " has nothing to send" << dendl;
     return next;
   }
 
@@ -1265,8 +1275,10 @@ void PGMonitor::_mark_pg_stale(pg_t pgid, const pg_stat_t& cur_stat)
   } else {
     stat = &q->second;
   }
-  stat->state |= PG_STATE_STALE;
-  stat->last_unstale = ceph_clock_now(g_ceph_context);
+  if (stat->acting_primary == cur_stat.acting_primary) {
+    stat->state |= PG_STATE_STALE;  
+    stat->last_unstale = ceph_clock_now(g_ceph_context);
+  }
 }
 
 bool PGMonitor::check_down_pgs()
@@ -1285,8 +1297,8 @@ bool PGMonitor::check_down_pgs()
   if (need_check_down_pgs) {
     for (auto p : pg_map.pg_stat) {
       if ((p.second.state & PG_STATE_STALE) == 0 &&
-	  p.second.acting_primary != -1 &&
-	  osdmap->is_down(p.second.acting_primary)) {
+          p.second.acting_primary != -1 &&
+          osdmap->is_down(p.second.acting_primary)) {
 	_mark_pg_stale(p.first, p.second);
 	ret = true;
       }
@@ -1322,9 +1334,13 @@ inline string percentify(const float& a) {
 
 //void PGMonitor::dump_object_stat_sum(stringstream& ss, Formatter *f,
 void PGMonitor::dump_object_stat_sum(TextTable &tbl, Formatter *f,
-				     object_stat_sum_t &sum, uint64_t avail,
-				     bool verbose) const
+                                     object_stat_sum_t &sum, uint64_t avail,
+                                     float raw_used_rate, bool verbose) const
 {
+  float curr_object_copies_rate = 0.0;
+  if (sum.num_object_copies > 0)
+    curr_object_copies_rate = (float)(sum.num_object_copies - sum.num_objects_degraded) / sum.num_object_copies;
+
   if (f) {
     f->dump_int("kb_used", SHIFT_ROUND_UP(sum.num_bytes, 10));
     f->dump_int("bytes_used", sum.num_bytes);
@@ -1336,6 +1352,7 @@ void PGMonitor::dump_object_stat_sum(TextTable &tbl, Formatter *f,
       f->dump_int("rd_bytes", sum.num_rd_kb * 1024ull);
       f->dump_int("wr", sum.num_wr);
       f->dump_int("wr_bytes", sum.num_wr_kb * 1024ull);
+      f->dump_int("raw_bytes_used", sum.num_bytes * raw_used_rate * curr_object_copies_rate);
     }
   } else {
     tbl << stringify(si_t(sum.num_bytes));
@@ -1348,8 +1365,9 @@ void PGMonitor::dump_object_stat_sum(TextTable &tbl, Formatter *f,
     tbl << sum.num_objects;
     if (verbose) {
       tbl << stringify(si_t(sum.num_objects_dirty))
-	  << stringify(si_t(sum.num_rd))
-          << stringify(si_t(sum.num_wr));
+          << stringify(si_t(sum.num_rd))
+          << stringify(si_t(sum.num_wr))
+          << stringify(si_t(sum.num_bytes * raw_used_rate * curr_object_copies_rate));
     }
   }
 }
@@ -1360,24 +1378,26 @@ int64_t PGMonitor::get_rule_avail(OSDMap& osdmap, int ruleno) const
   int r = osdmap.crush->get_rule_weight_osd_map(ruleno, &wm);
   if (r < 0)
     return r;
+
   if(wm.empty())
     return 0;
+
   int64_t min = -1;
   for (map<int,float>::iterator p = wm.begin(); p != wm.end(); ++p) {
     ceph::unordered_map<int32_t,osd_stat_t>::const_iterator osd_info = pg_map.osd_stat.find(p->first);
     if (osd_info != pg_map.osd_stat.end()) {
       if (osd_info->second.kb == 0 || p->second == 0) {
-        // osd must be out, hence its stats have been zeroed
-        // (unless we somehow managed to have a disk with size 0...)
-        //
-        // (p->second == 0), if osd weight is 0, no need to
-        // calculate proj below.
-        continue;
+	// osd must be out, hence its stats have been zeroed
+	// (unless we somehow managed to have a disk with size 0...)
+	//
+	// (p->second == 0), if osd weight is 0, no need to
+	// calculate proj below.
+	continue;
       }
       int64_t proj = (float)((osd_info->second).kb_avail * 1024ull) /
-        (double)p->second;
+                     (double)p->second;
       if (min < 0 || proj < min)
-        min = proj;
+	min = proj;
     } else {
       dout(0) << "Cannot get stat of OSD " << p->first << dendl;
     }
@@ -1404,6 +1424,7 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
       tbl.define_column("DIRTY", TextTable::LEFT, TextTable::RIGHT);
       tbl.define_column("READ", TextTable::LEFT, TextTable::RIGHT);
       tbl.define_column("WRITE", TextTable::LEFT, TextTable::RIGHT);
+      tbl.define_column("RAW USED", TextTable::LEFT, TextTable::RIGHT);
     }
   }
 
@@ -1419,13 +1440,14 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
 
     const pg_pool_t *pool = osdmap.get_pg_pool(pool_id);
     int ruleno = osdmap.crush->find_rule(pool->get_crush_ruleset(),
-					 pool->get_type(),
-					 pool->get_size());
+                                         pool->get_type(),
+                                         pool->get_size());
     int64_t avail;
+    float raw_used_rate;
     if (avail_by_rule.count(ruleno) == 0) {
       avail = get_rule_avail(osdmap, ruleno);
       if (avail < 0)
-        avail = 0;
+	avail = 0;
       avail_by_rule[ruleno] = avail;
     } else {
       avail = avail_by_rule[ruleno];
@@ -1433,20 +1455,24 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
     switch (pool->get_type()) {
     case pg_pool_t::TYPE_REPLICATED:
       avail /= pool->get_size();
+      raw_used_rate = pool->get_size();
       break;
     case pg_pool_t::TYPE_ERASURE:
-      {
-	const map<string,string>& ecp =
-	  osdmap.get_erasure_code_profile(pool->erasure_code_profile);
-	map<string,string>::const_iterator pm = ecp.find("m");
-	map<string,string>::const_iterator pk = ecp.find("k");
-	if (pm != ecp.end() && pk != ecp.end()) {
-	  int k = atoi(pk->second.c_str());
-	  int m = atoi(pm->second.c_str());
-	  avail = avail * k / (m + k);
-	}
+    {
+      const map<string,string>& ecp =
+        osdmap.get_erasure_code_profile(pool->erasure_code_profile);
+      map<string,string>::const_iterator pm = ecp.find("m");
+      map<string,string>::const_iterator pk = ecp.find("k");
+      if (pm != ecp.end() && pk != ecp.end()) {
+	int k = atoi(pk->second.c_str());
+	int m = atoi(pm->second.c_str());
+	avail = avail * k / (m + k);
+	raw_used_rate = (float)(m + k) / k;
+      } else {
+	raw_used_rate = 0.0;
       }
-      break;
+    }
+    break;
     default:
       assert(0 == "unrecognized pool type");
     }
@@ -1460,16 +1486,16 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose)
       tbl << pool_name
           << pool_id;
       if (verbose)
-        tbl << "-";
+	tbl << "-";
     }
-    dump_object_stat_sum(tbl, f, stat.stats.sum, avail, verbose);
+    dump_object_stat_sum(tbl, f, stat.stats.sum, avail, raw_used_rate, verbose);
     if (f)
-      f->close_section(); // stats
+      f->close_section();  // stats
     else
       tbl << TextTable::endrow;
 
     if (f)
-      f->close_section(); // pool
+      f->close_section();  // pool
   }
   if (f)
     f->close_section();
@@ -1589,7 +1615,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
     }
     cmd_putval(g_ceph_context, cmdmap, "pool", pool);
   }
-   
+
 
   string format;
   cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain"));
@@ -1615,7 +1641,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
     set<string> what;
     if (cmd_getval(g_ceph_context, cmdmap, "dumpcontents", dumpcontents)) {
       copy(dumpcontents.begin(), dumpcontents.end(),
-	   inserter(what, what.end()));
+           inserter(what, what.end()));
     }
     if (what.empty())
       what.insert("all");
@@ -1693,7 +1719,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
       r = -ENOENT;
       ss << "pool " << pool << " does not exist";
       goto reply;
-    } 
+    }
     if (osd >= 0 && !mon->osdmon()->osdmap.is_up(osd)) {
       ss << "osd " << osd << " is not up";
       r = -EAGAIN;
@@ -1707,10 +1733,10 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
       pg_map.get_filtered_pg_stats(state,pool,osd,primary,pgs);
       states.pop_back();
     }
-    if (f && !pgs.empty()){
+    if (f && !pgs.empty()) {
       pg_map.dump_filtered_pg_stats(f.get(),pgs);
       f->flush(ds);
-    } else if (!pgs.empty()){
+    } else if (!pgs.empty()) {
       pg_map.dump_filtered_pg_stats(ds,pgs);
     }
     r = 0;
@@ -1721,7 +1747,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
       stuckop_vec.push_back("unclean");
     int64_t threshold;
     cmd_getval(g_ceph_context, cmdmap, "threshold", threshold,
-	       int64_t(g_conf->mon_pg_stuck_threshold));
+               int64_t(g_conf->mon_pg_stuck_threshold));
 
     r = dump_stuck_pg_stats(ds, f.get(), (int)threshold, stuckop_vec);
     ss << "ok";
@@ -1763,13 +1789,13 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
       f->flush(ds);
     } else {
       ds << "osdmap e" << mon->osdmon()->osdmap.get_epoch()
-	 << " pg " << pgid << " (" << mpgid << ")"
-	 << " -> up " << up << " acting " << acting;
+         << " pg " << pgid << " (" << mpgid << ")"
+         << " -> up " << up << " acting " << acting;
     }
     r = 0;
-  } else if (prefix == "pg scrub" || 
-	     prefix == "pg repair" || 
-	     prefix == "pg deep-scrub") {
+  } else if (prefix == "pg scrub" ||
+             prefix == "pg repair" ||
+             prefix == "pg deep-scrub") {
     string scrubop = prefix.substr(3, string::npos);
     pg_t pgid;
     string pgidstr;
@@ -1798,9 +1824,9 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
     vector<pg_t> pgs(1);
     pgs[0] = pgid;
     mon->try_send_message(new MOSDScrub(mon->monmap->fsid, pgs,
-					scrubop == "repair",
-					scrubop == "deep-scrub"),
-			  mon->osdmon()->osdmap.get_inst(osd));
+                                        scrubop == "repair",
+                                        scrubop == "deep-scrub"),
+                          mon->osdmon()->osdmap.get_inst(osd));
     ss << "instructing pg " << pgid << " on osd." << osd << " to " << scrubop;
     r = 0;
   } else if (prefix == "pg debug") {
@@ -1810,7 +1836,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
       bool unfound_objects_exist = false;
       ceph::unordered_map<pg_t,pg_stat_t>::const_iterator end = pg_map.pg_stat.end();
       for (ceph::unordered_map<pg_t,pg_stat_t>::const_iterator s = pg_map.pg_stat.begin();
-	   s != end; ++s) {
+           s != end; ++s) {
 	if (s->second.stats.sum.num_objects_unfound > 0) {
 	  unfound_objects_exist = true;
 	  break;
@@ -1825,7 +1851,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
       bool degraded_pgs_exist = false;
       ceph::unordered_map<pg_t,pg_stat_t>::const_iterator end = pg_map.pg_stat.end();
       for (ceph::unordered_map<pg_t,pg_stat_t>::const_iterator s = pg_map.pg_stat.begin();
-	   s != end; ++s) {
+           s != end; ++s) {
 	if (s->second.stats.sum.num_objects_degraded > 0) {
 	  degraded_pgs_exist = true;
 	  break;
@@ -1842,7 +1868,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
   if (r == -1)
     return false;
 
- reply:
+reply:
   string rs;
   getline(ss, rs);
   rdata.append(ds);
@@ -1904,7 +1930,7 @@ bool PGMonitor::prepare_command(MonOpRequestRef op)
     ss << "pg " << pgidstr << " now creating, ok";
     goto update;
   } else if (prefix == "pg set_full_ratio" ||
-	     prefix == "pg set_nearfull_ratio") {
+             prefix == "pg set_nearfull_ratio") {
     double n;
     if (!cmd_getval(g_ceph_context, cmdmap, "ratio", n)) {
       ss << "unable to parse 'ratio' value '"
@@ -1923,24 +1949,24 @@ bool PGMonitor::prepare_command(MonOpRequestRef op)
     goto reply;
   }
 
- reply:
+reply:
   getline(ss, rs);
   if (r < 0 && rs.length() == 0)
     rs = cpp_strerror(r);
   mon->reply_command(op, r, rs, get_last_committed());
   return false;
 
- update:
+update:
   getline(ss, rs);
   wait_for_finished_proposal(op, new Monitor::C_Command(
-        mon, op, r, rs, get_last_committed() + 1));
+                               mon, op, r, rs, get_last_committed() + 1));
   return true;
 }
 
 // Only called with a single bit set in "what"
 static void note_stuck_detail(int what,
-			      ceph::unordered_map<pg_t,pg_stat_t>& stuck_pgs,
-			      list<pair<health_status_t,string> > *detail)
+                              ceph::unordered_map<pg_t,pg_stat_t>& stuck_pgs,
+                              list<pair<health_status_t,string> > *detail)
 {
   for (ceph::unordered_map<pg_t,pg_stat_t>::iterator p = stuck_pgs.begin();
        p != stuck_pgs.end();
@@ -1975,7 +2001,7 @@ static void note_stuck_detail(int what,
     ss << "pg " << p->first << " is stuck " << whatname;
     if (since == utime_t()) {
       ss << " since forever";
-    }else {
+    } else {
       utime_t dur = ceph_clock_now(g_ceph_context) - since;
       ss << " for " << dur;
     }
@@ -1986,8 +2012,8 @@ static void note_stuck_detail(int what,
 }
 
 int PGMonitor::_warn_slow_request_histogram(const pow2_hist_t& h, string suffix,
-					    list<pair<health_status_t,string> >& summary,
-					    list<pair<health_status_t,string> > *detail) const
+                                            list<pair<health_status_t,string> >& summary,
+                                            list<pair<health_status_t,string> > *detail) const
 {
   unsigned sum = 0;
   for (unsigned i = h.h.size() - 1; i > 0; --i) {
@@ -2006,7 +2032,7 @@ int PGMonitor::_warn_slow_request_histogram(const pow2_hist_t& h, string suffix,
 }
 
 void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
-			   list<pair<health_status_t,string> > *detail) const
+                           list<pair<health_status_t,string> > *detail) const
 {
   map<string,int> note;
   ceph::unordered_map<int,int>::const_iterator p = pg_map.num_pg_by_state.begin();
@@ -2093,22 +2119,22 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
     }
     if (detail) {
       for (ceph::unordered_map<pg_t,pg_stat_t>::const_iterator p = pg_map.pg_stat.begin();
-	   p != pg_map.pg_stat.end();
-	   ++p) {
+           p != pg_map.pg_stat.end();
+           ++p) {
 	if ((p->second.state & (PG_STATE_STALE |
-			       PG_STATE_DOWN |
-			       PG_STATE_UNDERSIZED |
-			       PG_STATE_DEGRADED |
-			       PG_STATE_INCONSISTENT |
-			       PG_STATE_PEERING |
-			       PG_STATE_REPAIR |
-			       PG_STATE_SPLITTING |
-			       PG_STATE_RECOVERING |
-			       PG_STATE_RECOVERY_WAIT |
-			       PG_STATE_INCOMPLETE |
-			       PG_STATE_BACKFILL_WAIT |
-			       PG_STATE_BACKFILL |
-			       PG_STATE_BACKFILL_TOOFULL)) &&
+	                        PG_STATE_DOWN |
+	                        PG_STATE_UNDERSIZED |
+	                        PG_STATE_DEGRADED |
+	                        PG_STATE_INCONSISTENT |
+	                        PG_STATE_PEERING |
+	                        PG_STATE_REPAIR |
+	                        PG_STATE_SPLITTING |
+	                        PG_STATE_RECOVERING |
+	                        PG_STATE_RECOVERY_WAIT |
+	                        PG_STATE_INCOMPLETE |
+	                        PG_STATE_BACKFILL_WAIT |
+	                        PG_STATE_BACKFILL |
+	                        PG_STATE_BACKFILL_TOOFULL)) &&
 	    stuck_pgs.count(p->first) == 0) {
 	  ostringstream ss;
 	  ss << "pg " << p->first << " is " << pg_state_string(p->second.state);
@@ -2119,7 +2145,7 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
 	    const pg_pool_t *pi = mon->osdmon()->osdmap.get_pg_pool(p->first.pool());
 	    if (pi && pi->min_size > 1) {
 	      ss << " (reducing pool " << mon->osdmon()->osdmap.get_pool_name(p->first.pool())
-		 << " min_size from " << (int)pi->min_size << " may help; search ceph.com/docs for 'incomplete')";
+	         << " min_size from " << (int)pi->min_size << " may help; search ceph.com/docs for 'incomplete')";
 	    }
 	  }
 	  detail->push_back(make_pair(HEALTH_WARN, ss.str()));
@@ -2138,14 +2164,14 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
       summary.push_back(make_pair(HEALTH_WARN, ss.str()));
 
       if (detail) {
-        unsigned num_slow_osds = 0;
+	unsigned num_slow_osds = 0;
 	// do per-osd warnings
 	for (ceph::unordered_map<int32_t,osd_stat_t>::const_iterator p = pg_map.osd_stat.begin();
 	     p != pg_map.osd_stat.end();
 	     ++p) {
 	  if (_warn_slow_request_histogram(p->second.op_queue_age_hist,
-					   string(" on osd.") + stringify(p->first),
-					   summary, detail))
+	                                   string(" on osd.") + stringify(p->first),
+	                                   summary, detail))
 	    ++num_slow_osds;
 	}
 	ostringstream ss2;
@@ -2164,7 +2190,7 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
     if (detail)
       detail->push_back(make_pair(HEALTH_WARN, "recovery " + *p));
   }
-  
+
   // full/nearfull
   check_full_osd_health(summary, detail, pg_map.full_osds, "full", HEALTH_ERR);
   check_full_osd_health(summary, detail, pg_map.nearfull_osds, "near full", HEALTH_WARN);
@@ -2174,16 +2200,16 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
   for (map<int64_t,pg_pool_t>::const_iterator p = pools.begin();
        p != pools.end(); ++p) {
     if ((!p->second.target_max_objects && !p->second.target_max_bytes) ||
-	!pg_map.pg_pool_sum.count(p->first))
+        !pg_map.pg_pool_sum.count(p->first))
       continue;
     bool nearfull = false;
     const string& name = mon->osdmon()->osdmap.get_pool_name(p->first);
     const pool_stat_t& st = pg_map.get_pg_pool_sum_stat(p->first);
     uint64_t ratio = p->second.cache_target_full_ratio_micro +
-      ((1000000 - p->second.cache_target_full_ratio_micro) *
-       g_conf->mon_cache_target_full_warn_ratio);
+                     ((1000000 - p->second.cache_target_full_ratio_micro) *
+                      g_conf->mon_cache_target_full_warn_ratio);
     if (p->second.target_max_objects && (uint64_t)(st.stats.sum.num_objects - st.stats.sum.num_objects_hit_set_archive) >
-	p->second.target_max_objects * (ratio / 1000000.0)) {
+        p->second.target_max_objects * (ratio / 1000000.0)) {
       nearfull = true;
       if (detail) {
 	ostringstream ss;
@@ -2195,7 +2221,7 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
       }
     }
     if (p->second.target_max_bytes && (uint64_t)(st.stats.sum.num_bytes - st.stats.sum.num_bytes_hit_set_archive) >
-	p->second.target_max_bytes * (ratio / 1000000.0)) {
+        p->second.target_max_bytes * (ratio / 1000000.0)) {
       nearfull = true;
       if (detail) {
 	ostringstream ss;
@@ -2248,8 +2274,8 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
   }
   if (!pg_map.pg_stat.empty()) {
     for (ceph::unordered_map<int,pool_stat_t>::const_iterator p = pg_map.pg_pool_sum.begin();
-	 p != pg_map.pg_pool_sum.end();
-	 ++p) {
+         p != pg_map.pg_pool_sum.end();
+         ++p) {
       const pg_pool_t *pi = mon->osdmon()->osdmap.get_pg_pool(p->first);
       if (!pi)
 	continue;   // in case osdmap changes haven't propagated to PGMap yet
@@ -2264,8 +2290,8 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
       }
       int average_objects_per_pg = pg_map.pg_sum.stats.sum.num_objects / pg_map.pg_stat.size();
       if (average_objects_per_pg > 0 &&
-	  pg_map.pg_sum.stats.sum.num_objects >= g_conf->mon_pg_warn_min_objects &&
-	  p->second.stats.sum.num_objects >= g_conf->mon_pg_warn_min_pool_objects) {
+          pg_map.pg_sum.stats.sum.num_objects >= g_conf->mon_pg_warn_min_objects &&
+          p->second.stats.sum.num_objects >= g_conf->mon_pg_warn_min_pool_objects) {
 	int objects_per_pg = p->second.stats.sum.num_objects / pi->get_pg_num();
 	float ratio = (float)objects_per_pg / (float)average_objects_per_pg;
 	if (g_conf->mon_pg_warn_max_object_skew > 0 &&
@@ -2287,9 +2313,9 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
 }
 
 void PGMonitor::check_full_osd_health(list<pair<health_status_t,string> >& summary,
-				      list<pair<health_status_t,string> > *detail,
-				      const set<int>& s, const char *desc,
-				      health_status_t sev) const
+                                      list<pair<health_status_t,string> > *detail,
+                                      const set<int>& s, const char *desc,
+                                      health_status_t sev) const
 {
   if (!s.empty()) {
     ostringstream ss;
@@ -2308,13 +2334,13 @@ void PGMonitor::check_full_osd_health(list<pair<health_status_t,string> >& summa
 }
 
 int PGMonitor::dump_stuck_pg_stats(stringstream &ds,
-				   Formatter *f,
-				   int threshold,
-				   vector<string>& args) const
+                                   Formatter *f,
+                                   int threshold,
+                                   vector<string>& args) const
 {
   int stuck_types = 0;
 
-  for (vector<string>::iterator i = args.begin() ; i != args.end(); ++i) {
+  for (vector<string>::iterator i = args.begin(); i != args.end(); ++i) {
     if (*i == "inactive")
       stuck_types |= PGMap::STUCK_INACTIVE;
     else if (*i == "unclean")
@@ -2350,6 +2376,7 @@ void PGMonitor::check_subs()
   string type = "osd_pg_creates";
   if (mon->session_map.subs.count(type) == 0)
     return;
+
   xlist<Subscription*>::iterator p = mon->session_map.subs[type]->begin();
   while (!p.end()) {
     Subscription *sub = *p;
@@ -2365,10 +2392,10 @@ void PGMonitor::check_sub(Subscription *sub)
     // only send these if the OSD is up.  we will check_subs() when they do
     // come up so they will get the creates then.
     if (sub->session->inst.name.is_osd() &&
-	mon->osdmon()->osdmap.is_up(sub->session->inst.name.num())) {
+        mon->osdmon()->osdmap.is_up(sub->session->inst.name.num())) {
       sub->next = send_pg_creates(sub->session->inst.name.num(),
-				  sub->session->con.get(),
-				  sub->next);
+                                  sub->session->con.get(),
+                                  sub->next);
     }
   }
 }
diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h
index 29b2e03..e2d2095 100644
--- a/src/mon/PGMonitor.h
+++ b/src/mon/PGMonitor.h
@@ -154,8 +154,9 @@ private:
 			  vector<string>& args) const;
 
   void dump_object_stat_sum(TextTable &tbl, Formatter *f,
-                            object_stat_sum_t &sum,
+			    object_stat_sum_t &sum,
 			    uint64_t avail,
+			    float raw_used_rate,
 			    bool verbose) const;
 
   int64_t get_rule_avail(OSDMap& osdmap, int ruleno) const;
diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc
index e0c8039..dfab30a 100644
--- a/src/mon/Paxos.cc
+++ b/src/mon/Paxos.cc
@@ -207,7 +207,7 @@ void Paxos::handle_collect(MonOpRequestRef op)
   state = STATE_RECOVERING;
 
   if (collect->first_committed > last_committed+1) {
-    dout(5) << __func__
+    dout(2) << __func__
             << " leader's lowest version is too high for our last committed"
             << " (theirs: " << collect->first_committed
             << "; ours: " << last_committed << ") -- bootstrap!" << dendl;
diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h
index 9b9a732..4f57027 100644
--- a/src/mon/Paxos.h
+++ b/src/mon/Paxos.h
@@ -282,7 +282,7 @@ public:
    *
    * @return 'true' if we are on the Recovering state; 'false' otherwise.
    */
-  bool is_recovering() const { return (state & STATE_RECOVERING); }
+  bool is_recovering() const { return (state == STATE_RECOVERING); }
   /**
    * Check if we are active.
    *
diff --git a/src/msg/Dispatcher.h b/src/msg/Dispatcher.h
index a0a3b37..d6868ed 100644
--- a/src/msg/Dispatcher.h
+++ b/src/msg/Dispatcher.h
@@ -16,11 +16,15 @@
 #ifndef CEPH_DISPATCHER_H
 #define CEPH_DISPATCHER_H
 
-#include "Message.h"
-#include "common/config.h"
-#include "auth/Auth.h"
+#include "include/buffer_fwd.h"
+#include "include/assert.h"
 
 class Messenger;
+class Message;
+class Connection;
+class AuthAuthorizer;
+class CryptoKey;
+class CephContext;
 
 class Dispatcher {
 public:
@@ -183,9 +187,13 @@ public:
    * @return True if we were able to prove or disprove correctness of
    * authorizer, false otherwise.
    */
-  virtual bool ms_verify_authorizer(Connection *con, int peer_type,
-				    int protocol, bufferlist& authorizer, bufferlist& authorizer_reply,
-				    bool& isvalid, CryptoKey& session_key) { return false; }
+  virtual bool ms_verify_authorizer(Connection *con,
+				    int peer_type,
+				    int protocol,
+				    ceph::bufferlist& authorizer,
+				    ceph::bufferlist& authorizer_reply,
+				    bool& isvalid,
+				    CryptoKey& session_key) { return false; }
   /**
    * @} //Authentication
    */
diff --git a/src/msg/Message.h b/src/msg/Message.h
index a53f282..9eddce1 100644
--- a/src/msg/Message.h
+++ b/src/msg/Message.h
@@ -300,7 +300,7 @@ protected:
       completion_hook->complete(0);
   }
 public:
-  inline const ConnectionRef& get_connection() const { return connection; }
+  const ConnectionRef& get_connection() const { return connection; }
   void set_connection(const ConnectionRef& c) {
     connection = c;
   }
diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc
index 83c36de..e9a80d7 100644
--- a/src/msg/async/AsyncConnection.cc
+++ b/src/msg/async/AsyncConnection.cc
@@ -147,6 +147,7 @@ class C_clean_handler : public EventCallback {
   C_clean_handler(AsyncConnectionRef c): conn(c) {}
   void do_request(int id) {
     conn->cleanup_handler();
+    delete this;
   }
 };
 
@@ -183,13 +184,13 @@ AsyncConnection::AsyncConnection(CephContext *cct, AsyncMessenger *m, EventCente
     recv_start(0), recv_end(0), got_bad_auth(false), authorizer(NULL), replacing(false),
     is_reset_from_peer(false), once_ready(false), state_buffer(NULL), state_offset(0), net(cct), center(c)
 {
-  read_handler.reset(new C_handle_read(this));
-  write_handler.reset(new C_handle_write(this));
-  reset_handler.reset(new C_handle_reset(async_msgr, this));
-  remote_reset_handler.reset(new C_handle_remote_reset(async_msgr, this));
-  connect_handler.reset(new C_deliver_connect(async_msgr, this));
-  local_deliver_handler.reset(new C_local_deliver(this));
-  wakeup_handler.reset(new C_time_wakeup(this));
+  read_handler = new C_handle_read(this);
+  write_handler = new C_handle_write(this);
+  reset_handler = new C_handle_reset(async_msgr, this);
+  remote_reset_handler = new C_handle_remote_reset(async_msgr, this);
+  connect_handler = new C_deliver_connect(async_msgr, this);
+  local_deliver_handler = new C_local_deliver(this);
+  wakeup_handler = new C_time_wakeup(this);
   memset(msgvec, 0, sizeof(msgvec));
   // double recv_max_prefetch see "read_until"
   recv_buf = new char[2*recv_max_prefetch];
@@ -210,9 +211,9 @@ AsyncConnection::~AsyncConnection()
 
 /* return -1 means `fd` occurs error or closed, it should be closed
  * return 0 means EAGAIN or EINTR */
-int AsyncConnection::read_bulk(int fd, char *buf, int len)
+ssize_t AsyncConnection::read_bulk(int fd, char *buf, unsigned len)
 {
-  int nread = ::read(fd, buf, len);
+  ssize_t nread = ::read(fd, buf, len);
   if (nread == -1) {
     if (errno == EAGAIN || errno == EINTR) {
       nread = 0;
@@ -294,12 +295,12 @@ void AsyncConnection::restore_sigpipe()
 
 // return the length of msg needed to be sent,
 // < 0 means error occured
-int AsyncConnection::do_sendmsg(struct msghdr &msg, int len, bool more)
+ssize_t AsyncConnection::do_sendmsg(struct msghdr &msg, unsigned len, bool more)
 {
   suppress_sigpipe();
 
   while (len > 0) {
-    int r;
+    ssize_t r;
 #if defined(MSG_NOSIGNAL)
     r = ::sendmsg(sd, &msg, MSG_NOSIGNAL);
 #else
@@ -338,12 +339,12 @@ int AsyncConnection::do_sendmsg(struct msghdr &msg, int len, bool more)
     }
     restore_sigpipe();
   }
-  return len;
+  return (ssize_t)len;
 }
 
 // return the remaining bytes, it may larger than the length of ptr
 // else return < 0 means error
-int AsyncConnection::_try_send(bufferlist &send_bl, bool send)
+ssize_t AsyncConnection::_try_send(bufferlist &send_bl, bool send)
 {
   ldout(async_msgr->cct, 20) << __func__ << " send bl length is " << send_bl.length() << dendl;
   if (send_bl.length()) {
@@ -373,7 +374,7 @@ int AsyncConnection::_try_send(bufferlist &send_bl, bool send)
     memset(&msg, 0, sizeof(msg));
     msg.msg_iovlen = 0;
     msg.msg_iov = msgvec;
-    int msglen = 0;
+    unsigned msglen = 0;
     while (size > 0) {
       msgvec[msg.msg_iovlen].iov_base = (void*)(pb->c_str());
       msgvec[msg.msg_iovlen].iov_len = pb->length();
@@ -383,7 +384,7 @@ int AsyncConnection::_try_send(bufferlist &send_bl, bool send)
       size--;
     }
 
-    int r = do_sendmsg(msg, msglen, false);
+    ssize_t r = do_sendmsg(msg, msglen, false);
     if (r < 0)
       return r;
 
@@ -431,7 +432,7 @@ int AsyncConnection::_try_send(bufferlist &send_bl, bool send)
 //
 // return the remaining bytes, 0 means this buffer is finished
 // else return < 0 means error
-int AsyncConnection::read_until(uint64_t len, char *p)
+ssize_t AsyncConnection::read_until(unsigned len, char *p)
 {
   ldout(async_msgr->cct, 25) << __func__ << " len is " << len << " state_offset is "
                              << state_offset << dendl;
@@ -443,7 +444,7 @@ int AsyncConnection::read_until(uint64_t len, char *p)
     }
   }
 
-  int r = 0;
+  ssize_t r = 0;
   uint64_t left = len - state_offset;
   if (recv_end > recv_start) {
     uint64_t to_read = MIN(recv_end - recv_start, left);
@@ -506,7 +507,7 @@ int AsyncConnection::read_until(uint64_t len, char *p)
 
 void AsyncConnection::process()
 {
-  int r = 0;
+  ssize_t r = 0;
   int prev_state = state;
   bool already_dispatch_writer = false;
   Mutex::Locker l(lock);
@@ -613,7 +614,7 @@ void AsyncConnection::process()
           ceph_msg_header header;
           ceph_msg_header_old oldheader;
           __u32 header_crc = 0;
-          int len;
+          unsigned len;
           if (has_feature(CEPH_FEATURE_NOSRCADDR))
             len = sizeof(header);
           else
@@ -721,7 +722,7 @@ void AsyncConnection::process()
       case STATE_OPEN_MESSAGE_READ_FRONT:
         {
           // read front
-          int front_len = current_header.front_len;
+          unsigned front_len = current_header.front_len;
           if (front_len) {
             if (!front.length()) {
               bufferptr ptr = buffer::create(front_len);
@@ -744,7 +745,7 @@ void AsyncConnection::process()
       case STATE_OPEN_MESSAGE_READ_MIDDLE:
         {
           // read middle
-          int middle_len = current_header.middle_len;
+          unsigned middle_len = current_header.middle_len;
           if (middle_len) {
             if (!middle.length()) {
               bufferptr ptr = buffer::create(middle_len);
@@ -767,8 +768,8 @@ void AsyncConnection::process()
       case STATE_OPEN_MESSAGE_READ_DATA_PREPARE:
         {
           // read data
-          uint64_t data_len = le32_to_cpu(current_header.data_len);
-          int data_off = le32_to_cpu(current_header.data_off);
+          unsigned data_len = le32_to_cpu(current_header.data_len);
+          unsigned data_off = le32_to_cpu(current_header.data_off);
           if (data_len) {
             // get a buffer
             map<ceph_tid_t,pair<bufferlist,int> >::iterator p = rx_buffers.find(current_header.tid);
@@ -797,7 +798,7 @@ void AsyncConnection::process()
         {
           while (msg_left > 0) {
             bufferptr bp = data_blp.get_current_ptr();
-            uint64_t read = MIN(bp.length(), msg_left);
+            unsigned read = MIN(bp.length(), msg_left);
             r = read_until(read, bp.c_str());
             if (r < 0) {
               ldout(async_msgr->cct, 1) << __func__ << " read data error " << dendl;
@@ -821,7 +822,7 @@ void AsyncConnection::process()
         {
           ceph_msg_footer footer;
           ceph_msg_footer_old old_footer;
-          int len;
+          unsigned len;
           // footer
           if (has_feature(CEPH_FEATURE_MSG_AUTH))
             len = sizeof(footer);
@@ -1011,9 +1012,9 @@ void AsyncConnection::process()
   fault();
 }
 
-int AsyncConnection::_process_connection()
+ssize_t AsyncConnection::_process_connection()
 {
-  int r = 0;
+  ssize_t r = 0;
 
   switch(state) {
     case STATE_WAIT_SEND:
@@ -1065,8 +1066,6 @@ int AsyncConnection::_process_connection()
           break;
         }
 
-        net.set_socket_options(sd);
-
         state = STATE_CONNECTING_WAIT_BANNER;
         break;
       }
@@ -1620,10 +1619,10 @@ int AsyncConnection::handle_connect_reply(ceph_msg_connect &connect, ceph_msg_co
   return -1;
 }
 
-int AsyncConnection::handle_connect_msg(ceph_msg_connect &connect, bufferlist &authorizer_bl,
-                                        bufferlist &authorizer_reply)
+ssize_t AsyncConnection::handle_connect_msg(ceph_msg_connect &connect, bufferlist &authorizer_bl,
+                                            bufferlist &authorizer_reply)
 {
-  int r = 0;
+  ssize_t r = 0;
   ceph_msg_connect_reply reply;
   bufferlist reply_bl;
 
@@ -2300,7 +2299,7 @@ void AsyncConnection::prepare_send_message(uint64_t features, Message *m, buffer
   bl.append(m->get_data());
 }
 
-int AsyncConnection::write_message(Message *m, bufferlist& bl)
+ssize_t AsyncConnection::write_message(Message *m, bufferlist& bl)
 {
   assert(can_write == CANWRITE);
   m->set_seq(out_seq.inc());
@@ -2381,7 +2380,7 @@ int AsyncConnection::write_message(Message *m, bufferlist& bl)
   logger->inc(l_msgr_send_bytes, complete_bl.length());
   ldout(async_msgr->cct, 20) << __func__ << " sending " << m->get_seq()
                              << " " << m << dendl;
-  int rc = _try_send(complete_bl);
+  ssize_t rc = _try_send(complete_bl);
   if (rc < 0) {
     ldout(async_msgr->cct, 1) << __func__ << " error sending " << m << ", "
                               << cpp_strerror(errno) << dendl;
@@ -2457,7 +2456,7 @@ void AsyncConnection::handle_write()
 {
   ldout(async_msgr->cct, 10) << __func__ << " started." << dendl;
   bufferlist bl;
-  int r = 0;
+  ssize_t r = 0;
 
   write_lock.Lock();
   if (can_write == CANWRITE) {
diff --git a/src/msg/async/AsyncConnection.h b/src/msg/async/AsyncConnection.h
index c578a7a..40a9887 100644
--- a/src/msg/async/AsyncConnection.h
+++ b/src/msg/async/AsyncConnection.h
@@ -45,25 +45,25 @@ class AsyncMessenger;
  */
 class AsyncConnection : public Connection {
 
-  int read_bulk(int fd, char *buf, int len);
+  ssize_t read_bulk(int fd, char *buf, unsigned len);
   void suppress_sigpipe();
   void restore_sigpipe();
-  int do_sendmsg(struct msghdr &msg, int len, bool more);
-  int try_send(bufferlist &bl, bool send=true) {
+  ssize_t do_sendmsg(struct msghdr &msg, unsigned len, bool more);
+  ssize_t try_send(bufferlist &bl, bool send=true) {
     Mutex::Locker l(write_lock);
     return _try_send(bl, send);
   }
   // if "send" is false, it will only append bl to send buffer
   // the main usage is avoid error happen outside messenger threads
-  int _try_send(bufferlist &bl, bool send=true);
-  int _send(Message *m);
+  ssize_t _try_send(bufferlist &bl, bool send=true);
+  ssize_t _send(Message *m);
   void prepare_send_message(uint64_t features, Message *m, bufferlist &bl);
-  int read_until(uint64_t needed, char *p);
-  int _process_connection();
+  ssize_t read_until(unsigned needed, char *p);
+  ssize_t _process_connection();
   void _connect();
   void _stop();
   int handle_connect_reply(ceph_msg_connect &connect, ceph_msg_connect_reply &r);
-  int handle_connect_msg(ceph_msg_connect &m, bufferlist &aubl, bufferlist &bl);
+  ssize_t handle_connect_msg(ceph_msg_connect &m, bufferlist &aubl, bufferlist &bl);
   void was_session_reset();
   void fault();
   void discard_out_queue();
@@ -72,8 +72,8 @@ class AsyncConnection : public Connection {
   int randomize_out_seq();
   void handle_ack(uint64_t seq);
   void _send_keepalive_or_ack(bool ack=false, utime_t *t=NULL);
-  int write_message(Message *m, bufferlist& bl);
-  int _reply_accept(char tag, ceph_msg_connect &connect, ceph_msg_connect_reply &reply,
+  ssize_t write_message(Message *m, bufferlist& bl);
+  ssize_t _reply_accept(char tag, ceph_msg_connect &connect, ceph_msg_connect_reply &reply,
                     bufferlist authorizer_reply) {
     bufferlist reply_bl;
     reply.tag = tag;
@@ -83,7 +83,7 @@ class AsyncConnection : public Connection {
     if (reply.authorizer_len) {
       reply_bl.append(authorizer_reply.c_str(), authorizer_reply.length());
     }
-    int r = try_send(reply_bl);
+    ssize_t r = try_send(reply_bl);
     if (r < 0)
       return -1;
 
@@ -122,7 +122,7 @@ class AsyncConnection : public Connection {
 
   ostream& _conn_prefix(std::ostream *_dout);
 
-  bool is_connected() {
+  bool is_connected() override {
     Mutex::Locker l(lock);
     return state >= STATE_OPEN && state <= STATE_OPEN_TAG_CLOSE;
   }
@@ -136,11 +136,11 @@ class AsyncConnection : public Connection {
   }
   // Only call when AsyncConnection first construct
   void accept(int sd);
-  int send_message(Message *m);
+  int send_message(Message *m) override;
 
-  void send_keepalive();
-  void mark_down();
-  void mark_disposable() {
+  void send_keepalive() override;
+  void mark_down() override;
+  void mark_disposable() override {
     Mutex::Locker l(lock);
     policy.lossy = true;
   }
@@ -266,7 +266,7 @@ class AsyncConnection : public Connection {
   // Open state
   utime_t recv_stamp;
   utime_t throttle_stamp;
-  uint64_t msg_left;
+  unsigned msg_left;
   ceph_msg_header current_header;
   bufferlist data_buf;
   bufferlist::iterator data_blp;
@@ -316,13 +316,13 @@ class AsyncConnection : public Connection {
     mark_down();
   }
   void cleanup_handler() {
-    read_handler.reset();
-    write_handler.reset();
-    reset_handler.reset();
-    remote_reset_handler.reset();
-    connect_handler.reset();
-    local_deliver_handler.reset();
-    wakeup_handler.reset();
+    delete read_handler;
+    delete write_handler;
+    delete reset_handler;
+    delete remote_reset_handler;
+    delete connect_handler;
+    delete local_deliver_handler;
+    delete wakeup_handler;
   }
   PerfCounters *get_perf_counter() {
     return logger;
diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc
index e5e393a..31158a4 100644
--- a/src/msg/async/AsyncMessenger.cc
+++ b/src/msg/async/AsyncMessenger.cc
@@ -50,16 +50,6 @@ static ostream& _prefix(std::ostream *_dout, WorkerPool *p) {
 }
 
 
-class C_processor_accept : public EventCallback {
-  Processor *pro;
-
- public:
-  C_processor_accept(Processor *p): pro(p) {}
-  void do_request(int id) {
-    pro->accept();
-  }
-};
-
 
 /*******************
  * Processor
@@ -232,8 +222,7 @@ int Processor::start(Worker *w)
   // start thread
   if (listen_sd >= 0) {
     worker = w;
-    w->center.create_file_event(listen_sd, EVENT_READABLE,
-                                EventCallbackRef(new C_processor_accept(this)));
+    w->center.create_file_event(listen_sd, EVENT_READABLE, listen_handler);
   }
 
   return 0;
@@ -355,7 +344,7 @@ void WorkerPool::start()
 {
   if (!started) {
     for (uint64_t i = 0; i < workers.size(); ++i) {
-      workers[i]->create();
+      workers[i]->create("ms_async_worker");
     }
     started = true;
   }
@@ -394,10 +383,11 @@ AsyncMessenger::AsyncMessenger(CephContext *cct, entity_name_t name,
 {
   ceph_spin_init(&global_seq_lock);
   cct->lookup_or_create_singleton_object<WorkerPool>(pool, WorkerPool::name);
-  Worker *w = pool->get_worker();
-  local_connection = new AsyncConnection(cct, this, &w->center, w->get_perf_counter());
+  local_worker = pool->get_worker();
+  local_connection = new AsyncConnection(cct, this, &local_worker->center, local_worker->get_perf_counter());
   local_features = features;
   init_local_connection();
+  reap_handler = new C_handle_reap(this);
 }
 
 /**
@@ -406,6 +396,7 @@ AsyncMessenger::AsyncMessenger(CephContext *cct, entity_name_t name,
  */
 AsyncMessenger::~AsyncMessenger()
 {
+  delete reap_handler;
   assert(!did_bind); // either we didn't bind or we shut down the Processor
   local_connection->mark_down();
 }
@@ -747,3 +738,25 @@ void AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
   }
   lock.Unlock();
 }
+
+int AsyncMessenger::reap_dead()
+{
+  int num = 0;
+
+  Mutex::Locker l1(lock);
+  Mutex::Locker l2(deleted_lock);
+
+  while (!deleted_conns.empty()) {
+    auto it = deleted_conns.begin();
+    AsyncConnectionRef p = *it;
+    ldout(cct, 5) << __func__ << " delete " << p << dendl;
+    auto conns_it = conns.find(p->peer_addr);
+    if (conns_it != conns.end() && conns_it->second == p)
+      conns.erase(conns_it);
+    accepting_conns.erase(p);
+    deleted_conns.erase(it);
+    ++num;
+  }
+
+  return num;
+}
diff --git a/src/msg/async/AsyncMessenger.h b/src/msg/async/AsyncMessenger.h
index ed8a0ff..5206a81 100644
--- a/src/msg/async/AsyncMessenger.h
+++ b/src/msg/async/AsyncMessenger.h
@@ -103,9 +103,22 @@ class Processor {
   Worker *worker;
   int listen_sd;
   uint64_t nonce;
+  EventCallbackRef listen_handler;
+
+  class C_processor_accept : public EventCallback {
+    Processor *pro;
+
+   public:
+    C_processor_accept(Processor *p): pro(p) {}
+    void do_request(int id) {
+      pro->accept();
+    }
+  };
 
  public:
-  Processor(AsyncMessenger *r, CephContext *c, uint64_t n): msgr(r), net(c), worker(NULL), listen_sd(-1), nonce(n) {}
+  Processor(AsyncMessenger *r, CephContext *c, uint64_t n)
+          : msgr(r), net(c), worker(NULL), listen_sd(-1), nonce(n), listen_handler(new C_processor_accept(this)) {}
+  ~Processor() { delete listen_handler; };
 
   void stop();
   int bind(const entity_addr_t &bind_addr, const set<int>& avoid_ports);
@@ -135,6 +148,7 @@ class WorkerPool {
       Mutex::Locker l(pool->barrier_lock);
       pool->barrier_count.dec();
       pool->barrier_cond.Signal();
+      delete this;
     }
   };
   friend class C_barrier;
@@ -307,11 +321,26 @@ private:
   int _send_message(Message *m, const entity_inst_t& dest);
 
  private:
+  static const uint64_t ReapDeadConnectionThreshold = 5;
+
   WorkerPool *pool;
 
   Processor processor;
   friend class Processor;
 
+  class C_handle_reap : public EventCallback {
+    AsyncMessenger *msgr;
+
+   public:
+    C_handle_reap(AsyncMessenger *m): msgr(m) {}
+    void do_request(int id) {
+      // judge whether is a time event
+      msgr->reap_dead();
+    }
+  };
+  // the worker run messenger's cron jobs
+  Worker *local_worker;
+
   /// overall lock used for AsyncMessenger data structures
   Mutex lock;
   // AsyncMessenger stuff
@@ -351,7 +380,6 @@ private:
    *
    * These are not yet in the conns map.
    */
-  // FIXME clear up
   set<AsyncConnectionRef> accepting_conns;
 
   /**
@@ -368,6 +396,8 @@ private:
   Mutex deleted_lock;
   set<AsyncConnectionRef> deleted_conns;
 
+  EventCallbackRef reap_handler;
+
   /// internal cluster protocol version, if any, for talking to entities of the same type.
   int cluster_protocol;
 
@@ -495,7 +525,21 @@ public:
   void unregister_conn(AsyncConnectionRef conn) {
     Mutex::Locker l(deleted_lock);
     deleted_conns.insert(conn);
+
+    if (deleted_conns.size() >= ReapDeadConnectionThreshold) {
+      local_worker->center.dispatch_event_external(reap_handler);
+    }
   }
+
+  /**
+   * Reap dead connection from `deleted_conns`
+   *
+   * @return the number of dead connections
+   *
+   * See "deleted_conns"
+   */
+  int reap_dead();
+
   /**
    * @} // AsyncMessenger Internals
    */
diff --git a/src/msg/async/Event.cc b/src/msg/async/Event.cc
index 2027a9f..04887b8 100644
--- a/src/msg/async/Event.cc
+++ b/src/msg/async/Event.cc
@@ -199,10 +199,10 @@ void EventCenter::delete_file_event(int fd, int mask)
   }
 
   if (mask & EVENT_READABLE && event->read_cb) {
-    event->read_cb.reset();
+    event->read_cb = nullptr;
   }
   if (mask & EVENT_WRITABLE && event->write_cb) {
-    event->write_cb.reset();
+    event->write_cb = nullptr;
   }
 
   event->mask = event->mask & (~mask);
@@ -248,7 +248,6 @@ void EventCenter::delete_time_event(uint64_t id)
   if (id >= time_event_next_id)
     return ;
 
-
   for (map<utime_t, list<TimeEvent> >::iterator it = time_events.begin();
        it != time_events.end(); ++it) {
     for (list<TimeEvent>::iterator j = it->second.begin();
diff --git a/src/msg/async/Event.h b/src/msg/async/Event.h
index dc85238..2575130 100644
--- a/src/msg/async/Event.h
+++ b/src/msg/async/Event.h
@@ -58,7 +58,7 @@ class EventCallback {
   virtual ~EventCallback() {}       // we want a virtual destructor!!!
 };
 
-typedef ceph::shared_ptr<EventCallback> EventCallbackRef;
+typedef EventCallback* EventCallbackRef;
 
 struct FiredFileEvent {
   int fd;
@@ -133,7 +133,7 @@ class EventCenter {
     file_lock("AsyncMessenger::file_lock"),
     time_lock("AsyncMessenger::time_lock"),
     file_events(NULL),
-    driver(NULL), time_event_next_id(0),
+    driver(NULL), time_event_next_id(1),
     notify_receive_fd(-1), notify_send_fd(-1), net(c), owner(0), already_wakeup(0) {
     last_time = time(NULL);
   }
diff --git a/src/msg/simple/Accepter.cc b/src/msg/simple/Accepter.cc
index a8aa495..3d6f1f7 100644
--- a/src/msg/simple/Accepter.cc
+++ b/src/msg/simple/Accepter.cc
@@ -208,7 +208,7 @@ int Accepter::start()
   ldout(msgr->cct,1) << "accepter.start" << dendl;
 
   // start thread
-  create();
+  create("ms_accepter");
 
   return 0;
 }
diff --git a/src/msg/simple/DispatchQueue.cc b/src/msg/simple/DispatchQueue.cc
index 500239f..6f7495e 100644
--- a/src/msg/simple/DispatchQueue.cc
+++ b/src/msg/simple/DispatchQueue.cc
@@ -217,8 +217,8 @@ void DispatchQueue::start()
 {
   assert(!stop);
   assert(!dispatch_thread.is_started());
-  dispatch_thread.create();
-  local_delivery_thread.create();
+  dispatch_thread.create("ms_dispatch");
+  local_delivery_thread.create("ms_local");
 }
 
 void DispatchQueue::wait()
diff --git a/src/msg/simple/Pipe.cc b/src/msg/simple/Pipe.cc
index 33884c8..ace77aa 100644
--- a/src/msg/simple/Pipe.cc
+++ b/src/msg/simple/Pipe.cc
@@ -27,6 +27,7 @@
 
 #include "common/debug.h"
 #include "common/errno.h"
+#include "common/valgrind.h"
 
 // Below included to get encode_encrypt(); That probably should be in Crypto.h, instead
 
@@ -83,6 +84,10 @@ Pipe::Pipe(SimpleMessenger *r, int st, PipeConnection *con)
     send_keepalive_ack(false),
     connect_seq(0), peer_global_seq(0),
     out_seq(0), in_seq(0), in_seq_acked(0) {
+  ANNOTATE_BENIGN_RACE_SIZED(&sd, sizeof(sd), "Pipe socket");
+  ANNOTATE_BENIGN_RACE_SIZED(&state, sizeof(state), "Pipe state");
+  ANNOTATE_BENIGN_RACE_SIZED(&recv_len, sizeof(recv_len), "Pipe recv_len");
+  ANNOTATE_BENIGN_RACE_SIZED(&recv_ofs, sizeof(recv_ofs), "Pipe recv_ofs");
   if (con) {
     connection_state = con;
     connection_state->reset_pipe(this);
@@ -135,7 +140,7 @@ void Pipe::start_reader()
     reader_needs_join = false;
   }
   reader_running = true;
-  reader_thread.create(msgr->cct->_conf->ms_rwthread_stack_bytes);
+  reader_thread.create("ms_pipe_read", msgr->cct->_conf->ms_rwthread_stack_bytes);
 }
 
 void Pipe::maybe_start_delay_thread()
@@ -144,7 +149,7 @@ void Pipe::maybe_start_delay_thread()
       msgr->cct->_conf->ms_inject_delay_type.find(ceph_entity_type_name(connection_state->peer_type)) != string::npos) {
     lsubdout(msgr->cct, ms, 1) << "setting up a delay queue on Pipe " << this << dendl;
     delay_thread = new DelayedDelivery(this);
-    delay_thread->create();
+    delay_thread->create("ms_pipe_delay");
   }
 }
 
@@ -153,7 +158,7 @@ void Pipe::start_writer()
   assert(pipe_lock.is_locked());
   assert(!writer_running);
   writer_running = true;
-  writer_thread.create(msgr->cct->_conf->ms_rwthread_stack_bytes);
+  writer_thread.create("ms_pipe_write", msgr->cct->_conf->ms_rwthread_stack_bytes);
 }
 
 void Pipe::join_reader()
@@ -2029,7 +2034,7 @@ int Pipe::read_message(Message **pm, AuthSessionHandler* auth_handler)
       bufferptr bp = blp.get_current_ptr();
       int read = MIN(bp.length(), left);
       ldout(msgr->cct,20) << "reader reading nonblocking into " << (void*)bp.c_str() << " len " << bp.length() << dendl;
-      int got = tcp_read_nonblocking(bp.c_str(), read);
+      ssize_t got = tcp_read_nonblocking(bp.c_str(), read);
       ldout(msgr->cct,30) << "reader read " << got << " of " << read << dendl;
       connection_state->lock.Unlock();
       if (got < 0)
@@ -2084,6 +2089,7 @@ int Pipe::read_message(Message **pm, AuthSessionHandler* auth_handler)
   } else {
     if (auth_handler->check_message_signature(message)) {
       ldout(msgr->cct, 0) << "Signature check failed" << dendl;
+      message->put();
       ret = -EINVAL;
       goto out_dethrottle;
     } 
@@ -2188,12 +2194,12 @@ void Pipe::restore_sigpipe()
 }
 
 
-int Pipe::do_sendmsg(struct msghdr *msg, int len, bool more)
+int Pipe::do_sendmsg(struct msghdr *msg, unsigned len, bool more)
 {
   suppress_sigpipe();
   while (len > 0) {
     if (0) { // sanity
-      int l = 0;
+      unsigned l = 0;
       for (unsigned i=0; i<msg->msg_iovlen; i++)
 	l += msg->msg_iov[i].iov_len;
       assert(l == len);
@@ -2352,15 +2358,15 @@ int Pipe::write_message(const ceph_msg_header& header, const ceph_msg_footer& fo
 
   // payload (front+data)
   list<bufferptr>::const_iterator pb = blist.buffers().begin();
-  int b_off = 0;  // carry-over buffer offset, if any
-  int bl_pos = 0; // blist pos
-  int left = blist.length();
+  unsigned b_off = 0;  // carry-over buffer offset, if any
+  unsigned bl_pos = 0; // blist pos
+  unsigned left = blist.length();
 
   while (left > 0) {
-    int donow = MIN(left, (int)pb->length()-b_off);
+    unsigned donow = MIN(left, pb->length()-b_off);
     if (donow == 0) {
       ldout(msgr->cct,0) << "donow = " << donow << " left " << left << " pb->length " << pb->length()
-	      << " b_off " << b_off << dendl;
+                         << " b_off " << b_off << dendl;
     }
     assert(donow > 0);
     ldout(msgr->cct,30) << " bl_pos " << bl_pos << " b_off " << b_off
@@ -2384,13 +2390,13 @@ int Pipe::write_message(const ceph_msg_header& header, const ceph_msg_footer& fo
     msglen += donow;
     msg.msg_iovlen++;
     
+    assert(left >= donow);
     left -= donow;
-    assert(left >= 0);
     b_off += donow;
     bl_pos += donow;
     if (left == 0)
       break;
-    while (b_off == (int)pb->length()) {
+    while (b_off == pb->length()) {
       ++pb;
       b_off = 0;
     }
@@ -2435,7 +2441,7 @@ int Pipe::write_message(const ceph_msg_header& header, const ceph_msg_footer& fo
 }
 
 
-int Pipe::tcp_read(char *buf, int len)
+int Pipe::tcp_read(char *buf, unsigned len)
 {
   if (sd < 0)
     return -1;
@@ -2452,7 +2458,7 @@ int Pipe::tcp_read(char *buf, int len)
     if (tcp_read_wait() < 0)
       return -1;
 
-    int got = tcp_read_nonblocking(buf, len);
+    ssize_t got = tcp_read_nonblocking(buf, len);
 
     if (got < 0)
       return -1;
@@ -2461,7 +2467,7 @@ int Pipe::tcp_read(char *buf, int len)
     buf += got;
     //lgeneric_dout(cct, DBL) << "tcp_read got " << got << ", " << len << " left" << dendl;
   }
-  return len;
+  return 0;
 }
 
 int Pipe::tcp_read_wait()
@@ -2495,10 +2501,10 @@ int Pipe::tcp_read_wait()
   return 0;
 }
 
-int Pipe::do_recv(char *buf, size_t len, int flags)
+ssize_t Pipe::do_recv(char *buf, size_t len, int flags)
 {
 again:
-  int got = ::recv( sd, buf, len, flags );
+  ssize_t got = ::recv( sd, buf, len, flags );
   if (got < 0) {
     if (errno == EAGAIN || errno == EINTR) {
       goto again;
@@ -2513,10 +2519,10 @@ again:
   return got;
 }
 
-int Pipe::buffered_recv(char *buf, size_t len, int flags)
+ssize_t Pipe::buffered_recv(char *buf, size_t len, int flags)
 {
-  int left = len;
-  int total_recv = 0;
+  size_t left = len;
+  ssize_t total_recv = 0;
   if (recv_len > recv_ofs) {
     int to_read = MIN(recv_len - recv_ofs, left);
     memcpy(buf, &recv_buf[recv_ofs], to_read);
@@ -2533,7 +2539,7 @@ int Pipe::buffered_recv(char *buf, size_t len, int flags)
 
   if (len > (size_t)recv_max_prefetch) {
     /* this was a large read, we don't prefetch for these */
-    int ret = do_recv(buf, left, flags );
+    ssize_t ret = do_recv(buf, left, flags );
     if (ret < 0) {
       if (total_recv > 0)
         return total_recv;
@@ -2544,7 +2550,7 @@ int Pipe::buffered_recv(char *buf, size_t len, int flags)
   }
 
 
-  int got = do_recv(recv_buf, recv_max_prefetch, flags);
+  ssize_t got = do_recv(recv_buf, recv_max_prefetch, flags);
   if (got <= 0) {
     if (total_recv > 0)
       return total_recv;
@@ -2552,17 +2558,17 @@ int Pipe::buffered_recv(char *buf, size_t len, int flags)
     return got;
   }
 
-  recv_len = got;
-  got = MIN(left, got);
+  recv_len = (size_t)got;
+  got = MIN(left, (size_t)got);
   memcpy(buf, recv_buf, got);
   recv_ofs = got;
   total_recv += got;
   return total_recv;
 }
 
-int Pipe::tcp_read_nonblocking(char *buf, int len)
+ssize_t Pipe::tcp_read_nonblocking(char *buf, unsigned len)
 {
-  int got = buffered_recv(buf, len, MSG_DONTWAIT );
+  ssize_t got = buffered_recv(buf, len, MSG_DONTWAIT );
   if (got < 0) {
     ldout(msgr->cct, 10) << __func__ << " socket " << sd << " returned "
 		         << got << " " << cpp_strerror(errno) << dendl;
@@ -2578,7 +2584,7 @@ int Pipe::tcp_read_nonblocking(char *buf, int len)
   return got;
 }
 
-int Pipe::tcp_write(const char *buf, int len)
+int Pipe::tcp_write(const char *buf, unsigned len)
 {
   if (sd < 0)
     return -1;
diff --git a/src/msg/simple/Pipe.h b/src/msg/simple/Pipe.h
index ce24a2a..bbe8aa2 100644
--- a/src/msg/simple/Pipe.h
+++ b/src/msg/simple/Pipe.h
@@ -49,7 +49,6 @@ class DispatchQueue;
       Reader(Pipe *p) : pipe(p) {}
       void *entry() { pipe->reader(); return 0; }
     } reader_thread;
-    friend class Reader;
 
     /**
      * The Writer thread handles all writes to the socket (after startup).
@@ -61,7 +60,6 @@ class DispatchQueue;
       Writer(Pipe *p) : pipe(p) {}
       void *entry() { pipe->writer(); return 0; }
     } writer_thread;
-    friend class Writer;
 
     /**
      * The DelayedDelivery is for injecting delays into Message delivery off
@@ -126,7 +124,6 @@ class DispatchQueue;
        */
       void stop_fast_dispatching();
     } *delay_thread;
-    friend class DelayedDelivery;
 
   public:
     Pipe(SimpleMessenger *r, int st, PipeConnection *con);
@@ -146,9 +143,9 @@ class DispatchQueue;
     }
 
     char *recv_buf;
-    int recv_max_prefetch;
-    int recv_ofs;
-    int recv_len;
+    size_t recv_max_prefetch;
+    size_t recv_ofs;
+    size_t recv_len;
 
     enum {
       STATE_ACCEPTING,
@@ -247,7 +244,7 @@ class DispatchQueue;
      * @param more Should be set true if this is one part of a larger message
      * @return 0, or -1 on failure (unrecoverable -- close the socket).
      */
-    int do_sendmsg(struct msghdr *msg, int len, bool more=false);
+    int do_sendmsg(struct msghdr *msg, unsigned len, bool more=false);
     int write_ack(uint64_t s);
     int write_keepalive();
     int write_keepalive2(char tag, const utime_t &t);
@@ -342,8 +339,8 @@ class DispatchQueue;
       recv_len = 0;
       recv_ofs = 0;
     }
-    int do_recv(char *buf, size_t len, int flags);
-    int buffered_recv(char *buf, size_t len, int flags);
+    ssize_t do_recv(char *buf, size_t len, int flags);
+    ssize_t buffered_recv(char *buf, size_t len, int flags);
     bool has_pending_data() { return recv_len > recv_ofs; }
 
     /**
@@ -353,7 +350,7 @@ class DispatchQueue;
      * @param len exact number of bytes to read
      * @return 0 for success, or -1 on error
      */
-    int tcp_read(char *buf, int len);
+    int tcp_read(char *buf, unsigned len);
 
     /**
      * wait for bytes to become available on the socket
@@ -372,7 +369,7 @@ class DispatchQueue;
      * @param len maximum number of bytes to read
      * @return bytes read, or -1 on error or when there is no data
      */
-    int tcp_read_nonblocking(char *buf, int len);
+    ssize_t tcp_read_nonblocking(char *buf, unsigned len);
 
     /**
      * blocking write of bytes to socket
@@ -381,7 +378,7 @@ class DispatchQueue;
      * @param len number of bytes to write
      * @return 0 for success, or -1 on error
      */
-    int tcp_write(const char *buf, int len);
+    int tcp_write(const char *buf, unsigned len);
 
   };
 
diff --git a/src/msg/simple/PipeConnection.h b/src/msg/simple/PipeConnection.h
index 9e27ec4..7a8e9d0 100644
--- a/src/msg/simple/PipeConnection.h
+++ b/src/msg/simple/PipeConnection.h
@@ -41,12 +41,12 @@ public:
 
   void reset_pipe(Pipe* p);
 
-  bool is_connected();
+  bool is_connected() override;
 
-  int send_message(Message *m);
-  void send_keepalive();
-  void mark_down();
-  void mark_disposable();
+  int send_message(Message *m) override;
+  void send_keepalive() override;
+  void mark_down() override;
+  void mark_disposable() override;
 
 }; /* PipeConnection */
 
diff --git a/src/msg/simple/SimpleMessenger.cc b/src/msg/simple/SimpleMessenger.cc
index fdb7278..5c257ab 100644
--- a/src/msg/simple/SimpleMessenger.cc
+++ b/src/msg/simple/SimpleMessenger.cc
@@ -22,6 +22,7 @@
 #include "common/config.h"
 #include "common/Timer.h"
 #include "common/errno.h"
+#include "common/valgrind.h"
 #include "auth/Crypto.h"
 #include "include/Spinlock.h"
 
@@ -53,6 +54,8 @@ SimpleMessenger::SimpleMessenger(CephContext *cct, entity_name_t name,
     timeout(0),
     local_connection(new PipeConnection(cct, this))
 {
+  ANNOTATE_BENIGN_RACE_SIZED(&timeout, sizeof(timeout),
+                             "SimpleMessenger read timeout");
   ceph_spin_init(&global_seq_lock);
   local_features = features;
   init_local_connection();
@@ -67,6 +70,7 @@ SimpleMessenger::~SimpleMessenger()
   assert(!did_bind); // either we didn't bind or we shut down the Accepter
   assert(rank_pipe.empty()); // we don't have any running Pipes.
   assert(!reaper_started); // the reaper thread is stopped
+  ceph_spin_destroy(&global_seq_lock);
 }
 
 void SimpleMessenger::ready()
@@ -329,7 +333,7 @@ int SimpleMessenger::start()
   lock.Unlock();
 
   reaper_started = true;
-  reaper_thread.create();
+  reaper_thread.create("ms_reaper");
   return 0;
 }
 
@@ -701,6 +705,8 @@ void SimpleMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
   if (need_addr) {
     entity_addr_t t = peer_addr_for_me;
     t.set_port(my_inst.addr.get_port());
+    ANNOTATE_BENIGN_RACE_SIZED(&my_inst.addr.addr, sizeof(my_inst.addr.addr),
+                               "SimpleMessenger learned addr");
     my_inst.addr.addr = t.addr;
     ldout(cct,1) << "learned my addr " << my_inst.addr << dendl;
     need_addr = false;
diff --git a/src/msg/xio/XioConnection.h b/src/msg/xio/XioConnection.h
index 9a5f615..da34d6e 100644
--- a/src/msg/xio/XioConnection.h
+++ b/src/msg/xio/XioConnection.h
@@ -259,14 +259,14 @@ public:
       xio_connection_destroy(conn);
   }
 
-  bool is_connected() { return connected.read(); }
+  bool is_connected() override { return connected.read(); }
 
-  int send_message(Message *m);
-  void send_keepalive() {}
-  virtual void mark_down();
+  int send_message(Message *m) override;
+  void send_keepalive() override {}
+  void mark_down() override;
   int _mark_down(uint32_t flags);
-  virtual void mark_disposable();
-  int _mark_disposable(uint32_t flags);
+  virtual void mark_disposable() override;
+  int _mark_disposable(uint32_t flags) override;
 
   const entity_inst_t& get_peer() const { return peer; }
 
@@ -334,12 +334,12 @@ public:
     return static_cast<XioLoopbackConnection*>(RefCountedObject::get());
   }
 
-  virtual bool is_connected() { return true; }
+  bool is_connected() override { return true; }
 
-  int send_message(Message *m);
-  void send_keepalive() {}
-  void mark_down() {}
-  void mark_disposable() {}
+  int send_message(Message *m) override;
+  void send_keepalive()i override {}
+  void mark_down() override {}
+  void mark_disposable() override {}
 
   uint32_t get_seq() {
     return seq.read();
diff --git a/src/msg/xio/XioMessenger.cc b/src/msg/xio/XioMessenger.cc
index d651800..a920f7e 100644
--- a/src/msg/xio/XioMessenger.cc
+++ b/src/msg/xio/XioMessenger.cc
@@ -319,12 +319,13 @@ XioMessenger::XioMessenger(CephContext *cct, entity_name_t name,
       xio_set_opt(NULL, XIO_OPTLEVEL_ACCELIO, XIO_OPTNAME_MAX_INLINE_XIO_HEADER,
                  &xopt, sizeof(xopt));
 
+      size_t queue_depth = cct->_conf->xio_queue_depth;
       struct xio_mempool_config mempool_config = {
         6,
         {
-          {1024,  0,  cct->_conf->xio_queue_depth,  262144},
-          {4096,  0,  cct->_conf->xio_queue_depth,  262144},
-          {16384, 0,  cct->_conf->xio_queue_depth,  262144},
+          {1024,  0,  queue_depth,  262144},
+          {4096,  0,  queue_depth,  262144},
+          {16384, 0,  queue_depth,  262144},
           {65536, 0,  128,  65536},
           {262144, 0,  32,  16384},
           {1048576, 0, 8,  8192}
diff --git a/src/ocf/Makefile.in b/src/ocf/Makefile.in
index ac86dc8..72ac9c4 100644
--- a/src/ocf/Makefile.in
+++ b/src/ocf/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -80,8 +90,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = src/ocf
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
-	$(srcdir)/ceph.in $(srcdir)/rbd.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/ac_prog_jar.m4 \
@@ -100,6 +108,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/acconfig.h
 CONFIG_CLEAN_FILES = ceph rbd
@@ -153,6 +162,8 @@ am__can_run_installinfo = \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/ceph.in \
+	$(srcdir)/rbd.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -243,6 +254,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -339,6 +351,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -380,7 +393,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/ocf/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign src/ocf/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -602,6 +614,8 @@ uninstall-am: uninstall-raSCRIPTS
 	mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
 	uninstall-am uninstall-hook uninstall-raSCRIPTS
 
+.PRECIOUS: Makefile
+
 
 @WITH_OCF_TRUE at install-data-hook:
 @WITH_OCF_TRUE@	$(LN_S) ceph $(DESTDIR)$(radir)/osd
diff --git a/src/os/Makefile.am b/src/os/Makefile.am
index 3ea9300..d7cdbf1 100644
--- a/src/os/Makefile.am
+++ b/src/os/Makefile.am
@@ -1,89 +1,126 @@
 libos_types_a_SOURCES = \
+	os/kstore/kstore_types.cc \
 	os/Transaction.cc
 libos_types_a_CXXFLAGS = ${AM_CXXFLAGS}
 noinst_LIBRARIES += libos_types.a
 
+if WITH_LIBAIO
+libos_types_a_SOURCES += \
+	os/bluestore/bluestore_types.cc \
+	os/bluestore/bluefs_types.cc
+endif
+
 if ENABLE_SERVER
 
 libos_a_SOURCES = \
-	os/chain_xattr.cc \
+	os/filestore/chain_xattr.cc \
+	os/filestore/DBObjectMap.cc \
+	os/filestore/FileJournal.cc \
+	os/filestore/FileStore.cc \
+	os/filestore/GenericFileStoreBackend.cc \
+	os/filestore/HashIndex.cc \
+	os/filestore/IndexManager.cc \
+	os/filestore/JournalingObjectStore.cc \
+	os/filestore/LFNIndex.cc \
+	os/filestore/WBThrottle.cc \
 	os/fs/FS.cc \
-	os/DBObjectMap.cc \
-	os/GenericObjectMap.cc \
-	os/FileJournal.cc \
-	os/FileStore.cc \
-	os/GenericFileStoreBackend.cc \
-	os/HashIndex.cc \
-	os/IndexManager.cc \
-	os/JournalingObjectStore.cc \
-	os/LFNIndex.cc \
-	os/MemStore.cc \
-	os/KeyValueStore.cc \
-	os/ObjectStore.cc \
-	os/WBThrottle.cc
+	os/keyvaluestore/GenericObjectMap.cc \
+	os/keyvaluestore/KeyValueStore.cc \
+	os/kstore/kv.cc \
+	os/kstore/KStore.cc \
+	os/memstore/MemStore.cc \
+	os/ObjectStore.cc
 
-if LINUX
-libos_a_SOURCES += os/BtrfsFileStoreBackend.cc
+if WITH_LIBAIO
+libos_a_SOURCES += \
+	os/bluestore/kv.cc \
+	os/bluestore/Allocator.cc \
+	os/bluestore/BlockDevice.cc \
+	os/bluestore/BlueFS.cc \
+	os/bluestore/BlueRocksEnv.cc \
+	os/bluestore/BlueStore.cc \
+	os/bluestore/FreelistManager.cc \
+	os/bluestore/StupidAllocator.cc
 endif
 
-if WITH_LIBAIO
-libos_types_a_SOURCES += os/newstore/newstore_types.cc
-libos_a_SOURCES += os/newstore/NewStore.cc
+if LINUX
+libos_a_SOURCES += os/filestore/BtrfsFileStoreBackend.cc
 endif
 
 if WITH_LIBXFS
 libos_a_SOURCES += \
-    os/fs/XFS.cc \
-    os/XfsFileStoreBackend.cc
+    os/filestore/XfsFileStoreBackend.cc \
+    os/fs/XFS.cc
 endif
 
 if WITH_LIBZFS
-libos_a_SOURCES += os/ZFSFileStoreBackend.cc
+libos_a_SOURCES += os/filestore/ZFSFileStoreBackend.cc
 endif
 
+libos_a_CXXFLAGS = ${AM_CXXFLAGS} -I rocksdb/include -fPIC
 libos_a_LIBADD = libos_types.a libkv.a
+noinst_LIBRARIES += libos.a
 
 if WITH_LTTNG
 libos_a_LIBADD += $(LIBOS_TP)
 endif
 
-noinst_LIBRARIES += libos.a
-
 noinst_HEADERS += \
-	os/btrfs_ioctl.h \
-	os/chain_xattr.h \
-	os/newstore/newstore_types.h \
-	os/newstore/NewStore.h \
-	os/BtrfsFileStoreBackend.h \
-	os/CollectionIndex.h \
-	os/DBObjectMap.h \
-	os/GenericObjectMap.h \
-	os/FileJournal.h \
-	os/FileStore.h \
-	os/FDCache.h \
+	os/filestore/chain_xattr.h \
+	os/filestore/BtrfsFileStoreBackend.h \
+	os/filestore/CollectionIndex.h \
+	os/filestore/DBObjectMap.h \
+	os/filestore/FileJournal.h \
+	os/filestore/FileStore.h \
+	os/filestore/FDCache.h \
+	os/filestore/GenericFileStoreBackend.h \
+	os/filestore/HashIndex.h \
+	os/filestore/IndexManager.h \
+	os/filestore/Journal.h \
+	os/filestore/JournalingObjectStore.h \
+	os/filestore/LFNIndex.h \
+	os/filestore/SequencerPosition.h \
+	os/filestore/WBThrottle.h \
+	os/filestore/XfsFileStoreBackend.h \
+	os/filestore/ZFSFileStoreBackend.h \
+	os/fs/btrfs_ioctl.h \
 	os/fs/FS.h \
 	os/fs/XFS.h \
-	os/GenericFileStoreBackend.h \
-	os/HashIndex.h \
-	os/IndexManager.h \
-	os/Journal.h \
-	os/JournalingObjectStore.h \
-	os/LFNIndex.h \
-	os/MemStore.h \
-	os/KeyValueStore.h \
+	os/keyvaluestore/GenericObjectMap.h \
+	os/keyvaluestore/KeyValueStore.h \
+	os/kstore/kstore_types.h \
+	os/kstore/KStore.h \
+	os/kstore/kv.h \
+	os/memstore/MemStore.h \
+	os/memstore/PageSet.h \
 	os/ObjectMap.h \
-	os/ObjectStore.h \
-	os/PageSet.h \
-	os/SequencerPosition.h \
-	os/WBThrottle.h \
-	os/XfsFileStoreBackend.h \
-	os/ZFSFileStoreBackend.h
+	os/ObjectStore.h
+
+if WITH_LIBAIO
+noinst_HEADERS += \
+	os/bluestore/bluefs_types.h \
+	os/bluestore/bluestore_types.h \
+	os/bluestore/kv.h \
+	os/bluestore/Allocator.h \
+	os/bluestore/BlockDevice.h \
+	os/bluestore/BlueFS.h \
+	os/bluestore/BlueRocksEnv.h \
+	os/bluestore/BlueStore.h \
+	os/bluestore/FreelistManager.h \
+	os/bluestore/StupidAllocator.h
+endif
 
 if WITH_LIBZFS
-libos_zfs_a_SOURCES = os/ZFS.cc
+libos_zfs_a_SOURCES = os/fs/ZFS.cc
 libos_zfs_a_CXXFLAGS = ${AM_CXXFLAGS} ${LIBZFS_CFLAGS}
 noinst_LIBRARIES += libos_zfs.a
-noinst_HEADERS += os/ZFS.h
+noinst_HEADERS += os/fs/ZFS.h
+endif
+
+if WITH_LIBAIO
+ceph_bluefs_tool_SOURCES = os/bluestore/bluefs_tool.cc
+ceph_bluefs_tool_LDADD = $(LIBOS) $(CEPH_GLOBAL)
+bin_PROGRAMS += ceph-bluefs-tool
 endif
 
 endif # ENABLE_SERVER
diff --git a/src/os/ObjectMap.h b/src/os/ObjectMap.h
index e7a64a4..c4efc7f 100644
--- a/src/os/ObjectMap.h
+++ b/src/os/ObjectMap.h
@@ -15,12 +15,13 @@
 #ifndef OS_KEYVALUESTORE_H
 #define OS_KEYVALUESTORE_H
 
-#include "IndexManager.h"
-#include "SequencerPosition.h"
 #include <string>
 #include <vector>
 #include "include/memory.h"
 #include "kv/KeyValueDB.h"
+#include "common/hobject.h"
+
+class SequencerPosition;
 
 /**
  * Encapsulates the FileStore key value store
diff --git a/src/os/ObjectStore.cc b/src/os/ObjectStore.cc
index e47a94c..62ec739 100644
--- a/src/os/ObjectStore.cc
+++ b/src/os/ObjectStore.cc
@@ -16,14 +16,15 @@
 #include "include/memory.h"
 #include "ObjectStore.h"
 #include "common/Formatter.h"
-#include "FileStore.h"
-#include "MemStore.h"
-#include "KeyValueStore.h"
 #include "common/safe_io.h"
 
+#include "filestore/FileStore.h"
+#include "memstore/MemStore.h"
+#include "keyvaluestore/KeyValueStore.h"
 #if defined(HAVE_LIBAIO)
-#include "newstore/NewStore.h"
+#include "bluestore/BlueStore.h"
 #endif
+#include "kstore/KStore.h"
 
 void decode_str_str_map_to_bl(bufferlist::iterator& p,
 			      bufferlist *out)
@@ -77,11 +78,15 @@ ObjectStore *ObjectStore::create(CephContext *cct,
     return new KeyValueStore(data);
   }
 #if defined(HAVE_LIBAIO)
-  if (type == "newstore" &&
-      cct->check_experimental_feature_enabled("newstore")) {
-    return new NewStore(cct, data);
+  if (type == "bluestore" &&
+      cct->check_experimental_feature_enabled("bluestore")) {
+    return new BlueStore(cct, data);
   }
 #endif
+  if (type == "kstore" &&
+      cct->check_experimental_feature_enabled("kstore")) {
+    return new KStore(cct, data);
+  }
   return NULL;
 }
 
@@ -91,6 +96,14 @@ int ObjectStore::probe_block_device_fsid(
 {
   int r;
 
+#if defined(HAVE_LIBAIO)
+  // first try bluestore -- it has a crc on its header and will fail
+  // reliably.
+  r = BlueStore::get_block_device_fsid(path, fsid);
+  if (r == 0)
+    return r;
+#endif
+
   // okay, try FileStore (journal).
   r = FileStore::get_block_device_fsid(path, fsid);
   if (r == 0)
diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h
index 8f2b749..ba9dd76 100644
--- a/src/os/ObjectStore.h
+++ b/src/os/ObjectStore.h
@@ -1818,6 +1818,9 @@ public:
   virtual bool test_mount_in_use() = 0;
   virtual int mount() = 0;
   virtual int umount() = 0;
+  virtual int fsck() {
+    return -EOPNOTSUPP;
+  }
   virtual unsigned get_max_object_name_length() = 0;
   virtual unsigned get_max_attr_name_length() = 0;
   virtual int mkfs() = 0;  // wipe
@@ -1825,8 +1828,6 @@ public:
   virtual bool needs_journal() = 0;  //< requires a journal
   virtual bool wants_journal() = 0;  //< prefers a journal
   virtual bool allows_journal() = 0; //< allows a journal
-  virtual void set_allow_sharded_objects() = 0;
-  virtual bool get_allow_sharded_objects() = 0;
 
   virtual bool can_sort_nibblewise() {
     return false;   // assume a backend cannot, unless it says otherwise
diff --git a/src/os/bluestore/Allocator.cc b/src/os/bluestore/Allocator.cc
new file mode 100644
index 0000000..e132291
--- /dev/null
+++ b/src/os/bluestore/Allocator.cc
@@ -0,0 +1,16 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "Allocator.h"
+#include "StupidAllocator.h"
+#include "common/debug.h"
+
+#define dout_subsys ceph_subsys_bluestore
+
+Allocator *Allocator::create(string type)
+{
+  if (type == "stupid")
+    return new StupidAllocator;
+  derr << "Allocator::" << __func__ << " unknown alloc type " << type << dendl;
+  return NULL;
+}
diff --git a/src/os/bluestore/Allocator.h b/src/os/bluestore/Allocator.h
new file mode 100644
index 0000000..6df2267
--- /dev/null
+++ b/src/os/bluestore/Allocator.h
@@ -0,0 +1,50 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+#ifndef CEPH_OS_BLUESTORE_ALLOCATOR_H
+#define CEPH_OS_BLUESTORE_ALLOCATOR_H
+
+#include "kv/KeyValueDB.h"
+#include <ostream>
+#include "include/assert.h"
+
+class FreelistManager;
+
+class Allocator {
+public:
+  virtual ~Allocator() {}
+
+  virtual int reserve(uint64_t need) = 0;
+  virtual void unreserve(uint64_t unused) = 0;
+
+  virtual int allocate(
+    uint64_t need_size, uint64_t alloc_unit, int64_t hint,
+    uint64_t *offset, uint32_t *length) = 0;
+
+  virtual int release(
+    uint64_t offset, uint64_t length) = 0;
+
+  virtual void commit_start() = 0;
+  virtual void commit_finish() = 0;
+
+  virtual void dump(std::ostream& out) = 0;
+
+  virtual void init_add_free(uint64_t offset, uint64_t length) = 0;
+  virtual void init_rm_free(uint64_t offset, uint64_t length) = 0;
+
+  virtual uint64_t get_free() = 0;
+
+  virtual void shutdown() = 0;
+
+  static Allocator *create(string type);
+};
+
+#endif
diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc
new file mode 100644
index 0000000..230ea45
--- /dev/null
+++ b/src/os/bluestore/BlockDevice.cc
@@ -0,0 +1,550 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "BlockDevice.h"
+#include "include/types.h"
+#include "include/compat.h"
+#include "common/errno.h"
+#include "common/debug.h"
+#include "common/blkdev.h"
+
+#define dout_subsys ceph_subsys_bdev
+#undef dout_prefix
+#define dout_prefix *_dout << "bdev "
+
+
+void IOContext::aio_wait()
+{
+  Mutex::Locker l(lock);
+  // see _aio_thread for waker logic
+  num_waiting.inc();
+  while (num_running.read() > 0 || num_reading.read() > 0) {
+    dout(10) << __func__ << " " << this
+	     << " waiting for " << num_running.read() << " aios and/or "
+	     << num_reading.read() << " readers to complete" << dendl;
+    cond.Wait(lock);
+  }
+  num_waiting.dec();
+  dout(20) << __func__ << " " << this << " done" << dendl;
+}
+
+// ----------------
+#undef dout_prefix
+#define dout_prefix *_dout << "bdev(" << path << ") "
+
+BlockDevice::BlockDevice(aio_callback_t cb, void *cbpriv)
+  : fd_direct(-1),
+    fd_buffered(-1),
+    size(0), block_size(0),
+    fs(NULL), aio(false), dio(false),
+    debug_lock("BlockDevice::debug_lock"),
+    ioc_reap_lock("BlockDevice::ioc_reap_lock"),
+    flush_lock("BlockDevice::flush_lock"),
+    aio_queue(g_conf->bdev_aio_max_queue_depth),
+    aio_callback(cb),
+    aio_callback_priv(cbpriv),
+    aio_stop(false),
+    aio_thread(this)
+{
+  zeros = buffer::create_page_aligned(1048576);
+  zeros.zero();
+}
+
+int BlockDevice::_lock()
+{
+  struct flock l;
+  memset(&l, 0, sizeof(l));
+  l.l_type = F_WRLCK;
+  l.l_whence = SEEK_SET;
+  l.l_start = 0;
+  l.l_len = 0;
+  int r = ::fcntl(fd_direct, F_SETLK, &l);
+  if (r < 0)
+    return -errno;
+  return 0;
+}
+
+int BlockDevice::open(string p)
+{
+  path = p;
+  int r = 0;
+  dout(1) << __func__ << " path " << path << dendl;
+
+  fd_direct = ::open(path.c_str(), O_RDWR | O_DIRECT);
+  if (fd_direct < 0) {
+    int r = -errno;
+    derr << __func__ << " open got: " << cpp_strerror(r) << dendl;
+    return r;
+  }
+  fd_buffered = ::open(path.c_str(), O_RDWR);
+  if (fd_buffered < 0) {
+    r = -errno;
+    derr << __func__ << " open got: " << cpp_strerror(r) << dendl;
+    goto out_direct;
+  }
+  dio = true;
+  aio = g_conf->bdev_aio;
+  if (!aio) {
+    assert(0 == "non-aio not supported");
+  }
+
+  // disable readahead as it will wreak havoc on our mix of
+  // directio/aio and buffered io.
+  r = posix_fadvise(fd_buffered, 0, 0, POSIX_FADV_RANDOM);
+  if (r < 0) {
+    r = -errno;
+    derr << __func__ << " open got: " << cpp_strerror(r) << dendl;
+    goto out_fail;
+  }
+
+  r = _lock();
+  if (r < 0) {
+    derr << __func__ << " failed to lock " << path << ": " << cpp_strerror(r)
+	 << dendl;
+    goto out_fail;
+  }
+
+  struct stat st;
+  r = ::fstat(fd_direct, &st);
+  if (r < 0) {
+    r = -errno;
+    derr << __func__ << " fstat got " << cpp_strerror(r) << dendl;
+    goto out_fail;
+  }
+  if (S_ISBLK(st.st_mode)) {
+    int64_t s;
+    r = get_block_device_size(fd_direct, &s);
+    if (r < 0) {
+      goto out_fail;
+    }
+    size = s;
+  } else {
+    size = st.st_size;
+  }
+  block_size = st.st_blksize;
+
+  fs = FS::create_by_fd(fd_direct);
+  assert(fs);
+
+  r = _aio_start();
+  assert(r == 0);
+
+  dout(1) << __func__
+	  << " size " << size
+	  << " (" << pretty_si_t(size) << "B)"
+	  << " block_size " << block_size
+	  << " (" << pretty_si_t(block_size) << "B)"
+	  << dendl;
+  return 0;
+
+ out_fail:
+  VOID_TEMP_FAILURE_RETRY(::close(fd_buffered));
+  fd_buffered = -1;
+ out_direct:
+  VOID_TEMP_FAILURE_RETRY(::close(fd_direct));
+  fd_direct = -1;
+  return r;
+}
+
+void BlockDevice::close()
+{
+  dout(1) << __func__ << dendl;
+  _aio_stop();
+
+  assert(fs);
+  delete fs;
+  fs = NULL;
+
+  assert(fd_direct >= 0);
+  VOID_TEMP_FAILURE_RETRY(::close(fd_direct));
+  fd_direct = -1;
+
+  assert(fd_buffered >= 0);
+  VOID_TEMP_FAILURE_RETRY(::close(fd_buffered));
+  fd_buffered = -1;
+
+  path.clear();
+}
+
+int BlockDevice::flush()
+{
+  // serialize flushers, so that we can avoid weird io_since_flush
+  // races (w/ multipler flushers).
+  Mutex::Locker l(flush_lock);
+  if (io_since_flush.read() == 0) {
+    dout(10) << __func__ << " no-op (no ios since last flush)" << dendl;
+    return 0;
+  }
+  dout(10) << __func__ << " start" << dendl;
+  io_since_flush.set(0);
+  if (g_conf->bdev_inject_crash) {
+    // sleep for a moment to give other threads a chance to submit or
+    // wait on io that races with a flush.
+    derr << __func__ << " injecting crash. first we sleep..." << dendl;
+    sleep(3);
+    derr << __func__ << " and now we die" << dendl;
+    assert(0 == "bdev_inject_crash");
+  }
+  utime_t start = ceph_clock_now(NULL);
+  int r = ::fdatasync(fd_direct);
+  utime_t end = ceph_clock_now(NULL);
+  utime_t dur = end - start;
+  if (r < 0) {
+    r = -errno;
+    derr << __func__ << " fdatasync got: " << cpp_strerror(r) << dendl;
+  }
+  dout(5) << __func__ << " in " << dur << dendl;;
+  return r;
+}
+
+int BlockDevice::_aio_start()
+{
+  if (g_conf->bdev_aio) {
+    dout(10) << __func__ << dendl;
+    int r = aio_queue.init();
+    if (r < 0) {
+      derr << __func__ << " failed: " << cpp_strerror(r) << dendl;
+      return r;
+    }
+    aio_thread.create("bstore_aio");
+  }
+  return 0;
+}
+
+void BlockDevice::_aio_stop()
+{
+  if (g_conf->bdev_aio) {
+    dout(10) << __func__ << dendl;
+    aio_stop = true;
+    aio_thread.join();
+    aio_stop = false;
+    aio_queue.shutdown();
+  }
+}
+
+void BlockDevice::_aio_thread()
+{
+  dout(10) << __func__ << " start" << dendl;
+  while (!aio_stop) {
+    dout(40) << __func__ << " polling" << dendl;
+    int max = 16;
+    FS::aio_t *aio[max];
+    int r = aio_queue.get_next_completed(g_conf->bdev_aio_poll_ms,
+					 aio, max);
+    if (r < 0) {
+      derr << __func__ << " got " << cpp_strerror(r) << dendl;
+    }
+    if (r > 0) {
+      dout(30) << __func__ << " got " << r << " completed aios" << dendl;
+      for (int i = 0; i < r; ++i) {
+	IOContext *ioc = static_cast<IOContext*>(aio[i]->priv);
+	_aio_log_finish(ioc, aio[i]->offset, aio[i]->length);
+	int left = ioc->num_running.dec();
+	int r = aio[i]->get_return_value();
+	dout(10) << __func__ << " finished aio " << aio[i] << " r " << r
+		 << " ioc " << ioc
+		 << " with " << left << " aios left" << dendl;
+	assert(r >= 0);
+	if (left == 0) {
+	  // check waiting count before doing callback (which may
+	  // destroy this ioc).
+	  if (ioc->num_waiting.read()) {
+	    dout(20) << __func__ << " waking waiter" << dendl;
+	    Mutex::Locker l(ioc->lock);
+	    ioc->cond.Signal();
+	  }
+	  if (ioc->priv) {
+	    aio_callback(aio_callback_priv, ioc->priv);
+	  }
+	}
+      }
+    }
+    if (ioc_reap_count.read()) {
+      Mutex::Locker l(ioc_reap_lock);
+      for (auto p : ioc_reap_queue) {
+	dout(20) << __func__ << " reap ioc " << p << dendl;
+	delete p;
+      }
+      ioc_reap_queue.clear();
+      ioc_reap_count.dec();
+    }
+  }
+  dout(10) << __func__ << " end" << dendl;
+}
+
+void BlockDevice::_aio_log_start(
+  IOContext *ioc,
+  uint64_t offset,
+  uint64_t length)
+{
+  dout(20) << __func__ << " " << offset << "~" << length << dendl;
+  if (g_conf->bdev_debug_inflight_ios) {
+    Mutex::Locker l(debug_lock);
+    if (debug_inflight.intersects(offset, length)) {
+      derr << __func__ << " inflight overlap of "
+	   << offset << "~" << length
+	   << " with " << debug_inflight << dendl;
+      assert(0);
+    }
+    debug_inflight.insert(offset, length);
+  }
+}
+
+void BlockDevice::_aio_log_finish(
+  IOContext *ioc,
+  uint64_t offset,
+  uint64_t length)
+{
+  dout(20) << __func__ << " " << aio << " " << offset << "~" << length << dendl;
+  if (g_conf->bdev_debug_inflight_ios) {
+    Mutex::Locker l(debug_lock);
+    debug_inflight.erase(offset, length);
+  }
+}
+
+void BlockDevice::aio_submit(IOContext *ioc)
+{
+  dout(20) << __func__ << " ioc " << ioc
+	   << " pending " << ioc->num_pending.read()
+	   << " running " << ioc->num_running.read()
+	   << dendl;
+  // move these aside, and get our end iterator position now, as the
+  // aios might complete as soon as they are submitted and queue more
+  // wal aio's.
+  list<FS::aio_t>::iterator e = ioc->running_aios.begin();
+  ioc->running_aios.splice(e, ioc->pending_aios);
+  list<FS::aio_t>::iterator p = ioc->running_aios.begin();
+
+  int pending = ioc->num_pending.read();
+  ioc->num_running.add(pending);
+  ioc->num_pending.sub(pending);
+  assert(ioc->num_pending.read() == 0);  // we should be only thread doing this
+
+  bool done = false;
+  while (!done) {
+    FS::aio_t& aio = *p;
+    aio.priv = static_cast<void*>(ioc);
+    dout(20) << __func__ << "  aio " << &aio << " fd " << aio.fd
+	     << " " << aio.offset << "~" << aio.length << dendl;
+    for (vector<iovec>::iterator q = aio.iov.begin(); q != aio.iov.end(); ++q)
+      dout(30) << __func__ << "   iov " << (void*)q->iov_base
+	       << " len " << q->iov_len << dendl;
+
+    // be careful: as soon as we submit aio we race with completion.
+    // since we are holding a ref take care not to dereference txc at
+    // all after that point.
+    list<FS::aio_t>::iterator cur = p;
+    ++p;
+    done = (p == e);
+
+    // do not dereference txc (or it's contents) after we submit (if
+    // done == true and we don't loop)
+    int retries = 0;
+    int r = aio_queue.submit(*cur, &retries);
+    if (retries)
+      derr << __func__ << " retries " << retries << dendl;
+    if (r) {
+      derr << " aio submit got " << cpp_strerror(r) << dendl;
+      assert(r == 0);
+    }
+  }
+}
+
+int BlockDevice::aio_write(
+  uint64_t off,
+  bufferlist &bl,
+  IOContext *ioc,
+  bool buffered)
+{
+  uint64_t len = bl.length();
+  dout(20) << __func__ << " " << off << "~" << len << dendl;
+  assert(off % block_size == 0);
+  assert(len % block_size == 0);
+  assert(len > 0);
+  assert(off < size);
+  assert(off + len <= size);
+
+  if (!bl.is_n_page_sized() || !bl.is_page_aligned()) {
+    dout(20) << __func__ << " rebuilding buffer to be page-aligned" << dendl;
+    bl.rebuild();
+  }
+
+  dout(40) << "data: ";
+  bl.hexdump(*_dout);
+  *_dout << dendl;
+
+  _aio_log_start(ioc, off, bl.length());
+
+#ifdef HAVE_LIBAIO
+  if (aio && dio && !buffered) {
+    ioc->pending_aios.push_back(FS::aio_t(ioc, fd_direct));
+    ioc->num_pending.inc();
+    FS::aio_t& aio = ioc->pending_aios.back();
+    if (g_conf->bdev_inject_crash &&
+	rand() % g_conf->bdev_inject_crash == 0) {
+      derr << __func__ << " bdev_inject_crash: dropping io " << off << "~" << len
+	   << dendl;
+      // generate a real io so that aio_wait behaves properly, but make it
+      // a read instead of write, and toss the result.
+      aio.pread(off, len);
+    } else {
+      bl.prepare_iov(&aio.iov);
+      for (unsigned i=0; i<aio.iov.size(); ++i) {
+	dout(30) << "aio " << i << " " << aio.iov[i].iov_base
+		 << " " << aio.iov[i].iov_len << dendl;
+      }
+      aio.bl.claim_append(bl);
+      aio.pwritev(off);
+    }
+    dout(5) << __func__ << " " << off << "~" << len << " aio " << &aio << dendl;
+  } else
+#endif
+  {
+    dout(5) << __func__ << " " << off << "~" << len << " buffered" << dendl;
+    if (g_conf->bdev_inject_crash &&
+	rand() % g_conf->bdev_inject_crash == 0) {
+      derr << __func__ << " bdev_inject_crash: dropping io " << off << "~" << len
+	   << dendl;
+      return 0;
+    }
+    vector<iovec> iov;
+    bl.prepare_iov(&iov);
+    int r = ::pwritev(buffered ? fd_buffered : fd_direct,
+		      &iov[0], iov.size(), off);
+    if (r < 0) {
+      derr << __func__ << " pwritev error: " << cpp_strerror(r) << dendl;
+      return r;
+    }
+    if (buffered) {
+      // initiate IO (but do not wait)
+      ::sync_file_range(fd_buffered, off, len, SYNC_FILE_RANGE_WRITE);
+    }
+  }
+
+  io_since_flush.set(1);
+  return 0;
+}
+
+int BlockDevice::aio_zero(
+  uint64_t off,
+  uint64_t len,
+  IOContext *ioc)
+{
+  dout(5) << __func__ << " " << off << "~" << len << dendl;
+  assert(off % block_size == 0);
+  assert(len % block_size == 0);
+  assert(len > 0);
+  assert(off < size);
+  assert(off + len <= size);
+
+  bufferlist bl;
+  while (len > 0) {
+    bufferlist t;
+    t.append(zeros, 0, MIN(zeros.length(), len));
+    len -= t.length();
+    bl.claim_append(t);
+  }
+  bufferlist foo;
+  // note: this works with aio only becaues the actual buffer is
+  // this->zeros, which is page-aligned and never freed.
+  return aio_write(off, bl, ioc, false);
+}
+
+int BlockDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
+		      IOContext *ioc,
+		      bool buffered)
+{
+  dout(5) << __func__ << " " << off << "~" << len << dendl;
+  assert(off % block_size == 0);
+  assert(len % block_size == 0);
+  assert(len > 0);
+  assert(off < size);
+  assert(off + len <= size);
+
+  _aio_log_start(ioc, off, len);
+  ioc->num_reading.inc();;
+
+  bufferptr p = buffer::create_page_aligned(len);
+  int r = ::pread(buffered ? fd_buffered : fd_direct,
+		  p.c_str(), len, off);
+  if (r < 0) {
+    r = -errno;
+    goto out;
+  }
+  pbl->clear();
+  pbl->push_back(p);
+
+  dout(40) << "data: ";
+  pbl->hexdump(*_dout);
+  *_dout << dendl;
+
+ out:
+  _aio_log_finish(ioc, off, len);
+  ioc->num_reading.dec();
+  if (ioc->num_waiting.read()) {
+    dout(20) << __func__ << " waking waiter" << dendl;
+    Mutex::Locker l(ioc->lock);
+    ioc->cond.Signal();
+  }
+  return r < 0 ? r : 0;
+}
+
+int BlockDevice::read_buffered(uint64_t off, uint64_t len, char *buf)
+{
+  dout(5) << __func__ << " " << off << "~" << len << dendl;
+  assert(len > 0);
+  assert(off < size);
+  assert(off + len <= size);
+
+  int r = 0;
+  char *t = buf;
+  uint64_t left = len;
+  while (left > 0) {
+    r = ::pread(fd_buffered, t, left, off);
+    if (r < 0) {
+      r = -errno;
+      goto out;
+    }
+    off += r;
+    t += r;
+    left -= r;
+  }
+
+  dout(40) << __func__ << " data: ";
+  bufferlist bl;
+  bl.append(buf, len);
+  bl.hexdump(*_dout);
+  *_dout << dendl;
+
+ out:
+  return r < 0 ? r : 0;
+}
+
+int BlockDevice::invalidate_cache(uint64_t off, uint64_t len)
+{
+  dout(5) << __func__ << " " << off << "~" << len << dendl;
+  assert(off % block_size == 0);
+  assert(len % block_size == 0);
+  int r = posix_fadvise(fd_buffered, off, len, POSIX_FADV_DONTNEED);
+  if (r < 0) {
+    r = -errno;
+    derr << __func__ << " " << off << "~" << len << " error: "
+	 << cpp_strerror(r) << dendl;
+  }
+  return r;
+}
+
+void BlockDevice::queue_reap_ioc(IOContext *ioc)
+{
+  Mutex::Locker l(ioc_reap_lock);
+  if (ioc_reap_count.read() == 0)
+    ioc_reap_count.inc();
+  ioc_reap_queue.push_back(ioc);
+}
diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h
new file mode 100644
index 0000000..77bb8eb
--- /dev/null
+++ b/src/os/bluestore/BlockDevice.h
@@ -0,0 +1,120 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_OS_BLUESTORE_BLOCKDEVICE
+#define CEPH_OS_BLUESTORE_BLOCKDEVICE
+
+#include "os/fs/FS.h"
+#include "include/interval_set.h"
+
+/// track in-flight io
+struct IOContext {
+  void *priv;
+
+  Mutex lock;
+  Cond cond;
+  //interval_set<uint64_t> blocks;  ///< blocks with aio in flight
+
+  list<FS::aio_t> pending_aios;    ///< not yet submitted
+  list<FS::aio_t> running_aios;    ///< submitting or submitted
+  atomic_t num_pending;
+  atomic_t num_running;
+  atomic_t num_reading;
+  atomic_t num_waiting;
+
+  IOContext(void *p)
+    : priv(p),
+      lock("IOContext::lock")
+    {}
+
+  // no copying
+  IOContext(const IOContext& other);
+  IOContext &operator=(const IOContext& other);
+
+  bool has_aios() {
+    Mutex::Locker l(lock);
+    return num_pending.read() + num_running.read();
+  }
+
+  void aio_wait();
+};
+
+class BlockDevice {
+public:
+  typedef void (*aio_callback_t)(void *handle, void *aio);
+
+private:
+  int fd_direct, fd_buffered;
+  uint64_t size;
+  uint64_t block_size;
+  string path;
+  FS *fs;
+  bool aio, dio;
+  bufferptr zeros;
+
+  Mutex debug_lock;
+  interval_set<uint64_t> debug_inflight;
+
+  Mutex ioc_reap_lock;
+  vector<IOContext*> ioc_reap_queue;
+  atomic_t ioc_reap_count;
+
+  Mutex flush_lock;
+  atomic_t io_since_flush;
+
+  FS::aio_queue_t aio_queue;
+  aio_callback_t aio_callback;
+  void *aio_callback_priv;
+  bool aio_stop;
+
+  struct AioCompletionThread : public Thread {
+    BlockDevice *bdev;
+    AioCompletionThread(BlockDevice *b) : bdev(b) {}
+    void *entry() {
+      bdev->_aio_thread();
+      return NULL;
+    }
+  } aio_thread;
+
+  void _aio_thread();
+  int _aio_start();
+  void _aio_stop();
+
+  void _aio_log_start(IOContext *ioc, uint64_t offset, uint64_t length);
+  void _aio_log_finish(IOContext *ioc, uint64_t offset, uint64_t length);
+
+  int _lock();
+
+public:
+  BlockDevice(aio_callback_t cb, void *cbpriv);
+
+  void aio_submit(IOContext *ioc);
+
+  uint64_t get_size() const {
+    return size;
+  }
+  uint64_t get_block_size() const {
+    return block_size;
+  }
+
+  int read(uint64_t off, uint64_t len, bufferlist *pbl,
+	   IOContext *ioc,
+	   bool buffered);
+  int read_buffered(uint64_t off, uint64_t len, char *buf);
+
+  int aio_write(uint64_t off, bufferlist& bl,
+		IOContext *ioc,
+		bool buffered);
+  int aio_zero(uint64_t off, uint64_t len,
+	       IOContext *ioc);
+  int flush();
+
+  void queue_reap_ioc(IOContext *ioc);
+
+  // for managing buffered readers/writers
+  int invalidate_cache(uint64_t off, uint64_t len);
+  int open(string path);
+  void close();
+};
+
+#endif
diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc
new file mode 100644
index 0000000..d32d7d6
--- /dev/null
+++ b/src/os/bluestore/BlueFS.cc
@@ -0,0 +1,1564 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "BlueFS.h"
+
+#include "common/debug.h"
+#include "common/errno.h"
+#include "BlockDevice.h"
+#include "Allocator.h"
+#include "StupidAllocator.h"
+
+
+#define dout_subsys ceph_subsys_bluefs
+#undef dout_prefix
+#define dout_prefix *_dout << "bluefs "
+
+BlueFS::BlueFS()
+  : lock("BlueFS::lock"),
+    ino_last(0),
+    log_seq(0),
+    log_writer(NULL)
+{
+}
+
+BlueFS::~BlueFS()
+{
+  for (auto p : bdev) {
+    p->close();
+    delete p;
+  }
+  for (auto p : ioc) {
+    delete p;
+  }
+}
+
+/*static void aio_cb(void *priv, void *priv2)
+{
+  BlueFS *fs = static_cast<BlueFS*>(priv);
+  if (priv2)
+    fs->_aio_finish(priv2);
+    }*/
+
+int BlueFS::add_block_device(unsigned id, string path)
+{
+  dout(10) << __func__ << " bdev " << id << " path " << path << dendl;
+  assert(id == bdev.size());
+  BlockDevice *b = new BlockDevice(NULL, NULL); //aio_cb, this);
+  int r = b->open(path);
+  if (r < 0) {
+    delete b;
+    return r;
+  }
+  dout(1) << __func__ << " bdev " << id << " path " << path
+	  << " size " << pretty_si_t(b->get_size()) << "B" << dendl;
+  bdev.push_back(b);
+  ioc.push_back(new IOContext(NULL));
+  block_all.resize(bdev.size());
+  return 0;
+}
+
+uint64_t BlueFS::get_block_device_size(unsigned id)
+{
+  return bdev[id]->get_size();
+}
+
+void BlueFS::add_block_extent(unsigned id, uint64_t offset, uint64_t length)
+{
+  Mutex::Locker l(lock);
+  dout(1) << __func__ << " bdev " << id << " " << offset << "~" << length
+	  << dendl;
+  assert(id < bdev.size());
+  assert(bdev[id]->get_size() >= offset + length);
+  block_all[id].insert(offset, length);
+
+  if (alloc.size()) {
+    log_t.op_alloc_add(id, offset, length);
+    int r = _flush_log();
+    assert(r == 0);
+    alloc[id]->init_add_free(offset, length);
+  }
+  dout(10) << __func__ << " done" << dendl;
+}
+
+int BlueFS::reclaim_blocks(unsigned id, uint64_t want,
+			   uint64_t *offset, uint32_t *length)
+{
+  dout(1) << __func__ << " bdev " << id << " want " << want << dendl;
+  assert(id < alloc.size());
+  int r = alloc[id]->reserve(want);
+  assert(r == 0); // caller shouldn't ask for more than they can get
+
+  r = alloc[id]->allocate(want, g_conf->bluefs_alloc_size, 0,
+			    offset, length);
+  assert(r >= 0);
+  if (*length < want)
+    alloc[id]->unreserve(want - *length);
+
+  block_all[id].erase(*offset, *length);
+  log_t.op_alloc_rm(id, *offset, *length);
+  r = _flush_log();
+  assert(r == 0);
+
+  dout(1) << __func__ << " bdev " << id << " want " << want
+	  << " got " << *offset << "~" << *length << dendl;
+  return 0;
+}
+
+uint64_t BlueFS::get_total(unsigned id)
+{
+  Mutex::Locker l(lock);
+  assert(id < block_all.size());
+  uint64_t r = 0;
+  interval_set<uint64_t>& p = block_all[id];
+  for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
+    r += q.get_len();
+  }
+  return r;
+}
+
+uint64_t BlueFS::get_free(unsigned id)
+{
+  Mutex::Locker l(lock);
+  assert(id < alloc.size());
+  return alloc[id]->get_free();
+}
+
+void BlueFS::get_usage(vector<pair<uint64_t,uint64_t>> *usage)
+{
+  Mutex::Locker l(lock);
+  usage->resize(bdev.size());
+  for (unsigned id = 0; id < bdev.size(); ++id) {
+    uint64_t total = 0;
+    interval_set<uint64_t>& p = block_all[id];
+    for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
+      total += q.get_len();
+    }
+    (*usage)[id].first = alloc[id]->get_free();
+    (*usage)[id].second = total;
+    uint64_t used = (total - (*usage)[id].first) * 100 / total;
+    dout(10) << __func__ << " bdev " << id
+	     << " free " << (*usage)[id].first
+	     << " (" << pretty_si_t((*usage)[id].first) << "B)"
+	     << " / " << (*usage)[id].second
+	     << " (" << pretty_si_t((*usage)[id].second) << "B)"
+	     << ", used " << used << "%"
+	     << dendl;
+  }
+}
+
+int BlueFS::get_block_extents(unsigned id, interval_set<uint64_t> *extents)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " bdev " << id << dendl;
+  if (id >= block_all.size())
+    return -EINVAL;
+  *extents = block_all[id];
+  return 0;
+}
+
+int BlueFS::mkfs(uuid_d osd_uuid)
+{
+  dout(1) << __func__
+	  << " osd_uuid " << osd_uuid
+	  << dendl;
+  assert(bdev.size() >= 1);
+
+  _init_alloc();
+
+  super.osd_uuid = osd_uuid;
+  super.uuid.generate_random();
+  dout(1) << __func__ << " uuid " << super.uuid << dendl;
+
+  // init log
+  FileRef log_file = new File;
+  log_file->fnode.ino = 1;
+  log_file->fnode.prefer_bdev = bdev.size() - 1;
+  _allocate(log_file->fnode.prefer_bdev,
+	    g_conf->bluefs_max_log_runway,
+	    &log_file->fnode.extents);
+  log_writer = new FileWriter(log_file, bdev.size());
+
+  // initial txn
+  log_t.op_init();
+  for (unsigned bdev = 0; bdev < block_all.size(); ++bdev) {
+    interval_set<uint64_t>& p = block_all[bdev];
+    for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
+      dout(20) << __func__ << " op_alloc_add " << bdev << " " << q.get_start()
+	       << "~" << q.get_len() << dendl;
+      log_t.op_alloc_add(bdev, q.get_start(), q.get_len());
+    }
+  }
+  _flush_log();
+
+  // write supers
+  super.version = 1;
+  super.block_size = bdev[0]->get_block_size();
+  super.log_fnode = log_file->fnode;
+  _write_super();
+  _flush_bdev();
+
+  // clean up
+  super = bluefs_super_t();
+  _close_writer(log_writer);
+  log_writer = NULL;
+  block_all.clear();
+  _stop_alloc();
+
+  dout(10) << __func__ << " success" << dendl;
+  return 0;
+}
+
+void BlueFS::_init_alloc()
+{
+  dout(20) << __func__ << dendl;
+  alloc.resize(bdev.size());
+  for (unsigned id = 0; id < bdev.size(); ++id) {
+    alloc[id] = new StupidAllocator;
+    interval_set<uint64_t>& p = block_all[id];
+    for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
+      alloc[id]->init_add_free(q.get_start(), q.get_len());
+    }
+  }
+}
+
+void BlueFS::_stop_alloc()
+{
+  dout(20) << __func__ << dendl;
+  for (auto p : alloc) {
+    delete p;
+  }
+  alloc.clear();
+}
+
+int BlueFS::mount()
+{
+  dout(1) << __func__ << dendl;
+  assert(!bdev.empty());
+
+  int r = _open_super();
+  if (r < 0) {
+    derr << __func__ << " failed to open super: " << cpp_strerror(r) << dendl;
+    goto out;
+  }
+
+  block_all.clear();
+  block_all.resize(bdev.size());
+  _init_alloc();
+
+  r = _replay();
+  if (r < 0) {
+    derr << __func__ << " failed to replay log: " << cpp_strerror(r) << dendl;
+    goto out;
+  }
+
+  // init freelist
+  for (auto& p : file_map) {
+    dout(30) << __func__ << " noting alloc for " << p.second->fnode << dendl;
+    for (auto& q : p.second->fnode.extents) {
+      alloc[q.bdev]->init_rm_free(q.offset, q.length);
+    }
+  }
+
+  // set up the log for future writes
+  log_writer = new FileWriter(_get_file(1), bdev.size());
+  assert(log_writer->file->fnode.ino == 1);
+  log_writer->pos = log_writer->file->fnode.size;
+  dout(10) << __func__ << " log write pos set to " << log_writer->pos << dendl;
+  return 0;
+
+ out:
+  super = bluefs_super_t();
+  return r;
+}
+
+void BlueFS::umount()
+{
+  dout(1) << __func__ << dendl;
+
+  sync_metadata();
+
+  _close_writer(log_writer);
+  log_writer = NULL;
+
+  block_all.clear();
+  _stop_alloc();
+  file_map.clear();
+  for (auto& p : dir_map) {
+    delete p.second;
+  }
+  super = bluefs_super_t();
+  log_t.clear();
+}
+
+int BlueFS::fsck()
+{
+  Mutex::Locker l(lock);
+  dout(1) << __func__ << dendl;
+  // hrm, i think we check everything on mount...
+  return 0;
+}
+
+int BlueFS::_write_super()
+{
+  // build superblock
+  bufferlist bl;
+  ::encode(super, bl);
+  uint32_t crc = bl.crc32c(-1);
+  ::encode(crc, bl);
+  assert(bl.length() <= get_super_length());
+  bufferptr z(get_super_length() - bl.length());
+  z.zero();
+  bl.append(z);
+  bl.rebuild();
+
+  IOContext ioc(NULL);
+  bdev[0]->aio_write(get_super_offset(), bl, &ioc, false);
+  bdev[0]->aio_submit(&ioc);
+  ioc.aio_wait();
+  dout(20) << __func__ << " v " << super.version << " crc " << crc
+	   << " offset " << get_super_offset() << dendl;
+  return 0;
+}
+
+int BlueFS::_open_super()
+{
+  dout(10) << __func__ << dendl;
+
+  bufferlist bl, t;
+  uint32_t expected_crc, crc;
+  int r;
+
+  // always the second block
+  r = bdev[0]->read(get_super_offset(), get_super_length(),
+		    &bl, ioc[0], false);
+  if (r < 0)
+    return r;
+
+  bufferlist::iterator p = bl.begin();
+  ::decode(super, p);
+  {
+    bufferlist t;
+    t.substr_of(bl, 0, p.get_off());
+    crc = t.crc32c(-1);
+  }
+  ::decode(expected_crc, p);
+  if (crc != expected_crc) {
+    derr << __func__ << " bad crc on superblock, expected " << expected_crc
+	 << " != actual " << crc << dendl;
+    return -EIO;
+  }
+  dout(10) << __func__ << " superblock " << super.version << dendl;
+  dout(10) << __func__ << " log_fnode " << super.log_fnode << dendl;
+  return 0;
+}
+
+int BlueFS::_replay()
+{
+  dout(10) << __func__ << dendl;
+  ino_last = 1;  // by the log
+  log_seq = 0;
+
+  FileRef log_file = _get_file(1);
+  log_file->fnode = super.log_fnode;
+
+  FileReader *log_reader = new FileReader(
+    log_file, g_conf->bluefs_alloc_size,
+    false,  // !random
+    true);  // ignore eof
+  while (true) {
+    assert((log_reader->buf.pos & ~super.block_mask()) == 0);
+    uint64_t pos = log_reader->buf.pos;
+    bufferlist bl;
+    {
+      int r = _read(log_reader, &log_reader->buf, pos, super.block_size,
+		    &bl, NULL);
+      assert(r == (int)super.block_size);
+    }
+    uint64_t more = 0;
+    uint64_t seq;
+    uuid_d uuid;
+    {
+      bufferlist::iterator p = bl.begin();
+      __u8 a, b;
+      uint32_t len;
+      ::decode(a, p);
+      ::decode(b, p);
+      ::decode(len, p);
+      ::decode(uuid, p);
+      ::decode(seq, p);
+      if (len + 6 > bl.length()) {
+	more = ROUND_UP_TO(len + 6 - bl.length(), super.block_size);
+      }
+    }
+    if (uuid != super.uuid) {
+      dout(10) << __func__ << " " << pos << ": stop: uuid " << uuid
+	       << " != super.uuid " << super.uuid << dendl;
+      break;
+    }
+    if (seq != log_seq + 1) {
+      dout(10) << __func__ << " " << pos << ": stop: seq " << seq
+	       << " != expected " << log_seq + 1 << dendl;
+      break;
+    }
+    if (more) {
+      dout(20) << __func__ << "  need " << more << " more bytes" << dendl;
+      bufferlist t;
+      int r = _read(log_reader, &log_reader->buf, pos + super.block_size, more,
+		    &t, NULL);
+      if (r < (int)more) {
+	dout(10) << __func__ << " " << pos << ": stop: len is "
+		 << bl.length() + more << ", which is past eof" << dendl;
+	break;
+      }
+      assert(r == (int)more);
+      bl.claim_append(t);
+    }
+    bluefs_transaction_t t;
+    try {
+      bufferlist::iterator p = bl.begin();
+      ::decode(t, p);
+    }
+    catch (buffer::error& e) {
+      dout(10) << __func__ << " " << pos << ": stop: failed to decode: "
+	       << e.what() << dendl;
+      delete log_reader;
+      return -EIO;
+    }
+    assert(seq == t.seq);
+    dout(10) << __func__ << " " << pos << ": " << t << dendl;
+
+    bufferlist::iterator p = t.op_bl.begin();
+    while (!p.end()) {
+      __u8 op;
+      ::decode(op, p);
+      switch (op) {
+
+      case bluefs_transaction_t::OP_INIT:
+	dout(20) << __func__ << " " << pos << ":  op_init" << dendl;
+	assert(t.seq == 1);
+	break;
+
+      case bluefs_transaction_t::OP_JUMP_SEQ:
+        {
+	  uint64_t next_seq;
+	  ::decode(next_seq, p);
+	  dout(20) << __func__ << " " << pos << ":  op_jump_seq "
+		   << next_seq << dendl;
+	  assert(next_seq >= log_seq);
+	  log_seq = next_seq - 1; // we will increment it below
+	}
+	break;
+
+      case bluefs_transaction_t::OP_ALLOC_ADD:
+        {
+	  __u8 id;
+	  uint64_t offset, length;
+	  ::decode(id, p);
+	  ::decode(offset, p);
+	  ::decode(length, p);
+	  dout(20) << __func__ << " " << pos << ":  op_alloc_add "
+		   << " " << (int)id << ":" << offset << "~" << length << dendl;
+	  block_all[id].insert(offset, length);
+	  alloc[id]->init_add_free(offset, length);
+	}
+	break;
+
+      case bluefs_transaction_t::OP_ALLOC_RM:
+        {
+	  __u8 id;
+	  uint64_t offset, length;
+	  ::decode(id, p);
+	  ::decode(offset, p);
+	  ::decode(length, p);
+	  dout(20) << __func__ << " " << pos << ":  op_alloc_add "
+		   << " " << (int)id << ":" << offset << "~" << length << dendl;
+	  block_all[id].erase(offset, length);
+	  alloc[id]->init_rm_free(offset, length);
+	}
+	break;
+
+      case bluefs_transaction_t::OP_DIR_LINK:
+        {
+	  string dirname, filename;
+	  uint64_t ino;
+	  ::decode(dirname, p);
+	  ::decode(filename, p);
+	  ::decode(ino, p);
+	  dout(20) << __func__ << " " << pos << ":  op_dir_link "
+		   << " " << dirname << "/" << filename << " to " << ino
+		   << dendl;
+	  FileRef file = _get_file(ino);
+	  assert(file->fnode.ino);
+	  map<string,Dir*>::iterator q = dir_map.find(dirname);
+	  assert(q != dir_map.end());
+	  map<string,FileRef>::iterator r = q->second->file_map.find(filename);
+	  assert(r == q->second->file_map.end());
+	  q->second->file_map[filename] = file;
+	  ++file->refs;
+	}
+	break;
+
+      case bluefs_transaction_t::OP_DIR_UNLINK:
+        {
+	  string dirname, filename;
+	  ::decode(dirname, p);
+	  ::decode(filename, p);
+	  dout(20) << __func__ << " " << pos << ":  op_dir_unlink "
+		   << " " << dirname << "/" << filename << dendl;
+	  map<string,Dir*>::iterator q = dir_map.find(dirname);
+	  assert(q != dir_map.end());
+	  map<string,FileRef>::iterator r = q->second->file_map.find(filename);
+	  assert(r != q->second->file_map.end());
+	  --r->second->refs;
+	  q->second->file_map.erase(r);
+	}
+	break;
+
+      case bluefs_transaction_t::OP_DIR_CREATE:
+        {
+	  string dirname;
+	  ::decode(dirname, p);
+	  dout(20) << __func__ << " " << pos << ":  op_dir_create " << dirname
+		   << dendl;
+	  map<string,Dir*>::iterator q = dir_map.find(dirname);
+	  assert(q == dir_map.end());
+	  dir_map[dirname] = new Dir;
+	}
+	break;
+
+      case bluefs_transaction_t::OP_DIR_REMOVE:
+        {
+	  string dirname;
+	  ::decode(dirname, p);
+	  dout(20) << __func__ << " " << pos << ":  op_dir_remove " << dirname
+		   << dendl;
+	  map<string,Dir*>::iterator q = dir_map.find(dirname);
+	  assert(q != dir_map.end());
+	  assert(q->second->file_map.empty());
+	  delete q->second;
+	  dir_map.erase(q);
+	}
+	break;
+
+      case bluefs_transaction_t::OP_FILE_UPDATE:
+        {
+	  bluefs_fnode_t fnode;
+	  ::decode(fnode, p);
+	  dout(20) << __func__ << " " << pos << ":  op_file_update "
+		   << " " << fnode << dendl;
+	  FileRef f = _get_file(fnode.ino);
+	  f->fnode = fnode;
+	  if (fnode.ino > ino_last) {
+	    ino_last = fnode.ino;
+	  }
+	}
+	break;
+
+      case bluefs_transaction_t::OP_FILE_REMOVE:
+        {
+	  uint64_t ino;
+	  ::decode(ino, p);
+	  dout(20) << __func__ << " " << pos << ":  op_file_remove " << ino
+		   << dendl;
+	  auto p = file_map.find(ino);
+	  assert(p != file_map.end());
+	  file_map.erase(p);
+	}
+	break;
+
+      default:
+	derr << __func__ << " " << pos << ": stop: unrecognized op " << (int)op
+	     << dendl;
+	delete log_reader;
+        return -EIO;
+      }
+    }
+    assert(p.end());
+
+    // we successfully replayed the transaction; bump the seq and log size
+    ++log_seq;
+    log_file->fnode.size = log_reader->buf.pos;
+  }
+
+  dout(10) << __func__ << " log file size was " << log_file->fnode.size << dendl;
+  delete log_reader;
+
+  // verify file link counts are all >0
+  for (auto& p : file_map) {
+    if (p.second->refs == 0 &&
+	p.second->fnode.ino > 1) {
+      derr << __func__ << " file with link count 0: " << p.second->fnode
+	   << dendl;
+      return -EIO;
+    }
+  }
+
+  dout(10) << __func__ << " done" << dendl;
+  return 0;
+}
+
+BlueFS::FileRef BlueFS::_get_file(uint64_t ino)
+{
+  auto p = file_map.find(ino);
+  if (p == file_map.end()) {
+    FileRef f = new File;
+    file_map[ino] = f;
+    dout(30) << __func__ << " ino " << ino << " = " << f
+	     << " (new)" << dendl;
+    return f;
+  } else {
+    dout(30) << __func__ << " ino " << ino << " = " << p->second << dendl;
+    return p->second;
+  }
+}
+
+void BlueFS::_drop_link(FileRef file)
+{
+  dout(20) << __func__ << " had refs " << file->refs
+	   << " on " << file->fnode << dendl;
+  --file->refs;
+  if (file->refs == 0) {
+    dout(20) << __func__ << " destroying " << file->fnode << dendl;
+    assert(file->num_reading.read() == 0);
+    log_t.op_file_remove(file->fnode.ino);
+    for (auto& r : file->fnode.extents) {
+      alloc[r.bdev]->release(r.offset, r.length);
+    }
+    file_map.erase(file->fnode.ino);
+    file->deleted = true;
+    if (file->dirty) {
+      file->dirty = false;
+      dirty_files.erase(dirty_files.iterator_to(*file));
+    }
+  }
+}
+
+int BlueFS::_read_random(
+  FileReader *h,         ///< [in] read from here
+  uint64_t off,          ///< [in] offset
+  size_t len,            ///< [in] this many bytes
+  char *out)             ///< [out] optional: or copy it here
+{
+  dout(10) << __func__ << " h " << h << " " << off << "~" << len
+	   << " from " << h->file->fnode << dendl;
+
+  h->file->num_reading.inc();
+
+  if (!h->ignore_eof &&
+      off + len > h->file->fnode.size) {
+    if (off > h->file->fnode.size)
+      len = 0;
+    else
+      len = h->file->fnode.size - off;
+    dout(20) << __func__ << " reaching (or past) eof, len clipped to "
+	     << len << dendl;
+  }
+
+  int ret = 0;
+  while (len > 0) {
+    uint64_t x_off = 0;
+    vector<bluefs_extent_t>::iterator p = h->file->fnode.seek(off, &x_off);
+    uint64_t l = MIN(p->length - x_off, len);
+    if (!h->ignore_eof &&
+	off + l > h->file->fnode.size) {
+      l = h->file->fnode.size - off;
+    }
+    dout(20) << __func__ << " read buffered " << x_off << "~" << l << " of "
+	       << *p << dendl;
+    int r = bdev[p->bdev]->read_buffered(p->offset + x_off, l, out);
+    assert(r == 0);
+    off += l;
+    len -= l;
+    ret += l;
+    out += l;
+  }
+
+  dout(20) << __func__ << " got " << ret << dendl;
+  h->file->num_reading.dec();
+  return ret;
+}
+
+int BlueFS::_read(
+  FileReader *h,         ///< [in] read from here
+  FileReaderBuffer *buf, ///< [in] reader state
+  uint64_t off,          ///< [in] offset
+  size_t len,            ///< [in] this many bytes
+  bufferlist *outbl,     ///< [out] optional: reference the result here
+  char *out)             ///< [out] optional: or copy it here
+{
+  dout(10) << __func__ << " h " << h << " " << off << "~" << len
+	   << " from " << h->file->fnode << dendl;
+
+  h->file->num_reading.inc();
+
+  if (!h->ignore_eof &&
+      off + len > h->file->fnode.size) {
+    if (off > h->file->fnode.size)
+      len = 0;
+    else
+      len = h->file->fnode.size - off;
+    dout(20) << __func__ << " reaching (or past) eof, len clipped to "
+	     << len << dendl;
+  }
+  if (outbl)
+    outbl->clear();
+
+  int ret = 0;
+  while (len > 0) {
+    int left;
+    if (off < buf->bl_off || off >= buf->get_buf_end()) {
+      buf->bl.clear();
+      buf->bl_off = off & super.block_mask();
+      uint64_t x_off = 0;
+      vector<bluefs_extent_t>::iterator p =
+	h->file->fnode.seek(buf->bl_off, &x_off);
+      uint64_t want = ROUND_UP_TO(len + (off & ~super.block_mask()),
+				  super.block_size);
+      want = MAX(want, buf->max_prefetch);
+      uint64_t l = MIN(p->length - x_off, want);
+      uint64_t eof_offset = ROUND_UP_TO(h->file->fnode.size, super.block_size);
+      if (!h->ignore_eof &&
+	  buf->bl_off + l > eof_offset) {
+	l = eof_offset - buf->bl_off;
+      }
+      dout(20) << __func__ << " fetching " << x_off << "~" << l << " of "
+	       << *p << dendl;
+      int r = bdev[p->bdev]->read(p->offset + x_off, l, &buf->bl, ioc[p->bdev],
+				  true);
+      assert(r == 0);
+    }
+    left = buf->get_buf_remaining(off);
+    dout(20) << __func__ << " left " << left << " len " << len << dendl;
+
+    int r = MIN((int)len, left);
+    if (outbl) {
+      bufferlist t;
+      t.substr_of(buf->bl, off - buf->bl_off, r);
+      outbl->claim_append(t);
+    }
+    if (out) {
+      // NOTE: h->bl is normally a contiguous buffer so c_str() is free.
+      memcpy(out, buf->bl.c_str() + off - buf->bl_off, r);
+      out += r;
+    }
+
+    dout(30) << __func__ << " result chunk (" << r << " bytes):\n";
+    bufferlist t;
+    t.substr_of(buf->bl, off - buf->bl_off, r);
+    t.hexdump(*_dout);
+    *_dout << dendl;
+
+    off += r;
+    len -= r;
+    ret += r;
+    buf->pos += r;
+  }
+
+  dout(20) << __func__ << " got " << ret << dendl;
+  assert(!outbl || (int)outbl->length() == ret);
+  h->file->num_reading.dec();
+  return ret;
+}
+
+void BlueFS::_invalidate_cache(FileRef f, uint64_t offset, uint64_t length)
+{
+  dout(10) << __func__ << " file " << f->fnode
+	   << " " << offset << "~" << length << dendl;
+  if (offset & ~super.block_mask()) {
+    offset &= super.block_mask();
+    length = ROUND_UP_TO(length, super.block_size);
+  }
+  uint64_t x_off = 0;
+  vector<bluefs_extent_t>::iterator p = f->fnode.seek(offset, &x_off);
+  while (length > 0 && p != f->fnode.extents.end()) {
+    uint64_t x_len = MIN(p->length - x_off, length);
+    bdev[p->bdev]->invalidate_cache(p->offset + x_off, x_len);
+    dout(20) << "  " << x_off << "~" << x_len << " of " << *p << dendl;
+    offset += x_len;
+    length -= x_len;
+  }
+}
+
+uint64_t BlueFS::_estimate_log_size()
+{
+  int avg_dir_size = 40;  // fixme
+  int avg_file_size = 12;
+  uint64_t size = 4096 * 2;
+  size += file_map.size() * (1 + sizeof(bluefs_fnode_t));
+  for (auto& p : block_all)
+    size += p.num_intervals() * (1 + 1 + sizeof(uint64_t) * 2);
+  size += dir_map.size() + (1 + avg_dir_size);
+  size += file_map.size() * (1 + avg_dir_size + avg_file_size);
+  return ROUND_UP_TO(size, super.block_size);
+}
+
+void BlueFS::_maybe_compact_log()
+{
+  uint64_t current = log_writer->file->fnode.size;
+  uint64_t expected = _estimate_log_size();
+  float ratio = (float)current / (float)expected;
+  dout(10) << __func__ << " current " << current
+	   << " expected " << expected
+	   << " ratio " << ratio << dendl;
+  if (current < g_conf->bluefs_log_compact_min_size ||
+      ratio < g_conf->bluefs_log_compact_min_ratio)
+    return;
+  _compact_log();
+  dout(20) << __func__ << " done, actual " << log_writer->file->fnode.size
+	   << " vs expected " << expected << dendl;
+}
+
+void BlueFS::_compact_log()
+{
+  // FIXME: we currently hold the lock while writing out the compacted log,
+  // which may mean a latency spike.  we could drop the lock while writing out
+  // the big compacted log, while continuing to log at the end of the old log
+  // file, and once it's done swap out the old log extents for the new ones.
+  dout(10) << __func__ << dendl;
+  File *log_file = log_writer->file.get();
+
+  // clear out log (be careful who calls us!!!)
+  log_t.clear();
+
+  bluefs_transaction_t t;
+  t.seq = 1;
+  t.uuid = super.uuid;
+  dout(20) << __func__ << " op_init" << dendl;
+  t.op_init();
+  for (unsigned bdev = 0; bdev < block_all.size(); ++bdev) {
+    interval_set<uint64_t>& p = block_all[bdev];
+    for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
+      dout(20) << __func__ << " op_alloc_add " << bdev << " " << q.get_start()
+	       << "~" << q.get_len() << dendl;
+      t.op_alloc_add(bdev, q.get_start(), q.get_len());
+    }
+  }
+  for (auto& p : file_map) {
+    if (p.first == 1)
+      continue;
+    dout(20) << __func__ << " op_file_update " << p.second->fnode << dendl;
+    t.op_file_update(p.second->fnode);
+  }
+  for (auto& p : dir_map) {
+    dout(20) << __func__ << " op_dir_create " << p.first << dendl;
+    t.op_dir_create(p.first);
+    for (auto& q : p.second->file_map) {
+      dout(20) << __func__ << " op_dir_link " << p.first << "/" << q.first
+	       << " to " << q.second->fnode.ino << dendl;
+      t.op_dir_link(p.first, q.first, q.second->fnode.ino);
+    }
+  }
+  dout(20) << __func__ << " op_jump_seq " << log_seq << dendl;
+  t.op_jump_seq(log_seq);
+
+  bufferlist bl;
+  ::encode(t, bl);
+  _pad_bl(bl);
+
+  uint64_t need = bl.length() + g_conf->bluefs_max_log_runway;
+  dout(20) << __func__ << " need " << need << dendl;
+
+  vector<bluefs_extent_t> old_extents;
+  old_extents.swap(log_file->fnode.extents);
+  while (log_file->fnode.get_allocated() < need) {
+    int r = _allocate(log_file->fnode.prefer_bdev,
+		      need - log_file->fnode.get_allocated(),
+		      &log_file->fnode.extents);
+    assert(r == 0);
+  }
+
+  _close_writer(log_writer);
+
+  log_file->fnode.size = bl.length();
+  log_writer = new FileWriter(log_file, bdev.size());
+  log_writer->append(bl);
+  int r = _flush(log_writer, true);
+  assert(r == 0);
+
+  dout(10) << __func__ << " writing super" << dendl;
+  super.log_fnode = log_file->fnode;
+  ++super.version;
+  _write_super();
+  _flush_bdev();
+
+  dout(10) << __func__ << " release old log extents " << old_extents << dendl;
+  for (auto& r : old_extents) {
+    alloc[r.bdev]->release(r.offset, r.length);
+  }
+}
+
+void BlueFS::_pad_bl(bufferlist& bl)
+{
+  uint64_t partial = bl.length() % super.block_size;
+  if (partial) {
+    bufferptr z(super.block_size - partial);
+    dout(10) << __func__ << " padding with " << z.length() << " zeros" << dendl;
+    z.zero();
+    bufferlist zbl;
+    zbl.append(z);
+    bl.append(z);
+  }
+}
+
+int BlueFS::_flush_log()
+{
+  log_t.seq = ++log_seq;
+  log_t.uuid = super.uuid;
+  dout(10) << __func__ << " " << log_t << dendl;
+  assert(!log_t.empty());
+
+  // allocate some more space (before we run out)?
+  uint64_t runway = log_writer->file->fnode.get_allocated() - log_writer->pos;
+  if (runway < g_conf->bluefs_min_log_runway) {
+    dout(10) << __func__ << " allocating more log runway ("
+	     << runway << " remaining" << dendl;
+    int r = _allocate(log_writer->file->fnode.prefer_bdev,
+		      g_conf->bluefs_max_log_runway,
+		      &log_writer->file->fnode.extents);
+    assert(r == 0);
+    log_t.op_file_update(log_writer->file->fnode);
+  }
+
+  bufferlist bl;
+  ::encode(log_t, bl);
+
+  // pad to block boundary
+  _pad_bl(bl);
+  log_writer->append(bl);
+
+  log_t.clear();
+  log_t.seq = 0;  // just so debug output is less confusing
+
+  _flush_bdev();
+  int r = _flush(log_writer, true);
+  assert(r == 0);
+  _flush_wait(log_writer);
+  _flush_bdev();
+
+  // clean dirty files
+  dirty_file_list_t::iterator p = dirty_files.begin();
+  while (p != dirty_files.end()) {
+    File *file = &(*p);
+    assert(file->dirty);
+    dout(20) << __func__ << " cleaned file " << file->fnode << dendl;
+    file->dirty = false;
+    dirty_files.erase(p++);
+  }
+
+  return 0;
+}
+
+int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
+{
+  dout(10) << __func__ << " " << h << " pos " << h->pos
+	   << " " << offset << "~" << length
+	   << " to " << h->file->fnode << dendl;
+  assert(!h->file->deleted);
+  assert(h->file->num_readers.read() == 0);
+
+  if (offset + length <= h->pos)
+    return 0;
+  if (offset < h->pos) {
+    length -= h->pos - offset;
+    offset = h->pos;
+    dout(10) << " still need " << offset << "~" << length << dendl;
+  }
+  assert(offset <= h->file->fnode.size);
+
+  uint64_t allocated = h->file->fnode.get_allocated();
+
+  // do not bother to dirty the file if we are overwriting
+  // previously allocated extents.
+  bool must_dirty = false;
+  if (allocated < offset + length) {
+    int r = _allocate(h->file->fnode.prefer_bdev,
+		      offset + length - allocated,
+		      &h->file->fnode.extents);
+    if (r < 0)
+      return r;
+    must_dirty = true;
+  }
+  if (h->file->fnode.size < offset + length) {
+    h->file->fnode.size = offset + length;
+    must_dirty = true;
+  }
+  if (must_dirty) {
+    h->file->fnode.mtime = ceph_clock_now(NULL);
+    log_t.op_file_update(h->file->fnode);
+    if (!h->file->dirty) {
+      h->file->dirty = true;
+      dirty_files.push_back(*h->file);
+    }
+  }
+  dout(20) << __func__ << " file now " << h->file->fnode << dendl;
+
+  uint64_t x_off = 0;
+  vector<bluefs_extent_t>::iterator p = h->file->fnode.seek(offset, &x_off);
+  assert(p != h->file->fnode.extents.end());
+  dout(20) << __func__ << " in " << *p << " x_off " << x_off << dendl;
+
+  unsigned partial = x_off & ~super.block_mask();
+  bufferlist bl;
+  if (partial) {
+    dout(20) << __func__ << " using partial tail " << partial << dendl;
+    assert(h->tail_block.length() == partial);
+    bl.claim_append(h->tail_block);
+    x_off -= partial;
+    offset -= partial;
+    length += partial;
+    dout(20) << __func__ << " waiting for previous aio to complete" << dendl;
+    for (auto p : h->iocv) {
+      p->aio_wait();
+    }
+  }
+  if (length == partial + h->buffer.length()) {
+    bl.claim_append(h->buffer);
+  } else {
+    bufferlist t;
+    t.substr_of(h->buffer, 0, length);
+    bl.claim_append(t);
+    t.substr_of(h->buffer, length, h->buffer.length() - length);
+    h->buffer.swap(t);
+    dout(20) << " leaving " << h->buffer.length() << " unflushed" << dendl;
+  }
+  assert(bl.length() == length);
+
+  dout(30) << "dump:\n";
+  bl.hexdump(*_dout);
+  *_dout << dendl;
+
+  h->pos = offset + length;
+  h->tail_block.clear();
+
+  uint64_t bloff = 0;
+  while (length > 0) {
+    uint64_t x_len = MIN(p->length - x_off, length);
+    bufferlist t;
+    t.substr_of(bl, bloff, x_len);
+    unsigned tail = x_len & ~super.block_mask();
+    if (tail) {
+      dout(20) << __func__ << " caching tail of " << tail
+	       << " and padding block with zeros" << dendl;
+      h->tail_block.substr_of(bl, bl.length() - tail, tail);
+      bufferptr z(super.block_size - tail);
+      z.zero();
+      t.append(z);
+    }
+    bdev[p->bdev]->aio_write(p->offset + x_off, t, h->iocv[p->bdev], true);
+    bloff += x_len;
+    length -= x_len;
+    ++p;
+    x_off = 0;
+  }
+  for (unsigned i = 0; i < bdev.size(); ++i) {
+    if (!h->iocv[i]->pending_aios.empty()) {
+      bdev[i]->aio_submit(h->iocv[i]);
+    }
+  }
+  dout(20) << __func__ << " h " << h << " pos now " << h->pos << dendl;
+  return 0;
+}
+
+void BlueFS::_flush_wait(FileWriter *h)
+{
+  dout(10) << __func__ << " " << h << dendl;
+  utime_t start = ceph_clock_now(NULL);
+  for (auto p : h->iocv) {
+    p->aio_wait();
+  }
+  utime_t end = ceph_clock_now(NULL);
+  utime_t dur = end - start;
+  dout(10) << __func__ << " " << h << " done in " << dur << dendl;
+}
+
+int BlueFS::_flush(FileWriter *h, bool force)
+{
+  uint64_t length = h->buffer.length();
+  uint64_t offset = h->pos;
+  if (!force &&
+      length < g_conf->bluefs_min_flush_size) {
+    dout(10) << __func__ << " " << h << " ignoring, length " << length
+	     << " < min_flush_size " << g_conf->bluefs_min_flush_size
+	     << dendl;
+    return 0;
+  }
+  if (length == 0) {
+    dout(10) << __func__ << " " << h << " no dirty data on "
+	     << h->file->fnode << dendl;
+    return 0;
+  }
+  dout(10) << __func__ << " " << h << " " << offset << "~" << length
+	   << " to " << h->file->fnode << dendl;
+  assert(h->pos <= h->file->fnode.size);
+  return _flush_range(h, offset, length);
+}
+
+int BlueFS::_truncate(FileWriter *h, uint64_t offset)
+{
+  dout(10) << __func__ << " " << offset << " file " << h->file->fnode << dendl;
+
+  // truncate off unflushed data?
+  if (h->pos < offset &&
+      h->pos + h->buffer.length() > offset) {
+    bufferlist t;
+    dout(20) << __func__ << " tossing out last " << offset - h->pos
+	     << " unflushed bytes" << dendl;
+    t.substr_of(h->buffer, 0, offset - h->pos);
+    h->buffer.swap(t);
+    assert(0 == "actually this shouldn't happen");
+  }
+  if (h->buffer.length()) {
+    int r = _flush(h, true);
+    if (r < 0)
+      return r;
+  }
+  if (offset == h->file->fnode.size) {
+    return 0;  // no-op!
+  }
+  if (offset > h->file->fnode.size) {
+    assert(0 == "truncate up not supported");
+  }
+  assert(h->file->fnode.size >= offset);
+  h->file->fnode.size = offset;
+  log_t.op_file_update(h->file->fnode);
+  return 0;
+}
+
+void BlueFS::_fsync(FileWriter *h)
+{
+  dout(10) << __func__ << " " << h << " " << h->file->fnode << dendl;
+  _flush(h, true);
+  _flush_wait(h);
+  if (h->file->dirty) {
+    dout(20) << __func__ << " file metadata is dirty, flushing log on "
+	     << h->file->fnode << dendl;
+    _flush_log();
+    assert(!h->file->dirty);
+  }
+}
+
+void BlueFS::_flush_bdev()
+{
+  dout(20) << __func__ << dendl;
+  for (auto p : bdev) {
+    p->flush();
+  }
+}
+
+int BlueFS::_allocate(unsigned id, uint64_t len, vector<bluefs_extent_t> *ev)
+{
+  dout(10) << __func__ << " len " << len << " from " << id << dendl;
+  assert(id < alloc.size());
+
+  uint64_t left = ROUND_UP_TO(len, g_conf->bluefs_alloc_size);
+  int r = alloc[id]->reserve(left);
+  if (r < 0) {
+    if (id) {
+      derr << __func__ << " failed to allocate " << left << " on bdev " << id
+	   << ", free " << alloc[id]->get_free()
+	   << "; fallback to bdev 0" << dendl;
+      return _allocate(0, len, ev);
+    }
+    derr << __func__ << " failed to allocate " << left << " on bdev " << id
+	 << ", free " << alloc[id]->get_free() << dendl;
+    return r;
+  }
+
+  uint64_t hint = 0;
+  if (!ev->empty()) {
+    hint = ev->back().end();
+  }
+  while (left > 0) {
+    bluefs_extent_t e;
+    e.bdev = id;
+    int r = alloc[id]->allocate(left, g_conf->bluefs_alloc_size, hint,
+				&e.offset, &e.length);
+    if (r < 0) {
+      assert(0 == "allocate failed... wtf");
+      return r;
+    }
+    if (!ev->empty() && ev->back().end() == e.offset)
+      ev->back().length += e.length;
+    else
+      ev->push_back(e);
+    if (e.length >= left)
+      break;
+    left -= e.length;
+    hint = e.end();
+  }
+  return 0;
+}
+
+int BlueFS::_preallocate(FileRef f, uint64_t off, uint64_t len)
+{
+  dout(10) << __func__ << " file " << f->fnode << " "
+	   << off << "~" << len << dendl;
+  uint64_t allocated = f->fnode.get_allocated();
+  if (off + len > allocated) {
+    uint64_t want = off + len - allocated;
+    int r = _allocate(f->fnode.prefer_bdev, want, &f->fnode.extents);
+    if (r < 0)
+      return r;
+    log_t.op_file_update(f->fnode);
+  }
+  return 0;
+}
+
+void BlueFS::sync_metadata()
+{
+  Mutex::Locker l(lock);
+  if (log_t.empty()) {
+    dout(10) << __func__ << " - no pending log events" << dendl;
+    return;
+  }
+  dout(10) << __func__ << dendl;
+  utime_t start = ceph_clock_now(NULL);
+  for (auto p : alloc) {
+    p->commit_start();
+  }
+  _flush_log();
+  for (auto p : alloc) {
+    p->commit_finish();
+  }
+  utime_t end = ceph_clock_now(NULL);
+  utime_t dur = end - start;
+  dout(10) << __func__ << " done in " << dur << dendl;
+  _maybe_compact_log();
+}
+
+int BlueFS::open_for_write(
+  const string& dirname,
+  const string& filename,
+  FileWriter **h,
+  bool overwrite)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << "/" << filename << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  Dir *dir;
+  if (p == dir_map.end()) {
+    // implicitly create the dir
+    dout(20) << __func__ << "  dir " << dirname
+	     << " does not exist" << dendl;
+    return -ENOENT;
+  } else {
+    dir = p->second;
+  }
+
+  FileRef file;
+  map<string,FileRef>::iterator q = dir->file_map.find(filename);
+  if (q == dir->file_map.end()) {
+    if (overwrite) {
+      dout(20) << __func__ << " dir " << dirname << " (" << dir
+	       << ") file " << filename
+	       << " does not exist" << dendl;
+      return -ENOENT;
+    }
+    file = new File;
+    file->fnode.ino = ++ino_last;
+    file->fnode.mtime = ceph_clock_now(NULL);
+    file_map[ino_last] = file;
+    dir->file_map[filename] = file;
+    ++file->refs;
+    log_t.op_file_update(file->fnode);
+    log_t.op_dir_link(dirname, filename, file->fnode.ino);
+  } else {
+    // overwrite existing file?
+    file = q->second;
+    if (overwrite) {
+      dout(20) << __func__ << " dir " << dirname << " (" << dir
+	       << ") file " << filename
+	       << " already exists, overwrite in place" << dendl;
+    } else {
+      dout(20) << __func__ << " dir " << dirname << " (" << dir
+	       << ") file " << filename
+	       << " already exists, truncate + overwrite" << dendl;
+      file->fnode.size = 0;
+    }
+    file->fnode.mtime = ceph_clock_now(NULL);
+    log_t.op_file_update(file->fnode);
+  }
+
+  if (dirname.length() > 5) {
+    // the "db.slow" and "db.wal" directory names are hard-coded at
+    // match up with bluestore.  the slow device is always the second
+    // one (when a dedicated block.db device is present and used at
+    // bdev 0).  the wal device is always last.
+    if (strcmp(dirname.c_str() + dirname.length() - 5, ".slow") == 0) {
+      assert(bdev.size() > 1);
+      dout(20) << __func__ << " mapping " << dirname << "/" << filename
+	       << " to bdev 1" << dendl;
+      file->fnode.prefer_bdev = 1;
+    } else if (strcmp(dirname.c_str() + dirname.length() - 4, ".wal") == 0) {
+      assert(bdev.size() > 1);
+      file->fnode.prefer_bdev = bdev.size() - 1;
+      dout(20) << __func__ << " mapping " << dirname << "/" << filename
+	       << " to bdev " << (int)file->fnode.prefer_bdev << dendl;
+    }
+  }
+
+  *h = new FileWriter(file, bdev.size());
+  dout(10) << __func__ << " h " << *h << " on " << file->fnode << dendl;
+  return 0;
+}
+
+void BlueFS::_close_writer(FileWriter *h)
+{
+  dout(10) << __func__ << " " << h << dendl;
+  for (unsigned i=0; i<bdev.size(); ++i) {
+    bdev[i]->queue_reap_ioc(h->iocv[i]);
+  }
+  h->iocv.clear();
+  delete h;
+}
+
+int BlueFS::open_for_read(
+  const string& dirname,
+  const string& filename,
+  FileReader **h,
+  bool random)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << "/" << filename
+	   << (random ? " (random)":" (sequential)") << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " not found" << dendl;
+    return -ENOENT;
+  }
+  Dir *dir = p->second;
+
+  map<string,FileRef>::iterator q = dir->file_map.find(filename);
+  if (q == dir->file_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " (" << dir
+	     << ") file " << filename
+	     << " not found" << dendl;
+    return -ENOENT;
+  }
+  File *file = q->second.get();
+
+  *h = new FileReader(file, random ? 4096 : g_conf->bluefs_max_prefetch,
+		      random, false);
+  dout(10) << __func__ << " h " << *h << " on " << file->fnode << dendl;
+  return 0;
+}
+
+int BlueFS::rename(
+  const string& old_dirname, const string& old_filename,
+  const string& new_dirname, const string& new_filename)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << old_dirname << "/" << old_filename
+	   << " -> " << new_dirname << "/" << new_filename << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(old_dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << old_dirname << " not found" << dendl;
+    return -ENOENT;
+  }
+  Dir *old_dir = p->second;
+  map<string,FileRef>::iterator q = old_dir->file_map.find(old_filename);
+  if (q == old_dir->file_map.end()) {
+    dout(20) << __func__ << " dir " << old_dirname << " (" << old_dir
+	     << ") file " << old_filename
+	     << " not found" << dendl;
+    return -ENOENT;
+  }
+  FileRef file = q->second;
+
+  p = dir_map.find(new_dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << new_dirname << " not found" << dendl;
+    return -ENOENT;
+  }
+  Dir *new_dir = p->second;
+  q = new_dir->file_map.find(new_filename);
+  if (q != new_dir->file_map.end()) {
+    dout(20) << __func__ << " dir " << new_dirname << " (" << old_dir
+	     << ") file " << new_filename
+	     << " already exists, unlinking" << dendl;
+    assert(q->second != file);
+    log_t.op_dir_unlink(new_dirname, new_filename);
+    _drop_link(q->second);
+  }
+
+  dout(10) << __func__ << " " << new_dirname << "/" << new_filename << " "
+	   << " " << file->fnode << dendl;
+
+  new_dir->file_map[new_filename] = file;
+  old_dir->file_map.erase(old_filename);
+
+  log_t.op_dir_link(new_dirname, new_filename, file->fnode.ino);
+  log_t.op_dir_unlink(old_dirname, old_filename);
+  return 0;
+}
+
+int BlueFS::mkdir(const string& dirname)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  if (p != dir_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " exists" << dendl;
+    return -EEXIST;
+  }
+  dir_map[dirname] = new Dir;
+  log_t.op_dir_create(dirname);
+  return 0;
+}
+
+int BlueFS::rmdir(const string& dirname)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " does not exist" << dendl;
+    return -ENOENT;
+  }
+  Dir *dir = p->second;
+  if (!dir->file_map.empty()) {
+    dout(20) << __func__ << " dir " << dirname << " not empty" << dendl;
+    return -ENOTEMPTY;
+  }
+  dir_map.erase(dirname);
+  log_t.op_dir_remove(dirname);
+  return 0;
+}
+
+bool BlueFS::dir_exists(const string& dirname)
+{
+  Mutex::Locker l(lock);
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  bool exists = p != dir_map.end();
+  dout(10) << __func__ << " " << dirname << " = " << (int)exists << dendl;
+  return exists;
+}
+
+int BlueFS::stat(const string& dirname, const string& filename,
+		 uint64_t *size, utime_t *mtime)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << "/" << filename << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " not found" << dendl;
+    return -ENOENT;
+  }
+  Dir *dir = p->second;
+  map<string,FileRef>::iterator q = dir->file_map.find(filename);
+  if (q == dir->file_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " (" << dir
+	     << ") file " << filename
+	     << " not found" << dendl;
+    return -ENOENT;
+  }
+  File *file = q->second.get();
+  dout(10) << __func__ << " " << dirname << "/" << filename
+	   << " " << file->fnode << dendl;
+  if (size)
+    *size = file->fnode.size;
+  if (mtime)
+    *mtime = file->fnode.mtime;
+  return 0;
+}
+
+int BlueFS::lock_file(const string& dirname, const string& filename,
+		      FileLock **plock)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << "/" << filename << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " not found" << dendl;
+    return -ENOENT;
+  }
+  Dir *dir = p->second;
+  map<string,FileRef>::iterator q = dir->file_map.find(filename);
+  File *file;
+  if (q == dir->file_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " (" << dir
+	     << ") file " << filename
+	     << " not found, creating" << dendl;
+    file = new File;
+    file->fnode.ino = ++ino_last;
+    file->fnode.mtime = ceph_clock_now(NULL);
+    file_map[ino_last] = file;
+    dir->file_map[filename] = file;
+    ++file->refs;
+    log_t.op_file_update(file->fnode);
+    log_t.op_dir_link(dirname, filename, file->fnode.ino);
+  } else {
+    file = q->second.get();
+  }
+  if (file->locked) {
+    dout(10) << __func__ << " already locked" << dendl;
+    return -EBUSY;
+  }
+  file->locked = true;
+  *plock = new FileLock(file);
+  dout(10) << __func__ << " locked " << file->fnode
+	   << " with " << *plock << dendl;
+  return 0;
+}
+
+int BlueFS::unlock_file(FileLock *fl)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << fl << " on " << fl->file->fnode << dendl;
+  assert(fl->file->locked);
+  fl->file->locked = false;
+  delete fl;
+  return 0;
+}
+
+int BlueFS::readdir(const string& dirname, vector<string> *ls)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << dendl;
+  if (dirname.size() == 0) {
+    // list dirs
+    ls->reserve(dir_map.size() + 2);
+    for (auto& q : dir_map) {
+      ls->push_back(q.first);
+    }
+  } else {
+    // list files in dir
+    map<string,Dir*>::iterator p = dir_map.find(dirname);
+    if (p == dir_map.end()) {
+      dout(20) << __func__ << " dir " << dirname << " not found" << dendl;
+      return -ENOENT;
+    }
+    Dir *dir = p->second;
+    ls->reserve(dir->file_map.size() + 2);
+    for (auto& q : dir->file_map) {
+      ls->push_back(q.first);
+    }
+  }
+  ls->push_back(".");
+  ls->push_back("..");
+  return 0;
+}
+
+int BlueFS::unlink(const string& dirname, const string& filename)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << dirname << "/" << filename << dendl;
+  map<string,Dir*>::iterator p = dir_map.find(dirname);
+  if (p == dir_map.end()) {
+    dout(20) << __func__ << " dir " << dirname << " not found" << dendl;
+    return -ENOENT;
+  }
+  Dir *dir = p->second;
+  map<string,FileRef>::iterator q = dir->file_map.find(filename);
+  if (q == dir->file_map.end()) {
+    dout(20) << __func__ << " file " << dirname << "/" << filename
+	     << " not found" << dendl;
+    return -ENOENT;
+  }
+  FileRef file = q->second;
+  dir->file_map.erase(filename);
+  log_t.op_dir_unlink(dirname, filename);
+  _drop_link(file);
+  return 0;
+}
diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h
new file mode 100644
index 0000000..be1f88d
--- /dev/null
+++ b/src/os/bluestore/BlueFS.h
@@ -0,0 +1,351 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#ifndef CEPH_OS_BLUESTORE_BLUEFS_H
+#define CEPH_OS_BLUESTORE_BLUEFS_H
+
+#include "bluefs_types.h"
+#include "common/Mutex.h"
+#include "common/Cond.h"
+#include "common/RefCountedObj.h"
+#include "BlockDevice.h"
+
+#include "boost/intrusive/list.hpp"
+#include <boost/intrusive_ptr.hpp>
+
+class Allocator;
+
+class BlueFS {
+public:
+  struct File : public RefCountedObject {
+    bluefs_fnode_t fnode;
+    int refs;
+    bool dirty;
+    bool locked;
+    bool deleted;
+    boost::intrusive::list_member_hook<> dirty_item;
+
+    atomic_t num_readers, num_writers;
+    atomic_t num_reading;
+
+    File()
+      : RefCountedObject(NULL, 0),
+	refs(0),
+	dirty(false),
+	locked(false),
+	deleted(false)
+      {}
+    ~File() {
+      assert(num_readers.read() == 0);
+      assert(num_writers.read() == 0);
+      assert(num_reading.read() == 0);
+      assert(!locked);
+    }
+
+    friend void intrusive_ptr_add_ref(File *f) {
+      f->get();
+    }
+    friend void intrusive_ptr_release(File *f) {
+      f->put();
+    }
+  };
+  typedef boost::intrusive_ptr<File> FileRef;
+
+  typedef boost::intrusive::list<
+      File,
+      boost::intrusive::member_hook<
+        File,
+	boost::intrusive::list_member_hook<>,
+	&File::dirty_item> > dirty_file_list_t;
+
+  struct Dir {
+    map<string,FileRef> file_map;
+  };
+
+  struct FileWriter {
+    FileRef file;
+    uint64_t pos;           ///< start offset for buffer
+    bufferlist buffer;      ///< new data to write (at end of file)
+    bufferlist tail_block;  ///< existing partial block at end of file, if any
+
+    Mutex lock;
+    vector<IOContext*> iocv;  ///< one for each bdev
+
+    FileWriter(FileRef f, unsigned num_bdev)
+      : file(f),
+	pos(0),
+	lock("BlueFS::FileWriter::lock") {
+      file->num_writers.inc();
+      iocv.resize(num_bdev);
+      for (unsigned i = 0; i < num_bdev; ++i) {
+	iocv[i] = new IOContext(NULL);
+      }
+    }
+    ~FileWriter() {
+      file->num_writers.dec();
+      assert(iocv.empty());  // caller must call BlueFS::close_writer()
+    }
+
+    void append(const char *buf, size_t len) {
+      buffer.append(buf, len);
+    }
+    void append(bufferlist& bl) {
+      buffer.claim_append(bl);
+    }
+    void append(bufferptr& bp) {
+      buffer.append(bp);
+    }
+  };
+
+  struct FileReaderBuffer {
+    uint64_t bl_off;        ///< prefetch buffer logical offset
+    bufferlist bl;          ///< prefetch buffer
+    uint64_t pos;           ///< current logical offset
+    uint64_t max_prefetch;  ///< max allowed prefetch
+
+    FileReaderBuffer(uint64_t mpf)
+      : bl_off(0),
+	pos(0),
+	max_prefetch(mpf) {}
+
+    uint64_t get_buf_end() {
+      return bl_off + bl.length();
+    }
+    uint64_t get_buf_remaining(uint64_t p) {
+      if (p >= bl_off && p < bl_off + bl.length())
+	return bl_off + bl.length() - p;
+      return 0;
+    }
+
+    void skip(size_t n) {
+      pos += n;
+    }
+    void seek(uint64_t offset) {
+      pos = offset;
+    }
+  };
+
+  struct FileReader {
+    FileRef file;
+    FileReaderBuffer buf;
+    bool random;
+    bool ignore_eof;        ///< used when reading our log file
+
+    FileReader(FileRef f, uint64_t mpf, bool rand, bool ie)
+      : file(f),
+	buf(mpf),
+	random(rand),
+	ignore_eof(ie) {
+      file->num_readers.inc();
+    }
+    ~FileReader() {
+      file->num_readers.dec();
+    }
+  };
+
+  struct FileLock {
+    FileRef file;
+    FileLock(FileRef f) : file(f) {}
+  };
+
+private:
+  Mutex lock;
+  Cond cond;
+
+  // cache
+  map<string, Dir*> dir_map;                      ///< dirname -> Dir
+  ceph::unordered_map<uint64_t,FileRef> file_map; ///< ino -> File
+  dirty_file_list_t dirty_files;                  ///< list of dirty files
+
+  bluefs_super_t super;       ///< latest superblock (as last written)
+  uint64_t ino_last;          ///< last assigned ino (this one is in use)
+  uint64_t log_seq;           ///< last used log seq (by current pending log_t)
+  FileWriter *log_writer;     ///< writer for the log
+  bluefs_transaction_t log_t; ///< pending, unwritten log transaction
+
+  /*
+   * - there can be from 1 to 3 block devices.
+   *
+   * - the first device always has the superblock.
+   *
+   * - if there is a dedicated db device, it is the first device, and the
+   *   second device is shared with bluestore.  the first device will be
+   *   db/, and the second device will be db.slow/.
+   *
+   * - if there is no dedicated db device, then the first device is shared, and
+   *   maps to the db/ directory.
+   *
+   * - a wal device, if present, it always the last device.  it should be
+   *   used for any files in the db.wal/ directory.
+   */
+  vector<BlockDevice*> bdev;                  ///< block devices we can use
+  vector<IOContext*> ioc;                     ///< IOContexts for bdevs
+  vector<interval_set<uint64_t> > block_all;  ///< extents in bdev we own
+  vector<Allocator*> alloc;                   ///< allocators for bdevs
+
+  void _init_alloc();
+  void _stop_alloc();
+
+  void _pad_bl(bufferlist& bl);  ///< pad bufferlist to block size w/ zeros
+
+  FileRef _get_file(uint64_t ino);
+  void _drop_link(FileRef f);
+
+  int _allocate(unsigned bdev, uint64_t len, vector<bluefs_extent_t> *ev);
+  int _flush_range(FileWriter *h, uint64_t offset, uint64_t length);
+  int _flush(FileWriter *h, bool force);
+  void _flush_wait(FileWriter *h);
+  void _fsync(FileWriter *h);
+
+  int _flush_log();
+  uint64_t _estimate_log_size();
+  void _maybe_compact_log();
+  void _compact_log();
+
+  //void _aio_finish(void *priv);
+
+  void _flush_bdev();
+
+  int _preallocate(FileRef f, uint64_t off, uint64_t len);
+  int _truncate(FileWriter *h, uint64_t off);
+
+  int _read(
+    FileReader *h,   ///< [in] read from here
+    FileReaderBuffer *buf, ///< [in] reader state
+    uint64_t offset, ///< [in] offset
+    size_t len,      ///< [in] this many bytes
+    bufferlist *outbl,   ///< [out] optional: reference the result here
+    char *out);      ///< [out] optional: or copy it here
+  int _read_random(
+    FileReader *h,   ///< [in] read from here
+    uint64_t offset, ///< [in] offset
+    size_t len,      ///< [in] this many bytes
+    char *out);      ///< [out] optional: or copy it here
+
+  void _invalidate_cache(FileRef f, uint64_t offset, uint64_t length);
+
+  int _open_super();
+  int _write_super();
+  int _replay(); ///< replay journal
+
+  void _close_writer(FileWriter *h);
+
+  // always put the super in the second 4k block.  FIXME should this be
+  // block size independent?
+  unsigned get_super_offset() {
+    return 4096;
+  }
+  unsigned get_super_length() {
+    return 4096;
+  }
+
+public:
+  BlueFS();
+  ~BlueFS();
+
+  // the super is always stored on bdev 0
+  int mkfs(uuid_d osd_uuid);
+  int mount();
+  void umount();
+
+  int fsck();
+
+  uint64_t get_total(unsigned id);
+  uint64_t get_free(unsigned id);
+  void get_usage(vector<pair<uint64_t,uint64_t>> *usage); // [<free,total> ...]
+
+  /// get current extents that we own for given block device
+  int get_block_extents(unsigned id, interval_set<uint64_t> *extents);
+
+  int open_for_write(
+    const string& dir,
+    const string& file,
+    FileWriter **h,
+    bool overwrite);
+
+  int open_for_read(
+    const string& dir,
+    const string& file,
+    FileReader **h,
+    bool random = false);
+
+  void close_writer(FileWriter *h) {
+    Mutex::Locker l(lock);
+    _close_writer(h);
+  }
+
+  int rename(const string& old_dir, const string& old_file,
+	     const string& new_dir, const string& new_file);
+
+  int readdir(const string& dirname, vector<string> *ls);
+
+  int unlink(const string& dirname, const string& filename);
+  int mkdir(const string& dirname);
+  int rmdir(const string& dirname);
+
+  bool dir_exists(const string& dirname);
+  int stat(const string& dirname, const string& filename,
+	   uint64_t *size, utime_t *mtime);
+
+  int lock_file(const string& dirname, const string& filename, FileLock **p);
+  int unlock_file(FileLock *l);
+
+  /// sync any uncommitted state to disk
+  int sync();
+
+  void sync_metadata();
+
+  /// compact metadata
+  int compact();
+
+  int add_block_device(unsigned bdev, string path);
+  uint64_t get_block_device_size(unsigned bdev);
+
+  /// gift more block space
+  void add_block_extent(unsigned bdev, uint64_t offset, uint64_t len);
+
+  /// reclaim block space
+  int reclaim_blocks(unsigned bdev, uint64_t want,
+		     uint64_t *offset, uint32_t *length);
+
+  void flush(FileWriter *h) {
+    Mutex::Locker l(lock);
+    _flush(h, false);
+  }
+  void flush_range(FileWriter *h, uint64_t offset, uint64_t length) {
+    Mutex::Locker l(lock);
+    _flush_range(h, offset, length);
+  }
+  void fsync(FileWriter *h) {
+    Mutex::Locker l(lock);
+    _fsync(h);
+  }
+  int read(FileReader *h, FileReaderBuffer *buf, uint64_t offset, size_t len,
+	   bufferlist *outbl, char *out) {
+    // no need to hold the global lock here; we only touch h and
+    // h->file, and read vs write or delete is already protected (via
+    // atomics and asserts).
+    return _read(h, buf, offset, len, outbl, out);
+  }
+  int read_random(FileReader *h, uint64_t offset, size_t len,
+		  char *out) {
+    // no need to hold the global lock here; we only touch h and
+    // h->file, and read vs write or delete is already protected (via
+    // atomics and asserts).
+    return _read_random(h, offset, len, out);
+  }
+  void invalidate_cache(FileRef f, uint64_t offset, uint64_t len) {
+    Mutex::Locker l(lock);
+    _invalidate_cache(f, offset, len);
+  }
+  int preallocate(FileRef f, uint64_t offset, uint64_t len) {
+    Mutex::Locker l(lock);
+    return _preallocate(f, offset, len);
+  }
+  int truncate(FileWriter *h, uint64_t offset) {
+    Mutex::Locker l(lock);
+    return _truncate(h, offset);
+  }
+
+};
+
+#endif
diff --git a/src/os/bluestore/BlueRocksEnv.cc b/src/os/bluestore/BlueRocksEnv.cc
new file mode 100644
index 0000000..252bdbd
--- /dev/null
+++ b/src/os/bluestore/BlueRocksEnv.cc
@@ -0,0 +1,552 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "BlueRocksEnv.h"
+#include "BlueFS.h"
+#include "include/stringify.h"
+#include "kv/RocksDBStore.h"
+
+rocksdb::Status err_to_status(int r)
+{
+  switch (r) {
+  case 0:
+    return rocksdb::Status::OK();
+  case -ENOENT:
+    return rocksdb::Status::NotFound(rocksdb::Status::kNone);
+  case -EINVAL:
+    return rocksdb::Status::InvalidArgument(rocksdb::Status::kNone);
+  case -EIO:
+    return rocksdb::Status::IOError(rocksdb::Status::kNone);
+  default:
+    // FIXME :(
+    assert(0 == "unrecognized error code");
+    return rocksdb::Status::NotSupported(rocksdb::Status::kNone);
+  }
+}
+
+// A file abstraction for reading sequentially through a file
+class BlueRocksSequentialFile : public rocksdb::SequentialFile {
+  BlueFS *fs;
+  BlueFS::FileReader *h;
+ public:
+  BlueRocksSequentialFile(BlueFS *fs, BlueFS::FileReader *h) : fs(fs), h(h) {}
+  ~BlueRocksSequentialFile() {
+    delete h;
+  }
+
+  // Read up to "n" bytes from the file.  "scratch[0..n-1]" may be
+  // written by this routine.  Sets "*result" to the data that was
+  // read (including if fewer than "n" bytes were successfully read).
+  // May set "*result" to point at data in "scratch[0..n-1]", so
+  // "scratch[0..n-1]" must be live when "*result" is used.
+  // If an error was encountered, returns a non-OK status.
+  //
+  // REQUIRES: External synchronization
+  rocksdb::Status Read(size_t n, rocksdb::Slice* result, char* scratch) {
+    int r = fs->read(h, &h->buf, h->buf.pos, n, NULL, scratch);
+    assert(r >= 0);
+    *result = rocksdb::Slice(scratch, r);
+    return rocksdb::Status::OK();
+  }
+
+  // Skip "n" bytes from the file. This is guaranteed to be no
+  // slower that reading the same data, but may be faster.
+  //
+  // If end of file is reached, skipping will stop at the end of the
+  // file, and Skip will return OK.
+  //
+  // REQUIRES: External synchronization
+  rocksdb::Status Skip(uint64_t n) {
+    h->buf.skip(n);
+    return rocksdb::Status::OK();
+  }
+
+  // Remove any kind of caching of data from the offset to offset+length
+  // of this file. If the length is 0, then it refers to the end of file.
+  // If the system is not caching the file contents, then this is a noop.
+  rocksdb::Status InvalidateCache(size_t offset, size_t length) {
+    fs->invalidate_cache(h->file, offset, length);
+    return rocksdb::Status::OK();
+  }
+};
+
+// A file abstraction for randomly reading the contents of a file.
+class BlueRocksRandomAccessFile : public rocksdb::RandomAccessFile {
+  BlueFS *fs;
+  BlueFS::FileReader *h;
+ public:
+  BlueRocksRandomAccessFile(BlueFS *fs, BlueFS::FileReader *h) : fs(fs), h(h) {}
+  ~BlueRocksRandomAccessFile() {
+    delete h;
+  }
+
+  // Read up to "n" bytes from the file starting at "offset".
+  // "scratch[0..n-1]" may be written by this routine.  Sets "*result"
+  // to the data that was read (including if fewer than "n" bytes were
+  // successfully read).  May set "*result" to point at data in
+  // "scratch[0..n-1]", so "scratch[0..n-1]" must be live when
+  // "*result" is used.  If an error was encountered, returns a non-OK
+  // status.
+  //
+  // Safe for concurrent use by multiple threads.
+  rocksdb::Status Read(uint64_t offset, size_t n, rocksdb::Slice* result,
+		       char* scratch) const {
+    int r = fs->read_random(h, offset, n, scratch);
+    assert(r >= 0);
+    *result = rocksdb::Slice(scratch, r);
+    return rocksdb::Status::OK();
+  }
+
+  // Used by the file_reader_writer to decide if the ReadAhead wrapper
+  // should simply forward the call and do not enact buffering or locking.
+  bool ShouldForwardRawRequest() const {
+    return false;
+  }
+
+  // For cases when read-ahead is implemented in the platform dependent
+  // layer
+  void EnableReadAhead() {}
+
+  // Tries to get an unique ID for this file that will be the same each time
+  // the file is opened (and will stay the same while the file is open).
+  // Furthermore, it tries to make this ID at most "max_size" bytes. If such an
+  // ID can be created this function returns the length of the ID and places it
+  // in "id"; otherwise, this function returns 0, in which case "id"
+  // may not have been modified.
+  //
+  // This function guarantees, for IDs from a given environment, two unique ids
+  // cannot be made equal to eachother by adding arbitrary bytes to one of
+  // them. That is, no unique ID is the prefix of another.
+  //
+  // This function guarantees that the returned ID will not be interpretable as
+  // a single varint.
+  //
+  // Note: these IDs are only valid for the duration of the process.
+  size_t GetUniqueId(char* id, size_t max_size) const {
+    return snprintf(id, max_size, "%016llx",
+		    (unsigned long long)h->file->fnode.ino);
+  };
+
+  //enum AccessPattern { NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED };
+
+  void Hint(AccessPattern pattern) {
+    if (pattern == RANDOM)
+      h->buf.max_prefetch = 4096;
+    else if (pattern == SEQUENTIAL)
+      h->buf.max_prefetch = g_conf->bluefs_max_prefetch;
+  }
+
+  // Remove any kind of caching of data from the offset to offset+length
+  // of this file. If the length is 0, then it refers to the end of file.
+  // If the system is not caching the file contents, then this is a noop.
+  rocksdb::Status InvalidateCache(size_t offset, size_t length) {
+    fs->invalidate_cache(h->file, offset, length);
+    return rocksdb::Status::OK();
+  }
+};
+
+
+// A file abstraction for sequential writing.  The implementation
+// must provide buffering since callers may append small fragments
+// at a time to the file.
+class BlueRocksWritableFile : public rocksdb::WritableFile {
+  BlueFS *fs;
+  BlueFS::FileWriter *h;
+ public:
+  BlueRocksWritableFile(BlueFS *fs, BlueFS::FileWriter *h) : fs(fs), h(h) {}
+  ~BlueRocksWritableFile() {
+    fs->close_writer(h);
+  }
+
+  // Indicates if the class makes use of unbuffered I/O
+  /*bool UseOSBuffer() const {
+    return true;
+    }*/
+
+  // This is needed when you want to allocate
+  // AlignedBuffer for use with file I/O classes
+  // Used for unbuffered file I/O when UseOSBuffer() returns false
+  /*size_t GetRequiredBufferAlignment() const {
+    return c_DefaultPageSize;
+    }*/
+
+  rocksdb::Status Append(const rocksdb::Slice& data) {
+    h->append(data.data(), data.size());
+    return rocksdb::Status::OK();
+  }
+
+  // Positioned write for unbuffered access default forward
+  // to simple append as most of the tests are buffered by default
+  rocksdb::Status PositionedAppend(
+    const rocksdb::Slice& /* data */,
+    uint64_t /* offset */) {
+    return rocksdb::Status::NotSupported();
+  }
+
+  // Truncate is necessary to trim the file to the correct size
+  // before closing. It is not always possible to keep track of the file
+  // size due to whole pages writes. The behavior is undefined if called
+  // with other writes to follow.
+  rocksdb::Status Truncate(uint64_t size) {
+    // we mirror the posix env, which does nothing here; instead, it
+    // truncates to the final size on close.  whatever!
+    return rocksdb::Status::OK();
+    //int r = fs->truncate(h, size);
+    //  return err_to_status(r);
+  }
+
+  rocksdb::Status Close() {
+    Flush();
+
+    // mimic posix env, here.  shrug.
+    size_t block_size;
+    size_t last_allocated_block;
+    GetPreallocationStatus(&block_size, &last_allocated_block);
+    if (last_allocated_block > 0) {
+      int r = fs->truncate(h, h->pos);
+      if (r < 0)
+	return err_to_status(r);
+    }
+
+    return rocksdb::Status::OK();
+  }
+
+  rocksdb::Status Flush() {
+    fs->flush(h);
+    return rocksdb::Status::OK();
+  }
+
+  rocksdb::Status Sync() { // sync data
+    fs->fsync(h);
+    return rocksdb::Status::OK();
+  }
+
+  // true if Sync() and Fsync() are safe to call concurrently with Append()
+  // and Flush().
+  bool IsSyncThreadSafe() const {
+    return true;
+  }
+
+  // Indicates the upper layers if the current WritableFile implementation
+  // uses direct IO.
+  bool UseDirectIO() const {
+    return false;
+  }
+
+  /*
+   * Get the size of valid data in the file.
+   */
+  uint64_t GetFileSize() {
+    return h->file->fnode.size + h->buffer.length();;
+  }
+
+  // For documentation, refer to RandomAccessFile::GetUniqueId()
+  size_t GetUniqueId(char* id, size_t max_size) const {
+    return snprintf(id, max_size, "%016llx",
+		    (unsigned long long)h->file->fnode.ino);
+  }
+
+  // Remove any kind of caching of data from the offset to offset+length
+  // of this file. If the length is 0, then it refers to the end of file.
+  // If the system is not caching the file contents, then this is a noop.
+  // This call has no effect on dirty pages in the cache.
+  rocksdb::Status InvalidateCache(size_t offset, size_t length) {
+    fs->invalidate_cache(h->file, offset, length);
+    return rocksdb::Status::OK();
+  }
+
+  // Sync a file range with disk.
+  // offset is the starting byte of the file range to be synchronized.
+  // nbytes specifies the length of the range to be synchronized.
+  // This asks the OS to initiate flushing the cached data to disk,
+  // without waiting for completion.
+  // Default implementation does nothing.
+  rocksdb::Status RangeSync(off_t offset, off_t nbytes) {
+    // round down to page boundaries
+    int partial = offset & 4095;
+    offset -= partial;
+    nbytes += partial;
+    nbytes &= ~4095;
+    if (nbytes)
+      fs->flush_range(h, offset, nbytes);
+    return rocksdb::Status::OK();
+  }
+
+ protected:
+  /*
+   * Pre-allocate space for a file.
+   */
+  rocksdb::Status Allocate(off_t offset, off_t len) {
+    int r = fs->preallocate(h->file, offset, len);
+    return err_to_status(r);
+  }
+};
+
+
+// Directory object represents collection of files and implements
+// filesystem operations that can be executed on directories.
+class BlueRocksDirectory : public rocksdb::Directory {
+  BlueFS *fs;
+ public:
+  BlueRocksDirectory(BlueFS *f) : fs(f) {}
+
+  // Fsync directory. Can be called concurrently from multiple threads.
+  rocksdb::Status Fsync() {
+    // it is sufficient to flush the log.
+    fs->sync_metadata();
+    return rocksdb::Status::OK();
+  }
+};
+
+// Identifies a locked file.
+class BlueRocksFileLock : public rocksdb::FileLock {
+ public:
+  BlueFS *fs;
+  BlueFS::FileLock *lock;
+  BlueRocksFileLock(BlueFS *fs, BlueFS::FileLock *l) : fs(fs), lock(l) { }
+  ~BlueRocksFileLock() {
+  }
+};
+
+
+// --------------------
+// --- BlueRocksEnv ---
+// --------------------
+
+BlueRocksEnv::BlueRocksEnv(BlueFS *f)
+  : EnvWrapper(Env::Default()),  // forward most of it to POSIX
+    fs(f)
+{
+
+}
+
+rocksdb::Status BlueRocksEnv::NewSequentialFile(
+  const std::string& fname,
+  std::unique_ptr<rocksdb::SequentialFile>* result,
+  const rocksdb::EnvOptions& options)
+{
+  if (fname[0] == '/')
+    return target()->NewSequentialFile(fname, result, options);
+  std::string dir, file;
+  split(fname, &dir, &file);
+  BlueFS::FileReader *h;
+  int r = fs->open_for_read(dir, file, &h, false);
+  if (r < 0)
+    return err_to_status(r);
+  result->reset(new BlueRocksSequentialFile(fs, h));
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::NewRandomAccessFile(
+  const std::string& fname,
+  std::unique_ptr<rocksdb::RandomAccessFile>* result,
+  const rocksdb::EnvOptions& options)
+{
+  std::string dir, file;
+  split(fname, &dir, &file);
+  BlueFS::FileReader *h;
+  int r = fs->open_for_read(dir, file, &h, true);
+  if (r < 0)
+    return err_to_status(r);
+  result->reset(new BlueRocksRandomAccessFile(fs, h));
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::NewWritableFile(
+  const std::string& fname,
+  std::unique_ptr<rocksdb::WritableFile>* result,
+  const rocksdb::EnvOptions& options)
+{
+  std::string dir, file;
+  split(fname, &dir, &file);
+  BlueFS::FileWriter *h;
+  int r = fs->open_for_write(dir, file, &h, false);
+  if (r < 0)
+    return err_to_status(r);
+  result->reset(new BlueRocksWritableFile(fs, h));
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::ReuseWritableFile(
+  const std::string& new_fname,
+  const std::string& old_fname,
+  std::unique_ptr<rocksdb::WritableFile>* result,
+  const rocksdb::EnvOptions& options)
+{
+  std::string old_dir, old_file;
+  split(old_fname, &old_dir, &old_file);
+  std::string new_dir, new_file;
+  split(new_fname, &new_dir, &new_file);
+
+  int r = fs->rename(old_dir, old_file, new_dir, new_file);
+  if (r < 0)
+    return err_to_status(r);
+
+  BlueFS::FileWriter *h;
+  r = fs->open_for_write(new_dir, new_file, &h, true);
+  if (r < 0)
+    return err_to_status(r);
+  result->reset(new BlueRocksWritableFile(fs, h));
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::NewDirectory(
+  const std::string& name,
+  std::unique_ptr<rocksdb::Directory>* result)
+{
+  if (!fs->dir_exists(name))
+    return rocksdb::Status::IOError(name, strerror(-ENOENT));
+  result->reset(new BlueRocksDirectory(fs));
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::FileExists(const std::string& fname)
+{
+  if (fname[0] == '/')
+    return target()->FileExists(fname);
+  std::string dir, file;
+  split(fname, &dir, &file);
+  if (fs->stat(dir, file, NULL, NULL) == 0)
+    return rocksdb::Status::OK();
+  return err_to_status(-ENOENT);
+}
+
+rocksdb::Status BlueRocksEnv::GetChildren(
+  const std::string& dir,
+  std::vector<std::string>* result)
+{
+  int r = fs->readdir(dir, result);
+  if (r < 0)
+    return rocksdb::Status::IOError(dir, strerror(-ENOENT));//    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::DeleteFile(const std::string& fname)
+{
+  std::string dir, file;
+  split(fname, &dir, &file);
+  int r = fs->unlink(dir, file);
+  if (r < 0)
+    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::CreateDir(const std::string& dirname)
+{
+  int r = fs->mkdir(dirname);
+  if (r < 0)
+    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::CreateDirIfMissing(const std::string& dirname)
+{
+  int r = fs->mkdir(dirname);
+  if (r < 0 && r != -EEXIST)
+    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::DeleteDir(const std::string& dirname)
+{
+  int r = fs->rmdir(dirname);
+  if (r < 0)
+    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::GetFileSize(
+  const std::string& fname,
+  uint64_t* file_size)
+{
+  std::string dir, file;
+  split(fname, &dir, &file);
+  int r = fs->stat(dir, file, file_size, NULL);
+  if (r < 0)
+    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::GetFileModificationTime(const std::string& fname,
+						      uint64_t* file_mtime)
+{
+  std::string dir, file;
+  split(fname, &dir, &file);
+  utime_t mtime;
+  int r = fs->stat(dir, file, NULL, &mtime);
+  if (r < 0)
+    return err_to_status(r);
+  *file_mtime = mtime.sec();
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::RenameFile(
+  const std::string& src,
+  const std::string& target)
+{
+  std::string old_dir, old_file;
+  split(src, &old_dir, &old_file);
+  std::string new_dir, new_file;
+  split(target, &new_dir, &new_file);
+
+  int r = fs->rename(old_dir, old_file, new_dir, new_file);
+  if (r < 0)
+    return err_to_status(r);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::LinkFile(
+  const std::string& src,
+  const std::string& target)
+{
+  assert(0);
+}
+
+rocksdb::Status BlueRocksEnv::LockFile(
+  const std::string& fname,
+  rocksdb::FileLock** lock)
+{
+  std::string dir, file;
+  split(fname, &dir, &file);
+  BlueFS::FileLock *l = NULL;
+  int r = fs->lock_file(dir, file, &l);
+  if (r < 0)
+    return err_to_status(r);
+  *lock = new BlueRocksFileLock(fs, l);
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::UnlockFile(rocksdb::FileLock* lock)
+{
+  BlueRocksFileLock *l = static_cast<BlueRocksFileLock*>(lock);
+  int r = fs->unlock_file(l->lock);
+  if (r < 0)
+    return err_to_status(r);
+  delete lock;
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::GetAbsolutePath(
+  const std::string& db_path,
+  std::string* output_path)
+{
+  // this is a lie...
+  *output_path = "/" + db_path;
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::NewLogger(
+  const std::string& fname,
+  std::shared_ptr<rocksdb::Logger>* result)
+{
+  // ignore the filename :)
+  result->reset(create_rocksdb_ceph_logger());
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status BlueRocksEnv::GetTestDirectory(std::string* path)
+{
+  static int foo = 0;
+  *path = "temp_" + stringify(++foo);
+  return rocksdb::Status::OK();
+}
diff --git a/src/os/bluestore/BlueRocksEnv.h b/src/os/bluestore/BlueRocksEnv.h
new file mode 100644
index 0000000..b67a2db
--- /dev/null
+++ b/src/os/bluestore/BlueRocksEnv.h
@@ -0,0 +1,158 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#ifndef CEPH_OS_BLUESTORE_BLUEROCKSENV_H
+#define CEPH_OS_BLUESTORE_BLUEROCKSENV_H
+
+#include <memory>
+#include <string>
+
+#include "rocksdb/status.h"
+#include "rocksdb/utilities/env_mirror.h"
+
+#include "include/assert.h"
+
+class BlueFS;
+
+class BlueRocksEnv : public rocksdb::EnvWrapper {
+  void split(const std::string &fn, std::string *dir, std::string *file) {
+    size_t slash = fn.rfind('/');
+    *file = fn.substr(slash + 1);
+    while (slash && fn[slash-1] == '/')
+      --slash;
+    *dir = fn.substr(0, slash);
+  }
+
+public:
+  // Create a brand new sequentially-readable file with the specified name.
+  // On success, stores a pointer to the new file in *result and returns OK.
+  // On failure stores nullptr in *result and returns non-OK.  If the file does
+  // not exist, returns a non-OK status.
+  //
+  // The returned file will only be accessed by one thread at a time.
+  rocksdb::Status NewSequentialFile(
+    const std::string& fname,
+    std::unique_ptr<rocksdb::SequentialFile>* result,
+    const rocksdb::EnvOptions& options);
+
+  // Create a brand new random access read-only file with the
+  // specified name.  On success, stores a pointer to the new file in
+  // *result and returns OK.  On failure stores nullptr in *result and
+  // returns non-OK.  If the file does not exist, returns a non-OK
+  // status.
+  //
+  // The returned file may be concurrently accessed by multiple threads.
+  rocksdb::Status NewRandomAccessFile(
+    const std::string& fname,
+    std::unique_ptr<rocksdb::RandomAccessFile>* result,
+    const rocksdb::EnvOptions& options);
+
+  // Create an object that writes to a new file with the specified
+  // name.  Deletes any existing file with the same name and creates a
+  // new file.  On success, stores a pointer to the new file in
+  // *result and returns OK.  On failure stores nullptr in *result and
+  // returns non-OK.
+  //
+  // The returned file will only be accessed by one thread at a time.
+  rocksdb::Status NewWritableFile(
+    const std::string& fname,
+    std::unique_ptr<rocksdb::WritableFile>* result,
+    const rocksdb::EnvOptions& options);
+
+  // Reuse an existing file by renaming it and opening it as writable.
+  rocksdb::Status ReuseWritableFile(
+    const std::string& fname,
+    const std::string& old_fname,
+    std::unique_ptr<rocksdb::WritableFile>* result,
+    const rocksdb::EnvOptions& options);
+
+  // Create an object that represents a directory. Will fail if directory
+  // doesn't exist. If the directory exists, it will open the directory
+  // and create a new Directory object.
+  //
+  // On success, stores a pointer to the new Directory in
+  // *result and returns OK. On failure stores nullptr in *result and
+  // returns non-OK.
+  rocksdb::Status NewDirectory(
+    const std::string& name,
+    std::unique_ptr<rocksdb::Directory>* result);
+
+  // Returns OK if the named file exists.
+  //         NotFound if the named file does not exist,
+  //                  the calling process does not have permission to determine
+  //                  whether this file exists, or if the path is invalid.
+  //         IOError if an IO Error was encountered
+  rocksdb::Status FileExists(const std::string& fname);
+
+  // Store in *result the names of the children of the specified directory.
+  // The names are relative to "dir".
+  // Original contents of *results are dropped.
+  rocksdb::Status GetChildren(const std::string& dir,
+                             std::vector<std::string>* result);
+
+  // Delete the named file.
+  rocksdb::Status DeleteFile(const std::string& fname);
+
+  // Create the specified directory. Returns error if directory exists.
+  rocksdb::Status CreateDir(const std::string& dirname);
+
+  // Creates directory if missing. Return Ok if it exists, or successful in
+  // Creating.
+  rocksdb::Status CreateDirIfMissing(const std::string& dirname);
+
+  // Delete the specified directory.
+  rocksdb::Status DeleteDir(const std::string& dirname);
+
+  // Store the size of fname in *file_size.
+  rocksdb::Status GetFileSize(const std::string& fname, uint64_t* file_size);
+
+  // Store the last modification time of fname in *file_mtime.
+  rocksdb::Status GetFileModificationTime(const std::string& fname,
+                                         uint64_t* file_mtime);
+  // Rename file src to target.
+  rocksdb::Status RenameFile(const std::string& src,
+                            const std::string& target);
+  // Hard Link file src to target.
+  rocksdb::Status LinkFile(const std::string& src, const std::string& target);
+
+  // Lock the specified file.  Used to prevent concurrent access to
+  // the same db by multiple processes.  On failure, stores nullptr in
+  // *lock and returns non-OK.
+  //
+  // On success, stores a pointer to the object that represents the
+  // acquired lock in *lock and returns OK.  The caller should call
+  // UnlockFile(*lock) to release the lock.  If the process exits,
+  // the lock will be automatically released.
+  //
+  // If somebody else already holds the lock, finishes immediately
+  // with a failure.  I.e., this call does not wait for existing locks
+  // to go away.
+  //
+  // May create the named file if it does not already exist.
+  rocksdb::Status LockFile(const std::string& fname, rocksdb::FileLock** lock);
+
+  // Release the lock acquired by a previous successful call to LockFile.
+  // REQUIRES: lock was returned by a successful LockFile() call
+  // REQUIRES: lock has not already been unlocked.
+  rocksdb::Status UnlockFile(rocksdb::FileLock* lock);
+
+  // *path is set to a temporary directory that can be used for testing. It may
+  // or many not have just been created. The directory may or may not differ
+  // between runs of the same process, but subsequent calls will return the
+  // same directory.
+  rocksdb::Status GetTestDirectory(std::string* path);
+
+  // Create and return a log file for storing informational messages.
+  rocksdb::Status NewLogger(
+    const std::string& fname,
+    std::shared_ptr<rocksdb::Logger>* result);
+
+  // Get full directory name for this db.
+  rocksdb::Status GetAbsolutePath(const std::string& db_path,
+      std::string* output_path);
+
+  BlueRocksEnv(BlueFS *f);
+private:
+  BlueFS *fs;
+};
+
+#endif
diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc
new file mode 100644
index 0000000..304a02a
--- /dev/null
+++ b/src/os/bluestore/BlueStore.cc
@@ -0,0 +1,6217 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "BlueStore.h"
+#include "kv.h"
+#include "include/compat.h"
+#include "include/stringify.h"
+#include "common/errno.h"
+#include "common/safe_io.h"
+#include "Allocator.h"
+#include "FreelistManager.h"
+#include "BlueFS.h"
+#include "BlueRocksEnv.h"
+
+#define dout_subsys ceph_subsys_bluestore
+
+/*
+
+  TODO:
+
+  * superblock, features
+  * bdev: smarter zeroing
+  * zero overlay in onode?
+  * discard
+  * aio read?
+  * read uses local ioc
+  * refcounted extents (for efficient clone)
+  * overlay does inefficient zeroing on unwritten extent
+
+ */
+
+/*
+ * Some invariants:
+ *
+ * - If the end of the object is a partial block, and is not an overlay,
+ *   the remainder of that block will always be zeroed.  (It has to be written
+ *   anyway, so we may as well have written zeros.)
+ *
+ */
+
+const string PREFIX_SUPER = "S";   // field -> value
+const string PREFIX_COLL = "C";    // collection name -> cnode_t
+const string PREFIX_OBJ = "O";     // object name -> onode_t
+const string PREFIX_OVERLAY = "V"; // u64 + offset -> data
+const string PREFIX_OMAP = "M";    // u64 + keyname -> value
+const string PREFIX_WAL = "L";     // id -> wal_transaction_t
+const string PREFIX_ALLOC = "B";   // u64 offset -> u64 length (freelist)
+
+// write a label in the first block.  always use this size.  note that
+// bluefs makes a matching assumption about the location of its
+// superblock (always the second block of the device).
+#define BDEV_LABEL_BLOCK_SIZE  4096
+
+// for bluefs, label (4k) + bluefs super (4k), means we start at 8k.
+#define BLUEFS_START  8192
+
+/*
+ * object name key structure
+ *
+ * 2 chars: shard (-- for none, or hex digit, so that we sort properly)
+ * encoded u64: poolid + 2^63 (so that it sorts properly)
+ * encoded u32: hash (bit reversed)
+ *
+ * 1 char: '.'
+ *
+ * escaped string: namespace
+ *
+ * 1 char: '<', '=', or '>'.  if =, then object key == object name, and
+ *         we are followed just by the key.  otherwise, we are followed by
+ *         the key and then the object name.
+ * escaped string: key
+ * escaped string: object name (unless '=' above)
+ *
+ * encoded u64: snap
+ * encoded u64: generation
+ */
+
+/*
+ * string encoding in the key
+ *
+ * The key string needs to lexicographically sort the same way that
+ * ghobject_t does.  We do this by escaping anything <= to '%' with %
+ * plus a 2 digit hex string, and anything >= '~' with ~ plus the two
+ * hex digits.
+ *
+ * We use ! as a terminator for strings; this works because it is < %
+ * and will get escaped if it is present in the string.
+ *
+ */
+
+static void append_escaped(const string &in, string *out)
+{
+  char hexbyte[8];
+  for (string::const_iterator i = in.begin(); i != in.end(); ++i) {
+    if (*i <= '#') {
+      snprintf(hexbyte, sizeof(hexbyte), "#%02x", (unsigned)*i);
+      out->append(hexbyte);
+    } else if (*i >= '~') {
+      snprintf(hexbyte, sizeof(hexbyte), "~%02x", (unsigned)*i);
+      out->append(hexbyte);
+    } else {
+      out->push_back(*i);
+    }
+  }
+  out->push_back('!');
+}
+
+static int decode_escaped(const char *p, string *out)
+{
+  const char *orig_p = p;
+  while (*p && *p != '!') {
+    if (*p == '#' || *p == '~') {
+      unsigned hex;
+      int r = sscanf(++p, "%2x", &hex);
+      if (r < 1)
+	return -EINVAL;
+      out->push_back((char)hex);
+      p += 2;
+    } else {
+      out->push_back(*p++);
+    }
+  }
+  return p - orig_p;
+}
+
+// some things we encode in binary (as le32 or le64); print the
+// resulting key strings nicely
+static string pretty_binary_string(const string& in)
+{
+  char buf[10];
+  string out;
+  out.reserve(in.length() * 3);
+  enum { NONE, HEX, STRING } mode = NONE;
+  unsigned from = 0, i;
+  for (i=0; i < in.length(); ++i) {
+    if ((in[i] < 32 || (unsigned char)in[i] > 126) ||
+	(mode == HEX && in.length() - i >= 4 &&
+	 ((in[i] < 32 || (unsigned char)in[i] > 126) ||
+	  (in[i+1] < 32 || (unsigned char)in[i+1] > 126) ||
+	  (in[i+2] < 32 || (unsigned char)in[i+2] > 126) ||
+	  (in[i+3] < 32 || (unsigned char)in[i+3] > 126)))) {
+      if (mode == STRING) {
+	out.append(in.substr(from, i - from));
+	out.push_back('\'');
+      }
+      if (mode != HEX) {
+	out.append("0x");
+	mode = HEX;
+      }
+      if (in.length() - i >= 4) {
+	// print a whole u32 at once
+	snprintf(buf, sizeof(buf), "%08x",
+		 (uint32_t)(((unsigned char)in[i] << 24) |
+			    ((unsigned char)in[i+1] << 16) |
+			    ((unsigned char)in[i+2] << 8) |
+			    ((unsigned char)in[i+3] << 0)));
+	i += 3;
+      } else {
+	snprintf(buf, sizeof(buf), "%02x", (int)(unsigned char)in[i]);
+      }
+      out.append(buf);
+    } else {
+      if (mode != STRING) {
+	out.push_back('\'');
+	mode = STRING;
+	from = i;
+      }
+    }
+  }
+  if (mode == STRING) {
+    out.append(in.substr(from, i - from));
+    out.push_back('\'');
+  }
+  return out;
+}
+
+static void _key_encode_shard(shard_id_t shard, string *key)
+{
+  // make field ordering match with ghobject_t compare operations
+  if (shard == shard_id_t::NO_SHARD) {
+    // otherwise ff will sort *after* 0, not before.
+    key->append("--");
+  } else {
+    char buf[32];
+    snprintf(buf, sizeof(buf), "%02x", (int)shard);
+    key->append(buf);
+  }
+}
+static const char *_key_decode_shard(const char *key, shard_id_t *pshard)
+{
+  if (key[0] == '-') {
+    *pshard = shard_id_t::NO_SHARD;
+  } else {
+    unsigned shard;
+    int r = sscanf(key, "%x", &shard);
+    if (r < 1)
+      return NULL;
+    *pshard = shard_id_t(shard);
+  }
+  return key + 2;
+}
+
+static void get_coll_key_range(const coll_t& cid, int bits,
+			       string *temp_start, string *temp_end,
+			       string *start, string *end)
+{
+  temp_start->clear();
+  temp_end->clear();
+  start->clear();
+  end->clear();
+
+  spg_t pgid;
+  if (cid.is_pg(&pgid)) {
+    _key_encode_shard(pgid.shard, start);
+    *end = *start;
+    *temp_start = *start;
+    *temp_end = *start;
+
+    _key_encode_u64(pgid.pool() + 0x8000000000000000ull, start);
+    _key_encode_u64((-2ll - pgid.pool()) + 0x8000000000000000ull, temp_start);
+    _key_encode_u32(hobject_t::_reverse_bits(pgid.ps()), start);
+    _key_encode_u32(hobject_t::_reverse_bits(pgid.ps()), temp_start);
+    start->append(".");
+    temp_start->append(".");
+
+    _key_encode_u64(pgid.pool() + 0x8000000000000000ull, end);
+    _key_encode_u64((-2ll - pgid.pool()) + 0x8000000000000000ull, temp_end);
+
+    uint64_t end_hash =
+      hobject_t::_reverse_bits(pgid.ps()) + (1ull << (32-bits));
+    if (end_hash <= 0xffffffffull) {
+      _key_encode_u32(end_hash, end);
+      _key_encode_u32(end_hash, temp_end);
+      end->append(".");
+      temp_end->append(".");
+    } else {
+      _key_encode_u32(0xffffffff, end);
+      _key_encode_u32(0xffffffff, temp_end);
+      end->append(":");
+      temp_end->append(":");
+    }
+  } else {
+    _key_encode_shard(shard_id_t::NO_SHARD, start);
+    _key_encode_u64(-1ull + 0x8000000000000000ull, start);
+    *end = *start;
+    _key_encode_u32(0, start);
+    start->append(".");
+    _key_encode_u32(0xffffffff, end);
+    end->append(":");
+
+    // no separate temp section
+    *temp_start = *end;
+    *temp_end = *end;
+  }
+}
+
+static bool is_enode_key(const string& key)
+{
+  if (key.size() == 2 + 8 + 4)
+    return true;
+  return false;
+}
+
+static void get_enode_key(shard_id_t shard, int64_t pool, uint32_t hash,
+			  string *key)
+{
+  key->clear();
+  _key_encode_shard(shard, key);
+  _key_encode_u64(pool + 0x8000000000000000ull, key);
+  _key_encode_u32(hobject_t::_reverse_bits(hash), key);
+}
+
+static int get_key_object(const string& key, ghobject_t *oid);
+
+static void get_object_key(const ghobject_t& oid, string *key)
+{
+  key->clear();
+
+  _key_encode_shard(oid.shard_id, key);
+  _key_encode_u64(oid.hobj.pool + 0x8000000000000000ull, key);
+  _key_encode_u32(oid.hobj.get_bitwise_key_u32(), key);
+  key->append(".");
+
+  append_escaped(oid.hobj.nspace, key);
+
+  if (oid.hobj.get_key().length()) {
+    // is a key... could be < = or >.
+    // (ASCII chars < = and > sort in that order, yay)
+    if (oid.hobj.get_key() < oid.hobj.oid.name) {
+      key->append("<");
+      append_escaped(oid.hobj.get_key(), key);
+      append_escaped(oid.hobj.oid.name, key);
+    } else if (oid.hobj.get_key() > oid.hobj.oid.name) {
+      key->append(">");
+      append_escaped(oid.hobj.get_key(), key);
+      append_escaped(oid.hobj.oid.name, key);
+    } else {
+      // same as no key
+      key->append("=");
+      append_escaped(oid.hobj.oid.name, key);
+    }
+  } else {
+    // no key
+    key->append("=");
+    append_escaped(oid.hobj.oid.name, key);
+  }
+
+  _key_encode_u64(oid.hobj.snap, key);
+  _key_encode_u64(oid.generation, key);
+
+  // sanity check
+  if (true) {
+    ghobject_t t;
+    int r = get_key_object(*key, &t);
+    if (r || t != oid) {
+      derr << "  r " << r << dendl;
+      derr << "key " << pretty_binary_string(*key) << dendl;
+      derr << "oid " << oid << dendl;
+      derr << "  t " << t << dendl;
+      assert(t == oid);
+    }
+  }
+}
+
+static int get_key_object(const string& key, ghobject_t *oid)
+{
+  int r;
+  const char *p = key.c_str();
+
+  if (key.length() < 2 + 8 + 4)
+    return -2;
+  p = _key_decode_shard(p, &oid->shard_id);
+
+  uint64_t pool;
+  p = _key_decode_u64(p, &pool);
+  oid->hobj.pool = pool - 0x8000000000000000ull;
+
+  unsigned hash;
+  p = _key_decode_u32(p, &hash);
+
+  oid->hobj.set_bitwise_key_u32(hash);
+  if (*p != '.')
+    return -5;
+  ++p;
+
+  r = decode_escaped(p, &oid->hobj.nspace);
+  if (r < 0)
+    return -6;
+  p += r + 1;
+
+  if (*p == '=') {
+    // no key
+    ++p;
+    r = decode_escaped(p, &oid->hobj.oid.name);
+    if (r < 0)
+      return -7;
+    p += r + 1;
+  } else if (*p == '<' || *p == '>') {
+    // key + name
+    ++p;
+    string okey;
+    r = decode_escaped(p, &okey);
+    if (r < 0)
+      return -8;
+    p += r + 1;
+    r = decode_escaped(p, &oid->hobj.oid.name);
+    if (r < 0)
+      return -9;
+    p += r + 1;
+    oid->hobj.set_key(okey);
+  } else {
+    // malformed
+    return -10;
+  }
+
+  p = _key_decode_u64(p, &oid->hobj.snap.val);
+  p = _key_decode_u64(p, &oid->generation);
+  if (*p) {
+    // if we get something other than a null terminator here, 
+    // something goes wrong.
+    return -12;
+  }  
+
+  return 0;
+}
+
+
+static void get_overlay_key(uint64_t nid, uint64_t offset, string *out)
+{
+  _key_encode_u64(nid, out);
+  _key_encode_u64(offset, out);
+}
+
+// '-' < '.' < '~'
+static void get_omap_header(uint64_t id, string *out)
+{
+  _key_encode_u64(id, out);
+  out->push_back('-');
+}
+
+// hmm, I don't think there's any need to escape the user key since we
+// have a clean prefix.
+static void get_omap_key(uint64_t id, const string& key, string *out)
+{
+  _key_encode_u64(id, out);
+  out->push_back('.');
+  out->append(key);
+}
+
+static void rewrite_omap_key(uint64_t id, string old, string *out)
+{
+  _key_encode_u64(id, out);
+  out->append(old.substr(out->length()));
+}
+
+static void decode_omap_key(const string& key, string *user_key)
+{
+  *user_key = key.substr(sizeof(uint64_t) + 1);
+}
+
+static void get_omap_tail(uint64_t id, string *out)
+{
+  _key_encode_u64(id, out);
+  out->push_back('~');
+}
+
+static void get_wal_key(uint64_t seq, string *out)
+{
+  _key_encode_u64(seq, out);
+}
+
+// Enode
+
+#undef dout_prefix
+#define dout_prefix *_dout << "bluestore.enode(" << this << ") "
+
+void BlueStore::Enode::put()
+{
+  int final = nref.dec();
+  if (final == 0) {
+    dout(20) << __func__ << " removing self from set " << enode_set << dendl;
+    enode_set->uset.erase(*this);
+    delete this;
+  }
+}
+
+// Onode
+
+#undef dout_prefix
+#define dout_prefix *_dout << "bluestore.onode(" << this << ") "
+
+BlueStore::Onode::Onode(const ghobject_t& o, const string& k)
+  : nref(0),
+    oid(o),
+    key(k),
+    dirty(false),
+    exists(true),
+    flush_lock("BlueStore::Onode::flush_lock") {
+}
+
+void BlueStore::Onode::flush()
+{
+  Mutex::Locker l(flush_lock);
+  dout(20) << __func__ << " " << flush_txns << dendl;
+  while (!flush_txns.empty())
+    flush_cond.Wait(flush_lock);
+  dout(20) << __func__ << " done" << dendl;
+}
+
+// OnodeHashLRU
+
+#undef dout_prefix
+#define dout_prefix *_dout << "bluestore.lru(" << this << ") "
+
+void BlueStore::OnodeHashLRU::_touch(OnodeRef o)
+{
+  lru_list_t::iterator p = lru.iterator_to(*o);
+  lru.erase(p);
+  lru.push_front(*o);
+}
+
+void BlueStore::OnodeHashLRU::add(const ghobject_t& oid, OnodeRef o)
+{
+  Mutex::Locker l(lock);
+  dout(30) << __func__ << " " << oid << " " << o << dendl;
+  assert(onode_map.count(oid) == 0);
+  onode_map[oid] = o;
+  lru.push_back(*o);
+}
+
+BlueStore::OnodeRef BlueStore::OnodeHashLRU::lookup(const ghobject_t& oid)
+{
+  Mutex::Locker l(lock);
+  dout(30) << __func__ << dendl;
+  ceph::unordered_map<ghobject_t,OnodeRef>::iterator p = onode_map.find(oid);
+  if (p == onode_map.end()) {
+    dout(30) << __func__ << " " << oid << " miss" << dendl;
+    return OnodeRef();
+  }
+  dout(30) << __func__ << " " << oid << " hit " << p->second << dendl;
+  _touch(p->second);
+  return p->second;
+}
+
+void BlueStore::OnodeHashLRU::clear()
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << dendl;
+  lru.clear();
+  onode_map.clear();
+}
+
+void BlueStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
+				    const ghobject_t& new_oid)
+{
+  Mutex::Locker l(lock);
+  dout(30) << __func__ << " " << old_oid << " -> " << new_oid << dendl;
+  ceph::unordered_map<ghobject_t,OnodeRef>::iterator po, pn;
+  po = onode_map.find(old_oid);
+  pn = onode_map.find(new_oid);
+  assert(po != pn);
+
+  assert(po != onode_map.end());
+  if (pn != onode_map.end()) {
+    dout(30) << __func__ << "  removing target " << pn->second << dendl;
+    lru_list_t::iterator p = lru.iterator_to(*pn->second);
+    lru.erase(p);
+    onode_map.erase(pn);
+  }
+  OnodeRef o = po->second;
+
+  // install a non-existent onode at old location
+  po->second.reset(new Onode(old_oid, o->key));
+  po->second->exists = false;
+  lru.push_back(*po->second);
+
+  // add at new position and fix oid, key
+  onode_map.insert(make_pair(new_oid, o));
+  _touch(o);
+  o->oid = new_oid;
+  get_object_key(new_oid, &o->key);
+}
+
+bool BlueStore::OnodeHashLRU::get_next(
+  const ghobject_t& after,
+  pair<ghobject_t,OnodeRef> *next)
+{
+  Mutex::Locker l(lock);
+  dout(20) << __func__ << " after " << after << dendl;
+
+  if (after == ghobject_t()) {
+    if (lru.empty()) {
+      return false;
+    }
+    ceph::unordered_map<ghobject_t,OnodeRef>::iterator p = onode_map.begin();
+    assert(p != onode_map.end());
+    next->first = p->first;
+    next->second = p->second;
+    return true;
+  }
+
+  ceph::unordered_map<ghobject_t,OnodeRef>::iterator p = onode_map.find(after);
+  assert(p != onode_map.end()); // for now
+  lru_list_t::iterator pi = lru.iterator_to(*p->second);
+  ++pi;
+  if (pi == lru.end()) {
+    return false;
+  }
+  next->first = pi->oid;
+  next->second = onode_map[pi->oid];
+  return true;
+}
+
+int BlueStore::OnodeHashLRU::trim(int max)
+{
+  Mutex::Locker l(lock);
+  dout(20) << __func__ << " max " << max
+	   << " size " << onode_map.size() << dendl;
+  int trimmed = 0;
+  int num = onode_map.size() - max;
+  lru_list_t::iterator p = lru.end();
+  if (num)
+    --p;
+  while (num > 0) {
+    Onode *o = &*p;
+    int refs = o->nref.read();
+    if (refs > 1) {
+      dout(20) << __func__ << "  " << o->oid << " has " << refs
+	       << " refs; stopping with " << num << " left to trim" << dendl;
+      break;
+    }
+    dout(30) << __func__ << "  trim " << o->oid << dendl;
+    if (p != lru.begin()) {
+      lru.erase(p--);
+    } else {
+      lru.erase(p);
+      assert(num == 1);
+    }
+    o->get();  // paranoia
+    onode_map.erase(o->oid);
+    o->put();
+    --num;
+    ++trimmed;
+  }
+  return trimmed;
+}
+
+// =======================================================
+
+// Collection
+
+#undef dout_prefix
+#define dout_prefix *_dout << "bluestore(" << store->path << ").collection(" << cid << ") "
+
+BlueStore::Collection::Collection(BlueStore *ns, coll_t c)
+  : store(ns),
+    cid(c),
+    lock("BlueStore::Collection::lock"),
+    onode_map(),
+    enode_set(g_conf->bluestore_onode_map_size)
+{
+}
+
+BlueStore::EnodeRef BlueStore::Collection::get_enode(
+  uint32_t hash
+  )
+{
+  Enode dummy(hash, string(), NULL);
+  auto p = enode_set.uset.find(dummy);
+  if (p == enode_set.uset.end()) {
+    spg_t pgid;
+    if (!cid.is_pg(&pgid))
+      pgid = spg_t();  // meta
+    string key;
+    get_enode_key(pgid.shard, pgid.pool(), hash, &key);
+    EnodeRef e = new Enode(hash, key, &enode_set);
+    dout(10) << __func__ << " hash " << std::hex << hash << std::dec
+	     << " created " << e << dendl;
+
+    bufferlist v;
+    int r = store->db->get(PREFIX_OBJ, key, &v);
+    if (r >= 0) {
+      assert(v.length() > 0);
+      bufferlist::iterator p = v.begin();
+      ::decode(e->ref_map, p);
+      dout(10) << __func__ << " hash " << std::hex << hash << std::dec
+	       << " loaded ref_map " << e->ref_map << dendl;
+    } else {
+      dout(10) << __func__ << " hash " <<std::hex << hash << std::dec
+	       << " missed, new ref_map" << dendl;
+    }
+    enode_set.uset.insert(*e);
+    return e;
+  } else {
+    dout(10) << __func__ << " hash " << std::hex << hash << std::dec
+	     << " had " << &*p << dendl;
+    return &*p;
+  }
+}
+
+BlueStore::OnodeRef BlueStore::Collection::get_onode(
+  const ghobject_t& oid,
+  bool create)
+{
+  assert(create ? lock.is_wlocked() : lock.is_locked());
+
+  spg_t pgid;
+  if (cid.is_pg(&pgid)) {
+    if (!oid.match(cnode.bits, pgid.ps())) {
+      derr << __func__ << " oid " << oid << " not part of " << pgid
+	   << " bits " << cnode.bits << dendl;
+      assert(0);
+    }
+  }
+
+  OnodeRef o = onode_map.lookup(oid);
+  if (o)
+    return o;
+
+  string key;
+  get_object_key(oid, &key);
+
+  dout(20) << __func__ << " oid " << oid << " key "
+	   << pretty_binary_string(key) << dendl;
+
+  bufferlist v;
+  int r = store->db->get(PREFIX_OBJ, key, &v);
+  dout(20) << " r " << r << " v.len " << v.length() << dendl;
+  Onode *on;
+  if (v.length() == 0) {
+    assert(r == -ENOENT);
+    if (!g_conf->bluestore_debug_misc &&
+	!create)
+      return OnodeRef();
+
+    // new
+    on = new Onode(oid, key);
+    on->dirty = true;
+    if (g_conf->bluestore_debug_misc && !create)
+      on->exists = on->dirty = false;
+  } else {
+    // loaded
+    assert(r >=0);
+    on = new Onode(oid, key);
+    bufferlist::iterator p = v.begin();
+    ::decode(on->onode, p);
+  }
+  o.reset(on);
+  onode_map.add(oid, o);
+  return o;
+}
+
+
+
+// =======================================================
+
+#undef dout_prefix
+#define dout_prefix *_dout << "bluestore(" << path << ") "
+
+
+static void aio_cb(void *priv, void *priv2)
+{
+  BlueStore *store = static_cast<BlueStore*>(priv);
+  store->_txc_aio_finish(priv2);
+}
+
+BlueStore::BlueStore(CephContext *cct, const string& path)
+  : ObjectStore(path),
+    cct(cct),
+    bluefs(NULL),
+    bluefs_shared_bdev(0),
+    db(NULL),
+    fs(NULL),
+    bdev(NULL),
+    fm(NULL),
+    alloc(NULL),
+    path_fd(-1),
+    fsid_fd(-1),
+    mounted(false),
+    coll_lock("BlueStore::coll_lock"),
+    nid_lock("BlueStore::nid_lock"),
+    nid_max(0),
+    throttle_ops(cct, "bluestore_max_ops", cct->_conf->bluestore_max_ops),
+    throttle_bytes(cct, "bluestore_max_bytes", cct->_conf->bluestore_max_bytes),
+    throttle_wal_ops(cct, "bluestore_wal_max_ops",
+		     cct->_conf->bluestore_max_ops +
+		     cct->_conf->bluestore_wal_max_ops),
+    throttle_wal_bytes(cct, "bluestore_wal_max_bytes",
+		       cct->_conf->bluestore_max_bytes +
+		       cct->_conf->bluestore_wal_max_bytes),
+    wal_lock("BlueStore::wal_lock"),
+    wal_seq(0),
+    wal_tp(cct,
+	   "BlueStore::wal_tp",
+           "tp_wal",
+	   cct->_conf->bluestore_wal_threads,
+	   "bluestore_wal_threads"),
+    wal_wq(this,
+	     cct->_conf->bluestore_wal_thread_timeout,
+	     cct->_conf->bluestore_wal_thread_suicide_timeout,
+	     &wal_tp),
+    finisher(cct),
+    kv_sync_thread(this),
+    kv_lock("BlueStore::kv_lock"),
+    kv_stop(false),
+    logger(NULL),
+    reap_lock("BlueStore::reap_lock")
+{
+  _init_logger();
+}
+
+BlueStore::~BlueStore()
+{
+  _shutdown_logger();
+  assert(!mounted);
+  assert(db == NULL);
+  assert(bluefs == NULL);
+  assert(fsid_fd < 0);
+}
+
+void BlueStore::_init_logger()
+{
+  // XXX
+}
+
+void BlueStore::_shutdown_logger()
+{
+  // XXX
+}
+
+int BlueStore::get_block_device_fsid(const string& path, uuid_d *fsid)
+{
+  bluestore_bdev_label_t label;
+  int r = _read_bdev_label(path, &label);
+  if (r < 0)
+    return r;
+  *fsid = label.osd_uuid;
+  return 0;
+}
+
+int BlueStore::_open_path()
+{
+  assert(path_fd < 0);
+  path_fd = ::open(path.c_str(), O_DIRECTORY);
+  if (path_fd < 0) {
+    int r = -errno;
+    derr << __func__ << " unable to open " << path << ": " << cpp_strerror(r)
+	 << dendl;
+    return r;
+  }
+  assert(fs == NULL);
+  fs = FS::create(path_fd);
+  dout(1) << __func__ << " using fs driver '" << fs->get_name() << "'" << dendl;
+  return 0;
+}
+
+void BlueStore::_close_path()
+{
+  VOID_TEMP_FAILURE_RETRY(::close(path_fd));
+  path_fd = -1;
+  delete fs;
+  fs = NULL;
+}
+
+int BlueStore::_write_bdev_label(string path, bluestore_bdev_label_t label)
+{
+  dout(10) << __func__ << " path " << path << " label " << label << dendl;
+  bufferlist bl;
+  ::encode(label, bl);
+  uint32_t crc = bl.crc32c(-1);
+  ::encode(crc, bl);
+  assert(bl.length() <= BDEV_LABEL_BLOCK_SIZE);
+  bufferptr z(BDEV_LABEL_BLOCK_SIZE - bl.length());
+  z.zero();
+  bl.append(z);
+
+  int fd = ::open(path.c_str(), O_WRONLY);
+  if (fd < 0) {
+    fd = errno;
+    derr << __func__ << " failed to open " << path << ": " << cpp_strerror(fd)
+	 << dendl;
+    return fd;
+  }
+  int r = bl.write_fd(fd);
+  if (r < 0) {
+    derr << __func__ << " failed to write to " << path
+	 << ": " << cpp_strerror(r) << dendl;
+  }
+  VOID_TEMP_FAILURE_RETRY(::close(fd));
+  return r;
+}
+
+int BlueStore::_read_bdev_label(string path, bluestore_bdev_label_t *label)
+{
+  dout(10) << __func__ << dendl;
+  int fd = ::open(path.c_str(), O_RDONLY);
+  if (fd < 0) {
+    fd = -errno;
+    derr << __func__ << " failed to open " << path << ": " << cpp_strerror(fd)
+	 << dendl;
+    return fd;
+  }
+  bufferlist bl;
+  int r = bl.read_fd(fd, BDEV_LABEL_BLOCK_SIZE);
+  VOID_TEMP_FAILURE_RETRY(::close(fd));
+  if (r < 0) {
+    derr << __func__ << " failed to read from " << path
+	 << ": " << cpp_strerror(r) << dendl;
+    return r;
+  }
+
+  uint32_t crc, expected_crc;
+  bufferlist::iterator p = bl.begin();
+  try {
+    ::decode(*label, p);
+    bufferlist t;
+    t.substr_of(bl, 0, p.get_off());
+    crc = t.crc32c(-1);
+    ::decode(expected_crc, p);
+  }
+  catch (buffer::error& e) {
+    derr << __func__ << " unable to decode label at offset " << p.get_off()
+	 << ": " << e.what()
+	 << dendl;
+    return -EINVAL;
+  }
+  if (crc != expected_crc) {
+    derr << __func__ << " bad crc on label, expected " << expected_crc
+	 << " != actual " << crc << dendl;
+    return -EIO;
+  }
+  dout(10) << __func__ << " got " << *label << dendl;
+  return 0;
+}
+
+int BlueStore::_check_or_set_bdev_label(
+  string path, uint64_t size, string desc, bool create)
+{
+  bluestore_bdev_label_t label;
+  if (create) {
+    label.osd_uuid = fsid;
+    label.size = size;
+    label.btime = ceph_clock_now(NULL);
+    label.description = desc;
+    int r = _write_bdev_label(path, label);
+    if (r < 0)
+      return r;
+  } else {
+    int r = _read_bdev_label(path, &label);
+    if (r < 0)
+      return r;
+    if (label.osd_uuid != fsid) {
+      derr << __func__ << " bdev " << path << " fsid " << label.osd_uuid
+	   << " does not match our fsid " << fsid << dendl;
+      return -EIO;
+    }
+  }
+  return 0;
+}
+
+int BlueStore::_open_bdev(bool create)
+{
+  bluestore_bdev_label_t label;
+  assert(bdev == NULL);
+  bdev = new BlockDevice(aio_cb, static_cast<void*>(this));
+  string p = path + "/block";
+  int r = bdev->open(p);
+  if (r < 0)
+    goto fail;
+
+  r = _check_or_set_bdev_label(p, bdev->get_size(), "main", create);
+  if (r < 0)
+    goto fail_close;
+  return 0;
+
+ fail_close:
+  bdev->close();
+ fail:
+  delete bdev;
+  bdev = NULL;
+  return r;
+}
+
+void BlueStore::_close_bdev()
+{
+  assert(bdev);
+  bdev->close();
+  delete bdev;
+  bdev = NULL;
+}
+
+int BlueStore::_open_alloc()
+{
+  assert(fm == NULL);
+  assert(alloc == NULL);
+  fm = new FreelistManager();
+  int r = fm->init(db, PREFIX_ALLOC);
+  if (r < 0) {
+    delete fm;
+    fm = NULL;
+    return r;
+  }
+
+  alloc = Allocator::create("stupid");
+  uint64_t num = 0, bytes = 0;
+  const auto& fl = fm->get_freelist();
+  for (auto& p : fl) {
+    alloc->init_add_free(p.first, p.second);
+    ++num;
+    bytes += p.second;
+  }
+  dout(10) << __func__ << " loaded " << pretty_si_t(bytes)
+	   << " in " << num << " extents"
+	   << dendl;
+  return r;
+}
+
+void BlueStore::_close_alloc()
+{
+  assert(fm);
+  assert(alloc);
+  alloc->shutdown();
+  delete alloc;
+  alloc = NULL;
+  fm->shutdown();
+  delete fm;
+  fm = NULL;
+}
+
+int BlueStore::_open_fsid(bool create)
+{
+  assert(fsid_fd < 0);
+  int flags = O_RDWR;
+  if (create)
+    flags |= O_CREAT;
+  fsid_fd = ::openat(path_fd, "fsid", flags, 0644);
+  if (fsid_fd < 0) {
+    int err = -errno;
+    derr << __func__ << " " << cpp_strerror(err) << dendl;
+    return err;
+  }
+  return 0;
+}
+
+int BlueStore::_read_fsid(uuid_d *uuid)
+{
+  char fsid_str[40];
+  memset(fsid_str, 0, sizeof(fsid_str));
+  int ret = safe_read(fsid_fd, fsid_str, sizeof(fsid_str));
+  if (ret < 0) {
+    derr << __func__ << " failed: " << cpp_strerror(ret) << dendl;
+    return ret;
+  }
+  if (ret > 36)
+    fsid_str[36] = 0;
+  else
+    fsid_str[ret] = 0;
+  if (!uuid->parse(fsid_str)) {
+    derr << __func__ << " unparsable uuid " << fsid_str << dendl;
+    return -EINVAL;
+  }
+  return 0;
+}
+
+int BlueStore::_write_fsid()
+{
+  int r = ::ftruncate(fsid_fd, 0);
+  if (r < 0) {
+    r = -errno;
+    derr << __func__ << " fsid truncate failed: " << cpp_strerror(r) << dendl;
+    return r;
+  }
+  string str = stringify(fsid) + "\n";
+  r = safe_write(fsid_fd, str.c_str(), str.length());
+  if (r < 0) {
+    derr << __func__ << " fsid write failed: " << cpp_strerror(r) << dendl;
+    return r;
+  }
+  r = ::fsync(fsid_fd);
+  if (r < 0) {
+    r = -errno;
+    derr << __func__ << " fsid fsync failed: " << cpp_strerror(r) << dendl;
+    return r;
+  }
+  return 0;
+}
+
+void BlueStore::_close_fsid()
+{
+  VOID_TEMP_FAILURE_RETRY(::close(fsid_fd));
+  fsid_fd = -1;
+}
+
+int BlueStore::_lock_fsid()
+{
+  struct flock l;
+  memset(&l, 0, sizeof(l));
+  l.l_type = F_WRLCK;
+  l.l_whence = SEEK_SET;
+  l.l_start = 0;
+  l.l_len = 0;
+  int r = ::fcntl(fsid_fd, F_SETLK, &l);
+  if (r < 0) {
+    int err = errno;
+    derr << __func__ << " failed to lock " << path << "/fsid"
+	 << " (is another ceph-osd still running?)"
+	 << cpp_strerror(err) << dendl;
+    return -err;
+  }
+  return 0;
+}
+
+bool BlueStore::test_mount_in_use()
+{
+  // most error conditions mean the mount is not in use (e.g., because
+  // it doesn't exist).  only if we fail to lock do we conclude it is
+  // in use.
+  bool ret = false;
+  int r = _open_path();
+  if (r < 0)
+    return false;
+  r = _open_fsid(false);
+  if (r < 0)
+    goto out_path;
+  r = _lock_fsid();
+  if (r < 0)
+    ret = true; // if we can't lock, it is in use
+  _close_fsid();
+ out_path:
+  _close_path();
+  return ret;
+}
+
+int BlueStore::_open_db(bool create)
+{
+  int r;
+  assert(!db);
+  char fn[PATH_MAX];
+  snprintf(fn, sizeof(fn), "%s/db", path.c_str());
+  string options;
+  stringstream err;
+
+  string kv_backend;
+  if (create) {
+    kv_backend = g_conf->bluestore_backend;
+  } else {
+    r = read_meta("kv_backend", &kv_backend);
+    if (r < 0) {
+      derr << __func__ << " uanble to read 'kv_backend' meta" << dendl;
+      return -EIO;
+    }
+  }
+  dout(10) << __func__ << " kv_backend = " << kv_backend << dendl;
+
+  bool do_bluefs;
+  if (create) {
+    do_bluefs = g_conf->bluestore_bluefs;
+  } else {
+    string s;
+    r = read_meta("bluefs", &s);
+    if (r < 0) {
+      derr << __func__ << " unable to read 'bluefs' meta" << dendl;
+      return -EIO;
+    }
+    if (s == "1") {
+      do_bluefs = true;
+    } else if (s == "0") {
+      do_bluefs = false;
+    } else {
+      derr << __func__ << " bluefs = " << s << " : not 0 or 1, aborting" << dendl;
+      return -EIO;
+    }
+  }
+  dout(10) << __func__ << " bluefs = " << bluefs << dendl;
+
+  rocksdb::Env *env = NULL;
+  if (do_bluefs) {
+    dout(10) << __func__ << " initializing bluefs" << dendl;
+    if (kv_backend != "rocksdb") {
+      derr << " backend must be rocksdb to use bluefs" << dendl;
+      return -EINVAL;
+    }
+    bluefs = new BlueFS;
+
+    char bfn[PATH_MAX];
+    struct stat st;
+    int id = 0;
+
+    snprintf(bfn, sizeof(bfn), "%s/block.db", path.c_str());
+    if (::stat(bfn, &st) == 0) {
+      r = bluefs->add_block_device(id, bfn);
+      if (r < 0) {
+        derr << __func__ << " add block device(" << bfn << ") returned: " 
+             << cpp_strerror(r) << dendl;
+        goto free_bluefs;
+      }
+      r = _check_or_set_bdev_label(bfn, bluefs->get_block_device_size(id),
+        "bluefs db", create);
+      if (r < 0) {
+        derr << __func__ << " check block device(" << bfn << ") label returned: " 
+             << cpp_strerror(r) << dendl;
+        goto free_bluefs;
+      }
+      if (create) {
+	bluefs->add_block_extent(
+	  id, BLUEFS_START,
+	  bluefs->get_block_device_size(id) - BLUEFS_START);
+      }
+      ++id;
+    }
+
+    snprintf(bfn, sizeof(bfn), "%s/block", path.c_str());
+    r = bluefs->add_block_device(id, bfn);
+    if (r < 0) {
+      derr << __func__ << " add block device(" << bfn << ") returned: " 
+           << cpp_strerror(r) << dendl;
+      goto free_bluefs;
+    }
+    if (create) {
+      // note: we might waste a 4k block here if block.db is used, but it's
+      // simpler.
+      uint64_t initial =
+	bdev->get_size() * (g_conf->bluestore_bluefs_min_ratio +
+			    g_conf->bluestore_bluefs_gift_ratio);
+      initial = MAX(initial, g_conf->bluestore_bluefs_min);
+      // align to bluefs's alloc_size
+      initial = ROUND_UP_TO(initial, g_conf->bluefs_alloc_size);
+      initial += g_conf->bluefs_alloc_size - BLUEFS_START;
+      bluefs->add_block_extent(id, BLUEFS_START, initial);
+      bluefs_extents.insert(BLUEFS_START, initial);
+    }
+    bluefs_shared_bdev = id;
+    ++id;
+    if (id == 2) {
+      // we have both block.db and block; tell rocksdb!
+      // note: the second (last) size value doesn't really matter
+      char db_paths[PATH_MAX*3];
+      snprintf(
+	db_paths, sizeof(db_paths), "%s/db,%lld %s/db.slow,%lld",
+	path.c_str(),
+	(unsigned long long)bluefs->get_block_device_size(0) * 95 / 100,
+	path.c_str(),
+	(unsigned long long)bluefs->get_block_device_size(1) * 95 / 100);
+      g_conf->set_val("rocksdb_db_paths", db_paths, false, false);
+      dout(10) << __func__ << " set rocksdb_db_paths to "
+	       << g_conf->rocksdb_db_paths << dendl;
+    }
+
+    snprintf(bfn, sizeof(bfn), "%s/block.wal", path.c_str());
+    if (::stat(bfn, &st) == 0) {
+      r = bluefs->add_block_device(id, bfn);
+      if (r < 0) {
+        derr << __func__ << " add block device(" << bfn << ") returned: " 
+	     << cpp_strerror(r) << dendl;
+        goto free_bluefs;			
+      }
+      r = _check_or_set_bdev_label(bfn, bluefs->get_block_device_size(id),
+        "bluefs wal", create);
+      if (r < 0) {
+        derr << __func__ << " check block device(" << bfn << ") label returned: " 
+	     << cpp_strerror(r) << dendl;
+        goto free_bluefs;
+      }
+      if (create) {
+	bluefs->add_block_extent(
+	  id, BDEV_LABEL_BLOCK_SIZE,
+	  bluefs->get_block_device_size(id) - BDEV_LABEL_BLOCK_SIZE);
+      }
+      g_conf->set_val("rocksdb_separate_wal_dir", "true");
+    } else {
+      g_conf->set_val("rocksdb_separate_wal_dir", "false");
+    }
+
+    if (create) {
+      bluefs->mkfs(fsid);
+    }
+    r = bluefs->mount();
+    if (r < 0) {
+      derr << __func__ << " failed bluefs mount: " << cpp_strerror(r) << dendl;
+      goto free_bluefs;
+    }
+    if (g_conf->bluestore_bluefs_env_mirror) {
+      rocksdb::Env *a = new BlueRocksEnv(bluefs);
+      unique_ptr<rocksdb::Directory> dir;
+      rocksdb::Env *b = rocksdb::Env::Default();
+      if (create) {
+	string cmd = "rm -rf " + path + "/db " +
+	  path + "/db.slow" +
+	  path + "/db.wal";
+	int r = system(cmd.c_str());
+	(void)r;
+      }
+      env = new rocksdb::EnvMirror(b, a);
+    } else {
+      env = new BlueRocksEnv(bluefs);
+
+      // simplify the dir names, too, as "seen" by rocksdb
+      strcpy(fn, "db");
+    }
+
+    if (create) {
+      env->CreateDir(fn);
+      if (g_conf->rocksdb_separate_wal_dir)
+	env->CreateDir(string(fn) + ".wal");
+      if (g_conf->rocksdb_db_paths.length())
+	env->CreateDir(string(fn) + ".slow");
+    }
+  } else if (create) {
+    int r = ::mkdir(fn, 0755);
+    if (r < 0)
+      r = -errno;
+    if (r < 0 && r != -EEXIST) {
+      derr << __func__ << " failed to create " << fn << ": " << cpp_strerror(r)
+	   << dendl;
+      return r;
+    }
+
+    // wal_dir, too!
+    char walfn[PATH_MAX];
+    snprintf(walfn, sizeof(walfn), "%s/db.wal", path.c_str());
+    r = ::mkdir(walfn, 0755);
+    if (r < 0)
+      r = -errno;
+    if (r < 0 && r != -EEXIST) {
+      derr << __func__ << " failed to create " << walfn
+	   << ": " << cpp_strerror(r)
+	   << dendl;
+      return r;
+    }
+  }
+
+  db = KeyValueDB::create(g_ceph_context,
+			  kv_backend,
+			  fn,
+			  static_cast<void*>(env));
+  if (!db) {
+    derr << __func__ << " error creating db" << dendl;
+    if (bluefs) {
+      bluefs->umount();
+      delete bluefs;
+      bluefs = NULL;
+    }
+    // delete env manually here since we can't depend on db to do this under this case
+    delete env;
+    env = NULL;
+    return -EIO;
+  }
+  
+  if (kv_backend == "rocksdb")
+    options = g_conf->bluestore_rocksdb_options;
+  db->init(options);
+  if (create)
+    r = db->create_and_open(err);
+  else
+    r = db->open(err);
+  if (r) {
+    derr << __func__ << " erroring opening db: " << err.str() << dendl;
+    if (bluefs) {
+      bluefs->umount();
+      delete bluefs;
+      bluefs = NULL;
+    }
+    delete db;
+    db = NULL;
+    return -EIO;
+  }
+  dout(1) << __func__ << " opened " << kv_backend
+	  << " path " << fn << " options " << options << dendl;
+  return 0;
+
+free_bluefs:
+  assert(bluefs);
+  delete bluefs;
+  bluefs = NULL;
+  return r;
+}
+
+void BlueStore::_close_db()
+{
+  assert(db);
+  delete db;
+  db = NULL;
+  if (bluefs) {
+    bluefs->umount();
+    delete bluefs;
+    bluefs = NULL;
+  }
+}
+
+int BlueStore::_reconcile_bluefs_freespace()
+{
+  dout(10) << __func__ << dendl;
+  interval_set<uint64_t> bset;
+  int r = bluefs->get_block_extents(bluefs_shared_bdev, &bset);
+  assert(r == 0);
+  if (bset == bluefs_extents) {
+    dout(10) << __func__ << " we agree bluefs has " << bset << dendl;
+    return 0;
+  }
+  dout(10) << __func__ << " bluefs says " << bset << dendl;
+  dout(10) << __func__ << " super says  " << bluefs_extents << dendl;
+
+  interval_set<uint64_t> overlap;
+  overlap.intersection_of(bset, bluefs_extents);
+
+  bset.subtract(overlap);
+  if (!bset.empty()) {
+    derr << __func__ << " bluefs extra " << bset << dendl;
+    return -EIO;
+  }
+
+  interval_set<uint64_t> super_extra;
+  super_extra = bluefs_extents;
+  super_extra.subtract(overlap);
+  if (!super_extra.empty()) {
+    // This is normal: it can happen if we commit to give extents to
+    // bluefs and we crash before bluefs commits that it owns them.
+    dout(10) << __func__ << " super extra " << super_extra << dendl;
+    for (interval_set<uint64_t>::iterator p = super_extra.begin();
+	 p != super_extra.end();
+	 ++p) {
+      bluefs->add_block_extent(bluefs_shared_bdev, p.get_start(), p.get_len());
+    }
+  }
+
+  return 0;
+}
+
+int BlueStore::_balance_bluefs_freespace(vector<bluestore_extent_t> *extents,
+					 KeyValueDB::Transaction t)
+{
+  int ret = 0;
+  assert(bluefs);
+
+  vector<pair<uint64_t,uint64_t>> bluefs_usage;  // <free, total> ...
+  bluefs->get_usage(&bluefs_usage);
+  assert(bluefs_usage.size() > bluefs_shared_bdev);
+
+  // fixme: look at primary bdev only for now
+  uint64_t bluefs_free = bluefs_usage[bluefs_shared_bdev].first;
+  uint64_t bluefs_total = bluefs_usage[bluefs_shared_bdev].second;
+  float bluefs_free_ratio = (float)bluefs_free / (float)bluefs_total;
+
+  uint64_t my_free = alloc->get_free();
+  uint64_t total = bdev->get_size();
+  float my_free_ratio = (float)my_free / (float)total;
+
+  uint64_t total_free = bluefs_free + my_free;
+
+  float bluefs_ratio = (float)bluefs_free / (float)total_free;
+
+  dout(10) << __func__
+	   << " bluefs " << pretty_si_t(bluefs_free)
+	   << " free (" << bluefs_free_ratio
+	   << ") bluestore " << pretty_si_t(my_free)
+	   << " free (" << my_free_ratio
+	   << "), bluefs_ratio " << bluefs_ratio
+	   << dendl;
+
+  uint64_t gift = 0;
+  uint64_t reclaim = 0;
+  if (bluefs_ratio < g_conf->bluestore_bluefs_min_ratio) {
+    gift = g_conf->bluestore_bluefs_gift_ratio * total_free;
+    dout(10) << __func__ << " bluefs_ratio " << bluefs_ratio
+	     << " < min_ratio " << g_conf->bluestore_bluefs_min_ratio
+	     << ", should gift " << pretty_si_t(gift) << dendl;
+  } else if (bluefs_ratio > g_conf->bluestore_bluefs_max_ratio) {
+    reclaim = g_conf->bluestore_bluefs_reclaim_ratio * total_free;
+    if (bluefs_total - reclaim < g_conf->bluestore_bluefs_min)
+      reclaim = bluefs_total - g_conf->bluestore_bluefs_min;
+    dout(10) << __func__ << " bluefs_ratio " << bluefs_ratio
+	     << " > max_ratio " << g_conf->bluestore_bluefs_max_ratio
+	     << ", should reclaim " << pretty_si_t(reclaim) << dendl;
+  }
+  if (bluefs_total < g_conf->bluestore_bluefs_min) {
+    uint64_t g = g_conf->bluestore_bluefs_min;
+    dout(10) << __func__ << " bluefs_total " << bluefs_total
+	     << " < min " << g_conf->bluestore_bluefs_min
+	     << ", should gift " << pretty_si_t(g) << dendl;
+    if (g > gift)
+      gift = g;
+    reclaim = 0;
+  }
+
+  if (gift) {
+    // round up to alloc size
+    uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+    gift = ROUND_UP_TO(gift, min_alloc_size);
+
+    // hard cap to fit into 32 bits
+    gift = MIN(gift, 1ull<<31);
+    dout(10) << __func__ << " gifting " << gift
+	     << " (" << pretty_si_t(gift) << ")" << dendl;
+
+    // fixme: just do one allocation to start...
+    int r = alloc->reserve(gift);
+    assert(r == 0);
+
+    bluestore_extent_t e;
+    r = alloc->allocate(gift, min_alloc_size, 0, &e.offset, &e.length);
+    if (r < 0) {
+      assert(0 == "allocate failed, wtf");
+      return r;
+    }
+    if (e.length < gift) {
+      alloc->unreserve(gift - e.length);
+    }
+
+    dout(1) << __func__ << " gifting " << e << " to bluefs" << dendl;
+    extents->push_back(e);
+    ret = 1;
+  }
+
+  // reclaim from bluefs?
+  if (reclaim) {
+    // round up to alloc size
+    uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+    reclaim = ROUND_UP_TO(reclaim, min_alloc_size);
+
+    // hard cap to fit into 32 bits
+    reclaim = MIN(reclaim, 1ull<<31);
+    dout(10) << __func__ << " reclaiming " << reclaim
+	     << " (" << pretty_si_t(reclaim) << ")" << dendl;
+
+    uint64_t offset = 0;
+    uint32_t length = 0;
+
+    // NOTE: this will block and do IO.
+    int r = bluefs->reclaim_blocks(bluefs_shared_bdev, reclaim,
+				   &offset, &length);
+    assert(r >= 0);
+
+    bluefs_extents.erase(offset, length);
+
+    fm->release(offset, length, t);
+    alloc->release(offset, length);
+    ret = 1;
+  }
+
+  return ret;
+}
+
+void BlueStore::_commit_bluefs_freespace(
+  const vector<bluestore_extent_t>& bluefs_gift_extents)
+{
+  dout(10) << __func__ << dendl;
+  for (auto& p : bluefs_gift_extents) {
+    bluefs->add_block_extent(bluefs_shared_bdev, p.offset, p.length);
+  }
+}
+
+int BlueStore::_open_collections(int *errors)
+{
+  assert(coll_map.empty());
+  KeyValueDB::Iterator it = db->get_iterator(PREFIX_COLL);
+  for (it->upper_bound(string());
+       it->valid();
+       it->next()) {
+    coll_t cid;
+    if (cid.parse(it->key())) {
+      CollectionRef c(new Collection(this, cid));
+      bufferlist bl;
+      db->get(PREFIX_COLL, it->key(), &bl);
+      bufferlist::iterator p = bl.begin();
+      ::decode(c->cnode, p);
+      dout(20) << __func__ << " opened " << cid << dendl;
+      coll_map[cid] = c;
+    } else {
+      derr << __func__ << " unrecognized collection " << it->key() << dendl;
+      if (errors)
+	(*errors)++;
+    }
+  }
+  return 0;
+}
+
+int BlueStore::_setup_block_symlink_or_file(
+  string name,
+  string path,
+  uint64_t size)
+{
+  dout(20) << __func__ << " name " << name << " path " << path
+	   << " size " << size << dendl;
+  if (path.length()) {
+    int r = ::symlinkat(path.c_str(), path_fd, name.c_str());
+    if (r < 0) {
+      r = -errno;
+      derr << __func__ << " failed to create " << name << " symlink to "
+	   << path << ": " << cpp_strerror(r) << dendl;
+      return r;
+    }
+  } else if (size) {
+    struct stat st;
+    int r = ::fstatat(path_fd, name.c_str(), &st, 0);
+    if (r < 0)
+      r = -errno;
+    if (r == -ENOENT) {
+      int fd = ::openat(path_fd, name.c_str(), O_CREAT|O_RDWR, 0644);
+      if (fd < 0) {
+	int r = -errno;
+	derr << __func__ << " failed to create " << name << " file: "
+	     << cpp_strerror(r) << dendl;
+	return r;
+      }
+      int r = ::ftruncate(fd, size);
+      assert(r == 0);
+      dout(1) << __func__ << " created " << name << " file with size "
+	      << pretty_si_t(size) << "B" << dendl;
+      VOID_TEMP_FAILURE_RETRY(::close(fd));
+    } else if (r < 0) {
+      derr << __func__ << " failed to stat " << name << " file: "
+           << cpp_strerror(r) << dendl;
+      return r;
+    } 
+  }
+  return 0;
+}
+
+int BlueStore::mkfs()
+{
+  dout(1) << __func__ << " path " << path << dendl;
+  int r;
+  uuid_d old_fsid;
+
+  r = _open_path();
+  if (r < 0)
+    return r;
+
+  r = _open_fsid(true);
+  if (r < 0)
+    goto out_path_fd;
+
+  r = _lock_fsid();
+  if (r < 0)
+    goto out_close_fsid;
+
+  r = _read_fsid(&old_fsid);
+  if (r < 0 && old_fsid.is_zero()) {
+    if (fsid.is_zero()) {
+      fsid.generate_random();
+      dout(1) << __func__ << " generated fsid " << fsid << dendl;
+    } else {
+      dout(1) << __func__ << " using provided fsid " << fsid << dendl;
+    }
+    // we'll write it last.
+  } else {
+    if (!fsid.is_zero() && fsid != old_fsid) {
+      derr << __func__ << " on-disk fsid " << old_fsid
+	   << " != provided " << fsid << dendl;
+      r = -EINVAL;
+      goto out_close_fsid;
+    }
+    fsid = old_fsid;
+    dout(1) << __func__ << " already created, fsid is " << fsid << dendl;
+    goto out_close_fsid;
+  }
+
+  r = _setup_block_symlink_or_file("block", g_conf->bluestore_block_path,
+				   g_conf->bluestore_block_size);
+  if (r < 0)
+    goto out_close_fsid;
+  r = _setup_block_symlink_or_file("block.wal", g_conf->bluestore_block_wal_path,
+				   g_conf->bluestore_block_wal_size);
+  if (r < 0)
+    goto out_close_fsid;
+  r = _setup_block_symlink_or_file("block.db", g_conf->bluestore_block_db_path,
+				   g_conf->bluestore_block_db_size);
+  if (r < 0)
+    goto out_close_fsid;
+
+  r = _open_bdev(true);
+  if (r < 0)
+    goto out_close_fsid;
+
+  r = _open_db(true);
+  if (r < 0)
+    goto out_close_bdev;
+
+  r = _open_alloc();
+  if (r < 0)
+    goto out_close_db;
+
+  // initialize freespace
+  {
+    dout(20) << __func__ << " initializing freespace" << dendl;
+    KeyValueDB::Transaction t = db->get_transaction();
+    uint64_t reserved = 0;
+    if (g_conf->bluestore_bluefs) {
+      assert(bluefs_extents.num_intervals() == 1);
+      interval_set<uint64_t>::iterator p = bluefs_extents.begin();
+      reserved = p.get_start() + p.get_len();
+      dout(20) << __func__ << " reserved " << reserved << " for bluefs" << dendl;
+      bufferlist bl;
+      ::encode(bluefs_extents, bl);
+      t->set(PREFIX_SUPER, "bluefs_extents", bl);
+      dout(20) << __func__ << " bluefs_extents " << bluefs_extents << dendl;
+    } else {
+      reserved = BLUEFS_START;
+    }
+    uint64_t end = bdev->get_size() - reserved;
+    if (g_conf->bluestore_debug_prefill > 0) {
+      dout(1) << __func__ << " pre-fragmenting freespace, using "
+	      << g_conf->bluestore_debug_prefill << " with max free extent "
+	      << g_conf->bluestore_debug_prefragment_max << dendl;
+      uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+      uint64_t start = ROUND_UP_TO(reserved, min_alloc_size);
+      uint64_t max_b = g_conf->bluestore_debug_prefragment_max / min_alloc_size;
+      float r = g_conf->bluestore_debug_prefill;
+      while (start < end) {
+	uint64_t l = (rand() % max_b + 1) * min_alloc_size;
+	if (start + l > end)
+	  l = end - start;
+	l = ROUND_UP_TO(l, min_alloc_size);
+	fm->release(start, l, t);
+	uint64_t u = 1 + (uint64_t)(r * (double)l / (1.0 - r));
+	u = ROUND_UP_TO(u, min_alloc_size);
+	dout(20) << "  free " << start << "~" << l << " use " << u << dendl;
+	start += l + u;
+      }
+    } else {
+      fm->release(reserved, end, t);
+    }
+    db->submit_transaction_sync(t);
+  }
+
+  r = write_meta("kv_backend", g_conf->bluestore_backend);
+  if (r < 0)
+    goto out_close_alloc;
+  r = write_meta("bluefs", stringify((int)g_conf->bluestore_bluefs));
+  if (r < 0)
+    goto out_close_alloc;
+  r = write_meta("type", "bluestore");
+  if (r < 0)
+    goto out_close_alloc;
+
+  // indicate mkfs completion/success by writing the fsid file
+  r = _write_fsid();
+  if (r == 0)
+    dout(10) << __func__ << " success" << dendl;
+  else
+    derr << __func__ << " error writing fsid: " << cpp_strerror(r) << dendl;
+
+ out_close_alloc:
+  _close_alloc();
+ out_close_db:
+  _close_db();
+ out_close_bdev:
+  _close_bdev();
+ out_close_fsid:
+  _close_fsid();
+ out_path_fd:
+  _close_path();
+  return r;
+}
+
+int BlueStore::mount()
+{
+  dout(1) << __func__ << " path " << path << dendl;
+
+  if (g_conf->bluestore_fsck_on_mount) {
+    int rc = fsck();
+    if (rc < 0)
+      return rc;
+    if (rc > 0) {
+      derr << __func__ << " fsck found " << rc << " errors" << dendl;
+      return -EIO;
+    }
+  }
+
+  int r = _open_path();
+  if (r < 0)
+    return r;
+  r = _open_fsid(false);
+  if (r < 0)
+    goto out_path;
+
+  r = _read_fsid(&fsid);
+  if (r < 0)
+    goto out_fsid;
+
+  r = _lock_fsid();
+  if (r < 0)
+    goto out_fsid;
+
+  r = _open_bdev(false);
+  if (r < 0)
+    goto out_fsid;
+
+  r = _open_db(false);
+  if (r < 0)
+    goto out_bdev;
+
+  r = _open_alloc();
+  if (r < 0)
+    goto out_db;
+
+  r = _open_super_meta();
+  if (r < 0)
+    goto out_alloc;
+
+  r = _open_collections();
+  if (r < 0)
+    goto out_alloc;
+
+  if (bluefs) {
+    r = _reconcile_bluefs_freespace();
+    if (r < 0)
+      goto out_coll;
+  }
+
+  finisher.start();
+  wal_tp.start();
+  kv_sync_thread.create("bstore_kv_sync");
+
+  r = _wal_replay();
+  if (r < 0)
+    goto out_stop;
+
+  mounted = true;
+  return 0;
+
+ out_stop:
+  _kv_stop();
+  wal_tp.stop();
+  finisher.wait_for_empty();
+  finisher.stop();
+out_coll:
+  coll_map.clear();
+ out_alloc:
+  _close_alloc();
+ out_db:
+  _close_db();
+ out_bdev:
+  _close_bdev();
+ out_fsid:
+  _close_fsid();
+ out_path:
+  _close_path();
+  return r;
+}
+
+int BlueStore::umount()
+{
+  assert(mounted);
+  dout(1) << __func__ << dendl;
+
+  _sync();
+  _reap_collections();
+  coll_map.clear();
+
+  dout(20) << __func__ << " stopping kv thread" << dendl;
+  _kv_stop();
+  dout(20) << __func__ << " draining wal_wq" << dendl;
+  wal_wq.drain();
+  dout(20) << __func__ << " stopping wal_tp" << dendl;
+  wal_tp.stop();
+  dout(20) << __func__ << " draining finisher" << dendl;
+  finisher.wait_for_empty();
+  dout(20) << __func__ << " stopping finisher" << dendl;
+  finisher.stop();
+  dout(20) << __func__ << " closing" << dendl;
+
+  mounted = false;
+  _close_alloc();
+  _close_db();
+  _close_bdev();
+  _close_fsid();
+  _close_path();
+
+  if (g_conf->bluestore_fsck_on_umount) {
+    int rc = fsck();
+    if (rc < 0)
+      return rc;
+    if (rc > 0) {
+      derr << __func__ << " fsck found " << rc << " errors" << dendl;
+      return -EIO;
+    }
+  }
+  return 0;
+}
+
+int BlueStore::_verify_enode_shared(
+  EnodeRef enode,
+  vector<bluestore_extent_t>& v)
+{
+  int errors = 0;
+  interval_set<uint64_t> span;
+  bluestore_extent_ref_map_t ref_map;
+  dout(10) << __func__ << " hash " << enode->hash << " v " << v << dendl;
+  for (auto& p : v) {
+    interval_set<uint64_t> t, i;
+    t.insert(p.offset, p.length);
+    i.intersection_of(t, span);
+    t.subtract(i);
+    dout(20) << __func__ << "  extent " << p << " t " << t << " i " << i
+	     << dendl;
+    for (interval_set<uint64_t>::iterator q = t.begin(); q != t.end(); ++q) {
+      ref_map.add(q.get_start(), q.get_len(), 1);
+    }
+    for (interval_set<uint64_t>::iterator q = i.begin(); q != i.end(); ++q) {
+      ref_map.get(q.get_start(), q.get_len());
+    }
+    span.insert(t);
+  }
+  if (enode->ref_map != ref_map) {
+    derr << " hash " << enode->hash << " ref_map " << enode->ref_map
+	 << " != expected " << ref_map << dendl;
+    ++errors;
+  }
+  return errors;
+}
+
+int BlueStore::fsck()
+{
+  dout(1) << __func__ << dendl;
+  int errors = 0;
+  set<uint64_t> used_nids;
+  set<uint64_t> used_omap_head;
+  interval_set<uint64_t> used_blocks;
+  KeyValueDB::Iterator it;
+  EnodeRef enode;
+  vector<bluestore_extent_t> hash_shared;
+
+  int r = _open_path();
+  if (r < 0)
+    return r;
+  r = _open_fsid(false);
+  if (r < 0)
+    goto out_path;
+
+  r = _read_fsid(&fsid);
+  if (r < 0)
+    goto out_fsid;
+
+  r = _lock_fsid();
+  if (r < 0)
+    goto out_fsid;
+
+  r = _open_bdev(false);
+  if (r < 0)
+    goto out_fsid;
+
+  r = _open_db(false);
+  if (r < 0)
+    goto out_bdev;
+
+  r = _open_alloc();
+  if (r < 0)
+    goto out_db;
+
+  r = _open_super_meta();
+  if (r < 0)
+    goto out_alloc;
+
+  r = _open_collections(&errors);
+  if (r < 0)
+    goto out_alloc;
+
+  used_blocks.insert(0, BLUEFS_START);
+  if (bluefs) {
+    used_blocks.insert(bluefs_extents);
+    r = bluefs->fsck();
+    if (r < 0) {
+      coll_map.clear();
+      goto out_alloc;
+    }
+    if (r > 0)
+      errors += r;
+  }
+
+  // walk collections, objects
+  for (ceph::unordered_map<coll_t, CollectionRef>::iterator p = coll_map.begin();
+       p != coll_map.end() && !errors;
+       ++p) {
+    dout(1) << __func__ << " collection " << p->first << dendl;
+    CollectionRef c = _get_collection(p->first);
+    RWLock::RLocker l(c->lock);
+    ghobject_t pos;
+    while (!errors) {
+      vector<ghobject_t> ols;
+      int r = collection_list(p->first, pos, ghobject_t::get_max(), true,
+			      100, &ols, &pos);
+      if (r < 0) {
+	++errors;
+	break;
+      }
+      if (ols.empty()) {
+	break;
+      }
+      for (auto& oid : ols) {
+	dout(10) << __func__ << "  " << oid << dendl;
+	OnodeRef o = c->get_onode(oid, false);
+	if (!o || !o->exists) {
+	  ++errors;
+	  break;
+	}
+	if (enode && enode->hash != o->oid.hobj.get_hash()) {
+	  if (enode)
+	    errors += _verify_enode_shared(enode, hash_shared);
+	  enode = c->get_enode(o->oid.hobj.get_hash());
+	  hash_shared.clear();
+	}
+	if (o->onode.nid) {
+	  if (used_nids.count(o->onode.nid)) {
+	    derr << " " << oid << " nid " << o->onode.nid << " already in use"
+		 << dendl;
+	    ++errors;
+	    break;
+	  }
+	  used_nids.insert(o->onode.nid);
+	}
+	// blocks
+	for (auto& b : o->onode.block_map) {
+	  if (b.second.has_flag(bluestore_extent_t::FLAG_SHARED))
+	    hash_shared.push_back(b.second);
+	  if (used_blocks.intersects(b.second.offset, b.second.length)) {
+	    derr << " " << oid << " extent " << b.first << ": " << b.second
+		 << " already allocated" << dendl;
+	    ++errors;
+	    continue;
+	  }
+	  used_blocks.insert(b.second.offset, b.second.length);
+	  if (b.second.end() > bdev->get_size()) {
+	    derr << " " << oid << " extent " << b.first << ": " << b.second
+		 << " past end of block device" << dendl;
+	    ++errors;
+	  }
+	}
+	// overlays
+	set<string> overlay_keys;
+	map<uint64_t,int> refs;
+	for (auto& v : o->onode.overlay_map) {
+	  if (v.first + v.second.length > o->onode.size) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " extends past end of object" << dendl;
+	    ++errors;
+	  }
+	  if (v.second.key > o->onode.last_overlay_key) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " is > last_overlay_key " << o->onode.last_overlay_key
+		 << dendl;
+	    ++errors;
+	  }
+	  ++refs[v.second.key];
+	  string key;
+	  bufferlist val;
+	  get_overlay_key(o->onode.nid, v.second.key, &key);
+	  overlay_keys.insert(key);
+	  int r = db->get(PREFIX_OVERLAY, key, &val);
+	  if (r < 0) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " failed to fetch: " << cpp_strerror(r) << dendl;
+	    ++errors;
+	  }
+	  if (val.length() < v.second.value_offset + v.second.length) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " too short, " << val.length() << dendl;
+	    ++errors;
+	  }
+	}
+	for (auto& vr : o->onode.overlay_refs) {
+	  if (refs[vr.first] != vr.second) {
+	    derr << " " << oid << " overlay key " << vr.first
+		 << " says " << vr.second << " refs but we have "
+		 << refs[vr.first] << dendl;
+	    ++errors;
+	  }
+	  refs.erase(vr.first);
+	}
+	for (auto& p : refs) {
+	  if (p.second > 1) {
+	    derr << " " << oid << " overlay key " << p.first
+		 << " has " << p.second << " refs but they are not recorded"
+		 << dendl;
+	    ++errors;
+	  }
+	}
+	do {
+	  string start;
+	  get_overlay_key(o->onode.nid, 0, &start);
+	  KeyValueDB::Iterator it = db->get_iterator(PREFIX_OVERLAY);
+	  if (!it)
+	    break;
+	  for (it->lower_bound(start); it->valid(); it->next()) {
+	    string k = it->key();
+	    const char *p = k.c_str();
+	    uint64_t nid;
+	    p = _key_decode_u64(p, &nid);
+	    if (nid != o->onode.nid)
+	      break;
+	    if (!overlay_keys.count(k)) {
+	      derr << " " << oid << " has stray overlay kv pair for "
+		   << k << dendl;
+	      ++errors;
+	    }
+	  }
+	} while (false);
+	// omap
+	while (o->onode.omap_head) {
+	  if (used_omap_head.count(o->onode.omap_head)) {
+	    derr << " " << oid << " omap_head " << o->onode.omap_head
+		 << " already in use" << dendl;
+	    ++errors;
+	    break;
+	  }
+	  used_omap_head.insert(o->onode.omap_head);
+	  // hrm, scan actual key/value pairs?
+	  KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+	  if (!it)
+	    break;
+	  string head, tail;
+	  get_omap_header(o->onode.omap_head, &head);
+	  get_omap_tail(o->onode.omap_head, &tail);
+	  it->lower_bound(head);
+	  while (it->valid()) {
+	    if (it->key() == head) {
+	      dout(30) << __func__ << "  got header" << dendl;
+	    } else if (it->key() >= tail) {
+	      dout(30) << __func__ << "  reached tail" << dendl;
+	      break;
+	    } else {
+	      string user_key;
+	      decode_omap_key(it->key(), &user_key);
+	      dout(30) << __func__
+		       << "  got " << pretty_binary_string(it->key())
+		       << " -> " << user_key << dendl;
+	      assert(it->key() < tail);
+	    }
+	    it->next();
+	  }
+	  break;
+	}
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking for stray objects" << dendl;
+  it = db->get_iterator(PREFIX_OBJ);
+  if (it) {
+    CollectionRef c;
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      ghobject_t oid;
+      int r = get_key_object(it->key(), &oid);
+      if (r < 0) {
+	dout(30) << __func__ << "  bad object key "
+		 << pretty_binary_string(it->key()) << dendl;
+	++errors;
+	continue;
+      }
+      if (!c || !c->contains(oid)) {
+	c = NULL;
+	for (ceph::unordered_map<coll_t, CollectionRef>::iterator p =
+	       coll_map.begin();
+	     p != coll_map.end() && !errors;
+	     ++p) {
+	  if (p->second->contains(oid)) {
+	    c = p->second;
+	    break;
+	  }
+	}
+	if (!c) {
+	  dout(30) << __func__ << "  stray object " << oid
+		   << " not owned by any collection" << dendl;
+	  ++errors;
+	  continue;
+	}
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking for stray overlay data" << dendl;
+  it = db->get_iterator(PREFIX_OVERLAY);
+  if (it) {
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      string key = it->key();
+      const char *p = key.c_str();
+      uint64_t nid;
+      p = _key_decode_u64(p, &nid);
+      if (used_nids.count(nid) == 0) {
+	derr << __func__ << " found stray overlay data on nid " << nid << dendl;
+	++errors;
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking for stray omap data" << dendl;
+  it = db->get_iterator(PREFIX_OMAP);
+  if (it) {
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      string key = it->key();
+      const char *p = key.c_str();
+      uint64_t omap_head;
+      p = _key_decode_u64(p, &omap_head);
+      if (used_omap_head.count(omap_head) == 0) {
+	derr << __func__ << " found stray omap data on omap_head " << omap_head
+	     << dendl;
+	++errors;
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking wal events" << dendl;
+  {
+    it = db->get_iterator(PREFIX_WAL);
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      bufferlist bl = it->value();
+      bufferlist::iterator p = bl.begin();
+      bluestore_wal_transaction_t wt;
+      try {
+	::decode(wt, p);
+      } catch (buffer::error& e) {
+	derr << __func__ << " failed to decode wal txn "
+	     << pretty_binary_string(it->key()) << dendl;
+	return -EIO;
+      }
+      dout(20) << __func__ << "  wal " << wt.seq
+	       << " ops " << wt.ops.size()
+	       << " released " << wt.released << dendl;
+      used_blocks.insert(wt.released);
+    }
+  }
+
+  dout(1) << __func__ << " checking freelist vs allocated" << dendl;
+  {
+    const auto& free = fm->get_freelist();
+    for (auto p = free.begin();
+	 p != free.end(); ++p) {
+      if (used_blocks.intersects(p->first, p->second)) {
+	derr << __func__ << " free extent " << p->first << "~" << p->second
+	     << " intersects allocated blocks" << dendl;
+	interval_set<uint64_t> free, overlap;
+	free.insert(p->first, p->second);
+	overlap.intersection_of(free, used_blocks);
+	derr << __func__ << " overlap: " << overlap << dendl;
+	++errors;
+	continue;
+      }
+      used_blocks.insert(p->first, p->second);
+    }
+    if (!used_blocks.contains(0, bdev->get_size())) {
+      derr << __func__ << " leaked some space; free+used = "
+	   << used_blocks
+	   << " != expected 0~" << bdev->get_size()
+	   << dendl;
+      ++errors;
+    }
+  }
+
+  coll_map.clear();
+ out_alloc:
+  _close_alloc();
+ out_db:
+  it.reset();  // before db is closed
+  _close_db();
+ out_bdev:
+  _close_bdev();
+ out_fsid:
+  _close_fsid();
+ out_path:
+  _close_path();
+
+  // fatal errors take precedence
+  if (r < 0)
+    return r;
+
+  dout(1) << __func__ << " finish with " << errors << " errors" << dendl;
+  return errors;
+}
+
+void BlueStore::_sync()
+{
+  dout(10) << __func__ << dendl;
+
+  // flush aios in flght
+  bdev->flush();
+
+  kv_lock.Lock();
+  while (!kv_committing.empty() ||
+	 !kv_queue.empty()) {
+    dout(20) << " waiting for kv to commit" << dendl;
+    kv_sync_cond.Wait(kv_lock);
+  }
+  kv_lock.Unlock();
+
+  dout(10) << __func__ << " done" << dendl;
+}
+
+int BlueStore::statfs(struct statfs *buf)
+{
+  memset(buf, 0, sizeof(*buf));
+  buf->f_blocks = bdev->get_size() / bdev->get_block_size();
+  buf->f_bsize = bdev->get_block_size();
+  buf->f_bfree = fm->get_total_free() / bdev->get_block_size();
+  buf->f_bavail = buf->f_bfree;
+  dout(20) << __func__ << " free " << pretty_si_t(buf->f_bfree * buf->f_bsize)
+	   << " / " << pretty_si_t(buf->f_blocks * buf->f_bsize) << dendl;
+  return 0;
+}
+
+// ---------------
+// cache
+
+BlueStore::CollectionRef BlueStore::_get_collection(coll_t cid)
+{
+  RWLock::RLocker l(coll_lock);
+  ceph::unordered_map<coll_t,CollectionRef>::iterator cp = coll_map.find(cid);
+  if (cp == coll_map.end())
+    return CollectionRef();
+  return cp->second;
+}
+
+void BlueStore::_queue_reap_collection(CollectionRef& c)
+{
+  dout(10) << __func__ << " " << c->cid << dendl;
+  Mutex::Locker l(reap_lock);
+  removed_collections.push_back(c);
+}
+
+void BlueStore::_reap_collections()
+{
+  reap_lock.Lock();
+
+  list<CollectionRef> removed_colls;
+  removed_colls.swap(removed_collections);
+  reap_lock.Unlock();
+
+  for (list<CollectionRef>::iterator p = removed_colls.begin();
+       p != removed_colls.end();
+       ++p) {
+    CollectionRef c = *p;
+    dout(10) << __func__ << " " << c->cid << dendl;
+    {
+      pair<ghobject_t,OnodeRef> next;
+      while (c->onode_map.get_next(next.first, &next)) {
+	assert(!next.second->exists);
+	if (!next.second->flush_txns.empty()) {
+	  dout(10) << __func__ << " " << c->cid << " " << next.second->oid
+		   << " flush_txns " << next.second->flush_txns << dendl;
+	  return;
+	}
+      }
+    }
+    c->onode_map.clear();
+    dout(10) << __func__ << " " << c->cid << " done" << dendl;
+  }
+
+  dout(10) << __func__ << " all reaped" << dendl;
+  reap_cond.Signal();
+}
+
+// ---------------
+// read operations
+
+bool BlueStore::exists(coll_t cid, const ghobject_t& oid)
+{
+  dout(10) << __func__ << " " << cid << " " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return false;
+  RWLock::RLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists)
+    return false;
+  return true;
+}
+
+int BlueStore::stat(
+    coll_t cid,
+    const ghobject_t& oid,
+    struct stat *st,
+    bool allow_eio)
+{
+  dout(10) << __func__ << " " << cid << " " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists)
+    return -ENOENT;
+  st->st_size = o->onode.size;
+  st->st_blksize = 4096;
+  st->st_blocks = (st->st_size + st->st_blksize - 1) / st->st_blksize;
+  st->st_nlink = 1;
+  return 0;
+}
+
+int BlueStore::read(
+  coll_t cid,
+  const ghobject_t& oid,
+  uint64_t offset,
+  size_t length,
+  bufferlist& bl,
+  uint32_t op_flags,
+  bool allow_eio)
+{
+  dout(15) << __func__ << " " << cid << " " << oid
+	   << " " << offset << "~" << length
+	   << dendl;
+  bl.clear();
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+
+  int r;
+
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+
+  if (offset == length && offset == 0)
+    length = o->onode.size;
+
+  r = _do_read(o, offset, length, bl, op_flags);
+
+ out:
+  dout(10) << __func__ << " " << cid << " " << oid
+	   << " " << offset << "~" << length
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_do_read(
+    OnodeRef o,
+    uint64_t offset,
+    size_t length,
+    bufferlist& bl,
+    uint32_t op_flags)
+{
+  map<uint64_t,bluestore_extent_t>::iterator bp, bend;
+  map<uint64_t,bluestore_overlay_t>::iterator op, oend;
+  uint64_t block_size = bdev->get_block_size();
+  int r;
+  IOContext ioc(NULL);   // FIXME?
+
+  // generally, don't buffer anything, unless the client explicitly requests
+  // it.
+  bool buffered = false;
+  if (op_flags & CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) {
+    dout(20) << __func__ << " will do buffered read" << dendl;
+    buffered = true;
+  } else if (g_conf->bluestore_default_buffered_read &&
+	     (op_flags & (CEPH_OSD_OP_FLAG_FADVISE_DONTNEED |
+			  CEPH_OSD_OP_FLAG_FADVISE_NOCACHE)) == 0) {
+    dout(20) << __func__ << " defaulting to buffered read" << dendl;
+    buffered = true;
+  }
+
+  dout(20) << __func__ << " " << offset << "~" << length << " size "
+	   << o->onode.size << dendl;
+  bl.clear();
+  _dump_onode(o);
+
+  if (offset > o->onode.size) {
+    r = 0;
+    goto out;
+  }
+
+  if (offset + length > o->onode.size) {
+    length = o->onode.size - offset;
+  }
+
+  o->flush();
+
+  r = 0;
+
+  // loop over overlays and data fragments.  overlays take precedence.
+  bend = o->onode.block_map.end();
+  bp = o->onode.block_map.lower_bound(offset);
+  if (bp != o->onode.block_map.begin()) {
+    --bp;
+  }
+  oend = o->onode.overlay_map.end();
+  op = o->onode.overlay_map.lower_bound(offset);
+  if (op != o->onode.overlay_map.begin()) {
+    --op;
+  }
+  while (length > 0) {
+    if (op != oend && op->first + op->second.length < offset) {
+      dout(20) << __func__ << " skip overlay " << op->first << " " << op->second
+	       << dendl;
+      ++op;
+      continue;
+    }
+    if (bp != bend && bp->first + bp->second.length <= offset) {
+      dout(30) << __func__ << " skip frag " << bp->first << " " << bp->second
+	       << dendl;
+      ++bp;
+      continue;
+    }
+
+    // overlay?
+    if (op != oend && op->first <= offset) {
+      uint64_t x_off = offset - op->first + op->second.value_offset;
+      uint64_t x_len = MIN(op->first + op->second.length - offset, length);
+      dout(20) << __func__ << "  overlay " << op->first << " " << op->second
+	       << " use " << x_off << "~" << x_len << dendl;
+      bufferlist v;
+      string key;
+      get_overlay_key(o->onode.nid, op->second.key, &key);
+      db->get(PREFIX_OVERLAY, key, &v);
+      bufferlist frag;
+      frag.substr_of(v, x_off, x_len);
+      bl.claim_append(frag);
+      ++op;
+      length -= x_len;
+      offset += x_len;
+      continue;
+    }
+    unsigned x_len = length;
+    if (op != oend &&
+	op->first > offset &&
+	op->first - offset < x_len) {
+      x_len = op->first - offset;
+    }
+
+    // extent?
+    if (bp != bend && bp->first <= offset) {
+      uint64_t x_off = offset - bp->first;
+      x_len = MIN(x_len, bp->second.length - x_off);
+      if (!bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN)) {
+	dout(30) << __func__ << " data " << bp->first << ": " << bp->second
+		 << " use " << x_off << "~" << x_len
+		 << " final offset " << x_off + bp->second.offset
+		 << dendl;
+	uint64_t front_extra = x_off % block_size;
+	uint64_t r_off = x_off - front_extra;
+	uint64_t r_len = ROUND_UP_TO(x_len + front_extra, block_size);
+	dout(30) << __func__ << "  reading " << r_off << "~" << r_len << dendl;
+	bufferlist t;
+	r = bdev->read(r_off + bp->second.offset, r_len, &t, &ioc, buffered);
+	if (r < 0) {
+	  goto out;
+	}
+	r = r_len;
+	bufferlist u;
+	u.substr_of(t, front_extra, x_len);
+	bl.claim_append(u);
+      } else {
+	// unwritten (zero) extent
+	dout(30) << __func__ << " data " << bp->first << ": " << bp->second
+		 << ", use " << x_len << " zeros" << dendl;
+	bufferptr bp(x_len);
+	bp.zero();
+	bl.push_back(bp);
+      }
+      offset += x_len;
+      length -= x_len;
+      if (x_off + x_len == bp->second.length) {
+	++bp;
+      }
+      continue;
+    }
+    if (bp != bend &&
+	bp->first > offset &&
+	bp->first - offset < x_len) {
+      x_len = bp->first - offset;
+    }
+
+    // zero.
+    dout(30) << __func__ << " zero " << offset << "~" << x_len << dendl;
+    bufferptr bp(x_len);
+    bp.zero();
+    bl.push_back(bp);
+    offset += x_len;
+    length -= x_len;
+    continue;
+  }
+  r = bl.length();
+
+ out:
+  return r;
+}
+
+int BlueStore::fiemap(
+  coll_t cid,
+  const ghobject_t& oid,
+  uint64_t offset,
+  size_t len,
+  bufferlist& bl)
+{
+  interval_set<uint64_t> m;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    return -ENOENT;
+  }
+  _dump_onode(o);
+
+  dout(20) << __func__ << " " << offset << "~" << len << " size "
+	   << o->onode.size << dendl;
+
+  map<uint64_t,bluestore_extent_t>::iterator bp, bend;
+  map<uint64_t,bluestore_overlay_t>::iterator op, oend;
+
+  if (offset == len && offset == 0)
+    len = o->onode.size;
+
+  if (offset > o->onode.size)
+    goto out;
+
+  if (offset + len > o->onode.size) {
+    len = o->onode.size - offset;
+  }
+
+  // loop over overlays and data fragments.  overlays take precedence.
+  bend = o->onode.block_map.end();
+  bp = o->onode.block_map.lower_bound(offset);
+  if (bp != o->onode.block_map.begin()) {
+    --bp;
+  }
+  oend = o->onode.overlay_map.end();
+  op = o->onode.overlay_map.lower_bound(offset);
+  if (op != o->onode.overlay_map.begin()) {
+    --op;
+  }
+  while (len > 0) {
+    dout(20) << __func__ << " offset " << offset << dendl;
+    if (op != oend && op->first + op->second.length < offset) {
+      ++op;
+      continue;
+    }
+    if (bp != bend && bp->first + bp->second.length <= offset) {
+      ++bp;
+      continue;
+    }
+
+    // overlay?
+    if (op != oend && op->first <= offset) {
+      uint64_t x_len = MIN(op->first + op->second.length - offset, len);
+      dout(30) << __func__ << " overlay " << offset << "~" << x_len << dendl;
+      m.insert(offset, x_len);
+      len -= x_len;
+      offset += x_len;
+      ++op;
+      continue;
+    }
+
+    uint64_t x_len = len;
+    if (op != oend &&
+	op->first > offset &&
+	op->first - offset < x_len) {
+      x_len = op->first - offset;
+    }
+
+    // extent?
+    if (bp != bend && bp->first <= offset) {
+      uint64_t x_off = offset - bp->first;
+      x_len = MIN(x_len, bp->second.length - x_off);
+      dout(30) << __func__ << " extent " << offset << "~" << x_len << dendl;
+      m.insert(offset, x_len);
+      len -= x_len;
+      offset += x_len;
+      if (x_off + x_len == bp->second.length)
+	++bp;
+      continue;
+    }
+    if (bp != bend &&
+	bp->first > offset &&
+	bp->first - offset < x_len) {
+      x_len = bp->first - offset;
+    }
+    offset += x_len;
+    len -= x_len;
+    continue;
+  }
+
+ out:
+  ::encode(m, bl);
+  dout(20) << __func__ << " " << offset << "~" << len
+	   << " size = 0 (" << m << ")" << dendl;
+  return 0;
+}
+
+int BlueStore::getattr(
+  coll_t cid,
+  const ghobject_t& oid,
+  const char *name,
+  bufferptr& value)
+{
+  dout(15) << __func__ << " " << cid << " " << oid << " " << name << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r;
+  string k(name);
+
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+
+  if (!o->onode.attrs.count(k)) {
+    r = -ENODATA;
+    goto out;
+  }
+  value = o->onode.attrs[k];
+  r = 0;
+ out:
+  dout(10) << __func__ << " " << cid << " " << oid << " " << name
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::getattrs(
+  coll_t cid,
+  const ghobject_t& oid,
+  map<string,bufferptr>& aset)
+{
+  dout(15) << __func__ << " " << cid << " " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r;
+
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  aset = o->onode.attrs;
+  r = 0;
+ out:
+  dout(10) << __func__ << " " << cid << " " << oid
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::list_collections(vector<coll_t>& ls)
+{
+  RWLock::RLocker l(coll_lock);
+  for (ceph::unordered_map<coll_t, CollectionRef>::iterator p = coll_map.begin();
+       p != coll_map.end();
+       ++p)
+    ls.push_back(p->first);
+  return 0;
+}
+
+bool BlueStore::collection_exists(coll_t c)
+{
+  RWLock::RLocker l(coll_lock);
+  return coll_map.count(c);
+}
+
+bool BlueStore::collection_empty(coll_t cid)
+{
+  dout(15) << __func__ << " " << cid << dendl;
+  vector<ghobject_t> ls;
+  ghobject_t next;
+  int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), true, 1,
+			  &ls, &next);
+  if (r < 0)
+    return false;  // fixme?
+  bool empty = ls.empty();
+  dout(10) << __func__ << " " << cid << " = " << (int)empty << dendl;
+  return empty;
+}
+
+int BlueStore::collection_list(
+  coll_t cid, ghobject_t start, ghobject_t end,
+  bool sort_bitwise, int max,
+  vector<ghobject_t> *ls, ghobject_t *pnext)
+{
+  dout(15) << __func__ << " " << cid
+	   << " start " << start << " end " << end << " max " << max << dendl;
+  if (!sort_bitwise)
+    return -EOPNOTSUPP;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r = 0;
+  KeyValueDB::Iterator it;
+  string temp_start_key, temp_end_key;
+  string start_key, end_key;
+  bool set_next = false;
+  string pend;
+  bool temp;
+
+  ghobject_t static_next;
+  if (!pnext)
+    pnext = &static_next;
+
+  if (start == ghobject_t::get_max() ||
+      start.hobj == hobject_t::get_max()) {
+    goto out;
+  }
+  get_coll_key_range(cid, c->cnode.bits, &temp_start_key, &temp_end_key,
+		     &start_key, &end_key);
+  dout(20) << __func__
+	   << " range " << pretty_binary_string(temp_start_key)
+	   << " to " << pretty_binary_string(temp_end_key)
+	   << " and " << pretty_binary_string(start_key)
+	   << " to " << pretty_binary_string(end_key)
+	   << " start " << start << dendl;
+  it = db->get_iterator(PREFIX_OBJ);
+  if (start == ghobject_t() ||
+      start.hobj == hobject_t() ||
+      start == cid.get_min_hobj()) {
+    it->upper_bound(temp_start_key);
+    temp = true;
+  } else {
+    string k;
+    get_object_key(start, &k);
+    if (start.hobj.is_temp()) {
+      temp = true;
+      assert(k >= temp_start_key && k < temp_end_key);
+    } else {
+      temp = false;
+      assert(k >= start_key && k < end_key);
+    }
+    dout(20) << " start from " << pretty_binary_string(k)
+	     << " temp=" << (int)temp << dendl;
+    it->lower_bound(k);
+  }
+  if (end.hobj.is_max()) {
+    pend = temp ? temp_end_key : end_key;
+  } else {
+    get_object_key(end, &end_key);
+    if (end.hobj.is_temp()) {
+      if (temp)
+	pend = end_key;
+      else
+	goto out;
+    } else {
+      pend = temp ? temp_end_key : end_key;
+    }
+  }
+  dout(20) << __func__ << " pend " << pretty_binary_string(pend) << dendl;
+  while (true) {
+    if (!it->valid() || it->key() > pend) {
+      if (!it->valid())
+	dout(20) << __func__ << " iterator not valid (end of db?)" << dendl;
+      else
+	dout(20) << __func__ << " key " << pretty_binary_string(it->key())
+		 << " > " << end << dendl;
+      if (temp) {
+	if (end.hobj.is_temp()) {
+	  break;
+	}
+	dout(30) << __func__ << " switch to non-temp namespace" << dendl;
+	temp = false;
+	it->upper_bound(start_key);
+	pend = end_key;
+	dout(30) << __func__ << " pend " << pretty_binary_string(pend) << dendl;
+	continue;
+      }
+      break;
+    }
+    if (is_enode_key(it->key())) {
+      dout(20) << __func__ << " key "
+	       << pretty_binary_string(it->key())
+	       << " (enode, skipping)" << dendl;
+      it->next();
+      continue;
+    }
+    dout(20) << __func__ << " key " << pretty_binary_string(it->key()) << dendl;
+    ghobject_t oid;
+    int r = get_key_object(it->key(), &oid);
+    assert(r == 0);
+    if (ls->size() >= (unsigned)max) {
+      dout(20) << __func__ << " reached max " << max << dendl;
+      *pnext = oid;
+      set_next = true;
+      break;
+    }
+    ls->push_back(oid);
+    it->next();
+  }
+  if (!set_next) {
+    *pnext = ghobject_t::get_max();
+  }
+ out:
+  dout(10) << __func__ << " " << cid
+	   << " start " << start << " end " << end << " max " << max
+	   << " = " << r << ", ls.size() = " << ls->size()
+	   << ", next = " << *pnext << dendl;
+  return r;
+}
+
+// omap reads
+
+BlueStore::OmapIteratorImpl::OmapIteratorImpl(
+  CollectionRef c, OnodeRef o, KeyValueDB::Iterator it)
+  : c(c), o(o), it(it)
+{
+  RWLock::RLocker l(c->lock);
+  if (o->onode.omap_head) {
+    get_omap_key(o->onode.omap_head, string(), &head);
+    get_omap_tail(o->onode.omap_head, &tail);
+    it->lower_bound(head);
+  }
+}
+
+int BlueStore::OmapIteratorImpl::seek_to_first()
+{
+  RWLock::RLocker l(c->lock);
+  if (o->onode.omap_head) {
+    it->lower_bound(head);
+  } else {
+    it = KeyValueDB::Iterator();
+  }
+  return 0;
+}
+
+int BlueStore::OmapIteratorImpl::upper_bound(const string& after)
+{
+  RWLock::RLocker l(c->lock);
+  if (o->onode.omap_head) {
+    string key;
+    get_omap_key(o->onode.omap_head, after, &key);
+    it->upper_bound(key);
+  } else {
+    it = KeyValueDB::Iterator();
+  }
+  return 0;
+}
+
+int BlueStore::OmapIteratorImpl::lower_bound(const string& to)
+{
+  RWLock::RLocker l(c->lock);
+  if (o->onode.omap_head) {
+    string key;
+    get_omap_key(o->onode.omap_head, to, &key);
+    it->lower_bound(key);
+  } else {
+    it = KeyValueDB::Iterator();
+  }
+  return 0;
+}
+
+bool BlueStore::OmapIteratorImpl::valid()
+{
+  RWLock::RLocker l(c->lock);
+  if (o->onode.omap_head && it->valid() && it->raw_key().second <= tail) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+int BlueStore::OmapIteratorImpl::next(bool validate)
+{
+  RWLock::RLocker l(c->lock);
+  if (o->onode.omap_head) {
+    it->next();
+    return 0;
+  } else {
+    return -1;
+  }
+}
+
+string BlueStore::OmapIteratorImpl::key()
+{
+  RWLock::RLocker l(c->lock);
+  assert(it->valid());
+  string db_key = it->raw_key().second;
+  string user_key;
+  decode_omap_key(db_key, &user_key);
+  return user_key;
+}
+
+bufferlist BlueStore::OmapIteratorImpl::value()
+{
+  RWLock::RLocker l(c->lock);
+  assert(it->valid());
+  return it->value();
+}
+
+int BlueStore::omap_get(
+  coll_t cid,                ///< [in] Collection containing oid
+  const ghobject_t &oid,   ///< [in] Object containing omap
+  bufferlist *header,      ///< [out] omap header
+  map<string, bufferlist> *out /// < [out] Key to value map
+  )
+{
+  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r = 0;
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head)
+    goto out;
+  o->flush();
+  {
+    KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+    string head, tail;
+    get_omap_header(o->onode.omap_head, &head);
+    get_omap_tail(o->onode.omap_head, &tail);
+    it->lower_bound(head);
+    while (it->valid()) {
+      if (it->key() == head) {
+	dout(30) << __func__ << "  got header" << dendl;
+	*header = it->value();
+      } else if (it->key() >= tail) {
+	dout(30) << __func__ << "  reached tail" << dendl;
+	break;
+      } else {
+	string user_key;
+	decode_omap_key(it->key(), &user_key);
+	dout(30) << __func__ << "  got " << pretty_binary_string(it->key())
+		 << " -> " << user_key << dendl;
+	assert(it->key() < tail);
+	(*out)[user_key] = it->value();
+      }
+      it->next();
+    }
+  }
+ out:
+  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::omap_get_header(
+  coll_t cid,                ///< [in] Collection containing oid
+  const ghobject_t &oid,   ///< [in] Object containing omap
+  bufferlist *header,      ///< [out] omap header
+  bool allow_eio ///< [in] don't assert on eio
+  )
+{
+  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r = 0;
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head)
+    goto out;
+  o->flush();
+  {
+    string head;
+    get_omap_header(o->onode.omap_head, &head);
+    if (db->get(PREFIX_OMAP, head, header) >= 0) {
+      dout(30) << __func__ << "  got header" << dendl;
+    } else {
+      dout(30) << __func__ << "  no header" << dendl;
+    }
+  }
+ out:
+  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::omap_get_keys(
+  coll_t cid,              ///< [in] Collection containing oid
+  const ghobject_t &oid, ///< [in] Object containing omap
+  set<string> *keys      ///< [out] Keys defined on oid
+  )
+{
+  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r = 0;
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head)
+    goto out;
+  o->flush();
+  {
+    KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+    string head, tail;
+    get_omap_key(o->onode.omap_head, string(), &head);
+    get_omap_tail(o->onode.omap_head, &tail);
+    it->lower_bound(head);
+    while (it->valid()) {
+      if (it->key() >= tail) {
+	dout(30) << __func__ << "  reached tail" << dendl;
+	break;
+      }
+      string user_key;
+      decode_omap_key(it->key(), &user_key);
+      dout(30) << __func__ << "  got " << pretty_binary_string(it->key())
+	       << " -> " << user_key << dendl;
+      assert(it->key() < tail);
+      keys->insert(user_key);
+      it->next();
+    }
+  }
+ out:
+  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::omap_get_values(
+  coll_t cid,                    ///< [in] Collection containing oid
+  const ghobject_t &oid,       ///< [in] Object containing omap
+  const set<string> &keys,     ///< [in] Keys to get
+  map<string, bufferlist> *out ///< [out] Returned keys and values
+  )
+{
+  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r = 0;
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head)
+    goto out;
+  o->flush();
+  for (set<string>::const_iterator p = keys.begin(); p != keys.end(); ++p) {
+    string key;
+    get_omap_key(o->onode.omap_head, *p, &key);
+    bufferlist val;
+    if (db->get(PREFIX_OMAP, key, &val) >= 0) {
+      dout(30) << __func__ << "  got " << pretty_binary_string(key)
+	       << " -> " << *p << dendl;
+      out->insert(make_pair(*p, val));
+    }
+  }
+ out:
+  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::omap_check_keys(
+  coll_t cid,                ///< [in] Collection containing oid
+  const ghobject_t &oid,   ///< [in] Object containing omap
+  const set<string> &keys, ///< [in] Keys to check
+  set<string> *out         ///< [out] Subset of keys defined on oid
+  )
+{
+  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c)
+    return -ENOENT;
+  RWLock::RLocker l(c->lock);
+  int r = 0;
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head)
+    goto out;
+  o->flush();
+  for (set<string>::const_iterator p = keys.begin(); p != keys.end(); ++p) {
+    string key;
+    get_omap_key(o->onode.omap_head, *p, &key);
+    bufferlist val;
+    if (db->get(PREFIX_OMAP, key, &val) >= 0) {
+      dout(30) << __func__ << "  have " << pretty_binary_string(key)
+	       << " -> " << *p << dendl;
+      out->insert(*p);
+    } else {
+      dout(30) << __func__ << "  miss " << pretty_binary_string(key)
+	       << " -> " << *p << dendl;
+    }
+  }
+ out:
+  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  return r;
+}
+
+ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
+  coll_t cid,              ///< [in] collection
+  const ghobject_t &oid  ///< [in] object
+  )
+{
+
+  dout(10) << __func__ << " " << cid << " " << oid << dendl;
+  CollectionRef c = _get_collection(cid);
+  if (!c) {
+    dout(10) << __func__ << " " << cid << "doesn't exist" <<dendl;
+    return ObjectMap::ObjectMapIterator();
+  }
+  RWLock::RLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o) {
+    dout(10) << __func__ << " " << oid << "doesn't exist" <<dendl;
+    return ObjectMap::ObjectMapIterator();
+  }
+  o->flush();
+  dout(10) << __func__ << " header = " << o->onode.omap_head <<dendl;
+  KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+  return ObjectMap::ObjectMapIterator(new OmapIteratorImpl(c, o, it));
+}
+
+
+// -----------------
+// write helpers
+
+int BlueStore::_open_super_meta()
+{
+  // nid
+  {
+    nid_max = 0;
+    bufferlist bl;
+    db->get(PREFIX_SUPER, "nid_max", &bl);
+    try {
+      ::decode(nid_max, bl);
+    } catch (buffer::error& e) {
+    }
+    dout(10) << __func__ << " old nid_max " << nid_max << dendl;
+    nid_last = nid_max;
+  }
+
+  // bluefs alloc
+  {
+    bluefs_extents.clear();
+    bufferlist bl;
+    db->get(PREFIX_SUPER, "bluefs_extents", &bl);
+    bufferlist::iterator p = bl.begin();
+    try {
+      ::decode(bluefs_extents, p);
+    }
+    catch (buffer::error& e) {
+    }
+    dout(10) << __func__ << " bluefs_extents " << bluefs_extents << dendl;
+  }
+  return 0;
+}
+
+void BlueStore::_assign_nid(TransContext *txc, OnodeRef o)
+{
+  if (o->onode.nid)
+    return;
+  Mutex::Locker l(nid_lock);
+  o->onode.nid = ++nid_last;
+  dout(20) << __func__ << " " << o->onode.nid << dendl;
+  if (nid_last > nid_max) {
+    nid_max += g_conf->bluestore_nid_prealloc;
+    bufferlist bl;
+    ::encode(nid_max, bl);
+    txc->t->set(PREFIX_SUPER, "nid_max", bl);
+    dout(10) << __func__ << " nid_max now " << nid_max << dendl;
+  }
+}
+
+BlueStore::TransContext *BlueStore::_txc_create(OpSequencer *osr)
+{
+  TransContext *txc = new TransContext(osr);
+  txc->t = db->get_transaction();
+  osr->queue_new(txc);
+  dout(20) << __func__ << " osr " << osr << " = " << txc << dendl;
+  return txc;
+}
+
+void BlueStore::_txc_release(
+  TransContext *txc, CollectionRef& c, EnodeRef& e, uint32_t hash,
+  uint64_t offset, uint64_t length,
+  bool shared)
+{
+  if (shared) {
+    vector<bluestore_extent_t> release;
+    if (!e)
+      e = c->get_enode(hash);
+    e->ref_map.put(offset, length, &release);
+    dout(10) << __func__ << " " << offset << "~" << length
+	     << " shared: ref_map now " << e->ref_map
+	     << " releasing " << release << dendl;
+    txc->write_enode(e);
+    for (auto& p : release) {
+      txc->released.insert(p.offset, p.length);
+    }
+  } else {
+    dout(10) << __func__ << " " << offset << "~" << length << dendl;
+    txc->released.insert(offset, length);
+  }
+}
+
+void BlueStore::_txc_state_proc(TransContext *txc)
+{
+  while (true) {
+    dout(10) << __func__ << " txc " << txc
+	     << " " << txc->get_state_name() << dendl;
+    switch (txc->state) {
+    case TransContext::STATE_PREPARE:
+      if (txc->ioc.has_aios()) {
+	txc->state = TransContext::STATE_AIO_WAIT;
+	_txc_aio_submit(txc);
+	return;
+      }
+      // ** fall-thru **
+
+    case TransContext::STATE_AIO_WAIT:
+      _txc_finish_io(txc);  // may trigger blocked txc's too
+      return;
+
+    case TransContext::STATE_IO_DONE:
+      assert(txc->osr->qlock.is_locked());  // see _txc_finish_io
+      txc->state = TransContext::STATE_KV_QUEUED;
+      if (!g_conf->bluestore_sync_transaction) {
+	Mutex::Locker l(kv_lock);
+	if (g_conf->bluestore_sync_submit_transaction) {
+	  db->submit_transaction(txc->t);
+	}
+	kv_queue.push_back(txc);
+	kv_cond.SignalOne();
+	return;
+      }
+      db->submit_transaction_sync(txc->t);
+      break;
+
+    case TransContext::STATE_KV_QUEUED:
+      txc->state = TransContext::STATE_KV_DONE;
+      _txc_finish_kv(txc);
+      // ** fall-thru **
+
+    case TransContext::STATE_KV_DONE:
+      if (txc->wal_txn) {
+	txc->state = TransContext::STATE_WAL_QUEUED;
+	if (g_conf->bluestore_sync_wal_apply) {
+	  _wal_apply(txc);
+	} else {
+	  wal_wq.queue(txc);
+	}
+	return;
+      }
+      txc->state = TransContext::STATE_FINISHING;
+      break;
+
+    case TransContext::STATE_WAL_APPLYING:
+      if (txc->ioc.has_aios()) {
+	txc->state = TransContext::STATE_WAL_AIO_WAIT;
+	_txc_aio_submit(txc);
+	return;
+      }
+      // ** fall-thru **
+
+    case TransContext::STATE_WAL_AIO_WAIT:
+      _wal_finish(txc);
+      return;
+
+    case TransContext::STATE_WAL_CLEANUP:
+      txc->state = TransContext::STATE_FINISHING;
+      // ** fall-thru **
+
+    case TransContext::TransContext::STATE_FINISHING:
+      _txc_finish(txc);
+      return;
+
+    default:
+      derr << __func__ << " unexpected txc " << txc
+	   << " state " << txc->get_state_name() << dendl;
+      assert(0 == "unexpected txc state");
+      return;
+    }
+  }
+}
+
+void BlueStore::_txc_finish_io(TransContext *txc)
+{
+  dout(20) << __func__ << " " << txc << dendl;
+
+  /*
+   * we need to preserve the order of kv transactions,
+   * even though aio will complete in any order.
+   */
+
+  OpSequencer *osr = txc->osr.get();
+  Mutex::Locker l(osr->qlock);
+  txc->state = TransContext::STATE_IO_DONE;
+
+  OpSequencer::q_list_t::iterator p = osr->q.iterator_to(*txc);
+  while (p != osr->q.begin()) {
+    --p;
+    if (p->state < TransContext::STATE_IO_DONE) {
+      dout(20) << __func__ << " " << txc << " blocked by " << &*p << " "
+	       << p->get_state_name() << dendl;
+      return;
+    }
+    if (p->state > TransContext::STATE_IO_DONE) {
+      ++p;
+      break;
+    }
+  }
+  do {
+    _txc_state_proc(&*p++);
+  } while (p != osr->q.end() &&
+	   p->state == TransContext::STATE_IO_DONE);
+}
+
+int BlueStore::_txc_finalize(OpSequencer *osr, TransContext *txc)
+{
+  dout(20) << __func__ << " osr " << osr << " txc " << txc
+	   << " onodes " << txc->onodes << dendl;
+
+  // finalize onodes
+  for (set<OnodeRef>::iterator p = txc->onodes.begin();
+       p != txc->onodes.end();
+       ++p) {
+    bufferlist bl;
+    ::encode((*p)->onode, bl);
+    dout(20) << " onode " << (*p)->oid << " is " << bl.length() << dendl;
+    txc->t->set(PREFIX_OBJ, (*p)->key, bl);
+
+    Mutex::Locker l((*p)->flush_lock);
+    (*p)->flush_txns.insert(txc);
+  }
+
+  // finalize enodes
+  for (set<EnodeRef>::iterator p = txc->enodes.begin();
+       p != txc->enodes.end();
+       ++p) {
+    if ((*p)->ref_map.empty()) {
+      dout(20) << "  enode " << std::hex << (*p)->hash << std::dec
+	       << " ref_map is empty" << dendl;
+      txc->t->rmkey(PREFIX_OBJ, (*p)->key);
+    } else {
+      bufferlist bl;
+      ::encode((*p)->ref_map, bl);
+      dout(20) << "  enode " << std::hex << (*p)->hash << std::dec
+	       << " ref_map is " << bl.length() << dendl;
+      txc->t->set(PREFIX_OBJ, (*p)->key, bl);
+    }
+  }
+
+  // journal wal items
+  if (txc->wal_txn) {
+    txc->wal_txn->seq = wal_seq.inc();
+    bufferlist bl;
+    ::encode(*txc->wal_txn, bl);
+    string key;
+    get_wal_key(txc->wal_txn->seq, &key);
+    txc->t->set(PREFIX_WAL, key, bl);
+  }
+
+  return 0;
+}
+
+void BlueStore::_txc_finish_kv(TransContext *txc)
+{
+  dout(20) << __func__ << " txc " << txc << dendl;
+
+  // warning: we're calling onreadable_sync inside the sequencer lock
+  if (txc->onreadable_sync) {
+    txc->onreadable_sync->complete(0);
+    txc->onreadable_sync = NULL;
+  }
+  if (txc->onreadable) {
+    finisher.queue(txc->onreadable);
+    txc->onreadable = NULL;
+  }
+  if (txc->oncommit) {
+    finisher.queue(txc->oncommit);
+    txc->oncommit = NULL;
+  }
+  while (!txc->oncommits.empty()) {
+    finisher.queue(txc->oncommits.front());
+    txc->oncommits.pop_front();
+  }
+
+  throttle_ops.put(txc->ops);
+  throttle_bytes.put(txc->bytes);
+}
+
+void BlueStore::_txc_finish(TransContext *txc)
+{
+  dout(20) << __func__ << " " << txc << " onodes " << txc->onodes << dendl;
+  assert(txc->state == TransContext::STATE_FINISHING);
+
+  for (set<OnodeRef>::iterator p = txc->onodes.begin();
+       p != txc->onodes.end();
+       ++p) {
+    Mutex::Locker l((*p)->flush_lock);
+    dout(20) << __func__ << " onode " << *p << " had " << (*p)->flush_txns
+	     << dendl;
+    assert((*p)->flush_txns.count(txc));
+    (*p)->flush_txns.erase(txc);
+    if ((*p)->flush_txns.empty())
+      (*p)->flush_cond.Signal();
+  }
+
+  // clear out refs
+  txc->onodes.clear();
+
+  while (!txc->removed_collections.empty()) {
+    _queue_reap_collection(txc->removed_collections.front());
+    txc->removed_collections.pop_front();
+  }
+
+  throttle_wal_ops.put(txc->ops);
+  throttle_wal_bytes.put(txc->bytes);
+
+  OpSequencerRef osr = txc->osr;
+  osr->qlock.Lock();
+  txc->state = TransContext::STATE_DONE;
+  osr->qlock.Unlock();
+
+  _osr_reap_done(osr.get());
+}
+
+void BlueStore::_osr_reap_done(OpSequencer *osr)
+{
+  Mutex::Locker l(osr->qlock);
+  dout(20) << __func__ << " osr " << osr << dendl;
+  while (!osr->q.empty()) {
+    TransContext *txc = &osr->q.front();
+    dout(20) << __func__ << "  txc " << txc << " " << txc->get_state_name()
+	     << dendl;
+    if (txc->state != TransContext::STATE_DONE) {
+      break;
+    }
+
+    if (txc->first_collection) {
+      txc->first_collection->onode_map.trim(g_conf->bluestore_onode_map_size);
+    }
+
+    osr->q.pop_front();
+    delete txc;
+    osr->qcond.Signal();
+    if (osr->q.empty())
+      dout(20) << __func__ << " osr " << osr << " q now empty" << dendl;
+  }
+}
+
+void BlueStore::_kv_sync_thread()
+{
+  dout(10) << __func__ << " start" << dendl;
+  kv_lock.Lock();
+  while (true) {
+    assert(kv_committing.empty());
+    assert(wal_cleaning.empty());
+    if (kv_queue.empty() && wal_cleanup_queue.empty()) {
+      if (kv_stop)
+	break;
+      dout(20) << __func__ << " sleep" << dendl;
+      kv_sync_cond.Signal();
+      kv_cond.Wait(kv_lock);
+      dout(20) << __func__ << " wake" << dendl;
+    } else {
+      dout(20) << __func__ << " committing " << kv_queue.size()
+	       << " cleaning " << wal_cleanup_queue.size() << dendl;
+      kv_committing.swap(kv_queue);
+      wal_cleaning.swap(wal_cleanup_queue);
+      utime_t start = ceph_clock_now(NULL);
+      kv_lock.Unlock();
+
+      dout(30) << __func__ << " committing txc " << kv_committing << dendl;
+      dout(30) << __func__ << " wal_cleaning txc " << wal_cleaning << dendl;
+
+      // one transaction to force a sync
+      KeyValueDB::Transaction t = db->get_transaction();
+
+      // allocations and deallocations
+      interval_set<uint64_t> released;
+      for (std::deque<TransContext *>::iterator it = kv_committing.begin();
+	   it != kv_committing.end();
+	   ++it) {
+	TransContext *txc = *it;
+	if (txc->wal_txn)
+	  dout(20) << __func__ << " txc " << txc
+		   << " allocated " << txc->allocated
+		   << " (will release " << txc->released << " after wal)"
+		   << dendl;
+	else
+	  dout(20) << __func__ << " txc " << *it
+		   << " allocated " << txc->allocated
+		   << " released " << txc->released
+		   << dendl;
+	for (interval_set<uint64_t>::iterator p = txc->allocated.begin();
+	     p != txc->allocated.end();
+	     ++p) {
+	  fm->allocate(p.get_start(), p.get_len(), txc->t);
+	}
+	if (txc->wal_txn) {
+	  txc->wal_txn->released.swap(txc->released);
+	  assert(txc->released.empty());
+	} else {
+	  released.insert(txc->released);
+	  for (interval_set<uint64_t>::iterator p = txc->released.begin();
+	       p != txc->released.end();
+	       ++p) {
+	    dout(20) << __func__ << " release " << p.get_start()
+		     << "~" << p.get_len() << dendl;
+	    fm->release(p.get_start(), p.get_len(), txc->t);
+	  }
+	}
+      }
+      for (std::deque<TransContext *>::iterator it = wal_cleaning.begin();
+	   it != wal_cleaning.end();
+	   ++it) {
+	TransContext *txc = *it;
+	if (!txc->wal_txn->released.empty()) {
+	  dout(20) << __func__ << " txc " << txc
+		   << " (post-wal) released " << txc->wal_txn->released
+		   << dendl;
+	  released.insert(txc->wal_txn->released);
+	  for (interval_set<uint64_t>::iterator p =
+		 txc->wal_txn->released.begin();
+	       p != txc->wal_txn->released.end();
+	       ++p) {
+	    dout(20) << __func__ << " release " << p.get_start()
+		     << "~" << p.get_len() << dendl;
+	    fm->release(p.get_start(), p.get_len(), t);
+	  }
+	}
+      }
+      for (interval_set<uint64_t>::iterator p = released.begin();
+	   p != released.end();
+	   ++p) {
+	dout(20) << __func__ << " release " << p.get_start()
+		 << "~" << p.get_len() << dendl;
+	if (!g_conf->bluestore_debug_no_reuse_blocks)
+	  alloc->release(p.get_start(), p.get_len());
+      }
+
+      vector<bluestore_extent_t> bluefs_gift_extents;
+      if (bluefs) {
+	int r = _balance_bluefs_freespace(&bluefs_gift_extents, t);
+	assert(r >= 0);
+	if (r > 0) {
+	  for (auto& p : bluefs_gift_extents) {
+	    fm->allocate(p.offset, p.length, t);
+	    bluefs_extents.insert(p.offset, p.length);
+	  }
+	  bufferlist bl;
+	  ::encode(bluefs_extents, bl);
+	  dout(10) << __func__ << " bluefs_extents now " << bluefs_extents
+		   << dendl;
+	  t->set(PREFIX_SUPER, "bluefs_extents", bl);
+	}
+      }
+
+      alloc->commit_start();
+
+      // flush/barrier on block device
+      bdev->flush();
+
+      if (!g_conf->bluestore_sync_submit_transaction) {
+	for (std::deque<TransContext *>::iterator it = kv_committing.begin();
+	     it != kv_committing.end();
+	     ++it) {
+	  db->submit_transaction((*it)->t);
+	}
+      }
+
+      // cleanup sync wal keys
+      for (std::deque<TransContext *>::iterator it = wal_cleaning.begin();
+	    it != wal_cleaning.end();
+	    ++it) {
+	bluestore_wal_transaction_t& wt =*(*it)->wal_txn;
+	// cleanup the data in overlays
+	for (list<bluestore_wal_op_t>::iterator p = wt.ops.begin(); p != wt.ops.end(); ++p) {
+	  for (vector<uint64_t>::iterator q = p->removed_overlays.begin();
+	       q != p->removed_overlays.end();
+	       ++q) {
+            string key;
+            get_overlay_key(p->nid, *q, &key);
+	    t->rmkey(PREFIX_OVERLAY, key);
+	  }
+	}
+	// cleanup the wal
+	string key;
+	get_wal_key(wt.seq, &key);
+	t->rmkey(PREFIX_WAL, key);
+      }
+      db->submit_transaction_sync(t);
+      utime_t finish = ceph_clock_now(NULL);
+      utime_t dur = finish - start;
+      dout(20) << __func__ << " committed " << kv_committing.size()
+	       << " cleaned " << wal_cleaning.size()
+	       << " in " << dur << dendl;
+      while (!kv_committing.empty()) {
+	TransContext *txc = kv_committing.front();
+	_txc_state_proc(txc);
+	kv_committing.pop_front();
+      }
+      while (!wal_cleaning.empty()) {
+	TransContext *txc = wal_cleaning.front();
+	_txc_state_proc(txc);
+	wal_cleaning.pop_front();
+      }
+
+      alloc->commit_finish();
+
+      // this is as good a place as any ...
+      _reap_collections();
+
+      if (bluefs) {
+	if (!bluefs_gift_extents.empty()) {
+	  _commit_bluefs_freespace(bluefs_gift_extents);
+	}
+      }
+
+      kv_lock.Lock();
+    }
+  }
+  kv_lock.Unlock();
+  dout(10) << __func__ << " finish" << dendl;
+}
+
+bluestore_wal_op_t *BlueStore::_get_wal_op(TransContext *txc, OnodeRef o)
+{
+  if (!txc->wal_txn) {
+    txc->wal_txn = new bluestore_wal_transaction_t;
+  }
+  txc->wal_txn->ops.push_back(bluestore_wal_op_t());
+  txc->wal_op_onodes.push_back(o);
+  return &txc->wal_txn->ops.back();
+}
+
+int BlueStore::_wal_apply(TransContext *txc)
+{
+  bluestore_wal_transaction_t& wt = *txc->wal_txn;
+  dout(20) << __func__ << " txc " << txc << " seq " << wt.seq << dendl;
+  txc->state = TransContext::STATE_WAL_APPLYING;
+
+  assert(txc->ioc.pending_aios.empty());
+  vector<OnodeRef>::iterator q = txc->wal_op_onodes.begin();
+  for (list<bluestore_wal_op_t>::iterator p = wt.ops.begin();
+       p != wt.ops.end();
+       ++p, ++q) {
+    int r = _do_wal_op(*p, &txc->ioc);
+    assert(r == 0);
+  }
+
+  _txc_state_proc(txc);
+  return 0;
+}
+
+int BlueStore::_wal_finish(TransContext *txc)
+{
+  bluestore_wal_transaction_t& wt = *txc->wal_txn;
+  dout(20) << __func__ << " txc " << " seq " << wt.seq << txc << dendl;
+
+  Mutex::Locker l(kv_lock);
+  txc->state = TransContext::STATE_WAL_CLEANUP;
+  wal_cleanup_queue.push_back(txc);
+  kv_cond.SignalOne();
+  return 0;
+}
+
+int BlueStore::_do_wal_op(bluestore_wal_op_t& wo, IOContext *ioc)
+{
+  const uint64_t block_size = bdev->get_block_size();
+  const uint64_t block_mask = ~(block_size - 1);
+
+  // read all the overlay data first for apply
+  _do_read_all_overlays(wo);
+
+  // NOTE: we are doing all reads and writes buffered so that we can
+  // avoid worrying about multiple RMW cycles over the same blocks.
+
+  switch (wo.op) {
+  case bluestore_wal_op_t::OP_WRITE:
+  {
+    dout(20) << __func__ << " write " << wo.extent << dendl;
+    // FIXME: do the reads async?
+    bufferlist bl;
+    bl.claim(wo.data);
+    uint64_t offset = wo.extent.offset;
+    bufferlist first;
+    uint64_t first_len = offset & ~block_mask;
+    if (first_len) {
+      uint64_t src_offset;
+      if (wo.src_rmw_head)
+	src_offset = wo.src_rmw_head & block_mask;
+      else
+	src_offset = wo.extent.offset & block_mask;
+      offset = offset & block_mask;
+      dout(20) << __func__ << "  reading initial partial block "
+	       << src_offset << "~" << block_size << dendl;
+      bdev->read(src_offset, block_size, &first, ioc, true);
+      bufferlist t;
+      t.substr_of(first, 0, first_len);
+      t.claim_append(bl);
+      bl.swap(t);
+    }
+    if (wo.extent.end() & ~block_mask) {
+      uint64_t last_offset;
+      if (wo.src_rmw_tail)
+	last_offset = wo.src_rmw_tail & block_mask;
+      else
+	last_offset = wo.extent.end() & block_mask;
+      bufferlist last;
+      if (last_offset == offset && first.length()) {
+	last.claim(first);   // same block we read above
+      } else {
+	dout(20) << __func__ << "  reading trailing partial block "
+		 << last_offset << "~" << block_size << dendl;
+	bdev->read(last_offset, block_size, &last, ioc, true);
+      }
+      bufferlist t;
+      uint64_t endoff = wo.extent.end() & ~block_mask;
+      t.substr_of(last, endoff, block_size - endoff);
+      bl.claim_append(t);
+    }
+    assert((bl.length() & ~block_mask) == 0);
+    bdev->aio_write(offset, bl, ioc, true);
+  }
+  break;
+
+  case bluestore_wal_op_t::OP_COPY:
+  {
+    dout(20) << __func__ << " copy " << wo.extent << " from " << wo.src_extent
+	     << dendl;
+    assert((wo.extent.offset & ~block_mask) == 0);
+    assert((wo.extent.length & ~block_mask) == 0);
+    assert(wo.extent.length == wo.src_extent.length);
+    assert((wo.src_extent.offset & ~block_mask) == 0);
+    bufferlist bl;
+    int r = bdev->read(wo.src_extent.offset, wo.src_extent.length, &bl, ioc,
+		       true);
+    assert(r >= 0);
+    assert(bl.length() == wo.extent.length);
+    bdev->aio_write(wo.extent.offset, bl, ioc, true);
+  }
+  break;
+
+  case bluestore_wal_op_t::OP_ZERO:
+  {
+    dout(20) << __func__ << " zero " << wo.extent << dendl;
+    uint64_t offset = wo.extent.offset;
+    uint64_t length = wo.extent.length;
+    bufferlist first;
+    uint64_t first_len = offset & ~block_mask;
+    if (first_len) {
+      uint64_t first_offset = offset & block_mask;
+      dout(20) << __func__ << "  reading initial partial block "
+	       << first_offset << "~" << block_size << dendl;
+      bdev->read(first_offset, block_size, &first, ioc, true);
+      size_t z_len = MIN(block_size - first_len, length);
+      memset(first.c_str() + first_len, 0, z_len);
+      bdev->aio_write(first_offset, first, ioc, true);
+      offset += block_size - first_len;
+      length -= z_len;
+    }
+    assert(offset % block_size == 0);
+    if (length >= block_size) {
+      uint64_t middle_len = length & block_mask;
+      dout(20) << __func__ << "  zero " << offset << "~" << length << dendl;
+      bdev->aio_zero(offset, middle_len, ioc);
+      offset += middle_len;
+      length -= middle_len;
+    }
+    assert(offset % block_size == 0);
+    if (length > 0) {
+      assert(length < block_size);
+      bufferlist last;
+      dout(20) << __func__ << "  reading trailing partial block "
+	       << offset << "~" << block_size << dendl;
+      bdev->read(offset, block_size, &last, ioc, true);
+      memset(last.c_str(), 0, length);
+      bdev->aio_write(offset, last, ioc, true);
+    }
+  }
+  break;
+
+  default:
+    assert(0 == "unrecognized wal op");
+  }
+
+  return 0;
+}
+
+int BlueStore::_wal_replay()
+{
+  dout(10) << __func__ << " start" << dendl;
+  OpSequencerRef osr = new OpSequencer;
+  int count = 0;
+  KeyValueDB::Iterator it = db->get_iterator(PREFIX_WAL);
+  for (it->lower_bound(string()); it->valid(); it->next(), ++count) {
+    dout(20) << __func__ << " replay " << pretty_binary_string(it->key())
+	     << dendl;
+    TransContext *txc = _txc_create(osr.get());
+    txc->wal_txn = new bluestore_wal_transaction_t;
+    bufferlist bl = it->value();
+    bufferlist::iterator p = bl.begin();
+    try {
+      ::decode(*txc->wal_txn, p);
+    } catch (buffer::error& e) {
+      derr << __func__ << " failed to decode wal txn "
+	   << pretty_binary_string(it->key()) << dendl;
+      return -EIO;
+    }
+    txc->state = TransContext::STATE_KV_DONE;
+    _txc_state_proc(txc);
+  }
+  dout(20) << __func__ << " flushing osr" << dendl;
+  osr->flush();
+  dout(10) << __func__ << " completed " << count << " events" << dendl;
+  return 0;
+}
+
+// ---------------------------
+// transactions
+
+int BlueStore::queue_transactions(
+    Sequencer *posr,
+    list<Transaction*>& tls,
+    TrackedOpRef op,
+    ThreadPool::TPHandle *handle)
+{
+  Context *onreadable;
+  Context *ondisk;
+  Context *onreadable_sync;
+  ObjectStore::Transaction::collect_contexts(
+    tls, &onreadable, &ondisk, &onreadable_sync);
+  int r;
+
+  // set up the sequencer
+  OpSequencer *osr;
+  assert(posr);
+  if (posr->p) {
+    osr = static_cast<OpSequencer *>(posr->p.get());
+    dout(10) << __func__ << " existing " << osr << " " << *osr << dendl;
+  } else {
+    osr = new OpSequencer;
+    osr->parent = posr;
+    posr->p = osr;
+    dout(10) << __func__ << " new " << osr << " " << *osr << dendl;
+  }
+
+  // prepare
+  TransContext *txc = _txc_create(osr);
+  txc->onreadable = onreadable;
+  txc->onreadable_sync = onreadable_sync;
+  txc->oncommit = ondisk;
+
+  for (list<Transaction*>::iterator p = tls.begin(); p != tls.end(); ++p) {
+    (*p)->set_osr(osr);
+    txc->ops += (*p)->get_num_ops();
+    txc->bytes += (*p)->get_num_bytes();
+    _txc_add_transaction(txc, *p);
+  }
+
+  r = _txc_finalize(osr, txc);
+  assert(r == 0);
+
+  throttle_ops.get(txc->ops);
+  throttle_bytes.get(txc->bytes);
+  throttle_wal_ops.get(txc->ops);
+  throttle_wal_bytes.get(txc->bytes);
+
+  // execute (start)
+  _txc_state_proc(txc);
+  return 0;
+}
+
+void BlueStore::_txc_aio_submit(TransContext *txc)
+{
+  dout(10) << __func__ << " txc " << txc << dendl;
+  bdev->aio_submit(&txc->ioc);
+}
+
+int BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
+{
+  Transaction::iterator i = t->begin();
+  int pos = 0;
+
+  vector<CollectionRef> cvec(i.colls.size());
+  unsigned j = 0;
+  for (vector<coll_t>::iterator p = i.colls.begin(); p != i.colls.end();
+       ++p, ++j) {
+    cvec[j] = _get_collection(*p);
+
+    // note first collection we reference
+    if (!j && !txc->first_collection)
+      txc->first_collection = cvec[j];
+  }
+
+  while (i.have_op()) {
+    Transaction::Op *op = i.decode_op();
+    int r = 0;
+    CollectionRef &c = cvec[op->cid];
+
+    switch (op->op) {
+    case Transaction::OP_NOP:
+      break;
+    case Transaction::OP_TOUCH:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+	r = _touch(txc, c, oid);
+      }
+      break;
+
+    case Transaction::OP_WRITE:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+        uint64_t off = op->off;
+        uint64_t len = op->len;
+	uint32_t fadvise_flags = i.get_fadvise_flags();
+        bufferlist bl;
+        i.decode_bl(bl);
+	r = _write(txc, c, oid, off, len, bl, fadvise_flags);
+      }
+      break;
+
+    case Transaction::OP_ZERO:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+        uint64_t off = op->off;
+        uint64_t len = op->len;
+	r = _zero(txc, c, oid, off, len);
+      }
+      break;
+
+    case Transaction::OP_TRIMCACHE:
+      {
+        // deprecated, no-op
+      }
+      break;
+
+    case Transaction::OP_TRUNCATE:
+      {
+        const ghobject_t& oid = i.get_oid(op->oid);
+        uint64_t off = op->off;
+	r = _truncate(txc, c, oid, off);
+      }
+      break;
+
+    case Transaction::OP_REMOVE:
+      {
+        const ghobject_t& oid = i.get_oid(op->oid);
+	r = _remove(txc, c, oid);
+      }
+      break;
+
+    case Transaction::OP_SETATTR:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+        string name = i.decode_string();
+        bufferlist bl;
+        i.decode_bl(bl);
+	map<string, bufferptr> to_set;
+	to_set[name] = bufferptr(bl.c_str(), bl.length());
+	r = _setattrs(txc, c, oid, to_set);
+      }
+      break;
+
+    case Transaction::OP_SETATTRS:
+      {
+        const ghobject_t& oid = i.get_oid(op->oid);
+        map<string, bufferptr> aset;
+        i.decode_attrset(aset);
+	r = _setattrs(txc, c, oid, aset);
+      }
+      break;
+
+    case Transaction::OP_RMATTR:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+	string name = i.decode_string();
+	r = _rmattr(txc, c, oid, name);
+      }
+      break;
+
+    case Transaction::OP_RMATTRS:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+	r = _rmattrs(txc, c, oid);
+      }
+      break;
+
+    case Transaction::OP_CLONE:
+      {
+        const ghobject_t& oid = i.get_oid(op->oid);
+        const ghobject_t& noid = i.get_oid(op->dest_oid);
+	r = _clone(txc, c, oid, noid);
+      }
+      break;
+
+    case Transaction::OP_CLONERANGE:
+      assert(0 == "deprecated");
+      break;
+
+    case Transaction::OP_CLONERANGE2:
+      {
+        const ghobject_t &oid = i.get_oid(op->oid);
+        const ghobject_t &noid = i.get_oid(op->dest_oid);
+        uint64_t srcoff = op->off;
+        uint64_t len = op->len;
+        uint64_t dstoff = op->dest_off;
+	r = _clone_range(txc, c, oid, noid, srcoff, len, dstoff);
+      }
+      break;
+
+    case Transaction::OP_MKCOLL:
+      {
+	assert(!c);
+        coll_t cid = i.get_cid(op->cid);
+	r = _create_collection(txc, cid, op->split_bits, &c);
+      }
+      break;
+
+    case Transaction::OP_COLL_HINT:
+      {
+        uint32_t type = op->hint_type;
+        bufferlist hint;
+        i.decode_bl(hint);
+        bufferlist::iterator hiter = hint.begin();
+        if (type == Transaction::COLL_HINT_EXPECTED_NUM_OBJECTS) {
+          uint32_t pg_num;
+          uint64_t num_objs;
+          ::decode(pg_num, hiter);
+          ::decode(num_objs, hiter);
+          dout(10) << __func__ << " collection hint objects is a no-op, "
+		   << " pg_num " << pg_num << " num_objects " << num_objs
+		   << dendl;
+        } else {
+          // Ignore the hint
+          dout(10) << __func__ << " unknown collection hint " << type << dendl;
+        }
+      }
+      break;
+
+    case Transaction::OP_RMCOLL:
+      {
+        coll_t cid = i.get_cid(op->cid);
+	r = _remove_collection(txc, cid, &c);
+      }
+      break;
+
+    case Transaction::OP_COLL_ADD:
+      assert(0 == "not implmeented");
+      break;
+
+    case Transaction::OP_COLL_REMOVE:
+      assert(0 == "not implmeented");
+      break;
+
+    case Transaction::OP_COLL_MOVE:
+      assert(0 == "deprecated");
+      break;
+
+    case Transaction::OP_COLL_MOVE_RENAME:
+      {
+	assert(op->cid == op->dest_cid);
+        ghobject_t oldoid = i.get_oid(op->oid);
+        ghobject_t newoid = i.get_oid(op->dest_oid);
+	r = _rename(txc, c, oldoid, newoid);
+      }
+      break;
+
+    case Transaction::OP_COLL_SETATTR:
+      r = -EOPNOTSUPP;
+      break;
+
+    case Transaction::OP_COLL_RMATTR:
+      r = -EOPNOTSUPP;
+      break;
+
+    case Transaction::OP_COLL_RENAME:
+      assert(0 == "not implmeneted");
+      break;
+
+    case Transaction::OP_OMAP_CLEAR:
+      {
+        ghobject_t oid = i.get_oid(op->oid);
+	r = _omap_clear(txc, c, oid);
+      }
+      break;
+    case Transaction::OP_OMAP_SETKEYS:
+      {
+        ghobject_t oid = i.get_oid(op->oid);
+	bufferlist aset_bl;
+        i.decode_attrset_bl(&aset_bl);
+	r = _omap_setkeys(txc, c, oid, aset_bl);
+      }
+      break;
+    case Transaction::OP_OMAP_RMKEYS:
+      {
+        ghobject_t oid = i.get_oid(op->oid);
+	bufferlist keys_bl;
+        i.decode_keyset_bl(&keys_bl);
+	r = _omap_rmkeys(txc, c, oid, keys_bl);
+      }
+      break;
+    case Transaction::OP_OMAP_RMKEYRANGE:
+      {
+        ghobject_t oid = i.get_oid(op->oid);
+        string first, last;
+        first = i.decode_string();
+        last = i.decode_string();
+	r = _omap_rmkey_range(txc, c, oid, first, last);
+      }
+      break;
+    case Transaction::OP_OMAP_SETHEADER:
+      {
+        ghobject_t oid = i.get_oid(op->oid);
+        bufferlist bl;
+        i.decode_bl(bl);
+	r = _omap_setheader(txc, c, oid, bl);
+      }
+      break;
+    case Transaction::OP_SPLIT_COLLECTION:
+      assert(0 == "deprecated");
+      break;
+    case Transaction::OP_SPLIT_COLLECTION2:
+      {
+        uint32_t bits = op->split_bits;
+        uint32_t rem = op->split_rem;
+	r = _split_collection(txc, c, cvec[op->dest_cid], bits, rem);
+      }
+      break;
+
+    case Transaction::OP_SETALLOCHINT:
+      {
+        ghobject_t oid = i.get_oid(op->oid);
+        uint64_t expected_object_size = op->expected_object_size;
+        uint64_t expected_write_size = op->expected_write_size;
+	r = _setallochint(txc, c, oid,
+			  expected_object_size,
+			  expected_write_size);
+      }
+      break;
+
+    default:
+      derr << "bad op " << op->op << dendl;
+      assert(0);
+    }
+
+    if (r < 0) {
+      bool ok = false;
+
+      if (r == -ENOENT && !(op->op == Transaction::OP_CLONERANGE ||
+			    op->op == Transaction::OP_CLONE ||
+			    op->op == Transaction::OP_CLONERANGE2 ||
+			    op->op == Transaction::OP_COLL_ADD))
+	// -ENOENT is usually okay
+	ok = true;
+      if (r == -ENODATA)
+	ok = true;
+
+      if (!ok) {
+	const char *msg = "unexpected error code";
+
+	if (r == -ENOENT && (op->op == Transaction::OP_CLONERANGE ||
+			     op->op == Transaction::OP_CLONE ||
+			     op->op == Transaction::OP_CLONERANGE2))
+	  msg = "ENOENT on clone suggests osd bug";
+
+	if (r == -ENOSPC)
+	  // For now, if we hit _any_ ENOSPC, crash, before we do any damage
+	  // by partially applying transactions.
+	  msg = "ENOSPC handling not implemented";
+
+	if (r == -ENOTEMPTY) {
+	  msg = "ENOTEMPTY suggests garbage data in osd data dir";
+	}
+
+	dout(0) << " error " << cpp_strerror(r) << " not handled on operation " << op->op
+		<< " (op " << pos << ", counting from 0)" << dendl;
+	dout(0) << msg << dendl;
+	dout(0) << " transaction dump:\n";
+	JSONFormatter f(true);
+	f.open_object_section("transaction");
+	t->dump(&f);
+	f.close_section();
+	f.flush(*_dout);
+	*_dout << dendl;
+	assert(0 == "unexpected error");
+      }
+    }
+
+    ++pos;
+  }
+
+  return 0;
+}
+
+
+
+// -----------------
+// write operations
+
+int BlueStore::_touch(TransContext *txc,
+		     CollectionRef& c,
+		     const ghobject_t& oid)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, true);
+  assert(o);
+  o->exists = true;
+  _assign_nid(txc, o);
+  txc->write_onode(o);
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_do_overlay_trim(TransContext *txc,
+			       OnodeRef o,
+			       uint64_t offset,
+			       uint64_t length)
+{
+  dout(10) << __func__ << " " << o->oid << " "
+	   << offset << "~" << length << dendl;
+  int changed = 0;
+
+  map<uint64_t,bluestore_overlay_t>::iterator p =
+    o->onode.overlay_map.lower_bound(offset);
+  if (p != o->onode.overlay_map.begin()) {
+    --p;
+  }
+  while (p != o->onode.overlay_map.end()) {
+    if (p->first >= offset + length) {
+      dout(20) << __func__ << " stop at " << p->first << " " << p->second
+	       << dendl;
+      break;
+    }
+    if (p->first + p->second.length <= offset) {
+      dout(20) << __func__ << " skip " << p->first << " " << p->second
+	       << dendl;
+      ++p;
+      continue;
+    }
+    if (p->first >= offset &&
+	p->first + p->second.length <= offset + length) {
+      dout(20) << __func__ << " rm " << p->first << " " << p->second
+	       << dendl;
+      if (o->onode.put_overlay_ref(p->second.key)) {
+	string key;
+	get_overlay_key(o->onode.nid, p->second.key, &key);
+	txc->t->rmkey(PREFIX_OVERLAY, key);
+      }
+      o->onode.overlay_map.erase(p++);
+      ++changed;
+      continue;
+    }
+    if (p->first >= offset) {
+      dout(20) << __func__ << " trim_front " << p->first << " " << p->second
+	       << dendl;
+      bluestore_overlay_t& ov = o->onode.overlay_map[offset + length] = p->second;
+      uint64_t by = offset + length - p->first;
+      ov.value_offset += by;
+      ov.length -= by;
+      o->onode.overlay_map.erase(p++);
+      ++changed;
+      continue;
+    }
+    if (p->first < offset &&
+	p->first + p->second.length <= offset + length) {
+      dout(20) << __func__ << " trim_tail " << p->first << " " << p->second
+	       << dendl;
+      p->second.length = offset - p->first;
+      ++p;
+      ++changed;
+      continue;
+    }
+    dout(20) << __func__ << " split " << p->first << " " << p->second
+	     << dendl;
+    assert(p->first < offset);
+    assert(p->first + p->second.length > offset + length);
+    bluestore_overlay_t& nov = o->onode.overlay_map[offset + length] = p->second;
+    p->second.length = offset - p->first;
+    uint64_t by = offset + length - p->first;
+    nov.value_offset += by;
+    nov.length -= by;
+    o->onode.get_overlay_ref(p->second.key);
+    ++p;
+    ++changed;
+  }
+  return changed;
+}
+
+int BlueStore::_do_overlay_write(TransContext *txc,
+				OnodeRef o,
+				uint64_t offset,
+				uint64_t length,
+				const bufferlist& bl)
+{
+  _do_overlay_trim(txc, o, offset, length);
+
+  // let's avoid considering how overlay interacts with cached tail
+  // blocks for now.
+  o->clear_tail();
+
+  dout(10) << __func__ << " " << o->oid << " "
+	   << offset << "~" << length << dendl;
+  bluestore_overlay_t& ov = o->onode.overlay_map[offset] =
+    bluestore_overlay_t(++o->onode.last_overlay_key, 0, length);
+  dout(20) << __func__ << " added " << offset << " " << ov << dendl;
+  string key;
+  get_overlay_key(o->onode.nid, o->onode.last_overlay_key, &key);
+  txc->t->set(PREFIX_OVERLAY, key, bl);
+  return 0;
+}
+
+int BlueStore::_do_write_overlays(TransContext *txc,
+				  CollectionRef& c,
+				 OnodeRef o,
+				 uint64_t orig_offset,
+				 uint64_t orig_length)
+{
+  if (o->onode.overlay_map.empty())
+    return 0;
+
+  assert(0 == "this is all broken");
+
+  uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+
+  uint64_t offset = 0;
+  uint64_t length = 0;
+  bluestore_wal_op_t *op = NULL;
+
+  map<uint64_t,bluestore_overlay_t>::iterator p =
+    o->onode.overlay_map.lower_bound(orig_offset);
+  while (true) {
+    if (p != o->onode.overlay_map.end() && p->first < orig_offset + orig_length) {
+      if (!op) {
+	dout(10) << __func__ << " overlay " << p->first
+		 << "~" << p->second.length << " " << p->second
+		 << " (first)" << dendl;
+	op = _get_wal_op(txc, o);
+	op->nid = o->onode.nid;
+	op->op = bluestore_wal_op_t::OP_WRITE;
+	op->overlays.push_back(p->second);
+	offset = p->first;
+	length = p->second.length;
+
+	if (o->onode.put_overlay_ref(p->second.key)) {
+	  string key;
+	  get_overlay_key(o->onode.nid, p->second.key, &key);
+	  txc->t->rmkey(PREFIX_OVERLAY, key);
+	}
+	o->onode.overlay_map.erase(p++);
+	continue;
+      }
+
+      // contiguous?  and in the same allocation unit?
+      if (offset + length == p->first &&
+	  p->first % min_alloc_size) {
+	dout(10) << __func__ << " overlay " << p->first
+		 << "~" << p->second.length << " " << p->second
+		 << " (contiguous)" << dendl;
+	op->overlays.push_back(p->second);
+	length += p->second.length;
+
+	if (o->onode.put_overlay_ref(p->second.key)) {
+	  string key;
+	  get_overlay_key(o->onode.nid, p->second.key, &key);
+	  txc->t->rmkey(PREFIX_OVERLAY, key);
+	}
+	o->onode.overlay_map.erase(p++);
+	continue;
+      }
+    }
+    if (!op) {
+      break;
+    }
+    assert(length <= min_alloc_size);
+
+    // emit
+    map<uint64_t, bluestore_extent_t>::iterator bp = o->onode.find_extent(offset);
+    if (bp == o->onode.block_map.end() ||
+	length == min_alloc_size) {
+      uint64_t cow_rmw_head = 0, cow_rmw_tail = 0;
+      int r = _do_allocate(txc, c, o, offset, length, 0, false,
+			   &cow_rmw_head, &cow_rmw_tail);
+      if (r < 0)
+	return r;
+      bp = o->onode.find_extent(offset);
+      if (bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN)) {
+	dout(10) << __func__ << " zero new allocation " << bp->second << dendl;
+	bdev->aio_zero(bp->second.offset, bp->second.length, &txc->ioc);
+	bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
+      }
+    }
+    uint64_t x_off = offset - bp->first;
+    dout(10) << __func__ << " wal write " << offset << "~" << length
+	     << " to extent " << bp->first << ": " << bp->second
+	     << " x_off " << x_off << " overlay data from "
+	     << offset << "~" << length << dendl;
+    op->extent.offset = bp->second.offset + x_off;
+    op->extent.length = length;
+    op = NULL;
+
+    if (p == o->onode.overlay_map.end() || p->first >= orig_offset + orig_length) {
+      break;
+    }
+    ++p;
+  }
+
+  txc->write_onode(o);
+  return 0;
+}
+
+void BlueStore::_do_read_all_overlays(bluestore_wal_op_t& wo)
+{
+  for (vector<bluestore_overlay_t>::iterator q = wo.overlays.begin();
+       q != wo.overlays.end(); ++q) {
+    string key;
+    get_overlay_key(wo.nid, q->key, &key);
+    bufferlist bl, bl_data;
+    db->get(PREFIX_OVERLAY, key, &bl);
+    bl_data.substr_of(bl, q->value_offset, q->length);
+    wo.data.claim_append(bl_data);
+  }
+  return;
+}
+
+void BlueStore::_dump_onode(OnodeRef o)
+{
+  if (!g_conf->subsys.should_gather(ceph_subsys_bluestore, 30))
+    return;
+  dout(30) << __func__ << " " << o
+	   << " nid " << o->onode.nid
+	   << " size " << o->onode.size
+	   << " expected_object_size " << o->onode.expected_object_size
+	   << " expected_write_size " << o->onode.expected_write_size
+	   << dendl;
+  for (map<string,bufferptr>::iterator p = o->onode.attrs.begin();
+       p != o->onode.attrs.end();
+       ++p) {
+    dout(30) << __func__ << "  attr " << p->first
+	     << " len " << p->second.length() << dendl;
+  }
+  uint64_t pos = 0;
+  for (map<uint64_t,bluestore_extent_t>::iterator p = o->onode.block_map.begin();
+       p != o->onode.block_map.end();
+       ++p) {
+    dout(30) << __func__ << "  extent " << p->first << " " << p->second
+	     << dendl;
+    assert(p->first >= pos);
+    pos = p->first + p->second.length;
+  }
+  pos = 0;
+  for (map<uint64_t,bluestore_overlay_t>::iterator p = o->onode.overlay_map.begin();
+       p != o->onode.overlay_map.end();
+       ++p) {
+    dout(30) << __func__ << "  overlay " << p->first << " " << p->second
+	     << dendl;
+    assert(p->first >= pos);
+    pos = p->first + p->second.length;
+  }
+  if (!o->onode.overlay_refs.empty()) {
+    dout(30) << __func__ << "  overlay_refs " << o->onode.overlay_refs << dendl;
+  }
+}
+
+void BlueStore::_pad_zeros(
+  OnodeRef o,
+  bufferlist *bl, uint64_t *offset, uint64_t *length,
+  uint64_t block_size)
+{
+  dout(40) << "before:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+  // front
+  size_t front_pad = *offset % block_size;
+  size_t back_pad = 0;
+  if (front_pad) {
+    size_t front_copy = MIN(block_size - front_pad, *length);
+    bufferptr z = buffer::create_page_aligned(block_size);
+    memset(z.c_str(), 0, front_pad);
+    memcpy(z.c_str() + front_pad, bl->get_contiguous(0, front_copy), front_copy);
+    if (front_copy + front_pad < block_size) {
+      back_pad = block_size - (*length + front_pad);
+      memset(z.c_str() + front_pad + *length, 0, back_pad);
+    }
+    bufferlist old, t;
+    old.swap(*bl);
+    t.substr_of(old, front_copy, *length - front_copy);
+    bl->append(z);
+    bl->claim_append(t);
+    *offset -= front_pad;
+    *length += front_pad + back_pad;
+  }
+
+  // back
+  uint64_t end = *offset + *length;
+  unsigned back_copy = end % block_size;
+  if (back_copy) {
+    assert(back_pad == 0);
+    back_pad = block_size - back_copy;
+    assert(back_copy <= *length);
+    bufferptr tail(block_size);
+    memcpy(tail.c_str(), bl->get_contiguous(*length - back_copy, back_copy),
+	   back_copy);
+    memset(tail.c_str() + back_copy, 0, back_pad);
+    bufferlist old;
+    old.swap(*bl);
+    bl->substr_of(old, 0, *length - back_copy);
+    bl->append(tail);
+    *length += back_pad;
+    if (end > o->onode.size && g_conf->bluestore_cache_tails) {
+      o->tail_bl.clear();
+      o->tail_bl.append(tail, 0, back_copy);
+      o->tail_offset = end - back_copy;
+      dout(20) << __func__ << " cached "<< back_copy << " of tail block at "
+	       << o->tail_offset << dendl;
+    }
+  }
+  dout(20) << __func__ << " pad " << front_pad << " + " << back_pad
+	   << " on front/back, now " << *offset << "~" << *length << dendl;
+  dout(40) << "after:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+}
+
+void BlueStore::_pad_zeros_head(
+  OnodeRef o,
+  bufferlist *bl, uint64_t *offset, uint64_t *length,
+  uint64_t block_size)
+{
+  dout(40) << "before:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+  size_t front_pad = *offset % block_size;
+  assert(front_pad);  // or we wouldn't have been called
+  size_t front_copy = MIN(block_size - front_pad, *length);
+  bufferptr z;
+  if (front_copy + front_pad < block_size)
+    z = buffer::create(front_copy + front_pad);
+  else
+    z = buffer::create_page_aligned(block_size);
+  memset(z.c_str(), 0, front_pad);
+  memcpy(z.c_str() + front_pad, bl->get_contiguous(0, front_copy), front_copy);
+  bufferlist old, t;
+  old.swap(*bl);
+  bl->append(z);
+  if (front_copy < *length) {
+    t.substr_of(old, front_copy, *length - front_copy);
+    bl->claim_append(t);
+  }
+  *offset -= front_pad;
+  *length += front_pad;
+  dout(20) << __func__ << " pad " << front_pad
+	   << " on front, now " << *offset << "~" << *length << dendl;
+  dout(40) << "after:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+}
+
+void BlueStore::_pad_zeros_tail(
+  OnodeRef o,
+  bufferlist *bl, uint64_t offset, uint64_t *length,
+  uint64_t block_size)
+{
+  dout(40) << "before:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+
+  // back
+  uint64_t end = offset + *length;
+  unsigned back_copy = end % block_size;
+  assert(back_copy);  // or we wouldn't have been called
+  uint64_t back_pad = block_size - back_copy;
+  assert(back_copy <= *length);
+  bufferptr tail(block_size);
+  memcpy(tail.c_str(), bl->get_contiguous(*length - back_copy, back_copy),
+	 back_copy);
+  memset(tail.c_str() + back_copy, 0, back_pad);
+  bufferlist old;
+  old.swap(*bl);
+  bl->substr_of(old, 0, *length - back_copy);
+  bl->append(tail);
+  *length += back_pad;
+  if (end > o->onode.size && g_conf->bluestore_cache_tails) {
+    o->tail_bl.clear();
+    o->tail_bl.append(tail, 0, back_copy);
+    o->tail_offset = end - back_copy;
+    dout(20) << __func__ << " cached "<< back_copy << " of tail block at "
+	     << o->tail_offset << dendl;
+  }
+  dout(20) << __func__ << " pad " << back_pad
+	   << " on back, now " << offset << "~" << *length << dendl;
+  dout(40) << "after:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+}
+
+/*
+ * Allocate extents for the given range.  In general, allocate new space
+ * for any min_alloc_size blocks that we overwrite.  For the head/tail and/or
+ * small writes that can be captured by overlay, or small writes that we will
+ * WAL, do not bother.
+ *
+ * If we are doing WAL over a shared extent, allocate a new extent, and queue
+ * WAL OP_COPY operations for any head/tail portions (rounded down/up to the
+ * nearest block--the overwrite will to read/modify/write on the first or last
+ * block as needed using the src_rmw_{head,tail} fields).
+ */
+int BlueStore::_do_allocate(
+  TransContext *txc,
+  CollectionRef& c,
+  OnodeRef o,
+  uint64_t orig_offset, uint64_t orig_length,
+  uint32_t fadvise_flags,
+  bool allow_overlay,
+  uint64_t *cow_rmw_head,
+  uint64_t *cow_rmw_tail)
+{
+  dout(20) << __func__
+	   << " " << o->oid << " " << orig_offset << "~" << orig_length
+	   << " - have " << o->onode.size
+	   << " bytes in " << o->onode.block_map.size()
+	   << " extents" << dendl;
+  uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+  uint64_t block_size = bdev->get_block_size();
+  uint64_t block_mask = ~(block_size - 1);
+
+  // start with any full blocks we will write
+  uint64_t offset = orig_offset;
+  uint64_t length = orig_length;
+  uint64_t head = 0;
+  uint64_t tail = 0;
+  if (offset % min_alloc_size) {
+    head = min_alloc_size - (offset % min_alloc_size);
+    offset += head;
+    if (length >= head)
+      length -= head;
+  }
+  if ((offset + length) % min_alloc_size) {
+    tail = (offset + length) % min_alloc_size;
+    if (length >= tail)
+      length -= tail;
+  }
+
+  map<uint64_t, bluestore_extent_t>::iterator bp;
+  bool shared_head = false;
+  bool shared_tail = false;
+  uint64_t orig_end = orig_offset + orig_length;
+  if (orig_offset / min_alloc_size == orig_end / min_alloc_size) {
+    // we fall within the same block
+    offset = orig_offset - orig_offset % min_alloc_size;
+    length = 0;
+    assert(offset <= orig_offset);
+    dout(20) << "  io falls within " << offset << "~" << min_alloc_size << dendl;
+    if (allow_overlay && _can_overlay_write(o, orig_length)) {
+      dout(20) << "  entire write will be captured by overlay" << dendl;
+    } else {
+      bp = o->onode.find_extent(offset);
+      if (bp == o->onode.block_map.end()) {
+	dout(20) << "  not yet allocated" << dendl;
+	length = min_alloc_size;
+      } else if (bp->second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+	dout(20) << "  shared" << dendl;
+	length = min_alloc_size;
+	shared_head = shared_tail = true;
+      } else {
+	dout(20) << "  will presumably WAL" << dendl;
+      }
+    }
+  } else {
+    dout(20) << "  initial full " << offset << "~" << length
+	     << ", head " << head << " tail " << tail << dendl;
+
+    // include tail?
+    if (tail) {
+      if (allow_overlay && _can_overlay_write(o, tail)) {
+	dout(20) << "  tail " << head << " will be captured by overlay" << dendl;
+      } else {
+	bp = o->onode.find_extent(orig_offset + orig_length - 1);
+	if (bp == o->onode.block_map.end()) {
+	  dout(20) << "  tail " << tail << " not yet allocated" << dendl;
+	  length += min_alloc_size;
+	} else if (bp->second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+	  dout(20) << "  tail shared" << dendl;
+	  length += min_alloc_size;
+	  shared_tail = true;
+	} else {
+	  dout(20) << "  tail " << tail << " will presumably WAL" << dendl;
+	}
+      }
+    }
+
+    // include head?
+    bp = o->onode.find_extent(orig_offset);
+    if (head) {
+      if (allow_overlay && _can_overlay_write(o, head)) {
+	dout(20) << "  head " << head << " will be captured by overlay" << dendl;
+      } else if (bp == o->onode.block_map.end()) {
+	dout(20) << "  head " << head << " not yet allocated" << dendl;
+	offset -= min_alloc_size;
+	length += min_alloc_size;
+      } else if (bp->second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+	dout(20) << "  head " << head << " shared" << dendl;
+	offset -= min_alloc_size;
+	length += min_alloc_size;
+	shared_head = true;
+      } else {
+	dout(20) << "  head " << head << " will presumably WAL" << dendl;
+      }
+    }
+  }
+
+  // COW head and/or tail?
+  bluestore_wal_op_t *cow_head_op = nullptr;
+  bluestore_wal_op_t *cow_tail_op = nullptr;
+  if (shared_head) {
+    uint64_t cow_offset = offset;
+    uint64_t cow_end = MIN(orig_offset & block_mask,
+			   ROUND_UP_TO(o->onode.size, block_size));
+    bp = o->onode.find_extent(cow_offset);
+    if (cow_end > cow_offset) {
+      uint64_t cow_length = cow_end - cow_offset;
+      uint64_t x_off = cow_offset - bp->first;
+      dout(20) << "  head shared, will COW "
+	       << x_off << "~" << cow_length << " of " << bp->second << dendl;
+      cow_head_op = _get_wal_op(txc, o);
+      cow_head_op->op = bluestore_wal_op_t::OP_COPY;
+      cow_head_op->src_extent.offset = bp->second.offset + x_off;
+      cow_head_op->src_extent.length = cow_length;
+      cow_head_op->extent.offset = 0;   // _do_write will reset this
+      cow_head_op->extent.length = cow_length;
+    } else {
+      dout(20) << "  head shared, but no COW needed" << dendl;
+    }
+    if (orig_offset & ~block_mask) {
+      *cow_rmw_head = bp->second.offset + orig_offset - bp->first;
+      dout(20) << "  cow_rmw_head " << *cow_rmw_head
+	       << " from " << bp->second << dendl;
+    }
+  }
+  if (shared_tail) {
+    uint64_t cow_offset_raw = orig_offset + orig_length;
+    uint64_t cow_offset = ROUND_UP_TO(cow_offset_raw, block_size);
+    uint64_t cow_end_raw = MIN(offset + length, o->onode.size);
+    uint64_t cow_end = ROUND_UP_TO(cow_end_raw, block_size);
+    bp = o->onode.find_extent(cow_offset_raw);
+    if (cow_end > cow_offset) {
+      uint64_t cow_length = cow_end - cow_offset;
+      uint64_t x_off = cow_offset - bp->first;
+      dout(20) << "  tail shared, will COW "
+	       << x_off << "~" << cow_length << " from " << bp->second << dendl;
+      cow_tail_op = _get_wal_op(txc, o);
+      cow_tail_op->op = bluestore_wal_op_t::OP_COPY;
+      cow_tail_op->src_extent.offset = bp->second.offset + x_off;
+      cow_tail_op->src_extent.length = cow_length;
+      // _do_write will adjust logical offset -> final bdev offset
+      cow_tail_op->extent.offset = cow_offset;
+      cow_tail_op->extent.length = cow_length;
+    } else {
+      dout(20) << "  tail shared, but no COW needed" << dendl;
+    }
+    if (cow_offset_raw & ~block_mask) {
+      *cow_rmw_tail = bp->second.offset + cow_offset_raw - bp->first;
+      dout(20) << "  cow_rmw_tail " << *cow_rmw_tail
+	       << " from " << bp->second << dendl;
+    }
+  }
+
+  if (length) {
+    dout(20) << "  must alloc " << offset << "~" << length << dendl;
+
+    // positional hint
+    uint64_t hint = 0;
+
+    int r = alloc->reserve(length);
+    if (r < 0) {
+      derr << __func__ << " failed to reserve " << length << dendl;
+      return r;
+    }
+
+    // deallocate existing extents
+    EnodeRef enode;
+    bp = o->onode.seek_extent(offset);
+    while (bp != o->onode.block_map.end() &&
+	   bp->first < offset + length &&
+	   bp->first + bp->second.length > offset) {
+      dout(30) << "   bp " << bp->first << ": " << bp->second << dendl;
+      if (bp->first < offset) {
+	uint64_t left = offset - bp->first;
+	if (bp->first + bp->second.length <= offset + length) {
+	  dout(20) << "  trim tail " << bp->first << ": " << bp->second << dendl;
+	  _txc_release(
+	    txc, c, enode, o->oid.hobj.get_hash(),
+	    bp->second.offset + left,
+	    bp->second.length - left,
+	    bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+	  bp->second.length = left;
+	  dout(20) << "        now " << bp->first << ": " << bp->second << dendl;
+	  hint = bp->first + bp->second.length;
+	  ++bp;
+	} else {
+	  dout(20) << "      split " << bp->first << ": " << bp->second << dendl;
+	  _txc_release(
+	    txc, c, enode, o->oid.hobj.get_hash(),
+	    bp->second.offset + left, length,
+	    bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+	  o->onode.block_map[offset + length] =
+	    bluestore_extent_t(
+	      bp->second.offset + left + length,
+	      bp->second.length - (left + length),
+	      bp->second.flags);
+	  bp->second.length = left;
+	  dout(20) << "       left " << bp->first << ": " << bp->second << dendl;
+	  ++bp;
+	  dout(20) << "      right " << bp->first << ": " << bp->second << dendl;
+	  assert(bp->first == offset + length);
+	  hint = bp->first + bp->second.length;
+	}
+      } else {
+	assert(bp->first >= offset);
+	if (bp->first + bp->second.length > offset + length) {
+	  uint64_t overlap = offset + length - bp->first;
+	  dout(20) << "  trim head " << bp->first << ": " << bp->second
+		   << " (overlap " << overlap << ")" << dendl;
+	  _txc_release(
+	    txc, c, enode, o->oid.hobj.get_hash(),
+	    bp->second.offset, overlap,
+	    bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+	  o->onode.block_map[bp->first + overlap] =
+	    bluestore_extent_t(
+	      bp->second.offset + overlap,
+	      bp->second.length - overlap,
+	      bp->second.flags);
+	  o->onode.block_map.erase(bp++);
+	  dout(20) << "        now " << bp->first << ": " << bp->second << dendl;
+	  assert(bp->first == offset + length);
+	  hint = bp->first;
+	} else {
+	  dout(20) << "    dealloc " << bp->first << ": " << bp->second << dendl;
+	  _txc_release(
+	    txc, c, enode, o->oid.hobj.get_hash(),
+	    bp->second.offset, bp->second.length,
+	    bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+	  hint = bp->first + bp->second.length;
+	  o->onode.block_map.erase(bp++);
+	}
+      }
+    }
+
+    // allocate our new extent(s)
+    uint64_t alloc_start = offset;
+    while (length > 0) {
+      bluestore_extent_t e;
+      // for safety, set the UNWRITTEN flag here.  We should clear this in
+      // _do_write or else we likely have problems.
+      e.flags |= bluestore_extent_t::FLAG_UNWRITTEN;
+      int r = alloc->allocate(length, min_alloc_size, hint,
+			      &e.offset, &e.length);
+      assert(r == 0);
+      assert(e.length <= length);  // bc length is a multiple of min_alloc_size
+      if (offset == alloc_start) {
+	if (cow_head_op) {
+	  // we set the COW flag to indicate that all or part of this new extent
+	  // will be copied from the previous allocation.
+	  e.flags |= bluestore_extent_t::FLAG_COW_HEAD;
+	}
+	if (cow_head_op) {
+	  cow_head_op->extent.offset = e.offset;
+	  dout(10) << __func__ << "  final head cow op extent "
+		   << cow_head_op->extent << dendl;
+	}
+      }
+      if (e.length == length) {
+	if (cow_tail_op) {
+	  // we set the COW flag to indicate that all or part of this new extent
+	  // will be copied from the previous allocation.
+	  e.flags |= bluestore_extent_t::FLAG_COW_TAIL;
+	}
+	if (cow_tail_op) {
+	  // extent.offset is the logical object offset
+	  assert(cow_tail_op->extent.offset >= offset);
+	  assert(cow_tail_op->extent.end() <= offset + length);
+	  cow_tail_op->extent.offset += e.offset - offset;
+	  dout(10) << __func__ << "  final tail cow op extent "
+		   << cow_tail_op->extent << dendl;
+	}
+      }
+      txc->allocated.insert(e.offset, e.length);
+      o->onode.block_map[offset] = e;
+      dout(10) << __func__ << "  alloc " << offset << ": " << e << dendl;
+      offset += e.length;
+      length -= e.length;
+      hint = e.end();
+    }
+  }
+
+  return 0;
+}
+
+bool BlueStore::_can_overlay_write(OnodeRef o, uint64_t length)
+{
+  return
+    (int)o->onode.overlay_map.size() < g_conf->bluestore_overlay_max &&
+    (int)length <= g_conf->bluestore_overlay_max_length;
+}
+
+int BlueStore::_do_write(
+  TransContext *txc,
+  CollectionRef& c,
+  OnodeRef o,
+  uint64_t orig_offset,
+  uint64_t orig_length,
+  bufferlist& orig_bl,
+  uint32_t fadvise_flags)
+{
+  int r = 0;
+
+  dout(20) << __func__
+	   << " " << o->oid << " " << orig_offset << "~" << orig_length
+	   << " - have " << o->onode.size
+	   << " bytes in " << o->onode.block_map.size()
+	   << " extents" << dendl;
+  _dump_onode(o);
+  o->exists = true;
+
+  if (orig_length == 0) {
+    return 0;
+  }
+
+  bool buffered = false;
+  if (fadvise_flags & CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) {
+    dout(20) << __func__ << " will do buffered write" << dendl;
+    buffered = true;
+  }
+
+  uint64_t block_size = bdev->get_block_size();
+  const uint64_t block_mask = ~(block_size - 1);
+  uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+  map<uint64_t, bluestore_extent_t>::iterator bp;
+  uint64_t length;
+  uint64_t cow_rmw_head = 0;
+  uint64_t cow_rmw_tail = 0;
+
+  r = _do_allocate(txc, c, o, orig_offset, orig_length, fadvise_flags, true,
+		   &cow_rmw_head, &cow_rmw_tail);
+  if (r < 0) {
+    derr << __func__ << " allocate failed, " << cpp_strerror(r) << dendl;
+    goto out;
+  }
+
+  bp = o->onode.seek_extent(orig_offset);
+
+  // zero tail of previous existing extent?
+  // (this happens if the old eof was partway through a previous extent,
+  // and we implicitly zero the rest of it by writing to a larger offset.)
+  if (orig_offset > o->onode.size) {
+    uint64_t end = ROUND_UP_TO(o->onode.size, block_size);
+    map<uint64_t, bluestore_extent_t>::iterator pp = o->onode.find_extent(end);
+    if (orig_offset > end &&
+	pp != o->onode.block_map.end() &&
+	pp != bp) {
+      assert(pp->first < bp->first);
+      uint64_t x_off = end - pp->first;
+      uint64_t x_len = pp->second.length - x_off;
+      dout(10) << __func__ << " zero tail " << x_off << "~" << x_len
+	       << " of prior extent " << pp->first << ": " << pp->second
+	       << dendl;
+      bdev->aio_zero(pp->second.offset + x_off, x_len, &txc->ioc);
+    }
+  }
+
+  for (uint64_t offset = orig_offset;
+       offset < orig_offset + orig_length;
+       offset += length) {
+    // cut to extent
+    length = orig_offset + orig_length - offset;
+    if (bp == o->onode.block_map.end() ||
+	bp->first > offset) {
+      // no allocation; crop at alloc boundary (this will be an overlay write)
+      uint64_t end = ROUND_UP_TO(offset + 1, min_alloc_size);
+      if (offset + length > end)
+	length = end - offset;
+    } else {
+      // we are inside this extent; don't go past it
+      if (bp->first + bp->second.length < offset + length) {
+	assert(bp->first <= offset);
+	length = bp->first + bp->second.length - offset;
+      }
+    }
+    bufferlist bl;
+    bl.substr_of(orig_bl, offset - orig_offset, length);
+    if (bp == o->onode.block_map.end())
+      dout(20) << __func__ << "  chunk " << offset << "~" << length
+	       << " (no extent)" << dendl;
+    else
+      dout(20) << __func__ << "  chunk " << offset << "~" << length
+	       << " extent " << bp->first << ": " << bp->second << dendl;
+
+    if (_can_overlay_write(o, length)) {
+      r = _do_overlay_write(txc, o, offset, length, bl);
+      if (r < 0)
+	goto out;
+      if (bp != o->onode.block_map.end() &&
+	  bp->first < offset + length)
+	++bp;
+      continue;
+    }
+
+    assert(bp != o->onode.block_map.end());
+    assert(offset >= bp->first);
+    assert(offset + length <= bp->first + bp->second.length);
+
+    // (pad and) overwrite unused portion of extent for an append?
+    if (offset > bp->first &&
+	offset >= o->onode.size &&                                  // past eof +
+	(offset / block_size != (o->onode.size - 1) / block_size)) {// diff block
+      dout(20) << __func__ << " append" << dendl;
+      _pad_zeros(o, &bl, &offset, &length, block_size);
+      assert(offset % block_size == 0);
+      assert(length % block_size == 0);
+      uint64_t x_off = offset - bp->first;
+      if (bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN) &&
+	  !bp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD)) {
+	if (x_off > 0) {
+	  // extent is unwritten; zero up until x_off
+	  dout(20) << __func__ << " zero " << bp->second.offset << "~" << x_off
+		   << dendl;
+	  bdev->aio_zero(bp->second.offset, x_off, &txc->ioc);
+	}
+      } else {
+	// the trailing block is zeroed from EOF to the end
+	uint64_t from = MAX(ROUND_UP_TO(o->onode.size, block_size), bp->first);
+	if (offset > from) {
+	  uint64_t zx_off = from - bp->first;
+	  uint64_t z_len = offset - from;
+	  dout(20) << __func__ << " zero " << from << "~" << z_len
+		   << " x_off " << zx_off << dendl;
+	  bdev->aio_zero(bp->second.offset + zx_off, z_len, &txc->ioc);
+	}
+	bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
+      }
+      dout(20) << __func__ << " write " << offset << "~" << length
+	       << " x_off " << x_off << dendl;
+      bdev->aio_write(bp->second.offset + x_off, bl, &txc->ioc, buffered);
+      bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
+      ++bp;
+      continue;
+    }
+
+    // use cached tail block?
+    uint64_t tail_start = o->onode.size - o->onode.size % block_size;
+    if (offset >= bp->first &&
+	offset > tail_start &&
+	offset + length >= o->onode.size &&
+	o->tail_bl.length() &&
+	(offset / block_size == (o->onode.size - 1) / block_size)) {
+      dout(20) << __func__ << " using cached tail" << dendl;
+      assert((offset & block_mask) == (o->onode.size & block_mask));
+      uint64_t tail_off = offset % block_size;
+      if (tail_off >= o->tail_bl.length()) {
+	bufferlist t;
+	t = o->tail_bl;
+	if (tail_off > t.length()) {
+	  bufferptr z(tail_off - t.length());
+	  z.zero();
+	  t.append(z);
+	}
+	offset -= t.length();
+	length += t.length();
+	t.claim_append(bl);
+	bl.swap(t);
+      } else {
+	bufferlist t;
+	t.substr_of(o->tail_bl, 0, tail_off);
+	offset -= t.length();
+	length += t.length();
+	t.claim_append(bl);
+	bl.swap(t);
+      }
+      assert(offset == tail_start);
+      assert(!bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN) ||
+	     bp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD) ||
+	     offset == bp->first);
+      bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
+      bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
+      _pad_zeros(o, &bl, &offset, &length, block_size);
+      uint64_t x_off = offset - bp->first;
+      dout(20) << __func__ << " write " << offset << "~" << length
+	       << " x_off " << x_off << dendl;
+      bdev->aio_write(bp->second.offset + x_off, bl, &txc->ioc, buffered);
+      ++bp;
+      continue;
+    }
+
+    if (offset + length > (o->onode.size & block_mask) &&
+	o->tail_bl.length()) {
+      dout(20) << __func__ << " clearing cached tail" << dendl;
+      o->clear_tail();
+    }
+
+    if (offset % min_alloc_size == 0 &&
+	length % min_alloc_size == 0) {
+      assert(bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN));
+    }
+
+    if (bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN)) {
+      // NOTE: we may need to zero before or after our write if the
+      // prior extent wasn't allocated but we are still doing some COW.
+      uint64_t z_end = offset & block_mask;
+      if (z_end > bp->first &&
+	  !bp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD)) {
+	uint64_t z_len = z_end - bp->first;
+	dout(20) << __func__ << " zero " << bp->first << "~" << z_len << dendl;
+	bdev->aio_zero(bp->second.offset, z_len, &txc->ioc);
+      }
+      uint64_t end = ROUND_UP_TO(offset + length, block_size);
+      if (end < bp->first + bp->second.length &&
+	  end <= o->onode.size &&
+	  !bp->second.has_flag(bluestore_extent_t::FLAG_COW_TAIL)) {
+	uint64_t z_len = bp->first + bp->second.length - end;
+	uint64_t x_off = end - bp->first;
+	dout(20) << __func__ << " zero " << end << "~" << z_len
+		 << " x_off " << x_off << dendl;
+	bdev->aio_zero(bp->second.offset + x_off, z_len, &txc->ioc);
+      }
+      if ((offset & ~block_mask) != 0 && !cow_rmw_head) {
+	_pad_zeros_head(o, &bl, &offset, &length, block_size);
+      }
+      if (((offset + length) & ~block_mask) != 0 && !cow_rmw_tail) {
+	_pad_zeros_tail(o, &bl, offset, &length, block_size);
+      }
+      if ((offset & ~block_mask) == 0 && (length & ~block_mask) == 0) {
+	uint64_t x_off = offset - bp->first;
+	dout(20) << __func__ << " write " << offset << "~" << length
+		 << " x_off " << x_off << dendl;
+	bdev->aio_write(bp->second.offset + x_off, bl, &txc->ioc, buffered);
+	bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
+	bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
+	bp->second.clear_flag(bluestore_extent_t::FLAG_COW_TAIL);
+	++bp;
+	continue;
+      }
+    }
+
+    // WAL.
+    r = _do_write_overlays(txc, c, o, bp->first, bp->second.length);
+    if (r < 0)
+      goto out;
+    assert(bp->first <= offset);
+    assert(offset + length <= bp->first + bp->second.length);
+    bluestore_wal_op_t *op = _get_wal_op(txc, o);
+    op->op = bluestore_wal_op_t::OP_WRITE;
+    if (offset == orig_offset && cow_rmw_head) {
+      op->src_rmw_head = cow_rmw_head;
+      dout(20) << __func__ << " src_rmw_head " << op->src_rmw_head << dendl;
+    }
+    if (offset + length == orig_offset + orig_length && cow_rmw_tail) {
+      op->src_rmw_tail = cow_rmw_tail;
+      dout(20) << __func__ << " src_rmw_tail " << op->src_rmw_tail << dendl;
+    } else if (((offset + length) & ~block_mask) &&
+	       offset + length > o->onode.size) {
+      dout(20) << __func__ << " past eof, padding out tail block" << dendl;
+      _pad_zeros_tail(o, &bl, offset, &length, block_size);
+    }
+    bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
+    bp->second.clear_flag(bluestore_extent_t::FLAG_COW_TAIL);
+    bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
+    op->extent.offset = bp->second.offset + offset - bp->first;
+    op->extent.length = length;
+    op->data = bl;
+    if (offset + length - bp->first > bp->second.length) {
+      op->extent.length = offset + length - bp->first;
+    }
+    dout(20) << __func__ << " wal write "
+	     << offset << "~" << length << " to " << op->extent
+	     << dendl;
+    ++bp;
+    continue;
+  }
+  r = 0;
+
+  if (orig_offset + orig_length > o->onode.size) {
+    dout(20) << __func__ << " extending size to " << orig_offset + orig_length
+	     << dendl;
+    o->onode.size = orig_offset + orig_length;
+  }
+
+  // make sure we didn't leave unwritten extents behind
+  for (map<uint64_t,bluestore_extent_t>::iterator p = o->onode.block_map.begin();
+       p != o->onode.block_map.end();
+       ++p) {
+    if (p->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN)) {
+      derr << __func__ << " left behind an unwritten extent, out of sync with "
+	   << "_do_allocate" << dendl;
+      _dump_onode(o);
+      assert(0 == "leaked unwritten extent");
+    }
+    if (p->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD) ||
+	p->second.has_flag(bluestore_extent_t::FLAG_COW_TAIL)) {
+      derr << __func__ << " left behind a COW extent, out of sync with "
+	   << "_do_allocate" << dendl;
+      _dump_onode(o);
+      assert(0 == "leaked cow extent");
+    }
+  }
+
+ out:
+  return r;
+}
+
+int BlueStore::_write(TransContext *txc,
+		     CollectionRef& c,
+		     const ghobject_t& oid,
+		     uint64_t offset, size_t length,
+		     bufferlist& bl,
+		     uint32_t fadvise_flags)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " " << offset << "~" << length
+	   << dendl;
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, true);
+  _assign_nid(txc, o);
+  int r = _do_write(txc, c, o, offset, length, bl, fadvise_flags);
+  txc->write_onode(o);
+
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " " << offset << "~" << length
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_do_write_zero(
+  TransContext *txc,
+  CollectionRef& c,
+  OnodeRef o,
+  uint64_t offset,
+  uint64_t length)
+{
+  bufferptr z(length);
+  z.zero();
+  bufferlist zl;
+  zl.push_back(z);
+  return _do_write(txc, c, o, offset, length, zl, 0);
+}
+
+int BlueStore::_zero(TransContext *txc,
+		    CollectionRef& c,
+		    const ghobject_t& oid,
+		    uint64_t offset, size_t length)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " " << offset << "~" << length
+	   << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  EnodeRef enode;
+  OnodeRef o = c->get_onode(oid, true);
+  _dump_onode(o);
+  _assign_nid(txc, o);
+
+  // overlay
+  _do_overlay_trim(txc, o, offset, length);
+
+  uint64_t block_size = bdev->get_block_size();
+  map<uint64_t,bluestore_extent_t>::iterator bp = o->onode.seek_extent(offset);
+
+  // zero tail of previous existing extent?
+  // (this happens if the old eof was partway through a previous extent,
+  // and we implicitly zero the rest of it by writing to a larger offset.)
+  if (offset > o->onode.size) {
+    uint64_t end = ROUND_UP_TO(o->onode.size, block_size);
+    map<uint64_t, bluestore_extent_t>::iterator pp = o->onode.find_extent(end);
+    if (offset > end &&
+	pp != o->onode.block_map.end()) {
+      uint64_t x_off = end - pp->first;
+      uint64_t x_len = pp->second.length - x_off;
+      dout(10) << __func__ << " zero tail " << x_off << "~" << x_len
+	       << " of prior extent " << pp->first << ": " << pp->second
+	       << dendl;
+      bdev->aio_zero(pp->second.offset + x_off, x_len, &txc->ioc);
+    }
+  }
+
+  while (bp != o->onode.block_map.end()) {
+    if (bp->first >= offset + length)
+      break;
+
+    if (offset <= bp->first &&
+	(offset + length >= bp->first + bp->second.length ||
+	 offset >= o->onode.size)) {
+      // remove fragment
+      dout(20) << __func__ << " dealloc " << bp->first << ": "
+	       << bp->second << dendl;
+      _txc_release(
+	txc, c, enode, oid.hobj.get_hash(),
+	bp->second.offset, bp->second.length,
+	bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+      o->onode.block_map.erase(bp++);
+      continue;
+    }
+
+    // start,end are offsets in the extent
+    uint64_t x_off = 0;
+    if (offset > bp->first) {
+      x_off = offset - bp->first;
+    }
+    uint64_t x_len = MIN(offset + length - bp->first,
+			 bp->second.length) - x_off;
+
+    if (bp->second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+      uint64_t end = bp->first + x_off + x_len;
+      _do_write_zero(txc, c, o, bp->first + x_off, x_len);
+      // we probably invalidated bp.  move past the extent we just
+      // reallocated.
+      bp = o->onode.seek_extent(end - 1);
+    } else {
+      // WAL
+      bluestore_wal_op_t *op = _get_wal_op(txc, o);
+      op->op = bluestore_wal_op_t::OP_ZERO;
+      op->extent.offset = bp->second.offset + x_off;
+      op->extent.length = x_len;
+      dout(20) << __func__ << "  wal zero " << x_off << "~" << x_len
+	       << " " << op->extent << dendl;
+    }
+    bp++;
+  }
+
+  if (offset + length > o->onode.size) {
+    o->onode.size = offset + length;
+    dout(20) << __func__ << " extending size to " << offset + length
+	     << dendl;
+  }
+  txc->write_onode(o);
+
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " " << offset << "~" << length
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_do_truncate(
+  TransContext *txc, CollectionRef& c, OnodeRef o, uint64_t offset)
+{
+  uint64_t block_size = bdev->get_block_size();
+  uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
+  uint64_t alloc_end = ROUND_UP_TO(offset, min_alloc_size);
+  EnodeRef enode;
+
+  // ensure any wal IO has completed before we truncate off any extents
+  // they may touch.
+  o->flush();
+
+  // trim down cached tail
+  if (o->tail_bl.length()) {
+    // we could adjust this if we truncate down within the same
+    // block...
+    dout(20) << __func__ << " clear cached tail" << dendl;
+    o->clear_tail();
+  }
+
+  // trim down fragments
+  map<uint64_t,bluestore_extent_t>::iterator bp = o->onode.block_map.end();
+  if (bp != o->onode.block_map.begin())
+    --bp;
+  while (bp != o->onode.block_map.end()) {
+    if (bp->first + bp->second.length <= alloc_end) {
+      break;
+    }
+    if (bp->first >= alloc_end) {
+      dout(20) << __func__ << " dealloc " << bp->first << ": "
+	       << bp->second << dendl;
+      _txc_release(
+	txc, c, enode, o->oid.hobj.get_hash(),
+	bp->second.offset, bp->second.length,
+	bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+      if (bp != o->onode.block_map.begin()) {
+	o->onode.block_map.erase(bp--);
+	continue;
+      } else {
+	o->onode.block_map.erase(bp);
+	break;
+      }
+    } else {
+      assert(bp->first + bp->second.length > alloc_end);
+      assert(bp->first < alloc_end);
+      uint64_t newlen = alloc_end - bp->first;
+      assert(newlen % min_alloc_size == 0);
+      dout(20) << __func__ << " trunc " << bp->first << ": " << bp->second
+	       << " to " << newlen << dendl;
+      _txc_release(
+	txc, c, enode, o->oid.hobj.get_hash(),
+	bp->second.offset + newlen, bp->second.length - newlen,
+	bp->second.has_flag(bluestore_extent_t::FLAG_SHARED));
+      bp->second.length = newlen;
+      break;
+    }
+  }
+
+  // adjust size now, in case we need to call _do_write_zero below.
+  uint64_t old_size = o->onode.size;
+  o->onode.size = offset;
+
+  // zero extent if trimming up?
+  if (offset > old_size) {
+    map<uint64_t,bluestore_extent_t>::iterator bp = o->onode.block_map.end();
+    if (bp != o->onode.block_map.begin())
+      --bp;
+    uint64_t x_end = bp->first + bp->second.length;
+    if (bp != o->onode.block_map.end() &&
+	x_end > old_size) {
+      // we need to zero from old_size to (end of extent or offset)
+      assert(offset > bp->first);    // else we would have trimmed it above
+      assert(old_size > bp->first);  // we do no preallocation (yet)
+      uint64_t x_off = old_size - bp->first;
+      uint64_t x_len = MIN(ROUND_UP_TO(offset, block_size), x_end) - old_size;
+      if (bp->second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+	_do_write_zero(txc, c, o, old_size, x_len);
+	o->onode.size = offset; // we (maybe) just wrote past eof; reset size
+      } else {
+	bluestore_wal_op_t *op = _get_wal_op(txc, o);
+	op->op = bluestore_wal_op_t::OP_ZERO;
+	op->extent.offset = bp->second.offset + x_off;
+	op->extent.length = x_len;
+	dout(20) << __func__ << "  wal zero " << x_off << "~" << x_len
+		 << " " << op->extent << dendl;
+      }
+    }
+  } else if (offset < old_size &&
+	     offset % block_size != 0) {
+    // zero trailing block?
+    map<uint64_t,bluestore_extent_t>::iterator bp = o->onode.find_extent(offset);
+    if (bp != o->onode.block_map.end()) {
+      uint64_t z_len = block_size - offset % block_size;
+      if (bp->second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+	_do_write_zero(txc, c, o, offset, z_len);
+	o->onode.size = offset; // we just wrote past eof; reset size
+      } else {
+	bluestore_wal_op_t *op = _get_wal_op(txc, o);
+	op->op = bluestore_wal_op_t::OP_ZERO;
+	op->extent.offset = bp->second.offset + offset - bp->first;
+	op->extent.length = block_size - offset % block_size;
+	dout(20) << __func__ << " wal zero tail " << offset << "~" << z_len
+		 << " at " << op->extent << dendl;
+      }
+    }
+  }
+
+  // trim down overlays
+  map<uint64_t,bluestore_overlay_t>::iterator op = o->onode.overlay_map.end();
+  if (op != o->onode.overlay_map.begin())
+    --op;
+  while (op != o->onode.overlay_map.end()) {
+    if (op->first + op->second.length <= offset) {
+      break;
+    }
+    if (op->first >= offset) {
+      if (o->onode.put_overlay_ref(op->second.key)) {
+	dout(20) << __func__ << " rm overlay " << op->first << " "
+		 << op->second << dendl;
+	string key;
+	get_overlay_key(o->onode.nid, op->second.key, &key);
+	txc->t->rmkey(PREFIX_OVERLAY, key);
+      } else {
+	dout(20) << __func__ << " rm overlay " << op->first << " "
+		 << op->second << " (put ref)" << dendl;
+      }
+      if (op != o->onode.overlay_map.begin()) {
+	o->onode.overlay_map.erase(op--);
+	continue;
+      } else {
+	o->onode.overlay_map.erase(op);
+	break;
+      }
+    } else {
+      assert(op->first + op->second.length > offset);
+      assert(op->first < offset);
+      uint64_t newlen = offset - op->first;
+      dout(20) << __func__ << " truncate overlay " << op->first << " "
+	       << op->second << " to " << newlen << dendl;
+      bluestore_overlay_t& ov = op->second;
+      ov.length = newlen;
+      break;
+    }
+  }
+
+  txc->write_onode(o);
+  return 0;
+}
+
+int BlueStore::_truncate(TransContext *txc,
+			CollectionRef& c,
+			const ghobject_t& oid,
+			uint64_t offset)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " " << offset
+	   << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  r = _do_truncate(txc, c, o, offset);
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " " << offset
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_do_remove(
+  TransContext *txc,
+  CollectionRef& c,
+  OnodeRef o)
+{
+  _do_truncate(txc, c, o, 0);
+  if (o->onode.omap_head) {
+    _do_omap_clear(txc, o->onode.omap_head);
+  }
+  o->exists = false;
+  o->onode = bluestore_onode_t();
+  txc->onodes.erase(o);
+  txc->t->rmkey(PREFIX_OBJ, o->key);
+  return 0;
+}
+
+int BlueStore::_remove(TransContext *txc,
+		      CollectionRef& c,
+		      const ghobject_t& oid)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r;
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  r = _do_remove(txc, c, o);
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_setattr(TransContext *txc,
+		       CollectionRef& c,
+		       const ghobject_t& oid,
+		       const string& name,
+		       bufferptr& val)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " " << name << " (" << val.length() << " bytes)"
+	   << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  o->onode.attrs[name] = val;
+  txc->write_onode(o);
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " " << name << " (" << val.length() << " bytes)"
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_setattrs(TransContext *txc,
+			CollectionRef& c,
+			const ghobject_t& oid,
+			const map<string,bufferptr>& aset)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " " << aset.size() << " keys"
+	   << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  for (map<string,bufferptr>::const_iterator p = aset.begin();
+       p != aset.end(); ++p) {
+    if (p->second.is_partial())
+      o->onode.attrs[p->first] = bufferptr(p->second.c_str(), p->second.length());
+    else
+      o->onode.attrs[p->first] = p->second;
+  }
+  txc->write_onode(o);
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " " << aset.size() << " keys"
+	   << " = " << r << dendl;
+  return r;
+}
+
+
+int BlueStore::_rmattr(TransContext *txc,
+		      CollectionRef& c,
+		      const ghobject_t& oid,
+		      const string& name)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " " << name << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  o->onode.attrs.erase(name);
+  txc->write_onode(o);
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " " << name << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_rmattrs(TransContext *txc,
+		       CollectionRef& c,
+		       const ghobject_t& oid)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  o->onode.attrs.clear();
+  txc->write_onode(o);
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+void BlueStore::_do_omap_clear(TransContext *txc, uint64_t id)
+{
+  KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+  string prefix, tail;
+  get_omap_header(id, &prefix);
+  get_omap_tail(id, &tail);
+  it->lower_bound(prefix);
+  while (it->valid()) {
+    if (it->key() >= tail) {
+      dout(30) << __func__ << "  stop at " << tail << dendl;
+      break;
+    }
+    txc->t->rmkey(PREFIX_OMAP, it->key());
+    dout(30) << __func__ << "  rm " << pretty_binary_string(it->key()) << dendl;
+    it->next();
+  }
+}
+
+int BlueStore::_omap_clear(TransContext *txc,
+			  CollectionRef& c,
+			  const ghobject_t& oid)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (o->onode.omap_head != 0) {
+    _do_omap_clear(txc, o->onode.omap_head);
+  }
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_omap_setkeys(TransContext *txc,
+			    CollectionRef& c,
+			    const ghobject_t& oid,
+			    bufferlist &bl)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+  bufferlist::iterator p = bl.begin();
+  __u32 num;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head) {
+    o->onode.omap_head = o->onode.nid;
+    txc->write_onode(o);
+  }
+  ::decode(num, p);
+  while (num--) {
+    string key;
+    bufferlist value;
+    ::decode(key, p);
+    ::decode(value, p);
+    string final_key;
+    get_omap_key(o->onode.omap_head, key, &final_key);
+    dout(30) << __func__ << "  " << pretty_binary_string(final_key)
+	     << " <- " << key << dendl;
+    txc->t->set(PREFIX_OMAP, final_key, value);
+  }
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_omap_setheader(TransContext *txc,
+			      CollectionRef& c,
+			      const ghobject_t& oid,
+			      bufferlist& bl)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  string key;
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head) {
+    o->onode.omap_head = o->onode.nid;
+    txc->write_onode(o);
+  }
+  get_omap_header(o->onode.omap_head, &key);
+  txc->t->set(PREFIX_OMAP, key, bl);
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_omap_rmkeys(TransContext *txc,
+			   CollectionRef& c,
+			   const ghobject_t& oid,
+			   bufferlist& bl)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+  bufferlist::iterator p = bl.begin();
+  __u32 num;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head) {
+    r = 0;
+    goto out;
+  }
+  ::decode(num, p);
+  while (num--) {
+    string key;
+    ::decode(key, p);
+    string final_key;
+    get_omap_key(o->onode.omap_head, key, &final_key);
+    dout(30) << __func__ << "  rm " << pretty_binary_string(final_key)
+	     << " <- " << key << dendl;
+    txc->t->rmkey(PREFIX_OMAP, final_key);
+  }
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_omap_rmkey_range(TransContext *txc,
+				CollectionRef& c,
+				const ghobject_t& oid,
+				const string& first, const string& last)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
+  int r = 0;
+  KeyValueDB::Iterator it;
+  string key_first, key_last;
+
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  if (!o->onode.omap_head) {
+    r = 0;
+    goto out;
+  }
+  it = db->get_iterator(PREFIX_OMAP);
+  get_omap_key(o->onode.omap_head, first, &key_first);
+  get_omap_key(o->onode.omap_head, last, &key_last);
+  it->lower_bound(key_first);
+  while (it->valid()) {
+    if (it->key() >= key_last) {
+      dout(30) << __func__ << "  stop at " << pretty_binary_string(key_last)
+	       << dendl;
+      break;
+    }
+    txc->t->rmkey(PREFIX_OMAP, it->key());
+    dout(30) << __func__ << "  rm " << pretty_binary_string(it->key()) << dendl;
+    it->next();
+  }
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_setallochint(TransContext *txc,
+			    CollectionRef& c,
+			    const ghobject_t& oid,
+			    uint64_t expected_object_size,
+			    uint64_t expected_write_size)
+{
+  dout(15) << __func__ << " " << c->cid << " " << oid
+	   << " object_size " << expected_object_size
+	   << " write_size " << expected_write_size
+	   << dendl;
+  int r = 0;
+  RWLock::WLocker l(c->lock);
+  OnodeRef o = c->get_onode(oid, false);
+  if (!o || !o->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+
+  o->onode.expected_object_size = expected_object_size;
+  o->onode.expected_write_size = expected_write_size;
+  txc->write_onode(o);
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << oid
+	   << " object_size " << expected_object_size
+	   << " write_size " << expected_write_size
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_clone(TransContext *txc,
+		     CollectionRef& c,
+		     const ghobject_t& old_oid,
+		     const ghobject_t& new_oid)
+{
+  dout(15) << __func__ << " " << c->cid << " " << old_oid << " -> "
+	   << new_oid << dendl;
+  int r = 0;
+  if (old_oid.hobj.get_hash() != new_oid.hobj.get_hash()) {
+    derr << __func__ << " mismatched hash on " << old_oid << " and " << new_oid
+	 << dendl;
+    return -EINVAL;
+  }
+
+  RWLock::WLocker l(c->lock);
+  bufferlist bl;
+  OnodeRef newo;
+  OnodeRef oldo = c->get_onode(old_oid, false);
+  if (!oldo || !oldo->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  newo = c->get_onode(new_oid, true);
+  assert(newo);
+  newo->exists = true;
+  _assign_nid(txc, newo);
+
+  // data
+  oldo->flush();
+
+  r = _do_truncate(txc, c, newo, 0);
+  if (r < 0)
+    goto out;
+
+  if (g_conf->bluestore_clone_cow) {
+    EnodeRef e = c->get_enode(newo->oid.hobj.get_hash());
+    bool marked = false;
+    for (auto& p : oldo->onode.block_map) {
+      if (p.second.has_flag(bluestore_extent_t::FLAG_SHARED)) {
+	e->ref_map.get(p.second.offset, p.second.length);
+      } else {
+	p.second.set_flag(bluestore_extent_t::FLAG_SHARED);
+	e->ref_map.add(p.second.offset, p.second.length, 2);
+	marked = true;
+      }
+    }
+    dout(20) << __func__ << " hash " << e->hash << " ref_map now "
+	     << e->ref_map << dendl;
+    newo->onode.block_map = oldo->onode.block_map;
+    newo->onode.size = oldo->onode.size;
+    dout(20) << __func__ << " block_map " << newo->onode.block_map << dendl;
+    txc->write_enode(e);
+    if (marked)
+      txc->write_onode(oldo);
+  } else {
+    // read + write
+    r = _do_read(oldo, 0, oldo->onode.size, bl, 0);
+    if (r < 0)
+      goto out;
+
+    r = _do_write(txc, c, newo, 0, oldo->onode.size, bl, 0);
+  }
+
+  // attrs
+  newo->onode.attrs = oldo->onode.attrs;
+
+  // clone omap
+  if (newo->onode.omap_head) {
+    dout(20) << __func__ << " clearing old omap data" << dendl;
+    _do_omap_clear(txc, newo->onode.omap_head);
+  }
+  if (oldo->onode.omap_head) {
+    dout(20) << __func__ << " copying omap data" << dendl;
+    if (!newo->onode.omap_head) {
+      newo->onode.omap_head = newo->onode.nid;
+    }
+    KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+    string head, tail;
+    get_omap_header(oldo->onode.omap_head, &head);
+    get_omap_tail(oldo->onode.omap_head, &tail);
+    it->lower_bound(head);
+    while (it->valid()) {
+      string key;
+      if (it->key() >= tail) {
+	dout(30) << __func__ << "  reached tail" << dendl;
+	break;
+      } else {
+	dout(30) << __func__ << "  got header/data "
+		 << pretty_binary_string(it->key()) << dendl;
+	assert(it->key() < tail);
+	rewrite_omap_key(newo->onode.omap_head, it->key(), &key);
+	txc->t->set(PREFIX_OMAP, key, it->value());
+      }
+      it->next();
+    }
+  }
+
+  txc->write_onode(newo);
+
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << old_oid << " -> "
+	   << new_oid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_clone_range(TransContext *txc,
+			   CollectionRef& c,
+			   const ghobject_t& old_oid,
+			   const ghobject_t& new_oid,
+			   uint64_t srcoff, uint64_t length, uint64_t dstoff)
+{
+  dout(15) << __func__ << " " << c->cid << " " << old_oid << " -> "
+	   << new_oid << " from " << srcoff << "~" << length
+	   << " to offset " << dstoff << dendl;
+  int r = 0;
+
+  RWLock::WLocker l(c->lock);
+  bufferlist bl;
+  OnodeRef newo;
+  OnodeRef oldo = c->get_onode(old_oid, false);
+  if (!oldo || !oldo->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  newo = c->get_onode(new_oid, true);
+  assert(newo);
+  newo->exists = true;
+
+  r = _do_read(oldo, srcoff, length, bl, 0);
+  if (r < 0)
+    goto out;
+
+  r = _do_write(txc, c, newo, dstoff, bl.length(), bl, 0);
+
+  txc->write_onode(newo);
+
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << old_oid << " -> "
+	   << new_oid << " from " << srcoff << "~" << length
+	   << " to offset " << dstoff
+	   << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_rename(TransContext *txc,
+		      CollectionRef& c,
+		      const ghobject_t& old_oid,
+		      const ghobject_t& new_oid)
+{
+  dout(15) << __func__ << " " << c->cid << " " << old_oid << " -> "
+	   << new_oid << dendl;
+  int r;
+
+  RWLock::WLocker l(c->lock);
+  bufferlist bl;
+  string old_key, new_key;
+  OnodeRef newo;
+  OnodeRef oldo = c->get_onode(old_oid, false);
+  if (!oldo || !oldo->exists) {
+    r = -ENOENT;
+    goto out;
+  }
+  newo = c->get_onode(new_oid, true);
+  assert(newo);
+
+  if (newo->exists) {
+    r = _do_remove(txc, c, newo);
+    if (r < 0)
+      return r;
+  }
+
+  txc->t->rmkey(PREFIX_OBJ, oldo->key);
+  txc->write_onode(oldo);
+  c->onode_map.rename(old_oid, new_oid);  // this adjusts oldo->{oid,key}
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << c->cid << " " << old_oid << " -> "
+	   << new_oid << " = " << r << dendl;
+  return r;
+}
+
+// collections
+
+int BlueStore::_create_collection(
+  TransContext *txc,
+  coll_t cid,
+  unsigned bits,
+  CollectionRef *c)
+{
+  dout(15) << __func__ << " " << cid << " bits " << bits << dendl;
+  int r;
+  bufferlist bl;
+
+  {
+    RWLock::WLocker l(coll_lock);
+    if (*c) {
+      r = -EEXIST;
+      goto out;
+    }
+    c->reset(new Collection(this, cid));
+    (*c)->cnode.bits = bits;
+    coll_map[cid] = *c;
+  }
+  ::encode((*c)->cnode, bl);
+  txc->t->set(PREFIX_COLL, stringify(cid), bl);
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << cid << " bits " << bits << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_remove_collection(TransContext *txc, coll_t cid,
+				 CollectionRef *c)
+{
+  dout(15) << __func__ << " " << cid << dendl;
+  int r;
+
+  {
+    RWLock::WLocker l(coll_lock);
+    if (!*c) {
+      r = -ENOENT;
+      goto out;
+    }
+    pair<ghobject_t,OnodeRef> next;
+    while ((*c)->onode_map.get_next(next.first, &next)) {
+      if (next.second->exists) {
+	r = -ENOTEMPTY;
+	goto out;
+      }
+    }
+    coll_map.erase(cid);
+    txc->removed_collections.push_back(*c);
+    c->reset();
+  }
+  txc->t->rmkey(PREFIX_COLL, stringify(cid));
+  r = 0;
+
+ out:
+  dout(10) << __func__ << " " << cid << " = " << r << dendl;
+  return r;
+}
+
+int BlueStore::_split_collection(TransContext *txc,
+				CollectionRef& c,
+				CollectionRef& d,
+				unsigned bits, int rem)
+{
+  dout(15) << __func__ << " " << c->cid << " to " << d->cid << " "
+	   << " bits " << bits << dendl;
+  int r;
+  RWLock::WLocker l(c->lock);
+  RWLock::WLocker l2(d->lock);
+  c->onode_map.clear();
+  d->onode_map.clear();
+  c->cnode.bits = bits;
+  assert(d->cnode.bits == bits);
+  r = 0;
+
+  bufferlist bl;
+  ::encode(c->cnode, bl);
+  txc->t->set(PREFIX_COLL, stringify(c->cid), bl);
+
+  dout(10) << __func__ << " " << c->cid << " to " << d->cid << " "
+	   << " bits " << bits << " = " << r << dendl;
+  return r;
+}
+
+// ===========================================
diff --git a/src/os/newstore/NewStore.h b/src/os/bluestore/BlueStore.h
similarity index 73%
copy from src/os/newstore/NewStore.h
copy to src/os/bluestore/BlueStore.h
index c32e2a9..cfabfe6 100644
--- a/src/os/newstore/NewStore.h
+++ b/src/os/bluestore/BlueStore.h
@@ -12,13 +12,17 @@
  *
  */
 
-#ifndef CEPH_OSD_NEWSTORE_H
-#define CEPH_OSD_NEWSTORE_H
+#ifndef CEPH_OSD_BLUESTORE_H
+#define CEPH_OSD_BLUESTORE_H
 
 #include "acconfig.h"
 
 #include <unistd.h>
 
+#include <boost/intrusive/list.hpp>
+#include <boost/intrusive/unordered_set.hpp>
+#include <boost/functional/hash.hpp>
+
 #include "include/assert.h"
 #include "include/unordered_map.h"
 #include "include/memory.h"
@@ -29,17 +33,77 @@
 #include "os/fs/FS.h"
 #include "kv/KeyValueDB.h"
 
-#include "newstore_types.h"
+#include "bluestore_types.h"
+#include "BlockDevice.h"
 
-#include "boost/intrusive/list.hpp"
+class Allocator;
+class FreelistManager;
+class BlueFS;
 
-class NewStore : public ObjectStore {
+class BlueStore : public ObjectStore {
   // -----------------------------------------------------
   // types
 public:
 
   class TransContext;
 
+  /// an in-memory extent-map, shared by a group of objects (w/ same hash value)
+  struct EnodeSet;
+
+  struct Enode : public boost::intrusive::unordered_set_base_hook<> {
+    atomic_t nref;        ///< reference count
+    uint32_t hash;
+    string key;           ///< key under PREFIX_OBJ where we are stored
+    EnodeSet *enode_set;  ///< reference to the containing set
+
+    bluestore_extent_ref_map_t ref_map;
+
+    boost::intrusive::unordered_set_member_hook<> map_item;
+
+    Enode(uint32_t h, const string& k, EnodeSet *s)
+      : nref(0),
+	hash(h),
+	key(k),
+	enode_set(s) {}
+
+    void get() {
+      nref.inc();
+    }
+    void put();
+
+    friend void intrusive_ptr_add_ref(Enode *e) { e->get(); }
+    friend void intrusive_ptr_release(Enode *e) { e->put(); }
+
+    friend bool operator==(const Enode &l, const Enode &r) {
+      return l.hash == r.hash;
+    }
+    friend std::size_t hash_value(const Enode &e) {
+      return e.hash;
+    }
+  };
+  typedef boost::intrusive_ptr<Enode> EnodeRef;
+
+  /// hash of Enodes, by (object) hash value
+  struct EnodeSet {
+    typedef boost::intrusive::unordered_set<Enode>::bucket_type bucket_type;
+    typedef boost::intrusive::unordered_set<Enode>::bucket_traits bucket_traits;
+
+    unsigned num_buckets;
+    vector<bucket_type> buckets;
+
+    boost::intrusive::unordered_set<Enode> uset;
+
+    EnodeSet(unsigned n)
+      : num_buckets(n),
+	buckets(n),
+	uset(bucket_traits(buckets.data(), num_buckets)) {
+      assert(n > 0);
+    }
+    ~EnodeSet() {
+      assert(uset.empty());
+    }
+  };
+
   /// an in-memory object
   struct Onode {
     atomic_t nref;  ///< reference count
@@ -48,21 +112,22 @@ public:
     string key;     ///< key under PREFIX_OBJ where we are stored
     boost::intrusive::list_member_hook<> lru_item;
 
-    onode_t onode;  ///< metadata stored as value in kv store
+    EnodeRef enode;  ///< ref to Enode [optional]
+
+    bluestore_onode_t onode;  ///< metadata stored as value in kv store
     bool dirty;     // ???
     bool exists;
 
-    Mutex flush_lock;  ///< protect unappliex_txns, num_fsyncs
-    Cond flush_cond;   ///< wait here for unapplied txns, fsyncs
-    set<TransContext*> flush_txns;   ///< fsyncing or committing or wal txns
+    Mutex flush_lock;  ///< protect flush_txns
+    Cond flush_cond;   ///< wait here for unapplied txns
+    set<TransContext*> flush_txns;   ///< committing or wal txns
+
+    uint64_t tail_offset;
+    bufferlist tail_bl;
 
     Onode(const ghobject_t& o, const string& k);
 
-    void flush() {
-      Mutex::Locker l(flush_lock);
-      while (!flush_txns.empty())
-	flush_cond.Wait(flush_lock);
-    }
+    void flush();
     void get() {
       nref.inc();
     }
@@ -70,6 +135,11 @@ public:
       if (nref.dec() == 0)
 	delete this;
     }
+
+    void clear_tail() {
+      tail_offset = 0;
+      tail_bl.clear();
+    }
   };
   typedef boost::intrusive_ptr<Onode> OnodeRef;
 
@@ -85,12 +155,11 @@ public:
     ceph::unordered_map<ghobject_t,OnodeRef> onode_map;  ///< forward lookups
     lru_list_t lru;                                      ///< lru
 
-    OnodeHashLRU() : lock("NewStore::OnodeHashLRU::lock") {}
+    OnodeHashLRU() : lock("BlueStore::OnodeHashLRU::lock") {}
 
     void add(const ghobject_t& oid, OnodeRef o);
     void _touch(OnodeRef o);
     OnodeRef lookup(const ghobject_t& o);
-    void remove(const ghobject_t& o);
     void rename(const ghobject_t& old_oid, const ghobject_t& new_oid);
     void clear();
     bool get_next(const ghobject_t& after, pair<ghobject_t,OnodeRef> *next);
@@ -98,18 +167,32 @@ public:
   };
 
   struct Collection {
-    NewStore *store;
+    BlueStore *store;
     coll_t cid;
-    cnode_t cnode;
+    bluestore_cnode_t cnode;
     RWLock lock;
 
     // cache onodes on a per-collection basis to avoid lock
     // contention.
     OnodeHashLRU onode_map;
 
+    EnodeSet enode_set;      ///< open Enodes
+
     OnodeRef get_onode(const ghobject_t& oid, bool create);
+    EnodeRef get_enode(uint32_t hash);
+
+    bool contains(const ghobject_t& oid) {
+      if (cid.is_meta())
+	return oid.hobj.pool == -1;
+      spg_t spgid;
+      if (cid.is_pg(&spgid))
+	return
+	  spgid.pgid.contains(cnode.bits, oid) &&
+	  oid.shard_id == spgid.shard;
+      return false;
+    }
 
-    Collection(NewStore *ns, coll_t c);
+    Collection(BlueStore *ns, coll_t c);
   };
   typedef ceph::shared_ptr<Collection> CollectionRef;
 
@@ -135,17 +218,9 @@ public:
   class OpSequencer;
   typedef boost::intrusive_ptr<OpSequencer> OpSequencerRef;
 
-  struct fsync_item {
-    boost::intrusive::list_member_hook<> queue_item;
-    int fd;
-    TransContext *txc;
-    fsync_item(int f, TransContext *t) : fd(f), txc(t) {}
-  };
-
   struct TransContext {
     typedef enum {
       STATE_PREPARE,
-      STATE_FSYNC_WAIT,
       STATE_AIO_WAIT,
       STATE_IO_DONE,
       STATE_KV_QUEUED,
@@ -165,7 +240,6 @@ public:
     const char *get_state_name() {
       switch (state) {
       case STATE_PREPARE: return "prepare";
-      case STATE_FSYNC_WAIT: return "fsync_wait";
       case STATE_AIO_WAIT: return "aio_wait";
       case STATE_IO_DONE: return "io_done";
       case STATE_KV_QUEUED: return "kv_queued";
@@ -187,8 +261,8 @@ public:
 
     uint64_t ops, bytes;
 
-    list<fsync_item> sync_items; ///< these fds need to be synced
     set<OnodeRef> onodes;     ///< these onodes need to be updated/written
+    set<EnodeRef> enodes;     ///< these enodes need to be updated/written
     KeyValueDB::Transaction t; ///< then we will commit this
     Context *oncommit;         ///< signal on commit
     Context *onreadable;         ///< signal on readable
@@ -197,16 +271,12 @@ public:
     list<CollectionRef> removed_collections; ///< colls we removed
 
     boost::intrusive::list_member_hook<> wal_queue_item;
-    wal_transaction_t *wal_txn; ///< wal transaction (if any)
-    unsigned num_fsyncs_completed;
+    bluestore_wal_transaction_t *wal_txn; ///< wal transaction (if any)
+    vector<OnodeRef> wal_op_onodes;
 
-    list<FS::aio_t> pending_aios;    ///< not yet submitted
-    list<FS::aio_t> submitted_aios;  ///< submitting or submitted
-    bufferlist aio_bl;  // just a pile of refs
-    atomic_t num_aio;
+    interval_set<uint64_t> allocated, released;
 
-    Mutex lock;
-    Cond cond;
+    IOContext ioc;
 
     CollectionRef first_collection;  ///< first referenced collection
 
@@ -219,9 +289,7 @@ public:
 	onreadable(NULL),
 	onreadable_sync(NULL),
 	wal_txn(NULL),
-	num_fsyncs_completed(0),
-	num_aio(0),
-	lock("NewStore::TransContext::lock") {
+	ioc(this) {
       //cout << "txc new " << this << std::endl;
     }
     ~TransContext() {
@@ -229,26 +297,11 @@ public:
       //cout << "txc del " << this << std::endl;
     }
 
-    void sync_fd(int f) {
-      sync_items.push_back(fsync_item(f, this));
-    }
     void write_onode(OnodeRef &o) {
       onodes.insert(o);
     }
-
-    bool finish_fsync() {
-      Mutex::Locker l(lock);
-      ++num_fsyncs_completed;
-      if (num_fsyncs_completed == sync_items.size()) {
-	cond.Signal();
-	return true;
-      }
-      return false;
-    }
-    void wait_fsync() {
-      Mutex::Locker l(lock);
-      while (num_fsyncs_completed < sync_items.size())
-	cond.Wait(lock);
+    void write_enode(EnodeRef &e) {
+      enodes.insert(e);
     }
   };
 
@@ -280,9 +333,9 @@ public:
 
     OpSequencer()
 	//set the qlock to to PTHREAD_MUTEX_RECURSIVE mode
-      : qlock("NewStore::OpSequencer::qlock", true, false),
+      : qlock("BlueStore::OpSequencer::qlock", true, false),
 	parent(NULL),
-	wal_apply_lock("NewStore::OpSequencer::wal_apply_lock") {
+	wal_apply_lock("BlueStore::OpSequencer::wal_apply_lock") {
     }
     ~OpSequencer() {
       assert(q.empty());
@@ -314,56 +367,6 @@ public:
     }
   };
 
-  class FsyncWQ : public ThreadPool::WorkQueue<fsync_item> {
-  public:
-    typedef boost::intrusive::list<
-      fsync_item,
-      boost::intrusive::member_hook<
-        fsync_item,
-	boost::intrusive::list_member_hook<>,
-	&fsync_item::queue_item> > fsync_queue_t;
-  private:
-    NewStore *store;
-    fsync_queue_t fd_queue;
-
-  public:
-    FsyncWQ(NewStore *s, time_t ti, time_t sti, ThreadPool *tp)
-      : ThreadPool::WorkQueue<fsync_item>("NewStore::FsyncWQ", ti, sti, tp),
-	store(s) {
-    }
-    bool _empty() {
-      return fd_queue.empty();
-    }
-    bool _enqueue(fsync_item *i) {
-      fd_queue.push_back(*i);
-      return true;
-    }
-    void _dequeue(fsync_item *p) {
-      assert(0 == "not needed, not implemented");
-    }
-    fsync_item *_dequeue() {
-      if (fd_queue.empty())
-	return NULL;
-      fsync_item *i = &fd_queue.front();
-      fd_queue.pop_front();
-      return i;
-    }
-    void _process(fsync_item *i, ThreadPool::TPHandle &handle) {
-      store->_txc_process_fsync(i);
-    }
-    void _clear() {
-      fd_queue.clear();
-    }
-
-    void flush() {
-      lock();
-      while (!fd_queue.empty())
-	_wait();
-      unlock();
-      drain();
-    }
-  };
-
   class WALWQ : public ThreadPool::WorkQueue<TransContext> {
     // We need to order WAL items within each Sequencer.  To do that,
     // queue each txc under osr, and queue the osr's here.  When we
@@ -380,12 +383,12 @@ public:
 	&OpSequencer::wal_osr_queue_item> > wal_osr_queue_t;
 
   private:
-    NewStore *store;
+    BlueStore *store;
     wal_osr_queue_t wal_queue;
 
   public:
-    WALWQ(NewStore *s, time_t ti, time_t sti, ThreadPool *tp)
-      : ThreadPool::WorkQueue<TransContext>("NewStore::WALWQ", ti, sti, tp),
+    WALWQ(BlueStore *s, time_t ti, time_t sti, ThreadPool *tp)
+      : ThreadPool::WorkQueue<TransContext>("BlueStore::WALWQ", ti, sti, tp),
 	store(s) {
     }
     bool _empty() {
@@ -422,6 +425,7 @@ public:
       store->_wal_apply(i);
       i->osr->wal_apply_lock.Unlock();
     }
+    using ThreadPool::WorkQueue<TransContext>::_process;
     void _clear() {
       assert(wal_queue.empty());
     }
@@ -437,43 +441,33 @@ public:
   };
 
   struct KVSyncThread : public Thread {
-    NewStore *store;
-    KVSyncThread(NewStore *s) : store(s) {}
+    BlueStore *store;
+    KVSyncThread(BlueStore *s) : store(s) {}
     void *entry() {
       store->_kv_sync_thread();
       return NULL;
     }
   };
 
-  struct AioCompletionThread : public Thread {
-    NewStore *store;
-    AioCompletionThread(NewStore *s) : store(s) {}
-    void *entry() {
-      store->_aio_thread();
-      return NULL;
-    }
-  };
-
   // --------------------------------------------------------
   // members
 private:
   CephContext *cct;
+  BlueFS *bluefs;
+  unsigned bluefs_shared_bdev;  ///< which bluefs bdev we are sharing
   KeyValueDB *db;
   FS *fs;
+  BlockDevice *bdev;
+  FreelistManager *fm;
+  Allocator *alloc;
   uuid_d fsid;
   int path_fd;  ///< open handle to $path
   int fsid_fd;  ///< open handle (locked) to $path/fsid
-  int frag_fd;  ///< open handle to $path/fragments
-  int fset_fd;  ///< open handle to $path/fragments/$cur_fid.fset
   bool mounted;
 
   RWLock coll_lock;    ///< rwlock to protect coll_map
   ceph::unordered_map<coll_t, CollectionRef> coll_map;
 
-  Mutex fid_lock;
-  fid_t fid_last;  ///< last allocated fid
-  fid_t fid_max;   ///< max fid we can allocate before reserving more
-
   Mutex nid_lock;
   uint64_t nid_last;
   uint64_t nid_max;
@@ -481,18 +475,14 @@ private:
   Throttle throttle_ops, throttle_bytes;          ///< submit to commit
   Throttle throttle_wal_ops, throttle_wal_bytes;  ///< submit to wal complete
 
+  interval_set<uint64_t> bluefs_extents;  ///< block extents owned by bluefs
+
   Mutex wal_lock;
   atomic64_t wal_seq;
   ThreadPool wal_tp;
   WALWQ wal_wq;
 
   Finisher finisher;
-  ThreadPool fsync_tp;
-  FsyncWQ fsync_wq;
-
-  AioCompletionThread aio_thread;
-  bool aio_stop;
-  FS::aio_queue_t aio_queue;
 
   KVSyncThread kv_sync_thread;
   Mutex kv_lock;
@@ -521,47 +511,57 @@ private:
   int _read_fsid(uuid_d *f);
   int _write_fsid();
   void _close_fsid();
-  int _open_frag();
-  int _create_frag();
-  void _close_frag();
+  int _open_bdev(bool create);
+  void _close_bdev();
   int _open_db(bool create);
   void _close_db();
-  int _open_collections();
+  int _open_alloc();
+  void _close_alloc();
+  int _open_collections(int *errors=0);
   void _close_collections();
 
+  int _setup_block_symlink_or_file(string name, string path, uint64_t size);
+
+  int _write_bdev_label(string path, bluestore_bdev_label_t label);
+  static int _read_bdev_label(string path, bluestore_bdev_label_t *label);
+  int _check_or_set_bdev_label(string path, uint64_t size, string desc,
+			       bool create);
+
+  int _open_super_meta();
+
+  int _reconcile_bluefs_freespace();
+  int _balance_bluefs_freespace(vector<bluestore_extent_t> *extents,
+				KeyValueDB::Transaction t);
+  void _commit_bluefs_freespace(const vector<bluestore_extent_t>& extents);
+
   CollectionRef _get_collection(coll_t cid);
   void _queue_reap_collection(CollectionRef& c);
   void _reap_collections();
 
-  int _recover_next_fid();
-  int _create_fid(TransContext *txc, fid_t *fid, unsigned flags);
-  int _open_fid(fid_t fid, unsigned flags);
-  int _remove_fid(fid_t fid);
-
-  int _recover_next_nid();
   void _assign_nid(TransContext *txc, OnodeRef o);
 
-  int _clean_fid_tail_fd(const fragment_t& f, int fd);
-  int _clean_fid_tail(TransContext *txc, const fragment_t& f);
+  void _dump_onode(OnodeRef o);
 
   TransContext *_txc_create(OpSequencer *osr);
+  void _txc_release(TransContext *txc, CollectionRef& c,
+		    EnodeRef& enode, uint32_t hash,
+		    uint64_t offset, uint64_t length,
+		    bool shared);
   int _txc_add_transaction(TransContext *txc, Transaction *t);
   int _txc_finalize(OpSequencer *osr, TransContext *txc);
   void _txc_state_proc(TransContext *txc);
   void _txc_aio_submit(TransContext *txc);
-  void _txc_do_sync_fsync(TransContext *txc);
-  void _txc_queue_fsync(TransContext *txc);
-  void _txc_process_fsync(fsync_item *i);
+public:
+  void _txc_aio_finish(void *p) {
+    _txc_state_proc(static_cast<TransContext*>(p));
+  }
+private:
   void _txc_finish_io(TransContext *txc);
   void _txc_finish_kv(TransContext *txc);
   void _txc_finish(TransContext *txc);
 
   void _osr_reap_done(OpSequencer *osr);
 
-  void _aio_thread();
-  int _aio_start();
-  void _aio_stop();
-
   void _kv_sync_thread();
   void _kv_stop() {
     {
@@ -573,21 +573,24 @@ private:
     kv_stop = false;
   }
 
-  wal_op_t *_get_wal_op(TransContext *txc);
+  bluestore_wal_op_t *_get_wal_op(TransContext *txc, OnodeRef o);
   int _wal_apply(TransContext *txc);
   int _wal_finish(TransContext *txc);
-  int _do_wal_transaction(wal_transaction_t& wt, TransContext *txc);
+  int _do_wal_op(bluestore_wal_op_t& wo, IOContext *ioc);
   int _wal_replay();
 
+  // for fsck
+  int _verify_enode_shared(EnodeRef enode, vector<bluestore_extent_t>& v);
+
 public:
-  NewStore(CephContext *cct, const string& path);
-  ~NewStore();
+  BlueStore(CephContext *cct, const string& path);
+  ~BlueStore();
 
   bool needs_journal() { return false; };
   bool wants_journal() { return false; };
   bool allows_journal() { return false; };
 
-  int peek_journal_fsid(uuid_d *fsid);
+  static int get_block_device_fsid(const string& path, uuid_d *fsid);
 
   bool test_mount_in_use();
 
@@ -595,6 +598,8 @@ public:
   int umount();
   void _sync();
 
+  int fsck();
+
   unsigned get_max_object_name_length() {
     return 4096;
   }
@@ -607,16 +612,7 @@ public:
     return 0;
   }
 
-private:
-  bool sharded;
 public:
-  void set_allow_sharded_objects() {
-    sharded = true;
-  }
-  bool get_allow_sharded_objects() {
-    return sharded;
-  }
-
   int statfs(struct statfs *buf);
 
   bool exists(coll_t cid, const ghobject_t& oid);
@@ -726,8 +722,7 @@ private:
 	     uint64_t offset, size_t len,
 	     bufferlist& bl,
 	     uint32_t fadvise_flags);
-  int _do_overlay_clear(TransContext *txc,
-			OnodeRef o);
+  bool _can_overlay_write(OnodeRef o, uint64_t length);
   int _do_overlay_trim(TransContext *txc,
 		       OnodeRef o,
 		       uint64_t offset,
@@ -737,10 +732,27 @@ private:
 			uint64_t offset,
 			uint64_t length,
 			const bufferlist& bl);
-  int _do_write_all_overlays(TransContext *txc,
-			     OnodeRef o);
-  void _do_read_all_overlays(wal_transaction_t& wt);
+  int _do_write_overlays(TransContext *txc, CollectionRef& c, OnodeRef o,
+			 uint64_t offset, uint64_t length);
+  void _do_read_all_overlays(bluestore_wal_op_t& wo);
+  void _pad_zeros(OnodeRef o, bufferlist *bl, uint64_t *offset, uint64_t *length,
+		  uint64_t block_size);
+  void _pad_zeros_head(OnodeRef o, bufferlist *bl,
+		       uint64_t *offset, uint64_t *length,
+		       uint64_t block_size);
+  void _pad_zeros_tail(OnodeRef o, bufferlist *bl,
+		       uint64_t offset, uint64_t *length,
+		       uint64_t block_size);
+  int _do_allocate(TransContext *txc,
+		   CollectionRef& c,
+		   OnodeRef o,
+		   uint64_t offset, uint64_t length,
+		   uint32_t fadvise_flags,
+		   bool allow_overlay,
+		   uint64_t *rmw_cow_head,
+		   uint64_t *rmw_cow_tail);
   int _do_write(TransContext *txc,
+		CollectionRef &c,
 		OnodeRef o,
 		uint64_t offset, uint64_t length,
 		bufferlist& bl,
@@ -748,11 +760,16 @@ private:
   int _touch(TransContext *txc,
 	     CollectionRef& c,
 	     const ghobject_t& oid);
+  int _do_write_zero(TransContext *txc,
+		     CollectionRef &c,
+		     OnodeRef o,
+		     uint64_t offset, uint64_t length);
   int _zero(TransContext *txc,
 	    CollectionRef& c,
 	    const ghobject_t& oid,
 	    uint64_t offset, size_t len);
   int _do_truncate(TransContext *txc,
+		   CollectionRef& c,
 		   OnodeRef o,
 		   uint64_t offset);
   int _truncate(TransContext *txc,
@@ -763,6 +780,7 @@ private:
 	      CollectionRef& c,
 	      const ghobject_t& oid);
   int _do_remove(TransContext *txc,
+		 CollectionRef& c,
 		 OnodeRef o);
   int _setattr(TransContext *txc,
 	       CollectionRef& c,
@@ -828,21 +846,21 @@ private:
 
 };
 
-inline ostream& operator<<(ostream& out, const NewStore::OpSequencer& s) {
+inline ostream& operator<<(ostream& out, const BlueStore::OpSequencer& s) {
   return out << *s.parent;
 }
 
-static inline void intrusive_ptr_add_ref(NewStore::Onode *o) {
+static inline void intrusive_ptr_add_ref(BlueStore::Onode *o) {
   o->get();
 }
-static inline void intrusive_ptr_release(NewStore::Onode *o) {
+static inline void intrusive_ptr_release(BlueStore::Onode *o) {
   o->put();
 }
 
-static inline void intrusive_ptr_add_ref(NewStore::OpSequencer *o) {
+static inline void intrusive_ptr_add_ref(BlueStore::OpSequencer *o) {
   o->get();
 }
-static inline void intrusive_ptr_release(NewStore::OpSequencer *o) {
+static inline void intrusive_ptr_release(BlueStore::OpSequencer *o) {
   o->put();
 }
 
diff --git a/src/os/bluestore/FreelistManager.cc b/src/os/bluestore/FreelistManager.cc
new file mode 100644
index 0000000..a9385ad
--- /dev/null
+++ b/src/os/bluestore/FreelistManager.cc
@@ -0,0 +1,248 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "FreelistManager.h"
+#include "kv/KeyValueDB.h"
+#include "kv.h"
+
+#include "common/debug.h"
+
+#define dout_subsys ceph_subsys_bluestore
+#undef dout_prefix
+#define dout_prefix *_dout << "freelist "
+
+int FreelistManager::init(KeyValueDB *db, string p)
+{
+  dout(1) << __func__ << " prefix " << p << dendl;
+
+  // load state from kvstore
+  prefix = p;
+
+  KeyValueDB::Transaction txn = db->get_transaction();
+  int fixed = 0;
+
+  KeyValueDB::Iterator it = db->get_iterator(prefix);
+  it->lower_bound(string());
+  uint64_t last_offset = 0;
+  uint64_t last_length = 0;
+  while (it->valid()) {
+    uint64_t offset, length;
+    string k = it->key();
+    const char *p = _key_decode_u64(k.c_str(), &offset);
+    assert(p);
+    bufferlist bl = it->value();
+    bufferlist::iterator bp = bl.begin();
+    ::decode(length, bp);
+
+    total_free += length;
+
+    if (offset && offset == last_offset + last_length) {
+      derr << __func__ << " detected contiguous extent on load, merging "
+	   << last_offset << "~" << last_length << " with "
+	   << offset << "~" << length
+	   << dendl;
+      kv_free.erase(last_offset);
+      string key;
+      _key_encode_u64(last_offset, &key);
+      txn->rmkey(prefix, key);
+      offset -= last_length;
+      length += last_length;
+      bufferlist value;
+      ::encode(length, value);
+      txn->set(prefix, key, value);
+      fixed++;
+    }
+
+    kv_free[offset] = length;
+    dout(20) << __func__ << "  " << offset << "~" << length << dendl;
+
+    last_offset = offset;
+    last_length = length;
+    it->next();
+  }
+
+  if (fixed) {
+    db->submit_transaction_sync(txn);
+    derr << " fixed " << fixed << " extents" << dendl;
+  }
+
+  dout(10) << __func__ << " loaded " << kv_free.size() << " extents" << dendl;
+  return 0;
+}
+
+void FreelistManager::shutdown()
+{
+  dout(1) << __func__ << dendl;
+}
+
+void FreelistManager::dump()
+{
+  std::lock_guard<std::mutex> l(lock);
+  _dump();
+}
+
+void FreelistManager::_dump()
+{
+  dout(30) << __func__ << " " << total_free
+	   << " in " << kv_free.size() << " extents" << dendl;
+  for (auto p = kv_free.begin();
+       p != kv_free.end();
+       ++p) {
+    dout(30) << __func__ << "  " << p->first << "~" << p->second << dendl;
+  }
+}
+
+void FreelistManager::_audit()
+{
+  uint64_t sum = 0;
+  for (auto& p : kv_free) {
+    sum += p.second;
+  }
+  if (total_free != sum) {
+    derr << __func__ << " sum " << sum << " != total_free " << total_free
+	 << dendl;
+    derr << kv_free << dendl;
+    assert(0 == "freelistmanager bug");
+  }
+}
+
+int FreelistManager::allocate(
+  uint64_t offset, uint64_t length,
+  KeyValueDB::Transaction txn)
+{
+  std::lock_guard<std::mutex> l(lock);
+  dout(10) << __func__ << " " << offset << "~" << length << dendl;
+  total_free -= length;
+  auto p = kv_free.lower_bound(offset);
+  if ((p == kv_free.end() || p->first > offset) &&
+      p != kv_free.begin()) {
+    --p;
+  }
+  if (p == kv_free.end() ||
+      p->first > offset ||
+      p->first + p->second < offset + length) {
+    derr << " bad allocate " << offset << "~" << length << " - dne" << dendl;
+    if (p != kv_free.end()) {
+      derr << " existing extent " << p->first << "~" << p->second << dendl;
+    }
+    _dump();
+    assert(0 == "bad allocate");
+  }
+
+  if (p->first == offset) {
+    string key;
+    _key_encode_u64(offset, &key);
+    txn->rmkey(prefix, key);
+    dout(20) << __func__ << "  rm " << p->first << "~" << p->second << dendl;
+    if (p->second > length) {
+      uint64_t newoff = offset + length;
+      uint64_t newlen = p->second - length;
+      string newkey;
+      _key_encode_u64(newoff, &newkey);
+      bufferlist newvalue;
+      ::encode(newlen, newvalue);
+      txn->set(prefix, newkey, newvalue);
+      dout(20) << __func__ << "  set " << newoff << "~" << newlen
+	       << " (remaining tail)" << dendl;
+      kv_free[newoff] = newlen;
+    }
+    kv_free.erase(p);
+  } else {
+    assert(p->first < offset);
+    // shorten
+    uint64_t newlen = offset - p->first;
+    string key;
+    _key_encode_u64(p->first, &key);
+    bufferlist newvalue;
+    ::encode(newlen, newvalue);
+    txn->set(prefix, key, newvalue);
+    dout(30) << __func__ << "  set " << p->first << "~" << newlen
+	     << " (remaining head from " << p->second << ")" << dendl;
+    if (p->first + p->second > offset + length) {
+      // new trailing piece, too
+      uint64_t tailoff = offset + length;
+      uint64_t taillen = p->first + p->second - (offset + length);
+      string tailkey;
+      _key_encode_u64(tailoff, &tailkey);
+      bufferlist tailvalue;
+      ::encode(taillen, tailvalue);
+      txn->set(prefix, tailkey, tailvalue);
+      dout(20) << __func__ << "  set " << tailoff << "~" << taillen
+	       << " (remaining tail from " << p->first << "~" << p->second << ")"
+	       << dendl;
+      kv_free[tailoff] = taillen;
+    }
+    p->second = newlen;
+  }
+  if (g_conf->bluestore_debug_freelist)
+    _audit();
+  return 0;
+}
+
+int FreelistManager::release(
+  uint64_t offset, uint64_t length,
+  KeyValueDB::Transaction txn)
+{
+  std::lock_guard<std::mutex> l(lock);
+  dout(10) << __func__ << " " << offset << "~" << length << dendl;
+  total_free += length;
+  auto p = kv_free.lower_bound(offset);
+
+  // contiguous with previous extent?
+  if (p != kv_free.begin()) {
+    --p;
+    if (p->first + p->second == offset) {
+      string prevkey;
+      _key_encode_u64(p->first, &prevkey);
+      txn->rmkey(prefix, prevkey);
+      dout(20) << __func__ << "  rm " << p->first << "~" << p->second
+	       << " (merge with previous)" << dendl;
+      length += p->second;
+      offset = p->first;
+      kv_free.erase(p++);
+    } else if (p->first + p->second > offset) {
+      derr << __func__ << " bad release " << offset << "~" << length
+	   << " overlaps with " << p->first << "~" << p->second << dendl;
+      _dump();
+      assert(0 == "bad release overlap");
+    } else {
+      dout(30) << __func__ << " previous extent " << p->first << "~" << p->second
+	       << " is not contiguous" << dendl;
+      ++p;
+    }
+  }
+
+  // contiguous with next extent?
+  if (p != kv_free.end()) {
+    if (p->first == offset + length) {
+      string tailkey;
+      _key_encode_u64(p->first, &tailkey);
+      txn->rmkey(prefix, tailkey);
+      dout(20) << __func__ << "  rm " << p->first << "~" << p->second
+	       << " (merge with next)" << dendl;
+      length += p->second;
+      kv_free.erase(p);
+    } else if (p->first < offset + length) {
+      derr << __func__ << " bad release " << offset << "~" << length
+	   << " overlaps with " << p->first << "~" << p->second << dendl;
+      _dump();
+      assert(0 == "bad release overlap");
+    } else {
+      dout(30) << __func__ << " next extent " << p->first << "~" << p->second
+	       << " is not contiguous" << dendl;
+    }
+  }
+
+  string key;
+  _key_encode_u64(offset, &key);
+  bufferlist value;
+  ::encode(length, value);
+  txn->set(prefix, key, value);
+  dout(20) << __func__ << "  set " << offset << "~" << length << dendl;
+
+  kv_free[offset] = length;
+
+  if (g_conf->bluestore_debug_freelist)
+    _audit();
+  return 0;
+}
diff --git a/src/os/bluestore/FreelistManager.h b/src/os/bluestore/FreelistManager.h
new file mode 100644
index 0000000..b0115e5
--- /dev/null
+++ b/src/os/bluestore/FreelistManager.h
@@ -0,0 +1,51 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_OS_BLUESTORE_FREELISTMANAGER_H
+#define CEPH_OS_BLUESTORE_FREELISTMANAGER_H
+
+#include <string>
+#include <map>
+#include <mutex>
+#include <ostream>
+#include "kv/KeyValueDB.h"
+
+class FreelistManager {
+  std::string prefix;
+  std::mutex lock;
+  uint64_t total_free;
+
+  std::map<uint64_t, uint64_t> kv_free;    ///< mirrors our kv values in the db
+
+  void _audit();
+  void _dump();
+
+public:
+  FreelistManager() :
+    total_free(0) {
+  }
+
+  int init(KeyValueDB *kvdb, std::string prefix);
+  void shutdown();
+
+  void dump();
+
+  uint64_t get_total_free() {
+    std::lock_guard<std::mutex> l(lock);
+    return total_free;
+  }
+
+  const std::map<uint64_t,uint64_t>& get_freelist() {
+    return kv_free;
+  }
+
+  int allocate(
+    uint64_t offset, uint64_t length,
+    KeyValueDB::Transaction txn);
+  int release(
+    uint64_t offset, uint64_t length,
+    KeyValueDB::Transaction txn);
+};
+
+
+#endif
diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc
new file mode 100644
index 0000000..d96e945
--- /dev/null
+++ b/src/os/bluestore/StupidAllocator.cc
@@ -0,0 +1,306 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "StupidAllocator.h"
+#include "bluestore_types.h"
+#include "BlueStore.h"
+
+#define dout_subsys ceph_subsys_bluestore
+#undef dout_prefix
+#define dout_prefix *_dout << "stupidalloc "
+
+StupidAllocator::StupidAllocator()
+  : lock("StupicAllocator::lock"),
+    num_free(0),
+    num_uncommitted(0),
+    num_committing(0),
+    num_reserved(0),
+    free(10),
+    last_alloc(0)
+{
+}
+
+StupidAllocator::~StupidAllocator()
+{
+}
+
+unsigned StupidAllocator::_choose_bin(uint64_t orig_len)
+{
+  uint64_t len = orig_len / g_conf->bluestore_min_alloc_size;
+  int bin = 0;
+  while (len && bin + 1 < (int)free.size()) {
+    len >>= 1;
+    bin++;
+  }
+  dout(30) << __func__ << " len " << orig_len << " -> " << bin << dendl;
+  return bin;
+}
+
+void StupidAllocator::_insert_free(uint64_t off, uint64_t len)
+{
+  unsigned bin = _choose_bin(len);
+  dout(30) << __func__ << " " << off << "~" << len << " in bin " << bin << dendl;
+  while (true) {
+    free[bin].insert(off, len, &off, &len);
+    unsigned newbin = _choose_bin(len);
+    if (newbin == bin)
+      break;
+    dout(30) << __func__ << " promoting " << off << "~" << len
+	     << " to bin " << newbin << dendl;
+    free[bin].erase(off, len);
+    bin = newbin;
+  }
+}
+
+int StupidAllocator::reserve(uint64_t need)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " need " << need << " num_free " << num_free
+	   << " num_reserved " << num_reserved << dendl;
+  if ((int64_t)need > num_free - num_reserved)
+    return -ENOSPC;
+  num_reserved += need;
+  return 0;
+}
+
+void StupidAllocator::unreserve(uint64_t unused)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " unused " << unused << " num_free " << num_free
+	   << " num_reserved " << num_reserved << dendl;
+  assert((int64_t)unused >= num_reserved);
+  num_reserved -= unused;
+}
+
+/// return the effective length of the extent if we align to alloc_unit
+static uint64_t aligned_len(interval_set<uint64_t>::iterator p,
+			    uint64_t alloc_unit)
+{
+  uint64_t skew = p.get_start() % alloc_unit;
+  if (skew)
+    skew = alloc_unit - skew;
+  if (skew > p.get_len())
+    return 0;
+  else
+    return p.get_len() - skew;
+}
+
+int StupidAllocator::allocate(
+  uint64_t need_size, uint64_t alloc_unit, int64_t hint,
+  uint64_t *offset, uint32_t *length)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " need_size " << need_size
+	   << " alloc_unit " << alloc_unit
+	   << " hint " << hint
+	   << dendl;
+  uint64_t want = MAX(alloc_unit, need_size);
+  int bin = _choose_bin(want);
+  int orig_bin = bin;
+
+  interval_set<uint64_t>::iterator p = free[0].begin();
+
+  if (!hint)
+    hint = last_alloc;
+
+  // search up (from hint)
+  if (hint) {
+    for (bin = orig_bin; bin < (int)free.size(); ++bin) {
+      p = free[bin].lower_bound(hint);
+      while (p != free[bin].end()) {
+	if (aligned_len(p, alloc_unit) >= need_size) {
+	  goto found;
+	}
+	++p;
+      }
+    }
+  }
+
+  // search up (from origin)
+  for (bin = orig_bin; bin < (int)free.size(); ++bin) {
+    p = free[bin].begin();
+    while (p != free[bin].end()) {
+      if (aligned_len(p, alloc_unit) >= need_size) {
+	goto found;
+      }
+      ++p;
+    }
+  }
+
+  // search down (hint)
+  if (hint) {
+    for (bin = orig_bin; bin >= 0; --bin) {
+      p = free[bin].lower_bound(hint);
+      while (p != free[bin].end()) {
+	if (aligned_len(p, alloc_unit) >= alloc_unit) {
+	  goto found;
+	}
+	++p;
+      }
+    }
+  }
+
+  // search down (origin)
+  for (bin = orig_bin; bin >= 0; --bin) {
+    p = free[bin].begin();
+    while (p != free[bin].end()) {
+      if (aligned_len(p, alloc_unit) >= alloc_unit) {
+	goto found;
+      }
+      ++p;
+    }
+  }
+
+  assert(0 == "caller didn't reserve?");
+  return -ENOSPC;
+
+ found:
+  uint64_t skew = p.get_start() % alloc_unit;
+  if (skew)
+    skew = alloc_unit - skew;
+  *offset = p.get_start() + skew;
+  *length = MIN(MAX(alloc_unit, need_size), p.get_len() - skew);
+  if (g_conf->bluestore_debug_small_allocations) {
+    uint64_t max =
+      alloc_unit * (rand() % g_conf->bluestore_debug_small_allocations);
+    if (max && *length > max) {
+      dout(10) << __func__ << " shortening allocation of " << *length << " -> "
+	       << max << " due to debug_small_allocations" << dendl;
+      *length = max;
+    }
+  }
+  dout(30) << __func__ << " got " << *offset << "~" << *length << " from bin "
+	   << bin << dendl;
+
+  free[bin].erase(*offset, *length);
+  uint64_t off, len;
+  if (*offset && free[bin].contains(*offset - skew - 1, &off, &len)) {
+    int newbin = _choose_bin(len);
+    if (newbin != bin) {
+      dout(30) << __func__ << " demoting " << off << "~" << len
+	       << " to bin " << newbin << dendl;
+      free[bin].erase(off, len);
+      _insert_free(off, len);
+    }
+  }
+  if (free[bin].contains(*offset + *length, &off, &len)) {
+    int newbin = _choose_bin(len);
+    if (newbin != bin) {
+      dout(30) << __func__ << " demoting " << off << "~" << len
+	       << " to bin " << newbin << dendl;
+      free[bin].erase(off, len);
+      _insert_free(off, len);
+    }
+  }
+
+  num_free -= *length;
+  num_reserved -= *length;
+  assert(num_free >= 0);
+  assert(num_reserved >= 0);
+  last_alloc = *offset + *length;
+  return 0;
+}
+
+int StupidAllocator::release(
+  uint64_t offset, uint64_t length)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << offset << "~" << length << dendl;
+  uncommitted.insert(offset, length);
+  num_uncommitted += length;
+  return 0;
+}
+
+uint64_t StupidAllocator::get_free()
+{
+  Mutex::Locker l(lock);
+  return num_free;
+}
+
+void StupidAllocator::dump(ostream& out)
+{
+  Mutex::Locker l(lock);
+  for (unsigned bin = 0; bin < free.size(); ++bin) {
+    dout(30) << __func__ << " free bin " << bin << ": "
+	     << free[bin].num_intervals() << " extents" << dendl;
+    for (interval_set<uint64_t>::iterator p = free[bin].begin();
+	 p != free[bin].end();
+	 ++p) {
+      dout(30) << __func__ << "  " << p.get_start() << "~" << p.get_len() << dendl;
+    }
+  }
+  dout(30) << __func__ << " committing: "
+	   << committing.num_intervals() << " extents" << dendl;
+  for (interval_set<uint64_t>::iterator p = committing.begin();
+       p != committing.end();
+       ++p) {
+    dout(30) << __func__ << "  " << p.get_start() << "~" << p.get_len() << dendl;
+  }
+  dout(30) << __func__ << " uncommitted: "
+	   << uncommitted.num_intervals() << " extents" << dendl;
+  for (interval_set<uint64_t>::iterator p = uncommitted.begin();
+       p != uncommitted.end();
+       ++p) {
+    dout(30) << __func__ << "  " << p.get_start() << "~" << p.get_len() << dendl;
+  }
+}
+
+void StupidAllocator::init_add_free(uint64_t offset, uint64_t length)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << offset << "~" << length << dendl;
+  _insert_free(offset, length);
+  num_free += length;
+}
+
+void StupidAllocator::init_rm_free(uint64_t offset, uint64_t length)
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " " << offset << "~" << length << dendl;
+  interval_set<uint64_t> rm;
+  rm.insert(offset, length);
+  for (unsigned i = 0; i < free.size() && !rm.empty(); ++i) {
+    interval_set<uint64_t> overlap;
+    overlap.intersection_of(rm, free[i]);
+    if (!overlap.empty()) {
+      dout(20) << __func__ << " bin " << i << " rm " << overlap << dendl;
+      free[i].subtract(overlap);
+      rm.subtract(overlap);
+    }
+  }
+  assert(rm.empty());
+  num_free -= length;
+  assert(num_free >= 0);
+}
+
+
+void StupidAllocator::shutdown()
+{
+  dout(1) << __func__ << dendl;
+}
+
+void StupidAllocator::commit_start()
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " releasing " << num_uncommitted
+	   << " in extents " << uncommitted.num_intervals() << dendl;
+  assert(committing.empty());
+  committing.swap(uncommitted);
+  num_committing = num_uncommitted;
+  num_uncommitted = 0;
+}
+
+void StupidAllocator::commit_finish()
+{
+  Mutex::Locker l(lock);
+  dout(10) << __func__ << " released " << num_committing
+	   << " in extents " << committing.num_intervals() << dendl;
+  for (interval_set<uint64_t>::iterator p = committing.begin();
+       p != committing.end();
+       ++p) {
+    _insert_free(p.get_start(), p.get_len());
+  }
+  committing.clear();
+  num_free += num_committing;
+  num_committing = 0;
+}
diff --git a/src/os/bluestore/StupidAllocator.h b/src/os/bluestore/StupidAllocator.h
new file mode 100644
index 0000000..ec71b86
--- /dev/null
+++ b/src/os/bluestore/StupidAllocator.h
@@ -0,0 +1,55 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_OS_BLUESTORE_STUPIDALLOCATOR_H
+#define CEPH_OS_BLUESTORE_STUPIDALLOCATOR_H
+
+#include "Allocator.h"
+#include "include/interval_set.h"
+#include "common/Mutex.h"
+
+class StupidAllocator : public Allocator {
+  Mutex lock;
+
+  int64_t num_free;     ///< total bytes in freelist
+  int64_t num_uncommitted;
+  int64_t num_committing;
+  int64_t num_reserved; ///< reserved bytes
+
+  vector<interval_set<uint64_t> > free;        ///< leading-edge copy
+  interval_set<uint64_t> uncommitted; ///< released but not yet usable
+  interval_set<uint64_t> committing;  ///< released but not yet usable
+
+  uint64_t last_alloc;
+
+  unsigned _choose_bin(uint64_t len);
+  void _insert_free(uint64_t offset, uint64_t len);
+
+public:
+  StupidAllocator();
+  ~StupidAllocator();
+
+  int reserve(uint64_t need);
+  void unreserve(uint64_t unused);
+
+  int allocate(
+    uint64_t need_size, uint64_t alloc_unit, int64_t hint,
+    uint64_t *offset, uint32_t *length);
+
+  int release(
+    uint64_t offset, uint64_t length);
+
+  void commit_start();
+  void commit_finish();
+
+  uint64_t get_free();
+
+  void dump(ostream& out);
+
+  void init_add_free(uint64_t offset, uint64_t length);
+  void init_rm_free(uint64_t offset, uint64_t length);
+
+  void shutdown();
+};
+
+#endif
diff --git a/src/os/bluestore/bluefs_tool.cc b/src/os/bluestore/bluefs_tool.cc
new file mode 100644
index 0000000..02bcb2f
--- /dev/null
+++ b/src/os/bluestore/bluefs_tool.cc
@@ -0,0 +1,85 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+#include <time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+#include "include/stringify.h"
+#include "common/errno.h"
+
+#include "os/bluestore/BlueFS.h"
+
+int main(int argc, char **argv)
+{
+  vector<const char*> args;
+  argv_to_vec(argc, (const char **)argv, args);
+  env_to_vec(args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+  g_ceph_context->_conf->set_val(
+    "enable_experimental_unrecoverable_data_corrupting_features",
+    "*");
+  g_ceph_context->_conf->apply_changes(NULL);
+
+  BlueFS fs;
+
+  cout << "args " << args << std::endl;
+  string outdir = args[0];
+  for (unsigned i = 1; i < args.size(); ++i) {
+    fs.add_block_device(i-1, args[i]);
+  }
+
+  int r = fs.mount();
+  assert(r == 0);
+
+  vector<string> dirs;
+  r = fs.readdir("", &dirs);
+  assert(r == 0);
+  for (auto& dir : dirs) {
+    if (dir[0] == '.')
+      continue;
+    cout << dir << "/" << std::endl;
+    vector<string> ls;
+    r = fs.readdir(dir, &ls);
+    assert(r == 0);
+    string cmd = "mkdir -p " + outdir + "/" + dir;
+    r = system(cmd.c_str());
+    assert(r == 0);
+    for (auto& file : ls) {
+      if (file[0] == '.')
+	continue;
+      cout << dir << "/" << file << std::endl;
+      uint64_t size;
+      utime_t mtime;
+      r = fs.stat(dir, file, &size, &mtime);
+      assert(r == 0);
+      string path = outdir + "/" + dir + "/" + file;
+      int fd = ::open(path.c_str(), O_CREAT|O_WRONLY|O_TRUNC, 0644);
+      assert(fd >= 0);
+      if (size > 0) {
+	BlueFS::FileReader *h;
+	r = fs.open_for_read(dir, file, &h, false);
+	assert(r == 0);
+	int pos = 0;
+	int left = size;
+	while (left) {
+	  bufferlist bl;
+	  r = fs.read(h, &h->buf, pos, left, &bl, NULL);
+	  assert(r > 0);
+	  int rc = bl.write_fd(fd);
+	  assert(rc == r);
+	  pos += r;
+	  left -= r;
+	}
+	delete h;
+      }
+      ::close(fd);
+    }
+  }
+}
diff --git a/src/os/bluestore/bluefs_types.cc b/src/os/bluestore/bluefs_types.cc
new file mode 100644
index 0000000..8b8a326
--- /dev/null
+++ b/src/os/bluestore/bluefs_types.cc
@@ -0,0 +1,234 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "bluefs_types.h"
+#include "common/Formatter.h"
+#include "include/uuid.h"
+#include "include/stringify.h"
+
+// bluefs_extent_t
+
+void bluefs_extent_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(offset, bl);
+  ::encode(length, bl);
+  ::encode(bdev, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluefs_extent_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(offset, p);
+  ::decode(length, p);
+  ::decode(bdev, p);
+  DECODE_FINISH(p);
+}
+
+void bluefs_extent_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("offset", offset);
+  f->dump_unsigned("length", length);
+  f->dump_unsigned("bdev", bdev);
+}
+
+void bluefs_extent_t::generate_test_instances(list<bluefs_extent_t*>& ls)
+{
+  ls.push_back(new bluefs_extent_t);
+  ls.push_back(new bluefs_extent_t);
+  ls.back()->offset = 1;
+  ls.back()->length = 2;
+  ls.back()->bdev = 3;
+}
+
+ostream& operator<<(ostream& out, bluefs_extent_t e)
+{
+  return out << e.bdev << ":" << e.offset << "+" << e.length;
+}
+
+// bluefs_super_t
+
+void bluefs_super_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(uuid, bl);
+  ::encode(osd_uuid, bl);
+  ::encode(version, bl);
+  ::encode(block_size, bl);
+  ::encode(log_fnode, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluefs_super_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(uuid, p);
+  ::decode(osd_uuid, p);
+  ::decode(version, p);
+  ::decode(block_size, p);
+  ::decode(log_fnode, p);
+  DECODE_FINISH(p);
+}
+
+void bluefs_super_t::dump(Formatter *f) const
+{
+  f->dump_stream("uuid") << uuid;
+  f->dump_stream("osd_uuid") << osd_uuid;
+  f->dump_unsigned("version", version);
+  f->dump_unsigned("block_size", block_size);
+  f->dump_object("log_fnode", log_fnode);
+}
+
+void bluefs_super_t::generate_test_instances(list<bluefs_super_t*>& ls)
+{
+  ls.push_back(new bluefs_super_t);
+  ls.push_back(new bluefs_super_t);
+  ls.back()->version = 1;
+  ls.back()->block_size = 4096;
+}
+
+ostream& operator<<(ostream& out, const bluefs_super_t& s)
+{
+  return out << "super(" << s.uuid
+	     << " osd " << s.osd_uuid
+	     << " v " << s.version
+	     << " block_size " << s.block_size
+	     << " log_fnode " << s.log_fnode
+	     << ")";
+}
+
+// bluefs_fnode_t
+
+vector<bluefs_extent_t>::iterator bluefs_fnode_t::seek(
+  uint64_t offset, uint64_t *x_off)
+{
+  vector<bluefs_extent_t>::iterator p = extents.begin();
+  while (p != extents.end()) {
+    if (offset >= p->length) {
+      offset -= p->length;
+      ++p;
+    } else {
+      break;
+    }
+  }
+  *x_off = offset;
+  return p;
+}
+
+void bluefs_fnode_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(ino, bl);
+  ::encode(size, bl);
+  ::encode(mtime, bl);
+  ::encode(prefer_bdev, bl);
+  ::encode(extents, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluefs_fnode_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(ino, p);
+  ::decode(size, p);
+  ::decode(mtime, p);
+  ::decode(prefer_bdev, p);
+  ::decode(extents, p);
+  DECODE_FINISH(p);
+}
+
+void bluefs_fnode_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("ino", ino);
+  f->dump_unsigned("size", size);
+  f->dump_stream("mtime") << mtime;
+  f->dump_unsigned("prefer_bdev", prefer_bdev);
+  f->open_array_section("extents");
+  for (auto& p : extents)
+    f->dump_object("extent", p);
+  f->close_section();
+}
+
+void bluefs_fnode_t::generate_test_instances(list<bluefs_fnode_t*>& ls)
+{
+  ls.push_back(new bluefs_fnode_t);
+  ls.push_back(new bluefs_fnode_t);
+  ls.back()->ino = 123;
+  ls.back()->size = 1048576;
+  ls.back()->mtime = utime_t(123,45);
+  ls.back()->extents.push_back(bluefs_extent_t(0, 1048576, 4096));
+  ls.back()->prefer_bdev = 1;
+}
+
+ostream& operator<<(ostream& out, const bluefs_fnode_t& file)
+{
+  return out << "file(" << file.ino
+	     << " size " << file.size
+	     << " mtime " << file.mtime
+	     << " bdev " << (int)file.prefer_bdev
+	     << " extents " << file.extents
+	     << ")";
+}
+
+
+// bluefs_transaction_t
+
+void bluefs_transaction_t::encode(bufferlist& bl) const
+{
+  uint32_t crc = op_bl.crc32c(-1);
+  ENCODE_START(1, 1, bl);
+  ::encode(uuid, bl);
+  ::encode(seq, bl);
+  ::encode(op_bl, bl);
+  ::encode(crc, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluefs_transaction_t::decode(bufferlist::iterator& p)
+{
+  uint32_t crc;
+  DECODE_START(1, p);
+  ::decode(uuid, p);
+  ::decode(seq, p);
+  ::decode(op_bl, p);
+  ::decode(crc, p);
+  DECODE_FINISH(p);
+  uint32_t actual = op_bl.crc32c(-1);
+  if (actual != crc)
+    throw buffer::malformed_input("bad crc " + stringify(actual)
+				  + " expected " + stringify(crc));
+}
+
+void bluefs_transaction_t::dump(Formatter *f) const
+{
+  f->dump_stream("uuid") << uuid;
+  f->dump_unsigned("seq", seq);
+  f->dump_unsigned("op_bl_length", op_bl.length());
+  f->dump_unsigned("crc", op_bl.crc32c(-1));
+}
+
+void bluefs_transaction_t::generate_test_instance(
+  list<bluefs_transaction_t*>& ls)
+{
+  ls.push_back(new bluefs_transaction_t);
+  ls.push_back(new bluefs_transaction_t);
+  ls.back()->op_init();
+  ls.back()->op_alloc_add(0, 0, 123123211);
+  ls.back()->op_alloc_rm(1, 0, 123);
+  ls.back()->op_dir_create("dir");
+  ls.back()->op_dir_create("dir2");
+  ls.back()->op_dir_link("dir", "file1", 1);
+  ls.back()->op_dir_unlink("dir", "oldfile");
+  ls.back()->op_file_update(bluefs_fnode_t());
+  ls.back()->op_dir_remove("dir3");
+  ls.back()->op_file_remove(2);
+}
+
+ostream& operator<<(ostream& out, const bluefs_transaction_t& t)
+{
+  return out << "txn(" << t.seq
+	     << " len " << t.op_bl.length()
+	     << " crc " << t.op_bl.crc32c(-1)
+	     << ")";
+}
diff --git a/src/os/bluestore/bluefs_types.h b/src/os/bluestore/bluefs_types.h
new file mode 100644
index 0000000..eef6b3e
--- /dev/null
+++ b/src/os/bluestore/bluefs_types.h
@@ -0,0 +1,170 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#ifndef CEPH_OS_BLUESTORE_BLUEFS_TYPES_H
+#define CEPH_OS_BLUESTORE_BLUEFS_TYPES_H
+
+#include "bluestore_types.h"
+#include "include/utime.h"
+#include "include/encoding.h"
+
+struct bluefs_extent_t {
+  uint64_t offset;
+  uint32_t length;
+  uint16_t bdev;
+
+  bluefs_extent_t(uint16_t b = 0, uint64_t o = 0, uint32_t l = 0)
+    : offset(o), length(l), bdev(b) {}
+
+  uint64_t end() const {
+    return offset + length;
+  }
+
+  void encode(bufferlist&) const;
+  void decode(bufferlist::iterator&);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluefs_extent_t*>&);
+};
+WRITE_CLASS_ENCODER(bluefs_extent_t)
+
+ostream& operator<<(ostream& out, bluefs_extent_t e);
+
+
+struct bluefs_fnode_t {
+  uint64_t ino;
+  uint64_t size;
+  utime_t mtime;
+  uint8_t prefer_bdev;
+  vector<bluefs_extent_t> extents;
+
+  bluefs_fnode_t() : ino(0), size(0), prefer_bdev(0) {}
+
+  uint64_t get_allocated() const {
+    uint64_t r = 0;
+    for (auto& p : extents)
+      r += p.length;
+    return r;
+  }
+
+  vector<bluefs_extent_t>::iterator seek(uint64_t off, uint64_t *x_off);
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluefs_fnode_t*>& ls);
+};
+WRITE_CLASS_ENCODER(bluefs_fnode_t)
+
+ostream& operator<<(ostream& out, const bluefs_fnode_t& file);
+
+
+struct bluefs_super_t {
+  uuid_d uuid;      ///< unique to this bluefs instance
+  uuid_d osd_uuid;  ///< matches the osd that owns us
+  uint64_t version;
+  uint32_t block_size;
+
+  bluefs_fnode_t log_fnode;
+
+  bluefs_super_t()
+    : version(0),
+      block_size(4096) { }
+
+  uint64_t block_mask() const {
+    return ~(block_size - 1);
+  }
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluefs_super_t*>& ls);
+};
+WRITE_CLASS_ENCODER(bluefs_super_t)
+
+ostream& operator<<(ostream&, const bluefs_super_t& s);
+
+
+struct bluefs_transaction_t {
+  typedef enum {
+    OP_NONE = 0,
+    OP_INIT,        ///< initial (empty) file system marker
+    OP_ALLOC_ADD,   ///< add extent to available block storage (extent)
+    OP_ALLOC_RM,    ///< remove extent from availabe block storage (extent)
+    OP_DIR_LINK,    ///< (re)set a dir entry (dirname, filename, ino)
+    OP_DIR_UNLINK,  ///< remove a dir entry (dirname, filename)
+    OP_DIR_CREATE,  ///< create a dir (dirname)
+    OP_DIR_REMOVE,  ///< remove a dir (dirname)
+    OP_FILE_UPDATE, ///< set/update file metadata (file)
+    OP_FILE_REMOVE, ///< remove file (ino)
+    OP_JUMP_SEQ,    ///< jump the seq #
+  } op_t;
+
+  uuid_d uuid;          ///< fs uuid
+  uint64_t seq;         ///< sequence number
+  bufferlist op_bl;     ///< encoded transaction ops
+
+  bluefs_transaction_t() : seq(0) {}
+
+  void clear() {
+    *this = bluefs_transaction_t();
+  }
+  bool empty() const {
+    return op_bl.length() == 0;
+  }
+
+  void op_init() {
+    ::encode((__u8)OP_INIT, op_bl);
+  }
+  void op_alloc_add(uint8_t id, uint64_t offset, uint64_t length) {
+    ::encode((__u8)OP_ALLOC_ADD, op_bl);
+    ::encode(id, op_bl);
+    ::encode(offset, op_bl);
+    ::encode(length, op_bl);
+  }
+  void op_alloc_rm(uint8_t id, uint64_t offset, uint64_t length) {
+    ::encode((__u8)OP_ALLOC_RM, op_bl);
+    ::encode(id, op_bl);
+    ::encode(offset, op_bl);
+    ::encode(length, op_bl);
+  }
+  void op_dir_create(const string& dir) {
+    ::encode((__u8)OP_DIR_CREATE, op_bl);
+    ::encode(dir, op_bl);
+  }
+  void op_dir_remove(const string& dir) {
+    ::encode((__u8)OP_DIR_REMOVE, op_bl);
+    ::encode(dir, op_bl);
+  }
+  void op_dir_link(const string& dir, const string& file, uint64_t ino) {
+    ::encode((__u8)OP_DIR_LINK, op_bl);
+    ::encode(dir, op_bl);
+    ::encode(file, op_bl);
+    ::encode(ino, op_bl);
+  }
+  void op_dir_unlink(const string& dir, const string& file) {
+    ::encode((__u8)OP_DIR_UNLINK, op_bl);
+    ::encode(dir, op_bl);
+    ::encode(file, op_bl);
+  }
+  void op_file_update(const bluefs_fnode_t& file) {
+    ::encode((__u8)OP_FILE_UPDATE, op_bl);
+    ::encode(file, op_bl);
+  }
+  void op_file_remove(uint64_t ino) {
+    ::encode((__u8)OP_FILE_REMOVE, op_bl);
+    ::encode(ino, op_bl);
+  }
+  void op_jump_seq(uint64_t next_seq) {
+    ::encode((__u8)OP_JUMP_SEQ, op_bl);
+    ::encode(next_seq, op_bl);
+  }
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instance(list<bluefs_transaction_t*>& ls);
+};
+WRITE_CLASS_ENCODER(bluefs_transaction_t)
+
+ostream& operator<<(ostream& out, const bluefs_transaction_t& t);
+
+#endif
diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc
new file mode 100644
index 0000000..2476957
--- /dev/null
+++ b/src/os/bluestore/bluestore_types.cc
@@ -0,0 +1,601 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "bluestore_types.h"
+#include "common/Formatter.h"
+#include "include/stringify.h"
+
+// bluestore_bdev_label_t
+
+void bluestore_bdev_label_t::encode(bufferlist& bl) const
+{
+  // be slightly friendly to someone who looks at the device
+  bl.append("bluestore block device\n");
+  bl.append(stringify(osd_uuid));
+  bl.append("\n");
+  ENCODE_START(1, 1, bl);
+  ::encode(osd_uuid, bl);
+  ::encode(size, bl);
+  ::encode(btime, bl);
+  ::encode(description, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_bdev_label_t::decode(bufferlist::iterator& p)
+{
+  p.advance(60); // see above
+  DECODE_START(1, p);
+  ::decode(osd_uuid, p);
+  ::decode(size, p);
+  ::decode(btime, p);
+  ::decode(description, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_bdev_label_t::dump(Formatter *f) const
+{
+  f->dump_stream("osd_uuid") << osd_uuid;
+  f->dump_unsigned("size", size);
+  f->dump_stream("btime") << btime;
+  f->dump_string("description", description);
+}
+
+void bluestore_bdev_label_t::generate_test_instances(
+  list<bluestore_bdev_label_t*>& o)
+{
+  o.push_back(new bluestore_bdev_label_t);
+  o.push_back(new bluestore_bdev_label_t);
+  o.back()->size = 123;
+  o.back()->btime = utime_t(4, 5);
+  o.back()->description = "fakey";
+}
+
+ostream& operator<<(ostream& out, const bluestore_bdev_label_t& l)
+{
+  return out << "bdev(osd_uuid " << l.osd_uuid
+	     << " size " << l.size
+	     << " btime " << l.btime
+	     << " desc " << l.description << ")";
+}
+
+// cnode_t
+
+void bluestore_cnode_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(bits, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_cnode_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(bits, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_cnode_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("bits", bits);
+}
+
+void bluestore_cnode_t::generate_test_instances(list<bluestore_cnode_t*>& o)
+{
+  o.push_back(new bluestore_cnode_t());
+  o.push_back(new bluestore_cnode_t(0));
+  o.push_back(new bluestore_cnode_t(123));
+}
+
+// bluestore_extent_t
+
+string bluestore_extent_t::get_flags_string(unsigned flags)
+{
+  string s;
+  if (flags & FLAG_UNWRITTEN) {
+    if (s.length())
+      s += '+';
+    s += "unwritten";
+  }
+  if (flags & FLAG_SHARED) {
+    if (s.length())
+      s += '+';
+    s += "shared";
+  }
+  if (flags & FLAG_COW_HEAD) {
+    if (s.length())
+      s += '+';
+    s += "cow_head";
+  }
+  if (flags & FLAG_COW_TAIL) {
+    if (s.length())
+      s += '+';
+    s += "cow_tail";
+  }
+  return s;
+}
+
+void bluestore_extent_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("offset", offset);
+  f->dump_unsigned("length", length);
+  f->dump_unsigned("flags", flags);
+}
+
+void bluestore_extent_t::generate_test_instances(list<bluestore_extent_t*>& o)
+{
+  o.push_back(new bluestore_extent_t());
+  o.push_back(new bluestore_extent_t(123, 456));
+  o.push_back(new bluestore_extent_t(789, 1024, 322));
+}
+
+ostream& operator<<(ostream& out, const bluestore_extent_t& e)
+{
+  out << e.offset << "~" << e.length;
+  if (e.flags)
+    out << ":" << bluestore_extent_t::get_flags_string(e.flags);
+  return out;
+}
+
+// bluestore_extent_ref_map_t
+
+void bluestore_extent_ref_map_t::add(uint64_t offset, uint32_t len, unsigned ref)
+{
+  map<uint64_t,record_t>::iterator p = ref_map.insert(
+    map<uint64_t,record_t>::value_type(offset, record_t(len, ref))).first;
+  _maybe_merge_left(p);
+  ++p;
+  if (p != ref_map.end())
+    _maybe_merge_left(p);
+  _check();
+}
+
+void bluestore_extent_ref_map_t::_check() const
+{
+  uint64_t pos = 0;
+  unsigned refs = 0;
+  for (const auto &p : ref_map) {
+    if (p.first < pos)
+      assert(0 == "overlap");
+    if (p.first == pos && p.second.refs == refs)
+      assert(0 == "unmerged");
+    pos = p.first + p.second.length;
+    refs = p.second.refs;
+  }
+}
+
+void bluestore_extent_ref_map_t::_maybe_merge_left(map<uint64_t,record_t>::iterator& p)
+{
+  if (p == ref_map.begin())
+    return;
+  auto q = p;
+  --q;
+  if (q->second.refs == p->second.refs &&
+      q->first + q->second.length == p->first) {
+    q->second.length += p->second.length;
+    ref_map.erase(p);
+    p = q;
+  }
+}
+
+void bluestore_extent_ref_map_t::get(uint64_t offset, uint32_t length)
+{
+  map<uint64_t,record_t>::iterator p = ref_map.lower_bound(offset);
+  if (p == ref_map.end() || p->first > offset) {
+    if (p == ref_map.begin()) {
+      assert(0 == "get on missing extent (nothing before)");
+    }
+    --p;
+    if (p->first + p->second.length <= offset) {
+      assert(0 == "get on missing extent (gap)");
+    }
+  }
+  if (p->first < offset) {
+    uint64_t left = p->first + p->second.length - offset;
+    p->second.length = offset - p->first;
+    p = ref_map.insert(map<uint64_t,record_t>::value_type(
+			 offset, record_t(left, p->second.refs))).first;
+  }
+  while (length > 0) {
+    assert(p->first == offset);
+    if (length < p->second.length) {
+      ref_map.insert(make_pair(offset + length,
+			       record_t(p->second.length - length,
+					p->second.refs)));
+      p->second.length = length;
+      ++p->second.refs;
+      _maybe_merge_left(p);
+      return;
+    }
+    ++p->second.refs;
+    offset += p->second.length;
+    length -= p->second.length;
+    _maybe_merge_left(p);
+    ++p;
+  }
+  if (p != ref_map.end())
+    _maybe_merge_left(p);
+  _check();
+}
+
+void bluestore_extent_ref_map_t::put(uint64_t offset, uint32_t length,
+			   vector<bluestore_extent_t> *release)
+{
+  map<uint64_t,record_t>::iterator p = ref_map.lower_bound(offset);
+  if (p == ref_map.end() || p->first > offset) {
+    if (p == ref_map.begin()) {
+      assert(0 == "put on missing extent (nothing before)");
+    }
+    --p;
+    if (p->first + p->second.length <= offset) {
+      assert(0 == "put on missing extent (gap)");
+    }
+  }
+  if (p->first < offset) {
+    uint64_t left = p->first + p->second.length - offset;
+    p->second.length = offset - p->first;
+    p = ref_map.insert(map<uint64_t,record_t>::value_type(
+			 offset, record_t(left, p->second.refs))).first;
+  }
+  while (length > 0) {
+    assert(p->first == offset);
+    if (length < p->second.length) {
+      ref_map.insert(make_pair(offset + length,
+			       record_t(p->second.length - length,
+					p->second.refs)));
+      if (p->second.refs > 1) {
+	p->second.length = length;
+	--p->second.refs;
+	_maybe_merge_left(p);
+      } else {
+	release->push_back(bluestore_extent_t(p->first, length));
+	ref_map.erase(p);
+      }
+      return;
+    }
+    offset += p->second.length;
+    length -= p->second.length;
+    if (p->second.refs > 1) {
+      --p->second.refs;
+      _maybe_merge_left(p);
+      ++p;
+    } else {
+      release->push_back(bluestore_extent_t(p->first, p->second.length));
+      ref_map.erase(p++);
+    }
+  }
+  if (p != ref_map.end())
+    _maybe_merge_left(p);
+  _check();
+}
+
+bool bluestore_extent_ref_map_t::contains(uint64_t offset, uint32_t length) const
+{
+  map<uint64_t,record_t>::const_iterator p = ref_map.lower_bound(offset);
+  if (p == ref_map.end() || p->first > offset) {
+    if (p == ref_map.begin()) {
+      return false; // nothing before
+    }
+    --p;
+    if (p->first + p->second.length <= offset) {
+      return false; // gap
+    }
+  }
+  while (length > 0) {
+    if (p == ref_map.end())
+      return false;
+    if (p->first > offset)
+      return false;
+    if (p->first + p->second.length >= offset + length)
+      return true;
+    uint64_t overlap = p->first + p->second.length - offset;
+    offset += overlap;
+    length -= overlap;
+    ++p;
+  }
+  return true;
+}
+
+void bluestore_extent_ref_map_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(ref_map, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_extent_ref_map_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(ref_map, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_extent_ref_map_t::dump(Formatter *f) const
+{
+  f->open_array_section("ref_map");
+  for (auto& p : ref_map) {
+    f->open_object_section("ref");
+    f->dump_unsigned("offset", p.first);
+    f->dump_unsigned("length", p.second.length);
+    f->dump_unsigned("refs", p.second.refs);
+    f->close_section();
+  }
+  f->close_section();
+}
+
+void bluestore_extent_ref_map_t::generate_test_instances(list<bluestore_extent_ref_map_t*>& o)
+{
+  o.push_back(new bluestore_extent_ref_map_t);
+  o.push_back(new bluestore_extent_ref_map_t);
+  o.back()->add(10, 10);
+  o.back()->add(20, 20, 3);
+  o.back()->get(15, 20);
+}
+
+ostream& operator<<(ostream& out, const bluestore_extent_ref_map_t& m)
+{
+  out << "ref_map(";
+  for (auto p = m.ref_map.begin(); p != m.ref_map.end(); ++p) {
+    if (p != m.ref_map.begin())
+      out << ",";
+    out << p->first << "~" << p->second.length << "=" << p->second.refs;
+  }
+  out << ")";
+  return out;
+}
+
+// bluestore_overlay_t
+
+void bluestore_overlay_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(key, bl);
+  ::encode(value_offset, bl);
+  ::encode(length, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_overlay_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(key, p);
+  ::decode(value_offset, p);
+  ::decode(length, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_overlay_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("key", key);
+  f->dump_unsigned("value_offset", value_offset);
+  f->dump_unsigned("length", length);
+}
+
+void bluestore_overlay_t::generate_test_instances(list<bluestore_overlay_t*>& o)
+{
+  o.push_back(new bluestore_overlay_t());
+  o.push_back(new bluestore_overlay_t(789, 1024, 1232232));
+}
+
+ostream& operator<<(ostream& out, const bluestore_overlay_t& o)
+{
+  out << "overlay(" << o.value_offset << "~" << o.length
+      << " key " << o.key << ")";
+  return out;
+}
+
+// bluestore_onode_t
+
+void bluestore_onode_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(nid, bl);
+  ::encode(size, bl);
+  ::encode(attrs, bl);
+  ::encode(block_map, bl);
+  ::encode(overlay_map, bl);
+  ::encode(overlay_refs, bl);
+  ::encode(last_overlay_key, bl);
+  ::encode(omap_head, bl);
+  ::encode(expected_object_size, bl);
+  ::encode(expected_write_size, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_onode_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(nid, p);
+  ::decode(size, p);
+  ::decode(attrs, p);
+  ::decode(block_map, p);
+  ::decode(overlay_map, p);
+  ::decode(overlay_refs, p);
+  ::decode(last_overlay_key, p);
+  ::decode(omap_head, p);
+  ::decode(expected_object_size, p);
+  ::decode(expected_write_size, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_onode_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("nid", nid);
+  f->dump_unsigned("size", size);
+  f->open_object_section("attrs");
+  for (map<string,bufferptr>::const_iterator p = attrs.begin();
+       p != attrs.end(); ++p) {
+    f->open_object_section("attr");
+    f->dump_string("name", p->first);
+    f->dump_unsigned("len", p->second.length());
+    f->close_section();
+  }
+  f->close_section();
+  f->open_object_section("block_map");
+  for (map<uint64_t, bluestore_extent_t>::const_iterator p = block_map.begin();
+       p != block_map.end(); ++p) {
+    f->open_object_section("extent");
+    f->dump_unsigned("extent_offset", p->first);
+    p->second.dump(f);
+    f->close_section();
+  }
+  f->close_section();
+  f->open_object_section("overlays");
+  for (map<uint64_t, bluestore_overlay_t>::const_iterator p = overlay_map.begin();
+       p != overlay_map.end(); ++p) {
+    f->open_object_section("overlay");
+    f->dump_unsigned("offset", p->first);
+    p->second.dump(f);
+    f->close_section();
+  }
+  f->close_section();
+  f->open_array_section("overlay_refs");
+  for (map<uint64_t,uint16_t>::const_iterator p = overlay_refs.begin();
+       p != overlay_refs.end(); ++p) {
+    f->open_object_section("overlay");
+    f->dump_unsigned("offset", p->first);
+    f->dump_unsigned("refs", p->second);
+    f->close_section();
+  }
+  f->close_section();
+  f->dump_unsigned("last_overlay_key", last_overlay_key);
+  f->dump_unsigned("omap_head", omap_head);
+  f->dump_unsigned("expected_object_size", expected_object_size);
+  f->dump_unsigned("expected_write_size", expected_write_size);
+}
+
+void bluestore_onode_t::generate_test_instances(list<bluestore_onode_t*>& o)
+{
+  o.push_back(new bluestore_onode_t());
+  // FIXME
+}
+
+// bluestore_wal_op_t
+
+void bluestore_wal_op_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(op, bl);
+  ::encode(extent, bl);
+  ::encode(src_extent, bl);
+  ::encode(src_rmw_head, bl);
+  ::encode(src_rmw_tail, bl);
+  ::encode(nid, bl);
+  ::encode(overlays, bl);
+  if (!overlays.size()) {
+    ::encode(data, bl);
+  }
+  ::encode(removed_overlays, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_wal_op_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(op, p);
+  ::decode(extent, p);
+  ::decode(src_extent, p);
+  ::decode(src_rmw_head, p);
+  ::decode(src_rmw_tail, p);
+  ::decode(nid, p);
+  ::decode(overlays, p);
+  if (!overlays.size()) {
+    ::decode(data, p);
+  }
+  ::decode(removed_overlays, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_wal_op_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("op", (int)op);
+  f->dump_object("extent", extent);
+  f->dump_object("src_extent", src_extent);
+  f->dump_unsigned("src_rmw_head", src_rmw_head);
+  f->dump_unsigned("src_rmw_tail", src_rmw_tail);
+  f->dump_unsigned("nid", nid);
+  f->open_array_section("overlays");
+  for (vector<bluestore_overlay_t>::const_iterator p = overlays.begin();
+       p != overlays.end(); ++p) {
+    f->dump_object("overlay", *p);
+  }
+  f->close_section();
+  f->open_array_section("removed_overlays");
+  for (vector<uint64_t>::const_iterator p = removed_overlays.begin();
+       p != removed_overlays.end(); ++p) {
+    f->dump_unsigned("key", *p);
+  }
+  f->close_section();
+}
+
+void bluestore_wal_op_t::generate_test_instances(list<bluestore_wal_op_t*>& o)
+{
+  o.push_back(new bluestore_wal_op_t);
+  o.push_back(new bluestore_wal_op_t);
+  o.back()->op = OP_WRITE;
+  o.back()->extent.offset = 1;
+  o.back()->extent.length = 2;
+  o.back()->src_extent.offset = 10000;
+  o.back()->src_extent.length = 2;
+  o.back()->src_rmw_head = 22;
+  o.back()->src_rmw_tail = 88;
+  o.back()->data.append("my data");
+  o.back()->nid = 3;
+  o.back()->overlays.push_back(bluestore_overlay_t());
+  o.back()->overlays.push_back(bluestore_overlay_t());
+  o.back()->overlays.back().key = 4;
+  o.back()->overlays.back().value_offset = 5;
+  o.back()->overlays.back().length = 6;
+}
+
+void bluestore_wal_transaction_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(seq, bl);
+  ::encode(ops, bl);
+  ::encode(released, bl);
+  ENCODE_FINISH(bl);
+}
+
+void bluestore_wal_transaction_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(seq, p);
+  ::decode(ops, p);
+  ::decode(released, p);
+  DECODE_FINISH(p);
+}
+
+void bluestore_wal_transaction_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("seq", seq);
+  f->open_array_section("ops");
+  for (list<bluestore_wal_op_t>::const_iterator p = ops.begin(); p != ops.end(); ++p) {
+    f->dump_object("op", *p);
+  }
+  f->close_section();
+}
+
+void bluestore_wal_transaction_t::generate_test_instances(list<bluestore_wal_transaction_t*>& o)
+{
+  o.push_back(new bluestore_wal_transaction_t());
+  o.push_back(new bluestore_wal_transaction_t());
+  o.back()->seq = 123;
+  o.back()->ops.push_back(bluestore_wal_op_t());
+  o.back()->ops.push_back(bluestore_wal_op_t());
+  o.back()->ops.back().op = bluestore_wal_op_t::OP_WRITE;
+  o.back()->ops.back().extent.offset = 2;
+  o.back()->ops.back().extent.length = 3;
+  o.back()->ops.back().data.append("foodata");
+  o.back()->ops.back().nid = 4;
+}
diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h
new file mode 100644
index 0000000..c07412d
--- /dev/null
+++ b/src/os/bluestore/bluestore_types.h
@@ -0,0 +1,312 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef CEPH_OSD_BLUESTORE_BLUESTORE_TYPES_H
+#define CEPH_OSD_BLUESTORE_BLUESTORE_TYPES_H
+
+#include <ostream>
+#include "include/types.h"
+#include "include/interval_set.h"
+#include "include/utime.h"
+#include "common/hobject.h"
+
+namespace ceph {
+  class Formatter;
+}
+
+/// label for block device
+struct bluestore_bdev_label_t {
+  uuid_d osd_uuid;     ///< osd uuid
+  uint64_t size;       ///< device size
+  utime_t btime;       ///< birth time
+  string description;  ///< device description
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_bdev_label_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_bdev_label_t)
+
+ostream& operator<<(ostream& out, const bluestore_bdev_label_t& l);
+
+/// collection metadata
+struct bluestore_cnode_t {
+  uint32_t bits;   ///< how many bits of coll pgid are significant
+
+  bluestore_cnode_t(int b=0) : bits(b) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_cnode_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_cnode_t)
+
+/// extent: a byte extent back by the block device
+struct bluestore_extent_t {
+  enum {
+    FLAG_UNWRITTEN = 1,   ///< extent is unwritten (and defined to be zero)
+    FLAG_SHARED = 2,      ///< extent is shared by another object, and refcounted
+    FLAG_COW_HEAD = 4,    ///< extent has pending wal OP_COPY for head
+    FLAG_COW_TAIL = 8,    ///< extent has pending wal OP_COPY for tail
+  };
+  static string get_flags_string(unsigned flags);
+
+  uint64_t offset;
+  uint32_t length;
+  uint32_t flags;  /// or reserved
+
+  bluestore_extent_t(uint64_t o=0, uint32_t l=0, uint32_t f=0)
+    : offset(o), length(l), flags(f) {}
+
+  uint64_t end() const {
+    return offset + length;
+  }
+
+  bool has_flag(unsigned f) const {
+    return flags & f;
+  }
+  void set_flag(unsigned f) {
+    flags |= f;
+  }
+  void clear_flag(unsigned f) {
+    flags &= ~f;
+  }
+
+  void encode(bufferlist& bl) const {
+    ::encode(offset, bl);
+    ::encode(length, bl);
+    ::encode(flags, bl);
+  }
+  void decode(bufferlist::iterator& p) {
+    ::decode(offset, p);
+    ::decode(length, p);
+    ::decode(flags, p);
+  }
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_extent_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_extent_t)
+
+ostream& operator<<(ostream& out, const bluestore_extent_t& bp);
+
+/// extent_map: a map of reference counted extents
+struct bluestore_extent_ref_map_t {
+  struct record_t {
+    uint32_t length;
+    uint32_t refs;
+    record_t(uint32_t l=0, uint32_t r=0) : length(l), refs(r) {}
+    void encode(bufferlist& bl) const {
+      ::encode(length, bl);
+      ::encode(refs, bl);
+    }
+    void decode(bufferlist::iterator& p) {
+      ::decode(length, p);
+      ::decode(refs, p);
+    }
+  };
+  WRITE_CLASS_ENCODER(record_t)
+
+  map<uint64_t,record_t> ref_map;
+
+  void _check() const;
+  void _maybe_merge_left(map<uint64_t,record_t>::iterator& p);
+
+  void clear() {
+    ref_map.clear();
+  }
+  bool empty() const {
+    return ref_map.empty();
+  }
+
+  void add(uint64_t offset, uint32_t len, unsigned ref=2);
+  void get(uint64_t offset, uint32_t len);
+  void put(uint64_t offset, uint32_t len, vector<bluestore_extent_t> *release);
+
+  bool contains(uint64_t offset, uint32_t len) const;
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_extent_ref_map_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_extent_ref_map_t::record_t)
+WRITE_CLASS_ENCODER(bluestore_extent_ref_map_t)
+
+ostream& operator<<(ostream& out, const bluestore_extent_ref_map_t& rm);
+static inline bool operator==(const bluestore_extent_ref_map_t::record_t& l,
+			      const bluestore_extent_ref_map_t::record_t& r) {
+  return l.length == r.length && l.refs == r.refs;
+}
+static inline bool operator==(const bluestore_extent_ref_map_t& l,
+			      const bluestore_extent_ref_map_t& r) {
+  return l.ref_map == r.ref_map;
+}
+static inline bool operator!=(const bluestore_extent_ref_map_t& l,
+			      const bluestore_extent_ref_map_t& r) {
+  return !(l == r);
+}
+
+/// overlay: a byte extent backed by kv pair, logically overlaying other content
+struct bluestore_overlay_t {
+  uint64_t key;          ///< key (nid+key identify the kv pair in the kvdb)
+  uint32_t value_offset; ///< offset in associated value for this extent
+  uint32_t length;
+
+  bluestore_overlay_t() : key(0), value_offset(0), length(0) {}
+  bluestore_overlay_t(uint64_t k, uint32_t vo, uint32_t l)
+    : key(k), value_offset(vo), length(l) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_overlay_t*>& o);
+
+};
+WRITE_CLASS_ENCODER(bluestore_overlay_t)
+
+ostream& operator<<(ostream& out, const bluestore_overlay_t& o);
+
+/// onode: per-object metadata
+struct bluestore_onode_t {
+  uint64_t nid;                        ///< numeric id (locally unique)
+  uint64_t size;                       ///< object size
+  map<string, bufferptr> attrs;        ///< attrs
+  map<uint64_t, bluestore_extent_t> block_map;   ///< block data
+  map<uint64_t,bluestore_overlay_t> overlay_map; ///< overlay data (stored in db)
+  map<uint64_t,uint16_t> overlay_refs; ///< overlay keys ref counts (if >1)
+  uint32_t last_overlay_key;           ///< key for next overlay
+  uint64_t omap_head;                  ///< id for omap root node
+
+  uint32_t expected_object_size;
+  uint32_t expected_write_size;
+
+  bluestore_onode_t()
+    : nid(0),
+      size(0),
+      last_overlay_key(0),
+      omap_head(0),
+      expected_object_size(0),
+      expected_write_size(0) {}
+
+  map<uint64_t,bluestore_extent_t>::iterator find_extent(uint64_t offset) {
+    map<uint64_t,bluestore_extent_t>::iterator fp = block_map.lower_bound(offset);
+    if (fp != block_map.begin()) {
+      --fp;
+      if (fp->first + fp->second.length <= offset) {
+	++fp;
+      }
+    }
+    if (fp != block_map.end() && fp->first > offset)
+      return block_map.end();  // extent is past offset
+    return fp;
+  }
+
+  map<uint64_t,bluestore_extent_t>::iterator seek_extent(uint64_t offset) {
+    map<uint64_t,bluestore_extent_t>::iterator fp = block_map.lower_bound(offset);
+    if (fp != block_map.begin()) {
+      --fp;
+      if (fp->first + fp->second.length <= offset) {
+	++fp;
+      }
+    }
+    return fp;
+  }
+
+  bool put_overlay_ref(uint64_t key) {
+    map<uint64_t,uint16_t>::iterator q = overlay_refs.find(key);
+    if (q == overlay_refs.end())
+      return true;
+    assert(q->second >= 2);
+    if (--q->second == 1) {
+      overlay_refs.erase(q);
+    }
+    return false;
+  }
+  void get_overlay_ref(uint64_t key) {
+    map<uint64_t,uint16_t>::iterator q = overlay_refs.find(key);
+    if (q == overlay_refs.end())
+      overlay_refs[key] = 2;
+    else
+      ++q->second;
+  }
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_onode_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_onode_t)
+
+
+/// writeahead-logged op
+struct bluestore_wal_op_t {
+  typedef enum {
+    OP_WRITE = 1,
+    OP_COPY = 2,
+    OP_ZERO = 4,
+  } type_t;
+  __u8 op = 0;
+  bluestore_extent_t extent;
+  bluestore_extent_t src_extent;
+  uint64_t src_rmw_head, src_rmw_tail;
+  bufferlist data;
+  uint64_t nid;
+  vector<bluestore_overlay_t> overlays;
+  vector<uint64_t> removed_overlays;
+
+  bluestore_wal_op_t() : src_rmw_head(0), src_rmw_tail(0), nid(0) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_wal_op_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_wal_op_t)
+
+
+/// writeahead-logged transaction
+struct bluestore_wal_transaction_t {
+  uint64_t seq = 0;
+  list<bluestore_wal_op_t> ops;
+  interval_set<uint64_t> released;  ///< allocations to release after wal
+
+  int64_t _bytes;  ///< cached byte count
+
+  bluestore_wal_transaction_t() : _bytes(-1) {}
+
+#if 0
+  no users for htis
+  uint64_t get_bytes() {
+    if (_bytes < 0) {
+      _bytes = 0;
+      for (list<bluestore_wal_op_t>::iterator p = ops.begin();
+	   p != ops.end();
+	   ++p) {
+	_bytes += p->extent.length;
+      }
+    }
+    return _bytes;
+  }
+#endif
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<bluestore_wal_transaction_t*>& o);
+};
+WRITE_CLASS_ENCODER(bluestore_wal_transaction_t)
+
+#endif
diff --git a/src/os/bluestore/kv.cc b/src/os/bluestore/kv.cc
new file mode 100644
index 0000000..8004e12
--- /dev/null
+++ b/src/os/bluestore/kv.cc
@@ -0,0 +1,61 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "kv.h"
+
+#include "include/byteorder.h"
+#include <string.h>
+
+void _key_encode_u32(uint32_t u, std::string *key)
+{
+  uint32_t bu;
+#ifdef CEPH_BIG_ENDIAN
+  bu = u;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  bu = swab32(u);
+#else
+# error wtf
+#endif
+  key->append((char*)&bu, 4);
+}
+
+const char *_key_decode_u32(const char *key, uint32_t *pu)
+{
+  uint32_t bu;
+  memcpy(&bu, key, 4);
+#ifdef CEPH_BIG_ENDIAN
+  *pu = bu;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  *pu = swab32(bu);
+#else
+# error wtf
+#endif
+  return key + 4;
+}
+
+void _key_encode_u64(uint64_t u, std::string *key)
+{
+  uint64_t bu;
+#ifdef CEPH_BIG_ENDIAN
+  bu = u;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  bu = swab64(u);
+#else
+# error wtf
+#endif
+  key->append((char*)&bu, 8);
+}
+
+const char *_key_decode_u64(const char *key, uint64_t *pu)
+{
+  uint64_t bu;
+  memcpy(&bu, key, 8);
+#ifdef CEPH_BIG_ENDIAN
+  *pu = bu;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  *pu = swab64(bu);
+#else
+# error wtf
+#endif
+  return key + 8;
+}
diff --git a/src/os/bluestore/kv.h b/src/os/bluestore/kv.h
new file mode 100644
index 0000000..7a52d4f
--- /dev/null
+++ b/src/os/bluestore/kv.h
@@ -0,0 +1,15 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_OS_BLUESTORE_KV_H
+#define CEPH_OS_BLUESTORE_KV_H
+
+#include <string>
+
+// some key encoding helpers
+void _key_encode_u32(uint32_t u, std::string *key);
+const char *_key_decode_u32(const char *key, uint32_t *pu);
+void _key_encode_u64(uint64_t u, std::string *key);
+const char *_key_decode_u64(const char *key, uint64_t *pu);
+
+#endif
diff --git a/src/os/BtrfsFileStoreBackend.cc b/src/os/filestore/BtrfsFileStoreBackend.cc
similarity index 99%
rename from src/os/BtrfsFileStoreBackend.cc
rename to src/os/filestore/BtrfsFileStoreBackend.cc
index 8c22733..97421c5 100644
--- a/src/os/BtrfsFileStoreBackend.cc
+++ b/src/os/filestore/BtrfsFileStoreBackend.cc
@@ -29,7 +29,7 @@
 #include "include/assert.h"
 
 #ifndef __CYGWIN__
-#include "btrfs_ioctl.h"
+#include "os/fs/btrfs_ioctl.h"
 #endif
 
 #include <iostream>
diff --git a/src/os/BtrfsFileStoreBackend.h b/src/os/filestore/BtrfsFileStoreBackend.h
similarity index 100%
rename from src/os/BtrfsFileStoreBackend.h
rename to src/os/filestore/BtrfsFileStoreBackend.h
diff --git a/src/os/CollectionIndex.h b/src/os/filestore/CollectionIndex.h
similarity index 95%
rename from src/os/CollectionIndex.h
rename to src/os/filestore/CollectionIndex.h
index 6af6d77..a9947cc 100644
--- a/src/os/CollectionIndex.h
+++ b/src/os/filestore/CollectionIndex.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #ifndef OS_COLLECTIONINDEX_H
@@ -28,7 +28,7 @@
  */
 class CollectionIndex {
 protected:
-  /** 
+  /**
    * Object encapsulating a returned path.
    *
    * A path to an object (existent or non-existent) becomes invalid
@@ -51,7 +51,7 @@ protected:
     /// Normal Constructor
     Path(
       string path,                              ///< [in] Path to return.
-      CollectionIndex* ref)  
+      CollectionIndex* ref)
       : full_path(path), parent_ref(ref), parent_coll(parent_ref->coll()) {}
 
     /// Debugging Constructor
@@ -59,7 +59,7 @@ protected:
       string path,                              ///< [in] Path to return.
       coll_t coll)                              ///< [in] collection
       : full_path(path), parent_coll(coll) {}
-      
+
     /// Getter for the stored path.
     const char *path() const { return full_path.c_str(); }
 
@@ -99,7 +99,7 @@ protected:
   virtual coll_t coll() const = 0;
 
 
-  /** 
+  /**
    * Initializes the index.
    *
    * @return Error Code, 0 for success
@@ -146,7 +146,7 @@ protected:
   virtual int lookup(
     const ghobject_t &oid, ///< [in] Object to lookup
     IndexedPath *path,	   ///< [out] Path to object
-    int *exist	           ///< [out] True if the object exists, else false
+    int *hardlink          ///< [out] number of hard links of this object. *hardlink=0 mean object no-exist.
     ) = 0;
 
   /**
@@ -177,7 +177,7 @@ protected:
   virtual int prep_delete() { return 0; }
 
   CollectionIndex(coll_t collection):
-    access_lock_name ("CollectionIndex::access_lock::" + collection.to_str()), 
+    access_lock_name ("CollectionIndex::access_lock::" + collection.to_str()),
     access_lock(access_lock_name.c_str()) {}
 
   /*
diff --git a/src/os/DBObjectMap.cc b/src/os/filestore/DBObjectMap.cc
similarity index 99%
rename from src/os/DBObjectMap.cc
rename to src/os/filestore/DBObjectMap.cc
index 449a5de..0434043 100644
--- a/src/os/DBObjectMap.cc
+++ b/src/os/filestore/DBObjectMap.cc
@@ -10,7 +10,7 @@
 #include "include/memory.h"
 #include <vector>
 
-#include "ObjectMap.h"
+#include "os/ObjectMap.h"
 #include "kv/KeyValueDB.h"
 #include "DBObjectMap.h"
 #include <errno.h>
@@ -390,7 +390,7 @@ int DBObjectMap::DBObjectMapIteratorImpl::in_complete_region(const string &to_te
 }
 
 /**
- * Moves parent_iter to the next position both out of the complete_region and 
+ * Moves parent_iter to the next position both out of the complete_region and
  * not equal to key_iter.  Then, we set cur_iter to parent_iter if valid and
  * less than key_iter and key_iter otherwise.
  */
diff --git a/src/os/DBObjectMap.h b/src/os/filestore/DBObjectMap.h
similarity index 99%
rename from src/os/DBObjectMap.h
rename to src/os/filestore/DBObjectMap.h
index 4b81acb..1b57485 100644
--- a/src/os/DBObjectMap.h
+++ b/src/os/filestore/DBObjectMap.h
@@ -11,7 +11,7 @@
 #include "include/memory.h"
 #include <boost/scoped_ptr.hpp>
 
-#include "ObjectMap.h"
+#include "os/ObjectMap.h"
 #include "kv/KeyValueDB.h"
 #include "osd/osd_types.h"
 #include "common/Mutex.h"
@@ -19,6 +19,8 @@
 #include "common/simple_cache.hpp"
 #include <boost/optional/optional_io.hpp>
 
+#include "SequencerPosition.h"
+
 /**
  * DBObjectMap: Implements ObjectMap in terms of KeyValueDB
  *
@@ -505,7 +507,7 @@ private:
   void _set_header(Header header, const bufferlist &bl,
 		   KeyValueDB::Transaction t);
 
-  /** 
+  /**
    * Removes header seq lock and possibly object lock
    * once Header is out of scope
    * @see lookup_parent
diff --git a/src/os/FDCache.h b/src/os/filestore/FDCache.h
similarity index 100%
rename from src/os/FDCache.h
rename to src/os/filestore/FDCache.h
diff --git a/src/os/FileJournal.cc b/src/os/filestore/FileJournal.cc
similarity index 94%
rename from src/os/FileJournal.cc
rename to src/os/filestore/FileJournal.cc
index 34c2f44..fa4751b 100644
--- a/src/os/FileJournal.cc
+++ b/src/os/filestore/FileJournal.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 #include "acconfig.h"
 
@@ -19,7 +19,7 @@
 #include "FileJournal.h"
 #include "include/color.h"
 #include "common/perf_counters.h"
-#include "os/FileStore.h"
+#include "FileStore.h"
 
 #include "include/compat.h"
 
@@ -59,7 +59,7 @@ int FileJournal::_open(bool forwrite, bool create)
   }
   if (create)
     flags |= O_CREAT;
-  
+
   if (fd >= 0) {
     if (TEMP_FAILURE_RETRY(::close(fd))) {
       int err = errno;
@@ -115,7 +115,7 @@ int FileJournal::_open(bool forwrite, bool create)
   max_size -= max_size % block_size;
 
   dout(1) << "_open " << fn << " fd " << fd
-	  << ": " << max_size 
+	  << ": " << max_size
 	  << " bytes, block size " << block_size
 	  << " bytes, directio = " << directio
 	  << ", aio = " << aio
@@ -316,7 +316,7 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
     }
     free(buf);
   }
-      
+
 
   dout(10) << "_open journal is not a block device, NOT checking disk "
            << "write cache on '" << fn << "'" << dendl;
@@ -389,7 +389,7 @@ int FileJournal::create()
 
   bp = prepare_header();
   if (TEMP_FAILURE_RETRY(::pwrite(fd, bp.c_str(), bp.length(), 0)) < 0) {
-    ret = errno;
+    ret = -errno;
     derr << "FileJournal::create : create write header error "
          << cpp_strerror(ret) << dendl;
     goto close_fd;
@@ -398,13 +398,14 @@ int FileJournal::create()
   // zero first little bit, too.
   ret = posix_memalign(&buf, block_size, block_size);
   if (ret) {
+    ret = -ret;
     derr << "FileJournal::create: failed to allocate " << block_size
 	 << " bytes of memory: " << cpp_strerror(ret) << dendl;
     goto close_fd;
   }
   memset(buf, 0, block_size);
   if (TEMP_FAILURE_RETRY(::pwrite(fd, buf, block_size, get_top())) < 0) {
-    ret = errno;
+    ret = -errno;
     derr << "FileJournal::create: error zeroing first " << block_size
 	 << " bytes " << cpp_strerror(ret) << dendl;
     goto free_buf;
@@ -427,10 +428,9 @@ free_buf:
   buf = 0;
 close_fd:
   if (TEMP_FAILURE_RETRY(::close(fd)) < 0) {
-    ret = errno;
+    ret = -errno;
     derr << "FileJournal::create: error closing fd: " << cpp_strerror(ret)
 	 << dendl;
-    goto done;
   }
 done:
   fd = -1;
@@ -477,8 +477,8 @@ int FileJournal::open(uint64_t fs_op_seq)
   zero_buf = new char[header.alignment];
   memset(zero_buf, 0, header.alignment);
 
-  dout(10) << "open header.fsid = " << header.fsid 
-    //<< " vs expected fsid = " << fsid 
+  dout(10) << "open header.fsid = " << header.fsid
+    //<< " vs expected fsid = " << fsid
 	   << dendl;
   if (header.fsid != fsid) {
     derr << "FileJournal::open: ondisk fsid " << header.fsid << " doesn't match expected " << fsid
@@ -499,7 +499,7 @@ int FileJournal::open(uint64_t fs_op_seq)
     return -EINVAL;
   }
   if (header.alignment != block_size && directio) {
-    dout(0) << "open journal alignment " << header.alignment << " does not match block size " 
+    dout(0) << "open journal alignment " << header.alignment << " does not match block size "
 	    << block_size << " (required for direct_io journal mode)" << dendl;
     return -EINVAL;
   }
@@ -691,10 +691,10 @@ void FileJournal::start_writer()
 {
   write_stop = false;
   aio_stop = false;
-  write_thread.create();
+  write_thread.create("journal_write");
 #ifdef HAVE_LIBAIO
   if (aio)
-    write_finish_thread.create();
+    write_finish_thread.create("journal_wrt_fin");
 #endif
 }
 
@@ -778,7 +778,7 @@ int FileJournal::read_header(header_t *hdr) const
     return -EINVAL;
   }
 
-  
+
   /*
    * Unfortunately we weren't initializing the flags field for new
    * journals!  Aie.  This is safe(ish) now that we have only one
@@ -876,47 +876,59 @@ int FileJournal::prepare_multi_write(bufferlist& bl, uint64_t& orig_ops, uint64_
 
   if (full_state != FULL_NOTFULL)
     return -ENOSPC;
-  
-  while (!writeq_empty()) {
-    int r = prepare_single_write(bl, queue_pos, orig_ops, orig_bytes);
-    if (r == -ENOSPC) {
-      if (orig_ops)
-	break;         // commit what we have
 
-      if (logger)
-	logger->inc(l_os_j_full);
-
-      if (wait_on_full) {
-	dout(20) << "prepare_multi_write full on first entry, need to wait" << dendl;
-      } else {
-	dout(20) << "prepare_multi_write full on first entry, restarting journal" << dendl;
-
-	// throw out what we have so far
-	full_state = FULL_FULL;
-	while (!writeq_empty()) {
-	  put_throttle(1, peek_write().orig_len);
-	  pop_write();
-	}  
-	print_header(header);
+  while (!writeq_empty()) {
+    list<write_item> items;
+    batch_pop_write(items);
+    list<write_item>::iterator it = items.begin();
+    while (it != items.end()) {
+      int r = prepare_single_write(*it, bl, queue_pos, orig_ops, orig_bytes);
+      if (r == 0) { // prepare ok, delete it
+         items.erase(it++);
       }
-
-      return -ENOSPC;  // hrm, full on first op
-    }
-
-    if (eleft) {
-      if (--eleft == 0) {
-	dout(20) << "prepare_multi_write hit max events per write " << g_conf->journal_max_write_entries << dendl;
-	break;
+      if (r == -ENOSPC) {
+        // the journal maybe full, insert the left item to writeq
+        batch_unpop_write(items);
+        if (orig_ops)
+          goto out;         // commit what we have
+
+        if (logger)
+          logger->inc(l_os_j_full);
+
+        if (wait_on_full) {
+          dout(20) << "prepare_multi_write full on first entry, need to wait" << dendl;
+        } else {
+          dout(20) << "prepare_multi_write full on first entry, restarting journal" << dendl;
+
+          // throw out what we have so far
+          full_state = FULL_FULL;
+          while (!writeq_empty()) {
+            put_throttle(1, peek_write().orig_len);
+            pop_write();
+          }
+          print_header(header);
+        }
+        
+        return -ENOSPC;  // hrm, full on first op
       }
-    }
-    if (bmax) {
-      if (bl.length() >= bmax) {
-	dout(20) << "prepare_multi_write hit max write size " << g_conf->journal_max_write_bytes << dendl;
-	break;
+      if (eleft) {
+        if (--eleft == 0) {
+          dout(20) << "prepare_multi_write hit max events per write " << g_conf->journal_max_write_entries << dendl;
+          batch_unpop_write(items);
+          goto out;
+        }
+      }
+      if (bmax) {
+        if (bl.length() >= bmax) {
+          dout(20) << "prepare_multi_write hit max write size " << g_conf->journal_max_write_bytes << dendl;
+          batch_unpop_write(items);
+          goto out;
+        }
       }
     }
   }
 
+out:
   dout(20) << "prepare_multi_write queue_pos now " << queue_pos << dendl;
   assert((write_pos + bl.length() == queue_pos) ||
          (write_pos + bl.length() - header.max_size + get_top() == queue_pos));
@@ -946,11 +958,13 @@ void FileJournal::queue_completions_thru(uint64_t seq)
 {
   assert(finisher_lock.is_locked());
   utime_t now = ceph_clock_now(g_ceph_context);
-  while (!completions_empty()) {
-    completion_item next = completion_peek_front();
+  list<completion_item> items;
+  batch_pop_completions(items);
+  list<completion_item>::iterator it = items.begin();
+  while (it != items.end()) {
+    completion_item& next = *it;
     if (next.seq > seq)
       break;
-    completion_pop_front();
     utime_t lat = now;
     lat -= next.start;
     dout(10) << "queue_completions_thru seq " << seq
@@ -964,14 +978,15 @@ void FileJournal::queue_completions_thru(uint64_t seq)
       finisher->queue(next.finish);
     if (next.tracked_op)
       next.tracked_op->mark_event("journaled_completion_queued");
+    items.erase(it++);
   }
+  batch_unpop_completions(items);
   finisher_cond.Signal();
 }
 
-int FileJournal::prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64_t& orig_ops, uint64_t& orig_bytes)
+
+int FileJournal::prepare_single_write(write_item &next_write, bufferlist& bl, off64_t& queue_pos, uint64_t& orig_ops, uint64_t& orig_bytes)
 {
-  // grab next item
-  write_item &next_write = peek_write();
   uint64_t seq = next_write.seq;
   bufferlist &ebl = next_write.bl;
   off64_t size = ebl.length();
@@ -987,7 +1002,7 @@ int FileJournal::prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64
   // add to write buffer
   dout(15) << "prepare_single_write " << orig_ops << " will write " << queue_pos << " : seq " << seq
 	   << " len " << orig_len << " -> " << size << dendl;
-    
+
   unsigned seq_offset = offsetof(entry_header_t, seq);
   unsigned magic1_offset = offsetof(entry_header_t, magic1);
   unsigned magic2_offset = offsetof(entry_header_t, magic2);
@@ -1010,8 +1025,6 @@ int FileJournal::prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64
   if (next_write.tracked_op)
     next_write.tracked_op->mark_event("write_thread_in_journal_buffer");
 
-  // pop from writeq
-  pop_write();
   journalq.push_back(pair<uint64_t,off64_t>(seq, queue_pos));
   writing_seq = seq;
 
@@ -1060,7 +1073,7 @@ int FileJournal::write_bl(off64_t& pos, bufferlist& bl)
 void FileJournal::do_write(bufferlist& bl)
 {
   // nothing to do?
-  if (bl.length() == 0 && !must_write_header) 
+  if (bl.length() == 0 && !must_write_header)
     return;
 
   buffer::ptr hbp;
@@ -1075,10 +1088,10 @@ void FileJournal::do_write(bufferlist& bl)
     hbp = prepare_header();
   }
 
-  dout(15) << "do_write writing " << write_pos << "~" << bl.length() 
+  dout(15) << "do_write writing " << write_pos << "~" << bl.length()
 	   << (hbp.length() ? " + header":"")
 	   << dendl;
-  
+
   utime_t from = ceph_clock_now(g_ceph_context);
 
   // entry
@@ -1182,10 +1195,10 @@ void FileJournal::do_write(bufferlist& bl)
 #endif
   }
 
-  utime_t lat = ceph_clock_now(g_ceph_context) - from;    
+  utime_t lat = ceph_clock_now(g_ceph_context) - from;
   dout(20) << "do_write latency " << lat << dendl;
 
-  write_lock.Lock();    
+  write_lock.Lock();
 
   assert(write_pos == pos);
   assert(write_pos % header.alignment == 0);
@@ -1240,7 +1253,7 @@ void FileJournal::write_thread_entry()
 	continue;
       }
     }
-    
+
 #ifdef HAVE_LIBAIO
     if (aio) {
       Mutex::Locker locker(aio_lock);
@@ -1287,7 +1300,7 @@ void FileJournal::write_thread_entry()
 	while (!writeq_empty()) {
 	  put_throttle(1, peek_write().orig_len);
 	  pop_write();
-	}  
+	}
 	print_header(header);
 	r = 0;
       } else {
@@ -1329,7 +1342,7 @@ void FileJournal::do_aio_write(bufferlist& bl)
   }
 
   // nothing to do?
-  if (bl.length() == 0 && !must_write_header) 
+  if (bl.length() == 0 && !must_write_header)
     return;
 
   buffer::ptr hbp;
@@ -1341,10 +1354,10 @@ void FileJournal::do_aio_write(bufferlist& bl)
   // entry
   off64_t pos = write_pos;
 
-  dout(15) << "do_aio_write writing " << pos << "~" << bl.length() 
+  dout(15) << "do_aio_write writing " << pos << "~" << bl.length()
 	   << (hbp.length() ? " + header":"")
 	   << dendl;
-  
+
   // split?
   off64_t split = 0;
   if (pos + bl.length() > header.max_size) {
@@ -1408,7 +1421,7 @@ int FileJournal::write_aio_bl(off64_t& pos, bufferlist& bl, uint64_t seq)
   align_bl(pos, bl);
 
   dout(20) << "write_aio_bl " << pos << "~" << bl.length() << " seq " << seq << dendl;
-  
+
   while (bl.length() > 0) {
     int max = MIN(bl.buffers().size(), IOV_MAX-1);
     iovec *iov = new iovec[max];
@@ -1426,7 +1439,7 @@ int FileJournal::write_aio_bl(off64_t& pos, bufferlist& bl, uint64_t seq)
     bufferlist tbl;
     bl.splice(0, len, &tbl);  // move bytes from bl -> tbl
 
-    // lock only aio_queue, current aio, aio_num, aio_bytes, which may be 
+    // lock only aio_queue, current aio, aio_num, aio_bytes, which may be
     // modified in check_aio_completion
     aio_lock.Lock();
     aio_queue.push_back(aio_info(tbl, pos, bl.length() > 0 ? 0 : seq));
@@ -1440,7 +1453,7 @@ int FileJournal::write_aio_bl(off64_t& pos, bufferlist& bl, uint64_t seq)
 
     aio_num++;
     aio_bytes += aio.len;
-   
+
     // need to save current aio len to update write_pos later because current
     // aio could be ereased from aio_queue once it is done
     uint64_t cur_len = aio.len;
@@ -1488,7 +1501,7 @@ void FileJournal::write_finish_thread_entry()
 	continue;
       }
     }
-    
+
     dout(20) << "write_finish_thread_entry waiting for aio(s)" << dendl;
     io_event event[16];
     int r = io_getevents(aio_ctx, 1, 16, event, NULL);
@@ -1500,7 +1513,7 @@ void FileJournal::write_finish_thread_entry()
       derr << "io_getevents got " << cpp_strerror(r) << dendl;
       assert(0 == "got unexpected error from io_getevents");
     }
-    
+
     {
       Mutex::Locker locker(aio_lock);
       for (int i=0; i<r; i++) {
@@ -1548,7 +1561,7 @@ void FileJournal::check_aio_completion()
   }
 
   if (completed_something) {
-    // kick finisher?  
+    // kick finisher?
     //  only if we haven't filled up recently!
     Mutex::Locker locker(finisher_lock);
     journaled_seq = new_journaled_seq;
@@ -1677,6 +1690,20 @@ void FileJournal::pop_write()
   writeq.pop_front();
 }
 
+void FileJournal::batch_pop_write(list<write_item> &items)
+{
+  assert(write_lock.is_locked());
+  Mutex::Locker locker(writeq_lock);
+  writeq.swap(items);
+}
+
+void FileJournal::batch_unpop_write(list<write_item> &items)
+{
+  assert(write_lock.is_locked());
+  Mutex::Locker locker(writeq_lock);
+  writeq.splice(writeq.begin(), items);
+}
+
 void FileJournal::commit_start(uint64_t seq)
 {
   dout(10) << "commit_start" << dendl;
@@ -1783,13 +1810,13 @@ void FileJournal::committed_thru(uint64_t seq)
 
   // committed but unjournaled items
   while (!writeq_empty() && peek_write().seq <= seq) {
-    dout(15) << " dropping committed but unwritten seq " << peek_write().seq 
+    dout(15) << " dropping committed but unwritten seq " << peek_write().seq
 	     << " len " << peek_write().bl.length()
 	     << dendl;
     put_throttle(1, peek_write().orig_len);
     pop_write();
   }
-  
+
   commit_cond.Signal();
 
   dout(10) << "committed_thru done" << dendl;
@@ -1800,7 +1827,7 @@ void FileJournal::put_throttle(uint64_t ops, uint64_t bytes)
 {
   uint64_t new_ops = throttle_ops.put(ops);
   uint64_t new_bytes = throttle_bytes.put(bytes);
-  dout(5) << "put_throttle finished " << ops << " ops and " 
+  dout(5) << "put_throttle finished " << ops << " ops and "
 	   << bytes << " bytes, now "
 	   << new_ops << " ops and " << new_bytes << " bytes"
 	   << dendl;
@@ -1849,10 +1876,10 @@ void FileJournal::wrap_read_bl(
       len = header.max_size - pos;        // partial
     else
       len = olen;                         // rest
-    
+
     int64_t actual = ::lseek64(fd, pos, SEEK_SET);
     assert(actual == pos);
-    
+
     bufferptr bp = buffer::create(len);
     int r = safe_read_exact(fd, bp.c_str(), len);
     if (r) {
diff --git a/src/os/FileJournal.h b/src/os/filestore/FileJournal.h
similarity index 95%
rename from src/os/FileJournal.h
rename to src/os/filestore/FileJournal.h
index 50bc810..69935a6 100644
--- a/src/os/FileJournal.h
+++ b/src/os/filestore/FileJournal.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -66,17 +66,27 @@ public:
 
   Mutex writeq_lock;
   Cond writeq_cond;
-  deque<write_item> writeq;
+  list<write_item> writeq;
   bool writeq_empty();
   write_item &peek_write();
   void pop_write();
+  void batch_pop_write(list<write_item> &items);
+  void batch_unpop_write(list<write_item> &items);
 
   Mutex completions_lock;
-  deque<completion_item> completions;
+  list<completion_item> completions;
   bool completions_empty() {
     Mutex::Locker l(completions_lock);
     return completions.empty();
   }
+  void batch_pop_completions(list<completion_item> &items) {
+    Mutex::Locker l(completions_lock);
+    completions.swap(items);
+  }
+  void batch_unpop_completions(list<completion_item> &items) {
+    Mutex::Locker l(completions_lock);
+    completions.splice(completions.begin(), items);
+  }
   completion_item completion_peek_front() {
     Mutex::Locker l(completions_lock);
     assert(!completions.empty());
@@ -204,7 +214,7 @@ public:
     uint32_t pre_pad, post_pad;
     uint64_t magic1;
     uint64_t magic2;
-    
+
     static uint64_t make_magic(uint64_t seq, uint32_t len, uint64_t fsid) {
       return (fsid ^ seq ^ len);
     }
@@ -281,7 +291,7 @@ private:
   deque<pair<uint64_t, off64_t> > journalq;  // track seq offsets, so we can trim later.
   uint64_t writing_seq;
 
-  
+
   // throttle
   Throttle throttle_ops, throttle_bytes;
 
@@ -311,7 +321,8 @@ private:
 
   int check_for_full(uint64_t seq, off64_t pos, off64_t size);
   int prepare_multi_write(bufferlist& bl, uint64_t& orig_ops, uint64_t& orig_bytee);
-  int prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64_t& orig_ops, uint64_t& orig_bytes);
+  int prepare_single_write(write_item &next_write, bufferlist& bl, off64_t& queue_pos,
+    uint64_t& orig_ops, uint64_t& orig_bytes);
   void do_write(bufferlist& bl);
 
   void write_finish_thread_entry();
@@ -378,7 +389,7 @@ private:
     aio_ctx(0),
     aio_num(0), aio_bytes(0),
 #endif
-    last_committed_seq(0), 
+    last_committed_seq(0),
     journaled_since_start(0),
     full_state(FULL_NOTFULL),
     fd(-1),
diff --git a/src/os/FileStore.cc b/src/os/filestore/FileStore.cc
similarity index 98%
rename from src/os/FileStore.cc
rename to src/os/filestore/FileStore.cc
index d58fa5f..5cb73e7 100644
--- a/src/os/FileStore.cc
+++ b/src/os/filestore/FileStore.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -8,9 +8,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 #include "include/int_types.h"
 
@@ -150,7 +150,7 @@ ostream& operator<<(ostream& out, const FileStore::OpSequencer& s)
   return out << *s.parent;
 }
 
-int FileStore::get_cdir(coll_t cid, char *s, int len) 
+int FileStore::get_cdir(coll_t cid, char *s, int len)
 {
   const string &cid_str(cid.to_str());
   return snprintf(s, len, "%s/current/%s", basedir.c_str(), cid_str.c_str());
@@ -202,6 +202,7 @@ int FileStore::lfn_truncate(coll_t cid, const ghobject_t& oid, off_t length)
     int rc = backend->_crc_update_truncate(**fd, length);
     assert(rc >= 0);
   }
+  lfn_close(fd);
   assert(!m_filestore_fail_eio || r != -EIO);
   return r;
 }
@@ -232,9 +233,6 @@ int FileStore::lfn_open(coll_t cid,
 			FDRef *outfd,
                         Index *index)
 {
-  assert(get_allow_sharded_objects() ||
-	 ( oid.shard_id == shard_id_t::NO_SHARD &&
-	   oid.generation == ghobject_t::NO_GEN ));
   assert(outfd);
   int r = 0;
   bool need_lock = true;
@@ -382,7 +380,7 @@ int FileStore::lfn_link(coll_t c, coll_t newcid, const ghobject_t& o, const ghob
     }
     if (!exist)
       return -ENOENT;
-  
+
     RWLock::WLocker l2((index_new.index)->access_lock);
 
     r = index_new->lookup(newoid, &path_new, &exist);
@@ -437,7 +435,7 @@ int FileStore::lfn_link(coll_t c, coll_t newcid, const ghobject_t& o, const ghob
       assert(!m_filestore_fail_eio || r != -EIO);
       return r;
     }
-  }    
+  }
   return 0;
 }
 
@@ -457,28 +455,20 @@ int FileStore::lfn_unlink(coll_t cid, const ghobject_t& o,
 
   {
     IndexedPath path;
-    int exist;
-    r = index->lookup(o, &path, &exist);
+    int hardlink;
+    r = index->lookup(o, &path, &hardlink);
     if (r < 0) {
       assert(!m_filestore_fail_eio || r != -EIO);
       return r;
     }
 
     if (!force_clear_omap) {
-      struct stat st;
-      r = ::stat(path->path(), &st);
-      if (r < 0) {
-	r = -errno;
-	if (r == -ENOENT) {
+      if (hardlink == 0) {
 	  wbthrottle.clear_object(o); // should be only non-cache ref
 	  fdcache.clear(o);
-	} else {
-	  assert(!m_filestore_fail_eio || r != -EIO);
-	}
-	dout(25) << __func__ << " stat failed " << cpp_strerror(r) << dendl;
-	return r;
-      } else if (st.st_nlink == 1) {
-	force_clear_omap = true;
+	  return 0;
+      } else if (hardlink == 1) {
+	  force_clear_omap = true;
       }
     }
     if (force_clear_omap) {
@@ -522,18 +512,18 @@ FileStore::FileStore(const std::string &base, const std::string &jdev, osflagbit
   backend(NULL),
   index_manager(do_update),
   lock("FileStore::lock"),
-  force_sync(false), 
+  force_sync(false),
   sync_entry_timeo_lock("sync_entry_timeo_lock"),
   timer(g_ceph_context, sync_entry_timeo_lock),
   stop(false), sync_thread(this),
   fdcache(g_ceph_context),
   wbthrottle(g_ceph_context),
   next_osr_id(0),
-  throttle_ops(g_ceph_context, "filestore_ops",g_conf->filestore_queue_max_ops),
-  throttle_bytes(g_ceph_context, "filestore_bytes",g_conf->filestore_queue_max_bytes),
+  throttle_ops(g_ceph_context, "filestore_ops", g_conf->filestore_queue_max_ops),
+  throttle_bytes(g_ceph_context, "filestore_bytes", g_conf->filestore_queue_max_bytes),
   m_ondisk_finisher_num(g_conf->filestore_ondisk_finisher_threads),
   m_apply_finisher_num(g_conf->filestore_apply_finisher_threads),
-  op_tp(g_ceph_context, "FileStore::op_tp", g_conf->filestore_op_threads, "filestore_op_threads"),
+  op_tp(g_ceph_context, "FileStore::op_tp", "tp_fstore_op", g_conf->filestore_op_threads, "filestore_op_threads"),
   op_wq(this, g_conf->filestore_op_thread_timeout,
 	g_conf->filestore_op_thread_suicide_timeout, &op_tp),
   logger(NULL),
@@ -570,13 +560,13 @@ FileStore::FileStore(const std::string &base, const std::string &jdev, osflagbit
   for (int i = 0; i < m_ondisk_finisher_num; ++i) {
     ostringstream oss;
     oss << "filestore-ondisk-" << i;
-    Finisher *f = new Finisher(g_ceph_context, oss.str());
+    Finisher *f = new Finisher(g_ceph_context, oss.str(), "fn_odsk_fstore");
     ondisk_finishers.push_back(f);
   }
   for (int i = 0; i < m_apply_finisher_num; ++i) {
     ostringstream oss;
     oss << "filestore-apply-" << i;
-    Finisher *f = new Finisher(g_ceph_context, oss.str());
+    Finisher *f = new Finisher(g_ceph_context, oss.str(), "fn_appl_fstore");
     apply_finishers.push_back(f);
   }
 
@@ -668,14 +658,18 @@ void FileStore::collect_metadata(map<string,string> *pm)
   char partition_path[PATH_MAX];
   char dev_node[PATH_MAX];
   int rc = 0;
-  
+
   (*pm)["filestore_backend"] = backend->get_name();
   ostringstream ss;
   ss << "0x" << std::hex << m_fs_type << std::dec;
   (*pm)["filestore_f_type"] = ss.str();
 
-  rc = get_device_by_uuid(get_fsid(), "PARTUUID", partition_path,
-        dev_node);
+  if (g_conf->filestore_collect_device_partition_information) {
+    rc = get_device_by_uuid(get_fsid(), "PARTUUID", partition_path,
+          dev_node);
+  } else {
+    rc = -EINVAL;
+  }
 
   switch (rc) {
     case -EOPNOTSUPP:
@@ -828,7 +822,7 @@ int FileStore::mkfs()
       goto close_fsid_fd;
     }
     if (::fsync(fsid_fd) < 0) {
-      ret = errno;
+      ret = -errno;
       derr << "mkfs: close failed: can't write fsid: "
 	   << cpp_strerror(ret) << dendl;
       goto close_fsid_fd;
@@ -905,13 +899,13 @@ int FileStore::mkfs()
 	ret = backend->create_checkpoint(s, NULL);
 	VOID_TEMP_FAILURE_RETRY(::close(current_fd));
 	if (ret < 0 && ret != -EEXIST) {
-	  VOID_TEMP_FAILURE_RETRY(::close(fd));  
+	  VOID_TEMP_FAILURE_RETRY(::close(fd));
 	  derr << "mkfs: failed to create snap_1: " << cpp_strerror(ret) << dendl;
 	  goto close_fsid_fd;
 	}
       }
     }
-    VOID_TEMP_FAILURE_RETRY(::close(fd));  
+    VOID_TEMP_FAILURE_RETRY(::close(fd));
   }
   ret = KeyValueDB::test_init(superblock.omap_backend, omap_dir);
   if (ret < 0) {
@@ -985,6 +979,7 @@ int FileStore::mkjournal()
 int FileStore::read_fsid(int fd, uuid_d *uuid)
 {
   char fsid_str[40];
+  memset(fsid_str, 0, sizeof(fsid_str));
   int ret = safe_read(fd, fsid_str, sizeof(fsid_str));
   if (ret < 0)
     return ret;
@@ -997,6 +992,8 @@ int FileStore::read_fsid(int fd, uuid_d *uuid)
 
   if (ret > 36)
     fsid_str[36] = 0;
+  else
+    fsid_str[ret] = 0;
   if (!uuid->parse(fsid_str))
     return -EINVAL;
   return 0;
@@ -1110,7 +1107,7 @@ int FileStore::_sanity_check_fs()
       (int)m_filestore_journal_parallel +
       (int)m_filestore_journal_trailing) > 1) {
     dout(0) << "mount ERROR: more than one of filestore journal {writeahead,parallel,trailing} enabled" << dendl;
-    cerr << TEXT_RED 
+    cerr << TEXT_RED
 	 << " ** WARNING: more than one of 'filestore journal {writeahead,parallel,trailing}'\n"
 	 << "             is enabled in ceph.conf.  You must choose a single journal mode."
 	 << TEXT_NORMAL << std::endl;
@@ -1120,7 +1117,7 @@ int FileStore::_sanity_check_fs()
   if (!backend->can_checkpoint()) {
     if (!journal || !m_filestore_journal_writeahead) {
       dout(0) << "mount WARNING: no btrfs, and no journal in writeahead mode; data may be lost" << dendl;
-      cerr << TEXT_RED 
+      cerr << TEXT_RED
 	   << " ** WARNING: no btrfs AND (no journal OR journal not in writeahead mode)\n"
 	   << "             For non-btrfs volumes, a writeahead journal is required to\n"
 	   << "             maintain on-disk consistency in the event of a crash.  Your conf\n"
@@ -1173,22 +1170,6 @@ int FileStore::read_superblock()
   return 0;
 }
 
-void FileStore::set_allow_sharded_objects()
-{
-  if (!get_allow_sharded_objects()) {
-    superblock.compat_features.incompat.insert(CEPH_FS_FEATURE_INCOMPAT_SHARDS);
-    int ret = write_superblock();
-    assert(ret == 0);	//Should we return error and make caller handle it?
-  }
-  return;
-}
-
-bool FileStore::get_allow_sharded_objects()
-{
-  return g_conf->filestore_debug_disable_sharded_check ||
-    superblock.compat_features.incompat.contains(CEPH_FS_FEATURE_INCOMPAT_SHARDS);
-}
-
 int FileStore::update_version_stamp()
 {
   return write_version_stamp();
@@ -1289,7 +1270,7 @@ int FileStore::mount()
   CompatSet supported_compat_set = get_fs_supported_compat_set();
 
   dout(5) << "basedir " << basedir << " journal " << journalpath << dendl;
-  
+
   // make sure global base dir exists
   if (::access(basedir.c_str(), R_OK | W_OK)) {
     ret = -errno;
@@ -1333,7 +1314,7 @@ int FileStore::mount()
   } else if (ret == 0) {
     if (do_update || (int)version_stamp < g_conf->filestore_update_to) {
       derr << "FileStore::mount : stale version stamp detected: "
-	   << version_stamp 
+	   << version_stamp
 	   << ". Proceeding, do_update "
 	   << "is set, performing disk format upgrade."
 	   << dendl;
@@ -1603,7 +1584,7 @@ int FileStore::mount()
       Index index;
       ret = get_index(*i, &index);
       if (ret < 0) {
-	derr << "Unable to mount index " << *i 
+	derr << "Unable to mount index " << *i
 	     << " with error: " << ret << dendl;
 	goto close_current_fd;
       }
@@ -1615,7 +1596,7 @@ int FileStore::mount()
   }
 
   wbthrottle.start();
-  sync_thread.create();
+  sync_thread.create("filestore_sync");
 
   if (!(generic_flags & SKIP_JOURNAL_REPLAY)) {
     ret = journal_replay(initial_op_seq);
@@ -1626,16 +1607,7 @@ int FileStore::mount()
 	     << "wasn't configured?" << dendl;
       }
 
-      // stop sync thread
-      lock.Lock();
-      stop = true;
-      sync_cond.Signal();
-      lock.Unlock();
-      sync_thread.join();
-
-      wbthrottle.stop();
-
-      goto close_current_fd;
+      goto stop_sync;
     }
   }
 
@@ -1644,7 +1616,7 @@ int FileStore::mount()
     if (g_conf->filestore_debug_omap_check && !object_map->check(err2)) {
       derr << err2.str() << dendl;
       ret = -EINVAL;
-      goto close_current_fd;
+      goto stop_sync;
     }
   }
 
@@ -1675,6 +1647,15 @@ int FileStore::mount()
   // all okay.
   return 0;
 
+stop_sync:
+  // stop sync thread
+  lock.Lock();
+  stop = true;
+  sync_cond.Signal();
+  lock.Unlock();
+  sync_thread.join();
+
+  wbthrottle.stop();
 close_current_fd:
   VOID_TEMP_FAILURE_RETRY(::close(current_fd));
   current_fd = -1;
@@ -1728,10 +1709,10 @@ void FileStore::init_temp_collections()
   }
 }
 
-int FileStore::umount() 
+int FileStore::umount()
 {
   dout(5) << "umount " << basedir << dendl;
-  
+
   flush();
   sync();
   do_force_sync();
@@ -1854,7 +1835,7 @@ void FileStore::op_queue_reserve_throttle(Op *o, ThreadPool::TPHandle *handle)
 
   if (handle)
     handle->suspend_tp_timeout();
-  if (throttle_ops.should_wait(1) || 
+  if (throttle_ops.should_wait(1) ||
     (throttle_bytes.get_current()      // let single large ops through!
     && throttle_bytes.should_wait(o->bytes))) {
     dout(2) << "waiting " << throttle_ops.get_current() + 1 << " > " << max_ops << " ops || "
@@ -1904,7 +1885,7 @@ void FileStore::_finish_op(OpSequencer *osr)
 {
   list<Context*> to_queue;
   Op *o = osr->dequeue(&to_queue);
-  
+
   utime_t lat = ceph_clock_now(g_ceph_context);
   lat -= o->start;
 
@@ -1994,14 +1975,14 @@ int FileStore::queue_transactions(Sequencer *posr, list<Transaction*> &tls,
 
     if (m_filestore_journal_parallel) {
       dout(5) << "queue_transactions (parallel) " << o->op << " " << o->tls << dendl;
-      
+
       _op_journal_transactions(tbl, orig_len, o->op, ondisk, osd_op);
-      
+
       // queue inside submit_manager op submission lock
       queue_op(osr, o);
     } else if (m_filestore_journal_writeahead) {
       dout(5) << "queue_transactions (writeahead) " << o->op << " " << o->tls << dendl;
-      
+
       osr->queue_journal(o->op);
 
       _op_journal_transactions(tbl, orig_len, o->op,
@@ -2053,7 +2034,7 @@ int FileStore::queue_transactions(Sequencer *posr, list<Transaction*> &tls,
 
   apply_manager.op_apply_start(op);
   int r = do_transactions(tls, op);
-    
+
   if (r >= 0) {
     _op_journal_transactions(tbl, orig_len, op, ondisk, osd_op);
   } else {
@@ -2101,20 +2082,17 @@ int FileStore::_do_transactions(
   uint64_t op_seq,
   ThreadPool::TPHandle *handle)
 {
-  int r = 0;
   int trans_num = 0;
 
   for (list<Transaction*>::iterator p = tls.begin();
        p != tls.end();
        ++p, trans_num++) {
-    r = _do_transaction(**p, op_seq, trans_num, handle);
-    if (r < 0)
-      break;
+    _do_transaction(**p, op_seq, trans_num, handle);
     if (handle)
       handle->reset_tp_timeout();
   }
-  
-  return r;
+
+  return 0;
 }
 
 void FileStore::_set_global_replay_guard(coll_t cid,
@@ -2210,7 +2188,7 @@ void FileStore::_set_replay_guard(coll_t cid,
   }
   _set_replay_guard(fd, spos, 0, in_progress);
   VOID_TEMP_FAILURE_RETRY(::close(fd));
-} 
+}
 
 
 void FileStore::_set_replay_guard(int fd,
@@ -2266,7 +2244,7 @@ void FileStore::_close_replay_guard(coll_t cid,
   }
   _close_replay_guard(fd, spos);
   VOID_TEMP_FAILURE_RETRY(::close(fd));
-} 
+}
 
 void FileStore::_close_replay_guard(int fd, const SequencerPosition& spos)
 {
@@ -2375,7 +2353,7 @@ int FileStore::_check_replay_guard(int fd, const SequencerPosition& spos)
   }
 }
 
-unsigned FileStore::_do_transaction(
+void FileStore::_do_transaction(
   Transaction& t, uint64_t op_seq, int trans_num,
   ThreadPool::TPHandle *handle)
 {
@@ -2386,7 +2364,7 @@ unsigned FileStore::_do_transaction(
 #endif
 
   Transaction::iterator i = t.begin();
-  
+
   SequencerPosition spos(op_seq, trans_num, 0);
   while (i.have_op()) {
     if (handle)
@@ -2411,7 +2389,7 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, touch_exit, r);
       }
       break;
-      
+
     case Transaction::OP_WRITE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2428,7 +2406,7 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, write_exit, r);
       }
       break;
-      
+
     case Transaction::OP_ZERO:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2442,13 +2420,13 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, zero_exit, r);
       }
       break;
-      
+
     case Transaction::OP_TRIMCACHE:
       {
 	// deprecated, no-op
       }
       break;
-      
+
     case Transaction::OP_TRUNCATE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2461,7 +2439,7 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, truncate_exit, r);
       }
       break;
-      
+
     case Transaction::OP_REMOVE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2473,7 +2451,7 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, remove_exit, r);
       }
       break;
-      
+
     case Transaction::OP_SETATTR:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2494,7 +2472,7 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, setattr_exit, r);
       }
       break;
-      
+
     case Transaction::OP_SETATTRS:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2535,7 +2513,7 @@ unsigned FileStore::_do_transaction(
         tracepoint(objectstore, rmattrs_exit, r);
       }
       break;
-      
+
     case Transaction::OP_CLONE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -2895,8 +2873,6 @@ unsigned FileStore::_do_transaction(
   }
 
   _inject_failure();
-
-  return 0;  // FIXME count errors
 }
 
   /*********************************************/
@@ -2915,7 +2891,7 @@ bool FileStore::exists(coll_t cid, const ghobject_t& oid)
   tracepoint(objectstore, exists_exit, retval);
   return retval;
 }
-  
+
 int FileStore::stat(
   coll_t cid, const ghobject_t& oid, struct stat *st, bool allow_eio)
 {
@@ -3148,7 +3124,7 @@ int FileStore::fiemap(coll_t cid, const ghobject_t& oid,
     dout(10) << "read couldn't open " << cid << "/" << oid << ": " << cpp_strerror(r) << dendl;
     goto done;
   }
-  
+
   if (backend->has_seek_data_hole()) {
     dout(15) << "seek_data/seek_hole " << cid << "/" << oid << " " << offset << "~" << len << dendl;
     r = _do_seek_hole_data(**fd, offset, len, &exomap);
@@ -3157,12 +3133,14 @@ int FileStore::fiemap(coll_t cid, const ghobject_t& oid,
     r = _do_fiemap(**fd, offset, len, &exomap);
   }
 
-done:
+  lfn_close(fd);
+
   if (r >= 0) {
-    lfn_close(fd);
     ::encode(exomap, bl);
   }
 
+done:
+
   dout(10) << "fiemap " << cid << "/" << oid << " " << offset << "~" << len << " = " << r << " num_extents=" << exomap.size() << " " << exomap << dendl;
   assert(!m_filestore_fail_eio || r != -EIO);
   tracepoint(objectstore, fiemap_exit, r);
@@ -3171,7 +3149,7 @@ done:
 
 
 int FileStore::_remove(coll_t cid, const ghobject_t& oid,
-		       const SequencerPosition &spos) 
+		       const SequencerPosition &spos)
 {
   dout(15) << "remove " << cid << "/" << oid << dendl;
   int r = lfn_unlink(cid, oid, spos);
@@ -3220,7 +3198,7 @@ int FileStore::_write(coll_t cid, const ghobject_t& oid,
 	    << cpp_strerror(r) << dendl;
     goto out;
   }
-    
+
   // seek
   actual = ::lseek64(**fd, offset, SEEK_SET);
   if (actual < 0) {
@@ -3459,7 +3437,7 @@ int FileStore::_do_copy_range(int from, int to, uint64_t srcoff, uint64_t len, u
   if (backend->has_splice()) {
     int pipefd[2];
     if (pipe(pipefd) < 0) {
-      r = errno;
+      r = -errno;
       derr << " pipe " << " got " << cpp_strerror(r) << dendl;
       return r;
     }
@@ -3500,13 +3478,13 @@ int FileStore::_do_copy_range(int from, int to, uint64_t srcoff, uint64_t len, u
 
     actual = ::lseek64(from, srcoff, SEEK_SET);
     if (actual != (int64_t)srcoff) {
-      r = errno;
+      r = -errno;
       derr << "lseek64 to " << srcoff << " got " << cpp_strerror(r) << dendl;
       return r;
     }
     actual = ::lseek64(to, dstoff, SEEK_SET);
     if (actual != (int64_t)dstoff) {
-      r = errno;
+      r = -errno;
       derr << "lseek64 to " << dstoff << " got " << cpp_strerror(r) << dendl;
       return r;
     }
@@ -3602,7 +3580,7 @@ int FileStore::_clone_range(coll_t cid, const ghobject_t& oldoid, const ghobject
 
 class SyncEntryTimeout : public Context {
 public:
-  SyncEntryTimeout(int commit_timeo) 
+  SyncEntryTimeout(int commit_timeo)
     : m_commit_timeo(commit_timeo)
   {
   }
@@ -3648,7 +3626,7 @@ void FileStore::sync_entry()
       if (woke < min_interval) {
 	utime_t t = min_interval;
 	t -= woke;
-	dout(20) << "sync_entry waiting for another " << t 
+	dout(20) << "sync_entry waiting for another " << t
 		 << " to reach min interval " << min_interval << dendl;
 	sync_cond.WaitInterval(g_ceph_context, lock, t);
       }
@@ -3658,7 +3636,7 @@ void FileStore::sync_entry()
   again:
     fin.swap(sync_waiters);
     lock.Unlock();
-    
+
     op_tp.pause();
     if (apply_manager.commit_start()) {
       utime_t start = ceph_clock_now(g_ceph_context);
@@ -3732,7 +3710,7 @@ void FileStore::sync_entry()
 	  assert(0 == "error during fsync of op_seq");
 	}
       }
-      
+
       utime_t done = ceph_clock_now(g_ceph_context);
       utime_t lat = done - start;
       utime_t dur = done - startwait;
@@ -3770,7 +3748,7 @@ void FileStore::sync_entry()
     } else {
       op_tp.unpause();
     }
-    
+
     lock.Lock();
     finish_contexts(g_ceph_context, fin, 0);
     fin.clear();
@@ -3858,7 +3836,7 @@ void FileStore::flush()
       cond.Wait(lock);
     assert(0);
   }
- 
+
   if (m_filestore_journal_writeahead) {
     if (journal)
       journal->flush();
@@ -4125,6 +4103,8 @@ int FileStore::getattrs(coll_t cid, const ghobject_t& oid, map<string,bufferptr>
     spill_out = false;
 
   r = _fgetattrs(**fd, aset);
+  lfn_close(fd);
+  fd = FDRef(); // defensive
   if (r < 0) {
     goto out;
   }
@@ -4203,7 +4183,7 @@ int FileStore::_setattrs(coll_t cid, const ghobject_t& oid, map<string,bufferptr
   incomplete_inline = (r == -E2BIG);
   assert(!m_filestore_fail_eio || r != -EIO);
   dout(15) << "setattrs " << cid << "/" << oid
-    	   << (incomplete_inline ? " (incomplete_inline, forcing omap)" : "")
+	   << (incomplete_inline ? " (incomplete_inline, forcing omap)" : "")
 	   << dendl;
 
   for (map<string,bufferptr>::iterator p = aset.begin();
@@ -4572,7 +4552,7 @@ int FileStore::collection_version_current(coll_t c, uint32_t *version)
   *version = index->collection_version();
   if (*version == target_version)
     return 1;
-  else 
+  else
     return 0;
 }
 
@@ -4650,7 +4630,7 @@ int FileStore::list_collections(vector<coll_t>& ls, bool include_temp)
   return r;
 }
 
-int FileStore::collection_stat(coll_t c, struct stat *st) 
+int FileStore::collection_stat(coll_t c, struct stat *st)
 {
   tracepoint(objectstore, collection_stat_enter, c.c_str());
   char fn[PATH_MAX];
@@ -4665,7 +4645,7 @@ int FileStore::collection_stat(coll_t c, struct stat *st)
   return r;
 }
 
-bool FileStore::collection_exists(coll_t c) 
+bool FileStore::collection_exists(coll_t c)
 {
   tracepoint(objectstore, collection_exists_enter, c.c_str());
   struct stat st;
@@ -4674,8 +4654,8 @@ bool FileStore::collection_exists(coll_t c)
   return ret;
 }
 
-bool FileStore::collection_empty(coll_t c) 
-{  
+bool FileStore::collection_empty(coll_t c)
+{
   tracepoint(objectstore, collection_empty_enter, c.c_str());
   dout(15) << "collection_empty " << c << dendl;
   Index index;
@@ -4933,7 +4913,7 @@ ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c,
   if (r < 0) {
     dout(10) << __func__ << " " << c << "/" << hoid << " = 0 "
 	     << "(get_index failed with " << cpp_strerror(r) << ")" << dendl;
-    return ObjectMap::ObjectMapIterator(); 
+    return ObjectMap::ObjectMapIterator();
   }
   {
     assert(NULL != index.index);
@@ -5008,7 +4988,7 @@ int FileStore::_create_collection(
   return 0;
 }
 
-int FileStore::_destroy_collection(coll_t c) 
+int FileStore::_destroy_collection(coll_t c)
 {
   int r = 0;
   char fn[PATH_MAX];
@@ -5053,7 +5033,7 @@ int FileStore::_collection_add(coll_t c, coll_t oldcid, const ghobject_t& o,
 			       const SequencerPosition& spos)
 {
   dout(15) << "collection_add " << c << "/" << o << " from " << oldcid << "/" << o << dendl;
-  
+
   int dstcmp = _check_replay_guard(c, o, spos);
   if (dstcmp < 0)
     return 0;
@@ -5166,10 +5146,10 @@ int FileStore::_collection_move_rename(coll_t oldcid, const ghobject_t& oldoid,
       r = lfn_open(c, o, 0, &fd);
 
     // close guard on object so we don't do this again
-    if (r == 0)
+    if (r == 0) {
       _close_replay_guard(**fd, spos);
-
-    lfn_close(fd);
+      lfn_close(fd);
+    }
   }
 
   dout(10) << __func__ << " " << c << "/" << o << " from " << oldcid << "/" << oldoid
@@ -5225,7 +5205,12 @@ int FileStore::_omap_setkeys(coll_t cid, const ghobject_t &hoid,
 			     const SequencerPosition &spos) {
   dout(15) << __func__ << " " << cid << "/" << hoid << dendl;
   Index index;
-  int r = get_index(cid, &index);
+  int r;
+  //treat pgmeta as a logical object, skip to check exist
+  if (hoid.is_pgmeta())
+    goto skip;
+
+  r = get_index(cid, &index);
   if (r < 0) {
     dout(20) << __func__ << " get_index got " << cpp_strerror(r) << dendl;
     return r;
@@ -5239,6 +5224,7 @@ int FileStore::_omap_setkeys(coll_t cid, const ghobject_t &hoid,
       return r;
     }
   }
+skip:
   r = object_map->set_keys(hoid, aset, &spos);
   dout(20) << __func__ << " " << cid << "/" << hoid << " = " << r << dendl;
   return r;
@@ -5249,7 +5235,12 @@ int FileStore::_omap_rmkeys(coll_t cid, const ghobject_t &hoid,
 			    const SequencerPosition &spos) {
   dout(15) << __func__ << " " << cid << "/" << hoid << dendl;
   Index index;
-  int r = get_index(cid, &index);
+  int r;
+  //treat pgmeta as a logical object, skip to check exist
+  if (hoid.is_pgmeta())
+    goto skip;
+
+  r = get_index(cid, &index);
   if (r < 0)
     return r;
   {
@@ -5259,6 +5250,7 @@ int FileStore::_omap_rmkeys(coll_t cid, const ghobject_t &hoid,
     if (r < 0)
       return r;
   }
+skip:
   r = object_map->rm_keys(hoid, keys, &spos);
   if (r < 0 && r != -ENOENT)
     return r;
@@ -5346,7 +5338,7 @@ int FileStore::_split_collection(coll_t cid,
 
       assert(NULL != to.index);
       RWLock::WLocker l2((to.index)->access_lock);
-      
+
       r = from->split(rem, bits, to.index);
     }
 
diff --git a/src/os/FileStore.h b/src/os/filestore/FileStore.h
similarity index 97%
rename from src/os/FileStore.h
rename to src/os/filestore/FileStore.h
index be5e668..52714f9 100644
--- a/src/os/FileStore.h
+++ b/src/os/filestore/FileStore.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -28,7 +28,7 @@ using namespace std;
 
 #include "include/assert.h"
 
-#include "ObjectStore.h"
+#include "os/ObjectStore.h"
 #include "JournalingObjectStore.h"
 
 #include "common/Timer.h"
@@ -37,7 +37,7 @@ using namespace std;
 #include "common/Mutex.h"
 #include "HashIndex.h"
 #include "IndexManager.h"
-#include "ObjectMap.h"
+#include "os/ObjectMap.h"
 #include "SequencerPosition.h"
 #include "FDCache.h"
 #include "WBThrottle.h"
@@ -124,7 +124,7 @@ private:
   std::string current_op_seq_fn;
   std::string omap_dir;
   uuid_d fsid;
-  
+
   size_t blk_size;            ///< fs block size
 
   int fsid_fd, op_fd, basedir_fd, current_fd;
@@ -151,10 +151,10 @@ private:
 
   // ObjectMap
   boost::scoped_ptr<ObjectMap> object_map;
-  
+
   // helper fns
   int get_cdir(coll_t cid, char *s, int len);
-  
+
   /// read a uuid from fd
   int read_fsid(int fd, uuid_d *uuid);
 
@@ -200,7 +200,7 @@ private:
     Sequencer *parent;
     Mutex apply_lock;  // for apply mutual exclusion
     int id;
-    
+
     /// get_max_uncompleted
     bool _get_max_uncompleted(
       uint64_t *seq ///< [out] max uncompleted seq
@@ -392,7 +392,7 @@ private:
   PerfCounters *logger;
 
 public:
-  int lfn_find(const ghobject_t& oid, const Index& index, 
+  int lfn_find(const ghobject_t& oid, const Index& index,
                                   IndexedPath *path = NULL);
   int lfn_truncate(coll_t cid, const ghobject_t& oid, off_t length);
   int lfn_stat(coll_t cid, const ghobject_t& oid, struct stat *buf);
@@ -416,7 +416,7 @@ public:
 
   int _detect_fs();
   int _sanity_check_fs();
-  
+
   bool test_mount_in_use();
   int read_op_seq(uint64_t *seq);
   int write_op_seq(int, uint64_t seq);
@@ -448,22 +448,6 @@ public:
   int update_version_stamp();
   int upgrade();
 
-  /**
-   * set_allow_sharded_objects()
-   *
-   * Before sharded ghobject_t can be specified this function must be called
-   *
-   * Once this function is called the FileStore is not mountable by prior releases
-   */
-  void set_allow_sharded_objects();
-
-  /**
-   * get_allow_sharded_objects()
-   *
-   * return value: true if set_allow_sharded_objects() called, otherwise false
-   */
-  bool get_allow_sharded_objects();
-
   bool can_sort_nibblewise() {
     return true;    // i support legacy sort order
   }
@@ -478,7 +462,7 @@ public:
   int do_transactions(list<Transaction*> &tls, uint64_t op_seq) {
     return _do_transactions(tls, op_seq, 0);
   }
-  unsigned _do_transaction(
+  void _do_transaction(
     Transaction& t, uint64_t op_seq, int trans_num,
     ThreadPool::TPHandle *handle);
 
diff --git a/src/os/GenericFileStoreBackend.cc b/src/os/filestore/GenericFileStoreBackend.cc
similarity index 99%
rename from src/os/GenericFileStoreBackend.cc
rename to src/os/filestore/GenericFileStoreBackend.cc
index 4bba413..d62d622 100644
--- a/src/os/GenericFileStoreBackend.cc
+++ b/src/os/filestore/GenericFileStoreBackend.cc
@@ -41,7 +41,7 @@
 #include "common/sync_filesystem.h"
 
 #include "common/SloppyCRCMap.h"
-#include "os/chain_xattr.h"
+#include "os/filestore/chain_xattr.h"
 
 #define SLOPPY_CRC_XATTR "user.cephos.scrc"
 
diff --git a/src/os/GenericFileStoreBackend.h b/src/os/filestore/GenericFileStoreBackend.h
similarity index 100%
rename from src/os/GenericFileStoreBackend.h
rename to src/os/filestore/GenericFileStoreBackend.h
diff --git a/src/os/HashIndex.cc b/src/os/filestore/HashIndex.cc
similarity index 99%
rename from src/os/HashIndex.cc
rename to src/os/filestore/HashIndex.cc
index 2c69d81..a358ef3 100644
--- a/src/os/HashIndex.cc
+++ b/src/os/filestore/HashIndex.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #include "include/types.h"
@@ -275,7 +275,7 @@ int HashIndex::col_split_level(
     if (r < 0)
       return r;
   }
-       
+
 
   r = to.set_info(path, to_info);
   if (r < 0)
@@ -361,7 +361,7 @@ int HashIndex::_remove(const vector<string> &path,
 int HashIndex::_lookup(const ghobject_t &oid,
 		       vector<string> *path,
 		       string *mangled_name,
-		       int *exists_out) {
+		       int *hardlink) {
   vector<string> path_comp;
   get_path_components(oid, &path_comp);
   vector<string>::iterator next = path_comp.begin();
@@ -380,7 +380,7 @@ int HashIndex::_lookup(const ghobject_t &oid,
       break;
     path->push_back(*(next++));
   }
-  return get_mangled_name(*path, oid, mangled_name, exists_out);
+  return get_mangled_name(*path, oid, mangled_name, hardlink);
 }
 
 int HashIndex::_collection_list_partial(const ghobject_t &start,
@@ -635,7 +635,7 @@ bool HashIndex::must_merge(const subdir_info_s &info) {
 bool HashIndex::must_split(const subdir_info_s &info) {
   return (info.hash_level < (unsigned)MAX_HASH_LEVEL &&
 	  info.objs > ((unsigned)(abs(merge_threshold)) * 16 * split_multiplier));
-			    
+
 }
 
 int HashIndex::initiate_merge(const vector<string> &path, subdir_info_s info) {
diff --git a/src/os/HashIndex.h b/src/os/filestore/HashIndex.h
similarity index 98%
rename from src/os/HashIndex.h
rename to src/os/filestore/HashIndex.h
index 6f5a22d..2ed2186 100644
--- a/src/os/HashIndex.h
+++ b/src/os/filestore/HashIndex.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #ifndef CEPH_HASHINDEX_H
@@ -36,15 +36,15 @@ extern string reverse_hexdigit_bits_string(string l);
  *            - F - 0
  * @endverbatim
  *
- * A file is located at the longest existing directory from the root 
+ * A file is located at the longest existing directory from the root
  * given by the hex characters in the hash beginning with the least
  * significant.
- * 
+ *
  * ex: ghobject_t("object", CEPH_NO_SNAP, 0xA4CEE0D2)
  * would be located in (root)/2/D/0/
- * 
+ *
  * Subdirectories are created when the number of objects in a directory
- * exceed (abs(merge_threshhold)) * 16 * split_multiplier.  The number of objects in a directory 
+ * exceed (abs(merge_threshhold)) * 16 * split_multiplier.  The number of objects in a directory
  * is encoded as subdir_info_s in an xattr on the directory.
  */
 class HashIndex : public LFNIndex {
@@ -74,7 +74,7 @@ private:
     uint32_t hash_level; ///< Hashlevel of subdir.
 
     subdir_info_s() : objs(0), subdirs(0), hash_level(0) {}
-    
+
     void encode(bufferlist &bl) const
     {
       __u8 v = 1;
@@ -83,7 +83,7 @@ private:
       ::encode(subdirs, bl);
       ::encode(hash_level, bl);
     }
-    
+
     void decode(bufferlist::iterator &bl)
     {
       __u8 v;
@@ -103,7 +103,7 @@ private:
     int op;
     vector<string> path;
 
-    InProgressOp(int op, const vector<string> &path) 
+    InProgressOp(int op, const vector<string> &path)
       : op(op), path(path) {}
 
     InProgressOp(bufferlist::iterator &bl) {
@@ -129,8 +129,8 @@ private:
       ::decode(path, bl);
     }
   };
-    
-    
+
+
 public:
   /// Constructor.
   HashIndex(
@@ -177,7 +177,7 @@ protected:
     const ghobject_t &oid,
     vector<string> *path,
     string *mangled_name,
-    int *exists
+    int *hardlink
     );
 
   /**
@@ -292,9 +292,9 @@ private:
     uint32_t match,             ///< [in] bits to match
     unsigned *mkdirred          ///< [in,out] path[:mkdirred] has been mkdirred
     );
-    
 
-  /** 
+
+  /**
    * Get string representation of ghobject_t/hash
    *
    * e.g: 0x01234567 -> "76543210"
diff --git a/src/os/IndexManager.cc b/src/os/filestore/IndexManager.cc
similarity index 96%
rename from src/os/IndexManager.cc
rename to src/os/filestore/IndexManager.cc
index 1415939..3a3e5c9 100644
--- a/src/os/IndexManager.cc
+++ b/src/os/filestore/IndexManager.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #include "include/memory.h"
@@ -36,13 +36,13 @@
 static int set_version(const char *path, uint32_t version) {
   bufferlist bl;
   ::encode(version, bl);
-  return chain_setxattr(path, "user.cephos.collection_version", bl.c_str(), 
+  return chain_setxattr(path, "user.cephos.collection_version", bl.c_str(),
 		     bl.length(), true);
 }
 
 static int get_version(const char *path, uint32_t *version) {
   bufferptr bp(PATH_MAX);
-  int r = chain_getxattr(path, "user.cephos.collection_version", 
+  int r = chain_getxattr(path, "user.cephos.collection_version",
 		      bp.c_str(), bp.length());
   if (r < 0) {
     if (r != -ENOENT) {
@@ -62,7 +62,7 @@ static int get_version(const char *path, uint32_t *version) {
 
 IndexManager::~IndexManager() {
 
-  for (ceph::unordered_map<coll_t, CollectionIndex* > ::iterator it = col_indices.begin(); 
+  for (ceph::unordered_map<coll_t, CollectionIndex* > ::iterator it = col_indices.begin();
        it != col_indices.end(); ++it) {
 
     delete it->second;
diff --git a/src/os/IndexManager.h b/src/os/filestore/IndexManager.h
similarity index 97%
rename from src/os/IndexManager.h
rename to src/os/filestore/IndexManager.h
index b167e7d..da71807 100644
--- a/src/os/IndexManager.h
+++ b/src/os/filestore/IndexManager.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 #ifndef OS_INDEXMANAGER_H
 #define OS_INDEXMANAGER_H
diff --git a/src/os/Journal.h b/src/os/filestore/Journal.h
similarity index 96%
rename from src/os/Journal.h
rename to src/os/filestore/Journal.h
index 400b1ea..602e8ea 100644
--- a/src/os/Journal.h
+++ b/src/os/filestore/Journal.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -75,7 +75,7 @@ public:
   virtual int prepare_entry(list<ObjectStore::Transaction*>& tls, bufferlist* tbl) = 0;
 
   // reads/recovery
-  
+
 };
 
 #endif
diff --git a/src/os/JournalingObjectStore.cc b/src/os/filestore/JournalingObjectStore.cc
similarity index 98%
rename from src/os/JournalingObjectStore.cc
rename to src/os/filestore/JournalingObjectStore.cc
index 599a1b5..e47b2e6 100644
--- a/src/os/JournalingObjectStore.cc
+++ b/src/os/filestore/JournalingObjectStore.cc
@@ -16,8 +16,8 @@ void JournalingObjectStore::journal_start()
   dout(10) << "journal_start" << dendl;
   finisher.start();
 }
- 
-void JournalingObjectStore::journal_stop() 
+
+void JournalingObjectStore::journal_stop()
 {
   dout(10) << "journal_stop" << dendl;
   finisher.stop();
@@ -55,7 +55,7 @@ int JournalingObjectStore::journal_replay(uint64_t fs_op_seq)
 
   int err = journal->open(op_seq);
   if (err < 0) {
-    dout(3) << "journal_replay open failed with " 
+    dout(3) << "journal_replay open failed with "
 	    << cpp_strerror(err) << dendl;
     delete journal;
     journal = 0;
@@ -78,7 +78,7 @@ int JournalingObjectStore::journal_replay(uint64_t fs_op_seq)
       continue;
     }
     assert(op_seq == seq-1);
-    
+
     dout(3) << "journal_replay: applying op seq " << seq << dendl;
     bufferlist::iterator p = bl.begin();
     list<Transaction*> tls;
@@ -94,7 +94,7 @@ int JournalingObjectStore::journal_replay(uint64_t fs_op_seq)
     op_seq = seq;
 
     while (!tls.empty()) {
-      delete tls.front(); 
+      delete tls.front();
       tls.pop_front();
     }
 
@@ -236,12 +236,12 @@ void JournalingObjectStore::ApplyManager::commit_finish()
 {
   Mutex::Locker l(com_lock);
   dout(10) << "commit_finish thru " << committing_seq << dendl;
-  
+
   if (journal)
     journal->committed_thru(committing_seq);
 
   committed_seq = committing_seq;
-  
+
   map<version_t, vector<Context*> >::iterator p = commit_waiters.begin();
   while (p != commit_waiters.end() &&
     p->first <= committing_seq) {
@@ -266,4 +266,3 @@ void JournalingObjectStore::_op_journal_transactions(
     apply_manager.add_waiter(op, onjournal);
   }
 }
-
diff --git a/src/os/JournalingObjectStore.h b/src/os/filestore/JournalingObjectStore.h
similarity index 95%
rename from src/os/JournalingObjectStore.h
rename to src/os/filestore/JournalingObjectStore.h
index bba3767..f384ba6 100644
--- a/src/os/JournalingObjectStore.h
+++ b/src/os/filestore/JournalingObjectStore.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,15 +7,15 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #ifndef CEPH_JOURNALINGOBJECTSTORE_H
 #define CEPH_JOURNALINGOBJECTSTORE_H
 
-#include "ObjectStore.h"
+#include "os/ObjectStore.h"
 #include "Journal.h"
 #include "FileJournal.h"
 #include "common/RWLock.h"
@@ -132,7 +132,7 @@ public:
   JournalingObjectStore(const std::string& path)
     : ObjectStore(path),
       journal(NULL),
-      finisher(g_ceph_context, "JournalObjectStore"),
+      finisher(g_ceph_context, "JournalObjectStore", "fn_jrn_objstore"),
       apply_manager(journal, finisher),
       replaying(false) {}
 
diff --git a/src/os/LFNIndex.cc b/src/os/filestore/LFNIndex.cc
similarity index 97%
rename from src/os/LFNIndex.cc
rename to src/os/filestore/LFNIndex.cc
index 90837b6..7f8e6d0 100644
--- a/src/os/LFNIndex.cc
+++ b/src/os/filestore/LFNIndex.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #include <string>
@@ -44,8 +44,8 @@ const string LFNIndex::LFN_ATTR = "user.cephos.lfn";
 const string LFNIndex::PHASH_ATTR_PREFIX = "user.cephos.phash.";
 const string LFNIndex::SUBDIR_PREFIX = "DIR_";
 const string LFNIndex::FILENAME_COOKIE = "long";
-const int LFNIndex::FILENAME_PREFIX_LEN =  FILENAME_SHORT_LEN - FILENAME_HASH_LEN - 
-								FILENAME_COOKIE.size() - 
+const int LFNIndex::FILENAME_PREFIX_LEN =  FILENAME_SHORT_LEN - FILENAME_HASH_LEN -
+								FILENAME_COOKIE.size() -
 								FILENAME_EXTRA;
 void LFNIndex::maybe_inject_failure()
 {
@@ -115,29 +115,15 @@ int LFNIndex::unlink(const ghobject_t &oid)
 
 int LFNIndex::lookup(const ghobject_t &oid,
 		     IndexedPath *out_path,
-		     int *exist)
+		     int *hardlink)
 {
   WRAP_RETRY(
   vector<string> path;
   string short_name;
-  r = _lookup(oid, &path, &short_name, exist);
+  r = _lookup(oid, &path, &short_name, hardlink);
   if (r < 0)
     goto out;
   string full_path = get_full_path(path, short_name);
-  struct stat buf;
-  maybe_inject_failure();
-  r = ::stat(full_path.c_str(), &buf);
-  maybe_inject_failure();
-  if (r < 0) {
-    if (errno == ENOENT) {
-      *exist = 0;
-    } else {
-      r = -errno;
-      goto out;
-    }
-  } else {
-    *exist = 1;
-  }
   *out_path = IndexedPath(new Path(full_path, this));
   r = 0;
   );
@@ -234,8 +220,8 @@ int LFNIndex::remove_objects(const vector<string> &dir,
 	 i != holes.end();
 	 ++i) {
       if (candidate == chain.rend() || *i > candidate->first) {
-	string remove_path_name = 
-	  get_full_path(dir, lfn_get_short_name(to_clean->second, *i)); 
+	string remove_path_name =
+	  get_full_path(dir, lfn_get_short_name(to_clean->second, *i));
 	maybe_inject_failure();
 	int r = ::unlink(remove_path_name.c_str());
 	maybe_inject_failure();
@@ -313,14 +299,16 @@ int LFNIndex::remove_object(const vector<string> &from,
   maybe_inject_failure();
   if (r < 0)
     return r;
+  if (exist == 0)
+    return -ENOENT;
   return lfn_unlink(from, oid, short_name);
 }
 
 int LFNIndex::get_mangled_name(const vector<string> &from,
 			       const ghobject_t &oid,
-			       string *mangled_name, int *exists)
+			       string *mangled_name, int *hardlink)
 {
-  return lfn_get_name(from, oid, mangled_name, 0, exists);
+  return lfn_get_name(from, oid, mangled_name, 0, hardlink);
 }
 
 int LFNIndex::move_subdir(
@@ -372,7 +360,7 @@ int LFNIndex::move_object(
 }
 
 
-static int get_hobject_from_oinfo(const char *dir, const char *file, 
+static int get_hobject_from_oinfo(const char *dir, const char *file,
 				  ghobject_t *o)
 {
   char path[PATH_MAX];
@@ -432,7 +420,7 @@ int LFNIndex::list_objects(const vector<string> &to_list, int max_objs,
 	}
 	if (index_version == HASH_INDEX_TAG)
 	  get_hobject_from_oinfo(to_list_path.c_str(), short_name.c_str(), &obj);
-	  
+
 	out->insert(pair<string, ghobject_t>(short_name, obj));
 	++listed;
       } else {
@@ -517,7 +505,7 @@ int LFNIndex::path_exists(const vector<string> &to_check, int *exists)
 }
 
 int LFNIndex::add_attr_path(const vector<string> &path,
-			    const string &attr_name, 
+			    const string &attr_name,
 			    bufferlist &attr_value)
 {
   string full_path = get_full_path_subdir(path);
@@ -528,7 +516,7 @@ int LFNIndex::add_attr_path(const vector<string> &path,
 }
 
 int LFNIndex::get_attr_path(const vector<string> &path,
-			    const string &attr_name, 
+			    const string &attr_name,
 			    bufferlist &attr_value)
 {
   string full_path = get_full_path_subdir(path);
@@ -562,7 +550,7 @@ int LFNIndex::remove_attr_path(const vector<string> &path,
   maybe_inject_failure();
   return chain_removexattr(full_path.c_str(), mangled_attr_name.c_str());
 }
-  
+
 string LFNIndex::lfn_generate_object_name_keyless(const ghobject_t &oid)
 {
   char s[FILENAME_MAX_LEN];
@@ -580,7 +568,7 @@ string LFNIndex::lfn_generate_object_name_keyless(const ghobject_t &oid)
   while (*i && t < end) {
     if (*i == '\\') {
       *t++ = '\\';
-      *t++ = '\\';      
+      *t++ = '\\';
     } else if (*i == '.' && i == oid.hobj.oid.name.c_str()) {  // only escape leading .
       *t++ = '\\';
       *t++ = '.';
@@ -604,7 +592,7 @@ string LFNIndex::lfn_generate_object_name_keyless(const ghobject_t &oid)
 }
 
 static void append_escaped(string::const_iterator begin,
-			   string::const_iterator end, 
+			   string::const_iterator end,
 			   string *out)
 {
   for (string::const_iterator i = begin; i != end; ++i) {
@@ -721,10 +709,10 @@ string LFNIndex::lfn_generate_object_name_poolless(const ghobject_t &oid)
   return full_name;
 }
 
-int LFNIndex::lfn_get_name(const vector<string> &path, 
+int LFNIndex::lfn_get_name(const vector<string> &path,
 			   const ghobject_t &oid,
 			   string *mangled_name, string *out_path,
-			   int *exists)
+			   int *hardlink)
 {
   string subdir_path = get_full_path_subdir(path);
   string full_name = lfn_generate_object_name(oid);
@@ -735,18 +723,18 @@ int LFNIndex::lfn_get_name(const vector<string> &path,
       *mangled_name = full_name;
     if (out_path)
       *out_path = get_full_path(path, full_name);
-    if (exists) {
+    if (hardlink) {
       struct stat buf;
       string full_path = get_full_path(path, full_name);
       maybe_inject_failure();
       r = ::stat(full_path.c_str(), &buf);
       if (r < 0) {
 	if (errno == ENOENT)
-	  *exists = 0;
+	  *hardlink = 0;
 	else
 	  return -errno;
       } else {
-	*exists = 1;
+	*hardlink = buf.st_nlink;
       }
     }
     return 0;
@@ -776,8 +764,8 @@ int LFNIndex::lfn_get_name(const vector<string> &path,
 	*mangled_name = candidate;
       if (out_path)
 	*out_path = candidate_path;
-      if (exists)
-	*exists = 0;
+      if (hardlink)
+	*hardlink = 0;
       return 0;
     }
     assert(r > 0);
@@ -787,8 +775,11 @@ int LFNIndex::lfn_get_name(const vector<string> &path,
 	*mangled_name = candidate;
       if (out_path)
 	*out_path = candidate_path;
-      if (exists)
-	*exists = 1;
+      if (hardlink) {
+	struct stat st;
+	r = ::stat(candidate_path.c_str(), &st);
+	*hardlink = st.st_nlink;
+      }
       return 0;
     }
     r = chain_getxattr(candidate_path.c_str(), get_alt_lfn_attr().c_str(),
@@ -818,8 +809,8 @@ int LFNIndex::lfn_get_name(const vector<string> &path,
 	  *mangled_name = candidate;
 	if (out_path)
 	  *out_path = candidate_path;
-	if (exists)
-	  *exists = 1;
+	if (hardlink)
+	  *hardlink = st.st_nlink;
 	return 0;
       }
     }
@@ -872,8 +863,8 @@ int LFNIndex::lfn_unlink(const vector<string> &path,
     return 0;
   }
   string subdir_path = get_full_path_subdir(path);
-  
-  
+
+
   int i = 0;
   for ( ; ; ++i) {
     string candidate = lfn_get_short_name(oid, i);
@@ -1002,9 +993,9 @@ static int parse_object(const char *s, ghobject_t& o)
       o.hobj.snap = CEPH_NOSNAP;
     else if (strncmp(bar+1, "snapdir", 7) == 0)
       o.hobj.snap = CEPH_SNAPDIR;
-    else 
+    else
       o.hobj.snap = strtoull(bar+1, NULL, 16);
-      
+
     uint32_t hobject_hash_input;
     sscanf(hash, "_%X", &hobject_hash_input);
     o.hobj.set_hash(hobject_hash_input);
@@ -1028,7 +1019,7 @@ bool LFNIndex::lfn_parse_object_name_keyless(const string &long_name, ghobject_t
 }
 
 static bool append_unescaped(string::const_iterator begin,
-			     string::const_iterator end, 
+			     string::const_iterator end,
 			     string *out)
 {
   for (string::const_iterator i = begin; i != end; ++i) {
diff --git a/src/os/LFNIndex.h b/src/os/filestore/LFNIndex.h
similarity index 97%
rename from src/os/LFNIndex.h
rename to src/os/filestore/LFNIndex.h
index 41f6c93..8f04407 100644
--- a/src/os/LFNIndex.h
+++ b/src/os/filestore/LFNIndex.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -29,19 +29,19 @@
 
 #include "CollectionIndex.h"
 
-/** 
+/**
  * LFNIndex also encapsulates logic for manipulating
  * subdirectories of of a collection as well as the long filename
  * logic.
  *
  * The protected methods provide machinery for derived classes to
  * manipulate subdirectories and objects.
- *  
+ *
  * The virtual methods are to be overridden to provide the actual
  * hashed layout.
- *  
+ *
  * User must call created when an object is created.
- *  
+ *
  * Syncronization: Calling code must ensure that there are no object
  * creations or deletions during the lifetime of a Path object (except
  * of an object at that path).
@@ -72,7 +72,7 @@
   return -1;					\
   }						\
 
-  
+
 
 class LFNIndex : public CollectionIndex {
   /// Hash digest output size.
@@ -131,7 +131,7 @@ public:
     const char *base_path, ///< [in] path to Index root
     uint32_t index_version,
     double _error_injection_probability=0)
-    : CollectionIndex(collection), 
+    : CollectionIndex(collection),
       base_path(base_path),
       index_version(index_version),
       error_injection_enabled(false),
@@ -175,7 +175,7 @@ public:
   int lookup(
     const ghobject_t &oid,
     IndexedPath *path,
-    int *exist
+    int *hardlink
     );
 
   /// @see CollectionIndex;
@@ -199,7 +199,7 @@ public:
     uint32_t bits,                              //< [in] bits to check
     CollectionIndex* dest                       //< [in] destination index
     ) = 0;
-  
+
   /// @see CollectionIndex
   int split(
     uint32_t match,
@@ -285,17 +285,17 @@ protected:
    * @return Error Code, 0 on success.
    */
   int remove_objects(
-    const vector<string> &dir,             
+    const vector<string> &dir,
     const map<string, ghobject_t> &to_remove,
     map<string, ghobject_t> *remaining
     );
-	
 
-  /** 
+
+  /**
    * Moves contents of from into to.
    *
    * Invalidates mangled names in to.  If interupted, all objects will be
-   * present in to before objects are removed from from.  Ignores EEXIST 
+   * present in to before objects are removed from from.  Ignores EEXIST
    * while linking into to.
    * @return Error Code, 0 on success
    */
@@ -304,7 +304,7 @@ protected:
     const vector<string> &to    ///< [in] Dest subdirectory.
     );
 
-  /** 
+  /**
    * Remove an object from from.
    *
    * Invalidates mangled names in from.
@@ -317,7 +317,7 @@ protected:
 
   /**
    * Gets the filename corresponding to oid in from.
-   * 
+   *
    * The filename may differ between subdirectories.  Furthermore,
    * file creations ore removals in from may invalidate the name.
    * @return Error code on failure, 0 on success
@@ -326,7 +326,7 @@ protected:
     const vector<string> &from, ///< [in] Subdirectory
     const ghobject_t &oid,	///< [in] Object
     string *mangled_name,	///< [out] Filename
-    int *exists			///< [out] 1 if the file exists, else 0
+    int *hardlink		///< [out] hardlink for this file, hardlink=0 mean no-exist
     );
 
   /// do move subdir from from to dest
@@ -394,7 +394,7 @@ protected:
   /// Read into attr_value atribute attr_name on path.
   int get_attr_path(
     const vector<string> &path, ///< [in] Path to read.
-    const string &attr_name, 	///< [in] Attribute to read. 
+    const string &attr_name, 	///< [in] Attribute to read.
     bufferlist &attr_value	///< [out] Attribute value read.
     );
 
@@ -424,7 +424,7 @@ private:
    * @param [in] oid Object for which to get filename.
    * @param [out] mangled_name Filename for oid, pass NULL if not needed.
    * @param [out] full_path Fullpath for oid, pass NULL if not needed.
-   * @param [out] exists 1 if the file exists, 0 otherwise, pass NULL if 
+   * @param [out] hardlink of this file, 0 mean no-exist, pass NULL if
    * not needed
    * @return Error Code, 0 on success.
    */
@@ -433,7 +433,7 @@ private:
     const ghobject_t &oid,
     string *mangled_name,
     string *full_path,
-    int *exists
+    int *hardlink
     );
 
   /// Adjusts path contents when oid is created at name mangled_name.
@@ -453,7 +453,7 @@ private:
   ///Transate a file into and ghobject_t.
   int lfn_translate(
     const vector<string> &path, ///< [in] Path containing the file.
-    const string &short_name,	///< [in] Filename to translate. 
+    const string &short_name,	///< [in] Filename to translate.
     ghobject_t *out		///< [out] Object found.
     ); ///< @return Negative error code on error, 0 if not an object, 1 else
 
diff --git a/src/os/SequencerPosition.h b/src/os/filestore/SequencerPosition.h
similarity index 99%
rename from src/os/SequencerPosition.h
rename to src/os/filestore/SequencerPosition.h
index 38f11f0..c2ecf85 100644
--- a/src/os/SequencerPosition.h
+++ b/src/os/filestore/SequencerPosition.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
 #ifndef __CEPH_OS_SEQUENCERPOSITION_H
diff --git a/src/os/WBThrottle.cc b/src/os/filestore/WBThrottle.cc
similarity index 99%
rename from src/os/WBThrottle.cc
rename to src/os/filestore/WBThrottle.cc
index 04c6922..fb98c97 100644
--- a/src/os/WBThrottle.cc
+++ b/src/os/filestore/WBThrottle.cc
@@ -3,7 +3,7 @@
 
 #include "acconfig.h"
 
-#include "os/WBThrottle.h"
+#include "os/filestore/WBThrottle.h"
 #include "common/perf_counters.h"
 
 WBThrottle::WBThrottle(CephContext *cct) :
@@ -49,7 +49,7 @@ void WBThrottle::start()
     Mutex::Locker l(lock);
     stopping = false;
   }
-  create();
+  create("wb_throttle");
 }
 
 void WBThrottle::stop()
@@ -141,7 +141,7 @@ bool WBThrottle::get_next_should_flush(
     return false;
   assert(!pending_wbs.empty());
   ghobject_t obj(pop_object());
-  
+
   ceph::unordered_map<ghobject_t, pair<PendingWB, FDRef> >::iterator i =
     pending_wbs.find(obj);
   *next = boost::make_tuple(obj, i->second.second, i->second.first);
diff --git a/src/os/WBThrottle.h b/src/os/filestore/WBThrottle.h
similarity index 100%
rename from src/os/WBThrottle.h
rename to src/os/filestore/WBThrottle.h
diff --git a/src/os/XfsFileStoreBackend.cc b/src/os/filestore/XfsFileStoreBackend.cc
similarity index 99%
rename from src/os/XfsFileStoreBackend.cc
rename to src/os/filestore/XfsFileStoreBackend.cc
index cf8bfe1..365692c 100644
--- a/src/os/XfsFileStoreBackend.cc
+++ b/src/os/filestore/XfsFileStoreBackend.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
diff --git a/src/os/XfsFileStoreBackend.h b/src/os/filestore/XfsFileStoreBackend.h
similarity index 99%
rename from src/os/XfsFileStoreBackend.h
rename to src/os/filestore/XfsFileStoreBackend.h
index 282fc1c..84d4694 100644
--- a/src/os/XfsFileStoreBackend.h
+++ b/src/os/filestore/XfsFileStoreBackend.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
diff --git a/src/os/ZFSFileStoreBackend.cc b/src/os/filestore/ZFSFileStoreBackend.cc
similarity index 100%
rename from src/os/ZFSFileStoreBackend.cc
rename to src/os/filestore/ZFSFileStoreBackend.cc
diff --git a/src/os/ZFSFileStoreBackend.h b/src/os/filestore/ZFSFileStoreBackend.h
similarity index 97%
rename from src/os/ZFSFileStoreBackend.h
rename to src/os/filestore/ZFSFileStoreBackend.h
index 8186d9c..f68b8ab 100644
--- a/src/os/ZFSFileStoreBackend.h
+++ b/src/os/filestore/ZFSFileStoreBackend.h
@@ -6,7 +6,7 @@
 
 #ifdef HAVE_LIBZFS
 #include "GenericFileStoreBackend.h"
-#include "ZFS.h"
+#include "os/fs/ZFS.h"
 
 class ZFSFileStoreBackend : public GenericFileStoreBackend {
 private:
diff --git a/src/os/chain_xattr.cc b/src/os/filestore/chain_xattr.cc
similarity index 99%
rename from src/os/chain_xattr.cc
rename to src/os/filestore/chain_xattr.cc
index 5351abf..28bb87b 100644
--- a/src/os/chain_xattr.cc
+++ b/src/os/filestore/chain_xattr.cc
@@ -288,7 +288,7 @@ int chain_setxattr(const char *fn, const char *name, const void *val, size_t siz
       i++;
     } while (r != -ENODATA);
   }
-  
+
   return ret;
 }
 
@@ -324,7 +324,7 @@ int chain_fsetxattr(int fd, const char *name, const void *val, size_t size, bool
       i++;
     } while (r != -ENODATA);
   }
-  
+
   return ret;
 }
 
diff --git a/src/os/chain_xattr.h b/src/os/filestore/chain_xattr.h
similarity index 100%
rename from src/os/chain_xattr.h
rename to src/os/filestore/chain_xattr.h
diff --git a/src/os/fs/FS.h b/src/os/fs/FS.h
index 941fd14..3941799 100644
--- a/src/os/fs/FS.h
+++ b/src/os/fs/FS.h
@@ -57,13 +57,31 @@ public:
     void *priv;
     int fd;
     vector<iovec> iov;
+    uint64_t offset, length;
+    int rval;
+    bufferlist bl;  ///< write payload (so that it remains stable for duration)
 
-    aio_t(void *p, int f) : priv(p), fd(f) {
+    aio_t(void *p, int f) : priv(p), fd(f), rval(-1000) {
       memset(&iocb, 0, sizeof(iocb));
     }
 
-    void pwritev(uint64_t offset) {
+    void pwritev(uint64_t _offset) {
+      offset = _offset;
       io_prep_pwritev(&iocb, fd, &iov[0], iov.size(), offset);
+      length = 0;
+      for (unsigned u=0; u<iov.size(); ++u)
+	length += iov[u].iov_len;
+    }
+    void pread(uint64_t _offset, uint64_t len) {
+      offset = _offset;
+      length = len;
+      bufferptr p = buffer::create_page_aligned(length);
+      bl.append(p);
+      io_prep_pread(&iocb, fd, p.c_str(), length, offset);
+    }
+
+    int get_return_value() {
+      return rval;
     }
   };
 
@@ -92,13 +110,16 @@ public:
     }
 
     int submit(aio_t &aio, int *retries) {
-      int attempts = 10;
+      // 2^16 * 125us = ~8 seconds, so max sleep is ~16 seconds
+      int attempts = 16;
+      int delay = 125;
       iocb *piocb = &aio.iocb;
       while (true) {
 	int r = io_submit(ctx, 1, &piocb);
 	if (r < 0) {
 	  if (r == -EAGAIN && attempts-- > 0) {
-	    usleep(500);
+	    usleep(delay);
+	    delay *= 2;
 	    (*retries)++;
 	    continue;
 	  }
@@ -122,6 +143,7 @@ public:
       }
       for (int i=0; i<r; ++i) {
 	paio[i] = (aio_t *)event[i].obj;
+	paio[i]->rval = event[i].res;
       }
       return r;
     }
diff --git a/src/os/ZFS.cc b/src/os/fs/ZFS.cc
similarity index 100%
rename from src/os/ZFS.cc
rename to src/os/fs/ZFS.cc
diff --git a/src/os/ZFS.h b/src/os/fs/ZFS.h
similarity index 100%
rename from src/os/ZFS.h
rename to src/os/fs/ZFS.h
diff --git a/src/os/btrfs_ioctl.h b/src/os/fs/btrfs_ioctl.h
similarity index 100%
rename from src/os/btrfs_ioctl.h
rename to src/os/fs/btrfs_ioctl.h
diff --git a/src/os/GenericObjectMap.cc b/src/os/keyvaluestore/GenericObjectMap.cc
similarity index 99%
rename from src/os/GenericObjectMap.cc
rename to src/os/keyvaluestore/GenericObjectMap.cc
index 14f8cd4..3453bc0 100644
--- a/src/os/GenericObjectMap.cc
+++ b/src/os/keyvaluestore/GenericObjectMap.cc
@@ -71,7 +71,7 @@ static void append_escaped(const string &in, string *out)
 
 static bool append_unescaped(string::const_iterator begin,
                              string::const_iterator end,
-                             string *out) 
+                             string *out)
 {
   for (string::const_iterator i = begin; i != end; ++i) {
     if (*i == '%') {
@@ -460,7 +460,7 @@ int GenericObjectMap::GenericObjectMapIteratorImpl::in_complete_region(
 }
 
 /**
- * Moves parent_iter to the next position both out of the complete_region and 
+ * Moves parent_iter to the next position both out of the complete_region and
  * not equal to key_iter.  Then, we set cur_iter to parent_iter if valid and
  * less than key_iter and key_iter otherwise.
  */
diff --git a/src/os/GenericObjectMap.h b/src/os/keyvaluestore/GenericObjectMap.h
similarity index 99%
rename from src/os/GenericObjectMap.h
rename to src/os/keyvaluestore/GenericObjectMap.h
index 62c376c..9417937 100644
--- a/src/os/GenericObjectMap.h
+++ b/src/os/keyvaluestore/GenericObjectMap.h
@@ -25,7 +25,7 @@
 #include <boost/scoped_ptr.hpp>
 
 #include "include/memory.h"
-#include "ObjectMap.h"
+#include "os/ObjectMap.h"
 #include "kv/KeyValueDB.h"
 #include "osd/osd_types.h"
 #include "common/Mutex.h"
diff --git a/src/os/KeyValueStore.cc b/src/os/keyvaluestore/KeyValueStore.cc
similarity index 99%
rename from src/os/KeyValueStore.cc
rename to src/os/keyvaluestore/KeyValueStore.cc
index 81b07d7..5738c50 100644
--- a/src/os/KeyValueStore.cc
+++ b/src/os/keyvaluestore/KeyValueStore.cc
@@ -49,10 +49,6 @@
 #include "common/perf_counters.h"
 #include "common/sync_filesystem.h"
 
-#ifdef HAVE_KINETIC
-#include "KineticStore.h"
-#endif
-
 #include "common/ceph_crypto.h"
 using ceph::crypto::SHA1;
 
@@ -537,7 +533,7 @@ KeyValueStore::KeyValueStore(const std::string &base,
   throttle_ops(g_ceph_context, "keyvaluestore_ops", g_conf->keyvaluestore_queue_max_ops),
   throttle_bytes(g_ceph_context, "keyvaluestore_bytes", g_conf->keyvaluestore_queue_max_bytes),
   op_finisher(g_ceph_context),
-  op_tp(g_ceph_context, "KeyValueStore::op_tp",
+  op_tp(g_ceph_context, "KeyValueStore::op_tp", "tp_kvstore",
         g_conf->keyvaluestore_op_threads, "keyvaluestore_op_threads"),
   op_wq(this, g_conf->keyvaluestore_op_thread_timeout,
         g_conf->keyvaluestore_op_thread_suicide_timeout, &op_tp),
@@ -581,7 +577,7 @@ KeyValueStore::~KeyValueStore()
   g_ceph_context->get_perfcounters_collection()->remove(perf_logger);
 
   delete perf_logger;
-  
+
   if (m_keyvaluestore_do_dump) {
     dump_stop();
   }
@@ -649,7 +645,7 @@ int KeyValueStore::mkfs()
       goto close_fsid_fd;
     }
     if (::fsync(fsid_fd) < 0) {
-      ret = errno;
+      ret = -errno;
       derr << "mkfs: close failed: can't write fsid: "
            << cpp_strerror(ret) << dendl;
       goto close_fsid_fd;
@@ -734,6 +730,7 @@ int KeyValueStore::mkfs()
 int KeyValueStore::read_fsid(int fd, uuid_d *uuid)
 {
   char fsid_str[40];
+  memset(fsid_str, 0, sizeof(fsid_str));
   int ret = safe_read(fd, fsid_str, sizeof(fsid_str));
   if (ret < 0)
     return ret;
@@ -912,7 +909,7 @@ int KeyValueStore::mount()
       goto close_fsid_fd;
     }
   }
-  
+
   superblock.backend = g_conf->keyvaluestore_backend;
   ret = read_superblock();
   if (ret < 0) {
@@ -949,7 +946,7 @@ int KeyValueStore::mount()
       derr << "KeyValueStore::mount backend type "
 	   << superblock.backend << " error" << dendl;
       ret = -1;
-      goto close_fsid_fd;
+      goto close_current_fd;
 
     }
 
@@ -1134,7 +1131,7 @@ void KeyValueStore::op_queue_reserve_throttle(Op *o, ThreadPool::TPHandle *handl
   if (throttle_ops.should_wait(1) ||
     (throttle_bytes.get_current()      // let single large ops through!
     && throttle_bytes.should_wait(o->bytes))) {
-    dout(2) << "waiting " << throttle_ops.get_current() + 1 << " > " << max_ops << " ops || " 
+    dout(2) << "waiting " << throttle_ops.get_current() + 1 << " > " << max_ops << " ops || "
       << throttle_bytes.get_current() + o->bytes << " > " << max_bytes << dendl;
   }
   throttle_ops.get();
@@ -1217,9 +1214,7 @@ int KeyValueStore::_do_transactions(list<Transaction*> &tls, uint64_t op_seq,
   for (list<Transaction*>::iterator p = tls.begin();
        p != tls.end();
        ++p, trans_num++) {
-    r = _do_transaction(**p, bt, handle);
-    if (r < 0)
-      break;
+    _do_transaction(**p, bt, handle);
     if (handle)
       handle->reset_tp_timeout();
   }
@@ -1232,7 +1227,7 @@ int KeyValueStore::_do_transactions(list<Transaction*> &tls, uint64_t op_seq,
   return r;
 }
 
-unsigned KeyValueStore::_do_transaction(Transaction& transaction,
+void KeyValueStore::_do_transaction(Transaction& transaction,
                                         BufferTransaction &t,
                                         ThreadPool::TPHandle *handle)
 {
@@ -1593,18 +1588,17 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
         f.close_section();
         f.flush(*_dout);
         *_dout << dendl;
-        assert(0 == "unexpected error");
 
         if (r == -EMFILE) {
           dump_open_fds(g_ceph_context);
-        }
+        }      
+
+        assert(0 == "unexpected error");
       }
     }
 
     op_num++;
   }
-
-  return 0;  // FIXME count errors
 }
 
 
@@ -1915,7 +1909,7 @@ int KeyValueStore::_generic_write(StripObjectMap::StripObjectHeaderRef header,
 
   int r = t.get_buffer_keys(header, OBJECT_STRIP_PREFIX, keys, &out);
   r = check_get_rc(header->cid, header->oid, r, keys.size() == out.size());
-  if (r < 0) 
+  if (r < 0)
     return r;
 
   uint64_t bl_offset = 0;
@@ -2022,7 +2016,7 @@ int KeyValueStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset,
         lookup_keys.insert(key);
         off_len[key] = make_pair(iter->offset, iter->len);
       }
-    }    
+    }
   }
   r = t.get_buffer_keys(header, OBJECT_STRIP_PREFIX,
                         lookup_keys, &values);
diff --git a/src/os/KeyValueStore.h b/src/os/keyvaluestore/KeyValueStore.h
similarity index 98%
rename from src/os/KeyValueStore.h
rename to src/os/keyvaluestore/KeyValueStore.h
index 914ce1d..9e245ee 100644
--- a/src/os/KeyValueStore.h
+++ b/src/os/keyvaluestore/KeyValueStore.h
@@ -28,7 +28,7 @@ using namespace std;
 
 #include "include/assert.h"
 
-#include "ObjectStore.h"
+#include "os/ObjectStore.h"
 
 #include "common/WorkQueue.h"
 #include "common/Finisher.h"
@@ -321,7 +321,7 @@ class KeyValueStore : public ObjectStore,
    public:
     Sequencer *parent;
     Mutex apply_lock;  // for apply mutual exclusion
-    
+
     /// get_max_uncompleted
     bool _get_max_uncompleted(
       uint64_t *seq ///< [out] max uncompleted seq
@@ -516,20 +516,6 @@ class KeyValueStore : public ObjectStore,
     return false;
   }
 
-  /**
-   ** set_allow_sharded_objects()
-   **
-   ** Before sharded ghobject_t can be specified this function must be called
-   **/
-  void set_allow_sharded_objects() {}
-
-  /**
-   ** get_allow_sharded_objects()
-   **
-   ** return value: true if set_allow_sharded_objects() called, otherwise false
-   **/
-  bool get_allow_sharded_objects() {return false;}
-
   void collect_metadata(map<string,string> *pm);
 
   int statfs(struct statfs *buf);
@@ -540,7 +526,7 @@ class KeyValueStore : public ObjectStore,
   int do_transactions(list<Transaction*> &tls, uint64_t op_seq) {
     return _do_transactions(tls, op_seq, 0);
   }
-  unsigned _do_transaction(Transaction& transaction,
+  void _do_transaction(Transaction& transaction,
                            BufferTransaction &bt,
                            ThreadPool::TPHandle *handle);
 
diff --git a/src/os/newstore/NewStore.cc b/src/os/kstore/KStore.cc
similarity index 50%
rename from src/os/newstore/NewStore.cc
rename to src/os/kstore/KStore.cc
index e1b4d73..c9fbf4a 100644
--- a/src/os/newstore/NewStore.cc
+++ b/src/os/kstore/KStore.cc
@@ -19,64 +19,65 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "NewStore.h"
+#include "KStore.h"
+#include "kv.h"
 #include "include/compat.h"
 #include "include/stringify.h"
 #include "common/errno.h"
 #include "common/safe_io.h"
 
-#define dout_subsys ceph_subsys_newstore
+
+#define dout_subsys ceph_subsys_kstore
 
 /*
 
   TODO:
 
-  * collection_list must flush pending db work
-  * multiple fragments per object (with configurable size.. maybe 1 or 2 mb default?)
-    * read path should be totally generic (handle any fragment pattern)
-    * write path should ideally tolerate any fragment pattern, but only generate a fixed layout (since the tunable may be changed over time).
-  * rocksdb: use db_paths (db/ and db.bulk/ ?)
-  * rocksdb: auto-detect use_fsync option when not xfs or btrfs
-  * avoid mtime updates when doing open-by-handle
-  * fid xattr backpointer
-  * inline first fsync_item in TransContext to void allocation?
-  * refcounted fragments (for efficient clone)
+  * superblock, features
+  * refcounted extents (for efficient clone)
 
  */
 
 const string PREFIX_SUPER = "S"; // field -> value
 const string PREFIX_COLL = "C"; // collection name -> (nothing)
 const string PREFIX_OBJ = "O";  // object name -> onode
-const string PREFIX_OVERLAY = "V"; // u64 + offset -> value
+const string PREFIX_DATA = "D"; // nid + offset -> data
 const string PREFIX_OMAP = "M"; // u64 + keyname -> value
-const string PREFIX_WAL = "L";  // write ahead log
 
+/*
+ * object name key structure
+ *
+ * 2 chars: shard (-- for none, or hex digit, so that we sort properly)
+ * encoded u64: poolid + 2^63 (so that it sorts properly)
+ * encoded u32: hash (bit reversed)
+ *
+ * 1 char: '.'
+ *
+ * escaped string: namespace
+ *
+ * 1 char: '<', '=', or '>'.  if =, then object key == object name, and
+ *         we are followed just by the key.  otherwise, we are followed by
+ *         the key and then the object name.
+ * escaped string: key
+ * escaped string: object name (unless '=' above)
+ *
+ * encoded u64: snap
+ * encoded u64: generation
+ */
 
 /*
- * key
+ * string encoding in the key
  *
  * The key string needs to lexicographically sort the same way that
- * ghobject_t does.  We do this by escaping anything <= to '%' with %
+ * ghobject_t does.  We do this by escaping anything <= to '#' with #
  * plus a 2 digit hex string, and anything >= '~' with ~ plus the two
  * hex digits.
  *
- * We use ! as a separator for strings; this works because it is < %
+ * We use ! as a terminator for strings; this works because it is < #
  * and will get escaped if it is present in the string.
  *
- * For the fixed length numeric fields, we just use hex and '.' as a
- * convenient visual separator.  Two oddities here:
- *
- *   1. for the -1 shard value we use --; it's the only negative value
- *      and it sorts < 0 that way.
- *
- *   2. for the pool value, we add 2^63 so that it sorts correctly
- *
- * We could do something much more compact here, but it would be less
- * readable by humans.  :/
  */
 
-const string KEY_SEP_S = "!";
-
 static void append_escaped(const string &in, string *out)
 {
   char hexbyte[8];
@@ -91,6 +92,7 @@ static void append_escaped(const string &in, string *out)
       out->push_back(*i);
     }
   }
+  out->push_back('!');
 }
 
 static int decode_escaped(const char *p, string *out)
@@ -111,8 +113,82 @@ static int decode_escaped(const char *p, string *out)
   return p - orig_p;
 }
 
-// here is a sample (large) key
-// --.7fffffffffffffff.B9FA767A.!0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [...]
+// some things we encode in binary (as le32 or le64); print the
+// resulting key strings nicely
+static string pretty_binary_string(const string& in)
+{
+  char buf[10];
+  string out;
+  out.reserve(in.length() * 3);
+  enum { NONE, HEX, STRING } mode = NONE;
+  unsigned from = 0, i;
+  for (i=0; i < in.length(); ++i) {
+    if ((in[i] < 32 || (unsigned char)in[i] > 126) ||
+	(mode == HEX && in.length() - i >= 4 &&
+	 ((in[i] < 32 || (unsigned char)in[i] > 126) ||
+	  (in[i+1] < 32 || (unsigned char)in[i+1] > 126) ||
+	  (in[i+2] < 32 || (unsigned char)in[i+2] > 126) ||
+	  (in[i+3] < 32 || (unsigned char)in[i+3] > 126)))) {
+      if (mode == STRING) {
+	out.append(in.substr(from, i - from));
+	out.push_back('\'');
+      }
+      if (mode != HEX) {
+	out.append("0x");
+	mode = HEX;
+      }
+      if (in.length() - i >= 4) {
+	// print a whole u32 at once
+	snprintf(buf, sizeof(buf), "%08x",
+		 (uint32_t)(((unsigned char)in[i] << 24) |
+			    ((unsigned char)in[i+1] << 16) |
+			    ((unsigned char)in[i+2] << 8) |
+			    ((unsigned char)in[i+3] << 0)));
+	i += 3;
+      } else {
+	snprintf(buf, sizeof(buf), "%02x", (int)(unsigned char)in[i]);
+      }
+      out.append(buf);
+    } else {
+      if (mode != STRING) {
+	out.push_back('\'');
+	mode = STRING;
+	from = i;
+      }
+    }
+  }
+  if (mode == STRING) {
+    out.append(in.substr(from, i - from));
+    out.push_back('\'');
+  }
+  return out;
+}
+
+static void _key_encode_shard(shard_id_t shard, string *key)
+{
+  // make field ordering match with ghobject_t compare operations
+  if (shard == shard_id_t::NO_SHARD) {
+    // otherwise ff will sort *after* 0, not before.
+    key->append("--");
+  } else {
+    char buf[32];
+    snprintf(buf, sizeof(buf), "%02x", (int)shard);
+    key->append(buf);
+  }
+}
+static const char *_key_decode_shard(const char *key, shard_id_t *pshard)
+{
+  if (key[0] == '-') {
+    *pshard = shard_id_t::NO_SHARD;
+  } else {
+    unsigned shard;
+    int r = sscanf(key, "%x", &shard);
+    if (r < 1)
+      return NULL;
+    *pshard = shard_id_t(shard);
+  }
+  return key + 2;
+}
 
 static void get_coll_key_range(const coll_t& cid, int bits,
 			       string *temp_start, string *temp_end,
@@ -125,56 +201,46 @@ static void get_coll_key_range(const coll_t& cid, int bits,
 
   spg_t pgid;
   if (cid.is_pg(&pgid)) {
-    char buf[PATH_MAX];
-
-    // make field ordering match with ghobject_t compare operations
-    if (pgid.shard == shard_id_t::NO_SHARD) {
-      // otherwise ff will sort *after* 0, not before.
-      *start = "--";
-    } else {
-      snprintf(buf, sizeof(buf), "%02x", (int)pgid.shard);
-      start->append(buf);
-    }
+    _key_encode_shard(pgid.shard, start);
     *end = *start;
     *temp_start = *start;
     *temp_end = *start;
 
-    snprintf(buf, sizeof(buf), ".%016llx.%08x.",
-	     (unsigned long long)(pgid.pool() + 0x8000000000000000ull),
-	     (unsigned)hobject_t::_reverse_bits(pgid.ps()));
-    start->append(buf);
-    snprintf(buf, sizeof(buf), ".%016llx.%08x.",
-	     (unsigned long long)((-2ll - pgid.pool()) + 0x8000000000000000ull),
-	     (unsigned)hobject_t::_reverse_bits(pgid.ps()));
-    temp_start->append(buf);
-
-    uint64_t end_hash = hobject_t::_reverse_bits(pgid.ps());
-    end_hash += (1ull << (32-bits));
-    if (end_hash > 0xffffffff) {
-      snprintf(buf, sizeof(buf), ".%016llx.gggggggg.",
-	       (unsigned long long)(pgid.pool() + 0x8000000000000000ull));
-      end->append(buf);
-      snprintf(buf, sizeof(buf), ".%016llx.gggggggg.",
-	       (unsigned long long)((-2ll - pgid.pool()) + 0x8000000000000000ull));
-      temp_end->append(buf);
+    _key_encode_u64(pgid.pool() + 0x8000000000000000ull, start);
+    _key_encode_u64((-2ll - pgid.pool()) + 0x8000000000000000ull, temp_start);
+    _key_encode_u32(hobject_t::_reverse_bits(pgid.ps()), start);
+    _key_encode_u32(hobject_t::_reverse_bits(pgid.ps()), temp_start);
+    start->append(".");
+    temp_start->append(".");
+
+    _key_encode_u64(pgid.pool() + 0x8000000000000000ull, end);
+    _key_encode_u64((-2ll - pgid.pool()) + 0x8000000000000000ull, temp_end);
+
+    uint64_t end_hash =
+      hobject_t::_reverse_bits(pgid.ps()) + (1ull << (32-bits));
+    if (end_hash <= 0xffffffffull) {
+      _key_encode_u32(end_hash, end);
+      _key_encode_u32(end_hash, temp_end);
+      end->append(".");
+      temp_end->append(".");
     } else {
-      snprintf(buf, sizeof(buf), ".%016llx.%08x.",
-	       (unsigned long long)(pgid.pool() + 0x8000000000000000ull),
-	       (unsigned)end_hash);
-      end->append(buf);
-      snprintf(buf, sizeof(buf), ".%016llx.%08x.",
-	       (unsigned long long)((-2ll - pgid.pool()) + 0x8000000000000000ull),
-	       (unsigned)end_hash);
-      temp_end->append(buf);
+      _key_encode_u32(0xffffffff, end);
+      _key_encode_u32(0xffffffff, temp_end);
+      end->append(":");
+      temp_end->append(":");
     }
-  } else if (cid.is_meta()) {
-    *start = "--.7fffffffffffffff.00000000.";
-    *end =   "--.7fffffffffffffff.gggggggg.";
+  } else {
+    _key_encode_shard(shard_id_t::NO_SHARD, start);
+    _key_encode_u64(-1ull + 0x8000000000000000ull, start);
+    *end = *start;
+    _key_encode_u32(0, start);
+    start->append(".");
+    _key_encode_u32(0xffffffff, end);
+    end->append(":");
+
     // no separate temp section
     *temp_start = *end;
     *temp_end = *end;
-  } else {
-    assert(0);
   }
 }
 
@@ -182,41 +248,39 @@ static int get_key_object(const string& key, ghobject_t *oid);
 
 static void get_object_key(const ghobject_t& oid, string *key)
 {
-  char buf[PATH_MAX];
-  char *t = buf;
-  char *end = t + sizeof(buf);
-
   key->clear();
 
-  // make field ordering match with ghobject_t compare operations
-  if (oid.shard_id == shard_id_t::NO_SHARD) {
-    // otherwise ff will sort *after* 0, not before.
-    *key = "--";
-  } else {
-    snprintf(buf, sizeof(buf), "%02x", (int)oid.shard_id);
-    key->append(buf);
-  }
-
-  t += snprintf(t, end - t, ".%016llx.%.*x.",
-		(unsigned long long)(oid.hobj.pool + 0x8000000000000000ull),
-		(int)(sizeof(oid.hobj.get_hash())*2),
-		(uint32_t)oid.hobj.get_bitwise_key_u32());
-  key->append(buf);
+  _key_encode_shard(oid.shard_id, key);
+  _key_encode_u64(oid.hobj.pool + 0x8000000000000000ull, key);
+  _key_encode_u32(oid.hobj.get_bitwise_key_u32(), key);
+  key->append(".");
 
   append_escaped(oid.hobj.nspace, key);
-  key->append(KEY_SEP_S);
-
-  append_escaped(oid.hobj.get_effective_key(), key);
-  key->append(KEY_SEP_S);
 
-  append_escaped(oid.hobj.oid.name, key);
-  key->append(KEY_SEP_S);
+  if (oid.hobj.get_key().length()) {
+    // is a key... could be < = or >.
+    // (ASCII chars < = and > sort in that order, yay)
+    if (oid.hobj.get_key() < oid.hobj.oid.name) {
+      key->append("<");
+      append_escaped(oid.hobj.get_key(), key);
+      append_escaped(oid.hobj.oid.name, key);
+    } else if (oid.hobj.get_key() > oid.hobj.oid.name) {
+      key->append(">");
+      append_escaped(oid.hobj.get_key(), key);
+      append_escaped(oid.hobj.oid.name, key);
+    } else {
+      // same as no key
+      key->append("=");
+      append_escaped(oid.hobj.oid.name, key);
+    }
+  } else {
+    // no key
+    key->append("=");
+    append_escaped(oid.hobj.oid.name, key);
+  }
 
-  t = buf;
-  t += snprintf(t, end - t, "%016llx.%016llx",
-		(long long unsigned)oid.hobj.snap,
-		(long long unsigned)oid.generation);
-  key->append(buf);
+  _key_encode_u64(oid.hobj.snap, key);
+  _key_encode_u64(oid.generation, key);
 
   // sanity check
   if (true) {
@@ -224,7 +288,7 @@ static void get_object_key(const ghobject_t& oid, string *key)
     int r = get_key_object(*key, &t);
     if (r || t != oid) {
       derr << "  r " << r << dendl;
-      derr << "key " << *key << dendl;
+      derr << "key " << pretty_binary_string(*key) << dendl;
       derr << "oid " << oid << dendl;
       derr << "  t " << t << dendl;
       assert(t == oid);
@@ -237,129 +301,138 @@ static int get_key_object(const string& key, ghobject_t *oid)
   int r;
   const char *p = key.c_str();
 
-  if (key[0] == '-') {
-    oid->shard_id = shard_id_t::NO_SHARD;
-  } else {
-    unsigned shard;
-    r = sscanf(p, "%x", &shard);
-    if (r < 1)
-      return -1;
-    oid->shard_id = shard_id_t(shard);
-  }
-  if (p[2] != '.' || p[19] != '.' || p[28] != '.')
-    return -2;
+  p = _key_decode_shard(p, &oid->shard_id);
 
-  unsigned hash;
   uint64_t pool;
-  r = sscanf(p + 3, "%llx.%x", (unsigned long long*)&pool, &hash);
-  if (r < 2)
-    return -3;
-  oid->hobj.pool = pool - 0x8000000000000000;
+  p = _key_decode_u64(p, &pool);
+  oid->hobj.pool = pool - 0x8000000000000000ull;
+
+  unsigned hash;
+  p = _key_decode_u32(p, &hash);
   oid->hobj.set_bitwise_key_u32(hash);
-  p += 3 + 2 + 16 + 8;
+  if (*p != '.')
+    return -5;
+  ++p;
 
   r = decode_escaped(p, &oid->hobj.nspace);
   if (r < 0)
-    return -4;
-  p += r + 1;
-  string okey;
-  r = decode_escaped(p, &okey);
-  if (r < 0)
-    return -5;
-  p += r + 1;
-  r = decode_escaped(p, &oid->hobj.oid.name);
-  if (r < 0)
     return -6;
   p += r + 1;
 
-  oid->hobj.set_key(okey);
+  if (*p == '=') {
+    // no key
+    ++p;
+    r = decode_escaped(p, &oid->hobj.oid.name);
+    if (r < 0)
+      return -7;
+    p += r + 1;
+  } else if (*p == '<' || *p == '>') {
+    // key + name
+    ++p;
+    string okey;
+    r = decode_escaped(p, &okey);
+    if (r < 0)
+      return -8;
+    p += r + 1;
+    r = decode_escaped(p, &oid->hobj.oid.name);
+    if (r < 0)
+      return -9;
+    p += r + 1;
+    oid->hobj.set_key(okey);
+  } else {
+    // malformed
+    return -10;
+  }
+
+  p = _key_decode_u64(p, &oid->hobj.snap.val);
+  p = _key_decode_u64(p, &oid->generation);
+  if (*p) {
+    // if we get something other than a null terminator here, 
+    // something goes wrong.
+    return -12;
+  }
 
-  r = sscanf(p, "%llx.%llx", (unsigned long long*)&oid->hobj.snap,
-	     (unsigned long long*)&oid->generation);
-  if (r < 2)
-    return -7;
   return 0;
 }
 
 
-void get_overlay_key(uint64_t nid, uint64_t offset, string *out)
+static void get_data_key(uint64_t nid, uint64_t offset, string *out)
 {
-  char buf[64];
-  // note: these don't have to sort by nid; no need to pad 0's
-  snprintf(buf, sizeof(buf), "%llx %016llx", (unsigned long long)nid,
-	   (unsigned long long)offset);
-  *out = buf;
+  _key_encode_u64(nid, out);
+  _key_encode_u64(offset, out);
 }
 
 // '-' < '.' < '~'
-void get_omap_header(uint64_t id, string *out)
+static void get_omap_header(uint64_t id, string *out)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%016llx-", (unsigned long long)id);
-  *out = buf;
+  _key_encode_u64(id, out);
+  out->push_back('-');
 }
 
 // hmm, I don't think there's any need to escape the user key since we
 // have a clean prefix.
-void get_omap_key(uint64_t id, const string& key, string *out)
+static void get_omap_key(uint64_t id, const string& key, string *out)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%016llx.", (unsigned long long)id);
-  *out = buf;
+  _key_encode_u64(id, out);
+  out->push_back('.');
   out->append(key);
 }
 
-void rewrite_omap_key(uint64_t id, string old, string *out)
+static void rewrite_omap_key(uint64_t id, string old, string *out)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%016llx", (unsigned long long)id);
-  *out = buf;
-  out->append(old.substr(16));
+  _key_encode_u64(id, out);
+  out->append(old.substr(out->length()));
 }
 
-void decode_omap_key(const string& key, string *user_key)
+static void decode_omap_key(const string& key, string *user_key)
 {
-  *user_key = key.substr(17);
+  *user_key = key.substr(sizeof(uint64_t) + 1);
 }
 
-void get_omap_tail(uint64_t id, string *out)
+static void get_omap_tail(uint64_t id, string *out)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%016llx~", (unsigned long long)id);
-  *out = buf;
+  _key_encode_u64(id, out);
+  out->push_back('~');
 }
 
-void get_wal_key(uint64_t seq, string *out)
-{
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%016llx", (unsigned long long)seq);
-  *out = buf;
-}
+
 
 // Onode
 
-NewStore::Onode::Onode(const ghobject_t& o, const string& k)
+#undef dout_prefix
+#define dout_prefix *_dout << "kstore.onode(" << this << ") "
+
+KStore::Onode::Onode(const ghobject_t& o, const string& k)
   : nref(0),
     oid(o),
     key(k),
     dirty(false),
     exists(true),
-    flush_lock("NewStore::Onode::flush_lock") {
+    flush_lock("KStore::Onode::flush_lock") {
+}
+
+void KStore::Onode::flush()
+{
+  Mutex::Locker l(flush_lock);
+  dout(20) << __func__ << " " << flush_txns << dendl;
+  while (!flush_txns.empty())
+    flush_cond.Wait(flush_lock);
+  dout(20) << __func__ << " done" << dendl;
 }
 
 // OnodeHashLRU
 
 #undef dout_prefix
-#define dout_prefix *_dout << "newstore.lru(" << this << ") "
+#define dout_prefix *_dout << "kstore.lru(" << this << ") "
 
-void NewStore::OnodeHashLRU::_touch(OnodeRef o)
+void KStore::OnodeHashLRU::_touch(OnodeRef o)
 {
   lru_list_t::iterator p = lru.iterator_to(*o);
   lru.erase(p);
   lru.push_front(*o);
 }
 
-void NewStore::OnodeHashLRU::add(const ghobject_t& oid, OnodeRef o)
+void KStore::OnodeHashLRU::add(const ghobject_t& oid, OnodeRef o)
 {
   Mutex::Locker l(lock);
   dout(30) << __func__ << " " << oid << " " << o << dendl;
@@ -368,7 +441,7 @@ void NewStore::OnodeHashLRU::add(const ghobject_t& oid, OnodeRef o)
   lru.push_back(*o);
 }
 
-NewStore::OnodeRef NewStore::OnodeHashLRU::lookup(const ghobject_t& oid)
+KStore::OnodeRef KStore::OnodeHashLRU::lookup(const ghobject_t& oid)
 {
   Mutex::Locker l(lock);
   dout(30) << __func__ << dendl;
@@ -382,7 +455,7 @@ NewStore::OnodeRef NewStore::OnodeHashLRU::lookup(const ghobject_t& oid)
   return p->second;
 }
 
-void NewStore::OnodeHashLRU::clear()
+void KStore::OnodeHashLRU::clear()
 {
   Mutex::Locker l(lock);
   dout(10) << __func__ << dendl;
@@ -390,7 +463,7 @@ void NewStore::OnodeHashLRU::clear()
   onode_map.clear();
 }
 
-void NewStore::OnodeHashLRU::remove(const ghobject_t& oid)
+void KStore::OnodeHashLRU::remove(const ghobject_t& oid)
 {
   Mutex::Locker l(lock);
   ceph::unordered_map<ghobject_t,OnodeRef>::iterator p = onode_map.find(oid);
@@ -404,7 +477,7 @@ void NewStore::OnodeHashLRU::remove(const ghobject_t& oid)
   onode_map.erase(p);
 }
 
-void NewStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
+void KStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
 				    const ghobject_t& new_oid)
 {
   Mutex::Locker l(lock);
@@ -419,12 +492,21 @@ void NewStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
     lru.erase(p);
     onode_map.erase(pn);
   }
-  onode_map.insert(make_pair(new_oid, po->second));
-  _touch(po->second);
-  onode_map.erase(po);
+  OnodeRef o = po->second;
+
+  // install a non-existent onode it its place
+  po->second.reset(new Onode(old_oid, o->key));
+  po->second->exists = false;
+  lru.push_back(*po->second);
+
+  // fix oid, key
+  onode_map.insert(make_pair(new_oid, o));
+  _touch(o);
+  o->oid = new_oid;
+  get_object_key(new_oid, &o->key);
 }
 
-bool NewStore::OnodeHashLRU::get_next(
+bool KStore::OnodeHashLRU::get_next(
   const ghobject_t& after,
   pair<ghobject_t,OnodeRef> *next)
 {
@@ -454,7 +536,7 @@ bool NewStore::OnodeHashLRU::get_next(
   return true;
 }
 
-int NewStore::OnodeHashLRU::trim(int max)
+int KStore::OnodeHashLRU::trim(int max)
 {
   Mutex::Locker l(lock);
   dout(20) << __func__ << " max " << max
@@ -493,17 +575,17 @@ int NewStore::OnodeHashLRU::trim(int max)
 // Collection
 
 #undef dout_prefix
-#define dout_prefix *_dout << "newstore(" << store->path << ").collection(" << cid << ") "
+#define dout_prefix *_dout << "kstore(" << store->path << ").collection(" << cid << ") "
 
-NewStore::Collection::Collection(NewStore *ns, coll_t c)
+KStore::Collection::Collection(KStore *ns, coll_t c)
   : store(ns),
     cid(c),
-    lock("NewStore::Collection::lock"),
+    lock("KStore::Collection::lock"),
     onode_map()
 {
 }
 
-NewStore::OnodeRef NewStore::Collection::get_onode(
+KStore::OnodeRef KStore::Collection::get_onode(
   const ghobject_t& oid,
   bool create)
 {
@@ -525,7 +607,8 @@ NewStore::OnodeRef NewStore::Collection::get_onode(
   string key;
   get_object_key(oid, &key);
 
-  dout(20) << __func__ << " oid " << oid << " key '" << key << "'" << dendl;
+  dout(20) << __func__ << " oid " << oid << " key "
+	   << pretty_binary_string(key) << dendl;
 
   bufferlist v;
   int r = store->db->get(PREFIX_OBJ, key, &v);
@@ -556,87 +639,49 @@ NewStore::OnodeRef NewStore::Collection::get_onode(
 // =======================================================
 
 #undef dout_prefix
-#define dout_prefix *_dout << "newstore(" << path << ") "
+#define dout_prefix *_dout << "kstore(" << path << ") "
 
-
-NewStore::NewStore(CephContext *cct, const string& path)
+KStore::KStore(CephContext *cct, const string& path)
   : ObjectStore(path),
     cct(cct),
     db(NULL),
-    fs(NULL),
     path_fd(-1),
     fsid_fd(-1),
-    frag_fd(-1),
-    fset_fd(-1),
     mounted(false),
-    coll_lock("NewStore::coll_lock"),
-    fid_lock("NewStore::fid_lock"),
-    nid_lock("NewStore::nid_lock"),
+    coll_lock("KStore::coll_lock"),
+    nid_lock("KStore::nid_lock"),
     nid_max(0),
-    throttle_ops(cct, "newstore_max_ops", cct->_conf->newstore_max_ops),
-    throttle_bytes(cct, "newstore_max_bytes", cct->_conf->newstore_max_bytes),
-    throttle_wal_ops(cct, "newstore_wal_max_ops",
-		     cct->_conf->newstore_max_ops +
-		     cct->_conf->newstore_wal_max_ops),
-    throttle_wal_bytes(cct, "newstore_wal_max_bytes",
-		       cct->_conf->newstore_max_bytes +
-		       cct->_conf->newstore_wal_max_bytes),
-    wal_lock("NewStore::wal_lock"),
-    wal_seq(0),
-    wal_tp(cct,
-	   "NewStore::wal_tp",
-	   cct->_conf->newstore_wal_threads,
-	   "newstore_wal_threads"),
-    wal_wq(this,
-	     cct->_conf->newstore_wal_thread_timeout,
-	     cct->_conf->newstore_wal_thread_suicide_timeout,
-	     &wal_tp),
+    throttle_ops(cct, "kstore_max_ops", cct->_conf->kstore_max_ops),
+    throttle_bytes(cct, "kstore_max_bytes", cct->_conf->kstore_max_bytes),
     finisher(cct),
-    fsync_tp(cct,
-	     "NewStore::fsync_tp",
-	     cct->_conf->newstore_fsync_threads,
-	     "newstore_fsync_threads"),
-    fsync_wq(this,
-	     cct->_conf->newstore_fsync_thread_timeout,
-	     cct->_conf->newstore_fsync_thread_suicide_timeout,
-	     &fsync_tp),
-    aio_thread(this),
-    aio_stop(false),
-    aio_queue(cct->_conf->newstore_aio_max_queue_depth),
     kv_sync_thread(this),
-    kv_lock("NewStore::kv_lock"),
+    kv_lock("KStore::kv_lock"),
     kv_stop(false),
     logger(NULL),
-    reap_lock("NewStore::reap_lock")
+    reap_lock("KStore::reap_lock")
 {
   _init_logger();
 }
 
-NewStore::~NewStore()
+KStore::~KStore()
 {
   _shutdown_logger();
   assert(!mounted);
   assert(db == NULL);
   assert(fsid_fd < 0);
-  assert(frag_fd < 0);
 }
 
-void NewStore::_init_logger()
+void KStore::_init_logger()
 {
   // XXX
 }
 
-void NewStore::_shutdown_logger()
+void KStore::_shutdown_logger()
 {
   // XXX
 }
 
-int NewStore::peek_journal_fsid(uuid_d *fsid)
-{
-  return 0;
-}
-
-int NewStore::_open_path()
+int KStore::_open_path()
 {
   assert(path_fd < 0);
   path_fd = ::open(path.c_str(), O_DIRECTORY);
@@ -646,67 +691,16 @@ int NewStore::_open_path()
 	 << dendl;
     return r;
   }
-  assert(fs == NULL);
-  fs = FS::create(path_fd);
-  dout(1) << __func__ << " using fs driver '" << fs->get_name() << "'" << dendl;
   return 0;
 }
 
-void NewStore::_close_path()
+void KStore::_close_path()
 {
   VOID_TEMP_FAILURE_RETRY(::close(path_fd));
   path_fd = -1;
-  delete fs;
-  fs = NULL;
-}
-
-int NewStore::_open_frag()
-{
-  assert(frag_fd < 0);
-  frag_fd = ::openat(path_fd, "fragments", O_DIRECTORY);
-  if (frag_fd < 0) {
-    int r = -errno;
-    derr << __func__ << " cannot open " << path << "/fragments: "
-	 << cpp_strerror(r) << dendl;
-    return r;
-  }
-  return 0;
-}
-
-int NewStore::_create_frag()
-{
-  assert(frag_fd < 0);
-  frag_fd = ::openat(path_fd, "fragments", O_DIRECTORY);
-  if (frag_fd < 0 && errno == ENOENT) {
-    int r = ::mkdirat(path_fd, "fragments", 0755);
-    if (r < 0) {
-      r = -errno;
-      derr << __func__ << " cannot create " << path << "/fragments: "
-	   << cpp_strerror(r) << dendl;
-      return r;
-    }
-    frag_fd = ::openat(path_fd, "fragments", O_DIRECTORY);
-  }
-  if (frag_fd < 0) {
-    int r = -errno;
-    derr << __func__ << " cannot open created " << path << "/fragments: "
-	 << cpp_strerror(r) << dendl;
-    return r;
-  }
-  return 0;
 }
 
-void NewStore::_close_frag()
-{
-  if (fset_fd >= 0) {
-    VOID_TEMP_FAILURE_RETRY(::close(fset_fd));
-    fset_fd = -1;
-  }
-  VOID_TEMP_FAILURE_RETRY(::close(frag_fd));
-  frag_fd = -1;
-}
-
-int NewStore::_open_fsid(bool create)
+int KStore::_open_fsid(bool create)
 {
   assert(fsid_fd < 0);
   int flags = O_RDWR;
@@ -721,20 +715,26 @@ int NewStore::_open_fsid(bool create)
   return 0;
 }
 
-int NewStore::_read_fsid(uuid_d *uuid)
+int KStore::_read_fsid(uuid_d *uuid)
 {
   char fsid_str[40];
   int ret = safe_read(fsid_fd, fsid_str, sizeof(fsid_str));
-  if (ret < 0)
+  if (ret < 0) {
+    derr << __func__ << " failed: " << cpp_strerror(ret) << dendl;
     return ret;
+  }
   if (ret > 36)
     fsid_str[36] = 0;
-  if (!uuid->parse(fsid_str))
+  else
+    fsid_str[ret] = 0;
+  if (!uuid->parse(fsid_str)) {
+    derr << __func__ << " unparsable uuid " << fsid_str << dendl;
     return -EINVAL;
+  }
   return 0;
 }
 
-int NewStore::_write_fsid()
+int KStore::_write_fsid()
 {
   int r = ::ftruncate(fsid_fd, 0);
   if (r < 0) {
@@ -750,19 +750,20 @@ int NewStore::_write_fsid()
   }
   r = ::fsync(fsid_fd);
   if (r < 0) {
+    r = -errno;
     derr << __func__ << " fsid fsync failed: " << cpp_strerror(r) << dendl;
     return r;
   }
   return 0;
 }
 
-void NewStore::_close_fsid()
+void KStore::_close_fsid()
 {
   VOID_TEMP_FAILURE_RETRY(::close(fsid_fd));
   fsid_fd = -1;
 }
 
-int NewStore::_lock_fsid()
+int KStore::_lock_fsid()
 {
   struct flock l;
   memset(&l, 0, sizeof(l));
@@ -781,7 +782,7 @@ int NewStore::_lock_fsid()
   return 0;
 }
 
-bool NewStore::test_mount_in_use()
+bool KStore::test_mount_in_use()
 {
   // most error conditions mean the mount is not in use (e.g., because
   // it doesn't exist).  only if we fail to lock do we conclude it is
@@ -795,33 +796,68 @@ bool NewStore::test_mount_in_use()
     goto out_path;
   r = _lock_fsid();
   if (r < 0)
-    ret = true; // if we can't lock, it is in used
+    ret = true; // if we can't lock, it is in use
   _close_fsid();
  out_path:
   _close_path();
   return ret;
 }
 
-int NewStore::_open_db(bool create)
+int KStore::_open_db(bool create)
 {
+  int r;
   assert(!db);
   char fn[PATH_MAX];
   snprintf(fn, sizeof(fn), "%s/db", path.c_str());
+
+  string kv_backend;
+  if (create) {
+    kv_backend = g_conf->kstore_backend;
+  } else {
+    r = read_meta("kv_backend", &kv_backend);
+    if (r < 0) {
+      derr << __func__ << " uanble to read 'kv_backend' meta" << dendl;
+      return -EIO;
+    }
+  }
+  dout(10) << __func__ << " kv_backend = " << kv_backend << dendl;
+
+  if (create) {
+    int r = ::mkdir(fn, 0755);
+    if (r < 0)
+      r = -errno;
+    if (r < 0 && r != -EEXIST) {
+      derr << __func__ << " failed to create " << fn << ": " << cpp_strerror(r)
+	   << dendl;
+      return r;
+    }
+
+    // wal_dir, too!
+    char walfn[PATH_MAX];
+    snprintf(walfn, sizeof(walfn), "%s/db.wal", path.c_str());
+    r = ::mkdir(walfn, 0755);
+    if (r < 0)
+      r = -errno;
+    if (r < 0 && r != -EEXIST) {
+      derr << __func__ << " failed to create " << walfn
+	   << ": " << cpp_strerror(r)
+	   << dendl;
+      return r;
+    }
+  }
+
   db = KeyValueDB::create(g_ceph_context,
-			  g_conf->newstore_backend,
+			  kv_backend,
 			  fn);
   if (!db) {
     derr << __func__ << " error creating db" << dendl;
-    delete db;
-    db = NULL;
     return -EIO;
   }
   string options;
-  if (g_conf->newstore_backend == "rocksdb")
-    options = g_conf->newstore_rocksdb_options;
+  if (kv_backend == "rocksdb")
+    options = g_conf->kstore_rocksdb_options;
   db->init(options);
   stringstream err;
-  int r;
   if (create)
     r = db->create_and_open(err);
   else
@@ -832,43 +868,21 @@ int NewStore::_open_db(bool create)
     db = NULL;
     return -EIO;
   }
-  dout(1) << __func__ << " opened " << g_conf->newstore_backend
-	  << " path " << path << " options " << options << dendl;
+  dout(1) << __func__ << " opened " << kv_backend
+	  << " path " << fn << " options " << options << dendl;
   return 0;
 }
 
-void NewStore::_close_db()
+void KStore::_close_db()
 {
   assert(db);
   delete db;
   db = NULL;
 }
 
-int NewStore::_aio_start()
-{
-  if (g_conf->newstore_aio) {
-    dout(10) << __func__ << dendl;
-    int r = aio_queue.init();
-    if (r < 0)
-      return r;
-    aio_thread.create();
-  }
-  return 0;
-}
-
-void NewStore::_aio_stop()
-{
-  if (g_conf->newstore_aio) {
-    dout(10) << __func__ << dendl;
-    aio_stop = true;
-    aio_thread.join();
-    aio_stop = false;
-    aio_queue.shutdown();
-  }
-}
-
-int NewStore::_open_collections()
+int KStore::_open_collections(int *errors)
 {
+  assert(coll_map.empty());
   KeyValueDB::Iterator it = db->get_iterator(PREFIX_COLL);
   for (it->upper_bound(string());
        it->valid();
@@ -883,13 +897,15 @@ int NewStore::_open_collections()
       dout(20) << __func__ << " opened " << cid << dendl;
       coll_map[cid] = c;
     } else {
-      dout(20) << __func__ << " unrecognized collection " << it->key() << dendl;
+      derr << __func__ << " unrecognized collection " << it->key() << dendl;
+      if (errors)
+	(*errors)++;
     }
   }
   return 0;
 }
 
-int NewStore::mkfs()
+int KStore::mkfs()
 {
   dout(1) << __func__ << " path " << path << dendl;
   int r;
@@ -915,9 +931,7 @@ int NewStore::mkfs()
     } else {
       dout(1) << __func__ << " using provided fsid " << fsid << dendl;
     }
-    r = _write_fsid();
-    if (r < 0)
-      goto out_close_fsid;
+    // we'll write it last.
   } else {
     if (!fsid.is_zero() && fsid != old_fsid) {
       derr << __func__ << " on-disk fsid " << old_fsid
@@ -926,25 +940,27 @@ int NewStore::mkfs()
       goto out_close_fsid;
     }
     fsid = old_fsid;
-    dout(1) << __func__ << " fsid is already set to " << fsid << dendl;
+    dout(1) << __func__ << " already created, fsid is " << fsid << dendl;
+    goto out_close_fsid;
   }
 
-  r = _create_frag();
+  r = _open_db(true);
   if (r < 0)
     goto out_close_fsid;
 
-  r = _open_db(true);
+  r = write_meta("kv_backend", g_conf->kstore_backend);
   if (r < 0)
-    goto out_close_frag;
+    goto out_close_db;
 
-  // FIXME: superblock
+  // indicate mkfs completion/success by writing the fsid file
+  r = _write_fsid();
+  if (r == 0)
+    dout(10) << __func__ << " success" << dendl;
+  else
+    derr << __func__ << " error writing fsid: " << cpp_strerror(r) << dendl;
 
-  dout(10) << __func__ << " success" << dendl;
-  r = 0;
+ out_close_db:
   _close_db();
-
- out_close_frag:
-  _close_frag();
  out_close_fsid:
   _close_fsid();
  out_path_fd:
@@ -952,10 +968,16 @@ int NewStore::mkfs()
   return r;
 }
 
-int NewStore::mount()
+int KStore::mount()
 {
   dout(1) << __func__ << " path " << path << dendl;
 
+  if (g_conf->kstore_fsck_on_mount) {
+    int rc = fsck();
+    if (rc < 0)
+      return rc;
+  }
+
   int r = _open_path();
   if (r < 0)
     return r;
@@ -971,21 +993,11 @@ int NewStore::mount()
   if (r < 0)
     goto out_fsid;
 
-  r = _open_frag();
-  if (r < 0)
-    goto out_fsid;
-
-  // FIXME: superblock, features
-
   r = _open_db(false);
   if (r < 0)
-    goto out_frag;
-
-  r = _recover_next_fid();
-  if (r < 0)
-    goto out_db;
+    goto out_fsid;
 
-  r = _recover_next_nid();
+  r = _open_super_meta();
   if (r < 0)
     goto out_db;
 
@@ -993,28 +1005,14 @@ int NewStore::mount()
   if (r < 0)
     goto out_db;
 
-  r = _aio_start();
-  if (r < 0)
-    goto out_db;
-
-  r = _wal_replay();
-  if (r < 0)
-    goto out_aio;
-
   finisher.start();
-  fsync_tp.start();
-  wal_tp.start();
-  kv_sync_thread.create();
+  kv_sync_thread.create("kstore_kv_sync");
 
   mounted = true;
   return 0;
 
- out_aio:
-  _aio_stop();
  out_db:
   _close_db();
- out_frag:
-  _close_frag();
  out_fsid:
   _close_fsid();
  out_path:
@@ -1022,24 +1020,17 @@ int NewStore::mount()
   return r;
 }
 
-int NewStore::umount()
+int KStore::umount()
 {
   assert(mounted);
   dout(1) << __func__ << dendl;
 
   _sync();
   _reap_collections();
+  coll_map.clear();
 
-  dout(20) << __func__ << " stopping fsync_wq" << dendl;
-  fsync_tp.stop();
-  dout(20) << __func__ << " stopping aio" << dendl;
-  _aio_stop();
   dout(20) << __func__ << " stopping kv thread" << dendl;
   _kv_stop();
-  dout(20) << __func__ << " draining wal_wq" << dendl;
-  wal_wq.drain();
-  dout(20) << __func__ << " stopping wal_tp" << dendl;
-  wal_tp.stop();
   dout(20) << __func__ << " draining finisher" << dendl;
   finisher.wait_for_empty();
   dout(20) << __func__ << " stopping finisher" << dendl;
@@ -1047,21 +1038,332 @@ int NewStore::umount()
   dout(20) << __func__ << " closing" << dendl;
 
   mounted = false;
-  if (fset_fd >= 0)
-    VOID_TEMP_FAILURE_RETRY(::close(fset_fd));
   _close_db();
-  _close_frag();
   _close_fsid();
   _close_path();
   return 0;
 }
 
-void NewStore::_sync()
+int KStore::fsck()
 {
-  dout(10) << __func__ << dendl;
+  dout(1) << __func__ << dendl;
+  int errors = 0;
+#if 0
+  set<uint64_t> used_nids;
+  set<uint64_t> used_omap_head;
+  interval_set<uint64_t> used_blocks;
+  KeyValueDB::Iterator it;
+
+  int r = _open_path();
+  if (r < 0)
+    return r;
+  r = _open_fsid(false);
+  if (r < 0)
+    goto out_path;
+
+  r = _read_fsid(&fsid);
+  if (r < 0)
+    goto out_fsid;
 
-  dout(20) << " flushing fsync wq" << dendl;
-  fsync_wq.flush();
+  r = _lock_fsid();
+  if (r < 0)
+    goto out_fsid;
+
+  r = _open_bdev(false);
+  if (r < 0)
+    goto out_fsid;
+
+  r = _open_db(false);
+  if (r < 0)
+    goto out_bdev;
+
+  r = _open_alloc();
+  if (r < 0)
+    goto out_db;
+
+  r = _open_super_meta();
+  if (r < 0)
+    goto out_alloc;
+
+  r = _open_collections(&errors);
+  if (r < 0)
+    goto out_alloc;
+
+  if (bluefs) {
+    used_blocks.insert(0, BLUEFS_START);
+    used_blocks.insert(bluefs_extents);
+    r = bluefs->fsck();
+    if (r < 0)
+      goto out_alloc;
+    if (r > 0)
+      errors += r;
+  }
+
+  // walk collections, objects
+  for (ceph::unordered_map<coll_t, CollectionRef>::iterator p = coll_map.begin();
+       p != coll_map.end() && !errors;
+       ++p) {
+    dout(1) << __func__ << " collection " << p->first << dendl;
+    CollectionRef c = _get_collection(p->first);
+    RWLock::RLocker l(c->lock);
+    ghobject_t pos;
+    while (!errors) {
+      vector<ghobject_t> ols;
+      int r = collection_list(p->first, pos, ghobject_t::get_max(), true,
+			      100, &ols, &pos);
+      if (r < 0) {
+	++errors;
+	break;
+      }
+      if (ols.empty()) {
+	break;
+      }
+      for (auto& oid : ols) {
+	dout(10) << __func__ << "  " << oid << dendl;
+	OnodeRef o = c->get_onode(oid, false);
+	if (!o || !o->exists) {
+	  ++errors;
+	  break;
+	}
+	if (o->onode.nid) {
+	  if (used_nids.count(o->onode.nid)) {
+	    derr << " " << oid << " nid " << o->onode.nid << " already in use"
+		 << dendl;
+	    ++errors;
+	    break;
+	  }
+	  used_nids.insert(o->onode.nid);
+	}
+	// blocks
+	for (auto& b : o->onode.block_map) {
+	  if (used_blocks.contains(b.second.offset, b.second.length)) {
+	    derr << " " << oid << " extent " << b.first << ": " << b.second
+		 << " already allocated" << dendl;
+	    ++errors;
+	    continue;
+	  }
+	  used_blocks.insert(b.second.offset, b.second.length);
+	  if (b.second.end() > bdev->get_size()) {
+	    derr << " " << oid << " extent " << b.first << ": " << b.second
+		 << " past end of block device" << dendl;
+	    ++errors;
+	  }
+	}
+	// overlays
+	set<string> overlay_keys;
+	map<uint64_t,int> refs;
+	for (auto& v : o->onode.overlay_map) {
+	  if (v.first + v.second.length > o->onode.size) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " extends past end of object" << dendl;
+	    ++errors;
+	  }
+	  if (v.second.key > o->onode.last_overlay_key) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " is > last_overlay_key " << o->onode.last_overlay_key
+		 << dendl;
+	    ++errors;
+	  }
+	  ++refs[v.second.key];
+	  string key;
+	  bufferlist val;
+	  get_overlay_key(o->onode.nid, v.second.key, &key);
+	  overlay_keys.insert(key);
+	  int r = db->get(PREFIX_OVERLAY, key, &val);
+	  if (r < 0) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " failed to fetch: " << cpp_strerror(r) << dendl;
+	    ++errors;
+	  }
+	  if (val.length() < v.second.value_offset + v.second.length) {
+	    derr << " " << oid << " overlay " << v.first << " " << v.second
+		 << " too short, " << val.length() << dendl;
+	    ++errors;
+	  }
+	}
+	for (auto& vr : o->onode.overlay_refs) {
+	  if (refs[vr.first] != vr.second) {
+	    derr << " " << oid << " overlay key " << vr.first
+		 << " says " << vr.second << " refs but we have "
+		 << refs[vr.first] << dendl;
+	    ++errors;
+	  }
+	  refs.erase(vr.first);
+	}
+	for (auto& p : refs) {
+	  if (p.second > 1) {
+	    derr << " " << oid << " overlay key " << p.first
+		 << " has " << p.second << " refs but they are not recorded"
+		 << dendl;
+	    ++errors;
+	  }
+	}
+	do {
+	  string start;
+	  get_overlay_key(o->onode.nid, 0, &start);
+	  KeyValueDB::Iterator it = db->get_iterator(PREFIX_OVERLAY);
+	  if (!it)
+	    break;
+	  for (it->lower_bound(start); it->valid(); it->next()) {
+	    string k = it->key();
+	    const char *p = k.c_str();
+	    uint64_t nid;
+	    p = _key_decode_u64(p, &nid);
+	    if (nid != o->onode.nid)
+	      break;
+	    if (!overlay_keys.count(k)) {
+	      derr << " " << oid << " has stray overlay kv pair for "
+		   << k << dendl;
+	      ++errors;
+	    }
+	  }
+	} while (false);
+	// omap
+	while (o->onode.omap_head) {
+	  if (used_omap_head.count(o->onode.omap_head)) {
+	    derr << " " << oid << " omap_head " << o->onode.omap_head
+		 << " already in use" << dendl;
+	    ++errors;
+	    break;
+	  }
+	  used_omap_head.insert(o->onode.omap_head);
+	  // hrm, scan actual key/value pairs?
+	  KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
+	  if (!it)
+	    break;
+	  string head, tail;
+	  get_omap_header(o->onode.omap_head, &head);
+	  get_omap_tail(o->onode.omap_head, &tail);
+	  it->lower_bound(head);
+	  while (it->valid()) {
+	    if (it->key() == head) {
+	      dout(30) << __func__ << "  got header" << dendl;
+	    } else if (it->key() >= tail) {
+	      dout(30) << __func__ << "  reached tail" << dendl;
+	      break;
+	    } else {
+	      string user_key;
+	      decode_omap_key(it->key(), &user_key);
+	      dout(30) << __func__
+		       << "  got " << pretty_binary_string(it->key())
+		       << " -> " << user_key << dendl;
+	      assert(it->key() < tail);
+	    }
+	    it->next();
+	  }
+	  break;
+	}
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking for stray objects" << dendl;
+  it = db->get_iterator(PREFIX_OBJ);
+  if (it) {
+    CollectionRef c;
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      ghobject_t oid;
+      int r = get_key_object(it->key(), &oid);
+      if (r < 0) {
+	dout(30) << __func__ << "  bad object key "
+		 << pretty_binary_string(it->key()) << dendl;
+	++errors;
+	continue;
+      }
+      if (!c || !c->contains(oid)) {
+	c = NULL;
+	for (ceph::unordered_map<coll_t, CollectionRef>::iterator p =
+	       coll_map.begin();
+	     p != coll_map.end() && !errors;
+	     ++p) {
+	  if (p->second->contains(oid)) {
+	    c = p->second;
+	    break;
+	  }
+	}
+	if (!c) {
+	  dout(30) << __func__ << "  stray object " << oid
+		   << " not owned by any collection" << dendl;
+	  ++errors;
+	  continue;
+	}
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking for stray overlay data" << dendl;
+  it = db->get_iterator(PREFIX_OVERLAY);
+  if (it) {
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      string key = it->key();
+      const char *p = key.c_str();
+      uint64_t nid;
+      p = _key_decode_u64(p, &nid);
+      if (used_nids.count(nid) == 0) {
+	derr << __func__ << " found stray overlay data on nid " << nid << dendl;
+	++errors;
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking for stray omap data" << dendl;
+  it = db->get_iterator(PREFIX_OMAP);
+  if (it) {
+    for (it->lower_bound(string()); it->valid(); it->next()) {
+      string key = it->key();
+      const char *p = key.c_str();
+      uint64_t omap_head;
+      p = _key_decode_u64(p, &omap_head);
+      if (used_omap_head.count(omap_head) == 0) {
+	derr << __func__ << " found stray omap data on omap_head " << omap_head
+	     << dendl;
+	++errors;
+      }
+    }
+  }
+
+  dout(1) << __func__ << " checking freelist vs allocated" << dendl;
+  {
+    const map<uint64_t,uint64_t>& free = fm->get_freelist();
+    for (map<uint64_t,uint64_t>::const_iterator p = free.begin();
+	 p != free.end(); ++p) {
+      if (used_blocks.contains(p->first, p->second)) {
+	derr << __func__ << " free extent " << p->first << "~" << p->second
+	     << " intersects allocated blocks" << dendl;
+	++errors;
+	continue;
+      }
+      used_blocks.insert(p->first, p->second);
+    }
+    if (!used_blocks.contains(0, bdev->get_size())) {
+      derr << __func__ << " leaked some space; free+used = "
+	   << used_blocks
+	   << " != expected 0~" << bdev->get_size()
+	   << dendl;
+      ++errors;
+    }
+  }
+  coll_map.clear();
+ out_alloc:
+  _close_alloc();
+ out_db:
+  it.reset();  // before db is closed
+  _close_db();
+ out_bdev:
+  _close_bdev();
+ out_fsid:
+  _close_fsid();
+ out_path:
+  _close_path();
+
+#endif
+  dout(1) << __func__ << " finish with " << errors << " errors" << dendl;
+  return errors;
+}
+
+void KStore::_sync()
+{
+  dout(10) << __func__ << dendl;
 
   kv_lock.Lock();
   while (!kv_committing.empty() ||
@@ -1074,20 +1376,15 @@ void NewStore::_sync()
   dout(10) << __func__ << " done" << dendl;
 }
 
-int NewStore::statfs(struct statfs *buf)
+int KStore::statfs(struct statfs *buf)
 {
-  if (::statfs(path.c_str(), buf) < 0) {
-    int r = -errno;
-    assert(!g_conf->newstore_fail_eio || r != -EIO);
-    return r;
-  }
-  return 0;
+  return db->get_statfs(buf);
 }
 
 // ---------------
 // cache
 
-NewStore::CollectionRef NewStore::_get_collection(coll_t cid)
+KStore::CollectionRef KStore::_get_collection(coll_t cid)
 {
   RWLock::RLocker l(coll_lock);
   ceph::unordered_map<coll_t,CollectionRef>::iterator cp = coll_map.find(cid);
@@ -1096,14 +1393,14 @@ NewStore::CollectionRef NewStore::_get_collection(coll_t cid)
   return cp->second;
 }
 
-void NewStore::_queue_reap_collection(CollectionRef& c)
+void KStore::_queue_reap_collection(CollectionRef& c)
 {
   dout(10) << __func__ << " " << c->cid << dendl;
   Mutex::Locker l(reap_lock);
   removed_collections.push_back(c);
 }
 
-void NewStore::_reap_collections()
+void KStore::_reap_collections()
 {
   reap_lock.Lock();
 
@@ -1138,7 +1435,7 @@ void NewStore::_reap_collections()
 // ---------------
 // read operations
 
-bool NewStore::exists(coll_t cid, const ghobject_t& oid)
+bool KStore::exists(coll_t cid, const ghobject_t& oid)
 {
   dout(10) << __func__ << " " << cid << " " << oid << dendl;
   CollectionRef c = _get_collection(cid);
@@ -1151,7 +1448,7 @@ bool NewStore::exists(coll_t cid, const ghobject_t& oid)
   return true;
 }
 
-int NewStore::stat(
+int KStore::stat(
     coll_t cid,
     const ghobject_t& oid,
     struct stat *st,
@@ -1172,7 +1469,7 @@ int NewStore::stat(
   return 0;
 }
 
-int NewStore::read(
+int KStore::read(
   coll_t cid,
   const ghobject_t& oid,
   uint64_t offset,
@@ -1210,150 +1507,84 @@ int NewStore::read(
   return r;
 }
 
-int NewStore::_do_read(
+int KStore::_do_read(
     OnodeRef o,
     uint64_t offset,
     size_t length,
     bufferlist& bl,
     uint32_t op_flags)
 {
-  map<uint64_t,fragment_t>::iterator fp, fend;
-  map<uint64_t,overlay_t>::iterator op, oend;
-  int r;
-  int fd = -1;
-  fid_t cur_fid;
+  int r = 0;
+  uint64_t stripe_size = o->onode.stripe_size;
+  uint64_t stripe_off;
 
   dout(20) << __func__ << " " << offset << "~" << length << " size "
-	   << o->onode.size << dendl;
+	   << o->onode.size << " nid " << o->onode.nid << dendl;
+  bl.clear();
 
   if (offset > o->onode.size) {
-    r = 0;
     goto out;
   }
-
   if (offset + length > o->onode.size) {
     length = o->onode.size - offset;
   }
+  if (stripe_size == 0) {
+    bufferptr z(length);
+    z.zero();
+    bl.append(z);
+    r = length;
+    goto out;
+  }
 
   o->flush();
 
-  r = 0;
-
-  // loop over overlays and data fragments.  overlays take precedence.
-  fend = o->onode.data_map.end();
-  fp = o->onode.data_map.lower_bound(offset);
-  if (fp != o->onode.data_map.begin()) {
-    --fp;
-  }
-  oend = o->onode.overlay_map.end();
-  op = o->onode.overlay_map.lower_bound(offset);
-  if (op != o->onode.overlay_map.begin()) {
-    --op;
-  }
+  stripe_off = offset % stripe_size;
   while (length > 0) {
-    if (op != oend && op->first + op->second.length < offset) {
-      dout(20) << __func__ << " skip overlay " << op->first << " " << op->second
-	       << dendl;
-      ++op;
-      continue;
-    }
-    if (fp != fend && fp->first + fp->second.length <= offset) {
-      dout(30) << __func__ << " skip frag " << fp->first << "~" << fp->second
-	       << dendl;
-      ++fp;
-      continue;
-    }
-
-    // overlay?
-    if (op != oend && op->first <= offset) {
-      uint64_t x_off = offset - op->first + op->second.value_offset;
-      uint64_t x_len = MIN(op->first + op->second.length - offset, length);
-      dout(20) << __func__ << "  overlay " << op->first << " " << op->second
-	       << " use " << x_off << "~" << x_len << dendl;
-      bufferlist v;
-      string key;
-      get_overlay_key(o->onode.nid, op->second.key, &key);
-      db->get(PREFIX_OVERLAY, key, &v);
-      bufferlist frag;
-      frag.substr_of(v, x_off, x_len);
-      bl.claim_append(frag);
-      ++op;
-      length -= x_len;
-      offset += x_len;
-      continue;
-    }
-
-    unsigned x_len = length;
-    if (op != oend &&
-	op->first > offset &&
-	op->first - offset < x_len) {
-      x_len = op->first - offset;
-    }
-
-    // frag?
-    if (fp != fend && fp->first <= offset) {
-      if (fp->second.fid != cur_fid) {
-	cur_fid = fp->second.fid;
-	if (fd >= 0) {
-	  VOID_TEMP_FAILURE_RETRY(::close(fd));
+    bufferlist stripe;
+    _do_read_stripe(o, offset - stripe_off, &stripe);
+    dout(30) << __func__ << " stripe " << offset - stripe_off << " got "
+	     << stripe.length() << dendl;
+    unsigned swant = MIN(stripe_size - stripe_off, length);
+    if (stripe.length()) {
+      if (swant == stripe.length()) {
+	bl.claim_append(stripe);
+	dout(30) << __func__ << " taking full stripe" << dendl;
+      } else {
+	unsigned l = 0;
+	if (stripe_off < stripe.length()) {
+	  l = MIN(stripe.length() - stripe_off, swant);
+	  bufferlist t;
+	  t.substr_of(stripe, stripe_off, l);
+	  bl.claim_append(t);
+	  dout(30) << __func__ << " taking " << stripe_off << "~" << l << dendl;
 	}
-	fd = _open_fid(cur_fid, O_RDONLY);
-	if (fd < 0) {
-	  r = fd;
-	  goto out;
+	if (l < swant) {
+	  bufferptr z(swant - l);
+	  z.zero();
+	  bl.append(z);
+	  dout(30) << __func__ << " adding " << z.length() << " zeros" << dendl;
 	}
       }
-      uint64_t x_off = offset - fp->first - fp->second.offset;
-      x_len = MIN(x_len, fp->second.length - x_off);
-      dout(30) << __func__ << " data " << fp->first << " " << fp->second
-	       << " use " << x_off << "~" << x_len
-	       << " fid " << cur_fid << " offset " << x_off + fp->second.offset
-	       << dendl;
-      r = ::lseek64(fd, x_off, SEEK_SET);
-      if (r < 0) {
-	r = -errno;
-	goto out;
-      }
-      bufferlist t;
-      r = t.read_fd(fd, x_len);
-      if (r < 0) {
-	goto out;
-      }
-      bl.claim_append(t);
-      if ((unsigned)r < x_len) {
-	dout(10) << __func__ << "   short read " << r << " < " << x_len
-		 << " from " << cur_fid << dendl;
-	bufferptr z(x_len - r);
-	z.zero();
-	bl.append(z);
-      }
-      offset += x_len;
-      length -= x_len;
-      if (x_off + x_len == fp->second.length) {
-	++fp;
-      }
-      continue;
+    } else {
+      dout(30) << __func__ << " generating " << swant << " zeros" << dendl;
+      bufferptr z(swant);
+      z.zero();
+      bl.append(z);
     }
-
-    // zero.
-    dout(30) << __func__ << " zero " << offset << "~" << x_len << dendl;
-    bufferptr bp(x_len);
-    bp.zero();
-    bl.push_back(bp);
-    offset += x_len;
-    length -= x_len;
-    continue;
+    offset += swant;
+    length -= swant;
+    stripe_off = 0;
   }
   r = bl.length();
+  dout(30) << " result:\n";
+  bl.hexdump(*_dout);
+  *_dout << dendl;
 
  out:
-  if (fd >= 0) {
-    VOID_TEMP_FAILURE_RETRY(::close(fd));
-  }
   return r;
 }
 
-int NewStore::fiemap(
+int KStore::fiemap(
   coll_t cid,
   const ghobject_t& oid,
   uint64_t offset,
@@ -1375,7 +1606,7 @@ int NewStore::fiemap(
     len = o->onode.size;
 
   if (offset > o->onode.size)
-    return 0;
+    goto out;
 
   if (offset + len > o->onode.size) {
     len = o->onode.size - offset;
@@ -1384,81 +1615,17 @@ int NewStore::fiemap(
   dout(20) << __func__ << " " << offset << "~" << len << " size "
 	   << o->onode.size << dendl;
 
-  map<uint64_t,fragment_t>::iterator fp, fend;
-  map<uint64_t,overlay_t>::iterator op, oend;
-
-  // loop over overlays and data fragments.  overlays take precedence.
-  fend = o->onode.data_map.end();
-  fp = o->onode.data_map.lower_bound(offset);
-  if (fp != o->onode.data_map.begin()) {
-    --fp;
-  }
-  oend = o->onode.overlay_map.end();
-  op = o->onode.overlay_map.lower_bound(offset);
-  if (op != o->onode.overlay_map.begin()) {
-    --op;
-  }
-  uint64_t start = offset;
-  while (len > 0) {
-    if (op != oend && op->first + op->second.length < offset) {
-      ++op;
-      continue;
-    }
-    if (fp != fend && fp->first + fp->second.length <= offset) {
-      ++fp;
-      continue;
-    }
-
-    // overlay?
-    if (op != oend && op->first <= offset) {
-      uint64_t x_len = MIN(op->first + op->second.length - offset, len);
-      //m[offset] = x_len;
-      dout(30) << __func__ << " get overlay, off =  " << offset << " len=" << x_len << dendl;
-      len -= x_len;
-      offset += x_len;
-      ++op;
-      continue;
-    }
-
-    unsigned x_len = len;
-    if (op != oend &&
-	op->first > offset &&
-	op->first - offset < x_len) {
-      x_len = op->first - offset;
-    }
-
-    // frag?
-    if (fp != fend && fp->first <= offset) {
-      uint64_t x_off = offset - fp->first - fp->second.offset;
-      x_len = MIN(x_len, fp->second.length - x_off);
-      //m[offset] = x_len;
-      dout(30) << __func__ << " get frag, off =  " << offset << " len=" << x_len << dendl;
-      len -= x_len;
-      offset += x_len;
-      if (x_off + x_len == fp->second.length)
-	++fp;
-      continue;
-    }
-    // we are seeing a hole, time to add an entry to fiemap.
-    m[start] = offset - start;
-    dout(20) << __func__ << " get fiemap entry, off =  " << start << " len=" << m[start] << dendl;
-    offset += x_len;
-    start = offset;
-    len -= x_len;
-    continue;
-  }
-  //add tailing
-  if (offset - start != 0) {
-    m[start] = offset - start;
-    dout(20) << __func__ << " get fiemap entry, off =  " << start << " len=" << m[start] << dendl;
-  }
+  // FIXME: do something smarter here
+  m[0] = o->onode.size;
 
+ out:
   ::encode(m, bl);
-  dout(20) << __func__ << " " << offset << "~" << len << " size = 0 (" << m << ")" << dendl;
+  dout(20) << __func__ << " " << offset << "~" << len
+	   << " size = 0 (" << m << ")" << dendl;
   return 0;
 }
 
-int NewStore::getattr(
+int KStore::getattr(
   coll_t cid,
   const ghobject_t& oid,
   const char *name,
@@ -1490,7 +1657,7 @@ int NewStore::getattr(
   return r;
 }
 
-int NewStore::getattrs(
+int KStore::getattrs(
   coll_t cid,
   const ghobject_t& oid,
   map<string,bufferptr>& aset)
@@ -1515,7 +1682,7 @@ int NewStore::getattrs(
   return r;
 }
 
-int NewStore::list_collections(vector<coll_t>& ls)
+int KStore::list_collections(vector<coll_t>& ls)
 {
   RWLock::RLocker l(coll_lock);
   for (ceph::unordered_map<coll_t, CollectionRef>::iterator p = coll_map.begin();
@@ -1525,18 +1692,18 @@ int NewStore::list_collections(vector<coll_t>& ls)
   return 0;
 }
 
-bool NewStore::collection_exists(coll_t c)
+bool KStore::collection_exists(coll_t c)
 {
   RWLock::RLocker l(coll_lock);
   return coll_map.count(c);
 }
 
-bool NewStore::collection_empty(coll_t cid)
+bool KStore::collection_empty(coll_t cid)
 {
   dout(15) << __func__ << " " << cid << dendl;
   vector<ghobject_t> ls;
   ghobject_t next;
-  int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), true, 5,
+  int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), true, 1,
 			  &ls, &next);
   if (r < 0)
     return false;  // fixme?
@@ -1545,7 +1712,7 @@ bool NewStore::collection_empty(coll_t cid)
   return empty;
 }
 
-int NewStore::collection_list(
+int KStore::collection_list(
   coll_t cid, ghobject_t start, ghobject_t end,
   bool sort_bitwise, int max,
   vector<ghobject_t> *ls, ghobject_t *pnext)
@@ -1563,7 +1730,7 @@ int NewStore::collection_list(
   string temp_start_key, temp_end_key;
   string start_key, end_key;
   bool set_next = false;
-  const char *pend;
+  string pend;
   bool temp;
 
   ghobject_t static_next;
@@ -1574,11 +1741,14 @@ int NewStore::collection_list(
     goto out;
   get_coll_key_range(cid, c->cnode.bits, &temp_start_key, &temp_end_key,
 		     &start_key, &end_key);
-  dout(20) << __func__ << " range " << temp_start_key << " to "
-	   << temp_end_key << " and " << start_key << " to " << end_key
+  dout(20) << __func__
+	   << " range " << pretty_binary_string(temp_start_key)
+	   << " to " << pretty_binary_string(temp_end_key)
+	   << " and " << pretty_binary_string(start_key)
+	   << " to " << pretty_binary_string(end_key)
 	   << " start " << start << dendl;
   it = db->get_iterator(PREFIX_OBJ);
-  if (start == ghobject_t()) {
+  if (start == ghobject_t() || start == cid.get_min_hobj()) {
     it->upper_bound(temp_start_key);
     temp = true;
   } else {
@@ -1591,28 +1761,31 @@ int NewStore::collection_list(
       temp = false;
       assert(k >= start_key && k < end_key);
     }
-    it->upper_bound(k);
+    dout(20) << " start from " << pretty_binary_string(k)
+	     << " temp=" << (int)temp << dendl;
+    it->lower_bound(k);
   }
   if (end.hobj.is_max()) {
-    pend = temp ? temp_end_key.c_str() : end_key.c_str();
+    pend = temp ? temp_end_key : end_key;
   } else {
     get_object_key(end, &end_key);
     if (end.hobj.is_temp()) {
       if (temp)
-	pend = end_key.c_str();
+	pend = end_key;
       else
 	goto out;
     } else {
-      pend = temp ? temp_end_key.c_str() : end_key.c_str();
+      pend = temp ? temp_end_key : end_key;
     }
   }
-  dout(30) << __func__ << " pend " << pend << dendl;
+  dout(20) << __func__ << " pend " << pretty_binary_string(pend) << dendl;
   while (true) {
-    if (!it->valid() || strcmp(it->key().c_str(), pend) > 0) {
+    if (!it->valid() || it->key() > pend) {
       if (!it->valid())
 	dout(20) << __func__ << " iterator not valid (end of db?)" << dendl;
       else
-	dout(20) << __func__ << " key " << it->key() << " > " << end << dendl;
+	dout(20) << __func__ << " key " << pretty_binary_string(it->key())
+		 << " > " << end << dendl;
       if (temp) {
 	if (end.hobj.is_temp()) {
 	  break;
@@ -1620,22 +1793,23 @@ int NewStore::collection_list(
 	dout(30) << __func__ << " switch to non-temp namespace" << dendl;
 	temp = false;
 	it->upper_bound(start_key);
-	pend = end_key.c_str();
-	dout(30) << __func__ << " pend " << pend << dendl;
+	pend = end_key;
+	dout(30) << __func__ << " pend " << pretty_binary_string(pend) << dendl;
 	continue;
       }
       break;
     }
-    dout(20) << __func__ << " key " << it->key() << dendl;
+    dout(20) << __func__ << " key " << pretty_binary_string(it->key()) << dendl;
     ghobject_t oid;
     int r = get_key_object(it->key(), &oid);
     assert(r == 0);
-    ls->push_back(oid);
     if (ls->size() >= (unsigned)max) {
+      dout(20) << __func__ << " reached max " << max << dendl;
       *pnext = oid;
       set_next = true;
       break;
     }
+    ls->push_back(oid);
     it->next();
   }
   if (!set_next) {
@@ -1651,18 +1825,19 @@ int NewStore::collection_list(
 
 // omap reads
 
-NewStore::OmapIteratorImpl::OmapIteratorImpl(CollectionRef c, OnodeRef o, KeyValueDB::Iterator it)
+KStore::OmapIteratorImpl::OmapIteratorImpl(
+  CollectionRef c, OnodeRef o, KeyValueDB::Iterator it)
   : c(c), o(o), it(it)
 {
   RWLock::RLocker l(c->lock);
   if (o->onode.omap_head) {
-    get_omap_header(o->onode.omap_head, &head);
+    get_omap_key(o->onode.omap_head, string(), &head);
     get_omap_tail(o->onode.omap_head, &tail);
     it->lower_bound(head);
   }
 }
 
-int NewStore::OmapIteratorImpl::seek_to_first()
+int KStore::OmapIteratorImpl::seek_to_first()
 {
   RWLock::RLocker l(c->lock);
   if (o->onode.omap_head) {
@@ -1673,7 +1848,7 @@ int NewStore::OmapIteratorImpl::seek_to_first()
   return 0;
 }
 
-int NewStore::OmapIteratorImpl::upper_bound(const string& after)
+int KStore::OmapIteratorImpl::upper_bound(const string& after)
 {
   RWLock::RLocker l(c->lock);
   if (o->onode.omap_head) {
@@ -1686,7 +1861,7 @@ int NewStore::OmapIteratorImpl::upper_bound(const string& after)
   return 0;
 }
 
-int NewStore::OmapIteratorImpl::lower_bound(const string& to)
+int KStore::OmapIteratorImpl::lower_bound(const string& to)
 {
   RWLock::RLocker l(c->lock);
   if (o->onode.omap_head) {
@@ -1699,7 +1874,7 @@ int NewStore::OmapIteratorImpl::lower_bound(const string& to)
   return 0;
 }
 
-bool NewStore::OmapIteratorImpl::valid()
+bool KStore::OmapIteratorImpl::valid()
 {
   RWLock::RLocker l(c->lock);
   if (o->onode.omap_head && it->valid() && it->raw_key().second <= tail) {
@@ -1709,7 +1884,7 @@ bool NewStore::OmapIteratorImpl::valid()
   }
 }
 
-int NewStore::OmapIteratorImpl::next(bool validate)
+int KStore::OmapIteratorImpl::next(bool validate)
 {
   RWLock::RLocker l(c->lock);
   if (o->onode.omap_head) {
@@ -1720,7 +1895,7 @@ int NewStore::OmapIteratorImpl::next(bool validate)
   }
 }
 
-string NewStore::OmapIteratorImpl::key()
+string KStore::OmapIteratorImpl::key()
 {
   RWLock::RLocker l(c->lock);
   assert(it->valid());
@@ -1730,14 +1905,14 @@ string NewStore::OmapIteratorImpl::key()
   return user_key;
 }
 
-bufferlist NewStore::OmapIteratorImpl::value()
+bufferlist KStore::OmapIteratorImpl::value()
 {
   RWLock::RLocker l(c->lock);
   assert(it->valid());
   return it->value();
 }
 
-int NewStore::omap_get(
+int KStore::omap_get(
   coll_t cid,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
   bufferlist *header,      ///< [out] omap header
@@ -1774,7 +1949,8 @@ int NewStore::omap_get(
       } else {
 	string user_key;
 	decode_omap_key(it->key(), &user_key);
-	dout(30) << __func__ << "  got " << it->key() << " -> " << user_key << dendl;
+	dout(30) << __func__ << "  got " << pretty_binary_string(it->key())
+		 << " -> " << user_key << dendl;
 	assert(it->key() < tail);
 	(*out)[user_key] = it->value();
       }
@@ -1786,7 +1962,7 @@ int NewStore::omap_get(
   return r;
 }
 
-int NewStore::omap_get_header(
+int KStore::omap_get_header(
   coll_t cid,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
   bufferlist *header,      ///< [out] omap header
@@ -1821,7 +1997,7 @@ int NewStore::omap_get_header(
   return r;
 }
 
-int NewStore::omap_get_keys(
+int KStore::omap_get_keys(
   coll_t cid,              ///< [in] Collection containing oid
   const ghobject_t &oid, ///< [in] Object containing omap
   set<string> *keys      ///< [out] Keys defined on oid
@@ -1844,22 +2020,18 @@ int NewStore::omap_get_keys(
   {
     KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
     string head, tail;
-    get_omap_header(o->onode.omap_head, &head);
+    get_omap_key(o->onode.omap_head, string(), &head);
     get_omap_tail(o->onode.omap_head, &tail);
     it->lower_bound(head);
     while (it->valid()) {
-      if (it->key() == head) {
-	dout(30) << __func__ << "  skipping head" << dendl;
-	it->next();
-	continue;
-      }
       if (it->key() >= tail) {
 	dout(30) << __func__ << "  reached tail" << dendl;
 	break;
       }
       string user_key;
       decode_omap_key(it->key(), &user_key);
-      dout(30) << __func__ << "  got " << it->key() << " -> " << user_key << dendl;
+      dout(30) << __func__ << "  got " << pretty_binary_string(it->key())
+	       << " -> " << user_key << dendl;
       assert(it->key() < tail);
       keys->insert(user_key);
       it->next();
@@ -1870,7 +2042,7 @@ int NewStore::omap_get_keys(
   return r;
 }
 
-int NewStore::omap_get_values(
+int KStore::omap_get_values(
   coll_t cid,                    ///< [in] Collection containing oid
   const ghobject_t &oid,       ///< [in] Object containing omap
   const set<string> &keys,     ///< [in] Keys to get
@@ -1896,7 +2068,8 @@ int NewStore::omap_get_values(
     get_omap_key(o->onode.omap_head, *p, &key);
     bufferlist val;
     if (db->get(PREFIX_OMAP, key, &val) >= 0) {
-      dout(30) << __func__ << "  got " << key << " -> " << *p << dendl;
+      dout(30) << __func__ << "  got " << pretty_binary_string(key)
+	       << " -> " << *p << dendl;
       out->insert(make_pair(*p, val));
     }
   }
@@ -1905,7 +2078,7 @@ int NewStore::omap_get_values(
   return r;
 }
 
-int NewStore::omap_check_keys(
+int KStore::omap_check_keys(
   coll_t cid,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
   const set<string> &keys, ///< [in] Keys to check
@@ -1931,10 +2104,12 @@ int NewStore::omap_check_keys(
     get_omap_key(o->onode.omap_head, *p, &key);
     bufferlist val;
     if (db->get(PREFIX_OMAP, key, &val) >= 0) {
-      dout(30) << __func__ << "  have " << key << " -> " << *p << dendl;
+      dout(30) << __func__ << "  have " << pretty_binary_string(key)
+	       << " -> " << *p << dendl;
       out->insert(*p);
     } else {
-      dout(30) << __func__ << "  miss " << key << " -> " << *p << dendl;
+      dout(30) << __func__ << "  miss " << pretty_binary_string(key)
+	       << " -> " << *p << dendl;
     }
   }
  out:
@@ -1942,7 +2117,7 @@ int NewStore::omap_check_keys(
   return r;
 }
 
-ObjectMap::ObjectMapIterator NewStore::get_omap_iterator(
+ObjectMap::ObjectMapIterator KStore::get_omap_iterator(
   coll_t cid,              ///< [in] collection
   const ghobject_t &oid  ///< [in] object
   )
@@ -1970,29 +2145,32 @@ ObjectMap::ObjectMapIterator NewStore::get_omap_iterator(
 // -----------------
 // write helpers
 
-int NewStore::_recover_next_nid()
+int KStore::_open_super_meta()
 {
-  nid_max = 0;
-  bufferlist bl;
-  db->get(PREFIX_SUPER, "nid_max", &bl);
-  try {
-    ::decode(nid_max, bl);
-  } catch (buffer::error& e) {
+  // nid
+  {
+    nid_max = 0;
+    bufferlist bl;
+    db->get(PREFIX_SUPER, "nid_max", &bl);
+    try {
+      ::decode(nid_max, bl);
+    } catch (buffer::error& e) {
+    }
+    dout(10) << __func__ << " old nid_max " << nid_max << dendl;
+    nid_last = nid_max;
   }
-  dout(1) << __func__ << " old nid_max " << nid_max << dendl;
-  nid_last = nid_max;
   return 0;
 }
 
-void NewStore::_assign_nid(TransContext *txc, OnodeRef o)
+void KStore::_assign_nid(TransContext *txc, OnodeRef o)
 {
   if (o->onode.nid)
     return;
   Mutex::Locker l(nid_lock);
   o->onode.nid = ++nid_last;
-  dout(20) << __func__ << " " << o->onode.nid << dendl;
+  dout(20) << __func__ << " " << o->oid << " nid " << o->onode.nid << dendl;
   if (nid_last > nid_max) {
-    nid_max += g_conf->newstore_nid_prealloc;
+    nid_max += g_conf->kstore_nid_prealloc;
     bufferlist bl;
     ::encode(nid_max, bl);
     txc->t->set(PREFIX_SUPER, "nid_max", bl);
@@ -2000,149 +2178,7 @@ void NewStore::_assign_nid(TransContext *txc, OnodeRef o)
   }
 }
 
-int NewStore::_recover_next_fid()
-{
-  bufferlist bl;
-  db->get(PREFIX_SUPER, "fid_max", &bl);
-  try {
-    ::decode(fid_max, bl);
-  } catch (buffer::error& e) {
-  }
-  dout(1) << __func__ << " old fid_max " << fid_max << dendl;
-  fid_last = fid_max;
-
-  if (fid_last.fset > 0) {
-    char s[32];
-    snprintf(s, sizeof(s), "%u", fid_last.fset);
-    assert(fset_fd < 0);
-    fset_fd = ::openat(frag_fd, s, O_DIRECTORY, 0644);
-    if (fset_fd < 0) {
-      int r = -errno;
-      derr << __func__ << " cannot open created " << path << "/fragments/"
-	 << s << ": " << cpp_strerror(r) << dendl;
-      return r;
-    }
-  }
-
-  return 0;
-}
-
-int NewStore::_open_fid(fid_t fid, unsigned flags)
-{
-  if (fid.handle.length() && g_conf->newstore_open_by_handle) {
-    int fd = fs->open_handle(path_fd, fid.handle, flags);
-    if (fd >= 0) {
-      dout(30) << __func__ << " " << fid << " = " << fd
-	       << " (open by handle)" << dendl;
-      return fd;
-    }
-    int err = -errno;
-    dout(30) << __func__ << " " << fid << " = " << cpp_strerror(err)
-	     << " (with open by handle, falling back to file name)" << dendl;
-  }
-
-  char fn[32];
-  snprintf(fn, sizeof(fn), "%u/%u", fid.fset, fid.fno);
-  int fd = ::openat(frag_fd, fn, flags);
-  if (fd < 0) {
-    int r = -errno;
-    derr << __func__ << " on " << fid << ": " << cpp_strerror(r) << dendl;
-    return r;
-  }
-  dout(30) << __func__ << " " << fid << " = " << fd << dendl;
-  return fd;
-}
-
-int NewStore::_create_fid(TransContext *txc, fid_t *fid, unsigned flags)
-{
-  {
-    Mutex::Locker l(fid_lock);
-    if (fid_last.fset > 0 &&
-	fid_last.fno > 0 &&
-	fid_last.fset == fid_max.fset &&
-	fid_last.fno < g_conf->newstore_max_dir_size) {
-      ++fid_last.fno;
-      if (fid_last.fno >= fid_max.fno) {
-	// raise fid_max, same fset, capping to max_dir_size
-	fid_max.fno = min(fid_max.fno + g_conf->newstore_fid_prealloc, g_conf->newstore_max_dir_size);
-	assert(fid_max.fno >= fid_last.fno);
-	bufferlist bl;
-	::encode(fid_max, bl);
-	txc->t->set(PREFIX_SUPER, "fid_max", bl);
-	dout(10) << __func__ << " fid_max now " << fid_max << dendl;
-      }
-    } else {
-      // new fset
-      ++fid_last.fset;
-      fid_last.fno = 1;
-      dout(10) << __func__ << " creating " << fid_last.fset << dendl;
-      char s[32];
-      snprintf(s, sizeof(s), "%u", fid_last.fset);
-      int r = ::mkdirat(frag_fd, s, 0755);
-      if (r < 0) {
-	r = -errno;
-	derr << __func__ << " cannot create " << path << "/fragments/"
-	     << s << ": " << cpp_strerror(r) << dendl;
-	return r;
-      }
-      if (fset_fd >= 0)
-	VOID_TEMP_FAILURE_RETRY(::close(fset_fd));
-      fset_fd = ::openat(frag_fd, s, O_DIRECTORY, 0644);
-      if (fset_fd < 0) {
-	r = -errno;
-	derr << __func__ << " cannot open created " << path << "/fragments/"
-	     << s << ": " << cpp_strerror(r) << dendl;
-      }
-
-      fid_max = fid_last;
-      fid_max.fno = g_conf->newstore_fid_prealloc;
-      bufferlist bl;
-      ::encode(fid_max, bl);
-      txc->t->set(PREFIX_SUPER, "fid_max", bl);
-      dout(10) << __func__ << " fid_max now " << fid_max << dendl;
-    }
-    *fid = fid_last;
-  }
-
-  dout(10) << __func__ << " " << fid_last << dendl;
-  char s[32];
-  snprintf(s, sizeof(s), "%u", fid->fno);
-  int fd = ::openat(fset_fd, s, flags | O_CREAT, 0644);
-  if (fd < 0) {
-    int r = -errno;
-    derr << __func__ << " cannot create " << path << "/fragments/"
-	 << *fid << ": " << cpp_strerror(r) << dendl;
-    return r;
-  }
-
-  if (g_conf->newstore_open_by_handle) {
-    int r = fs->get_handle(fd, &fid->handle);
-    if (r < 0) {
-      dout(30) << __func__ << " get_handle got " << cpp_strerror(r) << dendl;
-    } else {
-      dout(30) << __func__ << " got handle: ";
-      bufferlist bl;
-      bl.append(fid->handle);
-      bl.hexdump(*_dout);
-      *_dout << dendl;
-    }
-  }
-
-  dout(30) << __func__ << " " << *fid << " = " << fd << dendl;
-  return fd;
-}
-
-int NewStore::_remove_fid(fid_t fid)
-{
-  char fn[32];
-  snprintf(fn, sizeof(fn), "%u/%u", fid.fset, fid.fno);
-  int r = ::unlinkat(frag_fd, fn, 0);
-  if (r < 0)
-    return -errno;
-  return 0;
-}
-
-NewStore::TransContext *NewStore::_txc_create(OpSequencer *osr)
+KStore::TransContext *KStore::_txc_create(OpSequencer *osr)
 {
   TransContext *txc = new TransContext(osr);
   txc->t = db->get_transaction();
@@ -2151,38 +2187,17 @@ NewStore::TransContext *NewStore::_txc_create(OpSequencer *osr)
   return txc;
 }
 
-void NewStore::_txc_state_proc(TransContext *txc)
+void KStore::_txc_state_proc(TransContext *txc)
 {
   while (true) {
     dout(10) << __func__ << " txc " << txc
 	     << " " << txc->get_state_name() << dendl;
     switch (txc->state) {
     case TransContext::STATE_PREPARE:
-      if (!txc->pending_aios.empty()) {
-	txc->state = TransContext::STATE_AIO_WAIT;
-	_txc_aio_submit(txc);
-	return;
-      }
-      // ** fall-thru **
-
-    case TransContext::STATE_AIO_WAIT:
-      if (!txc->sync_items.empty()) {
-	txc->state = TransContext::STATE_FSYNC_WAIT;
-	if (!g_conf->newstore_sync_io) {
-	  _txc_queue_fsync(txc);
-	  return;
-	}
-	_txc_do_sync_fsync(txc);
-      }
-      _txc_finish_io(txc);  // may trigger blocked txc's too
-      return;
-
-    case TransContext::STATE_IO_DONE:
-      assert(txc->osr->qlock.is_locked());  // see _txc_finish_io
       txc->state = TransContext::STATE_KV_QUEUED;
-      if (!g_conf->newstore_sync_transaction) {
+      if (!g_conf->kstore_sync_transaction) {
 	Mutex::Locker l(kv_lock);
-	if (g_conf->newstore_sync_submit_transaction) {
+	if (g_conf->kstore_sync_submit_transaction) {
 	  db->submit_transaction(txc->t);
 	}
 	kv_queue.push_back(txc);
@@ -2198,34 +2213,9 @@ void NewStore::_txc_state_proc(TransContext *txc)
       // ** fall-thru **
 
     case TransContext::STATE_KV_DONE:
-      if (txc->wal_txn) {
-	txc->state = TransContext::STATE_WAL_QUEUED;
-	if (g_conf->newstore_sync_wal_apply) {
-	  _wal_apply(txc);
-	} else {
-	  wal_wq.queue(txc);
-	}
-	return;
-      }
       txc->state = TransContext::STATE_FINISHING;
       break;
 
-    case TransContext::STATE_WAL_APPLYING:
-      if (!txc->pending_aios.empty()) {
-	txc->state = TransContext::STATE_WAL_AIO_WAIT;
-	_txc_aio_submit(txc);
-	return;
-      }
-      // ** fall-thru **
-
-    case TransContext::STATE_WAL_AIO_WAIT:
-      _wal_finish(txc);
-      return;
-
-    case TransContext::STATE_WAL_CLEANUP:
-      txc->state = TransContext::STATE_FINISHING;
-      // ** fall-thru **
-
     case TransContext::TransContext::STATE_FINISHING:
       _txc_finish(txc);
       return;
@@ -2239,57 +2229,7 @@ void NewStore::_txc_state_proc(TransContext *txc)
   }
 }
 
-void NewStore::_txc_process_fsync(fsync_item *i)
-{
-  dout(20) << __func__ << " txc " << i->txc << dendl;
-  int r = ::fdatasync(i->fd);
-  if (r < 0) {
-    r = -errno;
-    derr << __func__ << " error from fdatasync on " << i->fd
-	 << " txc " << i->txc
-	 << ": " << cpp_strerror(r) << dendl;
-    assert(0 == "error from fdatasync");
-  }
-  VOID_TEMP_FAILURE_RETRY(::close(i->fd));
-  if (i->txc->finish_fsync()) {
-    _txc_finish_io(i->txc);
-  }
-  dout(20) << __func__ << " txc " << i->txc << " done" << dendl;
-}
-
-void NewStore::_txc_finish_io(TransContext *txc)
-{
-  dout(20) << __func__ << " " << txc << dendl;
-
-  /*
-   * we need to preserve the order of kv transactions,
-   * even though fsyncs will complete in any order.
-   */
-
-  OpSequencer *osr = txc->osr.get();
-  Mutex::Locker l(osr->qlock);
-  txc->state = TransContext::STATE_IO_DONE;
-
-  OpSequencer::q_list_t::iterator p = osr->q.iterator_to(*txc);
-  while (p != osr->q.begin()) {
-    --p;
-    if (p->state < TransContext::STATE_IO_DONE) {
-      dout(20) << __func__ << " " << txc << " blocked by " << &*p << " "
-	       << p->get_state_name() << dendl;
-      return;
-    }
-    if (p->state > TransContext::STATE_IO_DONE) {
-      ++p;
-      break;
-    }
-  }
-  do {
-    _txc_state_proc(&*p++);
-  } while (p != osr->q.end() &&
-	   p->state == TransContext::STATE_IO_DONE);
-}
-
-int NewStore::_txc_finalize(OpSequencer *osr, TransContext *txc)
+int KStore::_txc_finalize(OpSequencer *osr, TransContext *txc)
 {
   dout(20) << __func__ << " osr " << osr << " txc " << txc
 	   << " onodes " << txc->onodes << dendl;
@@ -2300,55 +2240,17 @@ int NewStore::_txc_finalize(OpSequencer *osr, TransContext *txc)
        ++p) {
     bufferlist bl;
     ::encode((*p)->onode, bl);
+    dout(20) << " onode size is " << bl.length() << dendl;
     txc->t->set(PREFIX_OBJ, (*p)->key, bl);
 
     Mutex::Locker l((*p)->flush_lock);
     (*p)->flush_txns.insert(txc);
   }
 
-  // journal wal items
-  if (txc->wal_txn) {
-    txc->wal_txn->seq = wal_seq.inc();
-    bufferlist bl;
-    ::encode(*txc->wal_txn, bl);
-    string key;
-    get_wal_key(txc->wal_txn->seq, &key);
-    txc->t->set(PREFIX_WAL, key, bl);
-  }
-
   return 0;
 }
 
-void NewStore::_txc_queue_fsync(TransContext *txc)
-{
-  dout(20) << __func__ << " txc " << txc << dendl;
-  fsync_wq.lock();
-  for (list<fsync_item>::iterator p = txc->sync_items.begin();
-       p != txc->sync_items.end();
-       ++p) {
-    fsync_wq._enqueue(&*p);
-    fsync_wq._wake();
-  }
-  fsync_wq.unlock();
-}
-
-void NewStore::_txc_do_sync_fsync(TransContext *txc)
-{
-  dout(20) << __func__ << " txc " << txc << dendl;
-  for (list<fsync_item>::iterator p = txc->sync_items.begin();
-       p != txc->sync_items.end(); ++p) {
-    dout(30) << __func__ << " fsync " << p->fd << dendl;
-    int r = ::fdatasync(p->fd);
-    if (r < 0) {
-      r = -errno;
-      derr << __func__ << " fsync: " << cpp_strerror(r) << dendl;
-      assert(0 == "fsync error");
-    }
-    VOID_TEMP_FAILURE_RETRY(::close(p->fd));
-  }
-}
-
-void NewStore::_txc_finish_kv(TransContext *txc)
+void KStore::_txc_finish_kv(TransContext *txc)
 {
   dout(20) << __func__ << " txc " << txc << dendl;
 
@@ -2374,7 +2276,7 @@ void NewStore::_txc_finish_kv(TransContext *txc)
   throttle_bytes.put(txc->bytes);
 }
 
-void NewStore::_txc_finish(TransContext *txc)
+void KStore::_txc_finish(TransContext *txc)
 {
   dout(20) << __func__ << " " << txc << " onodes " << txc->onodes << dendl;
   assert(txc->state == TransContext::STATE_FINISHING);
@@ -2387,8 +2289,10 @@ void NewStore::_txc_finish(TransContext *txc)
 	     << dendl;
     assert((*p)->flush_txns.count(txc));
     (*p)->flush_txns.erase(txc);
-    if ((*p)->flush_txns.empty())
+    if ((*p)->flush_txns.empty()) {
       (*p)->flush_cond.Signal();
+      (*p)->clear_pending_stripes();
+    }
   }
 
   // clear out refs
@@ -2399,9 +2303,6 @@ void NewStore::_txc_finish(TransContext *txc)
     txc->removed_collections.pop_front();
   }
 
-  throttle_wal_ops.put(txc->ops);
-  throttle_wal_bytes.put(txc->bytes);
-
   OpSequencerRef osr = txc->osr;
   osr->qlock.Lock();
   txc->state = TransContext::STATE_DONE;
@@ -2410,7 +2311,7 @@ void NewStore::_txc_finish(TransContext *txc)
   _osr_reap_done(osr.get());
 }
 
-void NewStore::_osr_reap_done(OpSequencer *osr)
+void KStore::_osr_reap_done(OpSequencer *osr)
 {
   Mutex::Locker l(osr->qlock);
   dout(20) << __func__ << " osr " << osr << dendl;
@@ -2423,53 +2324,24 @@ void NewStore::_osr_reap_done(OpSequencer *osr)
     }
 
     if (txc->first_collection) {
-      txc->first_collection->onode_map.trim(g_conf->newstore_onode_map_size);
+      txc->first_collection->onode_map.trim(g_conf->kstore_onode_map_size);
     }
 
     osr->q.pop_front();
     delete txc;
     osr->qcond.Signal();
+    if (osr->q.empty())
+      dout(20) << __func__ << " osr " << osr << " q now empty" << dendl;
   }
 }
 
-void NewStore::_aio_thread()
-{
-  dout(10) << __func__ << " start" << dendl;
-  while (!aio_stop) {
-    dout(40) << __func__ << " polling" << dendl;
-    int max = 16;
-    FS::aio_t *aio[max];
-    int r = aio_queue.get_next_completed(g_conf->newstore_aio_poll_ms,
-					 aio, max);
-    if (r < 0) {
-      derr << __func__ << " got " << cpp_strerror(r) << dendl;
-    }
-    if (r > 0) {
-      dout(30) << __func__ << " got " << r << " completed aios" << dendl;
-      for (int i = 0; i < r; ++i) {
-	TransContext *txc = static_cast<TransContext*>(aio[i]->priv);
-	int left = txc->num_aio.dec();
-	dout(10) << __func__ << " finished aio " << aio[i] << " txc " << txc
-		 << " state " << txc->get_state_name() << ", "
-		 << left << " aios left" << dendl;
-	VOID_TEMP_FAILURE_RETRY(::close(aio[i]->fd));
-	if (left == 0) {
-	  _txc_state_proc(txc);
-	}
-      }
-    }
-  }
-  dout(10) << __func__ << " end" << dendl;
-}
-
-void NewStore::_kv_sync_thread()
+void KStore::_kv_sync_thread()
 {
   dout(10) << __func__ << " start" << dendl;
   kv_lock.Lock();
   while (true) {
     assert(kv_committing.empty());
-    assert(wal_cleaning.empty());
-    if (kv_queue.empty() && wal_cleanup_queue.empty()) {
+    if (kv_queue.empty()) {
       if (kv_stop)
 	break;
       dout(20) << __func__ << " sleep" << dendl;
@@ -2477,274 +2349,48 @@ void NewStore::_kv_sync_thread()
       kv_cond.Wait(kv_lock);
       dout(20) << __func__ << " wake" << dendl;
     } else {
-      dout(20) << __func__ << " committing " << kv_queue.size()
-	       << " cleaning " << wal_cleanup_queue.size() << dendl;
+      dout(20) << __func__ << " committing " << kv_queue.size() << dendl;
       kv_committing.swap(kv_queue);
-      wal_cleaning.swap(wal_cleanup_queue);
-      utime_t start = ceph_clock_now(NULL);
-      kv_lock.Unlock();
-
-      if (!g_conf->newstore_sync_submit_transaction) {
-	for (std::deque<TransContext *>::iterator it = kv_committing.begin();
-	     it != kv_committing.end();
-	     ++it) {
-	  db->submit_transaction((*it)->t);
-	}
-      }
-
-      // one transaction to force a sync.  clean up wal keys while we
-      // are at it.
-      KeyValueDB::Transaction txc_cleanup_sync = db->get_transaction();
-      for (std::deque<TransContext *>::iterator it = wal_cleaning.begin();
-	    it != wal_cleaning.end();
-	    ++it) {
-	wal_transaction_t& wt =*(*it)->wal_txn;
-	// cleanup the data in overlays
-	for (list<wal_op_t>::iterator p = wt.ops.begin(); p != wt.ops.end(); ++p) {
-	  for (vector<overlay_t>::iterator q = p->overlays.begin();
-               q != p->overlays.end(); ++q) {
-            string key;
-            get_overlay_key(p->nid, q->key, &key);
-	    txc_cleanup_sync->rmkey(PREFIX_OVERLAY, key);
-	  }
-	}
-	// cleanup the shared overlays. this may double delete something we
-	// did above, but that's less work than doing careful ref counting
-	// of the overlay key/value pairs.
-	for (vector<string>::iterator p = wt.shared_overlay_keys.begin();
-             p != wt.shared_overlay_keys.end(); ++p) {
-	  txc_cleanup_sync->rmkey(PREFIX_OVERLAY, *p);
-	}
-	// cleanup the wal
-	string key;
-	get_wal_key(wt.seq, &key);
-	txc_cleanup_sync->rmkey(PREFIX_WAL, key);
-      }
-      db->submit_transaction_sync(txc_cleanup_sync);
-      utime_t finish = ceph_clock_now(NULL);
-      utime_t dur = finish - start;
-      dout(20) << __func__ << " committed " << kv_committing.size()
-	       << " cleaned " << wal_cleaning.size()
-	       << " in " << dur << dendl;
-      while (!kv_committing.empty()) {
-	TransContext *txc = kv_committing.front();
-	_txc_state_proc(txc);
-	kv_committing.pop_front();
-      }
-      while (!wal_cleaning.empty()) {
-	TransContext *txc = wal_cleaning.front();
-	_txc_state_proc(txc);
-	wal_cleaning.pop_front();
-      }
-
-      // this is as good a place as any ...
-      _reap_collections();
-
-      kv_lock.Lock();
-    }
-  }
-  kv_lock.Unlock();
-  dout(10) << __func__ << " finish" << dendl;
-}
-
-wal_op_t *NewStore::_get_wal_op(TransContext *txc)
-{
-  if (!txc->wal_txn) {
-    txc->wal_txn = new wal_transaction_t;
-  }
-  txc->wal_txn->ops.push_back(wal_op_t());
-  return &txc->wal_txn->ops.back();
-}
-
-int NewStore::_wal_apply(TransContext *txc)
-{
-  wal_transaction_t& wt = *txc->wal_txn;
-  dout(20) << __func__ << " txc " << txc << " seq " << wt.seq << dendl;
-  txc->state = TransContext::STATE_WAL_APPLYING;
-
-  assert(txc->pending_aios.empty());
-  int r = _do_wal_transaction(wt, txc);
-  assert(r == 0);
-
-  _txc_state_proc(txc);
-  return 0;
-}
-
-int NewStore::_wal_finish(TransContext *txc)
-{
-  wal_transaction_t& wt = *txc->wal_txn;
-  dout(20) << __func__ << " txc " << " seq " << wt.seq << txc << dendl;
-
-  Mutex::Locker l(kv_lock);
-  txc->state = TransContext::STATE_WAL_CLEANUP;
-  wal_cleanup_queue.push_back(txc);
-  kv_cond.SignalOne();
-  return 0;
-}
-
-int NewStore::_do_wal_transaction(wal_transaction_t& wt,
-				  TransContext *txc)
-{
-  vector<int> sync_fds;
-  sync_fds.reserve(wt.ops.size());
-
-  // read all the overlay data first for apply
-  _do_read_all_overlays(wt);
-
-  for (list<wal_op_t>::iterator p = wt.ops.begin(); p != wt.ops.end(); ++p) {
-    switch (p->op) {
-    case wal_op_t::OP_WRITE:
-      {
-	dout(20) << __func__ << " write " << p->fid << " "
-		 << p->offset << "~" << p->length << dendl;
-	unsigned flags = O_RDWR;
-	if (g_conf->newstore_o_direct &&
-	    (p->offset & ~CEPH_PAGE_MASK) == 0 &&
-	    (p->length & ~CEPH_PAGE_MASK) == 0) {
-	  dout(20) << __func__ << " page-aligned io, using O_DIRECT, "
-		   << p->data.buffers().size() << " buffers" << dendl;
-	  flags |= O_DIRECT | O_DSYNC;
-	  if (!p->data.is_page_aligned()) {
-	    dout(20) << __func__ << " rebuilding buffer to be page-aligned"
-		     << dendl;
-	    p->data.rebuild();
-	  }
-	}
-	int fd = _open_fid(p->fid, flags);
-	if (fd < 0)
-	  return fd;
-#ifdef HAVE_LIBAIO
-	if (g_conf->newstore_aio && txc && (flags & O_DIRECT)) {
-	  txc->pending_aios.push_back(FS::aio_t(txc, fd));
-	  FS::aio_t& aio = txc->pending_aios.back();
-	  p->data.prepare_iov(&aio.iov);
-	  aio.pwritev(p->offset);
-	  dout(2) << __func__ << " prepared aio " << &aio << dendl;
-	} else
-#endif
-	{
-	  int r = ::lseek64(fd, p->offset, SEEK_SET);
-	  if (r < 0) {
-	    r = -errno;
-	    derr << __func__ << " lseek64 on " << fd << " got: "
-		 << cpp_strerror(r) << dendl;
-	    return r;
-	  }
-	  r = p->data.write_fd(fd);
-	  if (r < 0) {
-	    derr << __func__ << " write_fd on " << fd << " got: "
-		 << cpp_strerror(r) << dendl;
-	    return r;
-	  }
-	  if (!(flags & O_DIRECT))
-	    sync_fds.push_back(fd);
-	  else
-	    VOID_TEMP_FAILURE_RETRY(::close(fd));
-	}
-      }
-      break;
-    case wal_op_t::OP_ZERO:
-      {
-	dout(20) << __func__ << " zero " << p->fid << " "
-		 << p->offset << "~" << p->length << dendl;
-	int fd = _open_fid(p->fid, O_RDWR);
-	if (fd < 0)
-	  return fd;
-	int r = fs->zero(fd, p->offset, p->length);
-	if (r < 0) {
-	  derr << __func__ << " zero on " << fd << " got: "
-	       << cpp_strerror(r) << dendl;
-	  return r;
+      utime_t start = ceph_clock_now(NULL);
+      kv_lock.Unlock();
+
+      dout(30) << __func__ << " committing txc " << kv_committing << dendl;
+
+      // one transaction to force a sync
+      KeyValueDB::Transaction t = db->get_transaction();
+      if (!g_conf->kstore_sync_submit_transaction) {
+	for (std::deque<TransContext *>::iterator it = kv_committing.begin();
+	     it != kv_committing.end();
+	     ++it) {
+	  db->submit_transaction((*it)->t);
 	}
-	// FIXME: do aio fdatasync?
-	sync_fds.push_back(fd);
       }
-      break;
-    case wal_op_t::OP_TRUNCATE:
-      {
-	dout(20) << __func__ << " truncate " << p->fid << " "
-		 << p->offset << dendl;
-	int fd = _open_fid(p->fid, O_RDWR);
-	if (fd < 0)
-	  return fd;
-	int r = ::ftruncate(fd, p->offset);
-	if (r < 0) {
-	  r = -errno;
-	  derr << __func__ << " truncate on " << fd << " got: "
-	       << cpp_strerror(r) << dendl;
-	  return r;
-	}
-	// note: we are not syncing this truncate.  instead, we are
-	// careful about only reading as much of the fragment as we
-	// know is valid, and truncating to expected size before
-	// extending the file.
+      db->submit_transaction_sync(t);
+      utime_t finish = ceph_clock_now(NULL);
+      utime_t dur = finish - start;
+      dout(20) << __func__ << " committed " << kv_committing.size()
+	       << " in " << dur << dendl;
+      while (!kv_committing.empty()) {
+	TransContext *txc = kv_committing.front();
+	_txc_state_proc(txc);
+	kv_committing.pop_front();
       }
-      break;
 
-    case wal_op_t::OP_REMOVE:
-      dout(20) << __func__ << " remove " << p->fid << dendl;
-      _remove_fid(p->fid);
-      // note: we do not fsync the directory.  instead, we tolerate
-      // leaked fragments in a crash.  in practice, this will be
-      // exceedingly rare.
-      break;
+      // this is as good a place as any ...
+      _reap_collections();
 
-    default:
-      assert(0 == "unrecognized wal op");
+      kv_lock.Lock();
     }
   }
-
-  for (vector<int>::iterator p = sync_fds.begin();
-       p != sync_fds.end();
-       ++p) {
-    int r = ::fdatasync(*p);
-    assert(r == 0);
-    VOID_TEMP_FAILURE_RETRY(::close(*p));
-  }
-
-  return 0;
+  kv_lock.Unlock();
+  dout(10) << __func__ << " finish" << dendl;
 }
 
-int NewStore::_wal_replay()
-{
-  dout(10) << __func__ << " start" << dendl;
-  KeyValueDB::Iterator it = db->get_iterator(PREFIX_WAL);
-  it->lower_bound(string());
-  KeyValueDB::Transaction cleanup = db->get_transaction();
-  int count = 0;
-  while (it->valid()) {
-    bufferlist bl = it->value();
-    bufferlist::iterator p = bl.begin();
-    wal_transaction_t wt;
-    try {
-      ::decode(wt, p);
-    } catch (buffer::error& e) {
-      derr << __func__ << " failed to decode wal txn " << it->key() << dendl;
-      return -EIO;
-    }
-
-    // Get the overlay data of the WAL for replay
-    _do_read_all_overlays(wt);
-    dout(20) << __func__ << " replay " << it->key() << dendl;
-    int r = _do_wal_transaction(wt, NULL);  // don't bother with aio here
-    if (r < 0)
-      return r;
-    cleanup->rmkey(PREFIX_WAL, it->key());
-    ++count;
-    it->next();
-  }
-  if (count) {
-    dout(10) << __func__ << " cleanup" << dendl;
-    db->submit_transaction_sync(cleanup);
-  }
-  dout(10) << __func__ << " completed " << count << " events" << dendl;
-  return 0;
-}
 
 // ---------------------------
 // transactions
 
-int NewStore::queue_transactions(
+int KStore::queue_transactions(
     Sequencer *posr,
     list<Transaction*>& tls,
     TrackedOpRef op,
@@ -2762,12 +2408,12 @@ int NewStore::queue_transactions(
   assert(posr);
   if (posr->p) {
     osr = static_cast<OpSequencer *>(posr->p.get());
-    dout(5) << __func__ << " existing " << osr << " " << *osr << dendl;
+    dout(10) << __func__ << " existing " << osr << " " << *osr << dendl;
   } else {
     osr = new OpSequencer;
     osr->parent = posr;
     posr->p = osr;
-    dout(5) << __func__ << " new " << osr << " " << *osr << dendl;
+    dout(10) << __func__ << " new " << osr << " " << *osr << dendl;
   }
 
   // prepare
@@ -2788,59 +2434,13 @@ int NewStore::queue_transactions(
 
   throttle_ops.get(txc->ops);
   throttle_bytes.get(txc->bytes);
-  throttle_wal_ops.get(txc->ops);
-  throttle_wal_bytes.get(txc->bytes);
 
   // execute (start)
   _txc_state_proc(txc);
   return 0;
 }
 
-void NewStore::_txc_aio_submit(TransContext *txc)
-{
-  int num = txc->pending_aios.size();
-  dout(10) << __func__ << " txc " << txc << " submitting " << num << dendl;
-  assert(num > 0);
-  txc->num_aio.set(num);
-
-  // move these aside, and get our end iterator position now, as the
-  // aios might complete as soon as they are submitted and queue more
-  // wal aio's.
-  list<FS::aio_t>::iterator e = txc->submitted_aios.begin();
-  txc->submitted_aios.splice(e, txc->pending_aios);
-  list<FS::aio_t>::iterator p = txc->submitted_aios.begin();
-  assert(p != e);
-  bool done = false;
-  while (!done) {
-    FS::aio_t& aio = *p;
-    dout(20) << __func__ << " aio " << &aio << " fd " << aio.fd << dendl;
-    for (vector<iovec>::iterator q = aio.iov.begin(); q != aio.iov.end(); ++q)
-      dout(30) << __func__ << "  iov " << (void*)q->iov_base
-	       << " len " << q->iov_len << dendl;
-    dout(30) << " fd " << aio.fd << " offset " << lseek64(aio.fd, 0, SEEK_CUR)
-	     << dendl;
-
-    // be careful: as soon as we submit aio we race with completion.
-    // since we are holding a ref take care not to dereference txc at
-    // all after that point.
-    list<FS::aio_t>::iterator cur = p;
-    ++p;
-    done = (p == e);
-
-    // do not dereference txc (or it's contents) after we submit (if
-    // done == true and we don't loop)
-    int retries = 0;
-    int r = aio_queue.submit(*cur, &retries);
-    if (retries)
-      derr << __func__ << " retries " << retries << dendl;
-    if (r) {
-      derr << " aio submit got " << cpp_strerror(r) << dendl;
-      assert(r == 0);
-    }
-  }
-}
-
-int NewStore::_txc_add_transaction(TransContext *txc, Transaction *t)
+int KStore::_txc_add_transaction(TransContext *txc, Transaction *t)
 {
   Transaction::iterator i = t->begin();
   int pos = 0;
@@ -2982,7 +2582,6 @@ int NewStore::_txc_add_transaction(TransContext *txc, Transaction *t)
 
     case Transaction::OP_COLL_HINT:
       {
-        coll_t cid = i.get_cid(op->cid);
         uint32_t type = op->hint_type;
         bufferlist hint;
         i.decode_bl(hint);
@@ -3162,7 +2761,7 @@ int NewStore::_txc_add_transaction(TransContext *txc, Transaction *t)
 // -----------------
 // write operations
 
-int NewStore::_touch(TransContext *txc,
+int KStore::_touch(TransContext *txc,
 		     CollectionRef& c,
 		     const ghobject_t& oid)
 {
@@ -3178,454 +2777,205 @@ int NewStore::_touch(TransContext *txc,
   return r;
 }
 
-int NewStore::_do_overlay_clear(TransContext *txc,
-				OnodeRef o)
+void KStore::_dump_onode(OnodeRef o)
 {
-  dout(10) << __func__ << " " << o->oid << dendl;
-
-  map<uint64_t,overlay_t>::iterator p = o->onode.overlay_map.begin();
-  while (p != o->onode.overlay_map.end()) {
-    dout(20) << __func__ << " rm " << p->first << " " << p->second << dendl;
+  dout(30) << __func__ << " " << o
+	   << " nid " << o->onode.nid
+	   << " size " << o->onode.size
+	   << " expected_object_size " << o->onode.expected_object_size
+	   << " expected_write_size " << o->onode.expected_write_size
+	   << dendl;
+  for (map<string,bufferptr>::iterator p = o->onode.attrs.begin();
+       p != o->onode.attrs.end();
+       ++p) {
+    dout(30) << __func__ << "  attr " << p->first
+	     << " len " << p->second.length() << dendl;
+  }
+}
+
+void KStore::_pad_zeros(
+  OnodeRef o,
+  bufferlist *bl, uint64_t *offset, uint64_t *length,
+  uint64_t block_size)
+{
+  dout(40) << "before:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+  // front
+  size_t front_pad = *offset % block_size;
+  size_t back_pad = 0;
+  if (front_pad) {
+    size_t front_copy = MIN(block_size - front_pad, *length);
+    bufferptr z = buffer::create_page_aligned(block_size);
+    memset(z.c_str(), 0, front_pad);
+    memcpy(z.c_str() + front_pad, bl->get_contiguous(0, front_copy), front_copy);
+    if (front_copy + front_pad < block_size) {
+      back_pad = block_size - (*length + front_pad);
+      memset(z.c_str() + front_pad + *length, 0, back_pad);
+    }
+    bufferlist old, t;
+    old.swap(*bl);
+    t.substr_of(old, front_copy, *length - front_copy);
+    bl->append(z);
+    bl->claim_append(t);
+    *offset -= front_pad;
+    *length += front_pad + back_pad;
+  }
+
+  // back
+  uint64_t end = *offset + *length;
+  unsigned back_copy = end % block_size;
+  if (back_copy) {
+    assert(back_pad == 0);
+    back_pad = block_size - back_copy;
+    assert(back_copy <= *length);
+    bufferptr tail(block_size);
+    memcpy(tail.c_str(), bl->get_contiguous(*length - back_copy, back_copy),
+	   back_copy);
+    memset(tail.c_str() + back_copy, 0, back_pad);
+    bufferlist old;
+    old.swap(*bl);
+    bl->substr_of(old, 0, *length - back_copy);
+    bl->append(tail);
+    *length += back_pad;
+    if (end > o->onode.size && g_conf->kstore_cache_tails) {
+      o->tail_bl.clear();
+      o->tail_bl.append(tail, 0, back_copy);
+      o->tail_offset = end - back_copy;
+      dout(20) << __func__ << " cached "<< back_copy << " of tail block at "
+	       << o->tail_offset << dendl;
+    }
+  }
+  dout(20) << __func__ << " pad " << front_pad << " + " << back_pad
+	   << " on front/back, now " << *offset << "~" << *length << dendl;
+  dout(40) << "after:\n";
+  bl->hexdump(*_dout);
+  *_dout << dendl;
+}
+
+void KStore::_do_read_stripe(OnodeRef o, uint64_t offset, bufferlist *pbl)
+{
+  map<uint64_t,bufferlist>::iterator p = o->pending_stripes.find(offset);
+  if (p == o->pending_stripes.end()) {
     string key;
-    get_overlay_key(o->onode.nid, p->first, &key);
-    txc->t->rmkey(PREFIX_OVERLAY, key);
-    o->onode.overlay_map.erase(p++);
-  }
-  o->onode.shared_overlays.clear();
-  return 0;
-}
-
-int NewStore::_do_overlay_trim(TransContext *txc,
-			       OnodeRef o,
-			       uint64_t offset,
-			       uint64_t length)
-{
-  dout(10) << __func__ << " " << o->oid << " "
-	   << offset << "~" << length << dendl;
-  int changed = 0;
-
-  map<uint64_t,overlay_t>::iterator p =
-    o->onode.overlay_map.lower_bound(offset);
-  if (p != o->onode.overlay_map.begin()) {
-    --p;
-  }
-  while (p != o->onode.overlay_map.end()) {
-    if (p->first >= offset + length) {
-      dout(20) << __func__ << " stop at " << p->first << " " << p->second
-	       << dendl;
-      break;
-    }
-    if (p->first + p->second.length <= offset) {
-      dout(20) << __func__ << " skip " << p->first << " " << p->second
-	       << dendl;
-      ++p;
-      continue;
-    }
-    if (p->first >= offset &&
-	p->first + p->second.length <= offset + length) {
-      dout(20) << __func__ << " rm " << p->first << " " << p->second
-	       << dendl;
-      if (o->onode.shared_overlays.count(p->second.key) == 0) {
-	string key;
-	get_overlay_key(o->onode.nid, p->first, &key);
-	txc->t->rmkey(PREFIX_OVERLAY, key);
-      }
-      o->onode.overlay_map.erase(p++);
-      ++changed;
-      continue;
-    }
-    if (p->first >= offset) {
-      dout(20) << __func__ << " trim_front " << p->first << " " << p->second
-	       << dendl;
-      overlay_t& ov = o->onode.overlay_map[offset + length] = p->second;
-      uint64_t by = offset + length - p->first;
-      ov.value_offset += by;
-      ov.length -= by;
-      o->onode.overlay_map.erase(p++);
-      ++changed;
-      continue;
-    }
-    if (p->first < offset &&
-	p->first + p->second.length <= offset + length) {
-      dout(20) << __func__ << " trim_tail " << p->first << " " << p->second
-	       << dendl;
-      p->second.length = offset - p->first;
-      ++p;
-      ++changed;
-      continue;
-    }
-    dout(20) << __func__ << " split " << p->first << " " << p->second
-	     << dendl;
-    assert(p->first < offset);
-    assert(p->first + p->second.length > offset + length);
-    overlay_t& nov = o->onode.overlay_map[offset + length] = p->second;
-    p->second.length = offset - p->first;
-    uint64_t by = offset + length - p->first;
-    nov.value_offset += by;
-    nov.length -= by;
-    o->onode.shared_overlays.insert(p->second.key);
-    ++p;
-    ++changed;
+    get_data_key(o->onode.nid, offset, &key);
+    db->get(PREFIX_DATA, key, pbl);
+    o->pending_stripes[offset] = *pbl;
+  } else {
+    *pbl = p->second;
   }
-  return changed;
 }
 
-int NewStore::_do_overlay_write(TransContext *txc,
-				OnodeRef o,
-				uint64_t offset,
-				uint64_t length,
-				const bufferlist& bl)
+void KStore::_do_write_stripe(TransContext *txc, OnodeRef o,
+			      uint64_t offset, bufferlist& bl)
 {
-  _do_overlay_trim(txc, o, offset, length);
-
-  dout(10) << __func__ << " " << o->oid << " "
-	   << offset << "~" << length << dendl;
-  overlay_t& ov = o->onode.overlay_map[offset] =
-    overlay_t(++o->onode.last_overlay_key, 0, length);
-  dout(20) << __func__ << " added " << offset << " " << ov << dendl;
+  o->pending_stripes[offset] = bl;
   string key;
-  get_overlay_key(o->onode.nid, o->onode.last_overlay_key, &key);
-  txc->t->set(PREFIX_OVERLAY, key, bl);
-  return 0;
-}
-
-int NewStore::_do_write_all_overlays(TransContext *txc,
-				     OnodeRef o)
-{
-  if (o->onode.overlay_map.empty())
-    return 0;
-
-  // overwrite to new fid
-  if (o->onode.data_map.empty()) {
-    // create
-    fragment_t &f = o->onode.data_map[0];
-    f.offset = 0;
-    f.length = o->onode.size;
-    int fd = _create_fid(txc, &f.fid, O_RDWR);
-    if (fd < 0) {
-      return fd;
-    }
-    VOID_TEMP_FAILURE_RETRY(::close(fd));
-    dout(20) << __func__ << " create " << f.fid << dendl;
-  }
-
-  assert(o->onode.data_map.size() == 1);
-  fragment_t& f = o->onode.data_map.begin()->second;
-  assert(f.offset == 0);
-  assert(f.length == o->onode.size);
-
-  for (map<uint64_t,overlay_t>::iterator p = o->onode.overlay_map.begin();
-       p != o->onode.overlay_map.end(); ) {
-    dout(10) << __func__ << " overlay " << p->first
-	     << "~" << p->second << dendl;
-
-    wal_op_t *op = _get_wal_op(txc);
-    op->op = wal_op_t::OP_WRITE;
-    op->offset = p->first;
-    op->length = p->second.length;
-    op->fid = f.fid;
-    // The overlays will be removed from the db after applying the WAL
-    op->nid = o->onode.nid;
-    op->overlays.push_back(p->second);
-
-    // Combine with later overlays if contiguous
-    map<uint64_t,overlay_t>::iterator prev = p, next = p;
-    ++next;
-    while (next != o->onode.overlay_map.end()) {
-      if (prev->first + prev->second.length == next->first) {
-        dout(10) << __func__ << " combining overlay " << next->first
-                 << "~" << next->second << dendl;
-        op->length += next->second.length;
-        op->overlays.push_back(next->second);
-
-        ++prev;
-        ++next;
-      } else {
-	break;
-      }
-    }
-    p = next;
-  }
-
-  // put the shared overlay keys into the WAL transaction, so that we
-  // can cleanup them later after applying the WAL
-  for (set<uint64_t>::iterator p = o->onode.shared_overlays.begin();
-       p != o->onode.shared_overlays.end();
-       ++p) {
-    dout(10) << __func__ << " shared overlay " << *p << dendl;
-    string key;
-    get_overlay_key(o->onode.nid, *p, &key);
-    txc->wal_txn->shared_overlay_keys.push_back(key);
-  }
-
-  o->onode.overlay_map.clear();
-  o->onode.shared_overlays.clear();
-  txc->write_onode(o);
-  return 0;
+  get_data_key(o->onode.nid, offset, &key);
+  txc->t->set(PREFIX_DATA, key, bl);
 }
 
-void NewStore::_do_read_all_overlays(wal_transaction_t& wt)
+void KStore::_do_remove_stripe(TransContext *txc, OnodeRef o, uint64_t offset)
 {
-  for (list<wal_op_t>::iterator p = wt.ops.begin(); p != wt.ops.end(); ++p) {
-    for (vector<overlay_t>::iterator q = p->overlays.begin();
-         q != p->overlays.end(); ++q) {
-      string key;
-      get_overlay_key(p->nid, q->key, &key);
-      bufferlist bl, bl_data;
-      db->get(PREFIX_OVERLAY, key, &bl);
-      bl_data.substr_of(bl, q->value_offset, q->length);
-      p->data.claim_append(bl_data);
-    }
-  }
-  return;
+  o->pending_stripes.erase(offset);
+  string key;
+  get_data_key(o->onode.nid, offset, &key);
+  txc->t->rmkey(PREFIX_DATA, key);
 }
 
-int NewStore::_do_write(TransContext *txc,
+int KStore::_do_write(TransContext *txc,
 			OnodeRef o,
 			uint64_t offset, uint64_t length,
-			bufferlist& bl,
+			bufferlist& orig_bl,
 			uint32_t fadvise_flags)
 {
-  int fd = -1;
   int r = 0;
-  unsigned flags;
-
-  dout(20) << __func__ << " have " << o->onode.size
-	   << " bytes in " << o->onode.data_map.size()
-	   << " fragments" << dendl;
 
+  dout(20) << __func__
+	   << " " << o->oid << " " << offset << "~" << length
+	   << " - have " << o->onode.size
+	   << " bytes, nid " << o->onode.nid << dendl;
+  _dump_onode(o);
   o->exists = true;
 
   if (length == 0) {
-    dout(20) << __func__ << " zero-length write" << dendl;
-    goto out;
-  }
-
-  if ((int)o->onode.overlay_map.size() < g_conf->newstore_overlay_max &&
-      (int)length <= g_conf->newstore_overlay_max_length) {
-    // write an overlay
-    r = _do_overlay_write(txc, o, offset, length, bl);
-    if (r < 0)
-      goto out;
-    if (offset + length > o->onode.size) {
-      // make sure the data fragment matches
-      if (!o->onode.data_map.empty()) {
-	assert(o->onode.data_map.size() == 1);
-	fragment_t& f = o->onode.data_map.begin()->second;
-	assert(f.offset == 0);
-	assert(f.length == o->onode.size);
-	r = _clean_fid_tail(txc, f);
-	if (r < 0)
-	  goto out;
-	f.length = offset + length;
-      }
-      dout(20) << __func__ << " extending size to " << offset + length << dendl;
-      o->onode.size = offset + length;
-    }
-    txc->write_onode(o);
-    r = 0;
-    goto out;
+    return 0;
   }
 
-  flags = O_RDWR;
-  if (g_conf->newstore_o_direct &&
-      (offset & ~CEPH_PAGE_MASK) == 0 &&
-      (length & ~CEPH_PAGE_MASK) == 0) {
-    dout(20) << __func__ << " page-aligned, can use O_DIRECT, "
-	     << bl.buffers().size() << " buffers" << dendl;
-    flags |= O_DIRECT | O_DSYNC;
-    if (!bl.is_page_aligned()) {
-      dout(20) << __func__ << " rebuilding buffer to be page-aligned" << dendl;
-      bl.rebuild();
-    }
+  uint64_t stripe_size = o->onode.stripe_size;
+  if (!stripe_size) {
+    o->onode.stripe_size = g_conf->kstore_default_stripe_size;
+    stripe_size = o->onode.stripe_size;
   }
 
-  if (o->onode.size <= offset ||
-      o->onode.size == 0 ||
-      o->onode.data_map.empty()) {
-    uint64_t x_offset;
-    if (o->onode.data_map.empty()) {
-      // create
-      fragment_t &f = o->onode.data_map[0];
-      f.offset = 0;
-      f.length = MAX(offset + length, o->onode.size);
-      fd = _create_fid(txc, &f.fid, flags);
-      if (fd < 0) {
-	r = fd;
-	goto out;
-      }
-      x_offset = offset;
-      dout(20) << __func__ << " create " << f.fid << " writing "
-	       << offset << "~" << length << dendl;
-    } else {
-      // append (possibly with gap)
-      assert(o->onode.data_map.size() == 1);
-      fragment_t &f = o->onode.data_map.rbegin()->second;
-      fd = _open_fid(f.fid, flags);
-      if (fd < 0) {
-	r = fd;
-	goto out;
-      }
-      r = _clean_fid_tail_fd(f, fd); // in case there is trailing crap
-      if (r < 0) {
-	goto out;
-      }
-      f.length = (offset + length) - f.offset;
-      x_offset = offset - f.offset;
-      dout(20) << __func__ << " append " << f.fid << " writing "
-	       << (offset - f.offset) << "~" << length << dendl;
-    }
-    if (offset + length > o->onode.size) {
-      o->onode.size = offset + length;
+  unsigned bl_off = 0;
+  while (length > 0) {
+    uint64_t offset_rem = offset % stripe_size;
+    uint64_t end_rem = (offset + length) % stripe_size;
+    if (offset_rem == 0 && end_rem == 0) {
+      bufferlist bl;
+      bl.substr_of(orig_bl, bl_off, stripe_size);
+      dout(30) << __func__ << " full stripe " << offset << dendl;
+      _do_write_stripe(txc, o, offset, bl);
+      offset += stripe_size;
+      length -= stripe_size;
+      bl_off += stripe_size;
+      continue;
     }
-#ifdef HAVE_LIBAIO
-    if (g_conf->newstore_aio && (flags & O_DIRECT)) {
-      txc->pending_aios.push_back(FS::aio_t(txc, fd));
-      FS::aio_t& aio = txc->pending_aios.back();
-      bl.prepare_iov(&aio.iov);
-      txc->aio_bl.append(bl);
-      aio.pwritev(x_offset);
-      dout(2) << __func__ << " prepared aio " << &aio << dendl;
-    } else
-#endif
-    {
-      ::lseek64(fd, x_offset, SEEK_SET);
-      r = bl.write_fd(fd);
-      if (r < 0) {
-	derr << __func__ << " bl.write_fd error: " << cpp_strerror(r) << dendl;
-	goto out;
+    uint64_t stripe_off = offset - offset_rem;
+    bufferlist prev;
+    _do_read_stripe(o, stripe_off, &prev);
+    dout(20) << __func__ << " read previous stripe " << stripe_off
+	     << ", got " << prev.length() << dendl;
+    bufferlist bl;
+    if (offset_rem) {
+      unsigned p = MIN(prev.length(), offset_rem);
+      if (p) {
+	dout(20) << __func__ << " reuse leading " << p << " bytes" << dendl;
+	bl.substr_of(prev, 0, p);
+      }
+      if (p < offset_rem) {
+	bufferptr z(offset_rem - p);
+	dout(20) << __func__ << " add leading " << z.length() << " zeros" << dendl;
+	z.zero();
+	bl.append(z);
       }
-      txc->sync_fd(fd);
-    }
-    r = 0;
-    goto out;
-  }
-
-  if (offset == 0 &&
-      length >= o->onode.size) {
-    // overwrite to new fid
-    assert(o->onode.data_map.size() == 1);
-    fragment_t& f = o->onode.data_map.begin()->second;
-    assert(f.offset == 0);
-    assert(f.length == o->onode.size);
-
-    _do_overlay_clear(txc, o);
-
-    wal_op_t *op = _get_wal_op(txc);
-    op->op = wal_op_t::OP_REMOVE;
-    op->fid = f.fid;
-
-    f.length = length;
-    o->onode.size = length;
-    fd = _create_fid(txc, &f.fid, O_RDWR);
-    if (fd < 0) {
-      r = fd;
-      goto out;
     }
-    dout(20) << __func__ << " replace old fid " << op->fid
-	     << " with new fid " << f.fid
-	     << ", writing " << offset << "~" << length << dendl;
-
-#ifdef HAVE_LIBAIO
-    if (g_conf->newstore_aio && (flags & O_DIRECT)) {
-      txc->pending_aios.push_back(FS::aio_t(txc, fd));
-      FS::aio_t& aio = txc->pending_aios.back();
-      bl.prepare_iov(&aio.iov);
-      txc->aio_bl.append(bl);
-      aio.pwritev(0);
-      dout(2) << __func__ << " prepared aio " << &aio << dendl;
-    } else
-#endif
-    {
-      r = bl.write_fd(fd);
-      if (r < 0) {
-	derr << __func__ << " bl.write_fd error: " << cpp_strerror(r) << dendl;
-	goto out;
+    unsigned use = stripe_size - offset_rem;
+    if (use > length)
+      use -= stripe_size - end_rem;
+    dout(20) << __func__ << " using " << use << " for this stripe" << dendl;
+    bufferlist t;
+    t.substr_of(orig_bl, bl_off, use);
+    bl.claim_append(t);
+    bl_off += use;
+    if (end_rem) {
+      if (end_rem < prev.length()) {
+	unsigned l = prev.length() - end_rem;
+	dout(20) << __func__ << " reuse trailing " << l << " bytes" << dendl;
+	bufferlist t;
+	t.substr_of(prev, end_rem, l);
+	bl.claim_append(t);
       }
-      txc->sync_fd(fd);
-    }
-    r = 0;
-    goto out;
-  }
-
-  if (true) {
-    // WAL
-    assert(o->onode.data_map.size() == 1);
-    fragment_t& f = o->onode.data_map.begin()->second;
-    assert(f.offset == 0);
-    assert(f.length == o->onode.size);
-    r = _do_write_all_overlays(txc, o);
-    if (r < 0)
-      goto out;
-    r = _clean_fid_tail(txc, f);
-    if (r < 0)
-      goto out;
-    wal_op_t *op = _get_wal_op(txc);
-    op->op = wal_op_t::OP_WRITE;
-    op->offset = offset - f.offset;
-    op->length = length;
-    op->fid = f.fid;
-    op->data = bl;
-    if (offset + length > o->onode.size) {
-      o->onode.size = offset + length;
     }
-    if (offset + length - f.offset > f.length) {
-      f.length = offset + length - f.offset;
-    }
-    dout(20) << __func__ << " wal " << f.fid << " write "
-	     << (offset - f.offset) << "~" << length << dendl;
+    dout(30) << " writing:\n";
+    bl.hexdump(*_dout);
+    *_dout << dendl;
+    _do_write_stripe(txc, o, stripe_off, bl);
+    offset += use;
+    length -= use;
   }
-  r = 0;
 
- out:
-  return r;
-}
-
-int NewStore::_clean_fid_tail_fd(const fragment_t& f, int fd)
-{
-  struct stat st;
-  int r = ::fstat(fd, &st);
-  if (r < 0) {
-    r = -errno;
-    derr << __func__ << " failed to fstat " << f.fid << ": "
-	 << cpp_strerror(r) << dendl;
-    return r;
-  }
-  if (st.st_size > f.length) {
-    dout(20) << __func__ << " frag " << f.fid << " is long, truncating"
+  if (offset > o->onode.size) {
+    dout(20) << __func__ << " extending size to " << offset + length
 	     << dendl;
-    r = ::ftruncate(fd, f.length);
-    if (r < 0) {
-      derr << __func__ << " failed to ftruncate " << f.fid << ": "
-	   << cpp_strerror(r) << dendl;
-      return r;
-    }
-    return 1;
+    o->onode.size = offset;
   }
-  return 0;
-}
 
-int NewStore::_clean_fid_tail(TransContext *txc, const fragment_t& f)
-{
-  int fd = _open_fid(f.fid, O_RDWR);
-  if (fd < 0) {
-    return fd;
-  }
-  int r = _clean_fid_tail_fd(f, fd);
-  if (r < 0) {
-    return r;
-  }
-  if (r > 0) {
-    txc->sync_fd(fd);
-  } else {
-    // all good!
-    VOID_TEMP_FAILURE_RETRY(::close(fd));
-  }
-  return 0;
+  return r;
 }
 
-
-int NewStore::_write(TransContext *txc,
+int KStore::_write(TransContext *txc,
 		     CollectionRef& c,
 		     const ghobject_t& oid,
 		     uint64_t offset, size_t length,
@@ -3647,7 +2997,7 @@ int NewStore::_write(TransContext *txc,
   return r;
 }
 
-int NewStore::_zero(TransContext *txc,
+int KStore::_zero(TransContext *txc,
 		    CollectionRef& c,
 		    const ghobject_t& oid,
 		    uint64_t offset, size_t length)
@@ -3661,159 +3011,104 @@ int NewStore::_zero(TransContext *txc,
   OnodeRef o = c->get_onode(oid, true);
   _assign_nid(txc, o);
 
-  // overlay
-  if (_do_overlay_trim(txc, o, offset, length) > 0)
-    txc->write_onode(o);
-
-  if (o->onode.data_map.empty()) {
-    // we're already a big hole
-    if (offset + length > o->onode.size) {
-      o->onode.size = offset + length;
-      txc->write_onode(o);
-    }
-  } else {
-    assert(o->onode.data_map.size() == 1);
-    fragment_t& f = o->onode.data_map.begin()->second;
-    assert(f.offset == 0);
-    assert(f.length == o->onode.size);
-
-    r = _clean_fid_tail(txc, f);
-    if (r < 0)
-      goto out;
-
-    if (offset >= o->onode.size) {
-      // after tail
-      int fd = _open_fid(f.fid, O_RDWR);
-      if (fd < 0) {
-	r = fd;
-	goto out;
-      }
-      f.length = (offset + length) - f.offset;
-      r = ::ftruncate(fd, f.length);
-      assert(r == 0);   // this shouldn't fail
-      dout(20) << __func__ << " tail " << f.fid << " truncating up to "
-	       << f.length << dendl;
-      o->onode.size = offset + length;
-      txc->write_onode(o);
-    } else {
-      // WAL
-      wal_op_t *op = _get_wal_op(txc);
-      op->op = wal_op_t::OP_ZERO;
-      op->offset = offset - f.offset;
-      op->length = length;
-      op->fid = f.fid;
-      if (offset + length > o->onode.size) {
-	f.length = offset + length - f.offset;
-	o->onode.size = offset + length;
-	txc->write_onode(o);
+  uint64_t stripe_size = o->onode.stripe_size;
+  if (stripe_size) {
+    uint64_t end = offset + length;
+    uint64_t pos = offset;
+    uint64_t stripe_off = pos % stripe_size;
+    while (pos < offset + length) {
+      if (stripe_off || end - pos < stripe_size) {
+	bufferlist stripe;
+	_do_read_stripe(o, pos - stripe_off, &stripe);
+	dout(30) << __func__ << " stripe " << pos - stripe_off << " got "
+		 << stripe.length() << dendl;
+	bufferlist bl;
+	bl.substr_of(stripe, 0, MIN(stripe.length(), stripe_off));
+	if (end >= pos - stripe_off + stripe_size ||
+	    end >= o->onode.size) {
+	  dout(20) << __func__ << " truncated stripe " << pos - stripe_off
+		   << " to " << bl.length() << dendl;
+	} else {
+	  bufferptr z(end - (pos - stripe_off + bl.length()));
+	  z.zero();
+	  bl.append(z);
+	  dout(20) << __func__ << " adding " << z.length() << " of zeros" << dendl;
+	  if (stripe.length() > bl.length()) {
+	    unsigned l = stripe.length() - bl.length();
+	    bufferlist t;
+	    t.substr_of(stripe, stripe.length() - l, l);
+	    dout(20) << __func__ << " keeping tail " << l << " of stripe" << dendl;
+	    bl.claim_append(t);
+	  }
+	}
+	_do_write_stripe(txc, o, pos - stripe_off, bl);
+	pos += stripe_size - stripe_off;
+	stripe_off = 0;
+      } else {
+	dout(20) << __func__ << " rm stripe " << pos << dendl;
+	_do_remove_stripe(txc, o, pos - stripe_off);
+	pos += stripe_size;
       }
     }
   }
+  if (offset + length > o->onode.size) {
+    o->onode.size = offset + length;
+    dout(20) << __func__ << " extending size to " << offset + length
+	     << dendl;
+  }
+  txc->write_onode(o);
 
- out:
   dout(10) << __func__ << " " << c->cid << " " << oid
 	   << " " << offset << "~" << length
 	   << " = " << r << dendl;
   return r;
 }
 
-int NewStore::_do_truncate(TransContext *txc, OnodeRef o, uint64_t offset)
-{
-  // trim down fragments
-  map<uint64_t,fragment_t>::iterator fp = o->onode.data_map.end();
-  if (fp != o->onode.data_map.begin())
-    --fp;
-  while (fp != o->onode.data_map.end()) {
-    if (fp->first + fp->second.length <= offset) {
-      break;
-    }
-    if (fp->first >= offset) {
-      dout(20) << __func__ << " wal rm fragment " << fp->first << " "
-	       << fp->second << dendl;
-      wal_op_t *op = _get_wal_op(txc);
-      op->op = wal_op_t::OP_REMOVE;
-      op->fid = fp->second.fid;
-      if (fp != o->onode.data_map.begin()) {
-	o->onode.data_map.erase(fp--);
-	continue;
+int KStore::_do_truncate(TransContext *txc, OnodeRef o, uint64_t offset)
+{
+  uint64_t stripe_size = o->onode.stripe_size;
+
+  // trim down stripes
+  if (stripe_size) {
+    uint64_t pos = offset;
+    uint64_t stripe_off = pos % stripe_size;
+    while (pos < o->onode.size) {
+      if (stripe_off) {
+	bufferlist stripe;
+	_do_read_stripe(o, pos - stripe_off, &stripe);
+	dout(30) << __func__ << " stripe " << pos - stripe_off << " got "
+		 << stripe.length() << dendl;
+	bufferlist t;
+	t.substr_of(stripe, 0, MIN(stripe_off, stripe.length()));
+	_do_write_stripe(txc, o, pos - stripe_off, t);
+	dout(20) << __func__ << " truncated stripe " << pos - stripe_off
+		 << " to " << t.length() << dendl;
+	pos += stripe_size - stripe_off;
+	stripe_off = 0;
       } else {
-	o->onode.data_map.erase(fp);
-	break;
+	dout(20) << __func__ << " rm stripe " << pos << dendl;
+	_do_remove_stripe(txc, o, pos - stripe_off);
+	pos += stripe_size;
       }
-    } else {
-      assert(fp->first + fp->second.length > offset);
-      assert(fp->first < offset);
-      uint64_t newlen = offset - fp->first;
-      dout(20) << __func__ << " wal truncate fragment " << fp->first << " "
-	       << fp->second << " to " << newlen << dendl;
-      fragment_t& f = fp->second;
-      f.length = newlen;
-      wal_op_t *op = _get_wal_op(txc);
-      op->op = wal_op_t::OP_TRUNCATE;
-      op->offset = offset;
-      op->fid = f.fid;
-      break;
     }
-  }
-
-  // truncate up trailing fragment?
-  if (!o->onode.data_map.empty() && offset > o->onode.size) {
-    // resize file up.  make sure we don't have trailing bytes
-    assert(o->onode.data_map.size() == 1);
-    fragment_t& f = o->onode.data_map.begin()->second;
-    assert(f.offset == 0);
-    assert(f.length == o->onode.size);
-    dout(20) << __func__ << " truncate up " << f << " to " << offset << dendl;
-    int r = _clean_fid_tail(txc, f);
-    if (r < 0)
-      return r;
-    f.length = offset;
-  }
 
-  // trim down overlays
-  map<uint64_t,overlay_t>::iterator op = o->onode.overlay_map.end();
-  if (op != o->onode.overlay_map.begin())
-    --op;
-  while (op != o->onode.overlay_map.end()) {
-    if (op->first + op->second.length <= offset) {
-      break;
-    }
-    if (op->first >= offset) {
-      if (!o->onode.shared_overlays.count(op->second.key)) {
-	dout(20) << __func__ << " rm overlay " << op->first << " "
-		 << op->second << dendl;
-	string key;
-	get_overlay_key(o->onode.nid, op->second.key, &key);
-	txc->t->rmkey(PREFIX_OVERLAY, key);
-      } else {
-	dout(20) << __func__ << " rm overlay " << op->first << " "
-		 << op->second << " (shared)" << dendl;
-      }
-      if (op != o->onode.overlay_map.begin()) {
-	o->onode.overlay_map.erase(op--);
-	continue;
-      } else {
-	o->onode.overlay_map.erase(op);
-	break;
+    // trim down cached tail
+    if (o->tail_bl.length()) {
+      if (offset / stripe_size != o->onode.size / stripe_size) {
+	dout(20) << __func__ << " clear cached tail" << dendl;
+	o->clear_tail();
       }
-    } else {
-      assert(op->first + op->second.length > offset);
-      assert(op->first < offset);
-      uint64_t newlen = offset - op->first;
-      dout(20) << __func__ << " truncate overlay " << op->first << " "
-	       << op->second << " to " << newlen << dendl;
-      overlay_t& ov = op->second;
-      ov.length = newlen;
-      break;
     }
   }
 
   o->onode.size = offset;
+  dout(10) << __func__ << " truncate size to " << offset << dendl;
+
   txc->write_onode(o);
   return 0;
 }
 
-int NewStore::_truncate(TransContext *txc,
+int KStore::_truncate(TransContext *txc,
 			CollectionRef& c,
 			const ghobject_t& oid,
 			uint64_t offset)
@@ -3825,7 +3120,7 @@ int NewStore::_truncate(TransContext *txc,
 
   RWLock::WLocker l(c->lock);
   OnodeRef o = c->get_onode(oid, false);
-  if (!o->exists) {
+  if (!o || !o->exists) {
     r = -ENOENT;
     goto out;
   }
@@ -3838,33 +3133,26 @@ int NewStore::_truncate(TransContext *txc,
   return r;
 }
 
-int NewStore::_do_remove(TransContext *txc,
-			 OnodeRef o)
+int KStore::_do_remove(TransContext *txc,
+		       OnodeRef o)
 {
   string key;
-  o->exists = false;
-  if (!o->onode.data_map.empty()) {
-    for (map<uint64_t,fragment_t>::iterator p = o->onode.data_map.begin();
-	 p != o->onode.data_map.end();
-	 ++p) {
-      dout(20) << __func__ << " will wal remove " << p->second.fid << dendl;
-      wal_op_t *op = _get_wal_op(txc);
-      op->op = wal_op_t::OP_REMOVE;
-      op->fid = p->second.fid;
-    }
-  }
-  o->onode.data_map.clear();
+
+  _do_truncate(txc, o, 0);
+
   o->onode.size = 0;
   if (o->onode.omap_head) {
     _do_omap_clear(txc, o->onode.omap_head);
   }
-
+  o->exists = false;
+  o->onode = kstore_onode_t();
+  txc->onodes.erase(o);
   get_object_key(o->oid, &key);
   txc->t->rmkey(PREFIX_OBJ, key);
   return 0;
 }
 
-int NewStore::_remove(TransContext *txc,
+int KStore::_remove(TransContext *txc,
 		      CollectionRef& c,
 		      const ghobject_t& oid)
 {
@@ -3883,7 +3171,7 @@ int NewStore::_remove(TransContext *txc,
   return r;
 }
 
-int NewStore::_setattr(TransContext *txc,
+int KStore::_setattr(TransContext *txc,
 		       CollectionRef& c,
 		       const ghobject_t& oid,
 		       const string& name,
@@ -3911,7 +3199,7 @@ int NewStore::_setattr(TransContext *txc,
   return r;
 }
 
-int NewStore::_setattrs(TransContext *txc,
+int KStore::_setattrs(TransContext *txc,
 			CollectionRef& c,
 			const ghobject_t& oid,
 			const map<string,bufferptr>& aset)
@@ -3941,7 +3229,7 @@ int NewStore::_setattrs(TransContext *txc,
 }
 
 
-int NewStore::_rmattr(TransContext *txc,
+int KStore::_rmattr(TransContext *txc,
 		      CollectionRef& c,
 		      const ghobject_t& oid,
 		      const string& name)
@@ -3966,7 +3254,7 @@ int NewStore::_rmattr(TransContext *txc,
   return r;
 }
 
-int NewStore::_rmattrs(TransContext *txc,
+int KStore::_rmattrs(TransContext *txc,
 		       CollectionRef& c,
 		       const ghobject_t& oid)
 {
@@ -3988,7 +3276,7 @@ int NewStore::_rmattrs(TransContext *txc,
   return r;
 }
 
-void NewStore::_do_omap_clear(TransContext *txc, uint64_t id)
+void KStore::_do_omap_clear(TransContext *txc, uint64_t id)
 {
   KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
   string prefix, tail;
@@ -4001,12 +3289,12 @@ void NewStore::_do_omap_clear(TransContext *txc, uint64_t id)
       break;
     }
     txc->t->rmkey(PREFIX_OMAP, it->key());
-    dout(30) << __func__ << "  rm " << it->key() << dendl;
+    dout(30) << __func__ << "  rm " << pretty_binary_string(it->key()) << dendl;
     it->next();
   }
 }
 
-int NewStore::_omap_clear(TransContext *txc,
+int KStore::_omap_clear(TransContext *txc,
 			  CollectionRef& c,
 			  const ghobject_t& oid)
 {
@@ -4029,7 +3317,7 @@ int NewStore::_omap_clear(TransContext *txc,
   return r;
 }
 
-int NewStore::_omap_setkeys(TransContext *txc,
+int KStore::_omap_setkeys(TransContext *txc,
 			    CollectionRef& c,
 			    const ghobject_t& oid,
 			    bufferlist &bl)
@@ -4057,7 +3345,8 @@ int NewStore::_omap_setkeys(TransContext *txc,
     ::decode(value, p);
     string final_key;
     get_omap_key(o->onode.omap_head, key, &final_key);
-    dout(30) << __func__ << "  " << final_key << " <- " << value << dendl;
+    dout(30) << __func__ << "  " << pretty_binary_string(final_key)
+	     << " <- " << key << dendl;
     txc->t->set(PREFIX_OMAP, final_key, value);
   }
   r = 0;
@@ -4067,7 +3356,7 @@ int NewStore::_omap_setkeys(TransContext *txc,
   return r;
 }
 
-int NewStore::_omap_setheader(TransContext *txc,
+int KStore::_omap_setheader(TransContext *txc,
 			      CollectionRef& c,
 			      const ghobject_t& oid,
 			      bufferlist& bl)
@@ -4095,7 +3384,7 @@ int NewStore::_omap_setheader(TransContext *txc,
   return r;
 }
 
-int NewStore::_omap_rmkeys(TransContext *txc,
+int KStore::_omap_rmkeys(TransContext *txc,
 			   CollectionRef& c,
 			   const ghobject_t& oid,
 			   bufferlist& bl)
@@ -4115,17 +3404,14 @@ int NewStore::_omap_rmkeys(TransContext *txc,
     r = 0;
     goto out;
   }
-  if (!o->onode.omap_head) {
-    o->onode.omap_head = o->onode.nid;
-    txc->write_onode(o);
-  }
   ::decode(num, p);
   while (num--) {
     string key;
     ::decode(key, p);
     string final_key;
     get_omap_key(o->onode.omap_head, key, &final_key);
-    dout(30) << __func__ << "  rm " << final_key << " <- " << key << dendl;
+    dout(30) << __func__ << "  rm " << pretty_binary_string(final_key)
+	     << " <- " << key << dendl;
     txc->t->rmkey(PREFIX_OMAP, final_key);
   }
   r = 0;
@@ -4135,7 +3421,7 @@ int NewStore::_omap_rmkeys(TransContext *txc,
   return r;
 }
 
-int NewStore::_omap_rmkey_range(TransContext *txc,
+int KStore::_omap_rmkey_range(TransContext *txc,
 				CollectionRef& c,
 				const ghobject_t& oid,
 				const string& first, const string& last)
@@ -4161,11 +3447,12 @@ int NewStore::_omap_rmkey_range(TransContext *txc,
   it->lower_bound(key_first);
   while (it->valid()) {
     if (it->key() >= key_last) {
-      dout(30) << __func__ << "  stop at " << key_last << dendl;
+      dout(30) << __func__ << "  stop at " << pretty_binary_string(key_last)
+	       << dendl;
       break;
     }
     txc->t->rmkey(PREFIX_OMAP, it->key());
-    dout(30) << __func__ << "  rm " << it->key() << dendl;
+    dout(30) << __func__ << "  rm " << pretty_binary_string(it->key()) << dendl;
     it->next();
   }
   r = 0;
@@ -4175,7 +3462,7 @@ int NewStore::_omap_rmkey_range(TransContext *txc,
   return r;
 }
 
-int NewStore::_setallochint(TransContext *txc,
+int KStore::_setallochint(TransContext *txc,
 			    CollectionRef& c,
 			    const ghobject_t& oid,
 			    uint64_t expected_object_size,
@@ -4205,7 +3492,7 @@ int NewStore::_setallochint(TransContext *txc,
   return r;
 }
 
-int NewStore::_clone(TransContext *txc,
+int KStore::_clone(TransContext *txc,
 		     CollectionRef& c,
 		     const ghobject_t& old_oid,
 		     const ghobject_t& new_oid)
@@ -4232,12 +3519,9 @@ int NewStore::_clone(TransContext *txc,
     goto out;
 
   // truncate any old data
-  while (!newo->onode.data_map.empty()) {
-    wal_op_t *op = _get_wal_op(txc);
-    op->op = wal_op_t::OP_REMOVE;
-    op->fid = newo->onode.data_map.rbegin()->second.fid;
-    newo->onode.data_map.erase(newo->onode.data_map.rbegin()->first);
-  }
+  r = _do_truncate(txc, newo, 0);
+  if (r < 0)
+    goto out;
 
   r = _do_write(txc, newo, 0, oldo->onode.size, bl, 0);
 
@@ -4264,7 +3548,8 @@ int NewStore::_clone(TransContext *txc,
 	dout(30) << __func__ << "  reached tail" << dendl;
 	break;
       } else {
-	dout(30) << __func__ << "  got header/data " << it->key() << dendl;
+	dout(30) << __func__ << "  got header/data "
+		 << pretty_binary_string(it->key()) << dendl;
 	assert(it->key() < tail);
 	rewrite_omap_key(newo->onode.omap_head, it->key(), &key);
 	txc->t->set(PREFIX_OMAP, key, it->value());
@@ -4283,7 +3568,7 @@ int NewStore::_clone(TransContext *txc,
   return r;
 }
 
-int NewStore::_clone_range(TransContext *txc,
+int KStore::_clone_range(TransContext *txc,
 			   CollectionRef& c,
 			   const ghobject_t& old_oid,
 			   const ghobject_t& new_oid,
@@ -4324,7 +3609,7 @@ int NewStore::_clone_range(TransContext *txc,
   return r;
 }
 
-int NewStore::_rename(TransContext *txc,
+int KStore::_rename(TransContext *txc,
 		      CollectionRef& c,
 		      const ghobject_t& old_oid,
 		      const ghobject_t& new_oid)
@@ -4351,15 +3636,9 @@ int NewStore::_rename(TransContext *txc,
       return r;
   }
 
-  get_object_key(old_oid, &old_key);
-  get_object_key(new_oid, &new_key);
-
-  c->onode_map.rename(old_oid, new_oid);
-  oldo->oid = new_oid;
-  oldo->key = new_key;
-
-  txc->t->rmkey(PREFIX_OBJ, old_key);
+  txc->t->rmkey(PREFIX_OBJ, oldo->key);
   txc->write_onode(oldo);
+  c->onode_map.rename(old_oid, new_oid);  // this adjusts oldo->{oid,key}
   r = 0;
 
  out:
@@ -4370,7 +3649,7 @@ int NewStore::_rename(TransContext *txc,
 
 // collections
 
-int NewStore::_create_collection(
+int KStore::_create_collection(
   TransContext *txc,
   coll_t cid,
   unsigned bits,
@@ -4399,12 +3678,11 @@ int NewStore::_create_collection(
   return r;
 }
 
-int NewStore::_remove_collection(TransContext *txc, coll_t cid,
+int KStore::_remove_collection(TransContext *txc, coll_t cid,
 				 CollectionRef *c)
 {
   dout(15) << __func__ << " " << cid << dendl;
   int r;
-  bufferlist empty;
 
   {
     RWLock::WLocker l(coll_lock);
@@ -4431,7 +3709,7 @@ int NewStore::_remove_collection(TransContext *txc, coll_t cid,
   return r;
 }
 
-int NewStore::_split_collection(TransContext *txc,
+int KStore::_split_collection(TransContext *txc,
 				CollectionRef& c,
 				CollectionRef& d,
 				unsigned bits, int rem)
@@ -4447,6 +3725,10 @@ int NewStore::_split_collection(TransContext *txc,
   assert(d->cnode.bits == bits);
   r = 0;
 
+  bufferlist bl;
+  ::encode(c->cnode, bl);
+  txc->t->set(PREFIX_COLL, stringify(c->cid), bl);
+
   dout(10) << __func__ << " " << c->cid << " to " << d->cid << " "
 	   << " bits " << bits << " = " << r << dendl;
   return r;
diff --git a/src/os/newstore/NewStore.h b/src/os/kstore/KStore.h
similarity index 62%
rename from src/os/newstore/NewStore.h
rename to src/os/kstore/KStore.h
index c32e2a9..d8cbdc2 100644
--- a/src/os/newstore/NewStore.h
+++ b/src/os/kstore/KStore.h
@@ -12,8 +12,8 @@
  *
  */
 
-#ifndef CEPH_OSD_NEWSTORE_H
-#define CEPH_OSD_NEWSTORE_H
+#ifndef CEPH_OSD_KSTORE_H
+#define CEPH_OSD_KSTORE_H
 
 #include "acconfig.h"
 
@@ -29,11 +29,11 @@
 #include "os/fs/FS.h"
 #include "kv/KeyValueDB.h"
 
-#include "newstore_types.h"
+#include "kstore_types.h"
 
 #include "boost/intrusive/list.hpp"
 
-class NewStore : public ObjectStore {
+class KStore : public ObjectStore {
   // -----------------------------------------------------
   // types
 public:
@@ -48,21 +48,22 @@ public:
     string key;     ///< key under PREFIX_OBJ where we are stored
     boost::intrusive::list_member_hook<> lru_item;
 
-    onode_t onode;  ///< metadata stored as value in kv store
+    kstore_onode_t onode;  ///< metadata stored as value in kv store
     bool dirty;     // ???
     bool exists;
 
-    Mutex flush_lock;  ///< protect unappliex_txns, num_fsyncs
-    Cond flush_cond;   ///< wait here for unapplied txns, fsyncs
-    set<TransContext*> flush_txns;   ///< fsyncing or committing or wal txns
+    Mutex flush_lock;  ///< protect flush_txns
+    Cond flush_cond;   ///< wait here for unapplied txns
+    set<TransContext*> flush_txns;   ///< committing txns
+
+    uint64_t tail_offset;
+    bufferlist tail_bl;
+
+    map<uint64_t,bufferlist> pending_stripes;  ///< unwritten stripes
 
     Onode(const ghobject_t& o, const string& k);
 
-    void flush() {
-      Mutex::Locker l(flush_lock);
-      while (!flush_txns.empty())
-	flush_cond.Wait(flush_lock);
-    }
+    void flush();
     void get() {
       nref.inc();
     }
@@ -70,6 +71,14 @@ public:
       if (nref.dec() == 0)
 	delete this;
     }
+
+    void clear_tail() {
+      tail_offset = 0;
+      tail_bl.clear();
+    }
+    void clear_pending_stripes() {
+      pending_stripes.clear();
+    }
   };
   typedef boost::intrusive_ptr<Onode> OnodeRef;
 
@@ -85,7 +94,7 @@ public:
     ceph::unordered_map<ghobject_t,OnodeRef> onode_map;  ///< forward lookups
     lru_list_t lru;                                      ///< lru
 
-    OnodeHashLRU() : lock("NewStore::OnodeHashLRU::lock") {}
+    OnodeHashLRU() : lock("KStore::OnodeHashLRU::lock") {}
 
     void add(const ghobject_t& oid, OnodeRef o);
     void _touch(OnodeRef o);
@@ -98,9 +107,9 @@ public:
   };
 
   struct Collection {
-    NewStore *store;
+    KStore *store;
     coll_t cid;
-    cnode_t cnode;
+    kstore_cnode_t cnode;
     RWLock lock;
 
     // cache onodes on a per-collection basis to avoid lock
@@ -109,7 +118,18 @@ public:
 
     OnodeRef get_onode(const ghobject_t& oid, bool create);
 
-    Collection(NewStore *ns, coll_t c);
+    bool contains(const ghobject_t& oid) {
+      if (cid.is_meta())
+	return oid.hobj.pool == -1;
+      spg_t spgid;
+      if (cid.is_pg(&spgid))
+	return
+	  spgid.pgid.contains(cnode.bits, oid) &&
+	  oid.shard_id == spgid.shard;
+      return false;
+    }
+
+    Collection(KStore *ns, coll_t c);
   };
   typedef ceph::shared_ptr<Collection> CollectionRef;
 
@@ -135,27 +155,14 @@ public:
   class OpSequencer;
   typedef boost::intrusive_ptr<OpSequencer> OpSequencerRef;
 
-  struct fsync_item {
-    boost::intrusive::list_member_hook<> queue_item;
-    int fd;
-    TransContext *txc;
-    fsync_item(int f, TransContext *t) : fd(f), txc(t) {}
-  };
-
   struct TransContext {
     typedef enum {
       STATE_PREPARE,
-      STATE_FSYNC_WAIT,
       STATE_AIO_WAIT,
       STATE_IO_DONE,
       STATE_KV_QUEUED,
       STATE_KV_COMMITTING,
       STATE_KV_DONE,
-      STATE_WAL_QUEUED,
-      STATE_WAL_APPLYING,
-      STATE_WAL_AIO_WAIT,
-      STATE_WAL_CLEANUP,   // remove wal kv record
-      STATE_WAL_DONE,
       STATE_FINISHING,
       STATE_DONE,
     } state_t;
@@ -165,17 +172,11 @@ public:
     const char *get_state_name() {
       switch (state) {
       case STATE_PREPARE: return "prepare";
-      case STATE_FSYNC_WAIT: return "fsync_wait";
       case STATE_AIO_WAIT: return "aio_wait";
       case STATE_IO_DONE: return "io_done";
       case STATE_KV_QUEUED: return "kv_queued";
       case STATE_KV_COMMITTING: return "kv_committing";
       case STATE_KV_DONE: return "kv_done";
-      case STATE_WAL_QUEUED: return "wal_queued";
-      case STATE_WAL_APPLYING: return "wal_applying";
-      case STATE_WAL_AIO_WAIT: return "wal_aio_wait";
-      case STATE_WAL_CLEANUP: return "wal_cleanup";
-      case STATE_WAL_DONE: return "wal_done";
       case STATE_FINISHING: return "finishing";
       case STATE_DONE: return "done";
       }
@@ -187,7 +188,6 @@ public:
 
     uint64_t ops, bytes;
 
-    list<fsync_item> sync_items; ///< these fds need to be synced
     set<OnodeRef> onodes;     ///< these onodes need to be updated/written
     KeyValueDB::Transaction t; ///< then we will commit this
     Context *oncommit;         ///< signal on commit
@@ -196,15 +196,6 @@ public:
     list<Context*> oncommits;  ///< more commit completions
     list<CollectionRef> removed_collections; ///< colls we removed
 
-    boost::intrusive::list_member_hook<> wal_queue_item;
-    wal_transaction_t *wal_txn; ///< wal transaction (if any)
-    unsigned num_fsyncs_completed;
-
-    list<FS::aio_t> pending_aios;    ///< not yet submitted
-    list<FS::aio_t> submitted_aios;  ///< submitting or submitted
-    bufferlist aio_bl;  // just a pile of refs
-    atomic_t num_aio;
-
     Mutex lock;
     Cond cond;
 
@@ -218,38 +209,16 @@ public:
 	oncommit(NULL),
 	onreadable(NULL),
 	onreadable_sync(NULL),
-	wal_txn(NULL),
-	num_fsyncs_completed(0),
-	num_aio(0),
-	lock("NewStore::TransContext::lock") {
+	lock("KStore::TransContext::lock") {
       //cout << "txc new " << this << std::endl;
     }
     ~TransContext() {
-      delete wal_txn;
       //cout << "txc del " << this << std::endl;
     }
 
-    void sync_fd(int f) {
-      sync_items.push_back(fsync_item(f, this));
-    }
     void write_onode(OnodeRef &o) {
       onodes.insert(o);
     }
-
-    bool finish_fsync() {
-      Mutex::Locker l(lock);
-      ++num_fsyncs_completed;
-      if (num_fsyncs_completed == sync_items.size()) {
-	cond.Signal();
-	return true;
-      }
-      return false;
-    }
-    void wait_fsync() {
-      Mutex::Locker l(lock);
-      while (num_fsyncs_completed < sync_items.size())
-	cond.Wait(lock);
-    }
   };
 
   class OpSequencer : public Sequencer_impl {
@@ -264,25 +233,12 @@ public:
 	&TransContext::sequencer_item> > q_list_t;
     q_list_t q;  ///< transactions
 
-    typedef boost::intrusive::list<
-      TransContext,
-      boost::intrusive::member_hook<
-	TransContext,
-	boost::intrusive::list_member_hook<>,
-	&TransContext::wal_queue_item> > wal_queue_t;
-    wal_queue_t wal_q; ///< transactions
-
-    boost::intrusive::list_member_hook<> wal_osr_queue_item;
-
     Sequencer *parent;
 
-    Mutex wal_apply_lock;
-
     OpSequencer()
 	//set the qlock to to PTHREAD_MUTEX_RECURSIVE mode
-      : qlock("NewStore::OpSequencer::qlock", true, false),
-	parent(NULL),
-	wal_apply_lock("NewStore::OpSequencer::wal_apply_lock") {
+      : qlock("KStore::OpSequencer::qlock", true, false),
+	parent(NULL) {
     }
     ~OpSequencer() {
       assert(q.empty());
@@ -314,192 +270,41 @@ public:
     }
   };
 
-  class FsyncWQ : public ThreadPool::WorkQueue<fsync_item> {
-  public:
-    typedef boost::intrusive::list<
-      fsync_item,
-      boost::intrusive::member_hook<
-        fsync_item,
-	boost::intrusive::list_member_hook<>,
-	&fsync_item::queue_item> > fsync_queue_t;
-  private:
-    NewStore *store;
-    fsync_queue_t fd_queue;
-
-  public:
-    FsyncWQ(NewStore *s, time_t ti, time_t sti, ThreadPool *tp)
-      : ThreadPool::WorkQueue<fsync_item>("NewStore::FsyncWQ", ti, sti, tp),
-	store(s) {
-    }
-    bool _empty() {
-      return fd_queue.empty();
-    }
-    bool _enqueue(fsync_item *i) {
-      fd_queue.push_back(*i);
-      return true;
-    }
-    void _dequeue(fsync_item *p) {
-      assert(0 == "not needed, not implemented");
-    }
-    fsync_item *_dequeue() {
-      if (fd_queue.empty())
-	return NULL;
-      fsync_item *i = &fd_queue.front();
-      fd_queue.pop_front();
-      return i;
-    }
-    void _process(fsync_item *i, ThreadPool::TPHandle &handle) {
-      store->_txc_process_fsync(i);
-    }
-    void _clear() {
-      fd_queue.clear();
-    }
-
-    void flush() {
-      lock();
-      while (!fd_queue.empty())
-	_wait();
-      unlock();
-      drain();
-    }
-  };
-
-  class WALWQ : public ThreadPool::WorkQueue<TransContext> {
-    // We need to order WAL items within each Sequencer.  To do that,
-    // queue each txc under osr, and queue the osr's here.  When we
-    // dequeue an txc, requeue the osr if there are more pending, and
-    // do it at the end of the list so that the next thread does not
-    // get a conflicted txc.  Hold an osr mutex while doing the wal to
-    // preserve the ordering.
-  public:
-    typedef boost::intrusive::list<
-      OpSequencer,
-      boost::intrusive::member_hook<
-	OpSequencer,
-	boost::intrusive::list_member_hook<>,
-	&OpSequencer::wal_osr_queue_item> > wal_osr_queue_t;
-
-  private:
-    NewStore *store;
-    wal_osr_queue_t wal_queue;
-
-  public:
-    WALWQ(NewStore *s, time_t ti, time_t sti, ThreadPool *tp)
-      : ThreadPool::WorkQueue<TransContext>("NewStore::WALWQ", ti, sti, tp),
-	store(s) {
-    }
-    bool _empty() {
-      return wal_queue.empty();
-    }
-    bool _enqueue(TransContext *i) {
-      if (i->osr->wal_q.empty()) {
-	wal_queue.push_back(*i->osr);
-      }
-      i->osr->wal_q.push_back(*i);
-      return true;
-    }
-    void _dequeue(TransContext *p) {
-      assert(0 == "not needed, not implemented");
-    }
-    TransContext *_dequeue() {
-      if (wal_queue.empty())
-	return NULL;
-      OpSequencer *osr = &wal_queue.front();
-      TransContext *i = &osr->wal_q.front();
-      osr->wal_q.pop_front();
-      wal_queue.pop_front();
-      if (!osr->wal_q.empty()) {
-	// requeue at the end to minimize contention
-	wal_queue.push_back(*i->osr);
-      }
-
-      // preserve wal ordering for this sequencer by taking the lock
-      // while still holding the queue lock
-      i->osr->wal_apply_lock.Lock();
-      return i;
-    }
-    void _process(TransContext *i, ThreadPool::TPHandle &handle) {
-      store->_wal_apply(i);
-      i->osr->wal_apply_lock.Unlock();
-    }
-    void _clear() {
-      assert(wal_queue.empty());
-    }
-
-    void flush() {
-      lock();
-      while (!wal_queue.empty()) {
-	_wait();
-      }
-      unlock();
-      drain();
-    }
-  };
-
   struct KVSyncThread : public Thread {
-    NewStore *store;
-    KVSyncThread(NewStore *s) : store(s) {}
+    KStore *store;
+    KVSyncThread(KStore *s) : store(s) {}
     void *entry() {
       store->_kv_sync_thread();
       return NULL;
     }
   };
 
-  struct AioCompletionThread : public Thread {
-    NewStore *store;
-    AioCompletionThread(NewStore *s) : store(s) {}
-    void *entry() {
-      store->_aio_thread();
-      return NULL;
-    }
-  };
-
   // --------------------------------------------------------
   // members
 private:
   CephContext *cct;
   KeyValueDB *db;
-  FS *fs;
   uuid_d fsid;
   int path_fd;  ///< open handle to $path
   int fsid_fd;  ///< open handle (locked) to $path/fsid
-  int frag_fd;  ///< open handle to $path/fragments
-  int fset_fd;  ///< open handle to $path/fragments/$cur_fid.fset
   bool mounted;
 
   RWLock coll_lock;    ///< rwlock to protect coll_map
   ceph::unordered_map<coll_t, CollectionRef> coll_map;
 
-  Mutex fid_lock;
-  fid_t fid_last;  ///< last allocated fid
-  fid_t fid_max;   ///< max fid we can allocate before reserving more
-
   Mutex nid_lock;
   uint64_t nid_last;
   uint64_t nid_max;
 
   Throttle throttle_ops, throttle_bytes;          ///< submit to commit
-  Throttle throttle_wal_ops, throttle_wal_bytes;  ///< submit to wal complete
-
-  Mutex wal_lock;
-  atomic64_t wal_seq;
-  ThreadPool wal_tp;
-  WALWQ wal_wq;
 
   Finisher finisher;
-  ThreadPool fsync_tp;
-  FsyncWQ fsync_wq;
-
-  AioCompletionThread aio_thread;
-  bool aio_stop;
-  FS::aio_queue_t aio_queue;
 
   KVSyncThread kv_sync_thread;
   Mutex kv_lock;
   Cond kv_cond, kv_sync_cond;
   bool kv_stop;
   deque<TransContext*> kv_queue, kv_committing;
-  deque<TransContext*> wal_cleanup_queue, wal_cleaning;
 
   Logger *logger;
 
@@ -521,47 +326,31 @@ private:
   int _read_fsid(uuid_d *f);
   int _write_fsid();
   void _close_fsid();
-  int _open_frag();
-  int _create_frag();
-  void _close_frag();
   int _open_db(bool create);
   void _close_db();
-  int _open_collections();
+  int _open_collections(int *errors=0);
   void _close_collections();
 
+  int _open_super_meta();
+
   CollectionRef _get_collection(coll_t cid);
   void _queue_reap_collection(CollectionRef& c);
   void _reap_collections();
 
-  int _recover_next_fid();
-  int _create_fid(TransContext *txc, fid_t *fid, unsigned flags);
-  int _open_fid(fid_t fid, unsigned flags);
-  int _remove_fid(fid_t fid);
-
-  int _recover_next_nid();
   void _assign_nid(TransContext *txc, OnodeRef o);
 
-  int _clean_fid_tail_fd(const fragment_t& f, int fd);
-  int _clean_fid_tail(TransContext *txc, const fragment_t& f);
+  void _dump_onode(OnodeRef o);
 
   TransContext *_txc_create(OpSequencer *osr);
+  void _txc_release(TransContext *txc, uint64_t offset, uint64_t length);
   int _txc_add_transaction(TransContext *txc, Transaction *t);
   int _txc_finalize(OpSequencer *osr, TransContext *txc);
   void _txc_state_proc(TransContext *txc);
-  void _txc_aio_submit(TransContext *txc);
-  void _txc_do_sync_fsync(TransContext *txc);
-  void _txc_queue_fsync(TransContext *txc);
-  void _txc_process_fsync(fsync_item *i);
-  void _txc_finish_io(TransContext *txc);
   void _txc_finish_kv(TransContext *txc);
   void _txc_finish(TransContext *txc);
 
   void _osr_reap_done(OpSequencer *osr);
 
-  void _aio_thread();
-  int _aio_start();
-  void _aio_stop();
-
   void _kv_sync_thread();
   void _kv_stop() {
     {
@@ -573,21 +362,20 @@ private:
     kv_stop = false;
   }
 
-  wal_op_t *_get_wal_op(TransContext *txc);
-  int _wal_apply(TransContext *txc);
-  int _wal_finish(TransContext *txc);
-  int _do_wal_transaction(wal_transaction_t& wt, TransContext *txc);
-  int _wal_replay();
+  void _do_read_stripe(OnodeRef o, uint64_t offset, bufferlist *pbl);
+  void _do_write_stripe(TransContext *txc, OnodeRef o,
+			uint64_t offset, bufferlist& bl);
+  void _do_remove_stripe(TransContext *txc, OnodeRef o, uint64_t offset);
 
 public:
-  NewStore(CephContext *cct, const string& path);
-  ~NewStore();
+  KStore(CephContext *cct, const string& path);
+  ~KStore();
 
   bool needs_journal() { return false; };
   bool wants_journal() { return false; };
   bool allows_journal() { return false; };
 
-  int peek_journal_fsid(uuid_d *fsid);
+  static int get_block_device_fsid(const string& path, uuid_d *fsid);
 
   bool test_mount_in_use();
 
@@ -595,6 +383,8 @@ public:
   int umount();
   void _sync();
 
+  int fsck();
+
   unsigned get_max_object_name_length() {
     return 4096;
   }
@@ -607,16 +397,6 @@ public:
     return 0;
   }
 
-private:
-  bool sharded;
-public:
-  void set_allow_sharded_objects() {
-    sharded = true;
-  }
-  bool get_allow_sharded_objects() {
-    return sharded;
-  }
-
   int statfs(struct statfs *buf);
 
   bool exists(coll_t cid, const ghobject_t& oid);
@@ -726,20 +506,8 @@ private:
 	     uint64_t offset, size_t len,
 	     bufferlist& bl,
 	     uint32_t fadvise_flags);
-  int _do_overlay_clear(TransContext *txc,
-			OnodeRef o);
-  int _do_overlay_trim(TransContext *txc,
-		       OnodeRef o,
-		       uint64_t offset,
-		       uint64_t length);
-  int _do_overlay_write(TransContext *txc,
-			OnodeRef o,
-			uint64_t offset,
-			uint64_t length,
-			const bufferlist& bl);
-  int _do_write_all_overlays(TransContext *txc,
-			     OnodeRef o);
-  void _do_read_all_overlays(wal_transaction_t& wt);
+  void _pad_zeros(OnodeRef o, bufferlist *bl, uint64_t *offset, uint64_t *length,
+		  uint64_t block_size);
   int _do_write(TransContext *txc,
 		OnodeRef o,
 		uint64_t offset, uint64_t length,
@@ -828,21 +596,21 @@ private:
 
 };
 
-inline ostream& operator<<(ostream& out, const NewStore::OpSequencer& s) {
+inline ostream& operator<<(ostream& out, const KStore::OpSequencer& s) {
   return out << *s.parent;
 }
 
-static inline void intrusive_ptr_add_ref(NewStore::Onode *o) {
+static inline void intrusive_ptr_add_ref(KStore::Onode *o) {
   o->get();
 }
-static inline void intrusive_ptr_release(NewStore::Onode *o) {
+static inline void intrusive_ptr_release(KStore::Onode *o) {
   o->put();
 }
 
-static inline void intrusive_ptr_add_ref(NewStore::OpSequencer *o) {
+static inline void intrusive_ptr_add_ref(KStore::OpSequencer *o) {
   o->get();
 }
-static inline void intrusive_ptr_release(NewStore::OpSequencer *o) {
+static inline void intrusive_ptr_release(KStore::OpSequencer *o) {
   o->put();
 }
 
diff --git a/src/os/kstore/kstore_types.cc b/src/os/kstore/kstore_types.cc
new file mode 100644
index 0000000..b8bbb05
--- /dev/null
+++ b/src/os/kstore/kstore_types.cc
@@ -0,0 +1,99 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "kstore_types.h"
+#include "common/Formatter.h"
+#include "include/stringify.h"
+
+// cnode_t
+
+void kstore_cnode_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(bits, bl);
+  ENCODE_FINISH(bl);
+}
+
+void kstore_cnode_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(bits, p);
+  DECODE_FINISH(p);
+}
+
+void kstore_cnode_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("bits", bits);
+}
+
+void kstore_cnode_t::generate_test_instances(list<kstore_cnode_t*>& o)
+{
+  o.push_back(new kstore_cnode_t());
+  o.push_back(new kstore_cnode_t(0));
+  o.push_back(new kstore_cnode_t(123));
+}
+
+
+// kstore_onode_t
+
+void kstore_onode_t::encode(bufferlist& bl) const
+{
+  ENCODE_START(1, 1, bl);
+  ::encode(nid, bl);
+  ::encode(size, bl);
+  ::encode(attrs, bl);
+  ::encode(omap_head, bl);
+  ::encode(stripe_size, bl);
+  ::encode(expected_object_size, bl);
+  ::encode(expected_write_size, bl);
+  ENCODE_FINISH(bl);
+}
+
+void kstore_onode_t::decode(bufferlist::iterator& p)
+{
+  DECODE_START(1, p);
+  ::decode(nid, p);
+  ::decode(size, p);
+  ::decode(attrs, p);
+  ::decode(omap_head, p);
+  ::decode(stripe_size, p);
+  ::decode(expected_object_size, p);
+  ::decode(expected_write_size, p);
+  DECODE_FINISH(p);
+}
+
+void kstore_onode_t::dump(Formatter *f) const
+{
+  f->dump_unsigned("nid", nid);
+  f->dump_unsigned("size", size);
+  f->open_object_section("attrs");
+  for (map<string,bufferptr>::const_iterator p = attrs.begin();
+       p != attrs.end(); ++p) {
+    f->open_object_section("attr");
+    f->dump_string("name", p->first);
+    f->dump_unsigned("len", p->second.length());
+    f->close_section();
+  }
+  f->close_section();
+  f->dump_unsigned("omap_head", omap_head);
+  f->dump_unsigned("stripe_size", stripe_size);
+  f->dump_unsigned("expected_object_size", expected_object_size);
+  f->dump_unsigned("expected_write_size", expected_write_size);
+}
+
+void kstore_onode_t::generate_test_instances(list<kstore_onode_t*>& o)
+{
+  o.push_back(new kstore_onode_t());
+  // FIXME
+}
diff --git a/src/os/kstore/kstore_types.h b/src/os/kstore/kstore_types.h
new file mode 100644
index 0000000..02c75cb
--- /dev/null
+++ b/src/os/kstore/kstore_types.h
@@ -0,0 +1,66 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef CEPH_OSD_KSTORE_TYPES_H
+#define CEPH_OSD_KSTORE_TYPES_H
+
+#include <ostream>
+#include "include/types.h"
+#include "include/interval_set.h"
+#include "include/utime.h"
+#include "common/hobject.h"
+
+namespace ceph {
+  class Formatter;
+}
+/// collection metadata
+struct kstore_cnode_t {
+  uint32_t bits;   ///< how many bits of coll pgid are significant
+
+  kstore_cnode_t(int b=0) : bits(b) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<kstore_cnode_t*>& o);
+};
+WRITE_CLASS_ENCODER(kstore_cnode_t)
+
+/// onode: per-object metadata
+struct kstore_onode_t {
+  uint64_t nid;                        ///< numeric id (locally unique)
+  uint64_t size;                       ///< object size
+  map<string, bufferptr> attrs;        ///< attrs
+  uint64_t omap_head;                  ///< id for omap root node
+  uint32_t stripe_size;                ///< stripe size
+
+  uint32_t expected_object_size;
+  uint32_t expected_write_size;
+
+  kstore_onode_t()
+    : nid(0),
+      size(0),
+      omap_head(0),
+      stripe_size(0),
+      expected_object_size(0),
+      expected_write_size(0) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<kstore_onode_t*>& o);
+};
+WRITE_CLASS_ENCODER(kstore_onode_t)
+
+#endif
diff --git a/src/os/kstore/kv.cc b/src/os/kstore/kv.cc
new file mode 100644
index 0000000..8004e12
--- /dev/null
+++ b/src/os/kstore/kv.cc
@@ -0,0 +1,61 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "kv.h"
+
+#include "include/byteorder.h"
+#include <string.h>
+
+void _key_encode_u32(uint32_t u, std::string *key)
+{
+  uint32_t bu;
+#ifdef CEPH_BIG_ENDIAN
+  bu = u;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  bu = swab32(u);
+#else
+# error wtf
+#endif
+  key->append((char*)&bu, 4);
+}
+
+const char *_key_decode_u32(const char *key, uint32_t *pu)
+{
+  uint32_t bu;
+  memcpy(&bu, key, 4);
+#ifdef CEPH_BIG_ENDIAN
+  *pu = bu;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  *pu = swab32(bu);
+#else
+# error wtf
+#endif
+  return key + 4;
+}
+
+void _key_encode_u64(uint64_t u, std::string *key)
+{
+  uint64_t bu;
+#ifdef CEPH_BIG_ENDIAN
+  bu = u;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  bu = swab64(u);
+#else
+# error wtf
+#endif
+  key->append((char*)&bu, 8);
+}
+
+const char *_key_decode_u64(const char *key, uint64_t *pu)
+{
+  uint64_t bu;
+  memcpy(&bu, key, 8);
+#ifdef CEPH_BIG_ENDIAN
+  *pu = bu;
+#elif defined(CEPH_LITTLE_ENDIAN)
+  *pu = swab64(bu);
+#else
+# error wtf
+#endif
+  return key + 8;
+}
diff --git a/src/os/kstore/kv.h b/src/os/kstore/kv.h
new file mode 100644
index 0000000..51fc7ed
--- /dev/null
+++ b/src/os/kstore/kv.h
@@ -0,0 +1,15 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_OS_NEWSTORE_KV_H
+#define CEPH_OS_NEWSTORE_KV_H
+
+#include <string>
+
+// some key encoding helpers
+void _key_encode_u32(uint32_t u, std::string *key);
+const char *_key_decode_u32(const char *key, uint32_t *pu);
+void _key_encode_u64(uint64_t u, std::string *key);
+const char *_key_decode_u64(const char *key, uint64_t *pu);
+
+#endif
diff --git a/src/os/MemStore.cc b/src/os/memstore/MemStore.cc
similarity index 98%
rename from src/os/MemStore.cc
rename to src/os/memstore/MemStore.cc
index f87e628..06919d0 100644
--- a/src/os/MemStore.cc
+++ b/src/os/memstore/MemStore.cc
@@ -83,14 +83,6 @@ int MemStore::_save()
   if (r < 0)
     return r;
 
-  if (sharded) {
-   string fn = path + "/sharded";
-    bufferlist bl;
-    int r = bl.write_file(fn.c_str());
-    if (r < 0)
-      return r;
-  }
-
   return 0;
 }
 
@@ -172,14 +164,9 @@ int MemStore::_load()
     used_bytes += c->used_bytes();
   }
 
-  fn = path + "/sharded";
-  struct stat st;
-  if (::stat(fn.c_str(), &st) == 0)
-    set_allow_sharded_objects();
-
   dump_all();
 
-  return 0;  
+  return 0;
 }
 
 void MemStore::set_fsid(uuid_d u)
@@ -211,7 +198,9 @@ int MemStore::mkfs()
     if (r < 0)
       return r;
     dout(1) << __func__ << " new fsid " << fsid_str << dendl;
-  } else {
+  } else if (r < 0) {
+    return r;
+  } else {  
     dout(1) << __func__ << " had fsid " << fsid_str << dendl;
   }
 
@@ -318,7 +307,7 @@ int MemStore::read(
   if (offset >= o->get_size())
     return 0;
   size_t l = len;
-  if (l == 0)  // note: len == 0 means read the entire object
+  if (l == 0 && offset == 0)  // note: len == 0 means read the entire object
     l = o->get_size();
   else if (offset + l > o->get_size())
     l = o->get_size() - offset;
@@ -338,15 +327,18 @@ int MemStore::fiemap(coll_t cid, const ghobject_t& oid,
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
-  if (offset >= o->get_size())
-    return 0;
+  map<uint64_t, uint64_t> m;
   size_t l = len;
+  if (offset == 0 && len == 0)
+    l = o->get_size();
   if (offset + l > o->get_size())
     l = o->get_size() - offset;
-  map<uint64_t, uint64_t> m;
+  if (offset >= o->get_size())
+    goto out;
+ out:
   m[offset] = l;
   ::encode(m, bl);
-  return 0;  
+  return 0;
 }
 
 int MemStore::getattr(coll_t cid, const ghobject_t& oid,
@@ -409,7 +401,7 @@ bool MemStore::collection_empty(coll_t cid)
   dout(10) << __func__ << " " << cid << dendl;
   CollectionRef c = get_collection(cid);
   if (!c)
-    return -ENOENT;
+    return false;
   RWLock::RLocker l(c->lock);
 
   return c->object_map.empty();
@@ -636,7 +628,7 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _touch(cid, oid);
       }
       break;
-      
+
     case Transaction::OP_WRITE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -649,7 +641,7 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _write(cid, oid, off, len, bl, fadvise_flags);
       }
       break;
-      
+
     case Transaction::OP_ZERO:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -659,13 +651,13 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _zero(cid, oid, off, len);
       }
       break;
-      
+
     case Transaction::OP_TRIMCACHE:
       {
         // deprecated, no-op
       }
       break;
-      
+
     case Transaction::OP_TRUNCATE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -674,7 +666,7 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _truncate(cid, oid, off);
       }
       break;
-      
+
     case Transaction::OP_REMOVE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -682,7 +674,7 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _remove(cid, oid);
       }
       break;
-      
+
     case Transaction::OP_SETATTR:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -695,7 +687,7 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _setattrs(cid, oid, to_set);
       }
       break;
-      
+
     case Transaction::OP_SETATTRS:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -722,7 +714,7 @@ void MemStore::_do_transaction(Transaction& t)
 	r = _rmattrs(cid, oid);
       }
       break;
-      
+
     case Transaction::OP_CLONE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -1024,9 +1016,9 @@ int MemStore::_remove(coll_t cid, const ghobject_t& oid)
   auto i = c->object_hash.find(oid);
   if (i == c->object_hash.end())
     return -ENOENT;
+  used_bytes -= i->second->get_size();
   c->object_hash.erase(i);
   c->object_map.erase(oid);
-  used_bytes -= i->second->get_size();
 
   return 0;
 }
@@ -1556,10 +1548,10 @@ int MemStore::PageSetObject::clone(Object *src, uint64_t srcoff,
                   dst_page->data + dbegin - dst_page->offset);
       }
       dst_pages.clear(); // drop page refs
-      srcoff += count;
-      dstoff += count;
-      len -= count;
     }
+    srcoff += count;
+    dstoff += count;
+    len -= count;
     tls_pages.clear(); // drop page refs
   }
 
diff --git a/src/os/MemStore.h b/src/os/memstore/MemStore.h
similarity index 97%
rename from src/os/MemStore.h
rename to src/os/memstore/MemStore.h
index fc047c0..ac410a1 100644
--- a/src/os/MemStore.h
+++ b/src/os/memstore/MemStore.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -25,7 +25,7 @@
 #include "common/Finisher.h"
 #include "common/RefCountedObj.h"
 #include "common/RWLock.h"
-#include "ObjectStore.h"
+#include "os/ObjectStore.h"
 #include "PageSet.h"
 #include "include/assert.h"
 
@@ -77,7 +77,7 @@ public:
 	f->open_object_section("xattr");
 	f->dump_string("name", p->first);
 	f->dump_int("length", p->second.length());
-	f->close_section();	
+	f->close_section();
       }
       f->close_section();
 
@@ -88,7 +88,7 @@ public:
 	f->open_object_section("pair");
 	f->dump_string("key", p->first);
 	f->dump_int("length", p->second.length());
-	f->close_section();	
+	f->close_section();
       }
       f->close_section();
     }
@@ -269,7 +269,7 @@ private:
     }
     bool valid() {
       std::lock_guard<std::mutex>(o->omap_mutex);
-      return it != o->omap.end();      
+      return it != o->omap.end();
     }
     int next(bool validate=true) {
       std::lock_guard<std::mutex>(o->omap_mutex);
@@ -344,8 +344,7 @@ public:
       coll_lock("MemStore::coll_lock"),
       apply_lock("MemStore::apply_lock"),
       finisher(cct),
-      used_bytes(0),
-      sharded(false) {}
+      used_bytes(0) {}
   ~MemStore() { }
 
   bool test_mount_in_use() {
@@ -376,14 +375,6 @@ public:
     return false;
   }
 
-  bool sharded;
-  void set_allow_sharded_objects() {
-    sharded = true;
-  }
-  bool get_allow_sharded_objects() {
-    return sharded;
-  }
-
   int statfs(struct statfs *buf);
 
   bool exists(coll_t cid, const ghobject_t& oid);
diff --git a/src/os/PageSet.h b/src/os/memstore/PageSet.h
similarity index 100%
rename from src/os/PageSet.h
rename to src/os/memstore/PageSet.h
diff --git a/src/os/newstore/newstore_types.cc b/src/os/newstore/newstore_types.cc
deleted file mode 100644
index 5489faf..0000000
--- a/src/os/newstore/newstore_types.cc
+++ /dev/null
@@ -1,304 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2014 Red Hat
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-#include "newstore_types.h"
-#include "common/Formatter.h"
-
-// cnode_t
-
-void cnode_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(1, 1, bl);
-  ::encode(bits, bl);
-  ENCODE_FINISH(bl);
-}
-
-void cnode_t::decode(bufferlist::iterator& p)
-{
-  DECODE_START(1, p);
-  ::decode(bits, p);
-  DECODE_FINISH(p);
-}
-
-void cnode_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("bits", bits);
-}
-
-void cnode_t::generate_test_instances(list<cnode_t*>& o)
-{
-  o.push_back(new cnode_t());
-  o.push_back(new cnode_t(0));
-  o.push_back(new cnode_t(123));
-}
-
-// fit_t
-
-void fid_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("fset", fset);
-  f->dump_unsigned("fno", fno);
-}
-
-void fid_t::generate_test_instances(list<fid_t*>& o)
-{
-  o.push_back(new fid_t());
-  o.push_back(new fid_t(0, 1));
-  o.push_back(new fid_t(123, 3278));
-}
-
-// fragment_t
-
-void fragment_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(1, 1, bl);
-  ::encode(offset, bl);
-  ::encode(length, bl);
-  ::encode(fid, bl);
-  ENCODE_FINISH(bl);
-}
-
-void fragment_t::decode(bufferlist::iterator& p)
-{
-  DECODE_START(1, p);
-  ::decode(offset, p);
-  ::decode(length, p);
-  ::decode(fid, p);
-  DECODE_FINISH(p);
-}
-
-void fragment_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("offset", offset);
-  f->dump_unsigned("length", length);
-  f->dump_object("fid", fid);
-}
-
-void fragment_t::generate_test_instances(list<fragment_t*>& o)
-{
-  o.push_back(new fragment_t());
-  o.push_back(new fragment_t(123, 456));
-  o.push_back(new fragment_t(789, 1024, fid_t(3, 400)));
-}
-
-ostream& operator<<(ostream& out, const fragment_t& f)
-{
-  out << "fragment(" << f.offset << "~" << f.length << " " << f.fid << ")";
-  return out;
-}
-
-// overlay_t
-
-void overlay_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(1, 1, bl);
-  ::encode(key, bl);
-  ::encode(value_offset, bl);
-  ::encode(length, bl);
-  ENCODE_FINISH(bl);
-}
-
-void overlay_t::decode(bufferlist::iterator& p)
-{
-  DECODE_START(1, p);
-  ::decode(key, p);
-  ::decode(value_offset, p);
-  ::decode(length, p);
-  DECODE_FINISH(p);
-}
-
-void overlay_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("key", key);
-  f->dump_unsigned("value_offset", value_offset);
-  f->dump_unsigned("length", length);
-}
-
-void overlay_t::generate_test_instances(list<overlay_t*>& o)
-{
-  o.push_back(new overlay_t());
-  o.push_back(new overlay_t(789, 1024, 1232232));
-}
-
-ostream& operator<<(ostream& out, const overlay_t& o)
-{
-  out << "overlay(" << o.value_offset << "~" << o.length
-      << " key " << o.key << ")";
-  return out;
-}
-
-// onode_t
-
-void onode_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(1, 1, bl);
-  ::encode(nid, bl);
-  ::encode(size, bl);
-  ::encode(attrs, bl);
-  ::encode(data_map, bl);
-  ::encode(overlay_map, bl);
-  ::encode(shared_overlays, bl);
-  ::encode(last_overlay_key, bl);
-  ::encode(omap_head, bl);
-  ::encode(expected_object_size, bl);
-  ::encode(expected_write_size, bl);
-  ENCODE_FINISH(bl);
-}
-
-void onode_t::decode(bufferlist::iterator& p)
-{
-  DECODE_START(1, p);
-  ::decode(nid, p);
-  ::decode(size, p);
-  ::decode(attrs, p);
-  ::decode(data_map, p);
-  ::decode(overlay_map, p);
-  ::decode(shared_overlays, p);
-  ::decode(last_overlay_key, p);
-  ::decode(omap_head, p);
-  ::decode(expected_object_size, p);
-  ::decode(expected_write_size, p);
-  DECODE_FINISH(p);
-}
-
-void onode_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("nid", nid);
-  f->dump_unsigned("size", size);
-  f->open_object_section("attrs");
-  for (map<string,bufferptr>::const_iterator p = attrs.begin();
-       p != attrs.end(); ++p) {
-    f->open_object_section("attr");
-    f->dump_string("name", p->first);
-    f->dump_unsigned("len", p->second.length());
-    f->close_section();
-  }
-  f->open_object_section("data_map");
-  for (map<uint64_t, fragment_t>::const_iterator p = data_map.begin();
-       p != data_map.end(); ++p) {
-    f->open_object_section("fragment");
-    f->dump_unsigned("fragment_offset", p->first);
-    p->second.dump(f);
-    f->close_section();
-  }
-  f->close_section();
-  f->open_object_section("overlays");
-  for (map<uint64_t, overlay_t>::const_iterator p = overlay_map.begin();
-       p != overlay_map.end(); ++p) {
-    f->open_object_section("overlay");
-    f->dump_unsigned("offset", p->first);
-    p->second.dump(f);
-    f->close_section();
-  }
-  f->close_section();
-  f->open_array_section("shared_overlays");
-  for (set<uint64_t>::const_iterator p = shared_overlays.begin();
-       p != shared_overlays.end(); ++p) {
-    f->dump_unsigned("offset", *p);
-  }
-  f->close_section();
-  f->dump_unsigned("last_overlay_key", last_overlay_key);
-  f->dump_unsigned("omap_head", omap_head);
-  f->dump_unsigned("expected_object_size", expected_object_size);
-  f->dump_unsigned("expected_write_size", expected_write_size);
-}
-
-void onode_t::generate_test_instances(list<onode_t*>& o)
-{
-  o.push_back(new onode_t());
-  // FIXME
-}
-
-// wal_op_t
-
-void wal_op_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(1, 1, bl);
-  ::encode(op, bl);
-  ::encode(fid, bl);
-  ::encode(offset, bl);
-  ::encode(length, bl);
-  ::encode(nid, bl);
-  ::encode(overlays, bl);
-  if (!overlays.size()) {
-    ::encode(data, bl);
-  }
-  ENCODE_FINISH(bl);
-}
-
-void wal_op_t::decode(bufferlist::iterator& p)
-{
-  DECODE_START(1, p);
-  ::decode(op, p);
-  ::decode(fid, p);
-  ::decode(offset, p);
-  ::decode(length, p);
-  ::decode(nid, p);
-  ::decode(overlays, p);
-  if (!overlays.size()) {
-    ::decode(data, p);
-  }
-  DECODE_FINISH(p);
-}
-
-void wal_op_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("op", (int)op);
-  f->dump_object("fid", fid);
-  f->dump_unsigned("offset", offset);
-  f->dump_unsigned("length", length);
-  if (overlays.size()) {
-    f->dump_unsigned("nid", nid);
-    f->open_array_section("overlays");
-    for (vector<overlay_t>::const_iterator p = overlays.begin();
-         p != overlays.end(); ++p) {
-      f->dump_object("overlay", *p);
-    }
-    f->close_section();
-  }
-}
-
-void wal_transaction_t::encode(bufferlist& bl) const
-{
-  ENCODE_START(1, 1, bl);
-  ::encode(seq, bl);
-  ::encode(ops, bl);
-  ::encode(shared_overlay_keys, bl);
-  ENCODE_FINISH(bl);
-}
-
-void wal_transaction_t::decode(bufferlist::iterator& p)
-{
-  DECODE_START(1, p);
-  ::decode(seq, p);
-  ::decode(ops, p);
-  ::decode(shared_overlay_keys, p);
-  DECODE_FINISH(p);
-}
-
-void wal_transaction_t::dump(Formatter *f) const
-{
-  f->dump_unsigned("seq", seq);
-  f->open_array_section("ops");
-  for (list<wal_op_t>::const_iterator p = ops.begin(); p != ops.end(); ++p) {
-    f->dump_object("op", *p);
-  }
-  f->close_section();
-  f->open_array_section("shared_overlay_keys");
-  for (vector<string>::const_iterator p = shared_overlay_keys.begin();
-       p != shared_overlay_keys.end(); ++p) {
-    f->dump_string("shared_overlay_key", *p);
-  }
-  f->close_section();
-}
diff --git a/src/os/newstore/newstore_types.h b/src/os/newstore/newstore_types.h
deleted file mode 100644
index ca616ad..0000000
--- a/src/os/newstore/newstore_types.h
+++ /dev/null
@@ -1,192 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2014 Red Hat
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-#ifndef CEPH_OSD_NEWSTORE_TYPES_H
-#define CEPH_OSD_NEWSTORE_TYPES_H
-
-#include <ostream>
-#include "include/types.h"
-
-namespace ceph {
-  class Formatter;
-}
-
-/// collection metadata
-struct cnode_t {
-  uint32_t bits;   ///< how many bits of coll pgid are significant
-
-  cnode_t(int b=0) : bits(b) {}
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& p);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<cnode_t*>& o);
-};
-WRITE_CLASS_ENCODER(cnode_t)
-
-/// unique id for a local file
-struct fid_t {
-  uint32_t fset, fno;
-  string handle;
-  fid_t() : fset(0), fno(0) { }
-  fid_t(uint32_t s, uint32_t n) : fset(s), fno(n) { }
-
-  void encode(bufferlist& bl) const {
-    ::encode(fset, bl);
-    ::encode(fno, bl);
-    ::encode(handle, bl);
-  }
-  void decode(bufferlist::iterator& p) {
-    ::decode(fset, p);
-    ::decode(fno, p);
-    ::decode(handle, p);
-  }
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<fid_t*>& o);
-};
-WRITE_CLASS_ENCODER(fid_t)
-
-static inline ostream& operator<<(ostream& out, const fid_t& fid) {
-  out << fid.fset << "/" << fid.fno;
-  if (fid.handle.length())
-    out << "~";
-  return out;
-}
-
-static inline bool operator==(const fid_t& a, const fid_t& b) {
-  return a.fset == b.fset && a.fno == b.fno && a.handle == b.handle;
-}
-static inline bool operator!=(const fid_t& a, const fid_t& b) {
-  return !(a == b);
-}
-
-/// fragment: a byte extent backed by a file
-struct fragment_t {
-  uint32_t offset;   ///< offset in file to first byte of this fragment
-  uint32_t length;   ///< length of fragment/extent
-  fid_t fid;         ///< file backing this fragment
-
-  fragment_t() : offset(0), length(0) {}
-  fragment_t(uint32_t o, uint32_t l) : offset(o), length(l) {}
-  fragment_t(uint32_t o, uint32_t l, fid_t f) : offset(o), length(l), fid(f) {}
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& p);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<fragment_t*>& o);
-};
-WRITE_CLASS_ENCODER(fragment_t)
-
-ostream& operator<<(ostream& out, const fragment_t& o);
-
-struct overlay_t {
-  uint64_t key;          ///< key (offset of start of original k/v pair)
-  uint32_t value_offset; ///< offset in associated value for this extent
-  uint32_t length;
-
-  overlay_t() : key(0), value_offset(0), length(0) {}
-  overlay_t(uint64_t k, uint32_t vo, uint32_t l)
-    : key(k), value_offset(vo), length(l) {}
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& p);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<overlay_t*>& o);
-
-};
-WRITE_CLASS_ENCODER(overlay_t)
-
-ostream& operator<<(ostream& out, const overlay_t& o);
-
-/// onode: per-object metadata
-struct onode_t {
-  uint64_t nid;                        ///< numeric id (locally unique)
-  uint64_t size;                       ///< object size
-  map<string, bufferptr> attrs;        ///< attrs
-  map<uint64_t, fragment_t> data_map;  ///< data (offset to fragment mapping)
-  map<uint64_t,overlay_t> overlay_map; ///< overlay data (stored in db)
-  set<uint64_t> shared_overlays;       ///< overlay keys that are shared
-  uint32_t last_overlay_key;           ///< key for next overlay
-  uint64_t omap_head;                  ///< id for omap root node
-
-  uint32_t expected_object_size;
-  uint32_t expected_write_size;
-
-  onode_t()
-    : nid(0),
-      size(0),
-      last_overlay_key(0),
-      omap_head(0),
-      expected_object_size(0),
-      expected_write_size(0) {}
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& p);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<onode_t*>& o);
-};
-WRITE_CLASS_ENCODER(onode_t)
-
-
-/// writeahead-logged op
-struct wal_op_t {
-  typedef enum {
-    OP_WRITE = 1,
-    OP_TRUNCATE = 3,
-    OP_ZERO = 4,
-    OP_REMOVE = 5,
-  } type_t;
-  __u8 op;
-  fid_t fid;
-  uint64_t offset, length;
-  bufferlist data;
-  uint64_t nid;
-  vector<overlay_t> overlays;
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& p);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<wal_op_t*>& o);
-};
-WRITE_CLASS_ENCODER(wal_op_t)
-
-
-/// writeahead-logged transaction
-struct wal_transaction_t {
-  uint64_t seq;
-  list<wal_op_t> ops;
-  vector<string> shared_overlay_keys;
-
-  int64_t _bytes;  ///< cached byte count
-
-  wal_transaction_t() : _bytes(-1) {}
-
-  uint64_t get_bytes() {
-    if (_bytes < 0) {
-      _bytes = 0;
-      for (list<wal_op_t>::iterator p = ops.begin(); p != ops.end(); ++p) {
-	_bytes += p->length;
-      }
-    }
-    return _bytes;
-  }
-
-  void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& p);
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<wal_transaction_t*>& o);
-};
-WRITE_CLASS_ENCODER(wal_transaction_t)
-
-#endif
diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc
index a79ba09..dadfeaa 100644
--- a/src/osd/ECBackend.cc
+++ b/src/osd/ECBackend.cc
@@ -88,7 +88,7 @@ ostream &operator<<(ostream &lhs, const ECBackend::read_result_t &rhs)
   } else {
     lhs << ", noattrs";
   }
-  return lhs << ", returned=" << rhs.returned;
+  return lhs << ", returned=" << rhs.returned << ")";
 }
 
 ostream &operator<<(ostream &lhs, const ECBackend::ReadOp &rhs)
@@ -150,7 +150,8 @@ ostream &operator<<(ostream &lhs, const ECBackend::RecoveryOp &rhs)
 	     << " obc refcount=" << rhs.obc.use_count()
 	     << " state=" << ECBackend::RecoveryOp::tostr(rhs.state)
 	     << " waiting_on_pushes=" << rhs.waiting_on_pushes
-	     << " extent_requested=" << rhs.extent_requested;
+	     << " extent_requested=" << rhs.extent_requested
+	     << ")";
 }
 
 void ECBackend::RecoveryOp::dump(Formatter *f) const
@@ -1702,7 +1703,7 @@ void ECBackend::start_remaining_read_op(
 }
 
 ECUtil::HashInfoRef ECBackend::get_hash_info(
-  const hobject_t &hoid, bool checks)
+  const hobject_t &hoid, bool checks, const map<string,bufferptr> *attrs)
 {
   dout(10) << __func__ << ": Getting attr on " << hoid << dendl;
   ECUtil::HashInfoRef ref = unstable_hashinfo_registry.lookup(hoid);
@@ -1718,12 +1719,25 @@ ECUtil::HashInfoRef ECBackend::get_hash_info(
     if (r >= 0) {
       dout(10) << __func__ << ": found on disk, size " << st.st_size << dendl;
       bufferlist bl;
-      r = store->getattr(
-	coll,
-	ghobject_t(hoid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
-	ECUtil::get_hinfo_key(),
-	bl);
-      if (r >= 0) {
+      if (attrs) {
+	map<string, bufferptr>::const_iterator k = attrs->find(ECUtil::get_hinfo_key());
+	if (k == attrs->end()) {
+	  dout(5) << __func__ << " " << hoid << " missing hinfo attr" << dendl;
+	} else {
+	  bl.push_back(k->second);
+	}
+      } else {
+	r = store->getattr(
+	  coll,
+	  ghobject_t(hoid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
+	  ECUtil::get_hinfo_key(),
+	  bl);
+	if (r < 0) {
+	  dout(5) << __func__ << ": getattr failed: " << cpp_strerror(r) << dendl;
+	  bl.clear(); // just in case
+	}
+      }
+      if (bl.length() > 0) {
 	bufferlist::iterator bp = bl.begin();
 	::decode(hinfo, bp);
 	if (checks && hinfo.get_total_chunk_size() != (uint64_t)st.st_size) {
@@ -2091,7 +2105,7 @@ void ECBackend::be_deep_scrub(
     return;
   }
 
-  ECUtil::HashInfoRef hinfo = get_hash_info(poid, false);
+  ECUtil::HashInfoRef hinfo = get_hash_info(poid, false, &o.attrs);
   if (!hinfo) {
     dout(0) << "_scan_list  " << poid << " could not retrieve hash info" << dendl;
     o.read_error = true;
diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h
index efb284e..bb064f8 100644
--- a/src/osd/ECBackend.h
+++ b/src/osd/ECBackend.h
@@ -456,7 +456,8 @@ public:
   const ECUtil::stripe_info_t sinfo;
   /// If modified, ensure that the ref is held until the update is applied
   SharedPtrRegistry<hobject_t, ECUtil::HashInfo, hobject_t::BitwiseComparator> unstable_hashinfo_registry;
-  ECUtil::HashInfoRef get_hash_info(const hobject_t &hoid, bool checks = true);
+  ECUtil::HashInfoRef get_hash_info(const hobject_t &hoid, bool checks = true,
+				    const map<string,bufferptr> *attr = NULL);
 
   friend struct ReadCB;
   void check_op(Op *op);
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 9911548..785ac50 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -238,7 +238,6 @@ OSDService::OSDService(OSD *osd) :
   backfill_request_lock("OSD::backfill_request_lock"),
   backfill_request_timer(cct, backfill_request_lock, false),
   last_tid(0),
-  tid_lock("OSDService::tid_lock"),
   reserver_finisher(cct),
   local_reserver(&reserver_finisher, cct->_conf->osd_max_backfills,
 		 cct->_conf->osd_min_recovery_priority),
@@ -483,7 +482,7 @@ void OSDService::init()
   watch_timer.init();
   agent_timer.init();
 
-  agent_thread.create();
+  agent_thread.create("osd_srv_agent");
 }
 
 void OSDService::final_init()
@@ -1367,88 +1366,79 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, const string &dev,
 
   ceph::shared_ptr<ObjectStore::Sequencer> osr(
     new ObjectStore::Sequencer("mkfs"));
+  OSDSuperblock sb;
+  bufferlist sbbl;
+  C_SaferCond waiter;
 
-  try {
-    // if we are fed a uuid for this osd, use it.
-    store->set_fsid(cct->_conf->osd_uuid);
-
-    ret = store->mkfs();
-    if (ret) {
-      derr << "OSD::mkfs: ObjectStore::mkfs failed with error " << ret << dendl;
-      goto free_store;
-    }
-
-    ret = store->mount();
-    if (ret) {
-      derr << "OSD::mkfs: couldn't mount ObjectStore: error " << ret << dendl;
-      goto free_store;
-    }
-
-    OSDSuperblock sb;
-    bufferlist sbbl;
-    ret = store->read(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, 0, sbbl);
-    if (ret >= 0) {
-      /* if we already have superblock, check content of superblock */
-      dout(0) << " have superblock" << dendl;
-      bufferlist::iterator p;
-      p = sbbl.begin();
-      ::decode(sb, p);
-      if (whoami != sb.whoami) {
-	derr << "provided osd id " << whoami << " != superblock's " << sb.whoami << dendl;
-	ret = -EINVAL;
-	goto umount_store;
-      }
-      if (fsid != sb.cluster_fsid) {
-	derr << "provided cluster fsid " << fsid << " != superblock's " << sb.cluster_fsid << dendl;
-	ret = -EINVAL;
-	goto umount_store;
-      }
-    } else {
-      // create superblock
-      if (fsid.is_zero()) {
-	derr << "must specify cluster fsid" << dendl;
-	ret = -EINVAL;
-	goto umount_store;
-      }
+  // if we are fed a uuid for this osd, use it.
+  store->set_fsid(cct->_conf->osd_uuid);
 
-      sb.cluster_fsid = fsid;
-      sb.osd_fsid = store->get_fsid();
-      sb.whoami = whoami;
-      sb.compat_features = get_osd_initial_compat_set();
+  ret = store->mkfs();
+  if (ret) {
+    derr << "OSD::mkfs: ObjectStore::mkfs failed with error " << ret << dendl;
+    goto free_store;
+  }
 
-      bufferlist bl;
-      ::encode(sb, bl);
+  ret = store->mount();
+  if (ret) {
+    derr << "OSD::mkfs: couldn't mount ObjectStore: error " << ret << dendl;
+    goto free_store;
+  }
 
-      ObjectStore::Transaction t;
-      t.create_collection(coll_t::meta(), 0);
-      t.write(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
-      ret = store->apply_transaction(osr.get(), t);
-      if (ret) {
-	derr << "OSD::mkfs: error while writing OSD_SUPERBLOCK_POBJECT: "
-	     << "apply_transaction returned " << ret << dendl;
-	goto umount_store;
-      }
+  ret = store->read(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, 0, sbbl);
+  if (ret >= 0) {
+    /* if we already have superblock, check content of superblock */
+    dout(0) << " have superblock" << dendl;
+    bufferlist::iterator p;
+    p = sbbl.begin();
+    ::decode(sb, p);
+    if (whoami != sb.whoami) {
+      derr << "provided osd id " << whoami << " != superblock's " << sb.whoami
+	   << dendl;
+      ret = -EINVAL;
+      goto umount_store;
     }
-
-    C_SaferCond waiter;
-    if (!osr->flush_commit(&waiter)) {
-      waiter.wait();
+    if (fsid != sb.cluster_fsid) {
+      derr << "provided cluster fsid " << fsid
+	   << " != superblock's " << sb.cluster_fsid << dendl;
+      ret = -EINVAL;
+      goto umount_store;
     }
+  } else {
+    // create superblock
+    if (fsid.is_zero()) {
+      derr << "must specify cluster fsid" << dendl;
+      ret = -EINVAL;
+      goto umount_store;
+    }
+
+    sb.cluster_fsid = fsid;
+    sb.osd_fsid = store->get_fsid();
+    sb.whoami = whoami;
+    sb.compat_features = get_osd_initial_compat_set();
 
-    ret = write_meta(store, sb.cluster_fsid, sb.osd_fsid, whoami);
+    bufferlist bl;
+    ::encode(sb, bl);
+
+    ObjectStore::Transaction t;
+    t.create_collection(coll_t::meta(), 0);
+    t.write(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
+    ret = store->apply_transaction(osr.get(), t);
     if (ret) {
-      derr << "OSD::mkfs: failed to write fsid file: error " << ret << dendl;
+      derr << "OSD::mkfs: error while writing OSD_SUPERBLOCK_POBJECT: "
+	   << "apply_transaction returned " << ret << dendl;
       goto umount_store;
     }
-
   }
-  catch (const std::exception &se) {
-    derr << "OSD::mkfs: caught exception " << se.what() << dendl;
-    ret = 1000;
+
+  if (!osr->flush_commit(&waiter)) {
+    waiter.wait();
   }
-  catch (...) {
-    derr << "OSD::mkfs: caught unknown exception." << dendl;
-    ret = 1000;
+
+  ret = write_meta(store, sb.cluster_fsid, sb.osd_fsid, whoami);
+  if (ret) {
+    derr << "OSD::mkfs: failed to write fsid file: error " << ret << dendl;
+    goto umount_store;
   }
 
 umount_store:
@@ -1504,16 +1494,16 @@ int OSD::peek_meta(ObjectStore *store, std::string& magic,
   if (r < 0)
     return r;
   r = cluster_fsid.parse(val.c_str());
-  if (r < 0)
-    return r;
+  if (!r)
+    return -EINVAL;
 
   r = store->read_meta("fsid", &val);
   if (r < 0) {
     osd_fsid = uuid_d();
   } else {
     r = osd_fsid.parse(val.c_str());
-    if (r < 0)
-      return r;
+    if (!r)
+      return -EINVAL;
   }
 
   return 0;
@@ -1563,17 +1553,17 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_,
   asok_hook(NULL),
   osd_compat(get_osd_compat_set()),
   state(STATE_INITIALIZING),
-  osd_tp(cct, "OSD::osd_tp", cct->_conf->osd_op_threads, "osd_op_threads"),
-  osd_op_tp(cct, "OSD::osd_op_tp", 
+  osd_tp(cct, "OSD::osd_tp", "tp_osd", cct->_conf->osd_op_threads, "osd_op_threads"),
+  osd_op_tp(cct, "OSD::osd_op_tp", "tp_osd_tp",
     cct->_conf->osd_op_num_threads_per_shard * cct->_conf->osd_op_num_shards),
-  recovery_tp(cct, "OSD::recovery_tp", cct->_conf->osd_recovery_threads, "osd_recovery_threads"),
-  disk_tp(cct, "OSD::disk_tp", cct->_conf->osd_disk_threads, "osd_disk_threads"),
-  command_tp(cct, "OSD::command_tp", 1),
+  recovery_tp(cct, "OSD::recovery_tp", "tp_osd_recov", cct->_conf->osd_recovery_threads, "osd_recovery_threads"),
+  disk_tp(cct, "OSD::disk_tp", "tp_osd_disk", cct->_conf->osd_disk_threads, "osd_disk_threads"),
+  command_tp(cct, "OSD::command_tp", "tp_osd_cmd",  1),
   paused_recovery(false),
   session_waiting_lock("OSD::session_waiting_lock"),
   heartbeat_lock("OSD::heartbeat_lock"),
   heartbeat_stop(false), heartbeat_update_lock("OSD::heartbeat_update_lock"),
-  heartbeat_need_update(true), heartbeat_epoch(0),
+  heartbeat_need_update(true),
   hbclient_messenger(hb_clientm),
   hb_front_server_messenger(hb_front_serverm),
   hb_back_server_messenger(hb_back_serverm),
@@ -1648,7 +1638,7 @@ void cls_initialize(ClassHandler *ch);
 void OSD::handle_signal(int signum)
 {
   assert(signum == SIGINT || signum == SIGTERM);
-  derr << "*** Got signal " << sys_siglist[signum] << " ***" << dendl;
+  derr << "*** Got signal " << sig_str(signum) << " ***" << dendl;
   shutdown();
 }
 
@@ -1970,7 +1960,7 @@ int OSD::init()
   set_disk_tp_priority();
 
   // start the heartbeat
-  heartbeat_thread.create();
+  heartbeat_thread.create("osd_srv_heartbt");
 
   // tick
   tick_timer.add_event_after(cct->_conf->osd_heartbeat_interval, new C_Tick(this));
@@ -2371,6 +2361,7 @@ int OSD::shutdown()
       p->second->osr->flush();
     }
   }
+  clear_pg_stat_queue();
   
   // finish ops
   op_shardedwq.drain(); // should already be empty except for lagard PGs
@@ -2571,7 +2562,8 @@ void OSD::clear_temp_objects()
 	break;
       vector<ghobject_t>::iterator q;
       for (q = objects.begin(); q != objects.end(); ++q) {
-	if (q->hobj.is_temp()) {
+	// Hammer set pool for temps to -1, so check for clean-up
+	if (q->hobj.is_temp() || (q->hobj.pool == -1)) {
 	  temps.push_back(*q);
 	} else {
 	  break;
@@ -2903,8 +2895,8 @@ void OSD::load_pgs()
        it != ls.end();
        ++it) {
     spg_t pgid;
-    if (it->is_temp(&pgid) || it->is_removal(&pgid) ||
-        (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
+    if (it->is_temp(&pgid) ||
+       (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
       dout(10) << "load_pgs " << *it << " clearing temp" << dendl;
       recursive_remove_collection(store, pgid, *it);
       continue;
@@ -3259,7 +3251,7 @@ void OSD::handle_pg_peering_evt(
 
       pg->queue_peering_event(evt);
       pg->unlock();
-      wake_pg_waiters(pg, pgid);
+      wake_pg_waiters(pgid);
       return;
     }
     case RES_SELF: {
@@ -3294,7 +3286,7 @@ void OSD::handle_pg_peering_evt(
 
       pg->queue_peering_event(evt);
       pg->unlock();
-      wake_pg_waiters(pg, resurrected);
+      wake_pg_waiters(resurrected);
       return;
     }
     case RES_PARENT: {
@@ -3335,7 +3327,7 @@ void OSD::handle_pg_peering_evt(
       //parent->queue_peering_event(evt);
       parent->queue_null(osdmap->get_epoch(), osdmap->get_epoch());
       parent->unlock();
-      wake_pg_waiters(parent, resurrected);
+      wake_pg_waiters(resurrected);
       return;
     }
     }
@@ -3538,7 +3530,6 @@ void OSD::maybe_update_heartbeat_peers()
 
   dout(10) << "maybe_update_heartbeat_peers updating" << dendl;
 
-  heartbeat_epoch = osdmap->get_epoch();
 
   // build heartbeat from set
   if (is_active()) {
@@ -3959,7 +3950,7 @@ bool OSD::heartbeat_reset(Connection *con)
 void OSD::tick()
 {
   assert(osd_lock.is_locked());
-  dout(5) << "tick" << dendl;
+  dout(10) << "tick" << dendl;
 
   logger->set(l_osd_buf, buffer::get_total_alloc());
   logger->set(l_osd_history_alloc_bytes, SHIFT_ROUND_UP(buffer::get_history_alloc_bytes(), 20));
@@ -3980,10 +3971,7 @@ void OSD::tick()
   }
 
   if (is_waiting_for_healthy()) {
-    if (_is_healthy()) {
-      dout(1) << "healthy again, booting" << dendl;
-      start_boot();
-    }
+    start_boot();
   }
 
   if (is_active()) {
@@ -4011,7 +3999,7 @@ void OSD::tick()
 void OSD::tick_without_osd_lock()
 {
   assert(tick_timer_lock.is_locked());
-  dout(5) << "tick_without_osd_lock" << dendl;
+  dout(10) << "tick_without_osd_lock" << dendl;
 
   // osd_lock is not being held, which means the OSD state
   // might change when doing the monitor report
@@ -4468,6 +4456,16 @@ struct C_OSD_GetVersion : public Context {
 
 void OSD::start_boot()
 {
+  if (!_is_healthy()) {
+    // if we are not healthy, do not mark ourselves up (yet)
+    dout(1) << "not healthy; waiting to boot" << dendl;
+    if (!is_waiting_for_healthy())
+      start_waiting_for_healthy();
+    // send pings sooner rather than later
+    heartbeat_kick();
+    return;
+  }
+  dout(1) << "We are healthy, booting" << dendl;
   set_state(STATE_PREBOOT);
   dout(10) << "start_boot - have maps " << superblock.oldest_map
 	   << ".." << superblock.newest_map << dendl;
@@ -4499,13 +4497,6 @@ void OSD::_preboot(epoch_t oldest, epoch_t newest)
 	     (osdmap->get_up_osd_features() & CEPH_FEATURE_HAMMER_0_94_4) == 0) {
     dout(1) << "osdmap indicates one or more pre-v0.94.4 hammer OSDs is running"
 	    << dendl;
-  } else if (is_waiting_for_healthy() || !_is_healthy()) {
-    // if we are not healthy, do not mark ourselves up (yet)
-    dout(1) << "not healthy; waiting to boot" << dendl;
-    if (!is_waiting_for_healthy())
-      start_waiting_for_healthy();
-    // send pings sooner rather than later
-    heartbeat_kick();
   } else if (osdmap->get_epoch() >= oldest - 1 &&
 	     osdmap->get_epoch() + cct->_conf->osd_map_message_max > newest) {
     _send_boot();
@@ -6560,6 +6551,18 @@ void OSD::handle_osd_map(MOSDMap *m)
         service.set_epochs(NULL,&up_epoch, &bind_epoch);
 	do_restart = true;
 
+	//add markdown log
+	utime_t now = ceph_clock_now(g_ceph_context);
+	utime_t grace = utime_t(g_conf->osd_max_markdown_period, 0);
+	osd_markdown_log.push_back(now);
+	//clear all out-of-date log
+	while (!osd_markdown_log.empty() && osd_markdown_log.front() + grace < now)
+	  osd_markdown_log.pop_front();
+	if ((int)osd_markdown_log.size() > g_conf->osd_max_markdown_count) {
+	  do_restart = false;
+	  do_shutdown = true;
+	}
+
 	start_waiting_for_healthy();
 
 	set<int> avoid_ports;
@@ -6631,16 +6634,17 @@ void OSD::handle_osd_map(MOSDMap *m)
     osdmap_subscribe(osdmap->get_epoch()+1, false);
   }
   else if (do_shutdown) {
-    osd_lock.Unlock();
-    shutdown();
     if (network_error) {
+      Mutex::Locker l(heartbeat_lock);	
       map<int,pair<utime_t,entity_inst_t>>::iterator it = failure_pending.begin();
       while (it != failure_pending.end()) {
         dout(10) << "handle_osd_ping canceling in-flight failure report for osd." << it->first << dendl;
         send_still_alive(osdmap->get_epoch(), it->second.second);
         failure_pending.erase(it++);
       }
-    }
+    }	
+    osd_lock.Unlock();
+    shutdown();
     osd_lock.Lock();
   }
   else if (is_preboot()) {
@@ -6702,14 +6706,13 @@ void OSD::check_osdmap_features(ObjectStore *fs)
     }
 
     if ((features & CEPH_FEATURE_OSD_ERASURE_CODES) &&
-	!fs->get_allow_sharded_objects()) {
+	!superblock.compat_features.incompat.contains(CEPH_OSD_FEATURE_INCOMPAT_SHARDS)) {
       dout(0) << __func__ << " enabling on-disk ERASURE CODES compat feature" << dendl;
       superblock.compat_features.incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_SHARDS);
       ObjectStore::Transaction *t = new ObjectStore::Transaction;
       write_superblock(*t);
       int err = store->queue_transaction_and_cleanup(service.meta_osr.get(), t);
       assert(err == 0);
-      fs->set_allow_sharded_objects();
     }
   }
 }
@@ -7207,7 +7210,7 @@ void OSD::handle_pg_create(OpRequestRef op)
     pg->write_if_dirty(*rctx.transaction);
     pg->publish_stats_to_osd();
     pg->unlock();
-    wake_pg_waiters(pg, pgid);
+    wake_pg_waiters(pgid);
     dispatch_context(rctx, pg, osdmap);
   }
 
@@ -7514,12 +7517,12 @@ void OSD::handle_pg_trim(OpRequestRef op)
     dout(10) << " don't have pg " << m->pgid << dendl;
   } else {
     PG *pg = _lookup_lock_pg(m->pgid);
+    assert(pg);
     if (m->epoch < pg->info.history.same_interval_since) {
       dout(10) << *pg << " got old trim to " << m->trim_to << ", ignoring" << dendl;
       pg->unlock();
       return;
     }
-    assert(pg);
 
     if (pg->is_primary()) {
       // peer is informing us of their last_complete_ondisk
@@ -7909,9 +7912,11 @@ bool OSD::_recover_now()
 void OSD::do_recovery(PG *pg, ThreadPool::TPHandle &handle)
 {
   if (g_conf->osd_recovery_sleep > 0) {
+    handle.suspend_tp_timeout();
     utime_t t;
     t.set_from_double(g_conf->osd_recovery_sleep);
     t.sleep();
+    handle.reset_tp_timeout();
     dout(20) << __func__ << " slept for " << t << dendl;
   }
 
@@ -8482,7 +8487,7 @@ struct C_CompleteSplits : public Context {
       osd->dispatch_context_transaction(rctx, &**i);
 	to_complete.insert((*i)->info.pgid);
       (*i)->unlock();
-      osd->wake_pg_waiters(&**i, (*i)->info.pgid);
+      osd->wake_pg_waiters((*i)->info.pgid);
       to_complete.clear();
     }
 
@@ -8814,6 +8819,7 @@ int OSD::init_op_flags(OpRequestRef& op)
     case CEPH_OSD_OP_READ:
     case CEPH_OSD_OP_SYNC_READ:
     case CEPH_OSD_OP_SPARSE_READ:
+    case CEPH_OSD_OP_WRITEFULL:
       if (m->ops.size() == 1 &&
           (iter->op.flags & CEPH_OSD_OP_FLAG_FADVISE_NOCACHE ||
            iter->op.flags & CEPH_OSD_OP_FLAG_FADVISE_DONTNEED)) {
diff --git a/src/osd/OSD.h b/src/osd/OSD.h
index 367d236..04bbe00 100644
--- a/src/osd/OSD.h
+++ b/src/osd/OSD.h
@@ -486,7 +486,7 @@ public:
   }
 
   /*
-   * osdmap - current published amp
+   * osdmap - current published map
    * next_osdmap - pre_published map that is about to be published.
    *
    * We use the next_osdmap to send messages and initiate connections,
@@ -798,14 +798,9 @@ public:
 
   // -- tids --
   // for ops i issue
-  ceph_tid_t last_tid;
-  Mutex tid_lock;
+  atomic_t last_tid;
   ceph_tid_t get_tid() {
-    ceph_tid_t t;
-    tid_lock.Lock();
-    t = ++last_tid;
-    tid_lock.Unlock();
-    return t;
+    return (ceph_tid_t)last_tid.inc();
   }
 
   // -- backfill_reservation --
@@ -1391,7 +1386,7 @@ public:
       (*i)->put();
     }
   }
-  void clear_session_waiting_on_pg(Session *session, spg_t pgid) {
+  void clear_session_waiting_on_pg(Session *session, const spg_t &pgid) {
     Mutex::Locker l(session_waiting_lock);
     map<spg_t, set<Session*> >::iterator i = session_waiting_for_pg.find(pgid);
     if (i == session_waiting_for_pg.end()) {
@@ -1409,19 +1404,14 @@ public:
   void session_handle_reset(Session *session) {
     Mutex::Locker l(session->session_dispatch_lock);
     clear_session_waiting_on_map(session);
-    vector<spg_t> pgs_to_clear;
-    pgs_to_clear.reserve(session->waiting_for_pg.size());
+
     for (map<spg_t, list<OpRequestRef> >::iterator i =
 	   session->waiting_for_pg.begin();
 	 i != session->waiting_for_pg.end();
 	 ++i) {
-      pgs_to_clear.push_back(i->first);
-    }
-    for (vector<spg_t>::iterator i = pgs_to_clear.begin();
-	 i != pgs_to_clear.end();
-	 ++i) {
-      clear_session_waiting_on_pg(session, *i);
-    }
+      clear_session_waiting_on_pg(session, i->first);
+    }    
+
     /* Messages have connection refs, we need to clear the
      * connection->session->message->connection
      * cycles which result.
@@ -1524,7 +1514,6 @@ private:
   bool heartbeat_stop;
   Mutex heartbeat_update_lock; // orders under heartbeat_lock
   bool heartbeat_need_update;   ///< true if we need to refresh our heartbeat peers
-  epoch_t heartbeat_epoch;      ///< last epoch we updated our heartbeat peers
   map<int,HeartbeatInfo> heartbeat_peers;  ///< map of osd id to HeartbeatInfo
   utime_t last_mon_heartbeat;
   Messenger *hbclient_messenger;
@@ -1834,6 +1823,7 @@ private:
   utime_t         had_map_since;
   RWLock          map_lock;
   list<OpRequestRef>  waiting_for_osdmap;
+  deque<utime_t> osd_markdown_log;
 
   friend struct send_map_on_destruct;
 
@@ -1942,7 +1932,7 @@ protected:
     int lastactingprimary
     ); ///< @return false if there was a map gap between from and now
 
-  void wake_pg_waiters(PG* pg, spg_t pgid) {
+  void wake_pg_waiters(spg_t pgid) {
     assert(osd_lock.is_locked());
     // Need write lock on pg_map_lock
     set<Session*> concerned_sessions;
diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc
index ebe73d6..9de54a9 100644
--- a/src/osd/OSDMap.cc
+++ b/src/osd/OSDMap.cc
@@ -1032,6 +1032,8 @@ uint64_t OSDMap::get_features(int entity_type, uint64_t *pmask) const
     features |= CEPH_FEATURE_CRUSH_TUNABLES3;
   if (crush->has_v4_buckets())
     features |= CEPH_FEATURE_CRUSH_V4;
+  if (crush->has_nondefault_tunables5())
+    features |= CEPH_FEATURE_CRUSH_TUNABLES5;
   mask |= CEPH_FEATURES_CRUSH;
 
   for (map<int64_t,pg_pool_t>::const_iterator p = pools.begin(); p != pools.end(); ++p) {
@@ -1054,6 +1056,8 @@ uint64_t OSDMap::get_features(int entity_type, uint64_t *pmask) const
 	features |= CEPH_FEATURE_CRUSH_V2;
       if (crush->is_v3_rule(ruleid))
 	features |= CEPH_FEATURE_CRUSH_TUNABLES3;
+      if (crush->is_v5_rule(ruleid))
+	features |= CEPH_FEATURE_CRUSH_TUNABLES5;
     }
   }
   if (entity_type == CEPH_ENTITY_TYPE_OSD) {
@@ -1347,9 +1351,21 @@ int OSDMap::apply_incremental(const Incremental &inc)
       osd_xinfo[i->first].down_stamp = modified;
     }
     if ((osd_state[i->first] & CEPH_OSD_EXISTS) &&
-	(s & CEPH_OSD_EXISTS))
+	(s & CEPH_OSD_EXISTS)) {
+      // osd is destroyed; clear out anything interesting.
       (*osd_uuid)[i->first] = uuid_d();
-    osd_state[i->first] ^= s;
+      osd_info[i->first] = osd_info_t();
+      osd_xinfo[i->first] = osd_xinfo_t();
+      osd_weight[i->first] = CEPH_OSD_IN;
+      set_primary_affinity(i->first, CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
+      osd_addrs->client_addr[i->first].reset(new entity_addr_t());
+      osd_addrs->cluster_addr[i->first].reset(new entity_addr_t());
+      osd_addrs->hb_front_addr[i->first].reset(new entity_addr_t());
+      osd_addrs->hb_back_addr[i->first].reset(new entity_addr_t());
+      osd_state[i->first] = 0;
+    } else {
+      osd_state[i->first] ^= s;
+    }
   }
   for (map<int32_t,entity_addr_t>::const_iterator i = inc.new_up_client.begin();
        i != inc.new_up_client.end();
@@ -2775,8 +2791,6 @@ int OSDMap::build_simple_crush_map_from_conf(CephContext *cct,
 
   crush.create();
 
-  set<string> hosts, racks;
-
   // root
   int root_type = _build_crush_types(crush);
   int rootid;
@@ -2815,9 +2829,6 @@ int OSDMap::build_simple_crush_map_from_conf(CephContext *cct,
     if (rack.length() == 0)
       rack = "unknownrack";
 
-    hosts.insert(host);
-    racks.insert(rack);
-
     map<string,string> loc;
     loc["host"] = host;
     loc["rack"] = rack;
diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h
index e929b72..24c287f 100644
--- a/src/osd/OSDMap.h
+++ b/src/osd/OSDMap.h
@@ -369,9 +369,6 @@ public:
     assert(o < max_osd);
     osd_state[o] = s;
   }
-  void set_weightf(int o, float w) {
-    set_weight(o, (int)((float)CEPH_OSD_IN * w));
-  }
   void set_weight(int o, unsigned w) {
     assert(o < max_osd);
     osd_weight[o] = w;
@@ -751,14 +748,16 @@ public:
     return p->second.get_size();
   }
   int get_pg_type(pg_t pg) const {
-    assert(pools.count(pg.pool()));
-    return pools.find(pg.pool())->second.get_type();
+    map<int64_t,pg_pool_t>::const_iterator p = pools.find(pg.pool());
+    assert(p != pools.end());
+    return p->second.get_type();
   }
 
 
   pg_t raw_pg_to_pg(pg_t pg) const {
-    assert(pools.count(pg.pool()));
-    return pools.find(pg.pool())->second.raw_pg_to_pg(pg);
+    map<int64_t,pg_pool_t>::const_iterator p = pools.find(pg.pool());
+    assert(p != pools.end());
+    return p->second.raw_pg_to_pg(pg);
   }
 
   // pg -> acting primary osd
diff --git a/src/osd/PG.cc b/src/osd/PG.cc
index ffbd6ff..2fd8dd2 100644
--- a/src/osd/PG.cc
+++ b/src/osd/PG.cc
@@ -74,7 +74,7 @@ static ostream& _prefix(std::ostream *_dout, T *t)
   return *_dout << t->gen_prefix();
 }
 
-void PG::get(const string &tag) 
+void PG::get(const char* tag)
 {
   ref.inc();
 #ifdef PG_DEBUG_REFS
@@ -86,7 +86,7 @@ void PG::get(const string &tag)
 #endif
 }
 
-void PG::put(const string &tag)
+void PG::put(const char* tag)
 {
 #ifdef PG_DEBUG_REFS
   {
@@ -185,7 +185,7 @@ PG::PG(OSDService *o, OSDMapRef curmap,
     _pool.id,
     p.shard),
   map_lock("PG::map_lock"),
-  osdmap_ref(curmap), last_persisted_osdmap_ref(curmap), pool(_pool),
+  osdmap_ref(curmap), pool(_pool),
   _lock("PG::_lock"),
   ref(0),
   #ifdef PG_DEBUG_REFS
@@ -223,7 +223,8 @@ PG::PG(OSDService *o, OSDMapRef curmap,
   acting_features(CEPH_FEATURES_SUPPORTED_DEFAULT),
   upacting_features(CEPH_FEATURES_SUPPORTED_DEFAULT),
   do_sort_bitwise(false),
-  last_epoch(0)
+  last_epoch(0),
+  last_persisted_epoch(curmap->get_epoch())
 {
 #ifdef PG_DEBUG_REFS
   osd->add_pgid(p, this);
@@ -954,12 +955,10 @@ map<pg_shard_t, pg_info_t>::const_iterator PG::find_best_info(
        ++i) {
     if (!cct->_conf->osd_find_best_info_ignore_history_les &&
 	max_last_epoch_started_found < i->second.history.last_epoch_started) {
-      min_last_update_acceptable = eversion_t::max();
       max_last_epoch_started_found = i->second.history.last_epoch_started;
     }
     if (!i->second.is_incomplete() &&
 	max_last_epoch_started_found < i->second.last_epoch_started) {
-      min_last_update_acceptable = eversion_t::max();
       max_last_epoch_started_found = i->second.last_epoch_started;
     }
   }
@@ -2568,7 +2567,7 @@ void PG::publish_stats_to_osd()
   if (pg_stats_publish_valid && info.stats == pg_stats_publish &&
       info.stats.last_fresh > cutoff) {
     dout(15) << "publish_stats_to_osd " << pg_stats_publish.reported_epoch
-	     << ": no change since" << dendl;
+	     << ": no change since " << info.stats.last_fresh << dendl;
   } else {
     // update our stat summary and timestamps
     info.stats.reported_epoch = get_osdmap()->get_epoch();
@@ -2788,7 +2787,7 @@ void PG::prepare_write_info(map<string,bufferlist> *km)
   assert(ret == 0);
   if (need_update_epoch)
     last_epoch = get_osdmap()->get_epoch();
-  last_persisted_osdmap_ref = osdmap_ref;
+  last_persisted_epoch = last_epoch;
 
   dirty_info = false;
   dirty_big_info = false;
@@ -3853,7 +3852,9 @@ void PG::scrub(epoch_t queued, ThreadPool::TPHandle &handle)
     unlock();
     utime_t t;
     t.set_from_double(g_conf->osd_scrub_sleep);
+    handle.suspend_tp_timeout();
     t.sleep();
+    handle.reset_tp_timeout();
     lock();
     dout(20) << __func__ << " slept for " << t << dendl;
   }
@@ -3993,7 +3994,8 @@ void PG::chunky_scrub(ThreadPool::TPHandle &handle)
 	  scrubber.reserved_peers.clear();
 	}
 
-        scrubber.start = hobject_t();
+        // Don't include temporary objects when scrubbing
+        scrubber.start = info.pgid.pgid.get_hobj_start();
         scrubber.state = PG::Scrubber::NEW_CHUNK;
 
 	{
@@ -5421,15 +5423,15 @@ void PG::handle_activate_map(RecoveryCtx *rctx)
   dout(10) << "handle_activate_map " << dendl;
   ActMap evt;
   recovery_state.handle_event(evt, rctx);
-  if (osdmap_ref->get_epoch() - last_persisted_osdmap_ref->get_epoch() >
+  if (osdmap_ref->get_epoch() - last_persisted_epoch >
     cct->_conf->osd_pg_epoch_persisted_max_stale) {
     dout(20) << __func__ << ": Dirtying info: last_persisted is "
-	     << last_persisted_osdmap_ref->get_epoch()
+	     << last_persisted_epoch
 	     << " while current is " << osdmap_ref->get_epoch() << dendl;
     dirty_info = true;
   } else {
     dout(20) << __func__ << ": Not dirtying info: last_persisted is "
-	     << last_persisted_osdmap_ref->get_epoch()
+	     << last_persisted_epoch
 	     << " while current is " << osdmap_ref->get_epoch() << dendl;
   }
   if (osdmap_ref->check_new_blacklist_entries()) check_blacklisted_watchers();
diff --git a/src/osd/PG.h b/src/osd/PG.h
index 5ab8d59..c5f1c12 100644
--- a/src/osd/PG.h
+++ b/src/osd/PG.h
@@ -206,7 +206,6 @@ protected:
   Mutex map_lock;
   list<OpRequestRef> waiting_for_map;
   OSDMapRef osdmap_ref;
-  OSDMapRef last_persisted_osdmap_ref;
   PGPool pool;
 
   void queue_op(OpRequestRef& op);
@@ -274,8 +273,8 @@ public:
   void put_with_id(uint64_t);
   void dump_live_ids();
 #endif
-  void get(const string &tag);
-  void put(const string &tag);
+  void get(const char* tag);
+  void put(const char* tag);
 
   bool dirty_info, dirty_big_info;
 
@@ -2056,6 +2055,7 @@ public:
 
   bool do_sort_bitwise;
   epoch_t last_epoch;
+  epoch_t last_persisted_epoch;
 
  public:
   const spg_t&      get_pgid() const { return pg_id; }
diff --git a/src/osd/PGBackend.cc b/src/osd/PGBackend.cc
index 806a4a0..7ef6c47 100644
--- a/src/osd/PGBackend.cc
+++ b/src/osd/PGBackend.cc
@@ -351,9 +351,9 @@ void PGBackend::be_scan_list(
 	       << ", skipping" << dendl;
     } else if (r == -EIO) {
       dout(25) << __func__ << "  " << poid << " got " << r
-	       << ", read_error" << dendl;
+	       << ", stat_error" << dendl;
       ScrubMap::object &o = map.objects[poid];
-      o.read_error = true;
+      o.stat_error = true;
     } else {
       derr << __func__ << " got: " << cpp_strerror(r) << dendl;
       assert(0);
@@ -370,9 +370,11 @@ enum scrub_error_type PGBackend::be_compare_scrub_objects(
   ostream &errorstream)
 {
   enum scrub_error_type error = CLEAN;
+  if (candidate.stat_error) {
+    error = SHALLOW_ERROR;
+    errorstream << "candidate had a stat error";
+  }
   if (candidate.read_error) {
-    // This can occur on stat() of a shallow scrub, but in that case size will
-    // be invalid, and this will be over-ridden below.
     error = DEEP_ERROR;
     errorstream << "candidate had a read error";
   }
@@ -404,12 +406,11 @@ enum scrub_error_type PGBackend::be_compare_scrub_objects(
 		  << " from auth shard " << auth_shard;
     }
   }
-  // Shallow error takes precendence because this will be seen by
-  // both types of scrubs.
-  if (auth.size != candidate.size) {
+  if (!candidate.stat_error && auth.size != candidate.size) {
     if (error != CLEAN)
       errorstream << ", ";
-    error = SHALLOW_ERROR;
+    if (error != DEEP_ERROR)
+      error = SHALLOW_ERROR;
     bool known = auth.size == be_get_ondisk_size(auth_oi.size);
     errorstream << "size " << candidate.size
 		<< " != "
@@ -422,12 +423,14 @@ enum scrub_error_type PGBackend::be_compare_scrub_objects(
     if (!candidate.attrs.count(i->first)) {
       if (error != CLEAN)
         errorstream << ", ";
-      error = SHALLOW_ERROR;
+      if (error != DEEP_ERROR)
+	error = SHALLOW_ERROR;
       errorstream << "missing attr " << i->first;
     } else if (candidate.attrs.find(i->first)->second.cmp(i->second)) {
       if (error != CLEAN)
         errorstream << ", ";
-      error = SHALLOW_ERROR;
+      if (error != DEEP_ERROR)
+	error = SHALLOW_ERROR;
       errorstream << "attr value mismatch " << i->first;
     }
   }
@@ -437,7 +440,8 @@ enum scrub_error_type PGBackend::be_compare_scrub_objects(
     if (!auth.attrs.count(i->first)) {
       if (error != CLEAN)
         errorstream << ", ";
-      error = SHALLOW_ERROR;
+      if (error != DEEP_ERROR)
+	error = SHALLOW_ERROR;
       errorstream << "extra attr " << i->first;
     }
   }
@@ -460,11 +464,12 @@ map<pg_shard_t, ScrubMap *>::const_iterator
     if (i == j->second->objects.end()) {
       continue;
     }
-    if (i->second.read_error) {
-      // scrub encountered read error, probably corrupt
+    if (i->second.read_error || i->second.stat_error) {
+      // scrub encountered read error or stat_error, probably corrupt
       dout(10) << __func__ << ": rejecting osd " << j->first
 	       << " for obj " << obj
-	       << ", read_error"
+	       << "," << (i->second.read_error ? " read_error" : "")
+	       << (i->second.stat_error ? " stat_error" : "")
 	       << dendl;
       continue;
     }
@@ -571,10 +576,9 @@ void PGBackend::be_compare_scrubmaps(
       be_select_auth_object(*k, maps, okseed, &auth_oi);
     list<pg_shard_t> auth_list;
     if (auth == maps.end()) {
-      dout(10) << __func__ << ": unable to find any auth object" << dendl;
       ++shallow_errors;
-      errorstream << pgid << " shard " << j->first
-		  << ": soid failed to pick suitable auth object\n";
+      errorstream << pgid.pgid << " soid " << *k
+		  << ": failed to pick suitable auth object\n";
       continue;
     }
     auth_list.push_back(auth->first);
@@ -650,9 +654,9 @@ void PGBackend::be_compare_scrubmaps(
 	  auth_oi.omap_digest != auth_object.omap_digest) {
 	++deep_errors;
 	errorstream << pgid << " recorded omap digest 0x"
-		    << std::hex << auth_oi.data_digest << " != on disk 0x"
-		    << auth_object.digest << std::dec << " on " << auth_oi.soid
-		    << "\n";
+		    << std::hex << auth_oi.omap_digest << " != on disk 0x"
+		    << auth_object.omap_digest << std::dec
+		    << " on " << auth_oi.soid << "\n";
 	if (repair)
 	  update = FORCE;
       }
diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc
index 1fabccd..5165c52 100644
--- a/src/osd/PGLog.cc
+++ b/src/osd/PGLog.cc
@@ -124,7 +124,7 @@ void PGLog::IndexedLog::trim(
     tail = s;
 }
 
-ostream& PGLog::IndexedLog::print(ostream& out) const 
+ostream& PGLog::IndexedLog::print(ostream& out) const
 {
   out << *this << std::endl;
   for (list<pg_log_entry_t>::const_iterator p = log.begin();
@@ -864,8 +864,8 @@ void PGLog::_write_log(
     ::encode(divergent_priors, (*km)["divergent_priors"]);
   }
   if (require_rollback) {
-    ::encode(log.can_rollback_to, (*km)["can_rollback_to"]);
-    ::encode(log.rollback_info_trimmed_to, (*km)["rollback_info_trimmed_to"]);
+  ::encode(log.can_rollback_to, (*km)["can_rollback_to"]);
+  ::encode(log.rollback_info_trimmed_to, (*km)["rollback_info_trimmed_to"]);
   }
 
   if (!to_remove.empty())
@@ -899,38 +899,34 @@ void PGLog::read_log(ObjectStore *store, coll_t pg_coll,
     for (p->seek_to_first(); p->valid() ; p->next(false)) {
       // non-log pgmeta_oid keys are prefixed with _; skip those
       if (p->key()[0] == '_')
-	continue;
+        continue;
       bufferlist bl = p->value();//Copy bufferlist before creating iterator
       bufferlist::iterator bp = bl.begin();
       if (p->key() == "divergent_priors") {
-	::decode(divergent_priors, bp);
-	dout(20) << "read_log " << divergent_priors.size() << " divergent_priors" << dendl;
+        ::decode(divergent_priors, bp);
+        dout(20) << "read_log " << divergent_priors.size() << " divergent_priors" << dendl;
       } else if (p->key() == "can_rollback_to") {
-	bufferlist bl = p->value();
-	bufferlist::iterator bp = bl.begin();
-	::decode(log.can_rollback_to, bp);
+        ::decode(log.can_rollback_to, bp);
       } else if (p->key() == "rollback_info_trimmed_to") {
-	bufferlist bl = p->value();
-	bufferlist::iterator bp = bl.begin();
-	::decode(log.rollback_info_trimmed_to, bp);
+        ::decode(log.rollback_info_trimmed_to, bp);
       } else {
-	pg_log_entry_t e;
-	e.decode_with_checksum(bp);
-	dout(20) << "read_log " << e << dendl;
-	if (!log.log.empty()) {
-	  pg_log_entry_t last_e(log.log.back());
-	  assert(last_e.version.version < e.version.version);
-	  assert(last_e.version.epoch <= e.version.epoch);
-	}
-	log.log.push_back(e);
-	log.head = e.version;
-	if (log_keys_debug)
-	  log_keys_debug->insert(e.get_key_name());
+        pg_log_entry_t e;
+        e.decode_with_checksum(bp);
+        dout(20) << "read_log " << e << dendl;
+        if (!log.log.empty()) {
+          pg_log_entry_t last_e(log.log.back());
+          assert(last_e.version.version < e.version.version);
+          assert(last_e.version.epoch <= e.version.epoch);
+        }
+        log.log.push_back(e);
+        log.head = e.version;
+        if (log_keys_debug)
+          log_keys_debug->insert(e.get_key_name());
       }
     }
   }
   log.head = info.last_update;
-  log.index();
+  log.reset_riter();
 
   // build missing
   if (info.last_complete < info.last_update) {
diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h
index a493488..87e7ab2 100644
--- a/src/osd/PGLog.h
+++ b/src/osd/PGLog.h
@@ -25,6 +25,11 @@
 #include <list>
 using namespace std;
 
+#define PGLOG_INDEXED_OBJECTS          (1 << 0)
+#define PGLOG_INDEXED_CALLER_OPS       (1 << 1)
+#define PGLOG_INDEXED_EXTRA_CALLER_OPS (1 << 2)
+#define PGLOG_INDEXED_ALL              (PGLOG_INDEXED_OBJECTS | PGLOG_INDEXED_CALLER_OPS | PGLOG_INDEXED_EXTRA_CALLER_OPS)
+
 struct PGLog {
   ////////////////////////////// sub classes //////////////////////////////
   struct LogEntryHandler {
@@ -55,9 +60,9 @@ struct PGLog {
    * plus some methods to manipulate it all.
    */
   struct IndexedLog : public pg_log_t {
-    ceph::unordered_map<hobject_t,pg_log_entry_t*> objects;  // ptrs into log.  be careful!
-    ceph::unordered_map<osd_reqid_t,pg_log_entry_t*> caller_ops;
-    ceph::unordered_multimap<osd_reqid_t,pg_log_entry_t*> extra_caller_ops;
+    mutable ceph::unordered_map<hobject_t,pg_log_entry_t*> objects;  // ptrs into log.  be careful!
+    mutable ceph::unordered_map<osd_reqid_t,pg_log_entry_t*> caller_ops;
+    mutable ceph::unordered_multimap<osd_reqid_t,pg_log_entry_t*> extra_caller_ops;
 
     // recovery pointers
     list<pg_log_entry_t>::iterator complete_to;  // not inclusive of referenced item
@@ -65,6 +70,7 @@ struct PGLog {
 
     //
   private:
+    mutable __u16 indexed_data;
     /**
      * rollback_info_trimmed_to_riter points to the first log entry <=
      * rollback_info_trimmed_to
@@ -80,6 +86,7 @@ struct PGLog {
     IndexedLog() :
       complete_to(log.end()),
       last_requested(0),
+      indexed_data(0),
       rollback_info_trimmed_to_riter(log.rbegin())
       {}
 
@@ -121,11 +128,25 @@ struct PGLog {
     }
 
     bool logged_object(const hobject_t& oid) const {
+      if (!(indexed_data & PGLOG_INDEXED_OBJECTS)) {
+         index_objects();
+      }
       return objects.count(oid);
     }
+
     bool logged_req(const osd_reqid_t &r) const {
-      return caller_ops.count(r) || extra_caller_ops.count(r);
+      if (!(indexed_data & PGLOG_INDEXED_CALLER_OPS)) {
+        index_caller_ops();
+      }
+      if (!caller_ops.count(r)) {
+        if (!(indexed_data & PGLOG_INDEXED_EXTRA_CALLER_OPS)) {
+          index_extra_caller_ops();
+        }
+        return extra_caller_ops.count(r);
+      }
+      return true;
     }
+
     bool get_request(
       const osd_reqid_t &r,
       eversion_t *replay_version,
@@ -133,6 +154,9 @@ struct PGLog {
       assert(replay_version);
       assert(user_version);
       ceph::unordered_map<osd_reqid_t,pg_log_entry_t*>::const_iterator p;
+      if (!(indexed_data & PGLOG_INDEXED_CALLER_OPS)) {
+        index_caller_ops();
+      }
       p = caller_ops.find(r);
       if (p != caller_ops.end()) {
 	*replay_version = p->second->version;
@@ -142,6 +166,9 @@ struct PGLog {
 
       // warning: we will return *a* request for this reqid, but not
       // necessarily the most recent.
+      if (!(indexed_data & PGLOG_INDEXED_EXTRA_CALLER_OPS)) {
+        index_extra_caller_ops();
+      }
       p = extra_caller_ops.find(r);
       if (p != extra_caller_ops.end()) {
 	for (vector<pair<osd_reqid_t, version_t> >::const_iterator i =
@@ -162,8 +189,11 @@ struct PGLog {
     /// get a (bounded) list of recent reqids for the given object
     void get_object_reqids(const hobject_t& oid, unsigned max,
 			   vector<pair<osd_reqid_t, version_t> > *pls) const {
-      // make sure object is present at least once before we do an
-      // O(n) search.
+       // make sure object is present at least once before we do an
+       // O(n) search.
+      if (!(indexed_data & PGLOG_INDEXED_OBJECTS)) {
+        index_objects();
+      }
       if (objects.count(oid) == 0)
 	return;
       for (list<pg_log_entry_t>::const_reverse_iterator i = log.rbegin();
@@ -182,75 +212,142 @@ struct PGLog {
 	}
       }
     }
+    
+    void reset_riter() {
+      rollback_info_trimmed_to_riter = log.rbegin();
+      while (rollback_info_trimmed_to_riter != log.rend() &&
+        rollback_info_trimmed_to_riter->version > rollback_info_trimmed_to)
+        ++rollback_info_trimmed_to_riter;
+    }
 
+    // indexes objects, caller ops and extra caller ops
     void index() {
       objects.clear();
       caller_ops.clear();
       extra_caller_ops.clear();
       for (list<pg_log_entry_t>::iterator i = log.begin();
-           i != log.end();
-           ++i) {
+             i != log.end();
+             ++i) {
+               
         objects[i->soid] = &(*i);
-	if (i->reqid_is_indexed()) {
-	  //assert(caller_ops.count(i->reqid) == 0);  // divergent merge_log indexes new before unindexing old
-	  caller_ops[i->reqid] = &(*i);
-	}
-	for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
-	       i->extra_reqids.begin();
-	     j != i->extra_reqids.end();
-	     ++j) {
-	  extra_caller_ops.insert(make_pair(j->first, &(*i)));
-	}
+        
+        if (i->reqid_is_indexed()) {
+        //assert(caller_ops.count(i->reqid) == 0);  // divergent merge_log indexes new before unindexing old
+          caller_ops[i->reqid] = &(*i);
+        }
+        
+        for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
+              i->extra_reqids.begin();
+              j != i->extra_reqids.end();
+              ++j) {
+            extra_caller_ops.insert(make_pair(j->first, &(*i)));
+        }
       }
+        
+      reset_riter();
+      indexed_data = PGLOG_INDEXED_ALL;
+        
+    }
 
-      rollback_info_trimmed_to_riter = log.rbegin();
-      while (rollback_info_trimmed_to_riter != log.rend() &&
-	     rollback_info_trimmed_to_riter->version > rollback_info_trimmed_to)
-	++rollback_info_trimmed_to_riter;
+    void index_objects() const {
+      objects.clear();
+      for (list<pg_log_entry_t>::const_iterator i = log.begin();
+            i != log.end();
+            ++i) {
+         objects[i->soid] = const_cast<pg_log_entry_t*>(&(*i));
+       }
+ 
+      indexed_data |= PGLOG_INDEXED_OBJECTS;
+
+    }
+
+    void index_caller_ops() const {
+      caller_ops.clear();
+      for (list<pg_log_entry_t>::const_iterator i = log.begin();
+             i != log.end();
+             ++i) {
+               
+        if (i->reqid_is_indexed()) {
+        //assert(caller_ops.count(i->reqid) == 0);  // divergent merge_log indexes new before unindexing old
+          caller_ops[i->reqid] = const_cast<pg_log_entry_t*>(&(*i));
+        }        
+      }
+        
+      indexed_data |= PGLOG_INDEXED_CALLER_OPS;
+    }
+
+    void index_extra_caller_ops() const {
+      extra_caller_ops.clear();
+      for (list<pg_log_entry_t>::const_iterator i = log.begin();
+             i != log.end();
+             ++i) {
+               
+        for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
+              i->extra_reqids.begin();
+              j != i->extra_reqids.end();
+              ++j) {
+            extra_caller_ops.insert(make_pair(j->first, const_cast<pg_log_entry_t*>(&(*i))));
+        }
+      }
+        
+      indexed_data |= PGLOG_INDEXED_EXTRA_CALLER_OPS;        
     }
 
     void index(pg_log_entry_t& e) {
-      if (objects.count(e.soid) == 0 || 
-          objects[e.soid]->version < e.version)
-        objects[e.soid] = &e;
-      if (e.reqid_is_indexed()) {
-	//assert(caller_ops.count(i->reqid) == 0);  // divergent merge_log indexes new before unindexing old
-	caller_ops[e.reqid] = &e;
+      if (indexed_data & PGLOG_INDEXED_OBJECTS) {
+        if (objects.count(e.soid) == 0 || 
+            objects[e.soid]->version < e.version)
+          objects[e.soid] = &e;
+      }
+      if (indexed_data & PGLOG_INDEXED_CALLER_OPS) {
+        if (e.reqid_is_indexed()) {
+    //assert(caller_ops.count(i->reqid) == 0);  // divergent merge_log indexes new before unindexing old
+    caller_ops[e.reqid] = &e;
+        }
       }
-      for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
-	     e.extra_reqids.begin();
-	   j != e.extra_reqids.end();
-	   ++j) {
-	extra_caller_ops.insert(make_pair(j->first, &e));
+      if (indexed_data & PGLOG_INDEXED_EXTRA_CALLER_OPS) {
+        for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
+         e.extra_reqids.begin();
+       j != e.extra_reqids.end();
+       ++j) {
+    extra_caller_ops.insert(make_pair(j->first, &e));
+        }
       }
     }
     void unindex() {
       objects.clear();
       caller_ops.clear();
       extra_caller_ops.clear();
+      indexed_data = 0;
     }
     void unindex(pg_log_entry_t& e) {
       // NOTE: this only works if we remove from the _tail_ of the log!
-      if (objects.count(e.soid) && objects[e.soid]->version == e.version)
-        objects.erase(e.soid);
+      if (indexed_data & PGLOG_INDEXED_OBJECTS) {
+        if (objects.count(e.soid) && objects[e.soid]->version == e.version)
+          objects.erase(e.soid);
+      }
       if (e.reqid_is_indexed()) {
-	if (caller_ops.count(e.reqid) &&  // divergent merge_log indexes new before unindexing old
-	    caller_ops[e.reqid] == &e)
-	  caller_ops.erase(e.reqid);
+        if (indexed_data & PGLOG_INDEXED_CALLER_OPS) {
+          if (caller_ops.count(e.reqid) &&  // divergent merge_log indexes new before unindexing old
+              caller_ops[e.reqid] == &e)
+            caller_ops.erase(e.reqid);    
+        }
       }
-      for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
-	     e.extra_reqids.begin();
-	   j != e.extra_reqids.end();
-	   ++j) {
-	for (ceph::unordered_multimap<osd_reqid_t,pg_log_entry_t*>::iterator k =
-	       extra_caller_ops.find(j->first);
-	     k != extra_caller_ops.end() && k->first == j->first;
-	     ++k) {
-	  if (k->second == &e) {
-	    extra_caller_ops.erase(k);
-	    break;
-	  }
-	}
+      if (indexed_data & PGLOG_INDEXED_EXTRA_CALLER_OPS) {
+        for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
+             e.extra_reqids.begin();
+             j != e.extra_reqids.end();
+             ++j) {
+          for (ceph::unordered_multimap<osd_reqid_t,pg_log_entry_t*>::iterator k =
+               extra_caller_ops.find(j->first);
+               k != extra_caller_ops.end() && k->first == j->first;
+               ++k) {
+            if (k->second == &e) {
+              extra_caller_ops.erase(k);
+              break;
+            }
+          }
+        }
       }
     }
 
@@ -274,15 +371,22 @@ struct PGLog {
       head = e.version;
 
       // to our index
-      objects[e.soid] = &(log.back());
-      if (e.reqid_is_indexed()) {
-	caller_ops[e.reqid] = &(log.back());
+      if (indexed_data & PGLOG_INDEXED_OBJECTS) {
+        objects[e.soid] = &(log.back());
       }
-      for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
-	     e.extra_reqids.begin();
-	   j != e.extra_reqids.end();
-	   ++j) {
-	extra_caller_ops.insert(make_pair(j->first, &(log.back())));
+      if (indexed_data & PGLOG_INDEXED_CALLER_OPS) {
+        if (e.reqid_is_indexed()) {
+    caller_ops[e.reqid] = &(log.back());
+        }
+      }
+      
+      if (indexed_data & PGLOG_INDEXED_EXTRA_CALLER_OPS) {
+        for (vector<pair<osd_reqid_t, version_t> >::const_iterator j =
+         e.extra_reqids.begin();
+       j != e.extra_reqids.end();
+       ++j) {
+    extra_caller_ops.insert(make_pair(j->first, &(log.back())));
+        }
       }
     }
 
diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc
index 6d33c01..1ffa50d 100644
--- a/src/osd/ReplicatedBackend.cc
+++ b/src/osd/ReplicatedBackend.cc
@@ -758,14 +758,18 @@ void ReplicatedBackend::be_deep_scrub(
 
   uint32_t fadvise_flags = CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL | CEPH_OSD_OP_FLAG_FADVISE_DONTNEED;
 
-  while ( (r = store->read(
-             coll,
-             ghobject_t(
-               poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
-             pos,
-             cct->_conf->osd_deep_scrub_stride, bl,
-             fadvise_flags, true)) > 0) {
+  while (true) {
     handle.reset_tp_timeout();
+    r = store->read(
+	  coll,
+	  ghobject_t(
+	    poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
+	  pos,
+	  cct->_conf->osd_deep_scrub_stride, bl,
+	  fadvise_flags, true);
+    if (r <= 0)
+      break;
+
     h << bl;
     pos += bl.length();
     bl.clear();
@@ -836,6 +840,8 @@ void ReplicatedBackend::be_deep_scrub(
   //Store final calculated CRC32 of omap header & key/values
   o.omap_digest = oh.digest();
   o.omap_digest_present = true;
+  dout(20) << __func__ << "  " << poid << " omap_digest "
+	   << std::hex << o.omap_digest << std::dec << dendl;
 }
 
 void ReplicatedBackend::_do_push(OpRequestRef op)
@@ -1571,14 +1577,14 @@ void ReplicatedBackend::prep_push_to_replica(
     // we need the head (and current SnapSet) locally to do that.
     if (get_parent()->get_local_missing().is_missing(head)) {
       dout(15) << "push_to_replica missing head " << head << ", pushing raw clone" << dendl;
-      return prep_push(obc, soid, peer, pop);
+      return prep_push(obc, soid, peer, pop, cache_dont_need);
     }
     hobject_t snapdir = head;
     snapdir.snap = CEPH_SNAPDIR;
     if (get_parent()->get_local_missing().is_missing(snapdir)) {
       dout(15) << "push_to_replica missing snapdir " << snapdir
 	       << ", pushing raw clone" << dendl;
-      return prep_push(obc, soid, peer, pop);
+      return prep_push(obc, soid, peer, pop, cache_dont_need);
     }
 
     SnapSetContext *ssc = obc->ssc;
@@ -1612,7 +1618,7 @@ void ReplicatedBackend::prep_push_to_replica(
 
 void ReplicatedBackend::prep_push(ObjectContextRef obc,
 			     const hobject_t& soid, pg_shard_t peer,
-			     PushOp *pop)
+			     PushOp *pop, bool cache_dont_need)
 {
   interval_set<uint64_t> data_subset;
   if (obc->obs.oi.size)
@@ -1621,7 +1627,7 @@ void ReplicatedBackend::prep_push(ObjectContextRef obc,
 
   prep_push(obc, soid, peer,
 	    obc->obs.oi.version, data_subset, clone_subsets,
-	    pop);
+	    pop, cache_dont_need);
 }
 
 void ReplicatedBackend::prep_push(
diff --git a/src/osd/ReplicatedBackend.h b/src/osd/ReplicatedBackend.h
index a36007d..7a1b72a 100644
--- a/src/osd/ReplicatedBackend.h
+++ b/src/osd/ReplicatedBackend.h
@@ -298,7 +298,8 @@ private:
     PushOp *pop, bool cache_dont_need = true);
   void prep_push(ObjectContextRef obc,
 		 const hobject_t& oid, pg_shard_t dest,
-		 PushOp *op);
+		 PushOp *op,
+		 bool cache_dont_need);
   void prep_push(ObjectContextRef obc,
 		 const hobject_t& soid, pg_shard_t peer,
 		 eversion_t version,
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index ba7cfa9..4d5c94d 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -63,7 +63,7 @@
 #include "include/rados/rados_types.hpp"
 
 #ifdef WITH_LTTNG
-#include "tracing/osd.h" // ??
+#include "tracing/osd.h"
 #else
 #define tracepoint(...)
 #endif
@@ -815,37 +815,39 @@ int ReplicatedPG::do_command(cmdmap_t cmdmap, ostream& ss,
     }
     f->dump_int("num_missing", missing.num_missing());
     f->dump_int("num_unfound", get_num_unfound());
-    map<hobject_t,pg_missing_t::item, hobject_t::ComparatorWithDefault>::const_iterator p = missing.missing.upper_bound(offset);
+    const map<hobject_t, pg_missing_t::item, hobject_t::BitwiseComparator> &needs_recovery_map =
+      missing_loc.get_needs_recovery();
+    map<hobject_t, pg_missing_t::item, hobject_t::BitwiseComparator>::const_iterator p =
+      needs_recovery_map.upper_bound(offset);
     {
       f->open_array_section("objects");
       int32_t num = 0;
       bufferlist bl;
-      while (p != missing.missing.end() && num < cct->_conf->osd_command_max_records) {
-	f->open_object_section("object");
-	{
-	  f->open_object_section("oid");
-	  p->first.dump(f.get());
-	  f->close_section();
-	}
-	p->second.dump(f.get());  // have, need keys
-	{
-	  f->open_array_section("locations");
-	  if (missing_loc.needs_recovery(p->first)) {
-	    for (set<pg_shard_t>::iterator r =
-		   missing_loc.get_locations(p->first).begin();
-		 r != missing_loc.get_locations(p->first).end();
-		 ++r)
-	      f->dump_stream("shard") << *r;
+      for (; p != needs_recovery_map.end() && num < cct->_conf->osd_command_max_records; ++p) {
+        if (missing_loc.is_unfound(p->first)) {
+	  f->open_object_section("object");
+	  {
+	    f->open_object_section("oid");
+	    p->first.dump(f.get());
+	    f->close_section();
+	  }
+          p->second.dump(f.get()); // have, need keys
+	  {
+	    f->open_array_section("locations");
+            for (set<pg_shard_t>::iterator r =
+                missing_loc.get_locations(p->first).begin();
+                r != missing_loc.get_locations(p->first).end();
+                ++r)
+              f->dump_stream("shard") << *r;
+	    f->close_section();
 	  }
 	  f->close_section();
-	}
-	f->close_section();
-	++p;
-	num++;
+	  num++;
+        }
       }
       f->close_section();
     }
-    f->dump_int("more", p != missing.missing.end());
+    f->dump_int("more", p != needs_recovery_map.end());
     f->close_section();
     f->flush(odata);
     return 0;
@@ -936,7 +938,10 @@ void ReplicatedPG::do_pg_op(OpRequestRef op)
 	}
 
 	hobject_t next;
-	hobject_t current = response.handle;
+	hobject_t lower_bound = response.handle;
+        dout(10) << " pgnls lower_bound " << lower_bound << dendl;
+
+	hobject_t current = lower_bound;
 	osr->flush();
 	int r = pgbackend->objects_list_partial(
 	  current,
@@ -985,6 +990,9 @@ void ReplicatedPG::do_pg_op(OpRequestRef op)
 	    ++ls_iter;
 	  }
 
+          dout(10) << " pgnls candidate 0x" << std::hex << candidate.get_hash()
+            << " vs lower bound 0x" << lower_bound.get_hash() << dendl;
+
 	  if (cmp(candidate, next, get_sort_bitwise()) >= 0) {
 	    break;
 	  }
@@ -1036,18 +1044,37 @@ void ReplicatedPG::do_pg_op(OpRequestRef op)
 	  if (filter && !pgls_filter(filter, candidate, filter_out))
 	    continue;
 
+          dout(20) << "pgnls item 0x" << std::hex
+            << candidate.get_hash()
+            << ", rev 0x" << hobject_t::_reverse_bits(candidate.get_hash())
+            << std::dec << " "
+            << candidate.oid.name << dendl;
+
 	  librados::ListObjectImpl item;
 	  item.nspace = candidate.get_namespace();
 	  item.oid = candidate.oid.name;
 	  item.locator = candidate.get_key();
 	  response.entries.push_back(item);
 	}
+
 	if (next.is_max() &&
 	    missing_iter == pg_log.get_missing().missing.end() &&
 	    ls_iter == sentries.end()) {
 	  result = 1;
-	}
-	response.handle = next;
+
+	  if (get_osdmap()->test_flag(CEPH_OSDMAP_SORTBITWISE)) {
+	    // Set response.handle to the start of the next PG
+	    // according to the object sort order.  Only do this if
+	    // the cluster is in bitwise mode; with legacy nibblewise
+	    // sort PGs don't always cover contiguous ranges of the
+	    // hash order.
+	    response.handle = info.pgid.pgid.get_hobj_end(
+	      pool.info.get_pg_num());
+	  }
+	} else {
+          response.handle = next;
+        }
+        dout(10) << "pgls handle=" << response.handle << dendl;
 	::encode(response, osd_op.outdata);
 	if (filter)
 	  ::encode(filter_out, osd_op.outdata);
@@ -2264,33 +2291,29 @@ bool ReplicatedPG::maybe_promote(ObjectContextRef obc,
     }
     break;
   default:
-    if (in_hit_set) {
-      promote_object(obc, missing_oid, oloc, promote_op);
-    } else {
-      // Check if in other hit sets
-      map<time_t,HitSetRef>::iterator itor;
-      bool in_other_hit_sets = false;
-      unsigned max_in_memory_read = pool.info.min_read_recency_for_promote > 0 ? pool.info.min_read_recency_for_promote - 1 : 0;
-      unsigned max_in_memory_write = pool.info.min_write_recency_for_promote > 0 ? pool.info.min_write_recency_for_promote - 1 : 0;
-      unsigned max_in_memory = MAX(max_in_memory_read, max_in_memory_write);
-      for (itor = agent_state->hit_set_map.begin(); itor != agent_state->hit_set_map.end() && max_in_memory--; ++itor) {
-        if (obc.get()) {
-          if (obc->obs.oi.soid != hobject_t() && itor->second->contains(obc->obs.oi.soid)) {
-            in_other_hit_sets = true;
-            break;
-          }
-        } else {
-          if (missing_oid != hobject_t() && itor->second->contains(missing_oid)) {
-            in_other_hit_sets = true;
-            break;
-          }
-        }
+    {
+      unsigned count = (int)in_hit_set;
+      if (count) {
+	// Check if in other hit sets
+	const hobject_t& oid = obc.get() ? obc->obs.oi.soid : missing_oid;
+	for (map<time_t,HitSetRef>::reverse_iterator itor =
+	       agent_state->hit_set_map.rbegin();
+	     itor != agent_state->hit_set_map.rend();
+	     ++itor) {
+	  if (!itor->second->contains(oid)) {
+	    break;
+	  }
+	  ++count;
+	  if (count >= recency) {
+	    break;
+	  }
+	}
       }
-      if (in_other_hit_sets) {
-        promote_object(obc, missing_oid, oloc, promote_op);
+      if (count >= recency) {
+	promote_object(obc, missing_oid, oloc, promote_op);
       } else {
 	// not promoting
-        return false;
+	return false;
       }
     }
     break;
@@ -2560,12 +2583,11 @@ void ReplicatedPG::do_proxy_write(OpRequestRef op, const hobject_t& missing_oid)
 
   C_ProxyWrite_Commit *fin = new C_ProxyWrite_Commit(
       this, soid, get_last_peering_reset(), pwop);
-  ceph_tid_t tid = osd->objecter->mutate(soid.oid, oloc, obj_op,
-				         snapc, pwop->mtime,
-					 flags, NULL,
-					 new C_OnFinisher(fin, &osd->objecter_finisher),
-				         &pwop->user_version,
-					 pwop->reqid);
+  ceph_tid_t tid = osd->objecter->mutate(
+    soid.oid, oloc, obj_op, snapc,
+    ceph::real_clock::from_ceph_timespec(pwop->mtime),
+    flags, NULL, new C_OnFinisher(fin, &osd->objecter_finisher),
+    &pwop->user_version, pwop->reqid);
   fin->tid = tid;
   pwop->objecter_tid = tid;
   proxywrite_ops[tid] = pwop;
@@ -4160,6 +4182,11 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 	  data_bl.claim_append(tmpbl);
 	  last = miter->first + r;
         }
+        
+        if (r < 0) {
+          result = r;
+          break;
+        }
 
 	// verify trailing hole?
 	if (cct->_conf->osd_verify_sparse_read_holes) {
@@ -4175,11 +4202,6 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 	  }
 	}
 
-        if (r < 0) {
-          result = r;
-          break;
-        }
-
 	// Why SPARSE_READ need checksum? In fact, librbd always use sparse-read. 
 	// Maybe at first, there is no much whole objects. With continued use, more and more whole object exist.
 	// So from this point, for spare-read add checksum make sense.
@@ -5634,12 +5656,10 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 	  result = -ENOENT;
 	  break;
 	}
-	t->touch(soid);
 	t->omap_clear(soid);
 	ctx->delta_stats.num_wr++;
       }
-      obs.oi.set_flag(object_info_t::FLAG_OMAP);
-      obs.oi.set_omap_digest(-1);
+      obs.oi.clear_omap_digest();
       break;
 
     case CEPH_OSD_OP_OMAPRMKEYS:
@@ -5656,7 +5676,6 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 	  tracepoint(osd, do_osd_op_pre_omaprmkeys, soid.oid.name.c_str(), soid.snap.val);
 	  break;
 	}
-	t->touch(soid);
 	bufferlist to_rm_bl;
 	try {
 	  decode_str_set_to_bl(bp, &to_rm_bl);
@@ -5670,7 +5689,6 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 	t->omap_rmkeys(soid, to_rm_bl);
 	ctx->delta_stats.num_wr++;
       }
-      obs.oi.set_flag(object_info_t::FLAG_OMAP);
       obs.oi.clear_omap_digest();
       break;
 
@@ -5678,16 +5696,12 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
       ++ctx->num_read;
       tracepoint(osd, do_osd_op_pre_copy_get_classic, soid.oid.name.c_str(), soid.snap.val);
       result = fill_in_copy_get(ctx, bp, osd_op, ctx->obc, true);
-      if (result == -EINVAL)
-	goto fail;
       break;
 
     case CEPH_OSD_OP_COPY_GET:
       ++ctx->num_read;
       tracepoint(osd, do_osd_op_pre_copy_get, soid.oid.name.c_str(), soid.snap.val);
       result = fill_in_copy_get(ctx, bp, osd_op, ctx->obc, false);
-      if (result == -EINVAL)
-	goto fail;
       break;
 
     case CEPH_OSD_OP_COPY_FROM:
@@ -6826,7 +6840,7 @@ int ReplicatedPG::fill_in_copy_get(
 
   // omap
   uint32_t omap_keys = 0;
-  if (!pool.info.supports_omap()) {
+  if (!pool.info.supports_omap() || !oi.is_omap()) {
     cursor.omap_complete = true;
   } else {
     if (left > 0 && !cursor.omap_complete) {
@@ -7763,7 +7777,7 @@ int ReplicatedPG::start_flush(
       base_oloc,
       o,
       dsnapc,
-      oi.mtime,
+      ceph::real_clock::from_ceph_timespec(oi.mtime),
       (CEPH_OSD_FLAG_IGNORE_OVERLAY |
        CEPH_OSD_FLAG_ORDERSNAP |
        CEPH_OSD_FLAG_ENFORCE_SNAPC),
@@ -7779,7 +7793,7 @@ int ReplicatedPG::start_flush(
       base_oloc,
       o,
       dsnapc2,
-      oi.mtime,
+      ceph::real_clock::from_ceph_timespec(oi.mtime),
       (CEPH_OSD_FLAG_IGNORE_OVERLAY |
        CEPH_OSD_FLAG_ORDERSNAP |
        CEPH_OSD_FLAG_ENFORCE_SNAPC),
@@ -7814,11 +7828,11 @@ int ReplicatedPG::start_flush(
   C_Flush *fin = new C_Flush(this, soid, get_last_peering_reset());
 
   ceph_tid_t tid = osd->objecter->mutate(
-    soid.oid, base_oloc, o, snapc, oi.mtime,
+    soid.oid, base_oloc, o, snapc,
+    ceph::real_clock::from_ceph_timespec(oi.mtime),
     CEPH_OSD_FLAG_IGNORE_OVERLAY | CEPH_OSD_FLAG_ENFORCE_SNAPC,
-    NULL,
-    new C_OnFinisher(fin,
-		     &osd->objecter_finisher));
+    NULL, new C_OnFinisher(fin,
+			   &osd->objecter_finisher));
   /* we're under the pg lock and fin->finish() is grabbing that */
   fin->tid = tid;
   fop->objecter_tid = tid;
@@ -7919,6 +7933,19 @@ int ReplicatedPG::try_flush_mark_clean(FlushOpRef fop)
     }
   }
 
+  // successfully flushed, can we evict this object?
+  if (!fop->op && agent_state->evict_mode != TierAgentState::EVICT_MODE_IDLE &&
+      agent_maybe_evict(obc, true)) {
+    osd->logger->inc(l_osd_tier_clean);
+    if (fop->on_flush) {
+      Context *on_flush = fop->on_flush;
+      fop->on_flush = NULL;
+      on_flush->complete(0);
+    }
+    flush_ops.erase(oid);
+    return 0;
+  }
+
   // successfully flushed; can we clear the dirty bit?
   // try to take the lock manually, since we don't
   // have a ctx yet.
@@ -8327,10 +8354,9 @@ ReplicatedPG::RepGather *ReplicatedPG::new_repop(OpContext *ctx, ObjectContextRe
   repop->start = ceph_clock_now(cct);
 
   repop_queue.push_back(&repop->queue_item);
-  repop_map[repop->rep_tid] = repop;
   repop->get();
 
-  osd->logger->set(l_osd_op_wip, repop_map.size());
+  osd->logger->inc(l_osd_op_wip);
 
   return repop;
 }
@@ -8346,10 +8372,9 @@ void ReplicatedPG::remove_repop(RepGather *repop)
     dout(20) << " snapset_obc " << *repop->ctx->snapset_obc << dendl;
   release_op_ctx_locks(repop->ctx);
   repop->ctx->finish(0);  // FIXME: return value here is sloppy
-  repop_map.erase(repop->rep_tid);
   repop->put();
 
-  osd->logger->set(l_osd_op_wip, repop_map.size());
+  osd->logger->dec(l_osd_op_wip);
 }
 
 ReplicatedPG::RepGather *ReplicatedPG::simple_repop_create(ObjectContextRef obc)
@@ -9518,7 +9543,6 @@ void ReplicatedPG::apply_and_flush_repops(bool requeue)
     remove_repop(repop);
   }
 
-  assert(repop_map.empty());
   assert(repop_queue.empty());
 
   if (requeue) {
@@ -9594,6 +9618,8 @@ void ReplicatedPG::on_shutdown()
   deleting = true;
 
   clear_scrub_reserved();
+  scrub_clear_state();
+
   unreg_next_scrub();
   cancel_copy_ops(false);
   cancel_flush_ops(false);
@@ -11449,7 +11475,7 @@ bool ReplicatedPG::agent_work(int start_max, int agent_flush_quota)
   assert(base_pool);
 
   int ls_min = 1;
-  int ls_max = 10; // FIXME?
+  int ls_max = cct->_conf->osd_pool_default_cache_max_evict_check_size;
 
   // list some objects.  this conveniently lists clones (oldest to
   // newest) before heads... the same order we want to flush in.
@@ -11518,7 +11544,7 @@ bool ReplicatedPG::agent_work(int start_max, int agent_flush_quota)
     }
 
     if (agent_state->evict_mode != TierAgentState::EVICT_MODE_IDLE &&
-	agent_maybe_evict(obc))
+	agent_maybe_evict(obc, false))
       ++started;
     else if (agent_state->flush_mode != TierAgentState::FLUSH_MODE_IDLE &&
              agent_flush_quota > 0 && agent_maybe_flush(obc)) {
@@ -11712,10 +11738,10 @@ struct C_AgentEvictStartStop : public Context {
   }
 };
 
-bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc)
+bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc, bool after_flush)
 {
   const hobject_t& soid = obc->obs.oi.soid;
-  if (obc->obs.oi.is_dirty()) {
+  if (!after_flush && obc->obs.oi.is_dirty()) {
     dout(20) << __func__ << " skip (dirty) " << obc->obs.oi << dendl;
     return false;
   }
@@ -11785,6 +11811,8 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc)
     ctx->delta_stats.num_objects_omap--;
   ctx->delta_stats.num_evict++;
   ctx->delta_stats.num_evict_kb += SHIFT_ROUND_UP(obc->obs.oi.size, 10);
+  if (obc->obs.oi.is_dirty())
+    --ctx->delta_stats.num_objects_dirty;
   assert(r == 0);
   finish_ctx(ctx, pg_log_entry_t::DELETE, false);
   simple_repop_submit(repop);
diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h
index 9f328e5..c596cb0 100644
--- a/src/osd/ReplicatedPG.h
+++ b/src/osd/ReplicatedPG.h
@@ -21,6 +21,7 @@
 #include <boost/tuple/tuple.hpp>
 
 #include "include/assert.h" 
+#include "include/unordered_map.h"
 #include "common/cmdparse.h"
 
 #include "HitSet.h"
@@ -74,7 +75,7 @@ public:
    * CopyResults stores the object metadata of interest to a copy initiator.
    */
   struct CopyResults {
-    utime_t mtime; ///< the copy source's mtime
+    ceph::real_time mtime; ///< the copy source's mtime
     uint64_t object_size; ///< the copied object's size
     bool started_temp_obj; ///< true if the callback needs to delete temp object
     hobject_t temp_oid;    ///< temp object (if any)
@@ -515,7 +516,7 @@ public:
       }
     };
     list<NotifyAck> notify_acks;
-    
+
     uint64_t bytes_written, bytes_read;
 
     utime_t mtime;
@@ -886,7 +887,6 @@ protected:
   // replica ops
   // [primary|tail]
   xlist<RepGather*> repop_queue;
-  map<ceph_tid_t, RepGather*> repop_map;
 
   friend class C_OSD_RepopApplied;
   friend class C_OSD_RepopCommit;
@@ -934,7 +934,7 @@ protected:
   }
   bool agent_work(int max, int agent_flush_quota);
   bool agent_maybe_flush(ObjectContextRef& obc);  ///< maybe flush
-  bool agent_maybe_evict(ObjectContextRef& obc);  ///< maybe evict
+  bool agent_maybe_evict(ObjectContextRef& obc, bool after_flush);  ///< maybe evict
 
   void agent_load_hit_sets();  ///< load HitSets, if needed
 
@@ -1242,7 +1242,6 @@ protected:
 
   void _clear_recovery_state();
 
-  void queue_for_recovery();
   bool start_recovery_ops(
     int max, ThreadPool::TPHandle &handle, int *started);
 
diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc
index de80857..f3e3b08 100644
--- a/src/osd/osd_types.cc
+++ b/src/osd/osd_types.cc
@@ -121,6 +121,22 @@ string ceph_osd_op_flag_string(unsigned flags)
   return string("-");
 }
 
+const char *num_char_map = "0123456789abcdef";
+template<typename T, const int base>
+static inline
+char* ritoa(T u, char *buf) {
+  if (u < base) {
+    *--buf = num_char_map[u];
+    return buf;
+  }
+ 
+  while (u) {
+    *--buf = num_char_map[u % base]; 
+    u /= base;
+  }
+  return buf;
+}
+
 void pg_shard_t::encode(bufferlist &bl) const
 {
   ENCODE_START(1, 1, bl);
@@ -441,11 +457,24 @@ bool spg_t::parse(const char *s)
   return true;
 }
 
+char *spg_t::calc_name(char *buf, const char *suffix_backwords) const
+{
+  while (*suffix_backwords)
+    *--buf = *suffix_backwords++;
+
+  if (!is_no_shard()) {
+    buf = ritoa<int8_t, 10>(shard.id, buf);
+    *--buf = 's';
+  }
+
+  return pgid.calc_name(buf, "");
+}
+
 ostream& operator<<(ostream& out, const spg_t &pg)
 {
-  out << pg.pgid;
-  if (!pg.is_no_shard())
-    out << "s" << (unsigned)pg.shard;
+  char buf[spg_t::calc_name_buf_size];
+  buf[spg_t::calc_name_buf_size - 1] = '\0';
+  out << pg.calc_name(buf + spg_t::calc_name_buf_size - 1, "");
   return out;
 }
 
@@ -522,6 +551,30 @@ pg_t pg_t::get_parent() const
   return retval;
 }
 
+hobject_t pg_t::get_hobj_start() const
+{
+  return hobject_t(object_t(), string(), CEPH_NOSNAP, m_seed, m_pool,
+		   string());
+}
+
+hobject_t pg_t::get_hobj_end(unsigned pg_num) const
+{
+  // note: this assumes a bitwise sort; with the legacy nibblewise
+  // sort a PG did not always cover a single contiguous range of the
+  // (bit-reversed) hash range.
+  unsigned bits = get_split_bits(pg_num);
+  uint64_t rev_start = hobject_t::_reverse_bits(m_seed);
+  uint64_t rev_end = (rev_start | (0xffffffff >> bits)) + 1;
+  if (rev_end >= 0x100000000) {
+    assert(rev_end == 0x100000000);
+    return hobject_t::get_max();
+  } else {
+    return hobject_t(object_t(), string(), CEPH_NOSNAP,
+		   hobject_t::_reverse_bits(rev_end), m_pool,
+		   string());
+  }
+}
+
 void pg_t::dump(Formatter *f) const
 {
   f->dump_unsigned("pool", m_pool);
@@ -537,15 +590,26 @@ void pg_t::generate_test_instances(list<pg_t*>& o)
   o.push_back(new pg_t(131223, 4, 23));
 }
 
-ostream& operator<<(ostream& out, const pg_t &pg)
+char *pg_t::calc_name(char *buf, const char *suffix_backwords) const
 {
-  out << pg.pool() << '.';
-  out << hex << pg.ps() << dec;
+  while (*suffix_backwords)
+    *--buf = *suffix_backwords++;
 
-  if (pg.preferred() >= 0)
-    out << 'p' << pg.preferred();
+  if (m_preferred >= 0)
+    *--buf ='p';
 
-  //out << "=" << hex << (__uint64_t)pg << dec;
+  buf = ritoa<uint32_t, 16>(m_seed, buf);
+
+  *--buf = '.';
+
+  return  ritoa<uint64_t, 10>(m_pool, buf);
+}
+
+ostream& operator<<(ostream& out, const pg_t &pg)
+{
+  char buf[pg_t::calc_name_buf_size];
+  buf[pg_t::calc_name_buf_size - 1] = '\0';
+  out << pg.calc_name(buf + pg_t::calc_name_buf_size - 1, "");
   return out;
 }
 
@@ -556,18 +620,16 @@ void coll_t::calc_str()
 {
   switch (type) {
   case TYPE_META:
-    _str = "meta";
+    strcpy(_str_buff, "meta");
+    _str = _str_buff;
     break;
   case TYPE_PG:
-    _str = stringify(pgid) + "_head";
+    _str_buff[spg_t::calc_name_buf_size - 1] = '\0';
+    _str = pgid.calc_name(_str_buff + spg_t::calc_name_buf_size - 1, "daeh_");
     break;
   case TYPE_PG_TEMP:
-    _str = stringify(pgid) + "_TEMP";
-    break;
-  case TYPE_PG_REMOVAL:
-    _str = string("FORREMOVAL_") +
-      stringify(removal_seq) + "_" +
-      stringify(pgid);
+    _str_buff[spg_t::calc_name_buf_size - 1] = '\0';
+    _str = pgid.calc_name(_str_buff + spg_t::calc_name_buf_size - 1, "PMET_");
     break;
   default:
     assert(0 == "unknown collection type");
@@ -600,29 +662,12 @@ bool coll_t::parse(const std::string& s)
     assert(s == _str);
     return true;
   }
-  if (s.find("FORREMOVAL_") == 0) {
-    type = TYPE_PG_REMOVAL;
-    stringstream ss(s.substr(11));
-    ss >> removal_seq;
-    char sep;
-    ss >> sep;
-    assert(sep == '_');
-    string pgid_str;
-    ss >> pgid_str;
-    if (!pgid.parse(pgid_str.c_str())) {
-      assert(0);
-      return false;
-    }
-    calc_str();
-    assert(s == _str);
-    return true;
-  }
   return false;
 }
 
 void coll_t::encode(bufferlist& bl) const
 {
-  if (is_removal() || is_temp()) {
+  if (is_temp()) {
     // can't express this as v2...
     __u8 struct_v = 3;
     ::encode(struct_v, bl);
@@ -706,8 +751,6 @@ void coll_t::generate_test_instances(list<coll_t*>& o)
   o.push_back(new coll_t(spg_t(pg_t(3, 2), shard_id_t(12))));
   o.push_back(new coll_t(o.back()->get_temp()));
   o.push_back(new coll_t());
-  o.back()->parse("FORREMOVAL_0_0.1");
-  o.back()->parse("FORREMOVAL_123_2.2a3f");
 }
 
 // ---
@@ -1790,6 +1833,9 @@ void object_stat_sum_t::dump(Formatter *f) const
 void object_stat_sum_t::encode(bufferlist& bl) const
 {
   ENCODE_START(15, 3, bl);
+#if defined(CEPH_LITTLE_ENDIAN)
+  bl.append((char *)(&num_bytes), sizeof(object_stat_sum_t));
+#else
   ::encode(num_bytes, bl);
   ::encode(num_objects, bl);
   ::encode(num_object_clones, bl);
@@ -1824,108 +1870,118 @@ void object_stat_sum_t::encode(bufferlist& bl) const
   ::encode(num_evict_mode_full, bl);
   ::encode(num_objects_pinned, bl);
   ::encode(num_objects_missing, bl);
+#endif
   ENCODE_FINISH(bl);
 }
 
 void object_stat_sum_t::decode(bufferlist::iterator& bl)
 {
+  bool decode_finish = false;
   DECODE_START_LEGACY_COMPAT_LEN(14, 3, 3, bl);
-  ::decode(num_bytes, bl);
-  if (struct_v < 3) {
-    uint64_t num_kb;
-    ::decode(num_kb, bl);
-  }
-  ::decode(num_objects, bl);
-  ::decode(num_object_clones, bl);
-  ::decode(num_object_copies, bl);
-  ::decode(num_objects_missing_on_primary, bl);
-  ::decode(num_objects_degraded, bl);
-  if (struct_v >= 2)
-    ::decode(num_objects_unfound, bl);
-  ::decode(num_rd, bl);
-  ::decode(num_rd_kb, bl);
-  ::decode(num_wr, bl);
-  ::decode(num_wr_kb, bl);
-  if (struct_v >= 4)
-    ::decode(num_scrub_errors, bl);
-  else
-    num_scrub_errors = 0;
-  if (struct_v >= 5) {
-    ::decode(num_objects_recovered, bl);
-    ::decode(num_bytes_recovered, bl);
-    ::decode(num_keys_recovered, bl);
-  } else {
-    num_objects_recovered = 0;
-    num_bytes_recovered = 0;
-    num_keys_recovered = 0;
-  }
-  if (struct_v >= 6) {
-    ::decode(num_shallow_scrub_errors, bl);
-    ::decode(num_deep_scrub_errors, bl);
-  } else {
-    num_shallow_scrub_errors = 0;
-    num_deep_scrub_errors = 0;
-  }
-  if (struct_v >= 7) {
-    ::decode(num_objects_dirty, bl);
-    ::decode(num_whiteouts, bl);
-  } else {
-    num_objects_dirty = 0;
-    num_whiteouts = 0;
-  }
-  if (struct_v >= 8) {
-    ::decode(num_objects_omap, bl);
-  } else {
-    num_objects_omap = 0;
-  }
-  if (struct_v >= 9) {
-    ::decode(num_objects_hit_set_archive, bl);
-  } else {
-    num_objects_hit_set_archive = 0;
-  }
-  if (struct_v >= 10) {
-    ::decode(num_objects_misplaced, bl);
-  } else {
-    num_objects_misplaced = 0;
-  }
-  if (struct_v >= 11) {
-    ::decode(num_bytes_hit_set_archive, bl);
-  } else {
-    num_bytes_hit_set_archive = 0;
-  }
-  if (struct_v >= 12) {
-    ::decode(num_flush, bl);
-    ::decode(num_flush_kb, bl);
-    ::decode(num_evict, bl);
-    ::decode(num_evict_kb, bl);
-    ::decode(num_promote, bl);
-  } else {
-    num_flush = 0;
-    num_flush_kb = 0;
-    num_evict = 0;
-    num_evict_kb = 0;
-    num_promote = 0;
-  }
-  if (struct_v >= 13) {
-    ::decode(num_flush_mode_high, bl);
-    ::decode(num_flush_mode_low, bl);
-    ::decode(num_evict_mode_some, bl);
-    ::decode(num_evict_mode_full, bl);
-  } else {
-    num_flush_mode_high = 0;
-    num_flush_mode_low = 0;
-    num_evict_mode_some = 0;
-    num_evict_mode_full = 0;
-  }
-  if (struct_v >= 14) {
-    ::decode(num_objects_pinned, bl);
-  } else {
-    num_objects_pinned = 0;
-  }
+#if defined(CEPH_LITTLE_ENDIAN)
   if (struct_v >= 15) {
-    ::decode(num_objects_missing, bl);
-  } else {
-    num_objects_missing = 0;
+    bl.copy(sizeof(object_stat_sum_t), (char*)(&num_bytes));
+    decode_finish = true;
+  }
+#endif
+  if (!decode_finish) {
+    ::decode(num_bytes, bl);
+    if (struct_v < 3) {
+      uint64_t num_kb;
+      ::decode(num_kb, bl);
+    }
+    ::decode(num_objects, bl);
+    ::decode(num_object_clones, bl);
+    ::decode(num_object_copies, bl);
+    ::decode(num_objects_missing_on_primary, bl);
+    ::decode(num_objects_degraded, bl);
+    if (struct_v >= 2)
+      ::decode(num_objects_unfound, bl);
+    ::decode(num_rd, bl);
+    ::decode(num_rd_kb, bl);
+    ::decode(num_wr, bl);
+    ::decode(num_wr_kb, bl);
+    if (struct_v >= 4)
+      ::decode(num_scrub_errors, bl);
+    else
+      num_scrub_errors = 0;
+    if (struct_v >= 5) {
+      ::decode(num_objects_recovered, bl);
+      ::decode(num_bytes_recovered, bl);
+      ::decode(num_keys_recovered, bl);
+    } else {
+      num_objects_recovered = 0;
+      num_bytes_recovered = 0;
+      num_keys_recovered = 0;
+    }
+    if (struct_v >= 6) {
+      ::decode(num_shallow_scrub_errors, bl);
+      ::decode(num_deep_scrub_errors, bl);
+    } else {
+      num_shallow_scrub_errors = 0;
+      num_deep_scrub_errors = 0;
+    }
+    if (struct_v >= 7) {
+      ::decode(num_objects_dirty, bl);
+      ::decode(num_whiteouts, bl);
+    } else {
+      num_objects_dirty = 0;
+      num_whiteouts = 0;
+    }
+    if (struct_v >= 8) {
+      ::decode(num_objects_omap, bl);
+    } else {
+      num_objects_omap = 0;
+    }
+    if (struct_v >= 9) {
+      ::decode(num_objects_hit_set_archive, bl);
+    } else {
+      num_objects_hit_set_archive = 0;
+    }
+    if (struct_v >= 10) {
+      ::decode(num_objects_misplaced, bl);
+    } else {
+      num_objects_misplaced = 0;
+    }
+    if (struct_v >= 11) {
+      ::decode(num_bytes_hit_set_archive, bl);
+    } else {
+      num_bytes_hit_set_archive = 0;
+    }
+    if (struct_v >= 12) {
+      ::decode(num_flush, bl);
+      ::decode(num_flush_kb, bl);
+      ::decode(num_evict, bl);
+      ::decode(num_evict_kb, bl);
+      ::decode(num_promote, bl);
+    } else {
+      num_flush = 0;
+      num_flush_kb = 0;
+      num_evict = 0;
+      num_evict_kb = 0;
+      num_promote = 0;
+    }
+    if (struct_v >= 13) {
+      ::decode(num_flush_mode_high, bl);
+      ::decode(num_flush_mode_low, bl);
+      ::decode(num_evict_mode_some, bl);
+      ::decode(num_evict_mode_full, bl);
+    } else {
+      num_flush_mode_high = 0;
+      num_flush_mode_low = 0;
+      num_evict_mode_some = 0;
+      num_evict_mode_full = 0;
+    }
+    if (struct_v >= 14) {
+      ::decode(num_objects_pinned, bl);
+    } else {
+      num_objects_pinned = 0;
+    }
+    if (struct_v >= 15) {
+      ::decode(num_objects_missing, bl);
+    } else {
+      num_objects_missing = 0;
+    }
   }
   DECODE_FINISH(bl);
 }
@@ -5277,7 +5333,7 @@ void ScrubMap::generate_test_instances(list<ScrubMap*>& o)
 
 void ScrubMap::object::encode(bufferlist& bl) const
 {
-  ENCODE_START(6, 2, bl);
+  ENCODE_START(7, 2, bl);
   ::encode(size, bl);
   ::encode(negative, bl);
   ::encode(attrs, bl);
@@ -5288,12 +5344,13 @@ void ScrubMap::object::encode(bufferlist& bl) const
   ::encode(omap_digest, bl);
   ::encode(omap_digest_present, bl);
   ::encode(read_error, bl);
+  ::encode(stat_error, bl);
   ENCODE_FINISH(bl);
 }
 
 void ScrubMap::object::decode(bufferlist::iterator& bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(5, 2, 2, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(7, 2, 2, bl);
   ::decode(size, bl);
   bool tmp;
   ::decode(tmp, bl);
@@ -5321,6 +5378,10 @@ void ScrubMap::object::decode(bufferlist::iterator& bl)
     ::decode(tmp, bl);
     read_error = tmp;
   }
+  if (struct_v >= 7) {
+    ::decode(tmp, bl);
+    stat_error = tmp;
+  }
   DECODE_FINISH(bl);
 }
 
diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h
index cb71218..1134ffd 100644
--- a/src/osd/osd_types.h
+++ b/src/osd/osd_types.h
@@ -33,6 +33,7 @@
 #include "include/CompatSet.h"
 #include "common/histogram.h"
 #include "include/interval_set.h"
+#include "include/inline_memory.h"
 #include "common/Formatter.h"
 #include "common/bloom_filter.hpp"
 #include "common/hobject.h"
@@ -328,6 +329,9 @@ struct pg_t {
     return m_preferred;
   }
 
+  static const uint8_t calc_name_buf_size = 36;  // max length for max values len("18446744073709551615.ffffffff") + future suffix len("_head") + '\0'
+  char *calc_name(char *buf, const char *suffix_backwords) const;
+
   void set_ps(ps_t p) {
     m_seed = p;
   }
@@ -356,6 +360,9 @@ struct pg_t {
     return oid.match(bits, ps());
   }
 
+  hobject_t get_hobj_start() const;
+  hobject_t get_hobj_end(unsigned pg_num) const;
+
   void encode(bufferlist& bl) const {
     __u8 v = 1;
     ::encode(v, bl);
@@ -445,6 +452,10 @@ struct spg_t {
   int32_t preferred() const {
     return pgid.preferred();
   }
+
+  static const uint8_t calc_name_buf_size = pg_t::calc_name_buf_size + 4; // 36 + len('s') + len("255");
+  char *calc_name(char *buf, const char *suffix_backwords) const;
+ 
   bool parse(const char *s);
   bool parse(const std::string& s) {
     return parse(s.c_str());
@@ -515,13 +526,13 @@ class coll_t {
     TYPE_LEGACY_TEMP = 1,  /* no longer used */
     TYPE_PG = 2,
     TYPE_PG_TEMP = 3,
-    TYPE_PG_REMOVAL = 4,   /* note: deprecated, not encoded */
   };
   type_t type;
   spg_t pgid;
   uint64_t removal_seq;  // note: deprecated, not encoded
 
-  string _str;  // cached string
+  char _str_buff[spg_t::calc_name_buf_size];
+  char *_str;
 
   void calc_str();
 
@@ -547,6 +558,15 @@ public:
     calc_str();
   }
 
+  coll_t& operator=(const coll_t& rhs)
+  {
+    this->type = rhs.type;
+    this->pgid = rhs.pgid;
+    this->removal_seq = rhs.removal_seq;
+    this->calc_str();
+    return *this;
+  }
+
   // named constructors
   static coll_t meta() {
     return coll_t();
@@ -555,12 +575,13 @@ public:
     return coll_t(p);
   }
 
-  const std::string& to_str() const {
-    return _str;
+  const std::string to_str() const {
+    return string(_str);
   }
   const char *c_str() const {
-    return _str.c_str();
+    return _str;
   }
+
   bool parse(const std::string& s);
 
   int operator<(const coll_t &rhs) const {
@@ -572,7 +593,7 @@ public:
     return type == TYPE_META;
   }
   bool is_pg_prefix(spg_t *pgid_) const {
-    if (type == TYPE_PG || type == TYPE_PG_TEMP || type == TYPE_PG_REMOVAL) {
+    if (type == TYPE_PG || type == TYPE_PG_TEMP) {
       *pgid_ = pgid;
       return true;
     }
@@ -598,16 +619,6 @@ public:
     }
     return false;
   }
-  bool is_removal() const {
-    return type == TYPE_PG_REMOVAL;
-  }
-  bool is_removal(spg_t *pgid_) const {
-    if (type == TYPE_PG_REMOVAL) {
-      *pgid_ = pgid;
-      return true;
-    }
-    return false;
-  }
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& bl);
@@ -631,6 +642,22 @@ public:
     return coll_t(TYPE_PG_TEMP, pgid, 0);
   }
 
+  ghobject_t get_min_hobj() const {
+    ghobject_t o;
+    switch (type) {
+    case TYPE_PG:
+      o.hobj.pool = pgid.pool();
+      o.set_shard(pgid.shard);
+      break;
+    case TYPE_META:
+      o.hobj.pool = -1;
+      break;
+    default:
+      break;
+    }
+    return o;
+  }
+
   void dump(Formatter *f) const;
   static void generate_test_instances(list<coll_t*>& o);
 };
@@ -673,6 +700,10 @@ inline ostream& operator<<(ostream& out, const ceph_object_layout &ol)
 
 
 // compound rados version type
+/* WARNING: If add member in eversion_t, please make sure the encode/decode function
+ * work well. For little-endian machine, we should make sure there is no padding
+ * in 32-bit machine and 64-bit machine.
+ */
 class eversion_t {
 public:
   version_t version;
@@ -705,12 +736,20 @@ public:
   string get_key_name() const;
 
   void encode(bufferlist &bl) const {
+#if defined(CEPH_LITTLE_ENDIAN)
+    bl.append((char *)this, sizeof(version_t) + sizeof(epoch_t));
+#else
     ::encode(version, bl);
     ::encode(epoch, bl);
+#endif
   }
   void decode(bufferlist::iterator &bl) {
+#if defined(CEPH_LITTLE_ENDIAN)
+    bl.copy(sizeof(version_t) + sizeof(epoch_t), (char *)this);
+#else
     ::decode(version, bl);
     ::decode(epoch, bl);
+#endif
   }
   void decode(bufferlist& bl) {
     bufferlist::iterator p = bl.begin();
@@ -1435,6 +1474,11 @@ ostream& operator<<(ostream& out, const pg_pool_t& p);
  * a summation of object stats
  *
  * This is just a container for object stats; we don't know what for.
+ *
+ * If you add members in object_stat_sum_t, you should make sure there are
+ * not padding among these members.
+ * You should also modify the padding_check function.
+
  */
 struct object_stat_sum_t {
   /**************************************************************************
@@ -1446,24 +1490,23 @@ struct object_stat_sum_t {
   int64_t num_object_clones;
   int64_t num_object_copies;  // num_objects * num_replicas
   int64_t num_objects_missing_on_primary;
-  int64_t num_objects_missing;
   int64_t num_objects_degraded;
-  int64_t num_objects_misplaced;
   int64_t num_objects_unfound;
   int64_t num_rd;
   int64_t num_rd_kb;
   int64_t num_wr;
   int64_t num_wr_kb;
   int64_t num_scrub_errors;	// total deep and shallow scrub errors
-  int64_t num_shallow_scrub_errors;
-  int64_t num_deep_scrub_errors;
   int64_t num_objects_recovered;
   int64_t num_bytes_recovered;
   int64_t num_keys_recovered;
+  int64_t num_shallow_scrub_errors;
+  int64_t num_deep_scrub_errors;
   int64_t num_objects_dirty;
   int64_t num_whiteouts;
   int64_t num_objects_omap;
   int64_t num_objects_hit_set_archive;
+  int64_t num_objects_misplaced;
   int64_t num_bytes_hit_set_archive;
   int64_t num_flush;
   int64_t num_flush_kb;
@@ -1475,24 +1518,25 @@ struct object_stat_sum_t {
   int32_t num_evict_mode_some;  // 1 when in evict some mode, otherwise 0
   int32_t num_evict_mode_full;  // 1 when in evict full mode, otherwise 0
   int64_t num_objects_pinned;
+  int64_t num_objects_missing;
 
   object_stat_sum_t()
     : num_bytes(0),
       num_objects(0), num_object_clones(0), num_object_copies(0),
-      num_objects_missing_on_primary(0), num_objects_missing(0),
-      num_objects_degraded(0),
-      num_objects_misplaced(0),
+      num_objects_missing_on_primary(0), num_objects_degraded(0),
       num_objects_unfound(0),
       num_rd(0), num_rd_kb(0), num_wr(0), num_wr_kb(0),
-      num_scrub_errors(0), num_shallow_scrub_errors(0),
-      num_deep_scrub_errors(0),
+      num_scrub_errors(0),
       num_objects_recovered(0),
       num_bytes_recovered(0),
       num_keys_recovered(0),
+      num_shallow_scrub_errors(0),
+      num_deep_scrub_errors(0),
       num_objects_dirty(0),
       num_whiteouts(0),
       num_objects_omap(0),
       num_objects_hit_set_archive(0),
+      num_objects_misplaced(0),
       num_bytes_hit_set_archive(0),
       num_flush(0),
       num_flush_kb(0),
@@ -1501,7 +1545,8 @@ struct object_stat_sum_t {
       num_promote(0),
       num_flush_mode_high(0), num_flush_mode_low(0),
       num_evict_mode_some(0), num_evict_mode_full(0),
-      num_objects_pinned(0)
+      num_objects_pinned(0),
+      num_objects_missing(0)
   {}
 
   void floor(int64_t f) {
@@ -1598,14 +1643,53 @@ struct object_stat_sum_t {
   }
 
   bool is_zero() const {
-    object_stat_sum_t zero;
-    return memcmp(this, &zero, sizeof(zero)) == 0;
+    return mem_is_zero((char*)this, sizeof(*this));
   }
 
   void add(const object_stat_sum_t& o);
   void sub(const object_stat_sum_t& o);
 
   void dump(Formatter *f) const;
+  void padding_check() {
+    static_assert(
+      sizeof(object_stat_sum_t) ==
+        sizeof(num_bytes) +
+        sizeof(num_objects) +
+        sizeof(num_object_clones) +
+        sizeof(num_object_copies) +
+        sizeof(num_objects_missing_on_primary) +
+        sizeof(num_objects_degraded) +
+        sizeof(num_objects_unfound) +
+        sizeof(num_rd) +
+        sizeof(num_rd_kb) +
+        sizeof(num_wr) +
+        sizeof(num_wr_kb) +
+        sizeof(num_scrub_errors) +
+        sizeof(num_objects_recovered) +
+        sizeof(num_bytes_recovered) +
+        sizeof(num_keys_recovered) +
+        sizeof(num_shallow_scrub_errors) +
+        sizeof(num_deep_scrub_errors) +
+        sizeof(num_objects_dirty) +
+        sizeof(num_whiteouts) +
+        sizeof(num_objects_omap) +
+        sizeof(num_objects_hit_set_archive) +
+        sizeof(num_objects_misplaced) +
+        sizeof(num_bytes_hit_set_archive) +
+        sizeof(num_flush) +
+        sizeof(num_flush_kb) +
+        sizeof(num_evict) +
+        sizeof(num_evict_kb) +
+        sizeof(num_promote) +
+        sizeof(num_flush_mode_high) +
+        sizeof(num_flush_mode_low) +
+        sizeof(num_evict_mode_some) +
+        sizeof(num_evict_mode_full) +
+        sizeof(num_objects_pinned) +
+        sizeof(num_objects_missing)
+      ,
+      "object_stat_sum_t have padding");
+  }
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& bl);
   static void generate_test_instances(list<object_stat_sum_t*>& o);
@@ -3784,12 +3868,13 @@ struct ScrubMap {
     bool digest_present:1;
     bool omap_digest_present:1;
     bool read_error:1;
+    bool stat_error:1;
 
     object() :
       // Init invalid size so it won't match if we get a stat EIO error
       size(-1), omap_digest(0), digest(0), nlinks(0), 
       negative(false), digest_present(false), omap_digest_present(false), 
-      read_error(false) {}
+      read_error(false), stat_error(false) {}
 
     void encode(bufferlist& bl) const;
     void decode(bufferlist::iterator& bl);
diff --git a/src/osdc/Filer.cc b/src/osdc/Filer.cc
index 5c8a13d..0a9d6e9 100644
--- a/src/osdc/Filer.cc
+++ b/src/osdc/Filer.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -38,8 +38,9 @@ public:
   Probe *probe;
   object_t oid;
   uint64_t size;
-  utime_t mtime;
-  C_Probe(Filer *f, Probe *p, object_t o) : filer(f), probe(p), oid(o), size(0) {}
+  ceph::real_time mtime;
+  C_Probe(Filer *f, Probe *p, object_t o) : filer(f), probe(p), oid(o),
+					    size(0) {}
   void finish(int r) {
     if (r == -ENOENT) {
       r = 0;
@@ -50,7 +51,7 @@ public:
     {
       probe->lock.Lock();
       if (r != 0) {
-        probe->err = r;
+	probe->err = r;
       }
 
       probe_complete = filer->_probed(probe, oid, size, mtime);
@@ -60,18 +61,41 @@ public:
       probe->onfinish->complete(probe->err);
       delete probe;
     }
-  }  
+  }
 };
 
 int Filer::probe(inodeno_t ino,
 		 ceph_file_layout *layout,
 		 snapid_t snapid,
 		 uint64_t start_from,
-		 uint64_t *end,           // LB, when !fwd
+		 uint64_t *end, // LB, when !fwd
+		 ceph::real_time *pmtime,
+		 bool fwd,
+		 int flags,
+		 Context *onfinish)
+{
+  ldout(cct, 10) << "probe " << (fwd ? "fwd ":"bwd ")
+	   << hex << ino << dec
+	   << " starting from " << start_from
+	   << dendl;
+
+  assert(snapid);  // (until there is a non-NOSNAP write)
+
+  Probe *probe = new Probe(ino, *layout, snapid, start_from, end, pmtime,
+			   flags, fwd, onfinish);
+
+  return probe_impl(probe, layout, start_from, end);
+}
+
+int Filer::probe(inodeno_t ino,
+		 ceph_file_layout *layout,
+		 snapid_t snapid,
+		 uint64_t start_from,
+		 uint64_t *end, // LB, when !fwd
 		 utime_t *pmtime,
 		 bool fwd,
 		 int flags,
-		 Context *onfinish) 
+		 Context *onfinish)
 {
   ldout(cct, 10) << "probe " << (fwd ? "fwd ":"bwd ")
 	   << hex << ino << dec
@@ -80,11 +104,18 @@ int Filer::probe(inodeno_t ino,
 
   assert(snapid);  // (until there is a non-NOSNAP write)
 
-  Probe *probe = new Probe(ino, *layout, snapid, start_from, end, pmtime, flags, fwd, onfinish);
-  
+  Probe *probe = new Probe(ino, *layout, snapid, start_from, end, pmtime,
+			   flags, fwd, onfinish);
+  return probe_impl(probe, layout, start_from, end);
+}
+
+int Filer::probe_impl(Probe* probe, ceph_file_layout *layout,
+		      uint64_t start_from, uint64_t *end) // LB, when !fwd
+{
   // period (bytes before we jump unto a new set of object(s))
-  uint64_t period = (uint64_t)layout->fl_stripe_count * (uint64_t)layout->fl_object_size;
-  
+  uint64_t period = (uint64_t)layout->fl_stripe_count *
+    (uint64_t)layout->fl_object_size;
+
   // start with 1+ periods.
   probe->probing_len = period;
   if (probe->fwd) {
@@ -96,7 +127,7 @@ int Filer::probe(inodeno_t ino,
       probe->probing_len -= period - (start_from % period);
     probe->probing_off -= probe->probing_len;
   }
-  
+
   probe->lock.Lock();
   _probe(probe);
   assert(!probe->lock.is_locked_by_me());
@@ -105,6 +136,7 @@ int Filer::probe(inodeno_t ino,
 }
 
 
+
 /**
  * probe->lock must be initially locked, this function will release it
  */
@@ -112,16 +144,16 @@ void Filer::_probe(Probe *probe)
 {
   assert(probe->lock.is_locked_by_me());
 
-  ldout(cct, 10) << "_probe " << hex << probe->ino << dec 
-	   << " " << probe->probing_off << "~" << probe->probing_len 
-	   << dendl;
-  
+  ldout(cct, 10) << "_probe " << hex << probe->ino << dec
+		 << " " << probe->probing_off << "~" << probe->probing_len
+		 << dendl;
+
   // map range onto objects
   probe->known_size.clear();
   probe->probing.clear();
-  Striper::file_to_extents(cct, probe->ino, &probe->layout,
-			   probe->probing_off, probe->probing_len, 0, probe->probing);
-  
+  Striper::file_to_extents(cct, probe->ino, &probe->layout, probe->probing_off,
+			   probe->probing_len, 0, probe->probing);
+
   std::vector<ObjectExtent> stat_extents;
   for (vector<ObjectExtent>::iterator p = probe->probing.begin();
        p != probe->probing.end();
@@ -133,7 +165,7 @@ void Filer::_probe(Probe *probe)
 
   probe->lock.Unlock();
   for (std::vector<ObjectExtent>::iterator i = stat_extents.begin();
-      i != stat_extents.end(); ++i) {
+       i != stat_extents.end(); ++i) {
     C_Probe *c = new C_Probe(this, probe, i->oid);
     objecter->stat(i->oid, i->oloc, probe->snapid, &c->size, &c->mtime,
 		   probe->flags | CEPH_OSD_FLAG_RWORDERED,
@@ -146,7 +178,8 @@ void Filer::_probe(Probe *probe)
  *
  * @return true if probe is complete and Probe object may be freed.
  */
-bool Filer::_probed(Probe *probe, const object_t& oid, uint64_t size, utime_t mtime)
+bool Filer::_probed(Probe *probe, const object_t& oid, uint64_t size,
+		    ceph::real_time mtime)
 {
   assert(probe->lock.is_locked_by_me());
 
@@ -187,35 +220,39 @@ bool Filer::_probed(Probe *probe, const object_t& oid, uint64_t size, utime_t mt
        p != probe->probing.end();
        ++p) {
     uint64_t shouldbe = p->length + p->offset;
-    ldout(cct, 10) << "_probed  " << probe->ino << " object " << hex << p->oid << dec
-	     << " should be " << shouldbe
-	     << ", actual is " << probe->known_size[p->oid]
-	     << dendl;
+    ldout(cct, 10) << "_probed  " << probe->ino << " object " << hex
+		   << p->oid << dec << " should be " << shouldbe
+		   << ", actual is " << probe->known_size[p->oid]
+		   << dendl;
 
     if (!probe->found_size) {
       assert(probe->known_size[p->oid] <= shouldbe);
 
       if ((probe->fwd && probe->known_size[p->oid] == shouldbe) ||
-	  (!probe->fwd && probe->known_size[p->oid] == 0 && probe->probing_off > 0))
+	  (!probe->fwd && probe->known_size[p->oid] == 0 &&
+	   probe->probing_off > 0))
 	continue;  // keep going
-      
+
       // aha, we found the end!
       // calc offset into buffer_extent to get distance from probe->from.
       uint64_t oleft = probe->known_size[p->oid] - p->offset;
-      for (vector<pair<uint64_t, uint64_t> >::iterator i = p->buffer_extents.begin();
+      for (vector<pair<uint64_t, uint64_t> >::iterator i
+	     = p->buffer_extents.begin();
 	   i != p->buffer_extents.end();
 	   ++i) {
 	if (oleft <= (uint64_t)i->second) {
 	  end = probe->probing_off + i->first + oleft;
-	  ldout(cct, 10) << "_probed  end is in buffer_extent " << i->first << "~" << i->second << " off " << oleft 
-		   << ", from was " << probe->probing_off << ", end is " << end 
-		   << dendl;
-	  
+	  ldout(cct, 10) << "_probed  end is in buffer_extent " << i->first
+			 << "~" << i->second << " off " << oleft
+			 << ", from was " << probe->probing_off << ", end is "
+			 << end << dendl;
+
 	  probe->found_size = true;
 	  ldout(cct, 10) << "_probed found size at " << end << dendl;
 	  *probe->psize = end;
-	  
-	  if (!probe->pmtime)  // stop if we don't need mtime too
+
+	  if (!probe->pmtime &&
+	      !probe->pumtime)  // stop if we don't need mtime too
 	    break;
 	}
 	oleft -= i->second;
@@ -224,11 +261,13 @@ bool Filer::_probed(Probe *probe, const object_t& oid, uint64_t size, utime_t mt
     break;
   }
 
-  if (!probe->found_size || (probe->probing_off && probe->pmtime)) {
+  if (!probe->found_size || (probe->probing_off && (probe->pmtime ||
+						    probe->pumtime))) {
     // keep probing!
     ldout(cct, 10) << "_probed probing further" << dendl;
 
-    uint64_t period = (uint64_t)probe->layout.fl_stripe_count * (uint64_t)probe->layout.fl_object_size;
+    uint64_t period = (uint64_t)probe->layout.fl_stripe_count *
+      (uint64_t)probe->layout.fl_object_size;
     if (probe->fwd) {
       probe->probing_off += probe->probing_len;
       assert(probe->probing_off % period == 0);
@@ -245,8 +284,10 @@ bool Filer::_probed(Probe *probe, const object_t& oid, uint64_t size, utime_t mt
   } else if (probe->pmtime) {
     ldout(cct, 10) << "_probed found mtime " << probe->max_mtime << dendl;
     *probe->pmtime = probe->max_mtime;
+  } else if (probe->pumtime) {
+    ldout(cct, 10) << "_probed found mtime " << probe->max_mtime << dendl;
+    *probe->pumtime = ceph::real_clock::to_ceph_timespec(probe->max_mtime);
   }
-
   // done!
   probe->lock.Unlock();
   return true;
@@ -261,24 +302,25 @@ struct PurgeRange {
   ceph_file_layout layout;
   SnapContext snapc;
   uint64_t first, num;
-  utime_t mtime;
+  ceph::real_time mtime;
   int flags;
   Context *oncommit;
   int uncommitted;
   PurgeRange(inodeno_t i, ceph_file_layout& l, const SnapContext& sc,
-	     uint64_t fo, uint64_t no, utime_t t, int fl, Context *fin) :
-	  lock("Filer::PurgeRange"), ino(i), layout(l), snapc(sc),
-	  first(fo), num(no), mtime(t), flags(fl), oncommit(fin),
-	  uncommitted(0) {}
+	     uint64_t fo, uint64_t no, ceph::real_time t, int fl,
+	     Context *fin)
+    : lock("Filer::PurgeRange"), ino(i), layout(l), snapc(sc),
+      first(fo), num(no), mtime(t), flags(fl), oncommit(fin),
+      uncommitted(0) {}
 };
 
 int Filer::purge_range(inodeno_t ino,
 		       ceph_file_layout *layout,
 		       const SnapContext& snapc,
 		       uint64_t first_obj, uint64_t num_obj,
-		       utime_t mtime,
+		       ceph::real_time mtime,
 		       int flags,
-		       Context *oncommit) 
+		       Context *oncommit)
 {
   assert(num_obj > 0);
 
@@ -312,8 +354,9 @@ void Filer::_do_purge_range(PurgeRange *pr, int fin)
 {
   pr->lock.Lock();
   pr->uncommitted -= fin;
-  ldout(cct, 10) << "_do_purge_range " << pr->ino << " objects " << pr->first << "~" << pr->num
-	   << " uncommitted " << pr->uncommitted << dendl;
+  ldout(cct, 10) << "_do_purge_range " << pr->ino << " objects " << pr->first
+		 << "~" << pr->num << " uncommitted " << pr->uncommitted
+		 << dendl;
 
   if (pr->num == 0 && pr->uncommitted == 0) {
     pr->oncommit->complete(0);
@@ -345,5 +388,3 @@ void Filer::_do_purge_range(PurgeRange *pr, int fin)
 		     new C_OnFinisher(new C_PurgeRange(this, pr), finisher));
   }
 }
-
-
diff --git a/src/osdc/Filer.h b/src/osdc/Filer.h
index 26a9204..c2359c7 100644
--- a/src/osdc/Filer.h
+++ b/src/osdc/Filer.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 
@@ -23,11 +23,14 @@
  *
  * also, provide convenience methods that call objecter for you.
  *
- * "files" are identified by ino. 
+ * "files" are identified by ino.
  */
 
+
 #include "include/types.h"
 
+#include "common/ceph_time.h"
+
 #include "osd/OSDMap.h"
 #include "Objecter.h"
 #include "Striper.h"
@@ -44,7 +47,7 @@ class Filer {
   CephContext *cct;
   Objecter   *objecter;
   Finisher   *finisher;
-  
+
   // probes
   struct Probe {
     Mutex lock;
@@ -53,19 +56,20 @@ class Filer {
     snapid_t snapid;
 
     uint64_t *psize;
-    utime_t *pmtime;
+    ceph::real_time *pmtime;
+    utime_t *pumtime;
 
     int flags;
 
     bool fwd;
 
     Context *onfinish;
-    
+
     vector<ObjectExtent> probing;
     uint64_t probing_off, probing_len;
-    
+
     map<object_t, uint64_t> known_size;
-    utime_t max_mtime;
+    ceph::real_time max_mtime;
 
     set<object_t> ops;
 
@@ -73,17 +77,27 @@ class Filer {
     bool found_size;
 
     Probe(inodeno_t i, ceph_file_layout &l, snapid_t sn,
-	  uint64_t f, uint64_t *e, utime_t *m, int fl, bool fw, Context *c) : 
+	  uint64_t f, uint64_t *e, ceph::real_time *m, int fl, bool fw,
+	  Context *c) :
       lock("Filer::Probe"), ino(i), layout(l), snapid(sn),
-      psize(e), pmtime(m), flags(fl), fwd(fw), onfinish(c),
+      psize(e), pmtime(m), pumtime(nullptr), flags(fl), fwd(fw), onfinish(c),
       probing_off(f), probing_len(0),
       err(0), found_size(false) {}
+
+    Probe(inodeno_t i, ceph_file_layout &l, snapid_t sn,
+	  uint64_t f, uint64_t *e, utime_t *m, int fl, bool fw,
+	  Context *c) :
+      lock("Filer::Probe"), ino(i), layout(l), snapid(sn),
+      psize(e), pmtime(nullptr), pumtime(m), flags(fl), fwd(fw),
+      onfinish(c), probing_off(f), probing_len(0),
+      err(0), found_size(false) {}
   };
-  
+
   class C_Probe;
 
   void _probe(Probe *p);
-  bool _probed(Probe *p, const object_t& oid, uint64_t size, utime_t mtime);
+  bool _probed(Probe *p, const object_t& oid, uint64_t size,
+	       ceph::real_time mtime);
 
  public:
   Filer(const Filer& other);
@@ -102,11 +116,11 @@ class Filer {
   int read(inodeno_t ino,
 	   ceph_file_layout *layout,
 	   snapid_t snap,
-           uint64_t offset, 
-           uint64_t len, 
-           bufferlist *bl,   // ptr to data
+	   uint64_t offset,
+	   uint64_t len,
+	   bufferlist *bl,   // ptr to data
 	   int flags,
-           Context *onfinish,
+	   Context *onfinish,
 	   int op_flags = 0) {
     assert(snap);  // (until there is a non-NOSNAP write)
     vector<ObjectExtent> extents;
@@ -116,19 +130,20 @@ class Filer {
   }
 
   int read_trunc(inodeno_t ino,
-	   ceph_file_layout *layout,
-	   snapid_t snap,
-           uint64_t offset, 
-           uint64_t len, 
-           bufferlist *bl,   // ptr to data
-	   int flags,
-	   uint64_t truncate_size,
-	   __u32 truncate_seq,
-           Context *onfinish,
-	   int op_flags = 0) {
+		 ceph_file_layout *layout,
+		 snapid_t snap,
+		 uint64_t offset,
+		 uint64_t len,
+		 bufferlist *bl, // ptr to data
+		 int flags,
+		 uint64_t truncate_size,
+		 __u32 truncate_seq,
+		 Context *onfinish,
+		 int op_flags = 0) {
     assert(snap);  // (until there is a non-NOSNAP write)
     vector<ObjectExtent> extents;
-    Striper::file_to_extents(cct, ino, layout, offset, len, truncate_size, extents);
+    Striper::file_to_extents(cct, ino, layout, offset, len, truncate_size,
+			     extents);
     objecter->sg_read_trunc(extents, snap, bl, flags,
 			    truncate_size, truncate_seq, onfinish, op_flags);
     return 0;
@@ -137,35 +152,37 @@ class Filer {
   int write(inodeno_t ino,
 	    ceph_file_layout *layout,
 	    const SnapContext& snapc,
-	    uint64_t offset, 
-            uint64_t len, 
-            bufferlist& bl,
-	    utime_t mtime,
-            int flags, 
-            Context *onack,
-            Context *oncommit,
+	    uint64_t offset,
+	    uint64_t len,
+	    bufferlist& bl,
+	    ceph::real_time mtime,
+	    int flags,
+	    Context *onack,
+	    Context *oncommit,
 	    int op_flags = 0) {
     vector<ObjectExtent> extents;
     Striper::file_to_extents(cct, ino, layout, offset, len, 0, extents);
-    objecter->sg_write(extents, snapc, bl, mtime, flags, onack, oncommit, op_flags);
+    objecter->sg_write(extents, snapc, bl, mtime, flags, onack, oncommit,
+		       op_flags);
     return 0;
   }
 
   int write_trunc(inodeno_t ino,
-	    ceph_file_layout *layout,
-	    const SnapContext& snapc,
-	    uint64_t offset, 
-            uint64_t len, 
-            bufferlist& bl,
-	    utime_t mtime,
-            int flags, 
-	   uint64_t truncate_size,
-	   __u32 truncate_seq,
-            Context *onack,
-            Context *oncommit,
-	    int op_flags = 0) {
+		  ceph_file_layout *layout,
+		  const SnapContext& snapc,
+		  uint64_t offset,
+		  uint64_t len,
+		  bufferlist& bl,
+		  ceph::real_time mtime,
+		  int flags,
+		  uint64_t truncate_size,
+		  __u32 truncate_seq,
+		  Context *onack,
+		  Context *oncommit,
+		  int op_flags = 0) {
     vector<ObjectExtent> extents;
-    Striper::file_to_extents(cct, ino, layout, offset, len, truncate_size, extents);
+    Striper::file_to_extents(cct, ino, layout, offset, len, truncate_size,
+			     extents);
     objecter->sg_write_trunc(extents, snapc, bl, mtime, flags,
 		       truncate_size, truncate_seq, onack, oncommit, op_flags);
     return 0;
@@ -177,7 +194,7 @@ class Filer {
 	       uint64_t offset,
 	       uint64_t len,
 	       __u32 truncate_seq,
-	       utime_t mtime,
+	       ceph::real_time mtime,
 	       int flags,
 	       Context *onack,
 	       Context *oncommit) {
@@ -188,11 +205,14 @@ class Filer {
       ops[0].op.op = CEPH_OSD_OP_TRIMTRUNC;
       ops[0].op.extent.truncate_seq = truncate_seq;
       ops[0].op.extent.truncate_size = extents[0].offset;
-      objecter->_modify(extents[0].oid, extents[0].oloc, ops, mtime, snapc, flags, onack, oncommit);
+      objecter->_modify(extents[0].oid, extents[0].oloc, ops, mtime, snapc,
+			flags, onack, oncommit);
     } else {
       C_GatherBuilder gack(cct, onack);
       C_GatherBuilder gcom(cct, oncommit);
-      for (vector<ObjectExtent>::iterator p = extents.begin(); p != extents.end(); ++p) {
+      for (vector<ObjectExtent>::iterator p = extents.begin();
+	   p != extents.end();
+	   ++p) {
 	vector<OSDOp> ops(1);
 	ops[0].op.op = CEPH_OSD_OP_TRIMTRUNC;
 	ops[0].op.extent.truncate_size = p->offset;
@@ -211,26 +231,29 @@ class Filer {
 	   ceph_file_layout *layout,
 	   const SnapContext& snapc,
 	   uint64_t offset,
-           uint64_t len,
-	   utime_t mtime,
+	   uint64_t len,
+	   ceph::real_time mtime,
 	   int flags,
 	   bool keep_first,
-           Context *onack,
-           Context *oncommit) {
+	   Context *onack,
+	   Context *oncommit) {
     vector<ObjectExtent> extents;
     Striper::file_to_extents(cct, ino, layout, offset, len, 0, extents);
     if (extents.size() == 1) {
-      if (extents[0].offset == 0 && extents[0].length == layout->fl_object_size &&
-	  (!keep_first || extents[0].objectno != 0))
-	objecter->remove(extents[0].oid, extents[0].oloc, 
+      if (extents[0].offset == 0 && extents[0].length == layout->fl_object_size
+	  && (!keep_first || extents[0].objectno != 0))
+	objecter->remove(extents[0].oid, extents[0].oloc,
 			 snapc, mtime, flags, onack, oncommit);
       else
-	objecter->zero(extents[0].oid, extents[0].oloc, extents[0].offset, extents[0].length, 
-		       snapc, mtime, flags, onack, oncommit);
+	objecter->zero(extents[0].oid, extents[0].oloc, extents[0].offset,
+		       extents[0].length, snapc, mtime, flags, onack,
+		       oncommit);
     } else {
       C_GatherBuilder gack(cct, onack);
       C_GatherBuilder gcom(cct, oncommit);
-      for (vector<ObjectExtent>::iterator p = extents.begin(); p != extents.end(); ++p) {
+      for (vector<ObjectExtent>::iterator p = extents.begin();
+	   p != extents.end();
+	   ++p) {
 	if (p->offset == 0 && p->length == layout->fl_object_size &&
 	    (!keep_first || p->objectno != 0))
 	  objecter->remove(p->oid, p->oloc,
@@ -238,7 +261,7 @@ class Filer {
 			   onack ? gack.new_sub():0,
 			   oncommit ? gcom.new_sub():0);
 	else
-	  objecter->zero(p->oid, p->oloc, p->offset, p->length, 
+	  objecter->zero(p->oid, p->oloc, p->offset, p->length,
 			 snapc, mtime, flags,
 			 onack ? gack.new_sub():0,
 			 oncommit ? gcom.new_sub():0);
@@ -253,30 +276,29 @@ class Filer {
 	   ceph_file_layout *layout,
 	   const SnapContext& snapc,
 	   uint64_t offset,
-           uint64_t len,
-	   utime_t mtime,
+	   uint64_t len,
+	   ceph::real_time mtime,
 	   int flags,
-           Context *onack,
-           Context *oncommit) {
+	   Context *onack,
+	   Context *oncommit) {
 
     return zero(ino, layout,
-                snapc, offset,
-                len, mtime,
-                flags, false,
-                onack, oncommit);
+		snapc, offset,
+		len, mtime,
+		flags, false,
+		onack, oncommit);
   }
   // purge range of ino.### objects
   int purge_range(inodeno_t ino,
 		  ceph_file_layout *layout,
 		  const SnapContext& snapc,
 		  uint64_t first_obj, uint64_t num_obj,
-		  utime_t mtime,
-		  int flags,
-		  Context *oncommit);
+		  ceph::real_time mtime,
+		  int flags, Context *oncommit);
   void _do_purge_range(struct PurgeRange *pr, int fin);
 
   /*
-   * probe 
+   * probe
    *  specify direction,
    *  and whether we stop when we find data, or hole.
    */
@@ -285,12 +307,36 @@ class Filer {
 	    snapid_t snapid,
 	    uint64_t start_from,
 	    uint64_t *end,
-	    utime_t *mtime,
+	    ceph::real_time *mtime,
 	    bool fwd,
 	    int flags,
 	    Context *onfinish);
-};
 
+  int probe(inodeno_t ino,
+	    ceph_file_layout *layout,
+	    snapid_t snapid,
+	    uint64_t start_from,
+	    uint64_t *end,
+	    bool fwd,
+	    int flags,
+	    Context *onfinish) {
+    return probe(ino, layout, snapid, start_from, end,
+		 (ceph::real_time* )0, fwd, flags, onfinish);
+  }
+
+  int probe(inodeno_t ino,
+	    ceph_file_layout *layout,
+	    snapid_t snapid,
+	    uint64_t start_from,
+	    uint64_t *end,
+	    utime_t *mtime,
+	    bool fwd,
+	    int flags,
+	    Context *onfinish);
 
+private:
+  int probe_impl(Probe* probe, ceph_file_layout *layout,
+		 uint64_t start_from, uint64_t *end);
+};
 
-#endif
+#endif // !CEPH_FILER_H
diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc
index 5b99517..02f93d3 100644
--- a/src/osdc/Journaler.cc
+++ b/src/osdc/Journaler.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #include "common/perf_counters.h"
@@ -23,7 +23,10 @@
 
 #define dout_subsys ceph_subsys_journaler
 #undef dout_prefix
-#define dout_prefix *_dout << objecter->messenger->get_myname() << ".journaler" << (readonly ? "(ro) ":"(rw) ")
+#define dout_prefix *_dout << objecter->messenger->get_myname() \
+  << ".journaler" << (readonly ? "(ro) ":"(rw) ")
+
+using std::chrono::seconds;
 
 
 void Journaler::set_readonly()
@@ -55,10 +58,11 @@ void Journaler::create(ceph_file_layout *l, stream_format_t const sf)
 
   prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos =
     read_pos = requested_pos = received_pos =
-    expire_pos = trimming_pos = trimmed_pos = (uint64_t)layout.fl_stripe_count * layout.fl_object_size;
+    expire_pos = trimming_pos = trimmed_pos =
+    (uint64_t)layout.fl_stripe_count * layout.fl_object_size;
 
-  ldout(cct, 1) << "created blank journal at inode 0x" << std::hex << ino << std::dec
-    << ", format=" << stream_format << dendl;
+  ldout(cct, 1) << "created blank journal at inode 0x" << std::hex << ino
+		<< std::dec << ", format=" << stream_format << dendl;
 }
 
 void Journaler::set_layout(ceph_file_layout const *l)
@@ -86,7 +90,7 @@ void Journaler::_set_layout(ceph_file_layout const *l)
 
 /***************** HEADER *******************/
 
-ostream& operator<<(ostream& out, Journaler::Header &h) 
+ostream& operator<<(ostream& out, Journaler::Header &h)
 {
   return out << "loghead(trim " << h.trimmed_pos
 	     << ", expire " << h.expire_pos
@@ -110,7 +114,8 @@ class Journaler::C_RereadHead : public Context {
   Context *onfinish;
 public:
   bufferlist bl;
-  C_RereadHead(Journaler *l, Context *onfinish_) : ls (l), onfinish(onfinish_){}
+  C_RereadHead(Journaler *l, Context *onfinish_) : ls (l),
+						   onfinish(onfinish_) {}
   void finish(int r) {
     ls->_finish_reread_head(r, bl, onfinish);
   }
@@ -152,7 +157,7 @@ void Journaler::recover(Context *onread)
 
   if (onread)
     waitfor_recover.push_back(onread);
-  
+
   if (state != STATE_UNDEF) {
     ldout(cct, 1) << "recover - already recovering" << dendl;
     return;
@@ -215,7 +220,8 @@ void Journaler::_finish_reread_head(int r, bufferlist& bl, Context *finish)
       finish->complete(-EINVAL);
       return;
     }
-    prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = h.write_pos;
+    prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos
+      = h.write_pos;
     expire_pos = h.expire_pos;
     trimmed_pos = trimming_pos = h.trimmed_pos;
     init_headers(h);
@@ -232,8 +238,7 @@ void Journaler::_finish_read_head(int r, bufferlist& bl)
   assert(state == STATE_READHEAD);
 
   if (r!=0) {
-    ldout(cct, 0) << "error getting journal off disk"
-                  << dendl;
+    ldout(cct, 0) << "error getting journal off disk" << dendl;
     list<Context*> ls;
     ls.swap(waitfor_recover);
     finish_contexts(cct, ls, r);
@@ -241,13 +246,14 @@ void Journaler::_finish_read_head(int r, bufferlist& bl)
   }
 
   if (bl.length() == 0) {
-    ldout(cct, 1) << "_finish_read_head r=" << r << " read 0 bytes, assuming empty log" << dendl;    
+    ldout(cct, 1) << "_finish_read_head r=" << r
+		  << " read 0 bytes, assuming empty log" << dendl;
     state = STATE_ACTIVE;
     list<Context*> ls;
     ls.swap(waitfor_recover);
     finish_contexts(cct, ls, 0);
     return;
-  } 
+  }
 
   // unpack header
   bool corrupt = false;
@@ -258,7 +264,7 @@ void Journaler::_finish_read_head(int r, bufferlist& bl)
 
     if (h.magic != magic) {
       ldout(cct, 0) << "on disk magic '" << h.magic << "' != my magic '"
-              << magic << "'" << dendl;
+		    << magic << "'" << dendl;
       corrupt = true;
     } else if (h.write_pos < h.expire_pos || h.expire_pos < h.trimmed_pos) {
       ldout(cct, 0) << "Corrupt header (bad offsets): " << h << dendl;
@@ -275,7 +281,8 @@ void Journaler::_finish_read_head(int r, bufferlist& bl)
     return;
   }
 
-  prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = h.write_pos;
+  prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos
+    = h.write_pos;
   read_pos = requested_pos = received_pos = expire_pos = h.expire_pos;
   trimmed_pos = trimming_pos = h.trimmed_pos;
 
@@ -284,7 +291,9 @@ void Journaler::_finish_read_head(int r, bufferlist& bl)
   stream_format = h.stream_format;
   journal_stream.set_format(h.stream_format);
 
-  ldout(cct, 1) << "_finish_read_head " << h << ".  probing for end of log (from " << write_pos << ")..." << dendl;
+  ldout(cct, 1) << "_finish_read_head " << h
+		<< ".  probing for end of log (from " << write_pos << ")..."
+		<< dendl;
   C_ProbeEnd *fin = new C_ProbeEnd(this);
   state = STATE_PROBING;
   _probe(fin, &fin->end);
@@ -297,7 +306,7 @@ void Journaler::_probe(Context *finish, uint64_t *end)
   assert(state == STATE_PROBING || state == STATE_REPROBING);
   // probe the log
   filer.probe(ino, &layout, CEPH_NOSNAP,
-	      write_pos, end, 0, true, 0, wrap_finisher(finish));
+	      write_pos, end, true, 0, wrap_finisher(finish));
 }
 
 void Journaler::_reprobe(C_OnFinisher *finish)
@@ -311,12 +320,13 @@ void Journaler::_reprobe(C_OnFinisher *finish)
 }
 
 
-void Journaler::_finish_reprobe(int r, uint64_t new_end, C_OnFinisher *onfinish)
+void Journaler::_finish_reprobe(int r, uint64_t new_end,
+				C_OnFinisher *onfinish)
 {
   Mutex::Locker l(lock);
 
   assert(new_end >= write_pos || r < 0);
-  ldout(cct, 1) << "_finish_reprobe new_end = " << new_end 
+  ldout(cct, 1) << "_finish_reprobe new_end = " << new_end
 	  << " (header had " << write_pos << ")."
 	  << dendl;
   prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = new_end;
@@ -334,21 +344,20 @@ void Journaler::_finish_probe_end(int r, uint64_t end)
   }
   if (((int64_t)end) == -1) {
     end = write_pos;
-    ldout(cct, 1) << "_finish_probe_end write_pos = " << end 
-	    << " (header had " << write_pos << "). log was empty. recovered."
-	    << dendl;
+    ldout(cct, 1) << "_finish_probe_end write_pos = " << end << " (header had "
+		  << write_pos << "). log was empty. recovered." << dendl;
     assert(0); // hrm.
   } else {
     assert(end >= write_pos);
-    ldout(cct, 1) << "_finish_probe_end write_pos = " << end 
-	    << " (header had " << write_pos << "). recovered."
-	    << dendl;
+    ldout(cct, 1) << "_finish_probe_end write_pos = " << end
+		  << " (header had " << write_pos << "). recovered."
+		  << dendl;
   }
 
   state = STATE_ACTIVE;
 
   prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = end;
-  
+
 out:
   // done.
   list<Context*> ls;
@@ -393,7 +402,8 @@ public:
   Journaler *ls;
   Header h;
   C_OnFinisher *oncommit;
-  C_WriteHead(Journaler *l, Header& h_, C_OnFinisher *c) : ls(l), h(h_), oncommit(c) {}
+  C_WriteHead(Journaler *l, Header& h_, C_OnFinisher *c) : ls(l), h(h_),
+							   oncommit(c) {}
   void finish(int r) {
     ls->_finish_write_head(r, h, oncommit);
   }
@@ -416,26 +426,28 @@ void Journaler::_write_head(Context *oncommit)
   last_written.write_pos = safe_pos;
   last_written.stream_format = stream_format;
   ldout(cct, 10) << "write_head " << last_written << dendl;
-  
+
   // Avoid persisting bad pointers in case of bugs
   assert(last_written.write_pos >= last_written.expire_pos);
   assert(last_written.expire_pos >= last_written.trimmed_pos);
 
-  last_wrote_head = ceph_clock_now(cct);
+  last_wrote_head = ceph::real_clock::now(cct);
 
   bufferlist bl;
   ::encode(last_written, bl);
   SnapContext snapc;
-  
+
   object_t oid = file_object_t(ino, 0);
   object_locator_t oloc(pg_pool);
-  objecter->write_full(oid, oloc, snapc, bl, ceph_clock_now(cct), 0, 
-		       NULL, 
-		       wrap_finisher(new C_WriteHead(this, last_written, wrap_finisher(oncommit))),
+  objecter->write_full(oid, oloc, snapc, bl, ceph::real_clock::now(cct), 0,
+		       NULL, wrap_finisher(new C_WriteHead(
+					     this, last_written,
+					     wrap_finisher(oncommit))),
 		       0, 0, write_iohint);
 }
 
-void Journaler::_finish_write_head(int r, Header &wrote, C_OnFinisher *oncommit)
+void Journaler::_finish_write_head(int r, Header &wrote,
+				   C_OnFinisher *oncommit)
 {
   Mutex::Locker l(lock);
 
@@ -460,15 +472,16 @@ void Journaler::_finish_write_head(int r, Header &wrote, C_OnFinisher *oncommit)
 class Journaler::C_Flush : public Context {
   Journaler *ls;
   uint64_t start;
-  utime_t stamp;
+  ceph::real_time stamp;
 public:
-  C_Flush(Journaler *l, int64_t s, utime_t st) : ls(l), start(s), stamp(st) {}
+  C_Flush(Journaler *l, int64_t s, ceph::real_time st)
+    : ls(l), start(s), stamp(st) {}
   void finish(int r) {
     ls->_finish_flush(r, start, stamp);
   }
 };
 
-void Journaler::_finish_flush(int r, uint64_t start, utime_t stamp)
+void Journaler::_finish_flush(int r, uint64_t start, ceph::real_time stamp)
 {
   Mutex::Locker l(lock);
   assert(!readonly);
@@ -484,8 +497,7 @@ void Journaler::_finish_flush(int r, uint64_t start, utime_t stamp)
 
   // calc latency?
   if (logger) {
-    utime_t lat = ceph_clock_now(cct);
-    lat -= stamp;
+    ceph::timespan lat = ceph::real_clock::now(cct) - stamp;
     logger->tinc(logger_key_lat, lat);
   }
 
@@ -500,8 +512,8 @@ void Journaler::_finish_flush(int r, uint64_t start, utime_t stamp)
   ldout(cct, 10) << "_finish_flush safe from " << start
 		 << ", pending_safe " << pending_safe
 		 << ", (prezeroing/prezero)/write/flush/safe positions now "
-		 << "(" << prezeroing_pos << "/" << prezero_pos << ")/" << write_pos
-		 << "/" << flush_pos << "/" << safe_pos
+		 << "(" << prezeroing_pos << "/" << prezero_pos << ")/"
+		 << write_pos << "/" << flush_pos << "/" << safe_pos
 		 << dendl;
 
   // kick waiters <= safe_pos
@@ -525,30 +537,34 @@ uint64_t Journaler::append_entry(bufferlist& bl)
   if (!cct->_conf->journaler_allow_split_entries) {
     // will we span a stripe boundary?
     int p = layout.fl_stripe_unit;
-    if (write_pos / p != (write_pos + (int64_t)(bl.length() + sizeof(s))) / p) {
+    if (write_pos / p != (write_pos + (int64_t)(bl.length() +
+						sizeof(s))) / p) {
       // yes.
       // move write_pos forward.
       int64_t owp = write_pos;
       write_pos += p;
       write_pos -= (write_pos % p);
-      
+
       // pad with zeros.
       bufferptr bp(write_pos - owp);
       bp.zero();
       assert(bp.length() >= 4);
       write_buf.push_back(bp);
-      
+
       // now flush.
       flush();
-      
-      ldout(cct, 12) << "append_entry skipped " << (write_pos-owp) << " bytes to " << write_pos << " to avoid spanning stripe boundary" << dendl;
+
+      ldout(cct, 12) << "append_entry skipped " << (write_pos-owp)
+		     << " bytes to " << write_pos
+		     << " to avoid spanning stripe boundary" << dendl;
     }
   }
-	
-  
+
+
   // append
   size_t wrote = journal_stream.write(bl, &write_buf, write_pos);
-  ldout(cct, 10) << "append_entry len " << s << " to " << write_pos << "~" << wrote << dendl;
+  ldout(cct, 10) << "append_entry len " << s << " to " << write_pos << "~"
+		 << wrote << dendl;
   write_pos += wrote;
 
   // flush previous object?
@@ -558,7 +574,8 @@ uint64_t Journaler::append_entry(bufferlist& bl)
   uint64_t write_obj = write_pos / su;
   uint64_t flush_obj = flush_pos / su;
   if (write_obj != flush_obj) {
-    ldout(cct, 10) << " flushing completed object(s) (su " << su << " wro " << write_obj << " flo " << flush_obj << ")" << dendl;
+    ldout(cct, 10) << " flushing completed object(s) (su " << su << " wro "
+		   << write_obj << " flo " << flush_obj << ")" << dendl;
     _do_flush(write_buf.length() - write_off);
   }
 
@@ -588,13 +605,15 @@ void Journaler::_do_flush(unsigned amount)
     int64_t newlen = prezero_pos - flush_pos - period;
     if (newlen <= 0) {
       ldout(cct, 10) << "_do_flush wanted to do " << flush_pos << "~" << len
-	       << " already too close to prezero_pos " << prezero_pos << ", zeroing first" << dendl;
+		     << " already too close to prezero_pos " << prezero_pos
+		     << ", zeroing first" << dendl;
       waiting_for_zero = true;
       return;
     }
     if (newlen < len) {
-      ldout(cct, 10) << "_do_flush wanted to do " << flush_pos << "~" << len << " but hit prezero_pos " << prezero_pos
-	       << ", will do " << flush_pos << "~" << newlen << dendl;
+      ldout(cct, 10) << "_do_flush wanted to do " << flush_pos << "~" << len
+		     << " but hit prezero_pos " << prezero_pos
+		     << ", will do " << flush_pos << "~" << newlen << dendl;
       len = newlen;
     } else {
       waiting_for_zero = false;
@@ -603,10 +622,10 @@ void Journaler::_do_flush(unsigned amount)
     waiting_for_zero = false;
   }
   ldout(cct, 10) << "_do_flush flushing " << flush_pos << "~" << len << dendl;
-  
+
   // submit write for anything pending
   // flush _start_ pos to _finish_flush
-  utime_t now = ceph_clock_now(cct);
+  ceph::real_time now = ceph::real_clock::now(cct);
   SnapContext snapc;
 
   Context *onsafe = new C_Flush(this, flush_pos, now);  // on COMMIT
@@ -622,15 +641,17 @@ void Journaler::_do_flush(unsigned amount)
   }
 
   filer.write(ino, &layout, snapc,
-	      flush_pos, len, write_bl, ceph_clock_now(cct),
+	      flush_pos, len, write_bl, ceph::real_clock::now(cct),
 	      0,
 	      NULL, wrap_finisher(onsafe), write_iohint);
 
   flush_pos += len;
   assert(write_buf.length() == write_pos - flush_pos);
-    
-  ldout(cct, 10) << "_do_flush (prezeroing/prezero)/write/flush/safe pointers now at "
-	   << "(" << prezeroing_pos << "/" << prezero_pos << ")/" << write_pos << "/" << flush_pos << "/" << safe_pos << dendl;
+
+  ldout(cct, 10)
+    << "_do_flush (prezeroing/prezero)/write/flush/safe pointers now at "
+    << "(" << prezeroing_pos << "/" << prezero_pos << ")/" << write_pos
+    << "/" << flush_pos << "/" << safe_pos << dendl;
 
   _issue_prezero();
 }
@@ -649,12 +670,14 @@ void Journaler::wait_for_flush(Context *onsafe)
 void Journaler::_wait_for_flush(Context *onsafe)
 {
   assert(!readonly);
-  
+
   // all flushed and safe?
   if (write_pos == safe_pos) {
     assert(write_buf.length() == 0);
-    ldout(cct, 10) << "flush nothing to flush, (prezeroing/prezero)/write/flush/safe pointers at " 
-	     << "(" << prezeroing_pos << "/" << prezero_pos << ")/" << write_pos << "/" << flush_pos << "/" << safe_pos << dendl;
+    ldout(cct, 10)
+      << "flush nothing to flush, (prezeroing/prezero)/write/flush/safe "
+      "pointers at " << "(" << prezeroing_pos << "/" << prezero_pos << ")/"
+      << write_pos << "/" << flush_pos << "/" << safe_pos << dendl;
     if (onsafe) {
       finisher->queue(onsafe, 0);
     }
@@ -665,7 +688,7 @@ void Journaler::_wait_for_flush(Context *onsafe)
   if (onsafe) {
     waitfor_safe[write_pos].push_back(wrap_finisher(onsafe));
   }
-}  
+}
 
 void Journaler::flush(Context *onsafe)
 {
@@ -679,8 +702,10 @@ void Journaler::_flush(C_OnFinisher *onsafe)
 
   if (write_pos == flush_pos) {
     assert(write_buf.length() == 0);
-    ldout(cct, 10) << "flush nothing to flush, (prezeroing/prezero)/write/flush/safe pointers at "
-	     << "(" << prezeroing_pos << "/" << prezero_pos << ")/" << write_pos << "/" << flush_pos << "/" << safe_pos << dendl;
+    ldout(cct, 10) << "flush nothing to flush, (prezeroing/prezero)/write/"
+      "flush/safe pointers at " << "(" << prezeroing_pos << "/" << prezero_pos
+		   << ")/" << write_pos << "/" << flush_pos << "/" << safe_pos
+		   << dendl;
     if (onsafe) {
       onsafe->complete(0);
     }
@@ -690,10 +715,11 @@ void Journaler::_flush(C_OnFinisher *onsafe)
       // delay!  schedule an event.
       ldout(cct, 20) << "flush delaying flush" << dendl;
       if (delay_flush_event) {
-        timer->cancel_event(delay_flush_event);
+	timer->cancel_event(delay_flush_event);
       }
       delay_flush_event = new C_DelayFlush(this);
-      timer->add_event_after(cct->_conf->journaler_batch_interval, delay_flush_event);	
+      timer->add_event_after(cct->_conf->journaler_batch_interval,
+			     delay_flush_event);
     } else {
       ldout(cct, 20) << "flush not delaying flush" << dendl;
       _do_flush();
@@ -702,7 +728,8 @@ void Journaler::_flush(C_OnFinisher *onsafe)
   }
 
   // write head?
-  if (last_wrote_head.sec() + cct->_conf->journaler_write_head_interval < ceph_clock_now(cct).sec()) {
+  if (last_wrote_head + seconds(cct->_conf->journaler_write_head_interval)
+      < ceph::real_clock::now(cct)) {
     _write_head();
   }
 }
@@ -713,7 +740,8 @@ void Journaler::_flush(C_OnFinisher *onsafe)
 struct C_Journaler_Prezero : public Context {
   Journaler *journaler;
   uint64_t from, len;
-  C_Journaler_Prezero(Journaler *j, uint64_t f, uint64_t l) : journaler(j), from(f), len(l) {}
+  C_Journaler_Prezero(Journaler *j, uint64_t f, uint64_t l)
+    : journaler(j), from(f), len(l) {}
   void finish(int r) {
     journaler->_finish_prezero(r, from, len);
   }
@@ -723,8 +751,8 @@ void Journaler::_issue_prezero()
 {
   assert(prezeroing_pos >= flush_pos);
 
-  // we need to zero at least two periods, minimum, to ensure that we have a full
-  // empty object/period in front of us.
+  // we need to zero at least two periods, minimum, to ensure that we
+  // have a full empty object/period in front of us.
   uint64_t num_periods = MAX(2, cct->_conf->journaler_prezero_periods);
 
   /*
@@ -736,7 +764,8 @@ void Journaler::_issue_prezero()
   to -= to % period;
 
   if (prezeroing_pos >= to) {
-    ldout(cct, 20) << "_issue_prezero target " << to << " <= prezeroing_pos " << prezeroing_pos << dendl;
+    ldout(cct, 20) << "_issue_prezero target " << to << " <= prezeroing_pos "
+		   << prezeroing_pos << dendl;
     return;
   }
 
@@ -744,14 +773,18 @@ void Journaler::_issue_prezero()
     uint64_t len;
     if (prezeroing_pos % period == 0) {
       len = period;
-      ldout(cct, 10) << "_issue_prezero removing " << prezeroing_pos << "~" << period << " (full period)" << dendl;
+      ldout(cct, 10) << "_issue_prezero removing " << prezeroing_pos << "~"
+		     << period << " (full period)" << dendl;
     } else {
       len = period - (prezeroing_pos % period);
-      ldout(cct, 10) << "_issue_prezero zeroing " << prezeroing_pos << "~" << len << " (partial period)" << dendl;
+      ldout(cct, 10) << "_issue_prezero zeroing " << prezeroing_pos << "~"
+		     << len << " (partial period)" << dendl;
     }
     SnapContext snapc;
-    Context *c = wrap_finisher(new C_Journaler_Prezero(this, prezeroing_pos, len));
-    filer.zero(ino, &layout, snapc, prezeroing_pos, len, ceph_clock_now(cct), 0, NULL, c);
+    Context *c = wrap_finisher(new C_Journaler_Prezero(this, prezeroing_pos,
+						       len));
+    filer.zero(ino, &layout, snapc, prezeroing_pos, len,
+	       ceph::real_clock::now(cct), 0, NULL, c);
     prezeroing_pos += len;
   }
 }
@@ -764,9 +797,9 @@ void Journaler::_finish_prezero(int r, uint64_t start, uint64_t len)
   Mutex::Locker l(lock);
 
   ldout(cct, 10) << "_prezeroed to " << start << "~" << len
-	   << ", prezeroing/prezero was " << prezeroing_pos << "/" << prezero_pos
-	   << ", pending " << pending_zero
-	   << dendl;
+		 << ", prezeroing/prezero was " << prezeroing_pos << "/"
+		 << prezero_pos << ", pending " << pending_zero
+		 << dendl;
   if (r < 0 && r != -ENOENT) {
     lderr(cct) << "_prezeroed got " << cpp_strerror(r) << dendl;
     handle_write_error(r);
@@ -790,9 +823,10 @@ void Journaler::_finish_prezero(int r, uint64_t start, uint64_t len)
   } else {
     pending_zero.insert(start, len);
   }
-  ldout(cct, 10) << "_prezeroed prezeroing/prezero now " << prezeroing_pos << "/" << prezero_pos
-	   << ", pending " << pending_zero
-	   << dendl;
+  ldout(cct, 10) << "_prezeroed prezeroing/prezero now " << prezeroing_pos
+		 << "/" << prezero_pos
+		 << ", pending " << pending_zero
+		 << dendl;
 }
 
 
@@ -820,10 +854,11 @@ public:
     // Should only be called from waitfor_safe i.e. already inside lock
     assert(ls->lock.is_locked_by_me());
     ls->_prefetch();
-  }  
+  }
 };
 
-void Journaler::_finish_read(int r, uint64_t offset, uint64_t length, bufferlist& bl)
+void Journaler::_finish_read(int r, uint64_t offset, uint64_t length,
+			     bufferlist& bl)
 {
   Mutex::Locker l(lock);
 
@@ -831,9 +866,11 @@ void Journaler::_finish_read(int r, uint64_t offset, uint64_t length, bufferlist
     ldout(cct, 0) << "_finish_read got error " << r << dendl;
     error = r;
   } else {
-    ldout(cct, 10) << "_finish_read got " << offset << "~" << bl.length() << dendl;
+    ldout(cct, 10) << "_finish_read got " << offset << "~" << bl.length()
+		   << dendl;
     if (bl.length() < length) {
-      ldout(cct, 0) << "_finish_read got less than expected (" << length << ")" << dendl;
+      ldout(cct, 0) << "_finish_read got less than expected (" << length << ")"
+		    << dendl;
       error = -EINVAL;
     }
   }
@@ -873,12 +910,14 @@ void Journaler::_assimilate_prefetch()
     map<uint64_t,bufferlist>::iterator p = prefetch_buf.begin();
     if (p->first != received_pos) {
       uint64_t gap = p->first - received_pos;
-      ldout(cct, 10) << "_assimilate_prefetch gap of " << gap << " from received_pos " << received_pos
-	       << " to first prefetched buffer " << p->first << dendl;
+      ldout(cct, 10) << "_assimilate_prefetch gap of " << gap
+		     << " from received_pos " << received_pos
+		     << " to first prefetched buffer " << p->first << dendl;
       break;
     }
 
-    ldout(cct, 10) << "_assimilate_prefetch " << p->first << "~" << p->second.length() << dendl;
+    ldout(cct, 10) << "_assimilate_prefetch " << p->first << "~"
+		   << p->second.length() << dendl;
     received_pos += p->second.length();
     read_buf.claim_append(p->second);
     assert(received_pos <= requested_pos);
@@ -887,9 +926,10 @@ void Journaler::_assimilate_prefetch()
   }
 
   if (got_any) {
-    ldout(cct, 10) << "_assimilate_prefetch read_buf now " << read_pos << "~" << read_buf.length() 
-	     << ", read pointers " << read_pos << "/" << received_pos << "/" << requested_pos
-	     << dendl;
+    ldout(cct, 10) << "_assimilate_prefetch read_buf now " << read_pos << "~"
+		   << read_buf.length() << ", read pointers " << read_pos
+		   << "/" << received_pos << "/" << requested_pos
+		   << dendl;
 
     // Update readability (this will also hit any decode errors resulting
     // from bad data)
@@ -912,11 +952,12 @@ void Journaler::_issue_read(uint64_t len)
   // make sure we're fully flushed
   _do_flush();
 
-  // stuck at safe_pos?
-  //  (this is needed if we are reading the tail of a journal we are also writing to)
+  // stuck at safe_pos?  (this is needed if we are reading the tail of
+  // a journal we are also writing to)
   assert(requested_pos <= safe_pos);
   if (requested_pos == safe_pos) {
-    ldout(cct, 10) << "_issue_read requested_pos = safe_pos = " << safe_pos << ", waiting" << dendl;
+    ldout(cct, 10) << "_issue_read requested_pos = safe_pos = " << safe_pos
+		   << ", waiting" << dendl;
     assert(write_pos > requested_pos);
     if (flush_pos == safe_pos) {
       _flush(NULL);
@@ -929,14 +970,15 @@ void Journaler::_issue_read(uint64_t len)
   // don't read too much
   if (requested_pos + len > safe_pos) {
     len = safe_pos - requested_pos;
-    ldout(cct, 10) << "_issue_read reading only up to safe_pos " << safe_pos << dendl;
+    ldout(cct, 10) << "_issue_read reading only up to safe_pos " << safe_pos
+		   << dendl;
   }
 
   // go.
-  ldout(cct, 10) << "_issue_read reading " << requested_pos << "~" << len 
-	   << ", read pointers " << read_pos << "/" << received_pos << "/" << (requested_pos+len)
-	   << dendl;
-  
+  ldout(cct, 10) << "_issue_read reading " << requested_pos << "~" << len
+		 << ", read pointers " << read_pos << "/" << received_pos
+		 << "/" << (requested_pos+len) << dendl;
+
   // step by period (object).  _don't_ do a single big filer.read()
   // here because it will wait for all object reads to complete before
   // giving us back any data.  this way we can process whatever bits
@@ -949,7 +991,8 @@ void Journaler::_issue_read(uint64_t len)
     if (l > len)
       l = len;
     C_Read *c = new C_Read(this, requested_pos, l);
-    filer.read(ino, &layout, CEPH_NOSNAP, requested_pos, l, &c->bl, 0, wrap_finisher(c), CEPH_OSD_OP_FLAG_FADVISE_DONTNEED);
+    filer.read(ino, &layout, CEPH_NOSNAP, requested_pos, l, &c->bl, 0,
+	       wrap_finisher(c), CEPH_OSD_OP_FLAG_FADVISE_DONTNEED);
     requested_pos += l;
     len -= l;
   }
@@ -982,8 +1025,9 @@ void Journaler::_prefetch()
 
   if (requested_pos < target) {
     uint64_t len = target - requested_pos;
-    ldout(cct, 10) << "_prefetch " << pf << " requested_pos " << requested_pos << " < target " << target
-	     << " (" << raw_target << "), prefetching " << len << dendl;
+    ldout(cct, 10) << "_prefetch " << pf << " requested_pos " << requested_pos
+		   << " < target " << target << " (" << raw_target
+		   << "), prefetching " << len << dendl;
     _issue_read(len);
   }
 }
@@ -1005,11 +1049,13 @@ bool Journaler::_is_readable()
   }
 
   ldout (cct, 10) << "_is_readable read_buf.length() == " << read_buf.length()
-		  << ", but need " << need << " for next entry; fetch_len is " << fetch_len << dendl;
+		  << ", but need " << need << " for next entry; fetch_len is "
+		  << fetch_len << dendl;
 
   // partial fragment at the end?
   if (received_pos == write_pos) {
-    ldout(cct, 10) << "is_readable() detected partial entry at tail, adjusting write_pos to " << read_pos << dendl;
+    ldout(cct, 10) << "is_readable() detected partial entry at tail, "
+      "adjusting write_pos to " << read_pos << dendl;
 
     // adjust write_pos
     prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = read_pos;
@@ -1017,8 +1063,8 @@ bool Journaler::_is_readable()
 
     // reset read state
     requested_pos = received_pos = read_pos;
-    read_buf.clear();    
-    
+    read_buf.clear();
+
     // FIXME: truncate on disk?
 
     return false;
@@ -1026,7 +1072,8 @@ bool Journaler::_is_readable()
 
   if (need > fetch_len) {
     temp_fetch_len = need;
-    ldout(cct, 10) << "_is_readable noting temp_fetch_len " << temp_fetch_len << dendl;
+    ldout(cct, 10) << "_is_readable noting temp_fetch_len " << temp_fetch_len
+		   << dendl;
   }
 
   ldout(cct, 10) << "_is_readable: not readable, returning false" << dendl;
@@ -1036,7 +1083,7 @@ bool Journaler::_is_readable()
 /*
  * is_readable() - kickstart prefetch, too
  */
-bool Journaler::is_readable() 
+bool Journaler::is_readable()
 {
   Mutex::Locker l(lock);
 
@@ -1070,12 +1117,15 @@ void Journaler::erase(Context *completion)
   // Async delete the journal data
   uint64_t first = trimmed_pos / get_layout_period();
   uint64_t num = (write_pos - trimmed_pos) / get_layout_period() + 2;
-  filer.purge_range(ino, &layout, SnapContext(), first, num, ceph_clock_now(cct), 0,
-      wrap_finisher(new C_EraseFinish(this, wrap_finisher(completion))));
-
-  // We will not start the operation to delete the header until _finish_erase has
-  // seen the data deletion succeed: otherwise if there was an error deleting data
-  // we might prematurely delete the header thereby lose our reference to the data.
+  filer.purge_range(ino, &layout, SnapContext(), first, num,
+		    ceph::real_clock::now(cct), 0,
+		    wrap_finisher(new C_EraseFinish(
+				    this, wrap_finisher(completion))));
+
+  // We will not start the operation to delete the header until
+  // _finish_erase has seen the data deletion succeed: otherwise if
+  // there was an error deleting data we might prematurely delete the
+  // header thereby lose our reference to the data.
 }
 
 void Journaler::_finish_erase(int data_result, C_OnFinisher *completion)
@@ -1084,10 +1134,11 @@ void Journaler::_finish_erase(int data_result, C_OnFinisher *completion)
 
   if (data_result == 0) {
     // Async delete the journal header
-    filer.purge_range(ino, &layout, SnapContext(), 0, 1, ceph_clock_now(cct), 0,
-        wrap_finisher(completion));
+    filer.purge_range(ino, &layout, SnapContext(), 0, 1, ceph::real_clock::now(cct),
+		      0, wrap_finisher(completion));
   } else {
-    lderr(cct) << "Failed to delete journal " << ino << " data: " << cpp_strerror(data_result) << dendl;
+    lderr(cct) << "Failed to delete journal " << ino << " data: "
+	       << cpp_strerror(data_result) << dendl;
     completion->complete(data_result);
   }
 }
@@ -1101,7 +1152,8 @@ bool Journaler::try_read_entry(bufferlist& bl)
   Mutex::Locker l(lock);
 
   if (!readable) {
-    ldout(cct, 10) << "try_read_entry at " << read_pos << " not readable" << dendl;
+    ldout(cct, 10) << "try_read_entry at " << read_pos << " not readable"
+		   << dendl;
     return false;
   }
 
@@ -1118,8 +1170,9 @@ bool Journaler::try_read_entry(bufferlist& bl)
     return false;
   }
 
-  ldout(cct, 10) << "try_read_entry at " << read_pos << " read " 
-	   << read_pos << "~" << consumed << " (have " << read_buf.length() << ")" << dendl;
+  ldout(cct, 10) << "try_read_entry at " << read_pos << " read "
+		 << read_pos << "~" << consumed << " (have "
+		 << read_buf.length() << ")" << dendl;
 
   read_pos += consumed;
   try {
@@ -1146,7 +1199,8 @@ void Journaler::wait_for_readable(Context *onreadable)
 
   assert(on_readable == 0);
   if (!readable) {
-    ldout(cct, 10) << "wait_for_readable at " << read_pos << " onreadable " << onreadable << dendl;
+    ldout(cct, 10) << "wait_for_readable at " << read_pos << " onreadable "
+		   << onreadable << dendl;
     on_readable = wrap_finisher(onreadable);
   } else {
     // race with OSD reply
@@ -1186,33 +1240,34 @@ void Journaler::_trim()
 	   << ", can trim to " << trim_to
 	   << dendl;
   if (trim_to == 0 || trim_to == trimming_pos) {
-    ldout(cct, 10) << "trim already trimmed/trimming to " 
-	     << trimmed_pos << "/" << trimming_pos << dendl;
+    ldout(cct, 10) << "trim already trimmed/trimming to "
+		   << trimmed_pos << "/" << trimming_pos << dendl;
     return;
   }
 
   if (trimming_pos > trimmed_pos) {
-    ldout(cct, 10) << "trim already trimming atm, try again later.  trimmed/trimming is " 
-	     << trimmed_pos << "/" << trimming_pos << dendl;
+    ldout(cct, 10) << "trim already trimming atm, try again later.  "
+      "trimmed/trimming is " << trimmed_pos << "/" << trimming_pos << dendl;
     return;
   }
-  
+
   // trim
   assert(trim_to <= write_pos);
   assert(trim_to <= expire_pos);
   assert(trim_to > trimming_pos);
-  ldout(cct, 10) << "trim trimming to " << trim_to 
-	   << ", trimmed/trimming/expire are " 
-	   << trimmed_pos << "/" << trimming_pos << "/" << expire_pos
-	   << dendl;
+  ldout(cct, 10) << "trim trimming to " << trim_to
+		 << ", trimmed/trimming/expire are "
+		 << trimmed_pos << "/" << trimming_pos << "/" << expire_pos
+		 << dendl;
 
   // delete range of objects
   uint64_t first = trimming_pos / period;
   uint64_t num = (trim_to - trimming_pos) / period;
   SnapContext snapc;
-  filer.purge_range(ino, &layout, snapc, first, num, ceph_clock_now(cct), 0, 
+  filer.purge_range(ino, &layout, snapc, first, num,
+		    ceph::real_clock::now(cct), 0,
 		    wrap_finisher(new C_Trim(this, trim_to)));
-  trimming_pos = trim_to;  
+  trimming_pos = trim_to;
 }
 
 void Journaler::_finish_trim(int r, uint64_t to)
@@ -1231,7 +1286,7 @@ void Journaler::_finish_trim(int r, uint64_t to)
   }
 
   assert(r >= 0 || r == -ENOENT);
-  
+
   assert(to <= trimming_pos);
   assert(to > trimmed_pos);
   trimmed_pos = to;
@@ -1247,9 +1302,11 @@ void Journaler::handle_write_error(int r)
     on_write_error = NULL;
     called_write_error = true;
   } else if (called_write_error) {
-    /* We don't call error handler more than once, subsequent errors are dropped --
-     * this is okay as long as the error handler does something dramatic like respawn */
-    lderr(cct) << __func__ << ": multiple write errors, handler already called" << dendl;
+    /* We don't call error handler more than once, subsequent errors
+     * are dropped -- this is okay as long as the error handler does
+     * something dramatic like respawn */
+    lderr(cct) << __func__ << ": multiple write errors, handler already called"
+	       << dendl;
   } else {
     assert(0 == "unhandled write error");
   }
@@ -1282,7 +1339,7 @@ bool JournalStream::readable(bufferlist &read_buf, uint64_t *need) const
     if (format >= JOURNAL_FORMAT_RESILIENT) {
       ::decode(entry_sentinel, p);
       if (entry_sentinel != sentinel) {
-        throw buffer::malformed_input("Invalid sentinel"); 
+	throw buffer::malformed_input("Invalid sentinel");
       }
     }
 
@@ -1320,7 +1377,8 @@ bool JournalStream::readable(bufferlist &read_buf, uint64_t *need) const
  *          that this is not equal to the length of `entry`, which contains
  *          the inner serialized LogEvent and not the envelope.
  */
-size_t JournalStream::read(bufferlist &from, bufferlist *entry, uint64_t *start_ptr)
+size_t JournalStream::read(bufferlist &from, bufferlist *entry,
+			   uint64_t *start_ptr)
 {
   assert(start_ptr != NULL);
   assert(entry != NULL);
@@ -1359,7 +1417,8 @@ size_t JournalStream::read(bufferlist &from, bufferlist *entry, uint64_t *start_
 /**
  * Append one entry
  */
-size_t JournalStream::write(bufferlist &entry, bufferlist *to, uint64_t const &start_ptr)
+size_t JournalStream::write(bufferlist &entry, bufferlist *to,
+			    uint64_t const &start_ptr)
 {
   assert(to != NULL);
 
diff --git a/src/osdc/Journaler.h b/src/osdc/Journaler.h
index 9db19c1..c12bc78 100644
--- a/src/osdc/Journaler.h
+++ b/src/osdc/Journaler.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,54 +7,64 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 /* Journaler
  *
- * This class stripes a serial log over objects on the store.  Four logical pointers:
+ * This class stripes a serial log over objects on the store.  Four
+ * logical pointers:
  *
  *  write_pos - where we're writing new entries
- *   unused_field - where we're reading old entires
- * expire_pos - what is deemed "old" by user
- *   trimmed_pos - where we're expiring old items
+ *  unused_field - where we're reading old entires
+ *  expire_pos - what is deemed "old" by user
+ *  trimmed_pos - where we're expiring old items
  *
  *  trimmed_pos <= expire_pos <= unused_field <= write_pos.
  *
- * Often, unused_field <= write_pos (as with MDS log).  During recovery, write_pos is undefined
- * until the end of the log is discovered.
+ * Often, unused_field <= write_pos (as with MDS log).  During
+ * recovery, write_pos is undefined until the end of the log is
+ * discovered.
  *
- * A "head" struct at the beginning of the log is used to store metadata at
- * regular intervals.  The basic invariants include:
+ * A "head" struct at the beginning of the log is used to store
+ * metadata at regular intervals.  The basic invariants include:
  *
- *   head.unused_field   <= unused_field   -- the head may "lag", since it's updated lazily.
+ *   head.unused_field <= unused_field -- the head may "lag", since
+ *                                        it's updated lazily.
  *   head.write_pos  <= write_pos
  *   head.expire_pos <= expire_pos
  *   head.trimmed_pos   <= trimmed_pos
  *
  * More significantly,
  *
- *   head.expire_pos >= trimmed_pos -- this ensures we can find the "beginning" of the log
- *                                  as last recorded, before it is trimmed.  trimming will
- *                                  block until a sufficiently current expire_pos is committed.
+ *   head.expire_pos >= trimmed_pos -- this ensures we can find the
+ *                                     "beginning" of the log as last
+ *                                     recorded, before it is trimmed.
+ *                                     trimming will block until a
+ *                                     sufficiently current expire_pos
+ *                                     is committed.
  *
- * To recover log state, we simply start at the last write_pos in the head, and probe the
- * object sequence sizes until we read the end.  
+ * To recover log state, we simply start at the last write_pos in the
+ * head, and probe the object sequence sizes until we read the end.
  *
- * Head struct is stored in the first object.  Actual journal starts after layout.period() bytes.
+ * Head struct is stored in the first object.  Actual journal starts
+ * after layout.period() bytes.
  *
  */
 
 #ifndef CEPH_JOURNALER_H
 #define CEPH_JOURNALER_H
 
+#include <list>
+#include <map>
+
 #include "Objecter.h"
 #include "Filer.h"
 
-#include <list>
-#include <map>
+#include "common/Timer.h"
+
 
 class CephContext;
 class Context;
@@ -78,16 +88,18 @@ enum StreamFormat {
 // Legacy envelope is leading uint32_t size
 #define JOURNAL_ENVELOPE_LEGACY (sizeof(uint32_t))
 
-// Resilient envelope is leading uint64_t sentinel, uint32_t size, trailing uint64_t start_ptr
-#define JOURNAL_ENVELOPE_RESILIENT (sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint64_t))
+// Resilient envelope is leading uint64_t sentinel, uint32_t size,
+// trailing uint64_t start_ptr
+#define JOURNAL_ENVELOPE_RESILIENT (sizeof(uint32_t) + sizeof(uint64_t) + \
+				    sizeof(uint64_t))
 
 /**
  * Represents a collection of entries serialized in a byte stream.
  *
  * Each entry consists of:
  *  - a blob (used by the next level up as a serialized LogEvent)
- *  - a uint64_t (used by the next level up as a pointer to the start of the entry
- *    in the collection bytestream)
+ *  - a uint64_t (used by the next level up as a pointer to the start
+ *    of the entry in the collection bytestream)
  */
 class JournalStream
 {
@@ -118,12 +130,14 @@ public:
     uint64_t unused_field;
     uint64_t write_pos;
     string magic;
-    ceph_file_layout layout; //< The mapping from byte stream offsets to RADOS objects
-    stream_format_t stream_format; //< The encoding of LogEvents within the journal byte stream
+    ceph_file_layout layout; //< The mapping from byte stream offsets
+			     //  to RADOS objects
+    stream_format_t stream_format; //< The encoding of LogEvents
+				   //  within the journal byte stream
 
     Header(const char *m="") :
-      trimmed_pos(0), expire_pos(0), unused_field(0), write_pos(0), magic(m), stream_format(-1) {
-      memset(&layout, 0, sizeof(layout));
+      trimmed_pos(0), expire_pos(0), unused_field(0), write_pos(0), magic(m),
+      stream_format(-1) {memset(&layout, 0, sizeof(layout));
     }
 
     void encode(bufferlist &bl) const {
@@ -146,9 +160,9 @@ public:
       ::decode(write_pos, bl);
       ::decode(layout, bl);
       if (struct_v > 1) {
-        ::decode(stream_format, bl);
+	::decode(stream_format, bl);
       } else {
-        stream_format = JOURNAL_FORMAT_LEGACY;
+	stream_format = JOURNAL_FORMAT_LEGACY;
       }
       DECODE_FINISH(bl);
     }
@@ -259,7 +273,7 @@ private:
   void _trim();
 
   // header
-  utime_t last_wrote_head;
+  ceph::real_time last_wrote_head;
   void _finish_write_head(int r, Header &wrote, C_OnFinisher *oncommit);
   class C_WriteHead;
   friend class C_WriteHead;
@@ -288,20 +302,25 @@ private:
 
   // writer
   uint64_t prezeroing_pos;
-  uint64_t prezero_pos;     // we zero journal space ahead of write_pos to avoid problems with tail probing
-  uint64_t write_pos;       // logical write position, where next entry will go
-  uint64_t flush_pos;       // where we will flush. if write_pos>flush_pos, we're buffering writes.
-  uint64_t safe_pos;        // what has been committed safely to disk.
-  bufferlist write_buf;  // write buffer.  flush_pos + write_buf.length() == write_pos.
+  uint64_t prezero_pos; ///< we zero journal space ahead of write_pos to
+			//   avoid problems with tail probing
+  uint64_t write_pos; ///< logical write position, where next entry
+		      //   will go
+  uint64_t flush_pos; ///< where we will flush. if
+		      ///  write_pos>flush_pos, we're buffering writes.
+  uint64_t safe_pos; ///< what has been committed safely to disk.
+  bufferlist write_buf; ///< write buffer.  flush_pos +
+			///  write_buf.length() == write_pos.
 
   bool waiting_for_zero;
   interval_set<uint64_t> pending_zero;  // non-contig bits we've zeroed
   std::set<uint64_t> pending_safe;
-  std::map<uint64_t, std::list<Context*> > waitfor_safe; // when safe through given offset
+  // when safe through given offset
+  std::map<uint64_t, std::list<Context*> > waitfor_safe;
 
   void _flush(C_OnFinisher *onsafe);
   void _do_flush(unsigned amount=0);
-  void _finish_flush(int r, uint64_t start, utime_t stamp);
+  void _finish_flush(int r, uint64_t start, ceph::real_time stamp);
   class C_Flush;
   friend class C_Flush;
 
@@ -309,7 +328,8 @@ private:
   uint64_t read_pos;      // logical read position, where next entry starts.
   uint64_t requested_pos; // what we've requested from OSD.
   uint64_t received_pos;  // what we've received from OSD.
-  bufferlist read_buf; // read buffer.  unused_field + read_buf.length() == prefetch_pos.
+  // read buffer.  unused_field + read_buf.length() == prefetch_pos.
+  bufferlist read_buf;
 
   map<uint64_t,bufferlist> prefetch_buf;
 
@@ -317,15 +337,16 @@ private:
   uint64_t temp_fetch_len;
 
   // for wait_for_readable()
-  C_OnFinisher    *on_readable;
-  C_OnFinisher    *on_write_error;
-  bool             called_write_error;
+  C_OnFinisher *on_readable;
+  C_OnFinisher *on_write_error;
+  bool called_write_error;
 
-  void _finish_read(int r, uint64_t offset, uint64_t length, bufferlist &bl); // read completion callback
+  // read completion callback
+  void _finish_read(int r, uint64_t offset, uint64_t length, bufferlist &bl);
   void _finish_retry_read(int r);
   void _assimilate_prefetch();
-  void _issue_read(uint64_t len);  // read some more
-  void _prefetch();             // maybe read ahead
+  void _issue_read(uint64_t len); // read some more
+  void _prefetch(); // maybe read ahead
   class C_Read;
   friend class C_Read;
   class C_RetryRead;
@@ -349,8 +370,8 @@ private:
   // only init_headers when following or first reading off-disk
   void init_headers(Header& h) {
     assert(readonly ||
-           state == STATE_READHEAD ||
-           state == STATE_REREADHEAD);
+	   state == STATE_READHEAD ||
+	   state == STATE_REREADHEAD);
     last_written = last_committed = h;
   }
 
@@ -371,10 +392,12 @@ private:
 
   C_OnFinisher *wrap_finisher(Context *c);
 
-  uint32_t write_iohint; //the fadvise flags for write op, see CEPH_OSD_OP_FADIVSE_*
+  uint32_t write_iohint; // the fadvise flags for write op, see
+			 // CEPH_OSD_OP_FADIVSE_*
 
 public:
-  Journaler(inodeno_t ino_, int64_t pool, const char *mag, Objecter *obj, PerfCounters *l, int lkey, SafeTimer *tim, Finisher *f) : 
+  Journaler(inodeno_t ino_, int64_t pool, const char *mag, Objecter *obj,
+	    PerfCounters *l, int lkey, SafeTimer *tim, Finisher *f) :
     last_committed(mag),
     cct(obj->cct), lock("Journaler"), finisher(f),
     last_written(mag),
@@ -396,9 +419,10 @@ public:
   }
 
   /* reset
-   *  NOTE: we assume the caller knows/has ensured that any objects 
-   * in our sequence do not exist.. e.g. after a MKFS.  this is _not_
-   * an "erase" method.
+   *
+   * NOTE: we assume the caller knows/has ensured that any objects in
+   * our sequence do not exist.. e.g. after a MKFS.  this is _not_ an
+   * "erase" method.
    */
   void reset() {
     Mutex::Locker l(lock);
@@ -441,13 +465,14 @@ public:
   void set_layout(ceph_file_layout const *l);
   void set_readonly();
   void set_writeable();
-  void set_write_pos(int64_t p) { 
+  void set_write_pos(int64_t p) {
     Mutex::Locker l(lock);
     prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = p;
   }
-  void set_read_pos(int64_t p) { 
+  void set_read_pos(int64_t p) {
     Mutex::Locker l(lock);
-    assert(requested_pos == received_pos);  // we can't cope w/ in-progress read right now.
+    // we can't cope w/ in-progress read right now.
+    assert(requested_pos == received_pos);
     read_pos = requested_pos = received_pos = p;
     read_buf.clear();
   }
@@ -486,7 +511,9 @@ public:
   // Synchronous getters
   // ===================
   // TODO: need some locks on reads for true safety
-  uint64_t get_layout_period() const { return (uint64_t)layout.fl_stripe_count * (uint64_t)layout.fl_object_size; }
+  uint64_t get_layout_period() const {
+    return (uint64_t)layout.fl_stripe_count * (uint64_t)layout.fl_object_size;
+  }
   ceph_file_layout& get_layout() { return layout; }
   bool is_active() { return state == STATE_ACTIVE; }
   int get_error() { return error; }
diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc
index 060b732..acf6004 100644
--- a/src/osdc/ObjectCacher.cc
+++ b/src/osdc/ObjectCacher.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
 #include <limits.h>
@@ -11,7 +11,10 @@
 
 #include "include/assert.h"
 
-#define MAX_FLUSH_UNDER_LOCK 20  ///< max bh's we start writeback on while holding the lock
+#define MAX_FLUSH_UNDER_LOCK 20  ///< max bh's we start writeback on
+
+using std::chrono::seconds;
+				 /// while holding the lock
 
 /*** ObjectCacher::BufferHead ***/
 
@@ -24,11 +27,12 @@
 
 
 
-ObjectCacher::BufferHead *ObjectCacher::Object::split(BufferHead *left, loff_t off)
+ObjectCacher::BufferHead *ObjectCacher::Object::split(BufferHead *left,
+						      loff_t off)
 {
   assert(oc->lock.is_locked());
   ldout(oc->cct, 20) << "split " << *left << " at " << off << dendl;
-  
+
   // split off right
   ObjectCacher::BufferHead *right = new BufferHead(this);
 
@@ -45,15 +49,15 @@ ObjectCacher::BufferHead *ObjectCacher::Object::split(BufferHead *left, loff_t o
   loff_t newleftlen = off - left->start();
   right->set_start(off);
   right->set_length(left->length() - newleftlen);
-  
+
   // shorten left
   oc->bh_stat_sub(left);
   left->set_length(newleftlen);
   oc->bh_stat_add(left);
-  
+
   // add right
   oc->bh_add(this, right);
-  
+
   // split buffers too
   bufferlist bl;
   bl.claim(left->bl);
@@ -65,13 +69,15 @@ ObjectCacher::BufferHead *ObjectCacher::Object::split(BufferHead *left, loff_t o
 
   // move read waiters
   if (!left->waitfor_read.empty()) {
-    map<loff_t, list<Context*> >::iterator start_remove = left->waitfor_read.begin();
+    map<loff_t, list<Context*> >::iterator start_remove
+      = left->waitfor_read.begin();
     while (start_remove != left->waitfor_read.end() &&
 	   start_remove->first < right->start())
       ++start_remove;
     for (map<loff_t, list<Context*> >::iterator p = start_remove;
 	 p != left->waitfor_read.end(); ++p) {
-      ldout(oc->cct, 20) << "split  moving waiters at byte " << p->first << " to right bh" << dendl;
+      ldout(oc->cct, 20) << "split  moving waiters at byte " << p->first
+			 << " to right bh" << dendl;
       right->waitfor_read[p->first].swap( p->second );
       assert(p->second.empty());
     }
@@ -116,10 +122,10 @@ void ObjectCacher::Object::merge_left(BufferHead *left, BufferHead *right)
   // waiters
   for (map<loff_t, list<Context*> >::iterator p = right->waitfor_read.begin();
        p != right->waitfor_read.end();
-       ++p) 
-    left->waitfor_read[p->first].splice( left->waitfor_read[p->first].begin(),
-                                         p->second );
-  
+       ++p)
+    left->waitfor_read[p->first].splice(left->waitfor_read[p->first].begin(),
+					p->second );
+
   // hose right
   delete right;
 
@@ -141,8 +147,8 @@ void ObjectCacher::Object::try_merge_bh(BufferHead *bh)
   if (p != data.begin()) {
     --p;
     if (p->second->end() == bh->start() &&
-        p->second->get_state() == bh->get_state() &&
-        p->second->can_merge_journal(bh)) {
+	p->second->get_state() == bh->get_state() &&
+	p->second->can_merge_journal(bh)) {
       merge_left(p->second, bh);
       bh = p->second;
     } else {
@@ -208,23 +214,23 @@ bool ObjectCacher::Object::include_all_cached_data(loff_t off, loff_t len)
  * - create missing buffer_heads as necessary.
  */
 int ObjectCacher::Object::map_read(OSDRead *rd,
-                                   map<loff_t, BufferHead*>& hits,
-                                   map<loff_t, BufferHead*>& missing,
-                                   map<loff_t, BufferHead*>& rx,
+				   map<loff_t, BufferHead*>& hits,
+				   map<loff_t, BufferHead*>& missing,
+				   map<loff_t, BufferHead*>& rx,
 				   map<loff_t, BufferHead*>& errors)
 {
   assert(oc->lock.is_locked());
   for (vector<ObjectExtent>::iterator ex_it = rd->extents.begin();
        ex_it != rd->extents.end();
        ++ex_it) {
-    
+
     if (ex_it->oid != oid.oid)
       continue;
 
-    ldout(oc->cct, 10) << "map_read " << ex_it->oid 
+    ldout(oc->cct, 10) << "map_read " << ex_it->oid
 		       << " " << ex_it->offset << "~" << ex_it->length
 		       << dendl;
-    
+
     loff_t cur = ex_it->offset;
     loff_t left = ex_it->length;
 
@@ -232,58 +238,60 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
     while (left > 0) {
       // at end?
       if (p == data.end()) {
-        // rest is a miss.
-        BufferHead *n = new BufferHead(this);
-        n->set_start(cur);
-        n->set_length(left);
-        oc->bh_add(this, n);
+	// rest is a miss.
+	BufferHead *n = new BufferHead(this);
+	n->set_start(cur);
+	n->set_length(left);
+	oc->bh_add(this, n);
 	if (complete) {
 	  oc->mark_zero(n);
 	  hits[cur] = n;
-	  ldout(oc->cct, 20) << "map_read miss+complete+zero " << left << " left, " << *n << dendl;
+	  ldout(oc->cct, 20) << "map_read miss+complete+zero " << left
+			     << " left, " << *n << dendl;
 	} else {
 	  missing[cur] = n;
-	  ldout(oc->cct, 20) << "map_read miss " << left << " left, " << *n << dendl;
+	  ldout(oc->cct, 20) << "map_read miss " << left << " left, " << *n
+			     << dendl;
 	}
-        cur += left;
-        assert(cur == (loff_t)ex_it->offset + (loff_t)ex_it->length);
-        break;  // no more.
+	cur += left;
+	assert(cur == (loff_t)ex_it->offset + (loff_t)ex_it->length);
+	break;  // no more.
       }
-      
+
       if (p->first <= cur) {
-        // have it (or part of it)
-        BufferHead *e = p->second;
+	// have it (or part of it)
+	BufferHead *e = p->second;
 
-        if (e->is_clean() ||
-            e->is_dirty() ||
-            e->is_tx() ||
+	if (e->is_clean() ||
+	    e->is_dirty() ||
+	    e->is_tx() ||
 	    e->is_zero()) {
-          hits[cur] = e;     // readable!
-          ldout(oc->cct, 20) << "map_read hit " << *e << dendl;
-        } else if (e->is_rx()) {
-          rx[cur] = e;       // missing, not readable.
-          ldout(oc->cct, 20) << "map_read rx " << *e << dendl;
-        } else if (e->is_error()) {
+	  hits[cur] = e;     // readable!
+	  ldout(oc->cct, 20) << "map_read hit " << *e << dendl;
+	} else if (e->is_rx()) {
+	  rx[cur] = e;       // missing, not readable.
+	  ldout(oc->cct, 20) << "map_read rx " << *e << dendl;
+	} else if (e->is_error()) {
 	  errors[cur] = e;
 	  ldout(oc->cct, 20) << "map_read error " << *e << dendl;
 	} else {
 	  assert(0);
 	}
-        
-        loff_t lenfromcur = MIN(e->end() - cur, left);
-        cur += lenfromcur;
-        left -= lenfromcur;
-        ++p;
-        continue;  // more?
-        
+
+	loff_t lenfromcur = MIN(e->end() - cur, left);
+	cur += lenfromcur;
+	left -= lenfromcur;
+	++p;
+	continue;  // more?
+
       } else if (p->first > cur) {
-        // gap.. miss
-        loff_t next = p->first;
-        BufferHead *n = new BufferHead(this);
+	// gap.. miss
+	loff_t next = p->first;
+	BufferHead *n = new BufferHead(this);
 	loff_t len = MIN(next - cur, left);
-        n->set_start(cur);
+	n->set_start(cur);
 	n->set_length(len);
-        oc->bh_add(this,n);
+	oc->bh_add(this,n);
 	if (complete) {
 	  oc->mark_zero(n);
 	  hits[cur] = n;
@@ -292,11 +300,11 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
 	  missing[cur] = n;
 	  ldout(oc->cct, 20) << "map_read gap " << *n << dendl;
 	}
-        cur += MIN(left, n->length());
-        left -= MIN(left, n->length());
-        continue;    // more?
+	cur += MIN(left, n->length());
+	left -= MIN(left, n->length());
+	continue;    // more?
       } else {
-        assert(0);
+	assert(0);
       }
     }
   }
@@ -340,7 +348,8 @@ void ObjectCacher::Object::audit_buffers()
  * map a range of extents on an object's buffer cache.
  * - combine any bh's we're writing into one
  * - break up bufferheads that don't fall completely within the range
- * //no! - return a bh that includes the write.  may also include other dirty data to left and/or right.
+ * //no! - return a bh that includes the write.  may also include
+ * other dirty data to left and/or right.
  */
 ObjectCacher::BufferHead *ObjectCacher::Object::map_write(OSDWrite *wr)
 {
@@ -353,8 +362,8 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(OSDWrite *wr)
 
     if (ex_it->oid != oid.oid) continue;
 
-    ldout(oc->cct, 10) << "map_write oex " << ex_it->oid
-		       << " " << ex_it->offset << "~" << ex_it->length << dendl;
+    ldout(oc->cct, 10) << "map_write oex " << ex_it->oid << " "
+		       << ex_it->offset << "~" << ex_it->length << dendl;
 
     loff_t cur = ex_it->offset;
     loff_t left = ex_it->length;
@@ -365,90 +374,93 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(OSDWrite *wr)
 
       // at end ?
       if (p == data.end()) {
-        if (final == NULL) {
-          final = new BufferHead(this);
-          final->set_start( cur );
-          final->set_length( max );
-          oc->bh_add(this, final);
-          ldout(oc->cct, 10) << "map_write adding trailing bh " << *final << dendl;
-        } else {
-          replace_journal_tid(final, wr->journal_tid);
+	if (final == NULL) {
+	  final = new BufferHead(this);
+	  final->set_start( cur );
+	  final->set_length( max );
+	  oc->bh_add(this, final);
+	  ldout(oc->cct, 10) << "map_write adding trailing bh " << *final
+			     << dendl;
+	} else {
+	  replace_journal_tid(final, wr->journal_tid);
 	  oc->bh_stat_sub(final);
-          final->set_length(final->length() + max);
+	  final->set_length(final->length() + max);
 	  oc->bh_stat_add(final);
-        }
-        left -= max;
-        cur += max;
-        continue;
+	}
+	left -= max;
+	cur += max;
+	continue;
       }
 
-      ldout(oc->cct, 10) << "cur is " << cur << ", p is " << *p->second << dendl;
+      ldout(oc->cct, 10) << "cur is " << cur << ", p is " << *p->second
+			 << dendl;
       //oc->verify_stats();
 
       if (p->first <= cur) {
-        BufferHead *bh = p->second;
-        ldout(oc->cct, 10) << "map_write bh " << *bh << " intersected" << dendl;
-
-        if (p->first < cur) {
-          assert(final == 0);
-          if (cur + max >= bh->end()) {
-            // we want right bit (one splice)
-            final = split(bh, cur);   // just split it, take right half.
-            ++p;
-            assert(p->second == final);
-          } else {
-            // we want middle bit (two splices)
-            final = split(bh, cur);
-            ++p;
-            assert(p->second == final);
-            split(final, cur+max);
-          }
-        } else {
+	BufferHead *bh = p->second;
+	ldout(oc->cct, 10) << "map_write bh " << *bh << " intersected"
+			   << dendl;
+
+	if (p->first < cur) {
+	  assert(final == 0);
+	  if (cur + max >= bh->end()) {
+	    // we want right bit (one splice)
+	    final = split(bh, cur);   // just split it, take right half.
+	    ++p;
+	    assert(p->second == final);
+	  } else {
+	    // we want middle bit (two splices)
+	    final = split(bh, cur);
+	    ++p;
+	    assert(p->second == final);
+	    split(final, cur+max);
+	  }
+	} else {
 	  assert(p->first == cur);
-          if (bh->length() <= max) {
-            // whole bufferhead, piece of cake.
-          } else {
-            // we want left bit (one splice)
-            split(bh, cur + max);        // just split
-          }
-          if (final) {
+	  if (bh->length() <= max) {
+	    // whole bufferhead, piece of cake.
+	  } else {
+	    // we want left bit (one splice)
+	    split(bh, cur + max); // just split
+	  }
+	  if (final) {
 	    oc->mark_dirty(bh);
 	    oc->mark_dirty(final);
 	    --p;  // move iterator back to final
 	    assert(p->second == final);
-            replace_journal_tid(bh, 0);
-            merge_left(final, bh);
+	    replace_journal_tid(bh, 0);
+	    merge_left(final, bh);
 	  } else {
-            final = bh;
+	    final = bh;
 	  }
-        }
-
-        // keep going.
-        loff_t lenfromcur = final->end() - cur;
-        cur += lenfromcur;
-        left -= lenfromcur;
-        ++p;
-        continue;
+	}
+
+	// keep going.
+	loff_t lenfromcur = final->end() - cur;
+	cur += lenfromcur;
+	left -= lenfromcur;
+	++p;
+	continue;
       } else {
-        // gap!
-        loff_t next = p->first;
-        loff_t glen = MIN(next - cur, max);
-        ldout(oc->cct, 10) << "map_write gap " << cur << "~" << glen << dendl;
-        if (final) {
-          replace_journal_tid(final, wr->journal_tid);
+	// gap!
+	loff_t next = p->first;
+	loff_t glen = MIN(next - cur, max);
+	ldout(oc->cct, 10) << "map_write gap " << cur << "~" << glen << dendl;
+	if (final) {
+	  replace_journal_tid(final, wr->journal_tid);
 	  oc->bh_stat_sub(final);
-          final->set_length(final->length() + glen);
+	  final->set_length(final->length() + glen);
 	  oc->bh_stat_add(final);
-        } else {
-          final = new BufferHead(this);
-          final->set_start( cur );
-          final->set_length( glen );
-          oc->bh_add(this, final);
-        }
-
-        cur += glen;
-        left -= glen;
-        continue;    // more?
+	} else {
+	  final = new BufferHead(this);
+	  final->set_start( cur );
+	  final->set_length( glen );
+	  oc->bh_add(this, final);
+	}
+
+	cur += glen;
+	left -= glen;
+	continue;    // more?
       }
     }
   }
@@ -461,14 +473,15 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(OSDWrite *wr)
   return final;
 }
 
-void ObjectCacher::Object::replace_journal_tid(BufferHead *bh, ceph_tid_t tid) {
+void ObjectCacher::Object::replace_journal_tid(BufferHead *bh,
+					       ceph_tid_t tid) {
   ceph_tid_t bh_tid = bh->get_journal_tid();
 
   assert(tid == 0 || bh_tid <= tid);
   if (bh_tid != 0 && bh_tid != tid) {
     // inform journal that it should not expect a writeback from this extent
-    oc->writeback_handler.overwrite_extent(get_oid(), bh->start(), bh->length(),
-                                           bh_tid);
+    oc->writeback_handler.overwrite_extent(get_oid(), bh->start(),
+					   bh->length(), bh_tid);
   }
   bh->set_journal_tid(tid);
 }
@@ -480,7 +493,7 @@ void ObjectCacher::Object::truncate(loff_t s)
 
   while (!data.empty()) {
     BufferHead *bh = data.rbegin()->second;
-    if (bh->end() <= s) 
+    if (bh->end() <= s)
       break;
 
     // split bh at truncation point?
@@ -501,7 +514,8 @@ void ObjectCacher::Object::truncate(loff_t s)
 void ObjectCacher::Object::discard(loff_t off, loff_t len)
 {
   assert(oc->lock.is_locked());
-  ldout(oc->cct, 10) << "discard " << *this << " " << off << "~" << len << dendl;
+  ldout(oc->cct, 10) << "discard " << *this << " " << off << "~" << len
+		     << dendl;
 
   if (!exists) {
     ldout(oc->cct, 10) << " setting exists on " << *this << dendl;
@@ -547,26 +561,28 @@ void ObjectCacher::Object::discard(loff_t off, loff_t len)
 #define dout_prefix *_dout << "objectcacher "
 
 
-ObjectCacher::ObjectCacher(CephContext *cct_, string name, WritebackHandler& wb, Mutex& l,
+ObjectCacher::ObjectCacher(CephContext *cct_, string name,
+			   WritebackHandler& wb, Mutex& l,
 			   flush_set_callback_t flush_callback,
-			   void *flush_callback_arg,
-			   uint64_t max_bytes, uint64_t max_objects,
-			   uint64_t max_dirty, uint64_t target_dirty,
-			   double max_dirty_age, bool block_writes_upfront)
+			   void *flush_callback_arg, uint64_t max_bytes,
+			   uint64_t max_objects, uint64_t max_dirty,
+			   uint64_t target_dirty, double max_dirty_age,
+			   bool block_writes_upfront)
   : perfcounter(NULL),
     cct(cct_), writeback_handler(wb), name(name), lock(l),
     max_dirty(max_dirty), target_dirty(target_dirty),
     max_size(max_bytes), max_objects(max_objects),
+    max_dirty_age(ceph::make_timespan(max_dirty_age)),
     block_writes_upfront(block_writes_upfront),
-    flush_set_callback(flush_callback), flush_set_callback_arg(flush_callback_arg),
-    last_read_tid(0),
-    flusher_stop(false), flusher_thread(this), finisher(cct),
-    stat_clean(0), stat_zero(0), stat_dirty(0), stat_rx(0), stat_tx(0), stat_missing(0),
-    stat_error(0), stat_dirty_waiting(0), reads_outstanding(0)
+    flush_set_callback(flush_callback),
+    flush_set_callback_arg(flush_callback_arg),
+    last_read_tid(0), flusher_stop(false), flusher_thread(this),finisher(cct),
+    stat_clean(0), stat_zero(0), stat_dirty(0), stat_rx(0), stat_tx(0),
+    stat_missing(0), stat_error(0), stat_dirty_waiting(0), reads_outstanding(0)
 {
-  this->max_dirty_age.set_from_double(max_dirty_age);
   perf_start();
   finisher.start();
+  scattered_write = writeback_handler.can_scattered_write();
 }
 
 ObjectCacher::~ObjectCacher()
@@ -574,9 +590,10 @@ ObjectCacher::~ObjectCacher()
   finisher.stop();
   perf_stop();
   // we should be empty.
-  for (vector<ceph::unordered_map<sobject_t, Object *> >::iterator i = objects.begin();
-      i != objects.end();
-      ++i)
+  for (vector<ceph::unordered_map<sobject_t, Object *> >::iterator i
+	 = objects.begin();
+       i != objects.end();
+       ++i)
     assert(i->empty());
   assert(bh_lru_rest.lru_get_size() == 0);
   assert(bh_lru_dirty.lru_get_size() == 0);
@@ -589,18 +606,30 @@ void ObjectCacher::perf_start()
   string n = "objectcacher-" + name;
   PerfCountersBuilder plb(cct, n, l_objectcacher_first, l_objectcacher_last);
 
-  plb.add_u64_counter(l_objectcacher_cache_ops_hit, "cache_ops_hit", "Hit operations");
-  plb.add_u64_counter(l_objectcacher_cache_ops_miss, "cache_ops_miss", "Miss operations");
-  plb.add_u64_counter(l_objectcacher_cache_bytes_hit, "cache_bytes_hit", "Hit data");
-  plb.add_u64_counter(l_objectcacher_cache_bytes_miss, "cache_bytes_miss", "Miss data");
-  plb.add_u64_counter(l_objectcacher_data_read, "data_read", "Read data");
-  plb.add_u64_counter(l_objectcacher_data_written, "data_written", "Data written to cache");
-  plb.add_u64_counter(l_objectcacher_data_flushed, "data_flushed", "Data flushed");
+  plb.add_u64_counter(l_objectcacher_cache_ops_hit,
+		      "cache_ops_hit", "Hit operations");
+  plb.add_u64_counter(l_objectcacher_cache_ops_miss,
+		      "cache_ops_miss", "Miss operations");
+  plb.add_u64_counter(l_objectcacher_cache_bytes_hit,
+		      "cache_bytes_hit", "Hit data");
+  plb.add_u64_counter(l_objectcacher_cache_bytes_miss,
+		      "cache_bytes_miss", "Miss data");
+  plb.add_u64_counter(l_objectcacher_data_read,
+		      "data_read", "Read data");
+  plb.add_u64_counter(l_objectcacher_data_written,
+		      "data_written", "Data written to cache");
+  plb.add_u64_counter(l_objectcacher_data_flushed,
+		      "data_flushed", "Data flushed");
   plb.add_u64_counter(l_objectcacher_overwritten_in_flush,
-                      "data_overwritten_while_flushing", "Data overwritten while flushing");
-  plb.add_u64_counter(l_objectcacher_write_ops_blocked, "write_ops_blocked", "Write operations, delayed due to dirty limits");
-  plb.add_u64_counter(l_objectcacher_write_bytes_blocked, "write_bytes_blocked", "Write data blocked on dirty limit");
-  plb.add_time(l_objectcacher_write_time_blocked, "write_time_blocked", "Time spent blocking a write due to dirty limits");
+		      "data_overwritten_while_flushing",
+		      "Data overwritten while flushing");
+  plb.add_u64_counter(l_objectcacher_write_ops_blocked, "write_ops_blocked",
+		      "Write operations, delayed due to dirty limits");
+  plb.add_u64_counter(l_objectcacher_write_bytes_blocked,
+		      "write_bytes_blocked",
+		      "Write data blocked on dirty limit");
+  plb.add_time(l_objectcacher_write_time_blocked, "write_time_blocked",
+	       "Time spent blocking a write due to dirty limits");
 
   perfcounter = plb.create_perf_counters();
   cct->get_perfcounters_collection()->add(perfcounter);
@@ -638,18 +667,18 @@ ObjectCacher::Object *ObjectCacher::get_object(sobject_t oid,
 
   // create it.
   Object *o = new Object(this, oid, object_no, oset, l, truncate_size,
-		         truncate_seq);
+			 truncate_seq);
   objects[l.pool][oid] = o;
   ob_lru.lru_insert_top(o);
   return o;
 }
 
-void ObjectCacher::close_object(Object *ob) 
+void ObjectCacher::close_object(Object *ob)
 {
   assert(lock.is_locked());
   ldout(cct, 10) << "close_object " << *ob << dendl;
   assert(ob->can_close());
-  
+
   // ok!
   ob_lru.lru_remove(ob);
   objects[ob->oloc.pool].erase(ob->get_soid());
@@ -657,9 +686,6 @@ void ObjectCacher::close_object(Object *ob)
   delete ob;
 }
 
-
-
-
 void ObjectCacher::bh_read(BufferHead *bh, int op_flags)
 {
   assert(lock.is_locked());
@@ -682,13 +708,13 @@ void ObjectCacher::bh_read(BufferHead *bh, int op_flags)
   ++reads_outstanding;
 }
 
-void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
-				  loff_t start, uint64_t length,
-				  bufferlist &bl, int r,
+void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid,
+				  ceph_tid_t tid, loff_t start,
+				  uint64_t length, bufferlist &bl, int r,
 				  bool trust_enoent)
 {
   assert(lock.is_locked());
-  ldout(cct, 7) << "bh_read_finish " 
+  ldout(cct, 7) << "bh_read_finish "
 		<< oid
 		<< " tid " << tid
 		<< " " << start << "~" << length
@@ -700,8 +726,9 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
   if (r >= 0 && bl.length() < length) {
     bufferptr bp(length - bl.length());
     bp.zero();
-    ldout(cct, 7) << "bh_read_finish " << oid << " padding " << start << "~" << length 
-	    << " with " << bp.length() << " bytes of zeroes" << dendl;
+    ldout(cct, 7) << "bh_read_finish " << oid << " padding " << start << "~"
+		  << length << " with " << bp.length() << " bytes of zeroes"
+		  << dendl;
     bl.push_back(bp);
   }
 
@@ -712,17 +739,20 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
     ldout(cct, 7) << "bh_read_finish no object cache" << dendl;
   } else {
     Object *ob = objects[poolid][oid];
-    
+
     if (r == -ENOENT && !ob->complete) {
-      // wake up *all* rx waiters, or else we risk reordering identical reads. e.g.
+      // wake up *all* rx waiters, or else we risk reordering
+      // identical reads. e.g.
       //   read 1~1
       //   reply to unrelated 3~1 -> !exists
       //   read 1~1 -> immediate ENOENT
       //   reply to first 1~1 -> ooo ENOENT
       bool allzero = true;
-      for (map<loff_t, BufferHead*>::iterator p = ob->data.begin(); p != ob->data.end(); ++p) {
+      for (map<loff_t, BufferHead*>::iterator p = ob->data.begin();
+	   p != ob->data.end(); ++p) {
 	BufferHead *bh = p->second;
-	for (map<loff_t, list<Context*> >::iterator p = bh->waitfor_read.begin();
+	for (map<loff_t, list<Context*> >::iterator p
+	       = bh->waitfor_read.begin();
 	     p != bh->waitfor_read.end();
 	     ++p)
 	  ls.splice(ls.end(), p->second);
@@ -734,7 +764,9 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
       // just pass through and retry all waiters if we don't trust
       // -ENOENT for this read
       if (trust_enoent) {
-	ldout(cct, 7) << "bh_read_finish ENOENT, marking complete and !exists on " << *ob << dendl;
+	ldout(cct, 7)
+	  << "bh_read_finish ENOENT, marking complete and !exists on " << *ob
+	  << dendl;
 	ob->complete = true;
 	ob->exists = false;
 
@@ -751,8 +783,9 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
 	 * returning -ENOENT immediately.
 	 */
 	if (allzero) {
-	  ldout(cct, 10) << "bh_read_finish ENOENT and allzero, getting rid of "
-			 << "bhs for " << *ob << dendl;
+	  ldout(cct, 10)
+	    << "bh_read_finish ENOENT and allzero, getting rid of "
+	    << "bhs for " << *ob << dendl;
 	  map<loff_t, BufferHead*>::iterator p = ob->data.begin();
 	  while (p != ob->data.end()) {
 	    BufferHead *bh = p->second;
@@ -782,29 +815,31 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
       ldout(cct, 20) << "checking bh " << *bh << dendl;
 
       // finishers?
-      for (map<loff_t, list<Context*> >::iterator it = bh->waitfor_read.begin();
-           it != bh->waitfor_read.end();
-           ++it)
+      for (map<loff_t, list<Context*> >::iterator it
+	     = bh->waitfor_read.begin();
+	   it != bh->waitfor_read.end();
+	   ++it)
 	ls.splice(ls.end(), it->second);
       bh->waitfor_read.clear();
 
       if (bh->start() > opos) {
-        ldout(cct, 1) << "bh_read_finish skipping gap "
+	ldout(cct, 1) << "bh_read_finish skipping gap "
 		      << opos << "~" << bh->start() - opos
 		      << dendl;
-        opos = bh->start();
-        continue;
+	opos = bh->start();
+	continue;
       }
 
       if (!bh->is_rx()) {
-        ldout(cct, 10) << "bh_read_finish skipping non-rx " << *bh << dendl;
-        opos = bh->end();
-        continue;
+	ldout(cct, 10) << "bh_read_finish skipping non-rx " << *bh << dendl;
+	opos = bh->end();
+	continue;
       }
 
       if (bh->last_read_tid != tid) {
-	ldout(cct, 10) << "bh_read_finish bh->last_read_tid " << bh->last_read_tid
-		       << " != tid " << tid << ", skipping" << dendl;
+	ldout(cct, 10) << "bh_read_finish bh->last_read_tid "
+		       << bh->last_read_tid << " != tid " << tid
+		       << ", skipping" << dendl;
 	opos = bh->end();
 	continue;
       }
@@ -857,6 +892,105 @@ void ObjectCacher::bh_read_finish(int64_t poolid, sobject_t oid, ceph_tid_t tid,
   read_cond.Signal();
 }
 
+void ObjectCacher::bh_write_adjacencies(BufferHead *bh, ceph::real_time cutoff,
+					int64_t *max_amount, int *max_count)
+{
+  list<BufferHead*> blist;
+
+  int count = 0;
+  int64_t total_len = 0;
+  set<BufferHead*, BufferHead::ptr_lt>::iterator it = dirty_or_tx_bh.find(bh);
+  assert(it != dirty_or_tx_bh.end());
+  for (set<BufferHead*, BufferHead::ptr_lt>::iterator p = it;
+       p != dirty_or_tx_bh.end();
+       ++p) {
+    BufferHead *obh = *p;
+    if (obh->ob != bh->ob)
+      break;
+    if (obh->is_dirty() && obh->last_write < cutoff) {
+      blist.push_back(obh);
+      ++count;
+      total_len += obh->length();
+      if ((max_count && count > *max_count) ||
+	  (max_amount && total_len > *max_amount))
+	break;
+    }
+  }
+
+  while (it != dirty_or_tx_bh.begin()) {
+    --it;
+    BufferHead *obh = *it;
+    if (obh->ob != bh->ob)
+      break;
+    if (obh->is_dirty() && obh->last_write < cutoff) {
+      blist.push_front(obh);
+      ++count;
+      total_len += obh->length();
+      if ((max_count && count > *max_count) ||
+	  (max_amount && total_len > *max_amount))
+	break;
+    }
+  }
+  if (max_count)
+    *max_count -= count;
+  if (max_amount)
+    *max_amount -= total_len;
+
+  bh_write_scattered(blist);
+}
+
+void ObjectCacher::bh_write_scattered(list<BufferHead*>& blist)
+{
+  assert(lock.is_locked());
+
+  Object *ob = blist.front()->ob;
+  ob->get();
+
+  ceph::real_time last_write;
+  SnapContext snapc;
+  vector<pair<loff_t, uint64_t> > ranges;
+  vector<pair<uint64_t, bufferlist> > io_vec;
+
+  ranges.reserve(blist.size());
+  io_vec.reserve(blist.size());
+
+  uint64_t total_len = 0;
+  for (list<BufferHead*>::iterator p = blist.begin(); p != blist.end(); ++p) {
+    BufferHead *bh = *p;
+    ldout(cct, 7) << "bh_write_scattered " << *bh << dendl;
+    assert(bh->ob == ob);
+    assert(bh->bl.length() == bh->length());
+    ranges.push_back(pair<loff_t, uint64_t>(bh->start(), bh->length()));
+
+    int n = io_vec.size();
+    io_vec.resize(n + 1);
+    io_vec[n].first = bh->start();
+    io_vec[n].second = bh->bl;
+
+    total_len += bh->length();
+    if (bh->snapc.seq > snapc.seq)
+      snapc = bh->snapc;
+    if (bh->last_write > last_write)
+      bh->last_write = bh->last_write;
+  }
+
+  C_WriteCommit *oncommit = new C_WriteCommit(this, ob->oloc.pool, ob->get_soid(), ranges);
+
+  ceph_tid_t tid = writeback_handler.write(ob->get_oid(), ob->get_oloc(),
+					   io_vec, snapc, last_write,
+					   ob->truncate_size, ob->truncate_seq,
+					   oncommit);
+  oncommit->tid = tid;
+  ob->last_write_tid = tid;
+  for (list<BufferHead*>::iterator p = blist.begin(); p != blist.end(); ++p) {
+    BufferHead *bh = *p;
+    bh->last_write_tid = tid;
+    mark_tx(bh);
+  }
+
+  if (perfcounter)
+    perfcounter->inc(l_objectcacher_data_flushed, total_len);
+}
 
 void ObjectCacher::bh_write(BufferHead *bh)
 {
@@ -867,14 +1001,16 @@ void ObjectCacher::bh_write(BufferHead *bh)
 
   // finishers
   C_WriteCommit *oncommit = new C_WriteCommit(this, bh->ob->oloc.pool,
-                                              bh->ob->get_soid(), bh->start(), bh->length());
+					      bh->ob->get_soid(), bh->start(),
+					      bh->length());
   // go
-  ceph_tid_t tid = writeback_handler.write(bh->ob->get_oid(), bh->ob->get_oloc(),
-                                           bh->start(), bh->length(),
-                                           bh->snapc, bh->bl, bh->last_write,
-                                           bh->ob->truncate_size,
-                                           bh->ob->truncate_seq,
-                                           bh->journal_tid, oncommit);
+  ceph_tid_t tid = writeback_handler.write(bh->ob->get_oid(),
+					   bh->ob->get_oloc(),
+					   bh->start(), bh->length(),
+					   bh->snapc, bh->bl, bh->last_write,
+					   bh->ob->truncate_size,
+					   bh->ob->truncate_seq,
+					   bh->journal_tid, oncommit);
   ldout(cct, 20) << " tid " << tid << " on " << bh->ob->get_oid() << dendl;
 
   // set bh last_write_tid
@@ -889,29 +1025,35 @@ void ObjectCacher::bh_write(BufferHead *bh)
   mark_tx(bh);
 }
 
-void ObjectCacher::bh_write_commit(int64_t poolid, sobject_t oid, loff_t start,
-				   uint64_t length, ceph_tid_t tid, int r)
+void ObjectCacher::bh_write_commit(int64_t poolid, sobject_t oid,
+				   vector<pair<loff_t, uint64_t> >& ranges,
+				   ceph_tid_t tid, int r)
 {
   assert(lock.is_locked());
-  ldout(cct, 7) << "bh_write_commit " 
-		<< oid 
-		<< " tid " << tid
-		<< " " << start << "~" << length
-		<< " returned " << r
-		<< dendl;
+  ldout(cct, 7) << "bh_write_commit " << oid << " tid " << tid
+		<< " ranges " << ranges << " returned " << r << dendl;
 
   if (objects[poolid].count(oid) == 0) {
     ldout(cct, 7) << "bh_write_commit no object cache" << dendl;
-  } else {
-    Object *ob = objects[poolid][oid];
-    int was_dirty_or_tx = ob->oset->dirty_or_tx;
-    
+    return;
+  }
+
+  Object *ob = objects[poolid][oid];
+  int was_dirty_or_tx = ob->oset->dirty_or_tx;
+
+  for (vector<pair<loff_t, uint64_t> >::iterator p = ranges.begin();
+       p != ranges.end();
+       ++p) {
+    loff_t start = p->first;
+    uint64_t length = p->second;
     if (!ob->exists) {
       ldout(cct, 10) << "bh_write_commit marking exists on " << *ob << dendl;
       ob->exists = true;
 
-      if (writeback_handler.may_copy_on_write(ob->get_oid(), start, length, ob->get_snap())) {
-	ldout(cct, 10) << "bh_write_commit may copy on write, clearing complete on " << *ob << dendl;
+      if (writeback_handler.may_copy_on_write(ob->get_oid(), start, length,
+					      ob->get_snap())) {
+	ldout(cct, 10) << "bh_write_commit may copy on write, clearing "
+	  "complete on " << *ob << dendl;
 	ob->complete = false;
       }
     }
@@ -919,36 +1061,36 @@ void ObjectCacher::bh_write_commit(int64_t poolid, sobject_t oid, loff_t start,
     list <BufferHead*> hit;
     // apply to bh's!
     for (map<loff_t, BufferHead*>::iterator p = ob->data_lower_bound(start);
-         p != ob->data.end();
-         ++p) {
+	 p != ob->data.end();
+	 ++p) {
       BufferHead *bh = p->second;
-      
+
       if (bh->start() > start+(loff_t)length)
 	break;
 
       if (bh->start() < start &&
-          bh->end() > start+(loff_t)length) {
-        ldout(cct, 20) << "bh_write_commit skipping " << *bh << dendl;
-        continue;
+	  bh->end() > start+(loff_t)length) {
+	ldout(cct, 20) << "bh_write_commit skipping " << *bh << dendl;
+	continue;
       }
-      
+
       // make sure bh is tx
       if (!bh->is_tx()) {
-        ldout(cct, 10) << "bh_write_commit skipping non-tx " << *bh << dendl;
-        continue;
+	ldout(cct, 10) << "bh_write_commit skipping non-tx " << *bh << dendl;
+	continue;
       }
-      
+
       // make sure bh tid matches
       if (bh->last_write_tid != tid) {
-        assert(bh->last_write_tid > tid);
-        ldout(cct, 10) << "bh_write_commit newer tid on " << *bh << dendl;
-        continue;
+	assert(bh->last_write_tid > tid);
+	ldout(cct, 10) << "bh_write_commit newer tid on " << *bh << dendl;
+	continue;
       }
 
       if (r >= 0) {
 	// ok!  mark bh clean and error-free
 	mark_clean(bh);
-        bh->set_journal_tid(0);
+	bh->set_journal_tid(0);
 	if (bh->get_nocache())
 	  bh_lru_rest.lru_bottouch(bh);
 	hit.push_back(bh);
@@ -967,53 +1109,59 @@ void ObjectCacher::bh_write_commit(int64_t poolid, sobject_t oid, loff_t start,
       assert(*bh);
       ob->try_merge_bh(*bh);
     }
+  }
 
-    // update last_commit.
-    assert(ob->last_commit_tid < tid);
-    ob->last_commit_tid = tid;
-
-    // waiters?
-    list<Context*> ls;
-    if (ob->waitfor_commit.count(tid)) {
-      ls.splice(ls.begin(), ob->waitfor_commit[tid]);
-      ob->waitfor_commit.erase(tid);
-    }
+  // update last_commit.
+  assert(ob->last_commit_tid < tid);
+  ob->last_commit_tid = tid;
 
-    // is the entire object set now clean and fully committed?
-    ObjectSet *oset = ob->oset;
-    ob->put();
+  // waiters?
+  list<Context*> ls;
+  if (ob->waitfor_commit.count(tid)) {
+    ls.splice(ls.begin(), ob->waitfor_commit[tid]);
+    ob->waitfor_commit.erase(tid);
+  }
 
-    if (flush_set_callback &&
-	was_dirty_or_tx > 0 &&
-	oset->dirty_or_tx == 0) {        // nothing dirty/tx
-      flush_set_callback(flush_set_callback_arg, oset);      
-    }
+  // is the entire object set now clean and fully committed?
+  ObjectSet *oset = ob->oset;
+  ob->put();
 
-    if (!ls.empty())
-      finish_contexts(cct, ls, r);
+  if (flush_set_callback &&
+      was_dirty_or_tx > 0 &&
+      oset->dirty_or_tx == 0) {        // nothing dirty/tx
+    flush_set_callback(flush_set_callback_arg, oset);
   }
+
+  if (!ls.empty())
+    finish_contexts(cct, ls, r);
 }
 
 void ObjectCacher::flush(loff_t amount)
 {
   assert(lock.is_locked());
-  utime_t cutoff = ceph_clock_now(cct);
+  ceph::real_time cutoff = ceph::real_clock::now();
 
   ldout(cct, 10) << "flush " << amount << dendl;
-  
+
   /*
-   * NOTE: we aren't actually pulling things off the LRU here, just looking at the
-   * tail item.  Then we call bh_write, which moves it to the other LRU, so that we
-   * can call lru_dirty.lru_get_next_expire() again.
+   * NOTE: we aren't actually pulling things off the LRU here, just
+   * looking at the tail item.  Then we call bh_write, which moves it
+   * to the other LRU, so that we can call
+   * lru_dirty.lru_get_next_expire() again.
    */
-  loff_t did = 0;
-  while (amount == 0 || did < amount) {
-    BufferHead *bh = static_cast<BufferHead*>(bh_lru_dirty.lru_get_next_expire());
+  int64_t left = amount;
+  while (amount == 0 || left > 0) {
+    BufferHead *bh = static_cast<BufferHead*>(
+      bh_lru_dirty.lru_get_next_expire());
     if (!bh) break;
     if (bh->last_write > cutoff) break;
 
-    did += bh->length();
-    bh_write(bh);
+    if (scattered_write) {
+      bh_write_adjacencies(bh, cutoff, amount > 0 ? &left : NULL, NULL);
+    } else {
+      left -= bh->length();
+      bh_write(bh);
+    }
   }    
 }
 
@@ -1021,9 +1169,9 @@ void ObjectCacher::flush(loff_t amount)
 void ObjectCacher::trim()
 {
   assert(lock.is_locked());
-  ldout(cct, 10) << "trim  start: bytes: max " << max_size << "  clean " << get_stat_clean()
-		 << ", objects: max " << max_objects << " current " << ob_lru.lru_get_size()
-		 << dendl;
+  ldout(cct, 10) << "trim  start: bytes: max " << max_size << "  clean "
+		 << get_stat_clean() << ", objects: max " << max_objects
+		 << " current " << ob_lru.lru_get_size() << dendl;
 
   while (get_stat_clean() > 0 && (uint64_t) get_stat_clean() > max_size) {
     BufferHead *bh = static_cast<BufferHead*>(bh_lru_rest.lru_expire());
@@ -1051,17 +1199,18 @@ void ObjectCacher::trim()
     ldout(cct, 10) << "trim trimming " << *ob << dendl;
     close_object(ob);
   }
-  
-  ldout(cct, 10) << "trim finish:  max " << max_size << "  clean " << get_stat_clean()
-		 << ", objects: max " << max_objects << " current " << ob_lru.lru_get_size()
-		 << dendl;
+
+  ldout(cct, 10) << "trim finish:  max " << max_size << "  clean "
+		 << get_stat_clean() << ", objects: max " << max_objects
+		 << " current " << ob_lru.lru_get_size() << dendl;
 }
 
 
 
 /* public */
 
-bool ObjectCacher::is_cached(ObjectSet *oset, vector<ObjectExtent>& extents, snapid_t snapid)
+bool ObjectCacher::is_cached(ObjectSet *oset, vector<ObjectExtent>& extents,
+			     snapid_t snapid)
 {
   assert(lock.is_locked());
   for (vector<ObjectExtent>::iterator ex_it = extents.begin();
@@ -1082,7 +1231,8 @@ bool ObjectCacher::is_cached(ObjectSet *oset, vector<ObjectExtent>& extents, sna
 
 
 /*
- * returns # bytes read (if in cache).  onfinish is untouched (caller must delete it)
+ * returns # bytes read (if in cache).  onfinish is untouched (caller
+ *           must delete it)
  * returns 0 if doing async read
  */
 int ObjectCacher::readx(OSDRead *rd, ObjectSet *oset, Context *onfinish)
@@ -1119,7 +1269,8 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 
     // get Object cache
     sobject_t soid(ex_it->oid, rd->snap);
-    Object *o = get_object(soid, ex_it->objectno, oset, ex_it->oloc, ex_it->truncate_size, oset->truncate_seq);
+    Object *o = get_object(soid, ex_it->objectno, oset, ex_it->oloc,
+			   ex_it->truncate_size, oset->truncate_seq);
     if (external_call)
       touch_ob(o);
 
@@ -1127,10 +1278,12 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
     if (oset->return_enoent && !o->exists) {
       ldout(cct, 10) << "readx  object !exists, 1 extent..." << dendl;
 
-      // should we worry about COW underneaeth us?
-      if (writeback_handler.may_copy_on_write(soid.oid, ex_it->offset, ex_it->length, soid.snap)) {
+      // should we worry about COW underneath us?
+      if (writeback_handler.may_copy_on_write(soid.oid, ex_it->offset,
+					      ex_it->length, soid.snap)) {
 	ldout(cct, 20) << "readx  may copy on write" << dendl;
 	bool wait = false;
+	list<BufferHead*> blist;
 	for (map<loff_t, BufferHead*>::iterator bh_it = o->data.begin();
 	     bh_it != o->data.end();
 	     ++bh_it) {
@@ -1138,13 +1291,21 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 	  if (bh->is_dirty() || bh->is_tx()) {
 	    ldout(cct, 10) << "readx  flushing " << *bh << dendl;
 	    wait = true;
-	    if (bh->is_dirty())
-	      bh_write(bh);
+	    if (bh->is_dirty()) {
+	      if (scattered_write)
+		blist.push_back(bh);
+	      else
+		bh_write(bh);
+	    }
 	  }
 	}
+	if (scattered_write && !blist.empty())
+	  bh_write_scattered(blist);
 	if (wait) {
-	  ldout(cct, 10) << "readx  waiting on tid " << o->last_write_tid << " on " << *o << dendl;
-	  o->waitfor_commit[o->last_write_tid].push_back(new C_RetryRead(this, rd, oset, onfinish));
+	  ldout(cct, 10) << "readx  waiting on tid " << o->last_write_tid
+			 << " on " << *o << dendl;
+	  o->waitfor_commit[o->last_write_tid].push_back(
+	    new C_RetryRead(this,rd, oset, onfinish));
 	  // FIXME: perfcounter!
 	  return 0;
 	}
@@ -1162,7 +1323,8 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 	}
       }
       if (allzero) {
-	ldout(cct, 10) << "readx  ob has all zero|rx, returning ENOENT" << dendl;
+	ldout(cct, 10) << "readx  ob has all zero|rx, returning ENOENT"
+		       << dendl;
 	delete rd;
 	if (dontneed)
 	  bottouch_ob(o);
@@ -1178,7 +1340,7 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
       missing.insert(errors.begin(), errors.end());
     } else {
       // some reads had errors, fail later so completions
-      // are cleaned up up properly
+      // are cleaned up properly
       // TODO: make read path not call _readx for every completion
       hits.insert(errors.begin(), errors.end());
     }
@@ -1187,11 +1349,11 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
       // read missing
       map<loff_t, BufferHead*>::iterator last = missing.end();
       for (map<loff_t, BufferHead*>::iterator bh_it = missing.begin();
-           bh_it != missing.end();
-           ++bh_it) {
+	   bh_it != missing.end();
+	   ++bh_it) {
 	uint64_t rx_bytes = static_cast<uint64_t>(
 	  stat_rx + bh_it->second->length());
-        bytes_not_in_cache += bh_it->second->length();
+	bytes_not_in_cache += bh_it->second->length();
 	if (!waitfor_read.empty() || (stat_rx > 0 && rx_bytes > max_size)) {
 	  // cache is full with concurrent reads -- wait for rx's to complete
 	  // to constrain memory growth (especially during copy-ups)
@@ -1218,40 +1380,43 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
       if (last != missing.end()) {
 	ldout(cct, 10) << "readx missed, waiting on " << *last->second
 	  << " off " << last->first << dendl;
-	last->second->waitfor_read[last->first].push_back( new C_RetryRead(this, rd, oset, onfinish) );
+	last->second->waitfor_read[last->first].push_back(
+	  new C_RetryRead(this, rd, oset, onfinish) );
 
       }
 
       // bump rx
       for (map<loff_t, BufferHead*>::iterator bh_it = rx.begin();
-           bh_it != rx.end();
-           ++bh_it) {
-        touch_bh(bh_it->second);        // bump in lru, so we don't lose it.
-        if (success && onfinish) {
-          ldout(cct, 10) << "readx missed, waiting on " << *bh_it->second 
-                   << " off " << bh_it->first << dendl;
-	  bh_it->second->waitfor_read[bh_it->first].push_back( new C_RetryRead(this, rd, oset, onfinish) );
-        }
-        bytes_not_in_cache += bh_it->second->length();
+	   bh_it != rx.end();
+	   ++bh_it) {
+	touch_bh(bh_it->second); // bump in lru, so we don't lose it.
+	if (success && onfinish) {
+	  ldout(cct, 10) << "readx missed, waiting on " << *bh_it->second
+			 << " off " << bh_it->first << dendl;
+	  bh_it->second->waitfor_read[bh_it->first].push_back(
+	    new C_RetryRead(this, rd, oset, onfinish) );
+	}
+	bytes_not_in_cache += bh_it->second->length();
 	success = false;
       }
 
       for (map<loff_t, BufferHead*>::iterator bh_it = hits.begin();
-           bh_it != hits.end();  ++bh_it)
-	touch_bh(bh_it->second); //bump in lru, so we don't lose it when later read
+	   bh_it != hits.end();  ++bh_it)
+	//bump in lru, so we don't lose it when later read
+	touch_bh(bh_it->second);
 
     } else {
       assert(!hits.empty());
 
       // make a plain list
       for (map<loff_t, BufferHead*>::iterator bh_it = hits.begin();
-           bh_it != hits.end();
-           ++bh_it) {
+	   bh_it != hits.end();
+	   ++bh_it) {
 	BufferHead *bh = bh_it->second;
 	ldout(cct, 10) << "readx hit bh " << *bh << dendl;
 	if (bh->is_error() && bh->error)
 	  error = bh->error;
-        bytes_in_cache += bh->length();
+	bytes_in_cache += bh->length();
 
 	if (bh->get_nocache() && bh->is_clean())
 	  bh_lru_rest.lru_bottouch(bh);
@@ -1259,7 +1424,8 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 	  touch_bh(bh);
 	//must be after touch_bh because touch_bh set dontneed false
 	if (dontneed &&
-	    ((loff_t)ex_it->offset <= bh->start() && (bh->end() <= (loff_t)(ex_it->offset + ex_it->length)))) {
+	    ((loff_t)ex_it->offset <= bh->start() &&
+	     (bh->end() <=(loff_t)(ex_it->offset + ex_it->length)))) {
 	  bh->set_dontneed(true); //if dirty
 	  if (bh->is_clean())
 	    bh_lru_rest.lru_bottouch(bh);
@@ -1267,28 +1433,31 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
       }
 
       if (!error) {
-	// create reverse map of buffer offset -> object for the eventual result.
-	// this is over a single ObjectExtent, so we know that
+	// create reverse map of buffer offset -> object for the
+	// eventual result.  this is over a single ObjectExtent, so we
+	// know that
 	//  - the bh's are contiguous
 	//  - the buffer frags need not be (and almost certainly aren't)
 	loff_t opos = ex_it->offset;
 	map<loff_t, BufferHead*>::iterator bh_it = hits.begin();
 	assert(bh_it->second->start() <= opos);
 	uint64_t bhoff = opos - bh_it->second->start();
-	vector<pair<uint64_t,uint64_t> >::iterator f_it = ex_it->buffer_extents.begin();
+	vector<pair<uint64_t,uint64_t> >::iterator f_it
+	  = ex_it->buffer_extents.begin();
 	uint64_t foff = 0;
 	while (1) {
 	  BufferHead *bh = bh_it->second;
 	  assert(opos == (loff_t)(bh->start() + bhoff));
 
 	  uint64_t len = MIN(f_it->second - foff, bh->length() - bhoff);
-	  ldout(cct, 10) << "readx rmap opos " << opos
-	    << ": " << *bh << " +" << bhoff
-	    << " frag " << f_it->first << "~" << f_it->second << " +" << foff << "~" << len
-	    << dendl;
-
-	  bufferlist bit;  // put substr here first, since substr_of clobbers, and
-	  // we may get multiple bh's at this stripe_map position
+	  ldout(cct, 10) << "readx rmap opos " << opos << ": " << *bh << " +"
+			 << bhoff << " frag " << f_it->first << "~"
+			 << f_it->second << " +" << foff << "~" << len
+			 << dendl;
+
+	  bufferlist bit;
+	  // put substr here first, since substr_of clobbers, and we
+	  // may get multiple bh's at this stripe_map position
 	  if (bh->is_zero()) {
 	    bufferptr bp(len);
 	    bp.zero();
@@ -1323,7 +1492,7 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 	  bottouch_ob(o);
     }
   }
-  
+
   if (!success) {
     if (perfcounter && external_call) {
       perfcounter->inc(l_objectcacher_data_read, total_bytes_read);
@@ -1333,7 +1502,8 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
     if (onfinish) {
       ldout(cct, 20) << "readx defer " << rd << dendl;
     } else {
-      ldout(cct, 20) << "readx drop " << rd << " (no complete, but no waiter)" << dendl;
+      ldout(cct, 20) << "readx drop " << rd << " (no complete, but no waiter)"
+		     << dendl;
       delete rd;
     }
     return 0;  // wait!
@@ -1355,7 +1525,8 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
 	 i != stripe_map.end();
 	 ++i) {
       assert(pos == i->first);
-      ldout(cct, 10) << "readx  adding buffer len " << i->second.length() << " at " << pos << dendl;
+      ldout(cct, 10) << "readx  adding buffer len " << i->second.length()
+		     << " at " << pos << dendl;
       pos += i->second.length();
       rd->bl->claim_append(i->second);
       assert(rd->bl->length() == pos);
@@ -1395,12 +1566,12 @@ void ObjectCacher::retry_waiting_reads()
 int ObjectCacher::writex(OSDWrite *wr, ObjectSet *oset, Context *onfreespace)
 {
   assert(lock.is_locked());
-  utime_t now = ceph_clock_now(cct);
+  ceph::real_time now = ceph::real_clock::now();
   uint64_t bytes_written = 0;
   uint64_t bytes_written_in_flush = 0;
   bool dontneed = wr->fadvise_flags & LIBRADOS_OP_FLAG_FADVISE_DONTNEED;
   bool nocache = wr->fadvise_flags & LIBRADOS_OP_FLAG_FADVISE_NOCACHE;
-  
+
   for (vector<ObjectExtent>::iterator ex_it = wr->extents.begin();
        ex_it != wr->extents.end();
        ++ex_it) {
@@ -1413,7 +1584,7 @@ int ObjectCacher::writex(OSDWrite *wr, ObjectSet *oset, Context *onfreespace)
     BufferHead *bh = o->map_write(wr);
     bool missing = bh->is_missing();
     bh->snapc = wr->snapc;
-    
+
     bytes_written += bh->length();
     if (bh->is_tx()) {
       bytes_written_in_flush += bh->length();
@@ -1425,17 +1596,20 @@ int ObjectCacher::writex(OSDWrite *wr, ObjectSet *oset, Context *onfreespace)
     //  - the buffer frags need not be (and almost certainly aren't)
     // note: i assume striping is monotonic... no jumps backwards, ever!
     loff_t opos = ex_it->offset;
-    for (vector<pair<uint64_t, uint64_t> >::iterator f_it = ex_it->buffer_extents.begin();
-         f_it != ex_it->buffer_extents.end();
-         ++f_it) {
-      ldout(cct, 10) << "writex writing " << f_it->first << "~" << f_it->second << " into " << *bh << " at " << opos << dendl;
+    for (vector<pair<uint64_t, uint64_t> >::iterator f_it
+	   = ex_it->buffer_extents.begin();
+	 f_it != ex_it->buffer_extents.end();
+	 ++f_it) {
+      ldout(cct, 10) << "writex writing " << f_it->first << "~"
+		     << f_it->second << " into " << *bh << " at " << opos
+		     << dendl;
       uint64_t bhoff = bh->start() - opos;
       assert(f_it->second <= bh->length() - bhoff);
 
       // get the frag we're mapping in
-      bufferlist frag; 
-      frag.substr_of(wr->bl, 
-                     f_it->first, f_it->second);
+      bufferlist frag;
+      frag.substr_of(wr->bl,
+		     f_it->first, f_it->second);
 
       // keep anything left of bhoff
       bufferlist newbl;
@@ -1465,7 +1639,7 @@ int ObjectCacher::writex(OSDWrite *wr, ObjectSet *oset, Context *onfreespace)
     perfcounter->inc(l_objectcacher_data_written, bytes_written);
     if (bytes_written_in_flush) {
       perfcounter->inc(l_objectcacher_overwritten_in_flush,
-                       bytes_written_in_flush);
+		       bytes_written_in_flush);
     }
   }
 
@@ -1487,7 +1661,7 @@ void ObjectCacher::C_WaitForWrite::finish(int r)
 void ObjectCacher::maybe_wait_for_writeback(uint64_t len)
 {
   assert(lock.is_locked());
-  utime_t start = ceph_clock_now(cct);
+  ceph::mono_time start = ceph::mono_clock::now();
   int blocked = 0;
   // wait for writeback?
   //  - wait for dirty and tx bytes (relative to the max_dirty threshold)
@@ -1511,13 +1685,14 @@ void ObjectCacher::maybe_wait_for_writeback(uint64_t len)
   if (blocked && perfcounter) {
     perfcounter->inc(l_objectcacher_write_ops_blocked);
     perfcounter->inc(l_objectcacher_write_bytes_blocked, len);
-    utime_t blocked = ceph_clock_now(cct) - start;
+    ceph::timespan blocked = ceph::mono_clock::now() - start;
     perfcounter->tinc(l_objectcacher_write_time_blocked, blocked);
   }
 }
 
 // blocking wait for write.
-int ObjectCacher::_wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset, Context *onfreespace)
+int ObjectCacher::_wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset,
+				  Context *onfreespace)
 {
   assert(lock.is_locked());
   int ret = 0;
@@ -1540,7 +1715,8 @@ int ObjectCacher::_wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset, C
     assert(fin);
     bool flushed = flush_set(oset, wr->extents, fin);
     assert(!flushed);   // we just dirtied it, and didn't drop our lock!
-    ldout(cct, 10) << "wait_for_write waiting on write-thru of " << len << " bytes" << dendl;
+    ldout(cct, 10) << "wait_for_write waiting on write-thru of " << len
+		   << " bytes" << dendl;
     if (block_writes_upfront) {
       while (!done)
 	cond.Wait(lock);
@@ -1565,7 +1741,8 @@ void ObjectCacher::flusher_entry()
   writeback_handler.get_client_lock();
   lock.Lock();
   while (!flusher_stop) {
-    loff_t all = get_stat_tx() + get_stat_rx() + get_stat_clean() + get_stat_dirty();
+    loff_t all = get_stat_tx() + get_stat_rx() + get_stat_clean() +
+      get_stat_dirty();
     ldout(cct, 11) << "flusher "
 		   << all << " / " << max_size << ":  "
 		   << get_stat_tx() << " tx, "
@@ -1578,29 +1755,33 @@ void ObjectCacher::flusher_entry()
     loff_t actual = get_stat_dirty() + get_stat_dirty_waiting();
     if (actual > 0 && (uint64_t) actual > target_dirty) {
       // flush some dirty pages
-      ldout(cct, 10) << "flusher " 
-		     << get_stat_dirty() << " dirty + " << get_stat_dirty_waiting()
-		     << " dirty_waiting > target "
-		     << target_dirty
-		     << ", flushing some dirty bhs" << dendl;
+      ldout(cct, 10) << "flusher " << get_stat_dirty() << " dirty + "
+		     << get_stat_dirty_waiting() << " dirty_waiting > target "
+		     << target_dirty << ", flushing some dirty bhs" << dendl;
       flush(actual - target_dirty);
     } else {
       // check tail of lru for old dirty items
-      utime_t cutoff = ceph_clock_now(cct);
+      ceph::real_time cutoff = ceph::real_clock::now();
       cutoff -= max_dirty_age;
       BufferHead *bh = 0;
       int max = MAX_FLUSH_UNDER_LOCK;
-      while ((bh = static_cast<BufferHead*>(bh_lru_dirty.lru_get_next_expire())) != 0 &&
+      while ((bh = static_cast<BufferHead*>(bh_lru_dirty.
+					    lru_get_next_expire())) != 0 &&
 	     bh->last_write < cutoff &&
-	     --max > 0) {
+	     max > 0) {
 	ldout(cct, 10) << "flusher flushing aged dirty bh " << *bh << dendl;
-	bh_write(bh);
+	if (scattered_write) {
+	  bh_write_adjacencies(bh, cutoff, NULL, &max);
+        } else {
+	  bh_write(bh);
+	  --max;
+	}
       }
       if (!max) {
 	// back off the lock to avoid starving other threads
 	lock.Unlock();
-        writeback_handler.put_client_lock();
-        writeback_handler.get_client_lock();
+	writeback_handler.put_client_lock();
+	writeback_handler.get_client_lock();
 	lock.Lock();
 	continue;
       }
@@ -1609,7 +1790,7 @@ void ObjectCacher::flusher_entry()
       break;
 
     writeback_handler.put_client_lock();
-    flusher_cond.WaitInterval(cct, lock, utime_t(1,0));
+    flusher_cond.WaitInterval(cct, lock, seconds(1));
     lock.Unlock();
 
     writeback_handler.get_client_lock();
@@ -1654,16 +1835,16 @@ bool ObjectCacher::set_is_cached(ObjectSet *oset)
   assert(lock.is_locked());
   if (oset->objects.empty())
     return false;
-  
+
   for (xlist<Object*>::iterator p = oset->objects.begin();
        !p.end(); ++p) {
     Object *ob = *p;
     for (map<loff_t,BufferHead*>::iterator q = ob->data.begin();
-         q != ob->data.end();
-         ++q) {
+	 q != ob->data.end();
+	 ++q) {
       BufferHead *bh = q->second;
-      if (!bh->is_dirty() && !bh->is_tx()) 
-        return true;
+      if (!bh->is_dirty() && !bh->is_tx())
+	return true;
     }
   }
 
@@ -1675,20 +1856,20 @@ bool ObjectCacher::set_is_dirty_or_committing(ObjectSet *oset)
   assert(lock.is_locked());
   if (oset->objects.empty())
     return false;
-  
+
   for (xlist<Object*>::iterator i = oset->objects.begin();
        !i.end(); ++i) {
     Object *ob = *i;
-    
+
     for (map<loff_t,BufferHead*>::iterator p = ob->data.begin();
-         p != ob->data.end();
-         ++p) {
+	 p != ob->data.end();
+	 ++p) {
       BufferHead *bh = p->second;
-      if (bh->is_dirty() || bh->is_tx()) 
-        return true;
+      if (bh->is_dirty() || bh->is_tx())
+	return true;
     }
-  }  
-  
+  }
+
   return false;
 }
 
@@ -1704,15 +1885,18 @@ void ObjectCacher::purge(Object *ob)
 
 
 // flush.  non-blocking.  no callback.
-// true if clean, already flushed.  
+// true if clean, already flushed.
 // false if we wrote something.
 // be sloppy about the ranges and flush any buffer it touches
 bool ObjectCacher::flush(Object *ob, loff_t offset, loff_t length)
 {
   assert(lock.is_locked());
+  list<BufferHead*> blist;
   bool clean = true;
   ldout(cct, 10) << "flush " << *ob << " " << offset << "~" << length << dendl;
-  for (map<loff_t,BufferHead*>::iterator p = ob->data_lower_bound(offset); p != ob->data.end(); ++p) {
+  for (map<loff_t,BufferHead*>::iterator p = ob->data_lower_bound(offset);
+       p != ob->data.end();
+       ++p) {
     BufferHead *bh = p->second;
     ldout(cct, 20) << "flush  " << *bh << dendl;
     if (length && bh->start() > offset+length) {
@@ -1725,13 +1909,21 @@ bool ObjectCacher::flush(Object *ob, loff_t offset, loff_t length)
     if (!bh->is_dirty()) {
       continue;
     }
-    bh_write(bh);
+
+    if (scattered_write)
+      blist.push_back(bh);
+    else
+      bh_write(bh);
     clean = false;
   }
+  if (scattered_write && !blist.empty())
+    bh_write_scattered(blist);
+
   return clean;
 }
 
-bool ObjectCacher::_flush_set_finish(C_GatherBuilder *gather, Context *onfinish)
+bool ObjectCacher::_flush_set_finish(C_GatherBuilder *gather,
+				     Context *onfinish)
 {
   assert(lock.is_locked());
   if (gather->has_subs()) {
@@ -1763,28 +1955,84 @@ bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish)
   C_GatherBuilder gather(cct);
   set<Object*> waitfor_commit;
 
-  set<BufferHead*>::iterator next, it;
-  next = it = dirty_or_tx_bh.begin();
-  while (it != dirty_or_tx_bh.end()) {
-    ++next;
-    BufferHead *bh = *it;
-    waitfor_commit.insert(bh->ob);
+  list<BufferHead*> blist;
+  Object *last_ob = NULL;
+  set<BufferHead*, BufferHead::ptr_lt>::iterator it, p, q;
 
-    if (bh->is_dirty())
-      bh_write(bh);
+  // Buffer heads in dirty_or_tx_bh are sorted in ObjectSet/Object/offset
+  // order. But items in oset->objects are not sorted. So the iterator can
+  // point to any buffer head in the ObjectSet
+  BufferHead key(*oset->objects.begin());
+  it = dirty_or_tx_bh.lower_bound(&key);
+  p = q = it;
 
-    it = next;
+  bool backwards = true;
+  if (it != dirty_or_tx_bh.begin())
+    --it;
+  else
+    backwards = false;
+
+  for (; p != dirty_or_tx_bh.end(); p = q) {
+    ++q;
+    BufferHead *bh = *p;
+    if (bh->ob->oset != oset)
+      break;
+    waitfor_commit.insert(bh->ob);
+    if (bh->is_dirty()) {
+      if (scattered_write) {
+	if (last_ob != bh->ob) {
+	  if (!blist.empty()) {
+	    bh_write_scattered(blist);
+	    blist.clear();
+	  }
+	  last_ob = bh->ob;
+	}
+	blist.push_back(bh);
+      } else {
+	bh_write(bh);
+      }
+    }
   }
 
+  if (backwards) {
+    for(p = q = it; true; p = q) {
+      if (q != dirty_or_tx_bh.begin())
+	--q;
+      else
+	backwards = false;
+      BufferHead *bh = *p;
+      if (bh->ob->oset != oset)
+	break;
+      waitfor_commit.insert(bh->ob);
+      if (bh->is_dirty()) {
+	if (scattered_write) {
+	  if (last_ob != bh->ob) {
+	    if (!blist.empty()) {
+	      bh_write_scattered(blist);
+	      blist.clear();
+	    }
+	    last_ob = bh->ob;
+	  }
+	  blist.push_front(bh);
+	} else {
+	  bh_write(bh);
+	}
+      }
+      if (!backwards)
+	break;
+    }
+  }
+
+  if (scattered_write && !blist.empty())
+    bh_write_scattered(blist);
+
   for (set<Object*>::iterator i = waitfor_commit.begin();
        i != waitfor_commit.end(); ++i) {
     Object *ob = *i;
 
     // we'll need to gather...
     ldout(cct, 10) << "flush_set " << oset << " will wait for ack tid "
-             << ob->last_write_tid
-             << " on " << *ob
-             << dendl;
+		   << ob->last_write_tid << " on " << *ob << dendl;
     ob->waitfor_commit[ob->last_write_tid].push_back(gather.new_sub());
   }
 
@@ -1793,7 +2041,8 @@ bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish)
 
 // flush.  non-blocking, takes callback.
 // returns true if already flushed
-bool ObjectCacher::flush_set(ObjectSet *oset, vector<ObjectExtent>& exv, Context *onfinish)
+bool ObjectCacher::flush_set(ObjectSet *oset, vector<ObjectExtent>& exv,
+			     Context *onfinish)
 {
   assert(lock.is_locked());
   assert(onfinish != NULL);
@@ -1818,11 +2067,12 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector<ObjectExtent>& exv, Context
       continue;
     Object *ob = objects[oset->poolid][soid];
 
-    ldout(cct, 20) << "flush_set " << oset << " ex " << ex << " ob " << soid << " " << ob << dendl;
+    ldout(cct, 20) << "flush_set " << oset << " ex " << ex << " ob " << soid
+		   << " " << ob << dendl;
 
     if (!flush(ob, ex.offset, ex.length)) {
       // we'll need to gather...
-      ldout(cct, 10) << "flush_set " << oset << " will wait for ack tid " 
+      ldout(cct, 10) << "flush_set " << oset << " will wait for ack tid "
 		     << ob->last_write_tid << " on " << *ob << dendl;
       ob->waitfor_commit[ob->last_write_tid].push_back(gather.new_sub());
     }
@@ -1831,6 +2081,63 @@ bool ObjectCacher::flush_set(ObjectSet *oset, vector<ObjectExtent>& exv, Context
   return _flush_set_finish(&gather, onfinish);
 }
 
+// flush all dirty data.  non-blocking, takes callback.
+// returns true if already flushed
+bool ObjectCacher::flush_all(Context *onfinish)
+{
+  assert(lock.is_locked());
+  assert(onfinish != NULL);
+
+  ldout(cct, 10) << "flush_all " << dendl;
+
+  // we'll need to wait for all objects to flush!
+  C_GatherBuilder gather(cct);
+  set<Object*> waitfor_commit;
+
+  list<BufferHead*> blist;
+  Object *last_ob = NULL;
+  set<BufferHead*, BufferHead::ptr_lt>::iterator next, it;
+  next = it = dirty_or_tx_bh.begin();
+  while (it != dirty_or_tx_bh.end()) {
+    ++next;
+    BufferHead *bh = *it;
+    waitfor_commit.insert(bh->ob);
+
+    if (bh->is_dirty()) {
+      if (scattered_write) {
+	if (last_ob != bh->ob) {
+	  if (!blist.empty()) {
+	    bh_write_scattered(blist);
+	    blist.clear();
+	  }
+	  last_ob = bh->ob;
+	}
+	blist.push_back(bh);
+      } else {
+	bh_write(bh);
+      }
+    }
+
+    it = next;
+  }
+
+  if (scattered_write && !blist.empty())
+    bh_write_scattered(blist);
+
+  for (set<Object*>::iterator i = waitfor_commit.begin();
+       i != waitfor_commit.end();
+       ++i) {
+    Object *ob = *i;
+
+    // we'll need to gather...
+    ldout(cct, 10) << "flush_all will wait for ack tid "
+		   << ob->last_write_tid << " on " << *ob << dendl;
+    ob->waitfor_commit[ob->last_write_tid].push_back(gather.new_sub());
+  }
+
+  return _flush_set_finish(&gather, onfinish);
+}
+
 void ObjectCacher::purge_set(ObjectSet *oset)
 {
   assert(lock.is_locked());
@@ -1869,7 +2176,7 @@ loff_t ObjectCacher::release(Object *ob)
     BufferHead *bh = p->second;
     if (bh->is_clean() || bh->is_zero() || bh->is_error())
       clean.push_back(bh);
-    else 
+    else
       o_unclean += bh->length();
   }
 
@@ -1922,16 +2229,16 @@ loff_t ObjectCacher::release_set(ObjectSet *oset)
     loff_t o_unclean = release(ob);
     unclean += o_unclean;
 
-    if (o_unclean) 
-      ldout(cct, 10) << "release_set " << oset << " " << *ob 
-               << " has " << o_unclean << " bytes left"
-               << dendl;
+    if (o_unclean)
+      ldout(cct, 10) << "release_set " << oset << " " << *ob
+		     << " has " << o_unclean << " bytes left"
+		     << dendl;
     p = q;
   }
 
   if (unclean) {
     ldout(cct, 10) << "release_set " << oset
-             << ", " << unclean << " bytes left" << dendl;
+		   << ", " << unclean << " bytes left" << dendl;
   }
 
   return unclean;
@@ -1943,8 +2250,9 @@ uint64_t ObjectCacher::release_all()
   assert(lock.is_locked());
   ldout(cct, 10) << "release_all" << dendl;
   uint64_t unclean = 0;
-  
-  vector<ceph::unordered_map<sobject_t, Object*> >::iterator i = objects.begin();
+
+  vector<ceph::unordered_map<sobject_t, Object*> >::iterator i
+    = objects.begin();
   while (i != objects.end()) {
     ceph::unordered_map<sobject_t, Object*>::iterator p = i->begin();
     while (p != i->end()) {
@@ -1957,16 +2265,17 @@ uint64_t ObjectCacher::release_all()
       unclean += o_unclean;
 
       if (o_unclean)
-        ldout(cct, 10) << "release_all " << *ob
-        << " has " << o_unclean << " bytes left"
-        << dendl;
+	ldout(cct, 10) << "release_all " << *ob
+		       << " has " << o_unclean << " bytes left"
+		       << dendl;
     p = n;
     }
     ++i;
   }
 
   if (unclean) {
-    ldout(cct, 10) << "release_all unclean " << unclean << " bytes left" << dendl;
+    ldout(cct, 10) << "release_all unclean " << unclean << " bytes left"
+		   << dendl;
   }
 
   return unclean;
@@ -1994,7 +2303,8 @@ void ObjectCacher::clear_nonexistence(ObjectSet *oset)
 }
 
 /**
- * discard object extents from an ObjectSet by removing the objects in exls from the in-memory oset.
+ * discard object extents from an ObjectSet by removing the objects in
+ * exls from the in-memory oset.
  */
 void ObjectCacher::discard_set(ObjectSet *oset, const vector<ObjectExtent>& exls)
 {
@@ -2003,7 +2313,7 @@ void ObjectCacher::discard_set(ObjectSet *oset, const vector<ObjectExtent>& exls
     ldout(cct, 10) << "discard_set on " << oset << " dne" << dendl;
     return;
   }
-  
+
   ldout(cct, 10) << "discard_set " << oset << dendl;
 
   bool were_dirty = oset->dirty_or_tx > 0;
@@ -2017,7 +2327,7 @@ void ObjectCacher::discard_set(ObjectSet *oset, const vector<ObjectExtent>& exls
     if (objects[oset->poolid].count(soid) == 0)
       continue;
     Object *ob = objects[oset->poolid][soid];
-    
+
     ob->discard(ex.offset, ex.length);
   }
 
@@ -2032,54 +2342,53 @@ void ObjectCacher::verify_stats() const
   assert(lock.is_locked());
   ldout(cct, 10) << "verify_stats" << dendl;
 
-  loff_t clean = 0, zero = 0, dirty = 0, rx = 0, tx = 0, missing = 0, error = 0;
-  for (vector<ceph::unordered_map<sobject_t, Object*> >::const_iterator i = objects.begin();
-      i != objects.end();
-      ++i) {
-    for (ceph::unordered_map<sobject_t, Object*>::const_iterator p = i->begin();
-        p != i->end();
-        ++p) {
+  loff_t clean = 0, zero = 0, dirty = 0, rx = 0, tx = 0, missing = 0,
+    error = 0;
+  for (vector<ceph::unordered_map<sobject_t, Object*> >::const_iterator i
+	 = objects.begin();
+       i != objects.end();
+       ++i) {
+    for (ceph::unordered_map<sobject_t, Object*>::const_iterator p
+	   = i->begin();
+	 p != i->end();
+	 ++p) {
       Object *ob = p->second;
       for (map<loff_t, BufferHead*>::const_iterator q = ob->data.begin();
-          q != ob->data.end();
-          ++q) {
-        BufferHead *bh = q->second;
-        switch (bh->get_state()) {
-        case BufferHead::STATE_MISSING:
-          missing += bh->length();
-          break;
-        case BufferHead::STATE_CLEAN:
-          clean += bh->length();
-          break;
-        case BufferHead::STATE_ZERO:
-          zero += bh->length();
-          break;
-        case BufferHead::STATE_DIRTY:
-          dirty += bh->length();
-          break;
-        case BufferHead::STATE_TX:
-          tx += bh->length();
-          break;
-        case BufferHead::STATE_RX:
-          rx += bh->length();
-          break;
+	   q != ob->data.end();
+	  ++q) {
+	BufferHead *bh = q->second;
+	switch (bh->get_state()) {
+	case BufferHead::STATE_MISSING:
+	  missing += bh->length();
+	  break;
+	case BufferHead::STATE_CLEAN:
+	  clean += bh->length();
+	  break;
+	case BufferHead::STATE_ZERO:
+	  zero += bh->length();
+	  break;
+	case BufferHead::STATE_DIRTY:
+	  dirty += bh->length();
+	  break;
+	case BufferHead::STATE_TX:
+	  tx += bh->length();
+	  break;
+	case BufferHead::STATE_RX:
+	  rx += bh->length();
+	  break;
 	case BufferHead::STATE_ERROR:
 	  error += bh->length();
 	  break;
-        default:
-          assert(0);
-        }
+	default:
+	  assert(0);
+	}
       }
     }
   }
 
-  ldout(cct, 10) << " clean " << clean
-	   << " rx " << rx 
-	   << " tx " << tx
-	   << " dirty " << dirty
-	   << " missing " << missing
-	   << " error " << error
-	   << dendl;
+  ldout(cct, 10) << " clean " << clean << " rx " << rx << " tx " << tx
+		 << " dirty " << dirty << " missing " << missing
+		 << " error " << error << dendl;
   assert(clean == stat_clean);
   assert(rx == stat_rx);
   assert(tx == stat_tx);
@@ -2167,7 +2476,7 @@ void ObjectCacher::bh_set_state(BufferHead *bh, int s)
   if (s == BufferHead::STATE_DIRTY && state != BufferHead::STATE_DIRTY) {
     bh_lru_rest.lru_remove(bh);
     bh_lru_dirty.lru_insert_top(bh);
-  } else if (s != BufferHead::STATE_DIRTY && state == BufferHead::STATE_DIRTY) {
+  } else if (s != BufferHead::STATE_DIRTY &&state == BufferHead::STATE_DIRTY) {
     bh_lru_dirty.lru_remove(bh);
     if (bh->get_dontneed())
       bh_lru_rest.lru_insert_bot(bh);
@@ -2187,7 +2496,8 @@ void ObjectCacher::bh_set_state(BufferHead *bh, int s)
     dirty_or_tx_bh.erase(bh);
   }
 
-  if (s != BufferHead::STATE_ERROR && bh->get_state() == BufferHead::STATE_ERROR) {
+  if (s != BufferHead::STATE_ERROR &&
+      bh->get_state() == BufferHead::STATE_ERROR) {
     bh->error = 0;
   }
 
diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h
index 87fe351..791412e 100644
--- a/src/osdc/ObjectCacher.h
+++ b/src/osdc/ObjectCacher.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 #ifndef CEPH_OBJECTCACHER_H
 #define CEPH_OBJECTCACHER_H
@@ -26,16 +26,25 @@ enum {
   l_objectcacher_cache_ops_miss, // ops we don't satisfy completely from cache
 
   l_objectcacher_cache_bytes_hit, // bytes read directly from cache
-  l_objectcacher_cache_bytes_miss, // bytes we couldn't read directly from cache
+
+  l_objectcacher_cache_bytes_miss, // bytes we couldn't read directly
+
+				   // from cache
 
   l_objectcacher_data_read, // total bytes read out
   l_objectcacher_data_written, // bytes written to cache
   l_objectcacher_data_flushed, // bytes flushed to WritebackHandler
-  l_objectcacher_overwritten_in_flush, // bytes overwritten while flushing is in progress
-
-  l_objectcacher_write_ops_blocked, // total write ops we delayed due to dirty limits
-  l_objectcacher_write_bytes_blocked, // total number of write bytes we delayed due to dirty limits
-  l_objectcacher_write_time_blocked, // total time in seconds spent blocking a write due to dirty limits
+  l_objectcacher_overwritten_in_flush, // bytes overwritten while
+				       // flushing is in progress
+
+  l_objectcacher_write_ops_blocked, // total write ops we delayed due
+				    // to dirty limits
+  l_objectcacher_write_bytes_blocked, // total number of write bytes
+				      // we delayed due to dirty
+				      // limits
+  l_objectcacher_write_time_blocked, // total time in seconds spent
+				     // blocking a write due to dirty
+				     // limits
 
   l_objectcacher_last,
 };
@@ -50,36 +59,37 @@ class ObjectCacher {
 
   typedef void (*flush_set_callback_t) (void *p, ObjectSet *oset);
 
-  // read scatter/gather  
+  // read scatter/gather
   struct OSDRead {
     vector<ObjectExtent> extents;
     snapid_t snap;
     map<object_t, bufferlist*> read_data;  // bits of data as they come back
     bufferlist *bl;
     int fadvise_flags;
-    OSDRead(snapid_t s, bufferlist *b, int f) : snap(s), bl(b), fadvise_flags(f) {}
+    OSDRead(snapid_t s, bufferlist *b, int f)
+      : snap(s), bl(b), fadvise_flags(f) {}
   };
 
   OSDRead *prepare_read(snapid_t snap, bufferlist *b, int f) {
     return new OSDRead(snap, b, f);
   }
-  
-  // write scatter/gather  
+
+  // write scatter/gather
   struct OSDWrite {
     vector<ObjectExtent> extents;
     SnapContext snapc;
     bufferlist bl;
-    utime_t mtime;
+    ceph::real_time mtime;
     int fadvise_flags;
     ceph_tid_t journal_tid;
-    OSDWrite(const SnapContext& sc, const bufferlist& b, utime_t mt, int f,
-             ceph_tid_t _journal_tid)
+    OSDWrite(const SnapContext& sc, const bufferlist& b, ceph::real_time mt,
+	     int f, ceph_tid_t _journal_tid)
       : snapc(sc), bl(b), mtime(mt), fadvise_flags(f),
-        journal_tid(_journal_tid) {}
+	journal_tid(_journal_tid) {}
   };
 
   OSDWrite *prepare_write(const SnapContext& sc, const bufferlist &b,
-			  utime_t mt, int f, ceph_tid_t journal_tid) {
+			  ceph::real_time mt, int f, ceph_tid_t journal_tid) {
     return new OSDWrite(sc, b, mt, f, journal_tid);
   }
 
@@ -112,15 +122,15 @@ class ObjectCacher {
     bufferlist  bl;
     ceph_tid_t last_write_tid;  // version of bh (if non-zero)
     ceph_tid_t last_read_tid;   // tid of last read op (if any)
-    utime_t last_write;
+    ceph::real_time last_write;
     SnapContext snapc;
     ceph_tid_t journal_tid;
     int error; // holds return value for failed reads
-    
-    map< loff_t, list<Context*> > waitfor_read;
-    
+
+    map<loff_t, list<Context*> > waitfor_read;
+
     // cons
-    BufferHead(Object *o) : 
+    BufferHead(Object *o) :
       state(STATE_MISSING),
       ref(0),
       dontneed(false),
@@ -132,7 +142,7 @@ class ObjectCacher {
       error(0) {
       ex.start = ex.length = 0;
     }
-  
+
     // extent
     loff_t start() const { return ex.start; }
     void set_start(loff_t s) { ex.start = s; }
@@ -153,7 +163,6 @@ class ObjectCacher {
       return journal_tid;
     }
     inline void set_journal_tid(ceph_tid_t _journal_tid) {
-      
       journal_tid = _journal_tid;
     }
 
@@ -164,7 +173,7 @@ class ObjectCacher {
     bool is_tx() { return state == STATE_TX; }
     bool is_rx() { return state == STATE_RX; }
     bool is_error() { return state == STATE_ERROR; }
-    
+
     // reference counting
     int get() {
       assert(ref >= 0);
@@ -194,8 +203,24 @@ class ObjectCacher {
 
     inline bool can_merge_journal(BufferHead *bh) const {
       return (get_journal_tid() == 0 || bh->get_journal_tid() == 0 ||
-              get_journal_tid() == bh->get_journal_tid());
+	      get_journal_tid() == bh->get_journal_tid());
     }
+
+    struct ptr_lt {
+      bool operator()(const BufferHead* l, const BufferHead* r) const {
+	const Object *lob = l->ob;
+	const Object *rob = r->ob;
+	const ObjectSet *loset = lob->oset;
+	const ObjectSet *roset = rob->oset;
+	if (loset != roset)
+	  return loset < roset;
+	if (lob != rob)
+	  return lob < rob;
+	if (l->start() != r->start())
+	  return l->start() < r->start();
+	return l < r;
+      }
+    };
   };
 
   // ******* Object *********
@@ -213,7 +238,7 @@ class ObjectCacher {
     xlist<Object*>::item set_item;
     object_locator_t oloc;
     uint64_t truncate_size, truncate_seq;
-    
+
     bool complete;
     bool exists;
 
@@ -258,7 +283,7 @@ class ObjectCacher {
     ObjectSet *get_object_set() { return oset; }
     string get_namespace() { return oloc.nspace; }
     uint64_t get_object_number() const { return object_no; }
-    
+
     object_locator_t& get_oloc() { return oloc; }
     void set_object_locator(object_locator_t& l) { oloc = l; }
 
@@ -321,9 +346,9 @@ class ObjectCacher {
     bool is_cached(loff_t off, loff_t len);
     bool include_all_cached_data(loff_t off, loff_t len);
     int map_read(OSDRead *rd,
-                 map<loff_t, BufferHead*>& hits,
-                 map<loff_t, BufferHead*>& missing,
-                 map<loff_t, BufferHead*>& rx,
+		 map<loff_t, BufferHead*>& hits,
+		 map<loff_t, BufferHead*>& missing,
+		 map<loff_t, BufferHead*>& rx,
 		 map<loff_t, BufferHead*>& errors);
     BufferHead *map_write(OSDWrite *wr);
 
@@ -344,7 +369,7 @@ class ObjectCacher {
       return ref;
     }
   };
-  
+
 
   struct ObjectSet {
     void *parent;
@@ -370,24 +395,26 @@ class ObjectCacher {
   // ObjectCacher fields
  private:
   WritebackHandler& writeback_handler;
+  bool scattered_write;
 
   string name;
   Mutex& lock;
-  
+
   uint64_t max_dirty, target_dirty, max_size, max_objects;
-  utime_t max_dirty_age;
+  ceph::timespan max_dirty_age;
   bool block_writes_upfront;
 
   flush_set_callback_t flush_set_callback;
   void *flush_set_callback_arg;
 
-  vector<ceph::unordered_map<sobject_t, Object*> > objects; // indexed by pool_id
+  // indexed by pool_id
+  vector<ceph::unordered_map<sobject_t, Object*> > objects;
 
   list<Context*> waitfor_read;
 
   ceph_tid_t last_read_tid;
 
-  set<BufferHead*>    dirty_or_tx_bh;
+  set<BufferHead*, BufferHead::ptr_lt> dirty_or_tx_bh;
   LRU   bh_lru_dirty, bh_lru_rest;
   LRU   ob_lru;
 
@@ -410,7 +437,7 @@ class ObjectCacher {
   Object *get_object_maybe(sobject_t oid, object_locator_t &l) {
     // have it?
     if (((uint32_t)l.pool < objects.size()) &&
-        (objects[l.pool].count(oid)))
+	(objects[l.pool].count(oid)))
       return objects[l.pool][oid];
     return NULL;
   }
@@ -462,18 +489,29 @@ class ObjectCacher {
 
   // bh states
   void bh_set_state(BufferHead *bh, int s);
-  void copy_bh_state(BufferHead *bh1, BufferHead *bh2) { 
+  void copy_bh_state(BufferHead *bh1, BufferHead *bh2) {
     bh_set_state(bh2, bh1->get_state());
   }
-  
-  void mark_missing(BufferHead *bh) { bh_set_state(bh, BufferHead::STATE_MISSING); }
-  void mark_clean(BufferHead *bh) { bh_set_state(bh, BufferHead::STATE_CLEAN); }
-  void mark_zero(BufferHead *bh) { bh_set_state(bh, BufferHead::STATE_ZERO); }
-  void mark_rx(BufferHead *bh) { bh_set_state(bh, BufferHead::STATE_RX); }
-  void mark_tx(BufferHead *bh) { bh_set_state(bh, BufferHead::STATE_TX); }
-  void mark_error(BufferHead *bh) { bh_set_state(bh, BufferHead::STATE_ERROR); }
-  void mark_dirty(BufferHead *bh) { 
-    bh_set_state(bh, BufferHead::STATE_DIRTY); 
+
+  void mark_missing(BufferHead *bh) {
+    bh_set_state(bh,BufferHead::STATE_MISSING);
+  }
+  void mark_clean(BufferHead *bh) {
+    bh_set_state(bh, BufferHead::STATE_CLEAN);
+  }
+  void mark_zero(BufferHead *bh) {
+    bh_set_state(bh, BufferHead::STATE_ZERO);
+  }
+  void mark_rx(BufferHead *bh) {
+    bh_set_state(bh, BufferHead::STATE_RX);
+  }
+  void mark_tx(BufferHead *bh) {
+    bh_set_state(bh, BufferHead::STATE_TX); }
+  void mark_error(BufferHead *bh) {
+    bh_set_state(bh, BufferHead::STATE_ERROR);
+  }
+  void mark_dirty(BufferHead *bh) {
+    bh_set_state(bh, BufferHead::STATE_DIRTY);
     bh_lru_dirty.lru_touch(bh);
     //bh->set_dirty_stamp(ceph_clock_now(g_ceph_context));
   }
@@ -484,6 +522,9 @@ class ObjectCacher {
   // io
   void bh_read(BufferHead *bh, int op_flags);
   void bh_write(BufferHead *bh);
+  void bh_write_scattered(list<BufferHead*>& blist);
+  void bh_write_adjacencies(BufferHead *bh, ceph::real_time cutoff,
+			    int64_t *amount, int *max_count);
 
   void trim();
   void flush(loff_t amount=0);
@@ -515,8 +556,10 @@ class ObjectCacher {
 		      loff_t offset, uint64_t length,
 		      bufferlist &bl, int r,
 		      bool trust_enoent);
-  void bh_write_commit(int64_t poolid, sobject_t oid, loff_t offset,
-		       uint64_t length, ceph_tid_t t, int r);
+  void bh_write_commit(int64_t poolid, sobject_t oid,
+		       vector<pair<loff_t, uint64_t> >& ranges,
+		       ceph_tid_t t, int r);
+
 
   class C_ReadFinish : public Context {
     ObjectCacher *oc;
@@ -530,7 +573,8 @@ class ObjectCacher {
 
   public:
     bufferlist bl;
-    C_ReadFinish(ObjectCacher *c, Object *ob, ceph_tid_t t, loff_t s, uint64_t l) :
+    C_ReadFinish(ObjectCacher *c, Object *ob, ceph_tid_t t, loff_t s,
+		 uint64_t l) :
       oc(c), poolid(ob->oloc.pool), oid(ob->get_soid()), start(s), length(l),
       set_item(this), trust_enoent(true),
       tid(t) {
@@ -554,16 +598,23 @@ class ObjectCacher {
     ObjectCacher *oc;
     int64_t poolid;
     sobject_t oid;
-    loff_t start;
-    uint64_t length;
+    vector<pair<loff_t, uint64_t> > ranges;
   public:
     ceph_tid_t tid;
-    C_WriteCommit(ObjectCacher *c, int64_t _poolid, sobject_t o, loff_t s, uint64_t l) :
-      oc(c), poolid(_poolid), oid(o), start(s), length(l), tid(0) {}
+    C_WriteCommit(ObjectCacher *c, int64_t _poolid, sobject_t o, loff_t s,
+		  uint64_t l) :
+      oc(c), poolid(_poolid), oid(o), tid(0) {
+	ranges.push_back(make_pair(s, l));
+      }
+    C_WriteCommit(ObjectCacher *c, int64_t _poolid, sobject_t o,
+		  vector<pair<loff_t, uint64_t> >& _ranges) :
+      oc(c), poolid(_poolid), oid(o), tid(0) {
+	ranges.swap(_ranges);
+      }
     void finish(int r) {
-      oc->bh_write_commit(poolid, oid, start, length, tid, r);
+      oc->bh_write_commit(poolid, oid, ranges, tid, r);
     }
-  };
+ };
 
   class C_WaitForWrite : public Context {
   public:
@@ -590,7 +641,7 @@ class ObjectCacher {
   ~ObjectCacher();
 
   void start() {
-    flusher_thread.create();
+    flusher_thread.create("flusher");
   }
   void stop() {
     assert(flusher_thread.is_started());
@@ -608,7 +659,8 @@ class ObjectCacher {
     ObjectSet *oset;
     Context *onfinish;
   public:
-    C_RetryRead(ObjectCacher *_oc, OSDRead *r, ObjectSet *os, Context *c) : oc(_oc), rd(r), oset(os), onfinish(c) {}
+    C_RetryRead(ObjectCacher *_oc, OSDRead *r, ObjectSet *os, Context *c)
+      : oc(_oc), rd(r), oset(os), onfinish(c) {}
     void finish(int r) {
       if (r < 0) {
 	if (onfinish)
@@ -617,7 +669,7 @@ class ObjectCacher {
       }
       int ret = oc->_readx(rd, oset, onfinish, false);
       if (ret != 0 && onfinish) {
-        onfinish->complete(ret);
+	onfinish->complete(ret);
       }
     }
   };
@@ -632,11 +684,13 @@ class ObjectCacher {
    */
   int readx(OSDRead *rd, ObjectSet *oset, Context *onfinish);
   int writex(OSDWrite *wr, ObjectSet *oset, Context *onfreespace);
-  bool is_cached(ObjectSet *oset, vector<ObjectExtent>& extents, snapid_t snapid);
+  bool is_cached(ObjectSet *oset, vector<ObjectExtent>& extents,
+		 snapid_t snapid);
 
 private:
   // write blocking
-  int _wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset, Context *onfreespace);
+  int _wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset,
+		      Context *onfreespace);
   void maybe_wait_for_writeback(uint64_t len);
   bool _flush_set_finish(C_GatherBuilder *gather, Context *onfinish);
 
@@ -646,12 +700,14 @@ public:
   bool set_is_dirty_or_committing(ObjectSet *oset);
 
   bool flush_set(ObjectSet *oset, Context *onfinish=0);
-  bool flush_set(ObjectSet *oset, vector<ObjectExtent>& ex, Context *onfinish=0);
-  void flush_all(Context *onfinish=0);
+  bool flush_set(ObjectSet *oset, vector<ObjectExtent>& ex,
+		 Context *onfinish = 0);
+  bool flush_all(Context *onfinish = 0);
 
   void purge_set(ObjectSet *oset);
 
-  loff_t release_set(ObjectSet *oset);  // returns # of bytes not released (ie non-clean)
+  // returns # of bytes not released (ie non-clean)
+  loff_t release_set(ObjectSet *oset);
   uint64_t release_all();
 
   void discard_set(ObjectSet *oset, const vector<ObjectExtent>& ex);
@@ -676,7 +732,7 @@ public:
     max_size = v;
   }
   void set_max_dirty_age(double a) {
-    max_dirty_age.set_from_double(a);
+    max_dirty_age = make_timespan(a);
   }
   void set_max_objects(int64_t v) {
     max_objects = v;
@@ -686,35 +742,38 @@ public:
   // file functions
 
   /*** async+caching (non-blocking) file interface ***/
-  int file_is_cached(ObjectSet *oset, ceph_file_layout *layout, snapid_t snapid,
-		     loff_t offset, uint64_t len) {
+  int file_is_cached(ObjectSet *oset, ceph_file_layout *layout,
+		     snapid_t snapid, loff_t offset, uint64_t len) {
     vector<ObjectExtent> extents;
-    Striper::file_to_extents(cct, oset->ino, layout, offset, len, oset->truncate_size, extents);
+    Striper::file_to_extents(cct, oset->ino, layout, offset, len,
+			     oset->truncate_size, extents);
     return is_cached(oset, extents, snapid);
   }
 
   int file_read(ObjectSet *oset, ceph_file_layout *layout, snapid_t snapid,
-                loff_t offset, uint64_t len, 
-                bufferlist *bl,
-		int flags,
-                Context *onfinish) {
+		loff_t offset, uint64_t len, bufferlist *bl, int flags,
+		Context *onfinish) {
     OSDRead *rd = prepare_read(snapid, bl, flags);
-    Striper::file_to_extents(cct, oset->ino, layout, offset, len, oset->truncate_size, rd->extents);
+    Striper::file_to_extents(cct, oset->ino, layout, offset, len,
+			     oset->truncate_size, rd->extents);
     return readx(rd, oset, onfinish);
   }
 
-  int file_write(ObjectSet *oset, ceph_file_layout *layout, const SnapContext& snapc,
-                 loff_t offset, uint64_t len, 
-                 bufferlist& bl, utime_t mtime, int flags) {
+  int file_write(ObjectSet *oset, ceph_file_layout *layout,
+		 const SnapContext& snapc, loff_t offset, uint64_t len,
+		 bufferlist& bl, ceph::real_time mtime, int flags) {
     OSDWrite *wr = prepare_write(snapc, bl, mtime, flags, 0);
-    Striper::file_to_extents(cct, oset->ino, layout, offset, len, oset->truncate_size, wr->extents);
+    Striper::file_to_extents(cct, oset->ino, layout, offset, len,
+			     oset->truncate_size, wr->extents);
     return writex(wr, oset, NULL);
   }
 
-  bool file_flush(ObjectSet *oset, ceph_file_layout *layout, const SnapContext& snapc,
-                  loff_t offset, uint64_t len, Context *onfinish) {
+  bool file_flush(ObjectSet *oset, ceph_file_layout *layout,
+		  const SnapContext& snapc, loff_t offset, uint64_t len,
+		  Context *onfinish) {
     vector<ObjectExtent> extents;
-    Striper::file_to_extents(cct, oset->ino, layout, offset, len, oset->truncate_size, extents);
+    Striper::file_to_extents(cct, oset->ino, layout, offset, len,
+			     oset->truncate_size, extents);
     return flush_set(oset, extents, onfinish);
   }
 };
@@ -740,7 +799,8 @@ inline ostream& operator<<(ostream& out, ObjectCacher::BufferHead &bh)
   if (bh.error) out << " error=" << bh.error;
   out << "]";
   out << " waiters = {";
-  for (map<loff_t, list<Context*> >::const_iterator it = bh.waitfor_read.begin();
+  for (map<loff_t, list<Context*> >::const_iterator it
+	 = bh.waitfor_read.begin();
        it != bh.waitfor_read.end(); ++it) {
     out << " " << it->first << "->[";
     for (list<Context*>::const_iterator lit = it->second.begin();
diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc
index ac06048..9bfbb06 100644
--- a/src/osdc/Objecter.cc
+++ b/src/osdc/Objecter.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #include "Objecter.h"
@@ -50,6 +50,15 @@
 #include "include/str_list.h"
 #include "common/errno.h"
 
+using ceph::real_time;
+using ceph::real_clock;
+
+using ceph::mono_clock;
+using ceph::mono_time;
+
+using ceph::timespan;
+
+
 #define dout_subsys ceph_subsys_objecter
 #undef dout_prefix
 #define dout_prefix *_dout << messenger->get_myname() << ".objecter "
@@ -147,7 +156,8 @@ static const char *config_keys[] = {
 Mutex *Objecter::OSDSession::get_lock(object_t& oid)
 {
 #define HASH_PRIME 1021
-  uint32_t h = ceph_str_hash_linux(oid.name.c_str(), oid.name.size()) % HASH_PRIME;
+  uint32_t h = ceph_str_hash_linux(oid.name.c_str(), oid.name.size())
+    % HASH_PRIME;
 
   return completion_locks[h % num_locks];
 }
@@ -168,13 +178,14 @@ void Objecter::handle_conf_change(const struct md_config_t *conf,
 
 void Objecter::update_crush_location()
 {
+  RWLock::WLocker rwlocker(rwlock);
   crush_location.clear();
   vector<string> lvec;
   get_str_vec(cct->_conf->crush_location, ";, \t", lvec);
   int r = CrushWrapper::parse_loc_multimap(lvec, &crush_location);
   if (r < 0) {
     lderr(cct) << "warning: crush_location '" << cct->_conf->crush_location
-               << "' does not parse" << dendl;
+	       << "' does not parse" << dendl;
   }
 }
 
@@ -191,7 +202,7 @@ void Objecter::init()
     PerfCountersBuilder pcb(cct, "objecter", l_osdc_first, l_osdc_last);
 
     pcb.add_u64(l_osdc_op_active, "op_active",
-        "Operations active", "actv");
+		"Operations active", "actv");
     pcb.add_u64(l_osdc_op_laggy, "op_laggy", "Laggy operations");
     pcb.add_u64_counter(l_osdc_op_send, "op_send", "Sent operations");
     pcb.add_u64_counter(l_osdc_op_send_bytes, "op_send_bytes", "Sent data");
@@ -201,73 +212,116 @@ void Objecter::init()
 
     pcb.add_u64_counter(l_osdc_op, "op", "Operations");
     pcb.add_u64_counter(l_osdc_op_r, "op_r",
-        "Read operations", "read");
+			"Read operations", "read");
     pcb.add_u64_counter(l_osdc_op_w, "op_w",
-        "Write operations", "writ");
-    pcb.add_u64_counter(l_osdc_op_rmw, "op_rmw", "Read-modify-write operations");
+			"Write operations", "writ");
+    pcb.add_u64_counter(l_osdc_op_rmw, "op_rmw",
+			"Read-modify-write operations");
     pcb.add_u64_counter(l_osdc_op_pg, "op_pg", "PG operation");
 
     pcb.add_u64_counter(l_osdc_osdop_stat, "osdop_stat", "Stat operations");
-    pcb.add_u64_counter(l_osdc_osdop_create, "osdop_create", "Create object operations");
+    pcb.add_u64_counter(l_osdc_osdop_create, "osdop_create",
+			"Create object operations");
     pcb.add_u64_counter(l_osdc_osdop_read, "osdop_read", "Read operations");
     pcb.add_u64_counter(l_osdc_osdop_write, "osdop_write", "Write operations");
-    pcb.add_u64_counter(l_osdc_osdop_writefull, "osdop_writefull", "Write full object operations");
-    pcb.add_u64_counter(l_osdc_osdop_append, "osdop_append", "Append operation");
-    pcb.add_u64_counter(l_osdc_osdop_zero, "osdop_zero", "Set object to zero operations");
-    pcb.add_u64_counter(l_osdc_osdop_truncate, "osdop_truncate", "Truncate object operations");
-    pcb.add_u64_counter(l_osdc_osdop_delete, "osdop_delete", "Delete object operations");
-    pcb.add_u64_counter(l_osdc_osdop_mapext, "osdop_mapext", "Map extent operations");
-    pcb.add_u64_counter(l_osdc_osdop_sparse_read, "osdop_sparse_read", "Sparse read operations");
-    pcb.add_u64_counter(l_osdc_osdop_clonerange, "osdop_clonerange", "Clone range operations");
-    pcb.add_u64_counter(l_osdc_osdop_getxattr, "osdop_getxattr", "Get xattr operations");
-    pcb.add_u64_counter(l_osdc_osdop_setxattr, "osdop_setxattr", "Set xattr operations");
-    pcb.add_u64_counter(l_osdc_osdop_cmpxattr, "osdop_cmpxattr", "Xattr comparison operations");
-    pcb.add_u64_counter(l_osdc_osdop_rmxattr, "osdop_rmxattr", "Remove xattr operations");
-    pcb.add_u64_counter(l_osdc_osdop_resetxattrs, "osdop_resetxattrs", "Reset xattr operations");
-    pcb.add_u64_counter(l_osdc_osdop_tmap_up, "osdop_tmap_up", "TMAP update operations");
-    pcb.add_u64_counter(l_osdc_osdop_tmap_put, "osdop_tmap_put", "TMAP put operations");
-    pcb.add_u64_counter(l_osdc_osdop_tmap_get, "osdop_tmap_get", "TMAP get operations");
-    pcb.add_u64_counter(l_osdc_osdop_call, "osdop_call", "Call (execute) operations");
-    pcb.add_u64_counter(l_osdc_osdop_watch, "osdop_watch", "Watch by object operations");
-    pcb.add_u64_counter(l_osdc_osdop_notify, "osdop_notify", "Notify about object operations");
-    pcb.add_u64_counter(l_osdc_osdop_src_cmpxattr, "osdop_src_cmpxattr", "Extended attribute comparison in multi operations");
+    pcb.add_u64_counter(l_osdc_osdop_writefull, "osdop_writefull",
+			"Write full object operations");
+    pcb.add_u64_counter(l_osdc_osdop_append, "osdop_append",
+			"Append operation");
+    pcb.add_u64_counter(l_osdc_osdop_zero, "osdop_zero",
+			"Set object to zero operations");
+    pcb.add_u64_counter(l_osdc_osdop_truncate, "osdop_truncate",
+			"Truncate object operations");
+    pcb.add_u64_counter(l_osdc_osdop_delete, "osdop_delete",
+			"Delete object operations");
+    pcb.add_u64_counter(l_osdc_osdop_mapext, "osdop_mapext",
+			"Map extent operations");
+    pcb.add_u64_counter(l_osdc_osdop_sparse_read, "osdop_sparse_read",
+			"Sparse read operations");
+    pcb.add_u64_counter(l_osdc_osdop_clonerange, "osdop_clonerange",
+			"Clone range operations");
+    pcb.add_u64_counter(l_osdc_osdop_getxattr, "osdop_getxattr",
+			"Get xattr operations");
+    pcb.add_u64_counter(l_osdc_osdop_setxattr, "osdop_setxattr",
+			"Set xattr operations");
+    pcb.add_u64_counter(l_osdc_osdop_cmpxattr, "osdop_cmpxattr",
+			"Xattr comparison operations");
+    pcb.add_u64_counter(l_osdc_osdop_rmxattr, "osdop_rmxattr",
+			"Remove xattr operations");
+    pcb.add_u64_counter(l_osdc_osdop_resetxattrs, "osdop_resetxattrs",
+			"Reset xattr operations");
+    pcb.add_u64_counter(l_osdc_osdop_tmap_up, "osdop_tmap_up",
+			"TMAP update operations");
+    pcb.add_u64_counter(l_osdc_osdop_tmap_put, "osdop_tmap_put",
+			"TMAP put operations");
+    pcb.add_u64_counter(l_osdc_osdop_tmap_get, "osdop_tmap_get",
+			"TMAP get operations");
+    pcb.add_u64_counter(l_osdc_osdop_call, "osdop_call",
+			"Call (execute) operations");
+    pcb.add_u64_counter(l_osdc_osdop_watch, "osdop_watch",
+			"Watch by object operations");
+    pcb.add_u64_counter(l_osdc_osdop_notify, "osdop_notify",
+			"Notify about object operations");
+    pcb.add_u64_counter(l_osdc_osdop_src_cmpxattr, "osdop_src_cmpxattr",
+			"Extended attribute comparison in multi operations");
     pcb.add_u64_counter(l_osdc_osdop_pgls, "osdop_pgls");
     pcb.add_u64_counter(l_osdc_osdop_pgls_filter, "osdop_pgls_filter");
     pcb.add_u64_counter(l_osdc_osdop_other, "osdop_other", "Other operations");
 
-    pcb.add_u64(l_osdc_linger_active, "linger_active", "Active lingering operations");
-    pcb.add_u64_counter(l_osdc_linger_send, "linger_send", "Sent lingering operations");
-    pcb.add_u64_counter(l_osdc_linger_resend, "linger_resend", "Resent lingering operations");
-    pcb.add_u64_counter(l_osdc_linger_ping, "linger_ping", "Sent pings to lingering operations");
-
-    pcb.add_u64(l_osdc_poolop_active, "poolop_active", "Active pool operations");
-    pcb.add_u64_counter(l_osdc_poolop_send, "poolop_send", "Sent pool operations");
-    pcb.add_u64_counter(l_osdc_poolop_resend, "poolop_resend", "Resent pool operations");
-
-    pcb.add_u64(l_osdc_poolstat_active, "poolstat_active", "Active get pool stat operations");
-    pcb.add_u64_counter(l_osdc_poolstat_send, "poolstat_send", "Pool stat operations sent");
-    pcb.add_u64_counter(l_osdc_poolstat_resend, "poolstat_resend", "Resent pool stats");
+    pcb.add_u64(l_osdc_linger_active, "linger_active",
+		"Active lingering operations");
+    pcb.add_u64_counter(l_osdc_linger_send, "linger_send",
+			"Sent lingering operations");
+    pcb.add_u64_counter(l_osdc_linger_resend, "linger_resend",
+			"Resent lingering operations");
+    pcb.add_u64_counter(l_osdc_linger_ping, "linger_ping",
+			"Sent pings to lingering operations");
+
+    pcb.add_u64(l_osdc_poolop_active, "poolop_active",
+		"Active pool operations");
+    pcb.add_u64_counter(l_osdc_poolop_send, "poolop_send",
+			"Sent pool operations");
+    pcb.add_u64_counter(l_osdc_poolop_resend, "poolop_resend",
+			"Resent pool operations");
+
+    pcb.add_u64(l_osdc_poolstat_active, "poolstat_active",
+		"Active get pool stat operations");
+    pcb.add_u64_counter(l_osdc_poolstat_send, "poolstat_send",
+			"Pool stat operations sent");
+    pcb.add_u64_counter(l_osdc_poolstat_resend, "poolstat_resend",
+			"Resent pool stats");
 
     pcb.add_u64(l_osdc_statfs_active, "statfs_active", "Statfs operations");
     pcb.add_u64_counter(l_osdc_statfs_send, "statfs_send", "Sent FS stats");
-    pcb.add_u64_counter(l_osdc_statfs_resend, "statfs_resend", "Resent FS stats");
+    pcb.add_u64_counter(l_osdc_statfs_resend, "statfs_resend",
+			"Resent FS stats");
 
     pcb.add_u64(l_osdc_command_active, "command_active", "Active commands");
-    pcb.add_u64_counter(l_osdc_command_send, "command_send", "Sent commands");
-    pcb.add_u64_counter(l_osdc_command_resend, "command_resend", "Resent commands");
+    pcb.add_u64_counter(l_osdc_command_send, "command_send",
+			"Sent commands");
+    pcb.add_u64_counter(l_osdc_command_resend, "command_resend",
+			"Resent commands");
 
     pcb.add_u64(l_osdc_map_epoch, "map_epoch", "OSD map epoch");
-    pcb.add_u64_counter(l_osdc_map_full, "map_full", "Full OSD maps received");
-    pcb.add_u64_counter(l_osdc_map_inc, "map_inc", "Incremental OSD maps received");
-
-    pcb.add_u64(l_osdc_osd_sessions, "osd_sessions", "Open sessions");  // open sessions
-    pcb.add_u64_counter(l_osdc_osd_session_open, "osd_session_open", "Sessions opened");
-    pcb.add_u64_counter(l_osdc_osd_session_close, "osd_session_close", "Sessions closed");
+    pcb.add_u64_counter(l_osdc_map_full, "map_full",
+			"Full OSD maps received");
+    pcb.add_u64_counter(l_osdc_map_inc, "map_inc",
+			"Incremental OSD maps received");
+
+    pcb.add_u64(l_osdc_osd_sessions, "osd_sessions",
+		"Open sessions");  // open sessions
+    pcb.add_u64_counter(l_osdc_osd_session_open, "osd_session_open",
+			"Sessions opened");
+    pcb.add_u64_counter(l_osdc_osd_session_close, "osd_session_close",
+			"Sessions closed");
     pcb.add_u64(l_osdc_osd_laggy, "osd_laggy", "Laggy OSD sessions");
 
-    pcb.add_u64_counter(l_osdc_osdop_omap_wr, "omap_wr", "OSD OMAP write operations");
-    pcb.add_u64_counter(l_osdc_osdop_omap_rd, "omap_rd", "OSD OMAP read operations");
-    pcb.add_u64_counter(l_osdc_osdop_omap_del, "omap_del", "OSD OMAP delete operations");
+    pcb.add_u64_counter(l_osdc_osdop_omap_wr, "omap_wr",
+			"OSD OMAP write operations");
+    pcb.add_u64_counter(l_osdc_osdop_omap_rd, "omap_rd",
+			"OSD OMAP read operations");
+    pcb.add_u64_counter(l_osdc_osdop_omap_del, "omap_del",
+			"OSD OMAP delete operations");
 
     logger = pcb.create_perf_counters();
     cct->get_perfcounters_collection()->add(logger);
@@ -287,11 +341,8 @@ void Objecter::init()
 	       << cpp_strerror(ret) << dendl;
   }
 
-  timer_lock.Lock();
-  timer.init();
-  timer_lock.Unlock();
-
   update_crush_location();
+
   cct->_conf->add_observer(this);
 
   initialized.set(1);
@@ -304,7 +355,7 @@ void Objecter::start()
 {
   RWLock::RLocker rl(rwlock);
 
-  schedule_tick();
+  start_tick();
   if (osdmap->get_epoch() == 0) {
     _maybe_request_map();
   }
@@ -339,7 +390,8 @@ void Objecter::shutdown()
   }
 
   while(!check_latest_map_commands.empty()) {
-    map<ceph_tid_t, CommandOp*>::iterator i = check_latest_map_commands.begin();
+    map<ceph_tid_t, CommandOp*>::iterator i
+      = check_latest_map_commands.begin();
     i->second->put();
     check_latest_map_commands.erase(i->first);
   }
@@ -364,7 +416,8 @@ void Objecter::shutdown()
 
   ldout(cct, 20) << __func__ << " clearing up homeless session..." << dendl;
   while(!homeless_session->linger_ops.empty()) {
-    std::map<uint64_t, LingerOp*>::iterator i = homeless_session->linger_ops.begin();
+    std::map<uint64_t, LingerOp*>::iterator i
+      = homeless_session->linger_ops.begin();
     ldout(cct, 10) << " linger_op " << i->first << dendl;
     LingerOp *lop = i->second;
     {
@@ -388,7 +441,8 @@ void Objecter::shutdown()
   }
 
   while(!homeless_session->command_ops.empty()) {
-    std::map<ceph_tid_t, CommandOp*>::iterator i = homeless_session->command_ops.begin();
+    std::map<ceph_tid_t, CommandOp*>::iterator i
+      = homeless_session->command_ops.begin();
     ldout(cct, 10) << " command_op " << i->first << dendl;
     CommandOp *cop = i->second;
     {
@@ -399,11 +453,10 @@ void Objecter::shutdown()
   }
 
   if (tick_event) {
-    Mutex::Locker l(timer_lock);
     if (timer.cancel_event(tick_event)) {
       ldout(cct, 10) <<  " successfully canceled tick" << dendl;
-      tick_event = NULL;
     }
+    tick_event = 0;
   }
 
   if (m_request_state_hook) {
@@ -421,13 +474,6 @@ void Objecter::shutdown()
 
   // Let go of Objecter write lock so timer thread can shutdown
   rwlock.unlock();
-
-  {
-    Mutex::Locker l(timer_lock);
-    timer.shutdown();
-  }
-
-  assert(tick_event == NULL);
 }
 
 void Objecter::_send_linger(LingerOp *info)
@@ -441,7 +487,8 @@ void Objecter::_send_linger(LingerOp *info)
   info->watch_lock.get_read(); // just to read registered status
   bufferlist *poutbl = NULL;
   if (info->registered && info->is_watch) {
-    ldout(cct, 15) << "send_linger " << info->linger_id << " reconnect" << dendl;
+    ldout(cct, 15) << "send_linger " << info->linger_id << " reconnect"
+		   << dendl;
     opv.push_back(OSDOp());
     opv.back().op.op = CEPH_OSD_OP_WATCH;
     opv.back().op.watch.cookie = info->get_cookie();
@@ -449,7 +496,8 @@ void Objecter::_send_linger(LingerOp *info)
     opv.back().op.watch.gen = ++info->register_gen;
     oncommit = new C_Linger_Reconnect(this, info);
   } else {
-    ldout(cct, 15) << "send_linger " << info->linger_id << " register" << dendl;
+    ldout(cct, 15) << "send_linger " << info->linger_id << " register"
+		   << dendl;
     opv = info->ops;
     C_Linger_Commit *c = new C_Linger_Commit(this, info);
     if (!info->is_watch) {
@@ -512,7 +560,8 @@ void Objecter::_linger_commit(LingerOp *info, int r, bufferlist& outbl)
     bufferlist::iterator p = outbl.begin();
     try {
       ::decode(info->notify_id, p);
-      ldout(cct, 10) << "_linger_commit  notify_id=" << info->notify_id << dendl;
+      ldout(cct, 10) << "_linger_commit  notify_id=" << info->notify_id
+		     << dendl;
     }
     catch (buffer::error& e) {
     }
@@ -577,7 +626,8 @@ void Objecter::_send_linger_ping(LingerOp *info)
   assert(info->session->lock.is_locked());
 
   if (cct->_conf->objecter_inject_no_watch_ping) {
-    ldout(cct, 10) << __func__ << " " << info->linger_id << " SKIPPING" << dendl;
+    ldout(cct, 10) << __func__ << " " << info->linger_id << " SKIPPING"
+		   << dendl;
     return;
   }
   if (osdmap->test_flag(CEPH_OSDMAP_PAUSERD)) {
@@ -585,8 +635,9 @@ void Objecter::_send_linger_ping(LingerOp *info)
     return;
   }
 
-  utime_t now = ceph_clock_now(NULL);
-  ldout(cct, 10) << __func__ << " " << info->linger_id << " now " << now << dendl;
+  ceph::mono_time now = ceph::mono_clock::now();
+  ldout(cct, 10) << __func__ << " " << info->linger_id << " now " << now
+		 << dendl;
 
   vector<OSDOp> opv(1);
   opv[0].op.op = CEPH_OSD_OP_WATCH;
@@ -611,7 +662,7 @@ void Objecter::_send_linger_ping(LingerOp *info)
   logger->inc(l_osdc_linger_ping);
 }
 
-void Objecter::_linger_ping(LingerOp *info, int r, utime_t sent,
+void Objecter::_linger_ping(LingerOp *info, int r, mono_time sent,
 			    uint32_t register_gen)
 {
   RWLock::WLocker l(info->watch_lock);
@@ -639,17 +690,17 @@ int Objecter::linger_check(LingerOp *info)
 {
   RWLock::RLocker l(info->watch_lock);
 
-  utime_t stamp = info->watch_valid_thru;
+  mono_time stamp = info->watch_valid_thru;
   if (!info->watch_pending_async.empty())
     stamp = MIN(info->watch_valid_thru, info->watch_pending_async.front());
-  utime_t age = ceph_clock_now(NULL) - stamp;
+  auto age = mono_clock::now() - stamp;
 
   ldout(cct, 10) << __func__ << " " << info->linger_id
 		 << " err " << info->last_error
 		 << " age " << age << dendl;
   if (info->last_error)
     return info->last_error;
-  return age.to_msec();
+  return std::chrono::duration_cast<std::chrono::milliseconds>(age).count();
 }
 
 void Objecter::linger_cancel(LingerOp *info)
@@ -692,7 +743,7 @@ Objecter::LingerOp *Objecter::linger_register(const object_t& oid,
   if (info->target.base_oloc.key == oid)
     info->target.base_oloc.key.clear();
   info->target.flags = flags;
-  info->watch_valid_thru = ceph_clock_now(NULL);
+  info->watch_valid_thru = mono_clock::now();
 
   RWLock::WLocker l(rwlock);
 
@@ -712,7 +763,8 @@ Objecter::LingerOp *Objecter::linger_register(const object_t& oid,
 
 ceph_tid_t Objecter::linger_watch(LingerOp *info,
 				  ObjectOperation& op,
-				  const SnapContext& snapc, utime_t mtime,
+				  const SnapContext& snapc,
+				  real_time mtime,
 				  bufferlist& inbl,
 				  Context *oncommit,
 				  version_t *objver)
@@ -815,8 +867,9 @@ void Objecter::handle_watch_notify(MWatchNotify *m)
       }
     }
   } else if (!info->is_watch) {
-    // we have CEPH_WATCH_EVENT_NOTIFY_COMPLETE; we can do this inline since
-    // we know the only user (librados) is safe to call in fast-dispatch context
+    // we have CEPH_WATCH_EVENT_NOTIFY_COMPLETE; we can do this inline
+    // since we know the only user (librados) is safe to call in
+    // fast-dispatch context
     if (info->notify_id &&
 	info->notify_id != m->notify_id) {
       ldout(cct, 10) << __func__ << " reply notify " << m->notify_id
@@ -916,12 +969,12 @@ bool Objecter::ms_dispatch(Message *m)
 }
 
 void Objecter::_scan_requests(OSDSession *s,
-                             bool force_resend,
-			     bool cluster_full,
-                             map<int64_t, bool> *pool_full_map,
-			     map<ceph_tid_t, Op*>& need_resend,
-			     list<LingerOp*>& need_resend_linger,
-			     map<ceph_tid_t, CommandOp*>& need_resend_command)
+			      bool force_resend,
+			      bool cluster_full,
+			      map<int64_t, bool> *pool_full_map,
+			      map<ceph_tid_t, Op*>& need_resend,
+			      list<LingerOp*>& need_resend_linger,
+			      map<ceph_tid_t, CommandOp*>& need_resend_command)
 {
   assert(rwlock.is_wlocked());
 
@@ -936,12 +989,15 @@ void Objecter::_scan_requests(OSDSession *s,
   while (lp != s->linger_ops.end()) {
     LingerOp *op = lp->second;
     assert(op->session == s);
-    ++lp;   // check_linger_pool_dne() may touch linger_ops; prevent iterator invalidation
+    // check_linger_pool_dne() may touch linger_ops; prevent iterator
+    // invalidation
+    ++lp;
     ldout(cct, 10) << " checking linger op " << op->linger_id << dendl;
     bool unregister, force_resend_writes = cluster_full;
     int r = _recalc_linger_op_target(op, lc);
     if (pool_full_map)
-      force_resend_writes = force_resend_writes || (*pool_full_map)[op->target.base_oloc.pool];
+      force_resend_writes = force_resend_writes ||
+	(*pool_full_map)[op->target.base_oloc.pool];
     switch (r) {
     case RECALC_OP_TARGET_NO_ACTION:
       if (!force_resend && !force_resend_writes)
@@ -954,10 +1010,10 @@ void Objecter::_scan_requests(OSDSession *s,
     case RECALC_OP_TARGET_POOL_DNE:
       _check_linger_pool_dne(op, &unregister);
       if (unregister) {
-        ldout(cct, 10) << " need to unregister linger op "
+	ldout(cct, 10) << " need to unregister linger op "
 		       << op->linger_id << dendl;
 	op->get();
-        unregister_lingers.push_back(op);
+	unregister_lingers.push_back(op);
       }
       break;
     }
@@ -971,7 +1027,8 @@ void Objecter::_scan_requests(OSDSession *s,
     ldout(cct, 10) << " checking op " << op->tid << dendl;
     bool force_resend_writes = cluster_full;
     if (pool_full_map)
-      force_resend_writes = force_resend_writes || (*pool_full_map)[op->target.base_oloc.pool];
+      force_resend_writes = force_resend_writes ||
+	(*pool_full_map)[op->target.base_oloc.pool];
     int r = _calc_target(&op->target, &op->last_force_resend);
     switch (r) {
     case RECALC_OP_TARGET_NO_ACTION:
@@ -1000,7 +1057,8 @@ void Objecter::_scan_requests(OSDSession *s,
     ldout(cct, 10) << " checking command " << c->tid << dendl;
     bool force_resend_writes = cluster_full;
     if (pool_full_map)
-      force_resend_writes = force_resend_writes || (*pool_full_map)[c->target_pg.pool()];
+      force_resend_writes = force_resend_writes ||
+	(*pool_full_map)[c->target_pg.pool()];
     int r = _calc_command_target(c);
     switch (r) {
     case RECALC_OP_TARGET_NO_ACTION:
@@ -1011,7 +1069,7 @@ void Objecter::_scan_requests(OSDSession *s,
     case RECALC_OP_TARGET_NEED_RESEND:
       need_resend_command[c->tid] = c;
       if (c->session) {
-        _session_command_op_remove(c->session, c);
+	_session_command_op_remove(c->session, c);
       }
       _command_cancel_map_check(c);
       break;
@@ -1020,7 +1078,7 @@ void Objecter::_scan_requests(OSDSession *s,
     case RECALC_OP_TARGET_OSD_DOWN:
       _check_command_map_dne(c);
       break;
-    }     
+    }
   }
 
   s->lock.unlock();
@@ -1039,7 +1097,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
   if (!initialized.read())
     return;
 
-  assert(osdmap); 
+  assert(osdmap);
 
   if (m->fsid != monc->get_fsid()) {
     ldout(cct, 0) << "handle_osd_map fsid " << m->fsid
@@ -1049,26 +1107,27 @@ void Objecter::handle_osd_map(MOSDMap *m)
 
   bool was_pauserd = osdmap->test_flag(CEPH_OSDMAP_PAUSERD);
   bool cluster_full = _osdmap_full_flag();
-  bool was_pausewr = osdmap->test_flag(CEPH_OSDMAP_PAUSEWR) || cluster_full || _osdmap_has_pool_full();
+  bool was_pausewr = osdmap->test_flag(CEPH_OSDMAP_PAUSEWR) || cluster_full ||
+    _osdmap_has_pool_full();
   map<int64_t, bool> pool_full_map;
-  for (map<int64_t, pg_pool_t>::const_iterator it = osdmap->get_pools().begin();
+  for (map<int64_t, pg_pool_t>::const_iterator it
+	 = osdmap->get_pools().begin();
        it != osdmap->get_pools().end(); ++it)
     pool_full_map[it->first] = _osdmap_pool_full(it->second);
 
-  
+
   list<LingerOp*> need_resend_linger;
   map<ceph_tid_t, Op*> need_resend;
   map<ceph_tid_t, CommandOp*> need_resend_command;
 
   if (m->get_last() <= osdmap->get_epoch()) {
-    ldout(cct, 3) << "handle_osd_map ignoring epochs [" 
-            << m->get_first() << "," << m->get_last() 
-            << "] <= " << osdmap->get_epoch() << dendl;
+    ldout(cct, 3) << "handle_osd_map ignoring epochs ["
+		  << m->get_first() << "," << m->get_last()
+		  << "] <= " << osdmap->get_epoch() << dendl;
   } else {
-    ldout(cct, 3) << "handle_osd_map got epochs [" 
-            << m->get_first() << "," << m->get_last() 
-            << "] > " << osdmap->get_epoch()
-            << dendl;
+    ldout(cct, 3) << "handle_osd_map got epochs ["
+		  << m->get_first() << "," << m->get_last()
+		  << "] > " << osdmap->get_epoch() << dendl;
 
     if (osdmap->get_epoch()) {
       bool skipped_map = false;
@@ -1076,7 +1135,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
       for (epoch_t e = osdmap->get_epoch() + 1;
 	   e <= m->get_last();
 	   e++) {
- 
+
 	if (osdmap->get_epoch() == e-1 &&
 	    m->incremental_maps.count(e)) {
 	  ldout(cct, 3) << "handle_osd_map decoding incremental epoch " << e
@@ -1107,10 +1166,10 @@ void Objecter::handle_osd_map(MOSDMap *m)
 	logger->set(l_osdc_map_epoch, osdmap->get_epoch());
 
 	cluster_full = cluster_full || _osdmap_full_flag();
-        update_pool_full_map(pool_full_map);
+	update_pool_full_map(pool_full_map);
 	_scan_requests(homeless_session, skipped_map, cluster_full,
-                       &pool_full_map, need_resend,
-                       need_resend_linger, need_resend_command);
+		       &pool_full_map, need_resend,
+		       need_resend_linger, need_resend_command);
 
 	// osd addr changes?
 	for (map<int,OSDSession*>::iterator p = osd_sessions.begin();
@@ -1118,7 +1177,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
 	  OSDSession *s = p->second;
 	  _scan_requests(s, skipped_map, cluster_full,
 			 &pool_full_map, need_resend,
-                         need_resend_linger, need_resend_command);
+			 need_resend_linger, need_resend_command);
 	  ++p;
 	  if (!osdmap->is_up(s->osd) ||
 	      (s->con &&
@@ -1129,16 +1188,16 @@ void Objecter::handle_osd_map(MOSDMap *m)
 
 	assert(e == osdmap->get_epoch());
       }
-      
+
     } else {
       // first map.  we want the full thing.
       if (m->maps.count(m->get_last())) {
-        for (map<int,OSDSession*>::iterator p = osd_sessions.begin();
+	for (map<int,OSDSession*>::iterator p = osd_sessions.begin();
 	     p != osd_sessions.end(); ++p) {
 	  OSDSession *s = p->second;
 	  _scan_requests(s, false, false, NULL, need_resend,
-                         need_resend_linger, need_resend_command);
-        }
+			 need_resend_linger, need_resend_command);
+	}
 	ldout(cct, 3) << "handle_osd_map decoding full epoch "
 		      << m->get_last() << dendl;
 	osdmap->decode(m->maps[m->get_last()]);
@@ -1156,10 +1215,12 @@ void Objecter::handle_osd_map(MOSDMap *m)
   }
 
   bool pauserd = osdmap->test_flag(CEPH_OSDMAP_PAUSERD);
-  bool pausewr = osdmap->test_flag(CEPH_OSDMAP_PAUSEWR) || _osdmap_full_flag() || _osdmap_has_pool_full();
+  bool pausewr = osdmap->test_flag(CEPH_OSDMAP_PAUSEWR) || _osdmap_full_flag()
+    || _osdmap_has_pool_full();
 
   // was/is paused?
-  if (was_pauserd || was_pausewr || pauserd || pausewr || osdmap->get_epoch() < epoch_barrier) {
+  if (was_pauserd || was_pausewr || pauserd || pausewr ||
+      osdmap->get_epoch() < epoch_barrier) {
     _maybe_request_map();
   }
 
@@ -1221,7 +1282,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
   }
 
   _dump_active();
-  
+
   // finish any Contexts that were waiting on a map update
   map<epoch_t,list< pair< Context*, int > > >::iterator p =
     waiting_for_map.begin();
@@ -1249,22 +1310,25 @@ void Objecter::C_Op_Map_Latest::finish(int r)
   if (r == -EAGAIN || r == -ECANCELED)
     return;
 
-  lgeneric_subdout(objecter->cct, objecter, 10) << "op_map_latest r=" << r << " tid=" << tid
-						<< " latest " << latest << dendl;
+  lgeneric_subdout(objecter->cct, objecter, 10)
+    << "op_map_latest r=" << r << " tid=" << tid
+    << " latest " << latest << dendl;
 
   RWLock::WLocker wl(objecter->rwlock);
 
   map<ceph_tid_t, Op*>::iterator iter =
     objecter->check_latest_map_ops.find(tid);
   if (iter == objecter->check_latest_map_ops.end()) {
-    lgeneric_subdout(objecter->cct, objecter, 10) << "op_map_latest op " << tid << " not found" << dendl;
+    lgeneric_subdout(objecter->cct, objecter, 10)
+      << "op_map_latest op "<< tid << " not found" << dendl;
     return;
   }
 
   Op *op = iter->second;
   objecter->check_latest_map_ops.erase(iter);
 
-  lgeneric_subdout(objecter->cct, objecter, 20) << "op_map_latest op " << op << dendl;
+  lgeneric_subdout(objecter->cct, objecter, 20)
+    << "op_map_latest op "<< op << dendl;
 
   if (op->map_dne_bound == 0)
     op->map_dne_bound = latest;
@@ -1274,7 +1338,8 @@ void Objecter::C_Op_Map_Latest::finish(int r)
   op->put();
 }
 
-int Objecter::pool_snap_by_name(int64_t poolid, const char *snap_name, snapid_t *snap)
+int Objecter::pool_snap_by_name(int64_t poolid, const char *snap_name,
+				snapid_t *snap)
 {
   RWLock::RLocker rl(rwlock);
 
@@ -1296,7 +1361,8 @@ int Objecter::pool_snap_by_name(int64_t poolid, const char *snap_name, snapid_t
   return -ENOENT;
 }
 
-int Objecter::pool_snap_get_info(int64_t poolid, snapid_t snap, pool_snap_info_t *info)
+int Objecter::pool_snap_get_info(int64_t poolid, snapid_t snap,
+				 pool_snap_info_t *info)
 {
   RWLock::RLocker rl(rwlock);
 
@@ -1366,11 +1432,11 @@ void Objecter::_check_op_pool_dne(Op *op, bool session_locked)
       assert(s != NULL);
 
       if (!session_locked) {
-        s->lock.get_write();
+	s->lock.get_write();
       }
       _finish_op(op, 0);
       if (!session_locked) {
-        s->lock.unlock();
+	s->lock.unlock();
       }
     }
   } else {
@@ -1563,7 +1629,8 @@ void Objecter::_command_cancel_map_check(CommandOp *c)
 /**
  * Look up OSDSession by OSD id.
  *
- * @returns 0 on success, or -EAGAIN if the lock context requires promotion to write.
+ * @returns 0 on success, or -EAGAIN if the lock context requires
+ * promotion to write.
  */
 int Objecter::_get_session(int osd, OSDSession **session, RWLock::Context& lc)
 {
@@ -1571,7 +1638,8 @@ int Objecter::_get_session(int osd, OSDSession **session, RWLock::Context& lc)
 
   if (osd < 0) {
     *session = homeless_session;
-    ldout(cct, 20) << __func__ << " osd=" << osd << " returning homeless" << dendl;
+    ldout(cct, 20) << __func__ << " osd=" << osd << " returning homeless"
+		   << dendl;
     return 0;
   }
 
@@ -1580,7 +1648,8 @@ int Objecter::_get_session(int osd, OSDSession **session, RWLock::Context& lc)
     OSDSession *s = p->second;
     s->get();
     *session = s;
-    ldout(cct, 20) << __func__ << " s=" << s << " osd=" << osd << " " << s->get_nref() << dendl;
+    ldout(cct, 20) << __func__ << " s=" << s << " osd=" << osd << " "
+		   << s->get_nref() << dendl;
     return 0;
   }
   if (!lc.is_wlocked()) {
@@ -1593,14 +1662,16 @@ int Objecter::_get_session(int osd, OSDSession **session, RWLock::Context& lc)
   logger->inc(l_osdc_osd_sessions, osd_sessions.size());
   s->get();
   *session = s;
-  ldout(cct, 20) << __func__ << " s=" << s << " osd=" << osd << " " << s->get_nref() << dendl;
+  ldout(cct, 20) << __func__ << " s=" << s << " osd=" << osd << " "
+		 << s->get_nref() << dendl;
   return 0;
 }
 
 void Objecter::put_session(Objecter::OSDSession *s)
 {
   if (s && !s->is_homeless()) {
-    ldout(cct, 20) << __func__ << " s=" << s << " osd=" << s->osd << " " << s->get_nref() << dendl;
+    ldout(cct, 20) << __func__ << " s=" << s << " osd=" << s->osd << " "
+		   << s->get_nref() << dendl;
     s->put();
   }
 }
@@ -1610,7 +1681,8 @@ void Objecter::get_session(Objecter::OSDSession *s)
   assert(s != NULL);
 
   if (!s->is_homeless()) {
-    ldout(cct, 20) << __func__ << " s=" << s << " osd=" << s->osd << " " << s->get_nref() << dendl;
+    ldout(cct, 20) << __func__ << " s=" << s << " osd=" << s->osd << " "
+		   << s->get_nref() << dendl;
     s->get();
   }
 }
@@ -1620,7 +1692,8 @@ void Objecter::_reopen_session(OSDSession *s)
   assert(s->lock.is_locked());
 
   entity_inst_t inst = osdmap->get_inst(s->osd);
-  ldout(cct, 10) << "reopen_session osd." << s->osd << " session, addr now " << inst << dendl;
+  ldout(cct, 10) << "reopen_session osd." << s->osd << " session, addr now "
+		 << inst << dendl;
   if (s->con) {
     s->con->mark_down();
     logger->inc(l_osdc_osd_session_close);
@@ -1674,15 +1747,15 @@ void Objecter::close_session(OSDSession *s)
   {
     RWLock::WLocker wl(homeless_session->lock);
     for (std::list<LingerOp*>::iterator i = homeless_lingers.begin();
-         i != homeless_lingers.end(); ++i) {
+	 i != homeless_lingers.end(); ++i) {
       _session_linger_op_assign(homeless_session, *i);
     }
     for (std::list<Op*>::iterator i = homeless_ops.begin();
-         i != homeless_ops.end(); ++i) {
+	 i != homeless_ops.end(); ++i) {
       _session_op_assign(homeless_session, *i);
     }
     for (std::list<CommandOp*>::iterator i = homeless_commands.begin();
-         i != homeless_commands.end(); ++i) {
+	 i != homeless_commands.end(); ++i) {
       _session_command_op_assign(homeless_session, *i);
     }
   }
@@ -1741,7 +1814,8 @@ void Objecter::get_latest_version(epoch_t oldest, epoch_t newest, Context *fin)
   _get_latest_version(oldest, newest, fin);
 }
 
-void Objecter::_get_latest_version(epoch_t oldest, epoch_t newest, Context *fin)
+void Objecter::_get_latest_version(epoch_t oldest, epoch_t newest,
+				   Context *fin)
 {
   assert(rwlock.is_wlocked());
   if (osdmap->get_epoch() >= newest) {
@@ -1768,9 +1842,11 @@ void Objecter::_maybe_request_map()
   if (_osdmap_full_flag()
       || osdmap->test_flag(CEPH_OSDMAP_PAUSERD)
       || osdmap->test_flag(CEPH_OSDMAP_PAUSEWR)) {
-    ldout(cct, 10) << "_maybe_request_map subscribing (continuous) to next osd map (FULL flag is set)" << dendl;
+    ldout(cct, 10) << "_maybe_request_map subscribing (continuous) to next "
+      "osd map (FULL flag is set)" << dendl;
   } else {
-    ldout(cct, 10) << "_maybe_request_map subscribing (onetime) to next osd map" << dendl;
+    ldout(cct, 10)
+      << "_maybe_request_map subscribing (onetime) to next osd map" << dendl;
     flag = CEPH_SUBSCRIBE_ONETIME;
   }
   epoch_t epoch = osdmap->get_epoch() ? osdmap->get_epoch()+1 : 0;
@@ -1789,13 +1865,13 @@ void Objecter::_wait_for_new_map(Context *c, epoch_t epoch, int err)
 
 /**
  * Use this together with wait_for_map: this is a pre-check to avoid
- * allocating a Context for wait_for_map if we can see that we definitely
- * already have the epoch.
+ * allocating a Context for wait_for_map if we can see that we
+ * definitely already have the epoch.
  *
- * This does *not* replace the need to handle the return value of wait_for_map:
- * just because we don't have it in this pre-check doesn't mean we won't
- * have it when calling back into wait_for_map, since the objecter lock
- * is dropped in between.
+ * This does *not* replace the need to handle the return value of
+ * wait_for_map: just because we don't have it in this pre-check
+ * doesn't mean we won't have it when calling back into wait_for_map,
+ * since the objecter lock is dropped in between.
  */
 bool Objecter::have_map(const epoch_t epoch)
 {
@@ -1831,13 +1907,15 @@ void Objecter::kick_requests(OSDSession *session)
   _linger_ops_resend(lresend);
 }
 
-void Objecter::_kick_requests(OSDSession *session, map<uint64_t, LingerOp *>& lresend)
+void Objecter::_kick_requests(OSDSession *session,
+			      map<uint64_t, LingerOp *>& lresend)
 {
   assert(rwlock.is_wlocked());
 
   // resend ops
   map<ceph_tid_t,Op*> resend;  // resend in tid order
-  for (map<ceph_tid_t, Op*>::iterator p = session->ops.begin(); p != session->ops.end();) {
+  for (map<ceph_tid_t, Op*>::iterator p = session->ops.begin();
+       p != session->ops.end();) {
     Op *op = p->second;
     ++p;
     logger->inc(l_osdc_op_resend);
@@ -1856,7 +1934,8 @@ void Objecter::_kick_requests(OSDSession *session, map<uint64_t, LingerOp *>& lr
   }
 
   // resend lingers
-  for (map<ceph_tid_t, LingerOp*>::iterator j = session->linger_ops.begin(); j != session->linger_ops.end(); ++j) {
+  for (map<ceph_tid_t, LingerOp*>::iterator j = session->linger_ops.begin();
+       j != session->linger_ops.end(); ++j) {
     LingerOp *op = j->second;
     op->get();
     logger->inc(l_osdc_linger_resend);
@@ -1866,7 +1945,8 @@ void Objecter::_kick_requests(OSDSession *session, map<uint64_t, LingerOp *>& lr
 
   // resend commands
   map<uint64_t,CommandOp*> cresend;  // resend in order
-  for (map<ceph_tid_t, CommandOp*>::iterator k = session->command_ops.begin(); k != session->command_ops.end(); ++k) {
+  for (map<ceph_tid_t, CommandOp*>::iterator k = session->command_ops.begin();
+       k != session->command_ops.end(); ++k) {
     logger->inc(l_osdc_command_resend);
     cresend[k->first] = k->second;
   }
@@ -1890,12 +1970,12 @@ void Objecter::_linger_ops_resend(map<uint64_t, LingerOp *>& lresend)
   }
 }
 
-void Objecter::schedule_tick()
+void Objecter::start_tick()
 {
-  Mutex::Locker l(timer_lock);
-  assert(tick_event == NULL);
-  tick_event = new C_Tick(this);
-  timer.add_event_after(cct->_conf->objecter_tick_interval, tick_event);
+  assert(tick_event == 0);
+  tick_event =
+    timer.add_event(ceph::make_timespan(cct->_conf->objecter_tick_interval),
+		    &Objecter::tick, this);
 }
 
 void Objecter::tick()
@@ -1905,8 +1985,7 @@ void Objecter::tick()
   ldout(cct, 10) << "tick" << dendl;
 
   // we are only called by C_Tick
-  assert(tick_event);
-  tick_event = NULL;
+  tick_event = 0;
 
   if (!initialized.read()) {
     // we raced with shutdown
@@ -1918,14 +1997,15 @@ void Objecter::tick()
 
 
   // look for laggy requests
-  utime_t cutoff = ceph_clock_now(cct);
-  cutoff -= cct->_conf->objecter_timeout;  // timeout
+  auto cutoff = ceph::mono_clock::now();
+  cutoff -= osd_timeout;  // timeout
 
   unsigned laggy_ops = 0;
 
-  for (map<int,OSDSession*>::iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  for (map<int,OSDSession*>::iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
-    RWLock::RLocker l(s->lock);
+    RWLock::WLocker l(s->lock);
     bool found = false;
     for (map<ceph_tid_t,Op*>::iterator p = s->ops.begin();
 	p != s->ops.end();
@@ -1933,7 +2013,8 @@ void Objecter::tick()
       Op *op = p->second;
       assert(op->session);
       if (op->stamp < cutoff) {
-	ldout(cct, 2) << " tid " << p->first << " on osd." << op->session->osd << " is laggy" << dendl;
+	ldout(cct, 2) << " tid " << p->first << " on osd." << op->session->osd
+		      << " is laggy" << dendl;
 	found = true;
 	++laggy_ops;
       }
@@ -1944,7 +2025,8 @@ void Objecter::tick()
       LingerOp *op = p->second;
       RWLock::WLocker wl(op->watch_lock);
       assert(op->session);
-      ldout(cct, 10) << " pinging osd that serves lingering tid " << p->first << " (osd." << op->session->osd << ")" << dendl;
+      ldout(cct, 10) << " pinging osd that serves lingering tid " << p->first
+		     << " (osd." << op->session->osd << ")" << dendl;
       found = true;
       if (op->is_watch && op->registered && !op->last_error)
 	_send_linger_ping(op);
@@ -1954,7 +2036,8 @@ void Objecter::tick()
 	++p) {
       CommandOp *op = p->second;
       assert(op->session);
-      ldout(cct, 10) << " pinging osd that serves command tid " << p->first << " (osd." << op->session->osd << ")" << dendl;
+      ldout(cct, 10) << " pinging osd that serves command tid " << p->first
+		     << " (osd." << op->session->osd << ")" << dendl;
       found = true;
     }
     if (found)
@@ -1977,8 +2060,11 @@ void Objecter::tick()
     }
   }
 
-  // reschedule
-  schedule_tick();
+  // Make sure we don't resechedule if we wake up after shutdown
+  if (initialized.read()) {
+    tick_event = timer.reschedule_me(ceph::make_timespan(
+				       cct->_conf->objecter_tick_interval));
+  }
 }
 
 void Objecter::resend_mon_ops()
@@ -1987,17 +2073,23 @@ void Objecter::resend_mon_ops()
 
   ldout(cct, 10) << "resend_mon_ops" << dendl;
 
-  for (map<ceph_tid_t,PoolStatOp*>::iterator p = poolstat_ops.begin(); p!=poolstat_ops.end(); ++p) {
+  for (map<ceph_tid_t,PoolStatOp*>::iterator p = poolstat_ops.begin();
+       p != poolstat_ops.end();
+       ++p) {
     _poolstat_submit(p->second);
     logger->inc(l_osdc_poolstat_resend);
   }
 
-  for (map<ceph_tid_t,StatfsOp*>::iterator p = statfs_ops.begin(); p!=statfs_ops.end(); ++p) {
+  for (map<ceph_tid_t,StatfsOp*>::iterator p = statfs_ops.begin();
+       p != statfs_ops.end();
+       ++p) {
     _fs_stats_submit(p->second);
     logger->inc(l_osdc_statfs_resend);
   }
 
-  for (map<ceph_tid_t,PoolOp*>::iterator p = pool_ops.begin(); p!=pool_ops.end(); ++p) {
+  for (map<ceph_tid_t,PoolOp*>::iterator p = pool_ops.begin();
+       p != pool_ops.end();
+       ++p) {
     _pool_op_submit(p->second);
     logger->inc(l_osdc_poolop_resend);
   }
@@ -2012,11 +2104,13 @@ void Objecter::resend_mon_ops()
   for (map<uint64_t, LingerOp*>::iterator p = check_latest_map_lingers.begin();
        p != check_latest_map_lingers.end();
        ++p) {
-    C_Linger_Map_Latest *c = new C_Linger_Map_Latest(this, p->second->linger_id);
+    C_Linger_Map_Latest *c
+      = new C_Linger_Map_Latest(this, p->second->linger_id);
     monc->get_version("osdmap", &c->latest, NULL, c);
   }
 
-  for (map<uint64_t, CommandOp*>::iterator p = check_latest_map_commands.begin();
+  for (map<uint64_t, CommandOp*>::iterator p
+	 = check_latest_map_commands.begin();
        p != check_latest_map_commands.end();
        ++p) {
     C_Command_Map_Latest *c = new C_Command_Map_Latest(this, p->second->tid);
@@ -2024,21 +2118,8 @@ void Objecter::resend_mon_ops()
   }
 }
 
-
-
 // read | write ---------------------------
 
-class C_CancelOp : public Context
-{
-  ceph_tid_t tid;
-  Objecter *objecter;
-public:
-  C_CancelOp(ceph_tid_t tid, Objecter *objecter) : tid(tid), objecter(objecter) {}
-  void finish(int r) {
-    objecter->op_cancel(tid, -ETIMEDOUT);
-  }
-};
-
 ceph_tid_t Objecter::op_submit(Op *op, int *ctx_budget)
 {
   RWLock::RLocker rl(rwlock);
@@ -2046,7 +2127,8 @@ ceph_tid_t Objecter::op_submit(Op *op, int *ctx_budget)
   return _op_submit_with_budget(op, lc, ctx_budget);
 }
 
-ceph_tid_t Objecter::_op_submit_with_budget(Op *op, RWLock::Context& lc, int *ctx_budget)
+ceph_tid_t Objecter::_op_submit_with_budget(Op *op, RWLock::Context& lc,
+					    int *ctx_budget)
 {
   assert(initialized.read());
 
@@ -2065,12 +2147,13 @@ ceph_tid_t Objecter::_op_submit_with_budget(Op *op, RWLock::Context& lc, int *ct
     }
   }
 
-  if (osd_timeout > 0) {
+  if (osd_timeout > timespan(0)) {
     if (op->tid == 0)
       op->tid = last_tid.inc();
-    op->ontimeout = new C_CancelOp(op->tid, this);
-    Mutex::Locker l(timer_lock);
-    timer.add_event_after(osd_timeout, op->ontimeout);
+    auto tid = op->tid;
+    op->ontimeout = timer.add_event(osd_timeout,
+				    [this, tid]() {
+				      op_cancel(tid, -ETIMEDOUT); });
   }
 
   return _op_submit(op, lc);
@@ -2095,7 +2178,8 @@ void Objecter::_send_op_account(Op *op)
   logger->inc(l_osdc_op_active);
   logger->inc(l_osdc_op);
 
-  if ((op->target.flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE)) == (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE))
+  if ((op->target.flags & (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_WRITE)) ==
+      (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE))
     logger->inc(l_osdc_op_rmw);
   else if (op->target.flags & CEPH_OSD_FLAG_WRITE)
     logger->inc(l_osdc_op_w);
@@ -2164,7 +2248,9 @@ ceph_tid_t Objecter::_op_submit(Op *op, RWLock::Context& lc)
   assert(op->session == NULL);
   OSDSession *s = NULL;
 
-  bool const check_for_latest_map = _calc_target(&op->target, &op->last_force_resend) == RECALC_OP_TARGET_POOL_DNE;
+  bool const check_for_latest_map = _calc_target(&op->target,
+						 &op->last_force_resend)
+    == RECALC_OP_TARGET_POOL_DNE;
 
   // Try to get a session, including a retry if we need to take write lock
   int r = _get_session(op->target.osd, &s, lc);
@@ -2185,10 +2271,10 @@ ceph_tid_t Objecter::_op_submit(Op *op, RWLock::Context& lc)
 
   // send?
   ldout(cct, 10) << "_op_submit oid " << op->target.base_oid
-           << " " << op->target.base_oloc << " " << op->target.target_oloc
-	   << " " << op->ops << " tid " << op->tid
-           << " osd." << (!s->is_homeless() ? s->osd : -1)
-           << dendl;
+		 << " '" << op->target.base_oloc << "' '"
+		 << op->target.target_oloc << "' " << op->ops << " tid "
+		 << op->tid << " osd." << (!s->is_homeless() ? s->osd : -1)
+		 << dendl;
 
   assert(op->target.flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE));
 
@@ -2196,23 +2282,23 @@ ceph_tid_t Objecter::_op_submit(Op *op, RWLock::Context& lc)
 
   if ((op->target.flags & CEPH_OSD_FLAG_WRITE) &&
       osdmap->test_flag(CEPH_OSDMAP_PAUSEWR)) {
-    ldout(cct, 10) << " paused modify " << op << " tid " << last_tid.read()
+    ldout(cct, 10) << " paused modify " << op << " tid " << op->tid
 		   << dendl;
     op->target.paused = true;
     _maybe_request_map();
   } else if ((op->target.flags & CEPH_OSD_FLAG_READ) &&
 	     osdmap->test_flag(CEPH_OSDMAP_PAUSERD)) {
-    ldout(cct, 10) << " paused read " << op << " tid " << last_tid.read()
+    ldout(cct, 10) << " paused read " << op << " tid " << op->tid
 		   << dendl;
     op->target.paused = true;
     _maybe_request_map();
   } else if ((op->target.flags & CEPH_OSD_FLAG_WRITE) &&
 	     !(op->target.flags & (CEPH_OSD_FLAG_FULL_TRY |
 				   CEPH_OSD_FLAG_FULL_FORCE)) &&
-             (_osdmap_full_flag() ||
+	     (_osdmap_full_flag() ||
 	      _osdmap_pool_full(op->target.base_oloc.pool))) {
-    ldout(cct, 0) << " FULL, paused modify " << op << " tid " << last_tid.read()
-		  << dendl;
+    ldout(cct, 0) << " FULL, paused modify " << op << " tid "
+		  << op->tid << dendl;
     op->target.paused = true;
     _maybe_request_map();
   } else if (!s->is_homeless()) {
@@ -2235,8 +2321,8 @@ ceph_tid_t Objecter::_op_submit(Op *op, RWLock::Context& lc)
     _send_op(op, m);
   }
 
-  // Last chance to touch Op here, after giving up session lock it can be
-  // freed at any time by response handler.
+  // Last chance to touch Op here, after giving up session lock it can
+  // be freed at any time by response handler.
   ceph_tid_t tid = op->tid;
   if (check_for_latest_map) {
     _send_op_map_check(op);
@@ -2246,7 +2332,8 @@ ceph_tid_t Objecter::_op_submit(Op *op, RWLock::Context& lc)
   s->lock.unlock();
   put_session(s);
 
-  ldout(cct, 5) << num_unacked.read() << " unacked, " << num_uncommitted.read() << " uncommitted" << dendl;
+  ldout(cct, 5) << num_unacked.read() << " unacked, " << num_uncommitted.read()
+		<< " uncommitted" << dendl;
 
   return tid;
 }
@@ -2259,7 +2346,8 @@ int Objecter::op_cancel(OSDSession *s, ceph_tid_t tid, int r)
 
   map<ceph_tid_t, Op*>::iterator p = s->ops.find(tid);
   if (p == s->ops.end()) {
-    ldout(cct, 10) << __func__ << " tid " << tid << " dne in session " << s->osd << dendl;
+    ldout(cct, 10) << __func__ << " tid " << tid << " dne in session "
+		   << s->osd << dendl;
     return -ENOENT;
   }
 
@@ -2269,7 +2357,8 @@ int Objecter::op_cancel(OSDSession *s, ceph_tid_t tid, int r)
     s->con->revoke_rx_buffer(tid);
   }
 
-  ldout(cct, 10) << __func__ << " tid " << tid << " in session " << s->osd << dendl;
+  ldout(cct, 10) << __func__ << " tid " << tid << " in session " << s->osd
+		 << dendl;
   Op *op = p->second;
   if (op->onack) {
     op->onack->complete(r);
@@ -2308,26 +2397,29 @@ int Objecter::_op_cancel(ceph_tid_t tid, int r)
 {
   int ret = 0;
 
-  ldout(cct, 5) << __func__ << ": cancelling tid " << tid << " r=" << r << dendl;
+  ldout(cct, 5) << __func__ << ": cancelling tid " << tid << " r=" << r
+		<< dendl;
 
 start:
 
-  for (map<int, OSDSession *>::iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  for (map<int, OSDSession *>::iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
     s->lock.get_read();
     if (s->ops.find(tid) != s->ops.end()) {
       s->lock.unlock();
       ret = op_cancel(s, tid, r);
       if (ret == -ENOENT) {
-        /* oh no! raced, maybe tid moved to another session, restarting */
-        goto start;
+	/* oh no! raced, maybe tid moved to another session, restarting */
+	goto start;
       }
       return ret;
     }
     s->lock.unlock();
   }
 
-  ldout(cct, 5) << __func__ << ": tid " << tid << " not found in live sessions" << dendl;
+  ldout(cct, 5) << __func__ << ": tid " << tid
+		<< " not found in live sessions" << dendl;
 
   // Handle case where the op is in homeless session
   homeless_session->lock.get_read();
@@ -2344,7 +2436,8 @@ start:
     homeless_session->lock.unlock();
   }
 
-  ldout(cct, 5) << __func__ << ": tid " << tid << " not found in homeless session" << dendl;
+  ldout(cct, 5) << __func__ << ": tid " << tid
+		<< " not found in homeless session" << dendl;
 
   return ret;
 }
@@ -2357,20 +2450,25 @@ epoch_t Objecter::op_cancel_writes(int r, int64_t pool)
   std::vector<ceph_tid_t> to_cancel;
   bool found = false;
 
-  for (map<int, OSDSession *>::iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  for (map<int, OSDSession *>::iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
     s->lock.get_read();
-    for (map<ceph_tid_t, Op*>::iterator op_i = s->ops.begin(); op_i != s->ops.end(); ++op_i) {
+    for (map<ceph_tid_t, Op*>::iterator op_i = s->ops.begin();
+	 op_i != s->ops.end(); ++op_i) {
       if (op_i->second->target.flags & CEPH_OSD_FLAG_WRITE
-        && (pool == -1 || op_i->second->target.target_oloc.pool == pool)) {
-        to_cancel.push_back(op_i->first);
+	  && (pool == -1 || op_i->second->target.target_oloc.pool == pool)) {
+	to_cancel.push_back(op_i->first);
       }
     }
     s->lock.unlock();
 
-    for (std::vector<ceph_tid_t>::iterator titer = to_cancel.begin(); titer != to_cancel.end(); ++titer) {
+    for (std::vector<ceph_tid_t>::iterator titer = to_cancel.begin();
+	 titer != to_cancel.end();
+	 ++titer) {
       int cancel_result = op_cancel(s, *titer, r);
-      // We hold rwlock across search and cancellation, so cancels should always succeed
+      // We hold rwlock across search and cancellation, so cancels
+      // should always succeed
       assert(cancel_result == 0);
     }
     if (!found && to_cancel.size())
@@ -2412,12 +2510,11 @@ bool Objecter::target_should_be_paused(op_target_t *t)
   const pg_pool_t *pi = osdmap->get_pg_pool(t->base_oloc.pool);
   bool pauserd = osdmap->test_flag(CEPH_OSDMAP_PAUSERD);
   bool pausewr = osdmap->test_flag(CEPH_OSDMAP_PAUSEWR) ||
-                 _osdmap_full_flag() ||
-                 _osdmap_pool_full(*pi);
+    _osdmap_full_flag() || _osdmap_pool_full(*pi);
 
   return (t->flags & CEPH_OSD_FLAG_READ && pauserd) ||
-         (t->flags & CEPH_OSD_FLAG_WRITE && pausewr) ||
-         (osdmap->get_epoch() < epoch_barrier);
+    (t->flags & CEPH_OSD_FLAG_WRITE && pausewr) ||
+    (osdmap->get_epoch() < epoch_barrier);
 }
 
 /**
@@ -2454,7 +2551,8 @@ bool Objecter::_osdmap_pool_full(const int64_t pool_id) const
 
 bool Objecter::_osdmap_has_pool_full() const
 {
-  for (map<int64_t, pg_pool_t>::const_iterator it = osdmap->get_pools().begin();
+  for (map<int64_t, pg_pool_t>::const_iterator it
+	 = osdmap->get_pools().begin();
        it != osdmap->get_pools().end(); ++it) {
     if (_osdmap_pool_full(it->second))
       return true;
@@ -2478,12 +2576,14 @@ bool Objecter::_osdmap_full_flag() const
 
 void Objecter::update_pool_full_map(map<int64_t, bool>& pool_full_map)
 {
-  for (map<int64_t, pg_pool_t>::const_iterator it = osdmap->get_pools().begin();
+  for (map<int64_t, pg_pool_t>::const_iterator it
+	 = osdmap->get_pools().begin();
        it != osdmap->get_pools().end(); ++it) {
     if (pool_full_map.find(it->first) == pool_full_map.end()) {
       pool_full_map[it->first] = _osdmap_pool_full(it->second);
     } else {
-      pool_full_map[it->first] = _osdmap_pool_full(it->second) || pool_full_map[it->first];
+      pool_full_map[it->first] = _osdmap_pool_full(it->second) ||
+	pool_full_map[it->first];
     }
   }
 }
@@ -2506,7 +2606,8 @@ int64_t Objecter::get_object_pg_hash_position(int64_t pool, const string& key,
   return p->raw_hash_to_pg(p->hash_key(key, ns));
 }
 
-int Objecter::_calc_target(op_target_t *t, epoch_t *last_force_resend,  bool any_change)
+int Objecter::_calc_target(op_target_t *t, epoch_t *last_force_resend,
+			   bool any_change)
 {
   assert(rwlock.is_locked());
 
@@ -2536,7 +2637,7 @@ int Objecter::_calc_target(op_target_t *t, epoch_t *last_force_resend,  bool any
     t->target_oloc = t->base_oloc;
     need_check_tiering = true;
   }
-  
+
   if (need_check_tiering &&
       (t->flags & CEPH_OSD_FLAG_IGNORE_OVERLAY) == 0) {
     if (is_read && pi->has_read_tier())
@@ -2574,23 +2675,23 @@ int Objecter::_calc_target(op_target_t *t, epoch_t *last_force_resend,  bool any
   bool sort_bitwise = osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE);
   unsigned prev_seed = ceph_stable_mod(pgid.ps(), t->pg_num, t->pg_num_mask);
   if (any_change && pg_interval_t::is_new_interval(
-          t->acting_primary,
-	  acting_primary,
-	  t->acting,
-	  acting,
-	  t->up_primary,
-	  up_primary,
-	  t->up,
-	  up,
-	  t->size,
-	  size,
-	  t->min_size,
-	  min_size,
-	  t->pg_num,
-	  pg_num,
-	  t->sort_bitwise,
-	  sort_bitwise,
-	  pg_t(prev_seed, pgid.pool(), pgid.preferred()))) {
+	t->acting_primary,
+	acting_primary,
+	t->acting,
+	acting,
+	t->up_primary,
+	up_primary,
+	t->up,
+	up,
+	t->size,
+	size,
+	t->min_size,
+	min_size,
+	t->pg_num,
+	pg_num,
+	t->sort_bitwise,
+	sort_bitwise,
+	pg_t(prev_seed, pgid.pool(), pgid.preferred()))) {
     force_resend = true;
   }
 
@@ -2630,7 +2731,8 @@ int Objecter::_calc_target(op_target_t *t, epoch_t *last_force_resend,  bool any
 	if (p)
 	  t->used_replica = true;
 	osd = acting[p];
-	ldout(cct, 10) << " chose random osd." << osd << " of " << acting << dendl;
+	ldout(cct, 10) << " chose random osd." << osd << " of " << acting
+		       << dendl;
       } else if (read && (t->flags & CEPH_OSD_FLAG_LOCALIZE_READS) &&
 		 acting.size() > 1) {
 	// look for a local replica.  prefer the primary if the
@@ -2721,7 +2823,8 @@ void Objecter::_session_linger_op_assign(OSDSession *to, LingerOp *op)
   op->session = to;
   to->linger_ops[op->linger_id] = op;
 
-  ldout(cct, 15) << __func__ << " " << to->osd << " " << op->linger_id << dendl;
+  ldout(cct, 15) << __func__ << " " << to->osd << " " << op->linger_id
+		 << dendl;
 }
 
 void Objecter::_session_linger_op_remove(OSDSession *from, LingerOp *op)
@@ -2737,7 +2840,8 @@ void Objecter::_session_linger_op_remove(OSDSession *from, LingerOp *op)
   put_session(from);
   op->session = NULL;
 
-  ldout(cct, 15) << __func__ << " " << from->osd << " " << op->linger_id << dendl;
+  ldout(cct, 15) << __func__ << " " << from->osd << " " << op->linger_id
+		 << dendl;
 }
 
 void Objecter::_session_command_op_remove(OSDSession *from, CommandOp *op)
@@ -2773,24 +2877,27 @@ void Objecter::_session_command_op_assign(OSDSession *to, CommandOp *op)
   ldout(cct, 15) << __func__ << " " << to->osd << " " << op->tid << dendl;
 }
 
-int Objecter::_recalc_linger_op_target(LingerOp *linger_op, RWLock::Context& lc)
+int Objecter::_recalc_linger_op_target(LingerOp *linger_op,
+				       RWLock::Context& lc)
 {
   assert(rwlock.is_wlocked());
 
-  int r = _calc_target(&linger_op->target, &linger_op->last_force_resend, true);
+  int r = _calc_target(&linger_op->target, &linger_op->last_force_resend,
+		       true);
   if (r == RECALC_OP_TARGET_NEED_RESEND) {
     ldout(cct, 10) << "recalc_linger_op_target tid " << linger_op->linger_id
 		   << " pgid " << linger_op->target.pgid
 		   << " acting " << linger_op->target.acting << dendl;
-    
+
     OSDSession *s = NULL;
     r = _get_session(linger_op->target.osd, &s, lc);
     assert(r == 0);
 
     if (linger_op->session != s) {
-      // NB locking two sessions (s and linger_op->session) at the same time here
-      // is only safe because we are the only one that takes two, and we are
-      // holding rwlock for write.  Disable lockdep because it doesn't know that.
+      // NB locking two sessions (s and linger_op->session) at the
+      // same time here is only safe because we are the only one that
+      // takes two, and we are holding rwlock for write.  Disable
+      // lockdep because it doesn't know that.
       s->lock.get_write(false);
       _session_linger_op_remove(linger_op->session, linger_op);
       _session_linger_op_assign(s, linger_op);
@@ -2830,10 +2937,8 @@ void Objecter::_finish_op(Op *op, int r)
   if (!op->ctx_budgeted && op->budgeted)
     put_op_budget(op);
 
-  if (op->ontimeout && r != -ETIMEDOUT) {
-    Mutex::Locker l(timer_lock);
+  if (op->ontimeout && r != -ETIMEDOUT)
     timer.cancel_event(op->ontimeout);
-  }
 
   _session_op_remove(op->session, op);
 
@@ -2850,7 +2955,7 @@ void Objecter::finish_op(OSDSession *session, ceph_tid_t tid)
 {
   ldout(cct, 15) << "finish_op " << tid << dendl;
   RWLock::RLocker rl(rwlock);
-  
+
   RWLock::WLocker wl(session->lock);
 
   map<ceph_tid_t, Op *>::iterator iter = session->ops.find(tid);
@@ -2877,9 +2982,9 @@ MOSDOp *Objecter::_prepare_osd_op(Op *op)
     flags |= CEPH_OSD_FLAG_FULL_FORCE;
 
   op->target.paused = false;
-  op->stamp = ceph_clock_now(cct);
+  op->stamp = ceph::mono_clock::now();
 
-  MOSDOp *m = new MOSDOp(client_inc.read(), op->tid, 
+  MOSDOp *m = new MOSDOp(client_inc.read(), op->tid,
 			 op->target.target_oid, op->target.target_oloc,
 			 op->target.pgid,
 			 osdmap->get_epoch(),
@@ -2921,20 +3026,23 @@ void Objecter::_send_op(Op *op, MOSDOp *m)
     m = _prepare_osd_op(op);
   }
 
-  ldout(cct, 15) << "_send_op " << op->tid << " to osd." << op->session->osd << dendl;
+  ldout(cct, 15) << "_send_op " << op->tid << " to osd." << op->session->osd
+		 << dendl;
 
   ConnectionRef con = op->session->con;
   assert(con);
 
   // preallocated rx buffer?
   if (op->con) {
-    ldout(cct, 20) << " revoking rx buffer for " << op->tid << " on " << op->con << dendl;
+    ldout(cct, 20) << " revoking rx buffer for " << op->tid << " on "
+		   << op->con << dendl;
     op->con->revoke_rx_buffer(op->tid);
   }
   if (op->outbl &&
-      op->ontimeout == NULL &&  // only post rx_buffer if no timeout; see #9582
+      op->ontimeout == 0 &&  // only post rx_buffer if no timeout; see #9582
       op->outbl->length()) {
-    ldout(cct, 20) << " posting rx buffer for " << op->tid << " on " << con << dendl;
+    ldout(cct, 20) << " posting rx buffer for " << op->tid << " on " << con
+		   << dendl;
     op->con = con;
     op->con->post_rx_buffer(op->tid, *op->outbl);
   }
@@ -2956,10 +3064,10 @@ int Objecter::calc_op_budget(Op *op)
       op_budget += i->indata.length();
     } else if (ceph_osd_op_mode_read(i->op.op)) {
       if (ceph_osd_op_type_data(i->op.op)) {
-        if ((int64_t)i->op.extent.length > 0)
+	if ((int64_t)i->op.extent.length > 0)
 	  op_budget += (int64_t)i->op.extent.length;
       } else if (ceph_osd_op_type_attr(i->op.op)) {
-        op_budget += i->op.xattr.name_len + i->op.xattr.value_len;
+	op_budget += i->op.xattr.name_len + i->op.xattr.value_len;
       }
     }
   }
@@ -3032,8 +3140,9 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
   map<ceph_tid_t, Op *>::iterator iter = s->ops.find(tid);
   if (iter == s->ops.end()) {
     ldout(cct, 7) << "handle_osd_op_reply " << tid
-	    << (m->is_ondisk() ? " ondisk":(m->is_onnvram() ? " onnvram":" ack"))
-	    << " ... stray" << dendl;
+		  << (m->is_ondisk() ? " ondisk" : (m->is_onnvram() ?
+						    " onnvram" : " ack"))
+		  << " ... stray" << dendl;
     s->lock.unlock();
     put_session(s);
     m->put();
@@ -3041,8 +3150,10 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
   }
 
   ldout(cct, 7) << "handle_osd_op_reply " << tid
-		<< (m->is_ondisk() ? " ondisk":(m->is_onnvram() ? " onnvram":" ack"))
-		<< " v " << m->get_replay_version() << " uv " << m->get_user_version()
+		<< (m->is_ondisk() ? " ondisk" :
+		    (m->is_onnvram() ? " onnvram" : " ack"))
+		<< " v " << m->get_replay_version() << " uv "
+		<< m->get_user_version()
 		<< " in " << m->get_pg()
 		<< " attempt " << m->get_retry_attempt()
 		<< dendl;
@@ -3050,7 +3161,8 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
 
   if (m->get_retry_attempt() >= 0) {
     if (m->get_retry_attempt() != (op->attempts - 1)) {
-      ldout(cct, 7) << " ignoring reply from attempt " << m->get_retry_attempt()
+      ldout(cct, 7) << " ignoring reply from attempt "
+		    << m->get_retry_attempt()
 		    << " from " << m->get_source_inst()
 		    << "; last attempt " << (op->attempts - 1) << " sent to "
 		    << op->session->con->get_peer_addr() << dendl;
@@ -3126,7 +3238,7 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
   // per-op result demuxing
   vector<OSDOp> out_ops;
   m->claim_ops(out_ops);
-  
+
   if (out_ops.size() != op->ops.size())
     ldout(cct, 0) << "WARNING: tid " << op->tid << " reply ops " << out_ops
 		  << " != request ops " << op->ops
@@ -3183,7 +3295,8 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
   }
 
   /* get it before we call _finish_op() */
-  Mutex *completion_lock = (op->target.base_oid.name.size() ? s->get_lock(op->target.base_oid) : NULL);
+  Mutex *completion_lock = (op->target.base_oid.name.size() ?
+			    s->get_lock(op->target.base_oid) : NULL);
 
   // done with this tid?
   if (!op->onack && !op->oncommit && !op->oncommit_sync) {
@@ -3191,7 +3304,8 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
     _finish_op(op, 0);
   }
 
-  ldout(cct, 5) << num_unacked.read() << " unacked, " << num_uncommitted.read() << " uncommitted" << dendl;
+  ldout(cct, 5) << num_unacked.read() << " unacked, " << num_uncommitted.read()
+		<< " uncommitted" << dendl;
 
   // serialize completions
   if (completion_lock) {
@@ -3250,20 +3364,26 @@ void Objecter::list_nobjects(NListContext *list_context, Context *onfinish)
       list_context->at_end_of_pool = true;
       ldout(cct, 20) << " no more pgs; reached end of pool" << dendl;
     } else {
-      ldout(cct, 20) << " move to next pg " << list_context->current_pg << dendl;
+      ldout(cct, 20) << " move to next pg " << list_context->current_pg
+		     << dendl;
     }
   }
   if (list_context->at_end_of_pool) {
     // release the listing context's budget once all
     // OPs (in the session) are finished
     put_nlist_context_budget(list_context);
-
     onfinish->complete(0);
     return;
   }
 
   rwlock.get_read();
   const pg_pool_t *pool = osdmap->get_pg_pool(list_context->pool_id);
+  if (!pool) { // pool is gone
+    rwlock.unlock();
+    put_nlist_context_budget(list_context);
+    onfinish->complete(-ENOENT);
+    return;
+  }
   int pg_num = pool->get_pg_num();
   rwlock.unlock();
 
@@ -3272,8 +3392,10 @@ void Objecter::list_nobjects(NListContext *list_context, Context *onfinish)
     list_context->sort_bitwise = osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE);
     ldout(cct, 20) << pg_num << " placement groups" << dendl;
   }
-  if (list_context->sort_bitwise != osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE)) {
-    ldout(cct, 10) << " hobject sort order changed, restarting this pg" << dendl;
+  if (list_context->sort_bitwise !=
+      osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE)) {
+    ldout(cct, 10) << " hobject sort order changed, restarting this pg"
+		   << dendl;
     list_context->cookie = collection_list_handle_t();
     list_context->sort_bitwise = osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE);
   }
@@ -3288,14 +3410,15 @@ void Objecter::list_nobjects(NListContext *list_context, Context *onfinish)
   assert(list_context->current_pg <= pg_num);
 
   ObjectOperation op;
-  op.pg_nls(list_context->max_entries, list_context->filter, list_context->cookie,
-	     list_context->current_pg_epoch);
+  op.pg_nls(list_context->max_entries, list_context->filter,
+	    list_context->cookie, list_context->current_pg_epoch);
   list_context->bl.clear();
   C_NList *onack = new C_NList(list_context, onfinish, this);
   object_locator_t oloc(list_context->pool_id, list_context->nspace);
 
   pg_read(list_context->current_pg, oloc, op,
-	  &list_context->bl, 0, onack, &onack->epoch, &list_context->ctx_budget);
+	  &list_context->bl, 0, onack, &onack->epoch,
+	  &list_context->ctx_budget);
 }
 
 void Objecter::_nlist_reply(NListContext *list_context, int r,
@@ -3320,15 +3443,16 @@ void Objecter::_nlist_reply(NListContext *list_context, int r,
 
   int response_size = response.entries.size();
   ldout(cct, 20) << " response.entries.size " << response_size
-		 << ", response.entries " << response.entries << dendl;
+		 << ", response.entries " << response.entries
+		 << ", handle " << response.handle << dendl;
   list_context->extra_info.append(extra_info);
   if (response_size) {
     list_context->list.merge(response.entries);
   }
 
-  // if the osd returns 1 (newer code), or no entries, it means we
+  // if the osd returns 1 (newer code), or handle MAX, it means we
   // hit the end of the pg.
-  if (response_size == 0 || r == 1) {
+  if (response.handle.is_max() || r == 1) {
     ldout(cct, 20) << " at end of pg" << dendl;
     list_context->at_end_of_pg = true;
   } else {
@@ -3354,7 +3478,8 @@ void Objecter::_nlist_reply(NListContext *list_context, int r,
 
 void Objecter::put_nlist_context_budget(NListContext *list_context) {
     if (list_context->ctx_budget >= 0) {
-      ldout(cct, 10) << " release listing context's budget " << list_context->ctx_budget << dendl;
+      ldout(cct, 10) << " release listing context's budget " <<
+	list_context->ctx_budget << dendl;
       put_op_budget_bytes(list_context->ctx_budget);
       list_context->ctx_budget = -1;
     }
@@ -3395,20 +3520,26 @@ void Objecter::list_objects(ListContext *list_context, Context *onfinish)
       list_context->at_end_of_pool = true;
       ldout(cct, 20) << " no more pgs; reached end of pool" << dendl;
     } else {
-      ldout(cct, 20) << " move to next pg " << list_context->current_pg << dendl;
+      ldout(cct, 20) << " move to next pg " << list_context->current_pg
+		     << dendl;
     }
   }
   if (list_context->at_end_of_pool) {
     // release the listing context's budget once all
     // OPs (in the session) are finished
     put_list_context_budget(list_context);
-
     onfinish->complete(0);
     return;
   }
 
   rwlock.get_read();
   const pg_pool_t *pool = osdmap->get_pg_pool(list_context->pool_id);
+  if (!pool) { // pool is gone
+    rwlock.unlock();
+    put_list_context_budget(list_context);
+    onfinish->complete(-ENOENT);
+    return;
+  }
   int pg_num = pool->get_pg_num();
   rwlock.unlock();
 
@@ -3417,8 +3548,10 @@ void Objecter::list_objects(ListContext *list_context, Context *onfinish)
     list_context->sort_bitwise = osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE);
     ldout(cct, 20) << pg_num << " placement groups" << dendl;
   }
-  if (list_context->sort_bitwise != osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE)) {
-    ldout(cct, 10) << " hobject sort order changed, restarting this pg" << dendl;
+  if (list_context->sort_bitwise !=
+      osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE)) {
+    ldout(cct, 10) << " hobject sort order changed, restarting this pg"
+		   << dendl;
     list_context->cookie = collection_list_handle_t();
     list_context->sort_bitwise = osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE);
   }
@@ -3433,14 +3566,14 @@ void Objecter::list_objects(ListContext *list_context, Context *onfinish)
   assert(list_context->current_pg <= pg_num);
 
   ObjectOperation op;
-  op.pg_ls(list_context->max_entries, list_context->filter, list_context->cookie,
-	   list_context->current_pg_epoch);
+  op.pg_ls(list_context->max_entries, list_context->filter,
+	   list_context->cookie, list_context->current_pg_epoch);
   list_context->bl.clear();
   C_List *onack = new C_List(list_context, onfinish, this);
   object_locator_t oloc(list_context->pool_id, list_context->nspace);
 
-  pg_read(list_context->current_pg, oloc, op,
-	  &list_context->bl, 0, onack, &onack->epoch, &list_context->ctx_budget);
+  pg_read(list_context->current_pg, oloc, op, &list_context->bl, 0, onack,
+	  &onack->epoch, &list_context->ctx_budget);
 }
 
 void Objecter::_list_reply(ListContext *list_context, int r,
@@ -3465,15 +3598,16 @@ void Objecter::_list_reply(ListContext *list_context, int r,
 
   int response_size = response.entries.size();
   ldout(cct, 20) << " response.entries.size " << response_size
-		 << ", response.entries " << response.entries << dendl;
+		 << ", response.entries " << response.entries
+		 << ", handle " << response.handle << dendl;
   list_context->extra_info.append(extra_info);
   if (response_size) {
     list_context->list.merge(response.entries);
   }
 
-  // if the osd returns 1 (newer code), or no entries, it means we
+  // if the osd returns 1 (newer code), or handle == MAX, it means we
   // hit the end of the pg.
-  if (response_size == 0 || r == 1) {
+  if (response.handle.is_max() || r == 1) {
     ldout(cct, 20) << " at end of pg" << dendl;
     list_context->at_end_of_pg = true;
   } else {
@@ -3499,19 +3633,22 @@ void Objecter::_list_reply(ListContext *list_context, int r,
 
 void Objecter::put_list_context_budget(ListContext *list_context) {
     if (list_context->ctx_budget >= 0) {
-      ldout(cct, 10) << " release listing context's budget " << list_context->ctx_budget << dendl;
+      ldout(cct, 10) << " release listing context's budget "
+		     << list_context->ctx_budget << dendl;
       put_op_budget_bytes(list_context->ctx_budget);
       list_context->ctx_budget = -1;
     }
   }
 
 
-//snapshots
+// snapshots
 
-int Objecter::create_pool_snap(int64_t pool, string& snap_name, Context *onfinish)
+int Objecter::create_pool_snap(int64_t pool, string& snap_name,
+			       Context *onfinish)
 {
   RWLock::WLocker wl(rwlock);
-  ldout(cct, 10) << "create_pool_snap; pool: " << pool << "; snap: " << snap_name << dendl;
+  ldout(cct, 10) << "create_pool_snap; pool: " << pool << "; snap: "
+		 << snap_name << dendl;
 
   const pg_pool_t *p = osdmap->get_pg_pool(pool);
   if (!p)
@@ -3567,10 +3704,12 @@ int Objecter::allocate_selfmanaged_snap(int64_t pool, snapid_t *psnapid,
   return 0;
 }
 
-int Objecter::delete_pool_snap(int64_t pool, string& snap_name, Context *onfinish)
+int Objecter::delete_pool_snap(int64_t pool, string& snap_name,
+			       Context *onfinish)
 {
   RWLock::WLocker wl(rwlock);
-  ldout(cct, 10) << "delete_pool_snap; pool: " << pool << "; snap: " << snap_name << dendl;
+  ldout(cct, 10) << "delete_pool_snap; pool: " << pool << "; snap: "
+		 << snap_name << dendl;
 
   const pg_pool_t *p = osdmap->get_pg_pool(pool);
   if (!p)
@@ -3587,9 +3726,9 @@ int Objecter::delete_pool_snap(int64_t pool, string& snap_name, Context *onfinis
   op->onfinish = onfinish;
   op->pool_op = POOL_OP_DELETE_SNAP;
   pool_ops[op->tid] = op;
-  
+
   pool_op_submit(op);
-  
+
   return 0;
 }
 
@@ -3597,8 +3736,8 @@ int Objecter::delete_selfmanaged_snap(int64_t pool, snapid_t snap,
 				      Context *onfinish)
 {
   RWLock::WLocker wl(rwlock);
-  ldout(cct, 10) << "delete_selfmanaged_snap; pool: " << pool << "; snap: " 
-	   << snap << dendl;
+  ldout(cct, 10) << "delete_selfmanaged_snap; pool: " << pool << "; snap: "
+		 << snap << dendl;
   PoolOp *op = new PoolOp;
   if (!op) return -ENOMEM;
   op->tid = last_tid.inc();
@@ -3702,25 +3841,13 @@ int Objecter::change_pool_auid(int64_t pool, Context *onfinish, uint64_t auid)
   return 0;
 }
 
-class C_CancelPoolOp : public Context
-{
-  ceph_tid_t tid;
-  Objecter *objecter;
-public:
-  C_CancelPoolOp(ceph_tid_t tid, Objecter *objecter) : tid(tid),
-						       objecter(objecter) {}
-  void finish(int r) {
-    objecter->pool_op_cancel(tid, -ETIMEDOUT);
-  }
-};
-
 void Objecter::pool_op_submit(PoolOp *op)
 {
   assert(rwlock.is_locked());
-  if (mon_timeout > 0) {
-    Mutex::Locker l(timer_lock);
-    op->ontimeout = new C_CancelPoolOp(op->tid, this);
-    timer.add_event_after(mon_timeout, op->ontimeout);
+  if (mon_timeout > timespan(0)) {
+    op->ontimeout = timer.add_event(mon_timeout,
+				    [this, op]() {
+				      pool_op_cancel(op->tid, -ETIMEDOUT); });
   }
   _pool_op_submit(op);
 }
@@ -3736,7 +3863,7 @@ void Objecter::_pool_op_submit(PoolOp *op)
   if (op->snapid) m->snapid = op->snapid;
   if (op->crush_rule) m->crush_rule = op->crush_rule;
   monc->send_mon_message(m);
-  op->last_submit = ceph_clock_now(cct);
+  op->last_submit = ceph::mono_clock::now();
 
   logger->inc(l_osdc_poolop_send);
 }
@@ -3762,7 +3889,8 @@ void Objecter::handle_pool_op_reply(MPoolOpReply *m)
   map<ceph_tid_t, PoolOp *>::iterator iter = pool_ops.find(tid);
   if (iter != pool_ops.end()) {
     PoolOp *op = iter->second;
-    ldout(cct, 10) << "have request " << tid << " at " << op << " Op: " << ceph_pool_op_name(op->pool_op) << dendl;
+    ldout(cct, 10) << "have request " << tid << " at " << op << " Op: "
+		   << ceph_pool_op_name(op->pool_op) << dendl;
     if (op->blp)
       op->blp->claim(m->response_data);
     if (m->version > last_seen_osdmap_version)
@@ -3774,16 +3902,17 @@ void Objecter::handle_pool_op_reply(MPoolOpReply *m)
       // (for promotion) above.
       iter = pool_ops.find(tid);
       if (iter == pool_ops.end())
-        goto done; // op is gone.
+	goto done; // op is gone.
       if (osdmap->get_epoch() < m->epoch) {
-        ldout(cct, 20) << "waiting for client to reach epoch " << m->epoch << " before calling back" << dendl;
-        _wait_for_new_map(op->onfinish, m->epoch, m->replyCode);
+	ldout(cct, 20) << "waiting for client to reach epoch " << m->epoch
+		       << " before calling back" << dendl;
+	_wait_for_new_map(op->onfinish, m->epoch, m->replyCode);
       } else {
 	// map epoch changed, probably because a MOSDMap message
 	// sneaked in. Do caller-specified callback now or else
 	// we lose it forever.
 	assert(op->onfinish);
-	op->onfinish->complete(m->replyCode);	
+	op->onfinish->complete(m->replyCode);
       }
     }
     else {
@@ -3839,7 +3968,6 @@ void Objecter::_finish_pool_op(PoolOp *op, int r)
   logger->set(l_osdc_poolop_active, pool_ops.size());
 
   if (op->ontimeout && r != -ETIMEDOUT) {
-    Mutex::Locker l(timer_lock);
     timer.cancel_event(op->ontimeout);
   }
 
@@ -3848,20 +3976,8 @@ void Objecter::_finish_pool_op(PoolOp *op, int r)
 
 // pool stats
 
-class C_CancelPoolStatOp : public Context
-{
-  ceph_tid_t tid;
-  Objecter *objecter;
-public:
-  C_CancelPoolStatOp(ceph_tid_t tid, Objecter *objecter) : tid(tid),
-						           objecter(objecter) {}
-  void finish(int r) {
-    // note that objecter lock == timer lock, and is already held
-    objecter->pool_stat_op_cancel(tid, -ETIMEDOUT);
-  }
-};
-
-void Objecter::get_pool_stats(list<string>& pools, map<string,pool_stat_t> *result,
+void Objecter::get_pool_stats(list<string>& pools,
+			      map<string,pool_stat_t> *result,
 			      Context *onfinish)
 {
   ldout(cct, 10) << "get_pool_stats " << pools << dendl;
@@ -3871,11 +3987,13 @@ void Objecter::get_pool_stats(list<string>& pools, map<string,pool_stat_t> *resu
   op->pools = pools;
   op->pool_stats = result;
   op->onfinish = onfinish;
-  op->ontimeout = NULL;
-  if (mon_timeout > 0) {
-    Mutex::Locker l(timer_lock);
-    op->ontimeout = new C_CancelPoolStatOp(op->tid, this);
-    timer.add_event_after(mon_timeout, op->ontimeout);
+  if (mon_timeout > timespan(0)) {
+    op->ontimeout = timer.add_event(mon_timeout,
+				    [this, op]() {
+				      pool_stat_op_cancel(op->tid,
+							  -ETIMEDOUT); });
+  } else {
+    op->ontimeout = 0;
   }
 
   RWLock::WLocker wl(rwlock);
@@ -3890,8 +4008,10 @@ void Objecter::get_pool_stats(list<string>& pools, map<string,pool_stat_t> *resu
 void Objecter::_poolstat_submit(PoolStatOp *op)
 {
   ldout(cct, 10) << "_poolstat_submit " << op->tid << dendl;
-  monc->send_mon_message(new MGetPoolStats(monc->get_fsid(), op->tid, op->pools, last_seen_pgmap_version));
-  op->last_submit = ceph_clock_now(cct);
+  monc->send_mon_message(new MGetPoolStats(monc->get_fsid(), op->tid,
+					   op->pools,
+					   last_seen_pgmap_version));
+  op->last_submit = ceph::mono_clock::now();
 
   logger->inc(l_osdc_poolstat_send);
 }
@@ -3919,7 +4039,7 @@ void Objecter::handle_get_pool_stats_reply(MGetPoolStatsReply *m)
     _finish_pool_stat_op(op, 0);
   } else {
     ldout(cct, 10) << "unknown request " << tid << dendl;
-  } 
+  }
   ldout(cct, 10) << "done" << dendl;
   m->put();
 }
@@ -3952,26 +4072,12 @@ void Objecter::_finish_pool_stat_op(PoolStatOp *op, int r)
   poolstat_ops.erase(op->tid);
   logger->set(l_osdc_poolstat_active, poolstat_ops.size());
 
-  if (op->ontimeout && r != -ETIMEDOUT) {
-    Mutex::Locker l(timer_lock);
+  if (op->ontimeout && r != -ETIMEDOUT)
     timer.cancel_event(op->ontimeout);
-  }
 
   delete op;
 }
 
-class C_CancelStatfsOp : public Context
-{
-  ceph_tid_t tid;
-  Objecter *objecter;
-public:
-  C_CancelStatfsOp(ceph_tid_t tid, Objecter *objecter) : tid(tid),
-							 objecter(objecter) {}
-  void finish(int r) {
-    objecter->statfs_op_cancel(tid, -ETIMEDOUT);
-  }
-};
-
 void Objecter::get_fs_stats(ceph_statfs& result, Context *onfinish)
 {
   ldout(cct, 10) << "get_fs_stats" << dendl;
@@ -3981,11 +4087,13 @@ void Objecter::get_fs_stats(ceph_statfs& result, Context *onfinish)
   op->tid = last_tid.inc();
   op->stats = &result;
   op->onfinish = onfinish;
-  op->ontimeout = NULL;
-  if (mon_timeout > 0) {
-    Mutex::Locker l(timer_lock);
-    op->ontimeout = new C_CancelStatfsOp(op->tid, this);
-    timer.add_event_after(mon_timeout, op->ontimeout);
+  if (mon_timeout > timespan(0)) {
+    op->ontimeout = timer.add_event(mon_timeout,
+				    [this, op]() {
+				      statfs_op_cancel(op->tid,
+						       -ETIMEDOUT); });
+  } else {
+    op->ontimeout = 0;
   }
   statfs_ops[op->tid] = op;
 
@@ -3999,8 +4107,9 @@ void Objecter::_fs_stats_submit(StatfsOp *op)
   assert(rwlock.is_wlocked());
 
   ldout(cct, 10) << "fs_stats_submit" << op->tid << dendl;
-  monc->send_mon_message(new MStatfs(monc->get_fsid(), op->tid, last_seen_pgmap_version));
-  op->last_submit = ceph_clock_now(cct);
+  monc->send_mon_message(new MStatfs(monc->get_fsid(), op->tid,
+				     last_seen_pgmap_version));
+  op->last_submit = ceph::mono_clock::now();
 
   logger->inc(l_osdc_statfs_send);
 }
@@ -4059,17 +4168,16 @@ void Objecter::_finish_statfs_op(StatfsOp *op, int r)
   statfs_ops.erase(op->tid);
   logger->set(l_osdc_statfs_active, statfs_ops.size());
 
-  if (op->ontimeout && r != -ETIMEDOUT) {
-    Mutex::Locker l(timer_lock);
+  if (op->ontimeout && r != -ETIMEDOUT)
     timer.cancel_event(op->ontimeout);
-  }
 
   delete op;
 }
 
 // scatter/gather
 
-void Objecter::_sg_read_finish(vector<ObjectExtent>& extents, vector<bufferlist>& resultbl, 
+void Objecter::_sg_read_finish(vector<ObjectExtent>& extents,
+			       vector<bufferlist>& resultbl,
 			       bufferlist *bl, Context *onfinish)
 {
   // all done
@@ -4115,7 +4223,6 @@ bool Objecter::ms_handle_reset(Connection *con)
   if (!initialized.read())
     return false;
   if (con->get_peer_type() == CEPH_ENTITY_TYPE_OSD) {
-    //
     int osd = osdmap->identify_osd(con->get_peer_addr());
     if (osd >= 0) {
       ldout(cct, 1) << "ms_handle_reset on osd." << osd << dendl;
@@ -4127,19 +4234,20 @@ bool Objecter::ms_handle_reset(Connection *con)
       map<int,OSDSession*>::iterator p = osd_sessions.find(osd);
       if (p != osd_sessions.end()) {
 	OSDSession *session = p->second;
-        map<uint64_t, LingerOp *> lresend;
-        session->lock.get_write();
+	map<uint64_t, LingerOp *> lresend;
+	session->lock.get_write();
 	_reopen_session(session);
 	_kick_requests(session, lresend);
-        session->lock.unlock();
-        _linger_ops_resend(lresend);
-        rwlock.unlock();
+	session->lock.unlock();
+	_linger_ops_resend(lresend);
+	rwlock.unlock();
 	maybe_request_map();
       } else {
-        rwlock.unlock();
+	rwlock.unlock();
       }
     } else {
-      ldout(cct, 10) << "ms_handle_reset on unknown osd addr " << con->get_peer_addr() << dendl;
+      ldout(cct, 10) << "ms_handle_reset on unknown osd addr "
+		     << con->get_peer_addr() << dendl;
     }
     return true;
   }
@@ -4182,7 +4290,9 @@ void Objecter::op_target_t::dump(Formatter *f) const
 
 void Objecter::_dump_active(OSDSession *s)
 {
-  for (map<ceph_tid_t,Op*>::iterator p = s->ops.begin(); p != s->ops.end(); ++p) {
+  for (map<ceph_tid_t,Op*>::iterator p = s->ops.begin();
+       p != s->ops.end();
+       ++p) {
     Op *op = p->second;
     ldout(cct, 20) << op->tid << "\t" << op->target.pgid
 		   << "\tosd." << (op->session ? op->session->osd : -1)
@@ -4193,8 +4303,10 @@ void Objecter::_dump_active(OSDSession *s)
 
 void Objecter::_dump_active()
 {
-  ldout(cct, 20) << "dump_active .. " << num_homeless_ops.read() << " homeless" << dendl;
-  for (map<int, OSDSession *>::iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  ldout(cct, 20) << "dump_active .. " << num_homeless_ops.read() << " homeless"
+		 << dendl;
+  for (map<int, OSDSession *>::iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
     s->lock.get_read();
     _dump_active(s);
@@ -4252,14 +4364,13 @@ void Objecter::_dump_ops(const OSDSession *s, Formatter *fmt)
 void Objecter::dump_ops(Formatter *fmt)
 {
   fmt->open_array_section("ops");
-  rwlock.get_read();
-  for (map<int, OSDSession *>::const_iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  for (map<int, OSDSession *>::const_iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
     s->lock.get_read();
     _dump_ops(s, fmt);
     s->lock.unlock();
   }
-  rwlock.unlock();
   _dump_ops(homeless_session, fmt);
   fmt->close_section(); // ops array
 }
@@ -4282,14 +4393,13 @@ void Objecter::_dump_linger_ops(const OSDSession *s, Formatter *fmt)
 void Objecter::dump_linger_ops(Formatter *fmt)
 {
   fmt->open_array_section("linger_ops");
-  rwlock.get_read();
-  for (map<int, OSDSession *>::const_iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  for (map<int, OSDSession *>::const_iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
     s->lock.get_read();
     _dump_linger_ops(s, fmt);
     s->lock.unlock();
   }
-  rwlock.unlock();
   _dump_linger_ops(homeless_session, fmt);
   fmt->close_section(); // linger_ops array
 }
@@ -4304,7 +4414,8 @@ void Objecter::_dump_command_ops(const OSDSession *s, Formatter *fmt)
     fmt->dump_unsigned("command_id", op->tid);
     fmt->dump_int("osd", op->session ? op->session->osd : -1);
     fmt->open_array_section("command");
-    for (vector<string>::const_iterator q = op->cmd.begin(); q != op->cmd.end(); ++q)
+    for (vector<string>::const_iterator q = op->cmd.begin();
+	 q != op->cmd.end(); ++q)
       fmt->dump_string("word", *q);
     fmt->close_section();
     if (op->target_osd >= 0)
@@ -4318,14 +4429,13 @@ void Objecter::_dump_command_ops(const OSDSession *s, Formatter *fmt)
 void Objecter::dump_command_ops(Formatter *fmt)
 {
   fmt->open_array_section("command_ops");
-  rwlock.get_read();
-  for (map<int, OSDSession *>::const_iterator siter = osd_sessions.begin(); siter != osd_sessions.end(); ++siter) {
+  for (map<int, OSDSession *>::const_iterator siter = osd_sessions.begin();
+       siter != osd_sessions.end(); ++siter) {
     OSDSession *s = siter->second;
     s->lock.get_read();
     _dump_command_ops(s, fmt);
     s->lock.unlock();
   }
-  rwlock.unlock();
   _dump_command_ops(homeless_session, fmt);
   fmt->close_section(); // command_ops array
 }
@@ -4368,7 +4478,7 @@ void Objecter::dump_pool_stat_ops(Formatter *fmt) const
 	 ++it) {
       fmt->dump_string("pool", *it);
     }
-    fmt->close_section(); // pool_op object
+    fmt->close_section(); // pools array
 
     fmt->close_section(); // pool_stat_op object
   }
@@ -4385,9 +4495,9 @@ void Objecter::dump_statfs_ops(Formatter *fmt) const
     fmt->open_object_section("statfs_op");
     fmt->dump_unsigned("tid", op->tid);
     fmt->dump_stream("last_sent") << op->last_submit;
-    fmt->close_section(); // pool_stat_op object
+    fmt->close_section(); // statfs_op object
   }
-  fmt->close_section(); // pool_stat_ops array
+  fmt->close_section(); // statfs_ops array
 }
 
 Objecter::RequestStateHook::RequestStateHook(Objecter *objecter) :
@@ -4413,7 +4523,7 @@ void Objecter::blacklist_self(bool set)
   vector<string> cmd;
   cmd.push_back("{\"prefix\":\"osd blacklist\", ");
   if (set)
-    cmd.push_back("\"blacklistop\":\"add\","); 
+    cmd.push_back("\"blacklistop\":\"add\",");
   else
     cmd.push_back("\"blacklistop\":\"rm\",");
   stringstream ss;
@@ -4440,7 +4550,8 @@ void Objecter::handle_command_reply(MCommandReply *m)
 
   map<int, OSDSession *>::iterator siter = osd_sessions.find(osd_num);
   if (siter == osd_sessions.end()) {
-    ldout(cct, 10) << "handle_command_reply tid " << m->get_tid() << " osd not found" << dendl;
+    ldout(cct, 10) << "handle_command_reply tid " << m->get_tid()
+		   << " osd not found" << dendl;
     m->put();
     return;
   }
@@ -4450,7 +4561,8 @@ void Objecter::handle_command_reply(MCommandReply *m)
   s->lock.get_read();
   map<ceph_tid_t,CommandOp*>::iterator p = s->command_ops.find(m->get_tid());
   if (p == s->command_ops.end()) {
-    ldout(cct, 10) << "handle_command_reply tid " << m->get_tid() << " not found" << dendl;
+    ldout(cct, 10) << "handle_command_reply tid " << m->get_tid()
+		   << " not found" << dendl;
     m->put();
     s->lock.unlock();
     return;
@@ -4459,8 +4571,10 @@ void Objecter::handle_command_reply(MCommandReply *m)
   CommandOp *c = p->second;
   if (!c->session ||
       m->get_connection() != c->session->con) {
-    ldout(cct, 10) << "handle_command_reply tid " << m->get_tid() << " got reply from wrong connection "
-		   << m->get_connection() << " " << m->get_source_inst() << dendl;
+    ldout(cct, 10) << "handle_command_reply tid " << m->get_tid()
+		   << " got reply from wrong connection "
+		   << m->get_connection() << " " << m->get_source_inst()
+		   << dendl;
     m->put();
     s->lock.unlock();
     return;
@@ -4475,19 +4589,6 @@ void Objecter::handle_command_reply(MCommandReply *m)
   m->put();
 }
 
-class C_CancelCommandOp : public Context
-{
-  Objecter::OSDSession *s;
-  ceph_tid_t tid;
-  Objecter *objecter;
-public:
-  C_CancelCommandOp(Objecter::OSDSession *s, ceph_tid_t tid, Objecter *objecter) : s(s), tid(tid),
-						     objecter(objecter) {}
-  void finish(int r) {
-    objecter->command_op_cancel(s, tid, -ETIMEDOUT);
-  }
-};
-
 int Objecter::submit_command(CommandOp *c, ceph_tid_t *ptid)
 {
   RWLock::WLocker wl(rwlock);
@@ -4505,10 +4606,11 @@ int Objecter::submit_command(CommandOp *c, ceph_tid_t *ptid)
 
   (void)_calc_command_target(c);
   _assign_command_session(c);
-  if (osd_timeout > 0) {
-    Mutex::Locker l(timer_lock);
-    c->ontimeout = new C_CancelCommandOp(c->session, tid, this);
-    timer.add_event_after(osd_timeout, c->ontimeout);
+  if (osd_timeout > timespan(0)) {
+    c->ontimeout = timer.add_event(osd_timeout,
+				   [this, c, tid]() {
+				     command_op_cancel(c->session, tid,
+						       -ETIMEDOUT); });
   }
 
   if (!c->session->is_homeless()) {
@@ -4566,7 +4668,8 @@ int Objecter::_calc_command_target(CommandOp *c)
 
   put_session(s);
 
-  ldout(cct, 20) << "_recalc_command_target " << c->tid << " no change, " << c->session << dendl;
+  ldout(cct, 20) << "_recalc_command_target " << c->tid << " no change, "
+		 << c->session << dendl;
 
   return RECALC_OP_TARGET_NO_ACTION;
 }
@@ -4633,16 +4736,15 @@ void Objecter::_finish_command(CommandOp *c, int r, string rs)
 {
   assert(rwlock.is_wlocked());
 
-  ldout(cct, 10) << "_finish_command " << c->tid << " = " << r << " " << rs << dendl;
+  ldout(cct, 10) << "_finish_command " << c->tid << " = " << r << " "
+		 << rs << dendl;
   if (c->prs)
     *c->prs = rs;
   if (c->onfinish)
     c->onfinish->complete(r);
 
-  if (c->ontimeout && r != -ETIMEDOUT) {
-    Mutex::Locker l(timer_lock);
+  if (c->ontimeout && r != -ETIMEDOUT)
     timer.cancel_event(c->ontimeout);
-  }
 
   OSDSession *s = c->session;
   s->lock.get_write();
@@ -4686,7 +4788,6 @@ Objecter::~Objecter()
   assert(check_latest_map_ops.empty());
   assert(check_latest_map_commands.empty());
 
-  assert(!tick_event);
   assert(!m_request_state_hook);
   assert(!logger);
 }
@@ -4702,11 +4803,205 @@ void Objecter::set_epoch_barrier(epoch_t epoch)
 {
   RWLock::WLocker wl(rwlock);
 
-  ldout(cct, 7) << __func__ << ": barrier " << epoch << " (was " << epoch_barrier
-                << ") current epoch " << osdmap->get_epoch() << dendl;
+  ldout(cct, 7) << __func__ << ": barrier " << epoch << " (was "
+		<< epoch_barrier << ") current epoch " << osdmap->get_epoch()
+		<< dendl;
   if (epoch >= epoch_barrier) {
     epoch_barrier = epoch;
     _maybe_request_map();
   }
 }
 
+
+
+hobject_t Objecter::enumerate_objects_begin()
+{
+  return hobject_t();
+}
+
+hobject_t Objecter::enumerate_objects_end()
+{
+  return hobject_t::get_max();
+}
+
+struct C_EnumerateReply : public Context {
+  bufferlist bl;
+
+  Objecter *objecter;
+  hobject_t *next;
+  std::list<librados::ListObjectImpl> *result;
+  const hobject_t end;
+  const int64_t pool_id;
+  Context *on_finish;
+
+  epoch_t epoch;
+  int budget;
+
+  C_EnumerateReply(Objecter *objecter_, hobject_t *next_,
+      std::list<librados::ListObjectImpl> *result_,
+      const hobject_t end_, const int64_t pool_id_, Context *on_finish_) :
+    objecter(objecter_), next(next_), result(result_),
+    end(end_), pool_id(pool_id_), on_finish(on_finish_),
+    epoch(0), budget(0)
+  {}
+
+  void finish(int r) {
+    objecter->_enumerate_reply(
+        bl, r, end, pool_id, budget, epoch, result, next, on_finish);
+  }
+};
+
+void Objecter::enumerate_objects(
+    int64_t pool_id,
+    const std::string &ns,
+    const hobject_t &start,
+    const hobject_t &end,
+    const uint32_t max,
+    std::list<librados::ListObjectImpl> *result, 
+    hobject_t *next,
+    Context *on_finish)
+{
+  assert(result);
+
+  if (!end.is_max() && cmp_bitwise(start, end) > 0) {
+    lderr(cct) << __func__ << ": start " << start << " > end " << end << dendl;
+    on_finish->complete(-EINVAL);
+    return;
+  }
+
+  if (max < 1) {
+    lderr(cct) << __func__ << ": result size may not be zero" << dendl;
+    on_finish->complete(-EINVAL);
+    return;
+  }
+
+  if (start.is_max()) {
+    on_finish->complete(0);
+    return;
+  }
+
+  rwlock.get_read();
+  assert(osdmap->get_epoch());
+  if (!osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE)) {
+    rwlock.unlock();
+    lderr(cct) << __func__ << ": SORTBITWISE cluster flag not set" << dendl;
+    on_finish->complete(-EOPNOTSUPP);
+    return;
+  }
+  const pg_pool_t *p = osdmap->get_pg_pool(pool_id);
+  if (!p) {
+    lderr(cct) << __func__ << ": pool " << pool_id << " DNE in"
+                     "osd epoch " << osdmap->get_epoch() << dendl;
+    rwlock.unlock();
+    on_finish->complete(-ENOENT);
+    return;
+  } else {
+    rwlock.unlock();
+  }
+
+  ldout(cct, 20) << __func__ << ": start=" << start << " end=" << end << dendl;
+
+  // Stash completion state
+  C_EnumerateReply *on_ack = new C_EnumerateReply(
+      this, next, result, end, pool_id, on_finish);
+
+  // Construct pgls operation
+  bufferlist filter; // FIXME pass in?
+
+  ObjectOperation op;
+  op.pg_nls(max, filter, start, 0);
+
+  // Issue.  See you later in _enumerate_reply
+  object_locator_t oloc(pool_id, ns);
+  pg_read(start.get_hash(), oloc, op,
+	  &on_ack->bl, 0, on_ack, &on_ack->epoch, &on_ack->budget);
+}
+
+void Objecter::_enumerate_reply(
+    bufferlist &bl,
+    int r,
+    const hobject_t &end,
+    const int64_t pool_id,
+    int budget,
+    epoch_t reply_epoch,
+    std::list<librados::ListObjectImpl> *result, 
+    hobject_t *next,
+    Context *on_finish)
+{
+  if (budget > 0) {
+    put_op_budget_bytes(budget);
+  }
+
+  if (r < 0) {
+    ldout(cct, 4) << __func__ << ": remote error " << r << dendl;
+    on_finish->complete(r);
+    return;
+  }
+
+  assert(next != NULL);
+
+  // Decode the results
+  bufferlist::iterator iter = bl.begin();
+  pg_nls_response_t response;
+
+  // XXX extra_info doesn't seem used anywhere?
+  bufferlist extra_info;
+  ::decode(response, iter);
+  if (!iter.end()) {
+    ::decode(extra_info, iter);
+  }
+
+  ldout(cct, 10) << __func__ << ": got " << response.entries.size()
+		 << " handle " << response.handle
+		 << " reply_epoch " << reply_epoch << dendl;
+  ldout(cct, 20) << __func__ << ": response.entries.size "
+                 << response.entries.size() << ", response.entries "
+                 << response.entries << dendl;
+  if (cmp_bitwise(response.handle, end) <= 0) {
+    *next = response.handle;
+  } else {
+    ldout(cct, 10) << __func__ << ": adjusted next down to end " << end << dendl;
+    *next = end;
+
+    // drop anything after 'end'
+    rwlock.get_read();
+    const pg_pool_t *pool = osdmap->get_pg_pool(pool_id);
+    if (!pool) {
+      // pool is gone, drop any results which are now meaningless.
+      rwlock.put_read();
+      on_finish->complete(-ENOENT);
+      return;
+    }
+    while (!response.entries.empty()) {
+      uint32_t hash = response.entries.back().locator.empty() ?
+	pool->hash_key(response.entries.back().oid,
+		       response.entries.back().nspace) :
+	pool->hash_key(response.entries.back().locator,
+		       response.entries.back().nspace);
+      hobject_t last(response.entries.back().oid,
+		     response.entries.back().locator,
+		     CEPH_NOSNAP,
+		     hash,
+		     pool_id,
+		     response.entries.back().nspace);
+      if (cmp_bitwise(last, end) < 0)
+	break;
+      ldout(cct, 20) << __func__ << " dropping item " << last
+		     << " >= end " << end << dendl;
+      response.entries.pop_back();
+    }
+    rwlock.put_read();
+  }
+  if (!response.entries.empty()) {
+    result->merge(response.entries);
+  }
+
+  // release the listing context's budget once all
+  // OPs (in the session) are finished
+#if 0
+  put_nlist_context_budget(list_context);
+#endif
+  on_finish->complete(r);
+  return;
+}
+
diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h
index e892ee0..16d8c0a 100644
--- a/src/osdc/Objecter.h
+++ b/src/osdc/Objecter.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -15,21 +15,24 @@
 #ifndef CEPH_OBJECTER_H
 #define CEPH_OBJECTER_H
 
+#include <list>
+#include <map>
+#include <memory>
+#include <sstream>
+
 #include "include/types.h"
 #include "include/buffer.h"
-
-#include "osd/OSDMap.h"
-#include "messages/MOSDOp.h"
+#include "include/rados/rados_types.hpp"
 
 #include "common/admin_socket.h"
-#include "common/Timer.h"
+#include "common/ceph_time.h"
+#include "common/ceph_timer.h"
 #include "common/RWLock.h"
-#include "include/rados/rados_types.hpp"
 
-#include <list>
-#include <map>
-#include <memory>
-#include <sstream>
+#include "messages/MOSDOp.h"
+#include "osd/OSDMap.h"
+
+
 using namespace std;
 
 class Context;
@@ -94,8 +97,8 @@ struct ObjectOperation {
     }
 
     virtual ~C_TwoContexts() {
-        delete first;
-        delete second;
+      delete first;
+      delete second;
     }
   };
 
@@ -132,7 +135,9 @@ struct ObjectOperation {
     osd_op.op.extent.length = len;
     osd_op.indata.claim_append(bl);
   }
-  void add_clone_range(int op, uint64_t off, uint64_t len, const object_t& srcoid, uint64_t srcoff, snapid_t srcsnapid) {
+  void add_clone_range(int op, uint64_t off, uint64_t len,
+		       const object_t& srcoid, uint64_t srcoff,
+		       snapid_t srcsnapid) {
     OSDOp& osd_op = add_op(op);
     osd_op.op.clonerange.offset = off;
     osd_op.op.clonerange.length = len;
@@ -147,7 +152,8 @@ struct ObjectOperation {
       osd_op.indata.append(name);
     osd_op.indata.append(data);
   }
-  void add_xattr_cmp(int op, const char *name, uint8_t cmp_op, uint8_t cmp_mode, const bufferlist& data) {
+  void add_xattr_cmp(int op, const char *name, uint8_t cmp_op,
+		     uint8_t cmp_mode, const bufferlist& data) {
     OSDOp& osd_op = add_op(op);
     osd_op.op.xattr.name_len = (name ? strlen(name) : 0);
     osd_op.op.xattr.value_len = data.length();
@@ -157,8 +163,9 @@ struct ObjectOperation {
       osd_op.indata.append(name);
     osd_op.indata.append(data);
   }
-  void add_call(int op, const char *cname, const char *method, bufferlist &indata,
-                bufferlist *outbl, Context *ctx, int *prval) {
+  void add_call(int op, const char *cname, const char *method,
+		bufferlist &indata,
+		bufferlist *outbl, Context *ctx, int *prval) {
     OSDOp& osd_op = add_op(op);
 
     unsigned p = ops.size() - 1;
@@ -173,13 +180,15 @@ struct ObjectOperation {
     osd_op.indata.append(method, osd_op.op.cls.method_len);
     osd_op.indata.append(indata);
   }
-  void add_pgls(int op, uint64_t count, collection_list_handle_t cookie, epoch_t start_epoch) {
+  void add_pgls(int op, uint64_t count, collection_list_handle_t cookie,
+		epoch_t start_epoch) {
     OSDOp& osd_op = add_op(op);
     osd_op.op.pgls.count = count;
     osd_op.op.pgls.start_epoch = start_epoch;
     ::encode(cookie, osd_op.indata);
   }
-  void add_pgls_filter(int op, uint64_t count, bufferlist& filter, collection_list_handle_t cookie, epoch_t start_epoch) {
+  void add_pgls_filter(int op, uint64_t count, bufferlist& filter,
+		       collection_list_handle_t cookie, epoch_t start_epoch) {
     OSDOp& osd_op = add_op(op);
     osd_op.op.pgls.count = count;
     osd_op.op.pgls.start_epoch = start_epoch;
@@ -191,7 +200,7 @@ struct ObjectOperation {
     ::encode(cookie, osd_op.indata);
   }
   void add_alloc_hint(int op, uint64_t expected_object_size,
-                      uint64_t expected_write_size) {
+		      uint64_t expected_write_size) {
     OSDOp& osd_op = add_op(op);
     osd_op.op.alloc_hint.expected_object_size = expected_object_size;
     osd_op.op.alloc_hint.expected_write_size = expected_write_size;
@@ -200,19 +209,23 @@ struct ObjectOperation {
   // ------
 
   // pg
-  void pg_ls(uint64_t count, bufferlist& filter, collection_list_handle_t cookie, epoch_t start_epoch) {
+  void pg_ls(uint64_t count, bufferlist& filter,
+	     collection_list_handle_t cookie, epoch_t start_epoch) {
     if (filter.length() == 0)
       add_pgls(CEPH_OSD_OP_PGLS, count, cookie, start_epoch);
     else
-      add_pgls_filter(CEPH_OSD_OP_PGLS_FILTER, count, filter, cookie, start_epoch);
+      add_pgls_filter(CEPH_OSD_OP_PGLS_FILTER, count, filter, cookie,
+		      start_epoch);
     flags |= CEPH_OSD_FLAG_PGOP;
   }
 
-  void pg_nls(uint64_t count, bufferlist& filter, collection_list_handle_t cookie, epoch_t start_epoch) {
+  void pg_nls(uint64_t count, bufferlist& filter,
+	      collection_list_handle_t cookie, epoch_t start_epoch) {
     if (filter.length() == 0)
       add_pgls(CEPH_OSD_OP_PGNLS, count, cookie, start_epoch);
     else
-      add_pgls_filter(CEPH_OSD_OP_PGNLS_FILTER, count, filter, cookie, start_epoch);
+      add_pgls_filter(CEPH_OSD_OP_PGNLS_FILTER, count, filter, cookie,
+		      start_epoch);
     flags |= CEPH_OSD_FLAG_PGOP;
   }
 
@@ -224,17 +237,18 @@ struct ObjectOperation {
   struct C_ObjectOperation_stat : public Context {
     bufferlist bl;
     uint64_t *psize;
-    utime_t *pmtime;
+    ceph::real_time *pmtime;
     time_t *ptime;
     int *prval;
-    C_ObjectOperation_stat(uint64_t *ps, utime_t *pm, time_t *pt, int *prval)
+    C_ObjectOperation_stat(uint64_t *ps, ceph::real_time *pm, time_t *pt,
+			   int *prval)
       : psize(ps), pmtime(pm), ptime(pt), prval(prval) {}
     void finish(int r) {
       if (r >= 0) {
 	bufferlist::iterator p = bl.begin();
 	try {
 	  uint64_t size;
-	  utime_t mtime;
+	  ceph::real_time mtime;
 	  ::decode(size, p);
 	  ::decode(mtime, p);
 	  if (psize)
@@ -242,7 +256,7 @@ struct ObjectOperation {
 	  if (pmtime)
 	    *pmtime = mtime;
 	  if (ptime)
-	    *ptime = mtime.sec();
+	    *ptime = ceph::real_clock::to_time_t(mtime);
 	} catch (buffer::error& e) {
 	  if (prval)
 	    *prval = -EIO;
@@ -250,7 +264,7 @@ struct ObjectOperation {
       }
     }
   };
-  void stat(uint64_t *psize, utime_t *pmtime, int *prval) {
+  void stat(uint64_t *psize, ceph::real_time *pmtime, int *prval) {
     add_op(CEPH_OSD_OP_STAT);
     unsigned p = ops.size() - 1;
     C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, pmtime, NULL,
@@ -314,8 +328,8 @@ struct ObjectOperation {
     out_rval[p] = prval;
   }
   void write(uint64_t off, bufferlist& bl,
-             uint64_t truncate_size,
-             uint32_t truncate_seq) {
+	     uint64_t truncate_size,
+	     uint32_t truncate_seq) {
     add_data(CEPH_OSD_OP_WRITE, off, bl.length(), bl);
     OSDOp& o = *ops.rbegin();
     o.op.extent.truncate_size = truncate_size;
@@ -351,8 +365,10 @@ struct ObjectOperation {
     add_data(CEPH_OSD_OP_SPARSE_READ, off, len, bl);
   }
 
-  void clone_range(const object_t& src_oid, uint64_t src_offset, uint64_t len, uint64_t dst_offset) {
-    add_clone_range(CEPH_OSD_OP_CLONERANGE, dst_offset, len, src_oid, src_offset, CEPH_NOSNAP);
+  void clone_range(const object_t& src_oid, uint64_t src_offset, uint64_t len,
+		   uint64_t dst_offset) {
+    add_clone_range(CEPH_OSD_OP_CLONERANGE, dst_offset, len, src_oid,
+		    src_offset, CEPH_NOSNAP);
   }
 
   // object attrs
@@ -400,7 +416,7 @@ struct ObjectOperation {
 	  if (prval)
 	    *prval = -EIO;
 	}
-      }	
+      }
     }
   };
   struct C_ObjectOperation_decodewatchers : public Context {
@@ -413,27 +429,27 @@ struct ObjectOperation {
       if (r >= 0) {
 	bufferlist::iterator p = bl.begin();
 	try {
-          obj_list_watch_response_t resp;
+	  obj_list_watch_response_t resp;
 	  ::decode(resp, p);
 	  if (pwatchers) {
-            for (list<watch_item_t>::iterator i = resp.entries.begin() ;
-                    i != resp.entries.end() ; ++i) {
-              obj_watch_t ow;
+	    for (list<watch_item_t>::iterator i = resp.entries.begin() ;
+		 i != resp.entries.end() ; ++i) {
+	      obj_watch_t ow;
 	      ostringstream sa;
 	      sa << i->addr;
 	      strncpy(ow.addr, sa.str().c_str(), 256);
-              ow.watcher_id = i->name.num();
-              ow.cookie = i->cookie;
-              ow.timeout_seconds = i->timeout_seconds;
-              pwatchers->push_back(ow);
-            }
-          }
+	      ow.watcher_id = i->name.num();
+	      ow.cookie = i->cookie;
+	      ow.timeout_seconds = i->timeout_seconds;
+	      pwatchers->push_back(ow);
+	    }
+	  }
 	}
 	catch (buffer::error& e) {
 	  if (prval)
 	    *prval = -EIO;
 	}
-      }	
+      }
     }
   };
   struct C_ObjectOperation_decodesnaps : public Context {
@@ -446,27 +462,27 @@ struct ObjectOperation {
       if (r >= 0) {
 	bufferlist::iterator p = bl.begin();
 	try {
-          obj_list_snap_response_t resp;
+	  obj_list_snap_response_t resp;
 	  ::decode(resp, p);
 	  if (psnaps) {
-            psnaps->clones.clear();
-            for (vector<clone_info>::iterator ci = resp.clones.begin(); 
-		 ci != resp.clones.end(); 
+	    psnaps->clones.clear();
+	    for (vector<clone_info>::iterator ci = resp.clones.begin();
+		 ci != resp.clones.end();
 		 ++ci) {
-              librados::clone_info_t clone;
+	      librados::clone_info_t clone;
 
-              clone.cloneid = ci->cloneid;
-              clone.snaps.reserve(ci->snaps.size());
-              clone.snaps.insert(clone.snaps.end(), ci->snaps.begin(), ci->snaps.end());
-              clone.overlap = ci->overlap;
-              clone.size = ci->size;
+	      clone.cloneid = ci->cloneid;
+	      clone.snaps.reserve(ci->snaps.size());
+	      clone.snaps.insert(clone.snaps.end(), ci->snaps.begin(),
+				 ci->snaps.end());
+	      clone.overlap = ci->overlap;
+	      clone.size = ci->size;
 
-              psnaps->clones.push_back(clone);
-            }
+	      psnaps->clones.push_back(clone);
+	    }
 	    psnaps->seq = resp.seq;
-          }
-	}
-	catch (buffer::error& e) {
+	  }
+	} catch (buffer::error& e) {
 	  if (prval)
 	    *prval = -EIO;
 	}
@@ -477,7 +493,8 @@ struct ObjectOperation {
     add_op(CEPH_OSD_OP_GETXATTRS);
     if (pattrs || prval) {
       unsigned p = ops.size() - 1;
-      C_ObjectOperation_decodevals *h = new C_ObjectOperation_decodevals(pattrs, prval);
+      C_ObjectOperation_decodevals *h
+	= new C_ObjectOperation_decodevals(pattrs, prval);
       out_handler[p] = h;
       out_bl[p] = &h->bl;
       out_rval[p] = prval;
@@ -491,7 +508,8 @@ struct ObjectOperation {
     bl.append(s);
     add_xattr(CEPH_OSD_OP_SETXATTR, name, bl);
   }
-  void cmpxattr(const char *name, uint8_t cmp_op, uint8_t cmp_mode, const bufferlist& bl) {
+  void cmpxattr(const char *name, uint8_t cmp_op, uint8_t cmp_mode,
+		const bufferlist& bl) {
     add_xattr_cmp(CEPH_OSD_OP_CMPXATTR, name, cmp_op, cmp_mode, bl);
   }
   void rmxattr(const char *name) {
@@ -508,7 +526,7 @@ struct ObjectOperation {
     ::encode(attrs, bl);
     add_xattr(CEPH_OSD_OP_RESETXATTRS, prefix, bl);
   }
-  
+
   // trivialmap
   void tmap_update(bufferlist& bl) {
     add_data(CEPH_OSD_OP_TMAPUP, 0, 0, bl);
@@ -595,7 +613,7 @@ struct ObjectOperation {
     }
   }
 
-  void omap_cmp(const std::map<std::string, pair<bufferlist, int> > &assertions,
+  void omap_cmp(const std::map<std::string, pair<bufferlist,int> > &assertions,
 		int *prval) {
     OSDOp &op = add_op(CEPH_OSD_OP_OMAP_CMP);
     bufferlist bl;
@@ -613,7 +631,7 @@ struct ObjectOperation {
     bufferlist bl;
     object_copy_cursor_t *cursor;
     uint64_t *out_size;
-    utime_t *out_mtime;
+    ceph::real_time *out_mtime;
     std::map<std::string,bufferlist> *out_attrs;
     bufferlist *out_data, *out_omap_header, *out_omap_data;
     vector<snapid_t> *out_snaps;
@@ -627,7 +645,7 @@ struct ObjectOperation {
     int *prval;
     C_ObjectOperation_copyget(object_copy_cursor_t *c,
 			      uint64_t *s,
-			      utime_t *m,
+			      ceph::real_time *m,
 			      std::map<std::string,bufferlist> *a,
 			      bufferlist *d, bufferlist *oh,
 			      bufferlist *o,
@@ -645,10 +663,10 @@ struct ObjectOperation {
 	out_attrs(a), out_data(d), out_omap_header(oh),
 	out_omap_data(o), out_snaps(osnaps), out_snap_seq(osnap_seq),
 	out_flags(flags), out_data_digest(dd), out_omap_digest(od),
-        out_reqids(oreqids),
-        out_truncate_seq(otseq),
-        out_truncate_size(otsize),
-        prval(r) {}
+	out_reqids(oreqids),
+	out_truncate_seq(otseq),
+	out_truncate_size(otsize),
+	prval(r) {}
     void finish(int r) {
       // reqids are copied on ENOENT
       if (r < 0 && r != -ENOENT)
@@ -665,7 +683,7 @@ struct ObjectOperation {
 	if (out_size)
 	  *out_size = copy_reply.size;
 	if (out_mtime)
-	  *out_mtime = copy_reply.mtime;
+	  *out_mtime = ceph::real_clock::from_ceph_timespec(copy_reply.mtime);
 	if (out_attrs)
 	  *out_attrs = copy_reply.attrs;
 	if (out_data)
@@ -702,7 +720,7 @@ struct ObjectOperation {
 		uint64_t max,
 		uint32_t copyget_flags,
 		uint64_t *out_size,
-		utime_t *out_mtime,
+		ceph::real_time *out_mtime,
 		std::map<std::string,bufferlist> *out_attrs,
 		bufferlist *out_data,
 		bufferlist *out_omap_header,
@@ -725,11 +743,11 @@ struct ObjectOperation {
     out_rval[p] = prval;
     C_ObjectOperation_copyget *h =
       new C_ObjectOperation_copyget(cursor, out_size, out_mtime,
-                                    out_attrs, out_data, out_omap_header,
+				    out_attrs, out_data, out_omap_header,
 				    out_omap_data, out_snaps, out_snap_seq,
-				    out_flags, out_data_digest, out_omap_digest,
-				    out_reqids, truncate_seq, truncate_size,
-				    prval);
+				    out_flags, out_data_digest,
+				    out_omap_digest, out_reqids, truncate_seq,
+				    truncate_size, prval);
     out_bl[p] = &h->bl;
     out_handler[p] = h;
   }
@@ -773,10 +791,11 @@ struct ObjectOperation {
   struct C_ObjectOperation_hit_set_ls : public Context {
     bufferlist bl;
     std::list< std::pair<time_t, time_t> > *ptls;
-    std::list< std::pair<utime_t, utime_t> > *putls;
+    std::list< std::pair<ceph::real_time, ceph::real_time> > *putls;
     int *prval;
     C_ObjectOperation_hit_set_ls(std::list< std::pair<time_t, time_t> > *t,
-				 std::list< std::pair<utime_t, utime_t> > *ut,
+				 std::list< std::pair<ceph::real_time,
+						      ceph::real_time> > *ut,
 				 int *r)
       : ptls(t), putls(ut), prval(r) {}
     void finish(int r) {
@@ -784,13 +803,19 @@ struct ObjectOperation {
 	return;
       try {
 	bufferlist::iterator p = bl.begin();
-	std::list< std::pair<utime_t, utime_t> > ls;
+	std::list< std::pair<ceph::real_time, ceph::real_time> > ls;
 	::decode(ls, p);
 	if (ptls) {
 	  ptls->clear();
-	  for (list< pair<utime_t,utime_t> >::iterator p = ls.begin(); p != ls.end(); ++p)
-	    // round initial timestamp up to the next full second to keep this a valid interval.
-	    ptls->push_back(make_pair(p->first.usec() ? p->first.sec() + 1 : p->first.sec(), p->second.sec()));
+	  for (auto p = ls.begin(); p != ls.end(); ++p)
+	    // round initial timestamp up to the next full second to
+	    // keep this a valid interval.
+	    ptls->push_back(
+	      make_pair(ceph::real_clock::to_time_t(
+			  ceph::ceil(p->first,
+				     // Sadly, no time literals until C++14.
+				     std::chrono::seconds(1))),
+			ceph::real_clock::to_time_t(p->second)));
 	}
 	if (putls)
 	  putls->swap(ls);
@@ -805,8 +830,9 @@ struct ObjectOperation {
   /**
    * list available HitSets.
    *
-   * We will get back a list of time intervals.  Note that the most recent range may have
-   * an empty end timestamp if it is still accumulating.
+   * We will get back a list of time intervals.  Note that the most
+   * recent range may have an empty end timestamp if it is still
+   * accumulating.
    *
    * @param pls [out] list of time intervals
    * @param prval [out] return value
@@ -820,7 +846,8 @@ struct ObjectOperation {
     out_bl[p] = &h->bl;
     out_handler[p] = h;
   }
-  void hit_set_ls(std::list< std::pair<utime_t, utime_t> > *pls, int *prval) {
+  void hit_set_ls(std::list<std::pair<ceph::real_time, ceph::real_time> > *pls,
+		  int *prval) {
     add_op(CEPH_OSD_OP_PG_HITSET_LS);
     unsigned p = ops.size() - 1;
     out_rval[p] = prval;
@@ -840,10 +867,9 @@ struct ObjectOperation {
    * @param pbl [out] target buffer for encoded HitSet
    * @param prval [out] return value
    */
-  void hit_set_get(utime_t stamp, bufferlist *pbl, int *prval) {
+  void hit_set_get(ceph::real_time stamp, bufferlist *pbl, int *prval) {
     OSDOp& op = add_op(CEPH_OSD_OP_PG_HITSET_GET);
-    op.op.hit_set_get.stamp.tv_sec = stamp.sec();
-    op.op.hit_set_get.stamp.tv_nsec = stamp.nsec();
+    op.op.hit_set_get.stamp = ceph::real_clock::to_ceph_timespec(stamp);
     unsigned p = ops.size() - 1;
     out_rval[p] = prval;
     out_bl[p] = pbl;
@@ -881,8 +907,8 @@ struct ObjectOperation {
     add_call(CEPH_OSD_OP_CALL, cname, method, indata, NULL, NULL, NULL);
   }
 
-  void call(const char *cname, const char *method, bufferlist &indata, bufferlist *outdata,
-	    Context *ctx, int *prval) {
+  void call(const char *cname, const char *method, bufferlist &indata,
+	    bufferlist *outdata, Context *ctx, int *prval) {
     add_call(CEPH_OSD_OP_CALL, cname, method, indata, outdata, ctx, prval);
   }
 
@@ -942,7 +968,8 @@ struct ObjectOperation {
     OSDOp& osd_op = add_op(CEPH_OSD_OP_ASSERT_VER);
     osd_op.op.assert_ver.ver = ver;
   }
-  void assert_src_version(const object_t& srcoid, snapid_t srcsnapid, uint64_t ver) {
+  void assert_src_version(const object_t& srcoid, snapid_t srcsnapid,
+			  uint64_t ver) {
     OSDOp& osd_op = add_op(CEPH_OSD_OP_ASSERT_SRC_VERSION);
     osd_op.op.assert_ver.ver = ver;
     ops.rbegin()->soid = sobject_t(srcoid, srcsnapid);
@@ -1024,9 +1051,9 @@ struct ObjectOperation {
   }
 
   void set_alloc_hint(uint64_t expected_object_size,
-                      uint64_t expected_write_size ) {
+		      uint64_t expected_write_size ) {
     add_alloc_hint(CEPH_OSD_OP_SETALLOCHINT, expected_object_size,
-                   expected_write_size);
+		   expected_write_size);
 
     // CEPH_OSD_OP_SETALLOCHINT op is advisory and therefore deemed
     // not worth a feature bit.  Set FAILOK per-op flag to make
@@ -1102,19 +1129,13 @@ private:
   version_t last_seen_pgmap_version;
 
   RWLock rwlock;
-  Mutex timer_lock;
-  SafeTimer timer;
+  ceph::timer<ceph::mono_clock> timer;
 
   PerfCounters *logger;
-  
-  class C_Tick : public Context {
-    Objecter *ob;
-  public:
-    C_Tick(Objecter *o) : ob(o) {}
-    void finish(int r) { ob->tick(); }
-  } *tick_event;
 
-  void schedule_tick();
+  uint64_t tick_event;
+
+  void start_tick();
   void tick();
   void update_crush_location();
 
@@ -1142,19 +1163,20 @@ public:
     object_t target_oid;
     object_locator_t target_oloc;
 
-    bool precalc_pgid;    ///< true if we are directed at base_pgid, not base_oid
-    pg_t base_pgid;       ///< explciti pg target, if any
+    bool precalc_pgid; ///< true if we are directed at base_pgid, not base_oid
+    pg_t base_pgid; ///< explciti pg target, if any
 
-    pg_t pgid;            ///< last pg we mapped to
-    unsigned pg_num;      ///< last pg_num we mapped to
+    pg_t pgid; ///< last pg we mapped to
+    unsigned pg_num; ///< last pg_num we mapped to
     unsigned pg_num_mask; ///< last pg_num_mask we mapped to
-    vector<int> up;       ///< set of up osds for last pg we mapped to
-    vector<int> acting;   ///< set of acting osds for last pg we mapped to
-    int up_primary;       ///< primary for last pg we mapped to based on the up set
-    int acting_primary;   ///< primary for last pg we mapped to based on the acting set
-    int size;             ///< the size of the pool when were were last mapped
-    int min_size;         ///< the min size of the pool when were were last mapped
-    bool sort_bitwise;    ///< whether the hobject_t sort order is bitwise
+    vector<int> up; ///< set of up osds for last pg we mapped to
+    vector<int> acting; ///< set of acting osds for last pg we mapped to
+    int up_primary; ///< primary for last pg we mapped to based on the up set
+    int acting_primary;  ///< primary for last pg we mapped to based on the
+			 ///  acting set
+    int size; ///< the size of the pool when were were last mapped
+    int min_size; ///< the min size of the pool when were were last mapped
+    bool sort_bitwise; ///< whether the hobject_t sort order is bitwise
 
     bool used_replica;
     bool paused;
@@ -1167,7 +1189,7 @@ public:
 	base_oloc(oloc),
 	precalc_pgid(false),
 	pg_num(0),
-        pg_num_mask(0),
+	pg_num_mask(0),
 	up_primary(-1),
 	acting_primary(-1),
 	size(-1),
@@ -1194,7 +1216,7 @@ public:
 
     snapid_t snapid;
     SnapContext snapc;
-    utime_t mtime;
+    ceph::real_time mtime;
 
     bufferlist *outbl;
     vector<bufferlist*> out_bl;
@@ -1202,17 +1224,18 @@ public:
     vector<int*> out_rval;
 
     int priority;
-    Context *onack, *oncommit, *ontimeout;
-    Context *oncommit_sync;         // used internally by watch/notify
+    Context *onack, *oncommit;
+    uint64_t ontimeout;
+    Context *oncommit_sync; // used internally by watch/notify
 
     ceph_tid_t tid;
-    eversion_t replay_version;        // for op replay
+    eversion_t replay_version; // for op replay
     int attempts;
 
     version_t *objver;
     epoch_t *reply_epoch;
 
-    utime_t stamp;
+    ceph::mono_time stamp;
 
     epoch_t map_dne_bound;
 
@@ -1221,9 +1244,10 @@ public:
     /// true if we should resend this message on failure
     bool should_resend;
 
-    /// true if the throttle budget is get/put on a series of OPs, instead of
-    /// per OP basis, when this flag is set, the budget is acquired before sending
-    /// the very first OP of the series and released upon receiving the last OP reply.
+    /// true if the throttle budget is get/put on a series of OPs,
+    /// instead of per OP basis, when this flag is set, the budget is
+    /// acquired before sending the very first OP of the series and
+    /// released upon receiving the last OP reply.
     bool ctx_budgeted;
 
     int *data_offset;
@@ -1243,7 +1267,7 @@ public:
       priority(0),
       onack(ac),
       oncommit(co),
-      ontimeout(NULL),
+      ontimeout(0),
       oncommit_sync(NULL),
       tid(0),
       attempts(0),
@@ -1256,7 +1280,7 @@ public:
       data_offset(offset),
       last_force_resend(0) {
       ops.swap(op);
-      
+
       /* initialize out_* to match op vector */
       out_bl.resize(ops.size());
       out_rval.resize(ops.size());
@@ -1288,7 +1312,8 @@ public:
     Objecter *objecter;
     ceph_tid_t tid;
     version_t latest;
-    C_Op_Map_Latest(Objecter *o, ceph_tid_t t) : objecter(o), tid(t), latest(0) {}
+    C_Op_Map_Latest(Objecter *o, ceph_tid_t t) : objecter(o), tid(t),
+						 latest(0) {}
     void finish(int r);
   };
 
@@ -1296,22 +1321,23 @@ public:
     Objecter *objecter;
     uint64_t tid;
     version_t latest;
-    C_Command_Map_Latest(Objecter *o, ceph_tid_t t) :  objecter(o), tid(t), latest(0) {}
+    C_Command_Map_Latest(Objecter *o, ceph_tid_t t) :  objecter(o), tid(t),
+						       latest(0) {}
     void finish(int r);
   };
 
   struct C_Stat : public Context {
     bufferlist bl;
     uint64_t *psize;
-    utime_t *pmtime;
+    ceph::real_time *pmtime;
     Context *fin;
-    C_Stat(uint64_t *ps, utime_t *pm, Context *c) :
+    C_Stat(uint64_t *ps, ceph::real_time *pm, Context *c) :
       psize(ps), pmtime(pm), fin(c) {}
     void finish(int r) {
       if (r >= 0) {
 	bufferlist::iterator p = bl.begin();
 	uint64_t s;
-	utime_t m;
+	ceph::real_time m;
 	::decode(s, p);
 	::decode(m, p);
 	if (psize)
@@ -1327,7 +1353,8 @@ public:
     bufferlist bl;
     map<string,bufferlist>& attrset;
     Context *fin;
-    C_GetAttrs(map<string, bufferlist>& set, Context *c) : attrset(set), fin(c) {}
+    C_GetAttrs(map<string, bufferlist>& set, Context *c) : attrset(set),
+							   fin(c) {}
     void finish(int r) {
       if (r >= 0) {
 	bufferlist::iterator p = bl.begin();
@@ -1338,7 +1365,7 @@ public:
   };
 
 
-  // Pools and statistics 
+  // Pools and statistics
   struct NListContext {
     int current_pg;
     collection_list_handle_t cookie;
@@ -1366,19 +1393,21 @@ public:
     // the last op reply.
     int ctx_budget;
 
-    NListContext() : current_pg(0), current_pg_epoch(0), starting_pg_num(0),
-		    at_end_of_pool(false),
-		    at_end_of_pg(false),
-		    sort_bitwise(false),
-		    pool_id(0),
-		    pool_snap_seq(0),
-                    max_entries(0),
-                    nspace(),
-                    bl(),
-                    list(),
-                    filter(),
-                    extra_info(),
-                    ctx_budget(-1) {}
+    NListContext() : current_pg(0),
+		     current_pg_epoch(0),
+		     starting_pg_num(0),
+		     at_end_of_pool(false),
+		     at_end_of_pg(false),
+		     sort_bitwise(false),
+		     pool_id(0),
+		     pool_snap_seq(0),
+		     max_entries(0),
+		     nspace(),
+		     bl(),
+		     list(),
+		     filter(),
+		     extra_info(),
+		     ctx_budget(-1) {}
 
     bool at_end() const {
       return at_end_of_pool;
@@ -1398,9 +1427,9 @@ public:
       list_context(lc), final_finish(finish), objecter(ob), epoch(0) {}
     void finish(int r) {
       if (r >= 0) {
-        objecter->_nlist_reply(list_context, r, final_finish, epoch);
+	objecter->_nlist_reply(list_context, r, final_finish, epoch);
       } else {
-        final_finish->complete(r);
+	final_finish->complete(r);
       }
     }
   };
@@ -1439,13 +1468,13 @@ public:
 		    sort_bitwise(false),
 		    pool_id(0),
 		    pool_snap_seq(0),
-                    max_entries(0),
-                    nspace(),
-                    bl(),
-                    list(),
-                    filter(),
-                    extra_info(),
-                    ctx_budget(-1) {}
+		    max_entries(0),
+		    nspace(),
+		    bl(),
+		    list(),
+		    filter(),
+		    extra_info(),
+		    ctx_budget(-1) {}
 
     bool at_end() const {
       return at_end_of_pool;
@@ -1465,44 +1494,47 @@ public:
       list_context(lc), final_finish(finish), objecter(ob), epoch(0) {}
     void finish(int r) {
       if (r >= 0) {
-        objecter->_list_reply(list_context, r, final_finish, epoch);
+	objecter->_list_reply(list_context, r, final_finish, epoch);
       } else {
-        final_finish->complete(r);
+	final_finish->complete(r);
       }
     }
   };
-  
+
   struct PoolStatOp {
     ceph_tid_t tid;
     list<string> pools;
 
     map<string,pool_stat_t> *pool_stats;
-    Context *onfinish, *ontimeout;
+    Context *onfinish;
+    uint64_t ontimeout;
 
-    utime_t last_submit;
+    ceph::mono_time last_submit;
   };
 
   struct StatfsOp {
     ceph_tid_t tid;
     struct ceph_statfs *stats;
-    Context *onfinish, *ontimeout;
+    Context *onfinish;
+    uint64_t ontimeout;
 
-    utime_t last_submit;
+    ceph::mono_time last_submit;
   };
 
   struct PoolOp {
     ceph_tid_t tid;
     int64_t pool;
     string name;
-    Context *onfinish, *ontimeout;
+    Context *onfinish;
+    uint64_t ontimeout;
     int pool_op;
     uint64_t auid;
     int16_t crush_rule;
     snapid_t snapid;
     bufferlist *blp;
 
-    utime_t last_submit;
-    PoolOp() : tid(0), pool(0), onfinish(NULL), ontimeout(NULL), pool_op(0),
+    ceph::mono_time last_submit;
+    PoolOp() : tid(0), pool(0), onfinish(NULL), ontimeout(0), pool_op(0),
 	       auid(0), crush_rule(0), snapid(0), blp(NULL) {}
   };
 
@@ -1518,10 +1550,11 @@ public:
     pg_t target_pg;
     int osd; /* calculated osd for sending request */
     epoch_t map_dne_bound;
-    int map_check_error;           // error to return if map check fails
+    int map_check_error; // error to return if map check fails
     const char *map_check_error_str;
-    Context *onfinish, *ontimeout;
-    utime_t last_submit;
+    Context *onfinish;
+    uint64_t ontimeout;
+    ceph::mono_time last_submit;
 
     CommandOp()
       : session(NULL),
@@ -1529,7 +1562,7 @@ public:
 	map_dne_bound(0),
 	map_check_error(0),
 	map_check_error_str(NULL),
-	onfinish(NULL), ontimeout(NULL) {}
+	onfinish(NULL), ontimeout(0) {}
   };
 
   int submit_command(CommandOp *c, ceph_tid_t *ptid);
@@ -1560,7 +1593,7 @@ public:
 
     snapid_t snap;
     SnapContext snapc;
-    utime_t mtime;
+    ceph::real_time mtime;
 
     vector<OSDOp> ops;
     bufferlist inbl;
@@ -1568,13 +1601,13 @@ public:
     version_t *pobjver;
 
     bool is_watch;
-    utime_t watch_valid_thru; ///< send time for last acked ping
+    ceph::mono_time watch_valid_thru; ///< send time for last acked ping
     int last_error;  ///< error from last failed ping|reconnect, if any
     RWLock watch_lock;
 
     // queue of pending async operations, with the timestamp of
     // when they were queued.
-    list<utime_t> watch_pending_async;
+    list<ceph::mono_time> watch_pending_async;
 
     uint32_t register_gen;
     bool registered;
@@ -1598,7 +1631,7 @@ public:
 
     void _queued_async() {
       assert(watch_lock.is_locked());
-      watch_pending_async.push_back(ceph_clock_now(NULL));
+      watch_pending_async.push_back(ceph::mono_clock::now());
     }
     void finished_async() {
       RWLock::WLocker l(watch_lock);
@@ -1608,10 +1641,8 @@ public:
 
     LingerOp() : linger_id(0),
 		 target(object_t(), object_locator_t(), 0),
-		 snap(CEPH_NOSNAP),
-		 poutbl(NULL), pobjver(NULL),
-		 is_watch(false),
-		 last_error(0),
+		 snap(CEPH_NOSNAP), poutbl(NULL), pobjver(NULL),
+		 is_watch(false), last_error(0),
 		 watch_lock("Objecter::LingerOp::watch_lock"),
 		 register_gen(0),
 		 registered(false),
@@ -1673,7 +1704,7 @@ public:
   struct C_Linger_Ping : public Context {
     Objecter *objecter;
     LingerOp *info;
-    utime_t sent;
+    ceph::mono_time sent;
     uint32_t register_gen;
     C_Linger_Ping(Objecter *o, LingerOp *l)
       : objecter(o), info(l), register_gen(info->register_gen) {
@@ -1702,9 +1733,9 @@ public:
     Mutex **completion_locks;
 
     // pending ops
-    map<ceph_tid_t,Op*>            ops;
-    map<uint64_t, LingerOp*>  linger_ops;
-    map<ceph_tid_t,CommandOp*>     command_ops;
+    map<ceph_tid_t,Op*> ops;
+    map<uint64_t, LingerOp*> linger_ops;
+    map<ceph_tid_t,CommandOp*> command_ops;
 
     int osd;
     int incarnation;
@@ -1715,12 +1746,11 @@ public:
       lock("OSDSession"),
       osd(o),
       incarnation(0),
-      con(NULL)
-    {
+      con(NULL) {
       num_locks = cct->_conf->objecter_completion_locks_per_session;
       completion_locks = new Mutex *[num_locks];
       for (int i = 0; i < num_locks; i++) {
-        completion_locks[i] = new Mutex("OSDSession::completion_lock");
+	completion_locks[i] = new Mutex("OSDSession::completion_lock");
       }
     }
 
@@ -1747,29 +1777,30 @@ public:
   bool _osdmap_pool_full(const pg_pool_t &p) const;
   void update_pool_full_map(map<int64_t, bool>& pool_full_map);
 
-  map<uint64_t, LingerOp*>  linger_ops;
+  map<uint64_t, LingerOp*> linger_ops;
   // we use this just to confirm a cookie is valid before dereferencing the ptr
-  set<LingerOp*>            linger_ops_set;
+  set<LingerOp*> linger_ops_set;
   int num_linger_callbacks;
   Mutex linger_callback_lock;
   Cond linger_callback_cond;
 
-  map<ceph_tid_t,PoolStatOp*>    poolstat_ops;
-  map<ceph_tid_t,StatfsOp*>      statfs_ops;
-  map<ceph_tid_t,PoolOp*>        pool_ops;
-  atomic_t                  num_homeless_ops;
+  map<ceph_tid_t,PoolStatOp*> poolstat_ops;
+  map<ceph_tid_t,StatfsOp*> statfs_ops;
+  map<ceph_tid_t,PoolOp*> pool_ops;
+  atomic_t num_homeless_ops;
 
   OSDSession *homeless_session;
 
   // ops waiting for an osdmap with a new pool or confirmation that
   // the pool does not exist (may be expanded to other uses later)
-  map<uint64_t, LingerOp*>       check_latest_map_lingers;
-  map<ceph_tid_t, Op*>           check_latest_map_ops;
-  map<ceph_tid_t, CommandOp*>    check_latest_map_commands;
+  map<uint64_t, LingerOp*> check_latest_map_lingers;
+  map<ceph_tid_t, Op*> check_latest_map_ops;
+  map<ceph_tid_t, CommandOp*> check_latest_map_commands;
 
   map<epoch_t,list< pair<Context*, int> > > waiting_for_map;
 
-  double mon_timeout, osd_timeout;
+  ceph::timespan mon_timeout;
+  ceph::timespan osd_timeout;
 
   MOSDOp *_prepare_osd_op(Op *op);
   void _send_op(Op *op, MOSDOp *m = NULL);
@@ -1794,7 +1825,8 @@ public:
   bool _osdmap_has_pool_full() const;
 
   bool target_should_be_paused(op_target_t *op);
-  int _calc_target(op_target_t *t, epoch_t *last_force_resend=0, bool any_change=false);
+  int _calc_target(op_target_t *t, epoch_t *last_force_resend = 0,
+		   bool any_change = false);
   int _map_session(op_target_t *op, OSDSession **s,
 		   RWLock::Context& lc);
 
@@ -1805,7 +1837,9 @@ public:
   void _session_command_op_assign(OSDSession *to, CommandOp *op);
   void _session_command_op_remove(OSDSession *from, CommandOp *op);
 
-  int _assign_op_target_session(Op *op, RWLock::Context& lc, bool src_session_locked, bool dst_session_locked);
+  int _assign_op_target_session(Op *op, RWLock::Context& lc,
+				bool src_session_locked,
+				bool dst_session_locked);
   int _recalc_linger_op_target(LingerOp *op, RWLock::Context& lc);
 
   void _linger_submit(LingerOp *info);
@@ -1813,7 +1847,8 @@ public:
   void _linger_commit(LingerOp *info, int r, bufferlist& outbl);
   void _linger_reconnect(LingerOp *info, int r);
   void _send_linger_ping(LingerOp *info);
-  void _linger_ping(LingerOp *info, int r, utime_t sent, uint32_t register_gen);
+  void _linger_ping(LingerOp *info, int r, ceph::mono_time sent,
+		    uint32_t register_gen);
   int _normalize_watch_error(int r);
 
   void _linger_callback_queue() {
@@ -1854,7 +1889,7 @@ private:
   void get_session(OSDSession *s);
   void _reopen_session(OSDSession *session);
   void close_session(OSDSession *session);
-  
+
   void _nlist_reply(NListContext *list_context, int r, Context *final_finish,
 		   epoch_t reply_epoch);
   void _list_reply(ListContext *list_context, int r, Context *final_finish,
@@ -1901,28 +1936,19 @@ private:
 	   Finisher *fin,
 	   double mon_timeout,
 	   double osd_timeout) :
-    Dispatcher(cct_),
-    messenger(m), monc(mc), finisher(fin),
-    osdmap(new OSDMap),
-    initialized(0),
-    last_tid(0), client_inc(-1), max_linger_id(0),
-    num_unacked(0), num_uncommitted(0),
-    global_op_flags(0),
+    Dispatcher(cct_), messenger(m), monc(mc), finisher(fin),
+    osdmap(new OSDMap), initialized(0), last_tid(0), client_inc(-1),
+    max_linger_id(0), num_unacked(0), num_uncommitted(0), global_op_flags(0),
     keep_balanced_budget(false), honor_osdmap_full(true),
-    last_seen_osdmap_version(0),
-    last_seen_pgmap_version(0),
-    rwlock("Objecter::rwlock"),
-    timer_lock("Objecter::timer_lock"),
-    timer(cct, timer_lock, false),
-    logger(NULL), tick_event(NULL),
-    m_request_state_hook(NULL),
-    num_linger_callbacks(0),
+    last_seen_osdmap_version(0), last_seen_pgmap_version(0),
+    rwlock("Objecter::rwlock"), logger(NULL), tick_event(0),
+    m_request_state_hook(NULL), num_linger_callbacks(0),
     linger_callback_lock("Objecter::linger_callback_lock"),
-    num_homeless_ops(0),
-    homeless_session(new OSDSession(cct, -1)),
-    mon_timeout(mon_timeout),
-    osd_timeout(osd_timeout),
-    op_throttle_bytes(cct, "objecter_bytes", cct->_conf->objecter_inflight_op_bytes),
+    num_homeless_ops(0), homeless_session(new OSDSession(cct, -1)),
+    mon_timeout(ceph::make_timespan(mon_timeout)),
+    osd_timeout(ceph::make_timespan(osd_timeout)),
+    op_throttle_bytes(cct, "objecter_bytes",
+		      cct->_conf->objecter_inflight_op_bytes),
     op_throttle_ops(cct, "objecter_ops", cct->_conf->objecter_inflight_ops),
     epoch_barrier(0)
   { }
@@ -1954,15 +1980,17 @@ private:
   void unset_honor_osdmap_full() { honor_osdmap_full = false; }
 
   void _scan_requests(OSDSession *s,
-                     bool force_resend,
-		     bool cluster_full,
-                     map<int64_t, bool> *pool_full_map,
-		     map<ceph_tid_t, Op*>& need_resend,
-		     list<LingerOp*>& need_resend_linger,
-		     map<ceph_tid_t, CommandOp*>& need_resend_command);
-
-  int64_t get_object_hash_position(int64_t pool, const string& key, const string& ns);
-  int64_t get_object_pg_hash_position(int64_t pool, const string& key, const string& ns);
+		      bool force_resend,
+		      bool cluster_full,
+		      map<int64_t, bool> *pool_full_map,
+		      map<ceph_tid_t, Op*>& need_resend,
+		      list<LingerOp*>& need_resend_linger,
+		      map<ceph_tid_t, CommandOp*>& need_resend_command);
+
+  int64_t get_object_hash_position(int64_t pool, const string& key,
+				   const string& ns);
+  int64_t get_object_pg_hash_position(int64_t pool, const string& key,
+				      const string& ns);
 
   // messages
  public:
@@ -1989,13 +2017,15 @@ private:
   void wait_for_osd_map();
 
   int pool_snap_by_name(int64_t poolid, const char *snap_name, snapid_t *snap);
-  int pool_snap_get_info(int64_t poolid, snapid_t snap, pool_snap_info_t *info);
+  int pool_snap_get_info(int64_t poolid, snapid_t snap,
+			 pool_snap_info_t *info);
   int pool_snap_list(int64_t poolid, vector<uint64_t> *snaps);
 private:
 
   // low-level
   ceph_tid_t _op_submit(Op *op, RWLock::Context& lc);
-  ceph_tid_t _op_submit_with_budget(Op *op, RWLock::Context& lc, int *ctx_budget = NULL);
+  ceph_tid_t _op_submit_with_budget(Op *op, RWLock::Context& lc,
+				    int *ctx_budget = NULL);
   inline void unregister_op(Op *op);
 
   // public interface
@@ -2003,7 +2033,8 @@ public:
   ceph_tid_t op_submit(Op *op, int *ctx_budget = NULL);
   bool is_active() {
     RWLock::RLocker l(rwlock);
-    return !((!inflight_ops.read()) && linger_ops.empty() && poolstat_ops.empty() && statfs_ops.empty());
+    return !((!inflight_ops.read()) && linger_ops.empty() &&
+	     poolstat_ops.empty() && statfs_ops.empty());
   }
 
   /**
@@ -2037,15 +2068,19 @@ public:
   /** Get the current set of global op flags */
   int get_global_op_flags() { return global_op_flags.read(); }
   /** Add a flag to the global op flags, not really atomic operation */
-  void add_global_op_flags(int flag) { global_op_flags.set(global_op_flags.read() | flag); } 
-  /** Clear the passed flags from the global op flag set, not really atomic operation */
-  void clear_global_op_flag(int flags) { global_op_flags.set(global_op_flags.read() & ~flags); }
+  void add_global_op_flags(int flag) {
+    global_op_flags.set(global_op_flags.read() | flag);
+  }
+  /** Clear the passed flags from the global op flag set, not really
+      atomic operation */
+  void clear_global_op_flag(int flags) {
+    global_op_flags.set(global_op_flags.read() & ~flags);
+  }
 
   /// cancel an in-progress request with the given return code
 private:
   int op_cancel(OSDSession *s, ceph_tid_t tid, int r);
   int _op_cancel(ceph_tid_t tid, int r);
-  friend class C_CancelOp;
 public:
   int op_cancel(ceph_tid_t tid, int r);
 
@@ -2088,11 +2123,12 @@ public:
 
   // mid-level helpers
   Op *prepare_mutate_op(const object_t& oid, const object_locator_t& oloc,
-	       ObjectOperation& op,
-	       const SnapContext& snapc, utime_t mtime, int flags,
-	       Context *onack, Context *oncommit, version_t *objver = NULL,
-	       osd_reqid_t reqid = osd_reqid_t()) {
-    Op *o = new Op(oid, oloc, op.ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+			ObjectOperation& op, const SnapContext& snapc,
+			ceph::real_time mtime, int flags, Context *onack,
+			Context *oncommit, version_t *objver = NULL,
+			osd_reqid_t reqid = osd_reqid_t()) {
+    Op *o = new Op(oid, oloc, op.ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->priority = op.priority;
     o->mtime = mtime;
     o->snapc = snapc;
@@ -2101,18 +2137,21 @@ public:
     return o;
   }
   ceph_tid_t mutate(const object_t& oid, const object_locator_t& oloc,
-	       ObjectOperation& op,
-	       const SnapContext& snapc, utime_t mtime, int flags,
-	       Context *onack, Context *oncommit, version_t *objver = NULL,
-	       osd_reqid_t reqid = osd_reqid_t()) {
-    Op *o = prepare_mutate_op(oid, oloc, op, snapc, mtime, flags, onack, oncommit, objver, reqid);
+		    ObjectOperation& op, const SnapContext& snapc,
+		    ceph::real_time mtime, int flags, Context *onack,
+		    Context *oncommit, version_t *objver = NULL,
+		    osd_reqid_t reqid = osd_reqid_t()) {
+    Op *o = prepare_mutate_op(oid, oloc, op, snapc, mtime, flags, onack,
+			      oncommit, objver, reqid);
     return op_submit(o);
   }
   Op *prepare_read_op(const object_t& oid, const object_locator_t& oloc,
 	     ObjectOperation& op,
 	     snapid_t snapid, bufferlist *pbl, int flags,
-	     Context *onack, version_t *objver = NULL, int *data_offset = NULL) {
-    Op *o = new Op(oid, oloc, op.ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, onack, NULL, objver, data_offset);
+	     Context *onack, version_t *objver = NULL,
+		      int *data_offset = NULL) {
+    Op *o = new Op(oid, oloc, op.ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, onack, NULL, objver, data_offset);
     o->priority = op.priority;
     o->snapid = snapid;
     o->outbl = pbl;
@@ -2126,19 +2165,19 @@ public:
   ceph_tid_t read(const object_t& oid, const object_locator_t& oloc,
 		  ObjectOperation& op,
 		  snapid_t snapid, bufferlist *pbl, int flags,
-		  Context *onack, version_t *objver = NULL, int *data_offset = NULL,
+		  Context *onack, version_t *objver = NULL,
+		  int *data_offset = NULL,
 		  uint64_t features = 0) {
-    Op *o = prepare_read_op(oid, oloc, op, snapid, pbl, flags, onack, objver, data_offset);
+    Op *o = prepare_read_op(oid, oloc, op, snapid, pbl, flags, onack, objver,
+			    data_offset);
     if (features)
       o->features = features;
     return op_submit(o);
   }
   ceph_tid_t pg_read(uint32_t hash, object_locator_t oloc,
-		ObjectOperation& op,
-		bufferlist *pbl, int flags,
-		Context *onack,
-		epoch_t *reply_epoch,
-                int *ctx_budget) {
+		     ObjectOperation& op, bufferlist *pbl, int flags,
+		     Context *onack, epoch_t *reply_epoch,
+		     int *ctx_budget) {
     Op *o = new Op(object_t(), oloc,
 		   op.ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ,
 		   onack, NULL, NULL);
@@ -2163,7 +2202,7 @@ public:
 			    int flags);
   ceph_tid_t linger_watch(LingerOp *info,
 			  ObjectOperation& op,
-			  const SnapContext& snapc, utime_t mtime,
+			  const SnapContext& snapc, ceph::real_time mtime,
 			  bufferlist& inbl,
 			  Context *onfinish,
 			  version_t *objver);
@@ -2207,25 +2246,25 @@ public:
 
 
   // high-level helpers
-  ceph_tid_t stat(const object_t& oid, const object_locator_t& oloc, snapid_t snap,
-	     uint64_t *psize, utime_t *pmtime, int flags, 
-	     Context *onfinish,
-	     version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+  ceph_tid_t stat(const object_t& oid, const object_locator_t& oloc,
+		  snapid_t snap, uint64_t *psize, ceph::real_time *pmtime,
+		  int flags, Context *onfinish, version_t *objver = NULL,
+		  ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_STAT;
     C_Stat *fin = new C_Stat(psize, pmtime, onfinish);
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, fin, 0, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, fin, 0, objver);
     o->snapid = snap;
     o->outbl = &fin->bl;
     return op_submit(o);
   }
 
   ceph_tid_t read(const object_t& oid, const object_locator_t& oloc,
-	     uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl, int flags,
-	     Context *onfinish,
-	     version_t *objver = NULL, ObjectOperation *extra_ops = NULL,
-	     int op_flags = 0) {
+		  uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl,
+		  int flags, Context *onfinish, version_t *objver = NULL,
+		  ObjectOperation *extra_ops = NULL, int op_flags = 0) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_READ;
@@ -2234,18 +2273,19 @@ public:
     ops[i].op.extent.truncate_size = 0;
     ops[i].op.extent.truncate_seq = 0;
     ops[i].op.flags = op_flags;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, onfinish, 0, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, onfinish, 0, objver);
     o->snapid = snap;
     o->outbl = pbl;
     return op_submit(o);
   }
 
   ceph_tid_t read_trunc(const object_t& oid, const object_locator_t& oloc,
-	     uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl, int flags,
-	     uint64_t trunc_size, __u32 trunc_seq,
-	     Context *onfinish, 
-	     version_t *objver = NULL, ObjectOperation *extra_ops = NULL,
-	     int op_flags = 0) {
+			uint64_t off, uint64_t len, snapid_t snap,
+			bufferlist *pbl, int flags, uint64_t trunc_size,
+			__u32 trunc_seq, Context *onfinish,
+			version_t *objver = NULL,
+			ObjectOperation *extra_ops = NULL, int op_flags = 0) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_READ;
@@ -2254,15 +2294,16 @@ public:
     ops[i].op.extent.truncate_size = trunc_size;
     ops[i].op.extent.truncate_seq = trunc_seq;
     ops[i].op.flags = op_flags;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, onfinish, 0, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, onfinish, 0, objver);
     o->snapid = snap;
     o->outbl = pbl;
     return op_submit(o);
   }
   ceph_tid_t mapext(const object_t& oid, const object_locator_t& oloc,
-	     uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl, int flags,
-	     Context *onfinish,
-	     version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+		    uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl,
+		    int flags, Context *onfinish, version_t *objver = NULL,
+		    ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_MAPEXT;
@@ -2270,7 +2311,8 @@ public:
     ops[i].op.extent.length = len;
     ops[i].op.extent.truncate_size = 0;
     ops[i].op.extent.truncate_seq = 0;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, onfinish, 0, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, onfinish, 0, objver);
     o->snapid = snap;
     o->outbl = pbl;
     return op_submit(o);
@@ -2286,52 +2328,54 @@ public:
     ops[i].op.xattr.value_len = 0;
     if (name)
       ops[i].indata.append(name);
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, onfinish, 0, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, onfinish, 0, objver);
     o->snapid = snap;
     o->outbl = pbl;
     return op_submit(o);
   }
 
-  ceph_tid_t getxattrs(const object_t& oid, const object_locator_t& oloc, snapid_t snap,
-		  map<string,bufferlist>& attrset,
-		  int flags, Context *onfinish,
-		  version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+  ceph_tid_t getxattrs(const object_t& oid, const object_locator_t& oloc,
+		       snapid_t snap, map<string,bufferlist>& attrset,
+		       int flags, Context *onfinish, version_t *objver = NULL,
+		       ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_GETXATTRS;
     C_GetAttrs *fin = new C_GetAttrs(attrset, onfinish);
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ, fin, 0, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_READ, fin, 0, objver);
     o->snapid = snap;
     o->outbl = &fin->bl;
     return op_submit(o);
   }
 
   ceph_tid_t read_full(const object_t& oid, const object_locator_t& oloc,
-		  snapid_t snap, bufferlist *pbl, int flags,
-		  Context *onfinish,
-	          version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
-    return read(oid, oloc, 0, 0, snap, pbl, flags | global_op_flags.read() | CEPH_OSD_FLAG_READ,
-		onfinish, objver, extra_ops);
+		       snapid_t snap, bufferlist *pbl, int flags,
+		       Context *onfinish, version_t *objver = NULL,
+		       ObjectOperation *extra_ops = NULL) {
+    return read(oid, oloc, 0, 0, snap, pbl, flags | global_op_flags.read() |
+		CEPH_OSD_FLAG_READ, onfinish, objver, extra_ops);
   }
 
 
   // writes
   ceph_tid_t _modify(const object_t& oid, const object_locator_t& oloc,
-		vector<OSDOp>& ops, utime_t mtime,
-		const SnapContext& snapc, int flags,
-	        Context *onack, Context *oncommit,
-	        version_t *objver = NULL) {
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+		     vector<OSDOp>& ops, ceph::real_time mtime,
+		     const SnapContext& snapc, int flags,
+		     Context *onack, Context *oncommit,
+		     version_t *objver = NULL) {
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
-	      uint64_t off, uint64_t len, const SnapContext& snapc, const bufferlist &bl,
-	      utime_t mtime, int flags,
-	      Context *onack, Context *oncommit,
-	      version_t *objver = NULL, ObjectOperation *extra_ops = NULL,
-	      int op_flags = 0) {
+		   uint64_t off, uint64_t len, const SnapContext& snapc,
+		   const bufferlist &bl, ceph::real_time mtime, int flags,
+		   Context *onack, Context *oncommit, version_t *objver = NULL,
+		   ObjectOperation *extra_ops = NULL, int op_flags = 0) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_WRITE;
@@ -2341,16 +2385,18 @@ public:
     ops[i].op.extent.truncate_seq = 0;
     ops[i].indata = bl;
     ops[i].op.flags = op_flags;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t append(const object_t& oid, const object_locator_t& oloc,
-	       uint64_t len, const SnapContext& snapc, const bufferlist &bl,
-	       utime_t mtime, int flags,
-	       Context *onack, Context *oncommit,
-	       version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+		    uint64_t len, const SnapContext& snapc,
+		    const bufferlist &bl, ceph::real_time mtime, int flags,
+		    Context *onack, Context *oncommit,
+		    version_t *objver = NULL,
+		    ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_APPEND;
@@ -2359,18 +2405,19 @@ public:
     ops[i].op.extent.truncate_size = 0;
     ops[i].op.extent.truncate_seq = 0;
     ops[i].indata = bl;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t write_trunc(const object_t& oid, const object_locator_t& oloc,
-	      uint64_t off, uint64_t len, const SnapContext& snapc, const bufferlist &bl,
-	      utime_t mtime, int flags,
-	      uint64_t trunc_size, __u32 trunc_seq,
-	      Context *onack, Context *oncommit,
-	      version_t *objver = NULL, ObjectOperation *extra_ops = NULL,
-	      int op_flags = 0) {
+			 uint64_t off, uint64_t len, const SnapContext& snapc,
+			 const bufferlist &bl, ceph::real_time mtime, int flags,
+			 uint64_t trunc_size, __u32 trunc_seq,
+			 Context *onack, Context *oncommit,
+			 version_t *objver = NULL,
+			 ObjectOperation *extra_ops = NULL, int op_flags = 0) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_WRITE;
@@ -2380,16 +2427,17 @@ public:
     ops[i].op.extent.truncate_seq = trunc_seq;
     ops[i].indata = bl;
     ops[i].op.flags = op_flags;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t write_full(const object_t& oid, const object_locator_t& oloc,
-		   const SnapContext& snapc, const bufferlist &bl, utime_t mtime, int flags,
-		   Context *onack, Context *oncommit,
-		   version_t *objver = NULL, ObjectOperation *extra_ops = NULL,
-		   int op_flags = 0) {
+			const SnapContext& snapc, const bufferlist &bl,
+			ceph::real_time mtime, int flags, Context *onack,
+			Context *oncommit, version_t *objver = NULL,
+			ObjectOperation *extra_ops = NULL, int op_flags = 0) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_WRITEFULL;
@@ -2397,77 +2445,83 @@ public:
     ops[i].op.extent.length = bl.length();
     ops[i].indata = bl;
     ops[i].op.flags = op_flags;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t trunc(const object_t& oid, const object_locator_t& oloc,
-	      const SnapContext& snapc,
-	      utime_t mtime, int flags,
-	      uint64_t trunc_size, __u32 trunc_seq,
-              Context *onack, Context *oncommit,
-	      version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+		   const SnapContext& snapc, ceph::real_time mtime, int flags,
+		   uint64_t trunc_size, __u32 trunc_seq, Context *onack,
+		   Context *oncommit, version_t *objver = NULL,
+		   ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_TRUNCATE;
     ops[i].op.extent.offset = trunc_size;
     ops[i].op.extent.truncate_size = trunc_size;
     ops[i].op.extent.truncate_seq = trunc_seq;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t zero(const object_t& oid, const object_locator_t& oloc,
-	     uint64_t off, uint64_t len, const SnapContext& snapc, utime_t mtime, int flags,
-             Context *onack, Context *oncommit,
+		  uint64_t off, uint64_t len, const SnapContext& snapc,
+		  ceph::real_time mtime, int flags, Context *onack, Context *oncommit,
 	     version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_ZERO;
     ops[i].op.extent.offset = off;
     ops[i].op.extent.length = len;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t rollback_object(const object_t& oid, const object_locator_t& oloc,
-		 const SnapContext& snapc, snapid_t snapid,
-		 utime_t mtime, Context *onack, Context *oncommit,
-		 version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+			     const SnapContext& snapc, snapid_t snapid,
+			     ceph::real_time mtime, Context *onack, Context *oncommit,
+			     version_t *objver = NULL,
+			     ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_ROLLBACK;
     ops[i].op.snap.snapid = snapid;
-    Op *o = new Op(oid, oloc, ops, CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, CEPH_OSD_FLAG_WRITE, onack, oncommit,
+		   objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t create(const object_t& oid, const object_locator_t& oloc,
-	     const SnapContext& snapc, utime_t mtime,
-             int global_flags, int create_flags,
-             Context *onack, Context *oncommit,
-             version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
+		    const SnapContext& snapc, ceph::real_time mtime, int global_flags,
+		    int create_flags, Context *onack, Context *oncommit,
+		    version_t *objver = NULL,
+		    ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_CREATE;
     ops[i].op.flags = create_flags;
-    Op *o = new Op(oid, oloc, ops, global_flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, global_flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t remove(const object_t& oid, const object_locator_t& oloc,
-	       const SnapContext& snapc, utime_t mtime, int flags,
+	       const SnapContext& snapc, ceph::real_time mtime, int flags,
 	       Context *onack, Context *oncommit,
 	       version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_DELETE;
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
@@ -2475,7 +2529,7 @@ public:
 
   ceph_tid_t setxattr(const object_t& oid, const object_locator_t& oloc,
 	      const char *name, const SnapContext& snapc, const bufferlist &bl,
-	      utime_t mtime, int flags,
+	      ceph::real_time mtime, int flags,
 	      Context *onack, Context *oncommit,
 	      version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
@@ -2486,14 +2540,15 @@ public:
     if (name)
       ops[i].indata.append(name);
     ops[i].indata.append(bl);
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
   }
   ceph_tid_t removexattr(const object_t& oid, const object_locator_t& oloc,
 	      const char *name, const SnapContext& snapc,
-	      utime_t mtime, int flags,
+	      ceph::real_time mtime, int flags,
 	      Context *onack, Context *oncommit,
 	      version_t *objver = NULL, ObjectOperation *extra_ops = NULL) {
     vector<OSDOp> ops;
@@ -2503,7 +2558,8 @@ public:
     ops[i].op.xattr.value_len = 0;
     if (name)
       ops[i].indata.append(name);
-    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() | CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
+    Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
+		   CEPH_OSD_FLAG_WRITE, onack, oncommit, objver);
     o->mtime = mtime;
     o->snapc = snapc;
     return op_submit(o);
@@ -2514,6 +2570,31 @@ public:
   void list_objects(ListContext *p, Context *onfinish);
   uint32_t list_objects_seek(ListContext *p, uint32_t pos);
 
+  hobject_t enumerate_objects_begin();
+  hobject_t enumerate_objects_end();
+  //hobject_t enumerate_objects_begin(int n, int m);
+  void enumerate_objects(
+    int64_t pool_id,
+    const std::string &ns,
+    const hobject_t &start,
+    const hobject_t &end,
+    const uint32_t max,
+    std::list<librados::ListObjectImpl> *result, 
+    hobject_t *next,
+    Context *on_finish);
+
+  void _enumerate_reply(
+      bufferlist &bl,
+      int r,
+      const hobject_t &end,
+      const int64_t pool_id,
+      int budget,
+      epoch_t reply_epoch,
+      std::list<librados::ListObjectImpl> *result, 
+      hobject_t *next,
+      Context *on_finish);
+  friend class C_EnumerateReply;
+
   // -------------------------
   // pool ops
 private:
@@ -2523,7 +2604,8 @@ private:
   void _do_delete_pool(int64_t pool, Context *onfinish);
 public:
   int create_pool_snap(int64_t pool, string& snapName, Context *onfinish);
-  int allocate_selfmanaged_snap(int64_t pool, snapid_t *psnapid, Context *onfinish);
+  int allocate_selfmanaged_snap(int64_t pool, snapid_t *psnapid,
+				Context *onfinish);
   int delete_pool_snap(int64_t pool, string& snapName, Context *onfinish);
   int delete_selfmanaged_snap(int64_t pool, snapid_t snap, Context *onfinish);
 
@@ -2560,7 +2642,8 @@ public:
   // ---------------------------
   // some scatter/gather hackery
 
-  void _sg_read_finish(vector<ObjectExtent>& extents, vector<bufferlist>& resultbl, 
+  void _sg_read_finish(vector<ObjectExtent>& extents,
+		       vector<bufferlist>& resultbl,
 		       bufferlist *bl, Context *onfinish);
 
   struct C_SGRead : public Context {
@@ -2569,59 +2652,69 @@ public:
     vector<bufferlist> resultbl;
     bufferlist *bl;
     Context *onfinish;
-    C_SGRead(Objecter *ob, 
-	     vector<ObjectExtent>& e, vector<bufferlist>& r, bufferlist *b, Context *c) :
+    C_SGRead(Objecter *ob,
+	     vector<ObjectExtent>& e, vector<bufferlist>& r, bufferlist *b,
+	     Context *c) :
       objecter(ob), bl(b), onfinish(c) {
       extents.swap(e);
       resultbl.swap(r);
     }
     void finish(int r) {
       objecter->_sg_read_finish(extents, resultbl, bl, onfinish);
-    }      
+    }
   };
 
-  void sg_read_trunc(vector<ObjectExtent>& extents, snapid_t snap, bufferlist *bl, int flags,
-		uint64_t trunc_size, __u32 trunc_seq, Context *onfinish, int op_flags = 0) {
+  void sg_read_trunc(vector<ObjectExtent>& extents, snapid_t snap,
+		     bufferlist *bl, int flags, uint64_t trunc_size,
+		     __u32 trunc_seq, Context *onfinish, int op_flags = 0) {
     if (extents.size() == 1) {
-      read_trunc(extents[0].oid, extents[0].oloc, extents[0].offset, extents[0].length,
-	   snap, bl, flags, extents[0].truncate_size, trunc_seq, onfinish, 
-	   0, 0, op_flags);
+      read_trunc(extents[0].oid, extents[0].oloc, extents[0].offset,
+		 extents[0].length, snap, bl, flags, extents[0].truncate_size,
+		 trunc_seq, onfinish, 0, 0, op_flags);
     } else {
       C_GatherBuilder gather(cct);
       vector<bufferlist> resultbl(extents.size());
       int i=0;
-      for (vector<ObjectExtent>::iterator p = extents.begin(); p != extents.end(); ++p) {
-	read_trunc(p->oid, p->oloc, p->offset, p->length,
-	     snap, &resultbl[i++], flags, p->truncate_size, trunc_seq, gather.new_sub(),
-	     0, 0, op_flags);
+      for (vector<ObjectExtent>::iterator p = extents.begin();
+	   p != extents.end();
+	   ++p) {
+	read_trunc(p->oid, p->oloc, p->offset, p->length, snap, &resultbl[i++],
+		   flags, p->truncate_size, trunc_seq, gather.new_sub(),
+		   0, 0, op_flags);
       }
       gather.set_finisher(new C_SGRead(this, extents, resultbl, bl, onfinish));
       gather.activate();
     }
   }
 
-  void sg_read(vector<ObjectExtent>& extents, snapid_t snap, bufferlist *bl, int flags, Context *onfinish, int op_flags = 0) {
+  void sg_read(vector<ObjectExtent>& extents, snapid_t snap, bufferlist *bl,
+	       int flags, Context *onfinish, int op_flags = 0) {
     sg_read_trunc(extents, snap, bl, flags, 0, 0, onfinish, op_flags);
   }
 
-  void sg_write_trunc(vector<ObjectExtent>& extents, const SnapContext& snapc, const bufferlist& bl, utime_t mtime,
-		int flags, uint64_t trunc_size, __u32 trunc_seq,
-		Context *onack, Context *oncommit, int op_flags = 0) {
+  void sg_write_trunc(vector<ObjectExtent>& extents, const SnapContext& snapc,
+		      const bufferlist& bl, ceph::real_time mtime, int flags,
+		      uint64_t trunc_size, __u32 trunc_seq, Context *onack,
+		      Context *oncommit, int op_flags = 0) {
     if (extents.size() == 1) {
-      write_trunc(extents[0].oid, extents[0].oloc, extents[0].offset, extents[0].length,
-	    snapc, bl, mtime, flags, extents[0].truncate_size, trunc_seq, onack, oncommit,
-	    0, 0, op_flags);
+      write_trunc(extents[0].oid, extents[0].oloc, extents[0].offset,
+		  extents[0].length, snapc, bl, mtime, flags,
+		  extents[0].truncate_size, trunc_seq, onack, oncommit,
+		  0, 0, op_flags);
     } else {
       C_GatherBuilder gack(cct, onack);
       C_GatherBuilder gcom(cct, oncommit);
-      for (vector<ObjectExtent>::iterator p = extents.begin(); p != extents.end(); ++p) {
+      for (vector<ObjectExtent>::iterator p = extents.begin();
+	   p != extents.end();
+	   ++p) {
 	bufferlist cur;
-	for (vector<pair<uint64_t,uint64_t> >::iterator bit = p->buffer_extents.begin();
+	for (vector<pair<uint64_t,uint64_t> >::iterator bit
+	       = p->buffer_extents.begin();
 	     bit != p->buffer_extents.end();
 	     ++bit)
 	  bl.copy(bit->first, bit->second, cur);
 	assert(cur.length() == p->length);
-	write_trunc(p->oid, p->oloc, p->offset, p->length, 
+	write_trunc(p->oid, p->oloc, p->offset, p->length,
 	      snapc, cur, mtime, flags, p->truncate_size, trunc_seq,
 	      onack ? gack.new_sub():0,
 	      oncommit ? gcom.new_sub():0,
@@ -2632,9 +2725,11 @@ public:
     }
   }
 
-  void sg_write(vector<ObjectExtent>& extents, const SnapContext& snapc, const bufferlist& bl, utime_t mtime,
-		int flags, Context *onack, Context *oncommit, int op_flags = 0) {
-    sg_write_trunc(extents, snapc, bl, mtime, flags, 0, 0, onack, oncommit, op_flags);
+  void sg_write(vector<ObjectExtent>& extents, const SnapContext& snapc,
+		const bufferlist& bl, ceph::real_time mtime, int flags,
+		Context *onack, Context *oncommit, int op_flags = 0) {
+    sg_write_trunc(extents, snapc, bl, mtime, flags, 0, 0, onack, oncommit,
+		   op_flags);
   }
 
   void ms_handle_connect(Connection *con);
diff --git a/src/osdc/Striper.cc b/src/osdc/Striper.cc
index a8682de..9a35ffe 100644
--- a/src/osdc/Striper.cc
+++ b/src/osdc/Striper.cc
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #include "Striper.h"
@@ -27,10 +27,11 @@
 
 
 void Striper::file_to_extents(CephContext *cct, const char *object_format,
-			    const ceph_file_layout *layout,
-			    uint64_t offset, uint64_t len, uint64_t trunc_size,
-			    vector<ObjectExtent>& extents,
-			    uint64_t buffer_offset)
+			      const ceph_file_layout *layout,
+			      uint64_t offset, uint64_t len,
+			      uint64_t trunc_size,
+			      vector<ObjectExtent>& extents,
+			      uint64_t buffer_offset)
 {
   map<object_t,vector<ObjectExtent> > object_extents;
   file_to_extents(cct, object_format, layout, offset, len, trunc_size,
@@ -38,23 +39,25 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format,
   assimilate_extents(object_extents, extents);
 }
 
-void Striper::file_to_extents(CephContext *cct, const char *object_format,
-			      const ceph_file_layout *layout,
-			      uint64_t offset, uint64_t len, uint64_t trunc_size,
-			      map<object_t,vector<ObjectExtent> >& object_extents,
-			      uint64_t buffer_offset)
+void Striper::file_to_extents(
+  CephContext *cct, const char *object_format,
+  const ceph_file_layout *layout,
+  uint64_t offset, uint64_t len,
+  uint64_t trunc_size,
+  map<object_t,vector<ObjectExtent> >& object_extents,
+  uint64_t buffer_offset)
 {
-  ldout(cct, 10) << "file_to_extents " << offset << "~" << len 
+  ldout(cct, 10) << "file_to_extents " << offset << "~" << len
 		 << " format " << object_format
 		 << dendl;
   assert(len > 0);
 
   /*
-   * we want only one extent per object!
-   * this means that each extent we read may map into different bits of the 
-   * final read buffer.. hence ObjectExtent.buffer_extents
+   * we want only one extent per object!  this means that each extent
+   * we read may map into different bits of the final read
+   * buffer.. hence ObjectExtent.buffer_extents
    */
-  
+
   __u32 object_size = layout->fl_object_size;
   __u32 su = layout->fl_stripe_unit;
   __u32 stripe_count = layout->fl_stripe_count;
@@ -64,18 +67,23 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format,
     su = object_size;
   }
   uint64_t stripes_per_object = object_size / su;
-  ldout(cct, 20) << " su " << su << " sc " << stripe_count << " os " << object_size
-		 << " stripes_per_object " << stripes_per_object << dendl;
+  ldout(cct, 20) << " su " << su << " sc " << stripe_count << " os "
+		 << object_size << " stripes_per_object " << stripes_per_object
+		 << dendl;
 
   uint64_t cur = offset;
   uint64_t left = len;
   while (left > 0) {
     // layout into objects
-    uint64_t blockno = cur / su;          // which block
-    uint64_t stripeno = blockno / stripe_count;    // which horizontal stripe        (Y)
-    uint64_t stripepos = blockno % stripe_count;   // which object in the object set (X)
-    uint64_t objectsetno = stripeno / stripes_per_object;       // which object set
-    uint64_t objectno = objectsetno * stripe_count + stripepos;  // object id
+    uint64_t blockno = cur / su; // which block
+    // which horizontal stripe (Y)
+    uint64_t stripeno = blockno / stripe_count;
+    // which object in the object set (X)
+    uint64_t stripepos = blockno % stripe_count;
+    // which object set
+    uint64_t objectsetno = stripeno / stripes_per_object;
+    // object id
+    uint64_t objectno = objectsetno * stripe_count + stripepos;
 
     // find oid, extent
     char buf[strlen(object_format) + 32];
@@ -94,12 +102,11 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format,
     else
       x_len = left;
 
-    ldout(cct, 20) << " off " << cur << " blockno " << blockno << " stripeno " << stripeno
-		   << " stripepos " << stripepos << " objectsetno " << objectsetno
-		   << " objectno " << objectno
-		   << " block_start " << block_start
-		   << " block_off " << block_off
-		   << " " << x_offset << "~" << x_len
+    ldout(cct, 20) << " off " << cur << " blockno " << blockno << " stripeno "
+		   << stripeno << " stripepos " << stripepos << " objectsetno "
+		   << objectsetno << " objectno " << objectno
+		   << " block_start " << block_start << " block_off "
+		   << block_off << " " << x_offset << "~" << x_len
 		   << dendl;
 
     ObjectExtent *ex = 0;
@@ -113,7 +120,8 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format,
 
       ex->offset = x_offset;
       ex->length = x_len;
-      ex->truncate_size = object_truncate_size(cct, layout, objectno, trunc_size);
+      ex->truncate_size = object_truncate_size(cct, layout, objectno,
+					       trunc_size);
 
       ldout(cct, 20) << " added new " << *ex << dendl;
     } else {
@@ -122,24 +130,32 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format,
       ldout(cct, 20) << " adding in to " << *ex << dendl;
       ex->length += x_len;
     }
-    ex->buffer_extents.push_back(make_pair(cur - offset + buffer_offset, x_len));
-        
-    ldout(cct, 15) << "file_to_extents  " << *ex << " in " << ex->oloc << dendl;
-    //ldout(cct, 0) << "map: ino " << ino << " oid " << ex.oid << " osd " << ex.osd << " offset " << ex.offset << " len " << ex.len << " ... left " << left << dendl;
-    
+    ex->buffer_extents.push_back(make_pair(cur - offset + buffer_offset,
+					   x_len));
+
+    ldout(cct, 15) << "file_to_extents  " << *ex << " in " << ex->oloc
+		   << dendl;
+    // ldout(cct, 0) << "map: ino " << ino << " oid " << ex.oid << " osd "
+    //		  << ex.osd << " offset " << ex.offset << " len " << ex.len
+    //		  << " ... left " << left << dendl;
+
     left -= x_len;
     cur += x_len;
   }
 }
 
-void Striper::assimilate_extents(map<object_t,vector<ObjectExtent> >& object_extents,
-				 vector<ObjectExtent>& extents)
+void Striper::assimilate_extents(
+  map<object_t,vector<ObjectExtent> >& object_extents,
+  vector<ObjectExtent>& extents)
 {
   // make final list
-  for (map<object_t, vector<ObjectExtent> >::iterator it = object_extents.begin();
+  for (map<object_t, vector<ObjectExtent> >::iterator it
+	 = object_extents.begin();
        it != object_extents.end();
        ++it) {
-    for (vector<ObjectExtent>::iterator p = it->second.begin(); p != it->second.end(); ++p) {
+    for (vector<ObjectExtent>::iterator p = it->second.begin();
+	 p != it->second.end();
+	 ++p) {
       extents.push_back(*p);
     }
   }
@@ -149,7 +165,8 @@ void Striper::extent_to_file(CephContext *cct, ceph_file_layout *layout,
 			   uint64_t objectno, uint64_t off, uint64_t len,
 			   vector<pair<uint64_t, uint64_t> >& extents)
 {
-  ldout(cct, 10) << "extent_to_file " << objectno << " " << off << "~" << len << dendl;
+  ldout(cct, 10) << "extent_to_file " << objectno << " " << off << "~"
+		 << len << dendl;
 
   __u32 object_size = layout->fl_object_size;
   __u32 su = layout->fl_stripe_unit;
@@ -181,7 +198,8 @@ void Striper::extent_to_file(CephContext *cct, ceph_file_layout *layout,
   }
 }
 
-uint64_t Striper::object_truncate_size(CephContext *cct, const ceph_file_layout *layout,
+uint64_t Striper::object_truncate_size(CephContext *cct,
+				       const ceph_file_layout *layout,
 				       uint64_t objectno, uint64_t trunc_size)
 {
   uint64_t obj_trunc_size;
@@ -204,20 +222,23 @@ uint64_t Striper::object_truncate_size(CephContext *cct, const ceph_file_layout
       uint64_t trunc_blockno = trunc_size / su;
       uint64_t trunc_stripeno = trunc_blockno / stripe_count;
       uint64_t trunc_stripepos = trunc_blockno % stripe_count;
-      uint64_t trunc_objectno = trunc_objectsetno * stripe_count + trunc_stripepos;
+      uint64_t trunc_objectno = trunc_objectsetno * stripe_count
+	+ trunc_stripepos;
       if (objectno < trunc_objectno)
 	obj_trunc_size = ((trunc_stripeno % stripes_per_object) + 1) * su;
       else if (objectno > trunc_objectno)
 	obj_trunc_size = (trunc_stripeno % stripes_per_object) * su;
       else
-	obj_trunc_size = (trunc_stripeno % stripes_per_object) * su + (trunc_size % su);
+	obj_trunc_size = (trunc_stripeno % stripes_per_object) * su
+	  + (trunc_size % su);
     }
   }
   ldout(cct, 20) << "object_truncate_size " << objectno << " "
 		 << trunc_size << "->" << obj_trunc_size << dendl;
   return obj_trunc_size;
 }
-uint64_t Striper::get_num_objects(const ceph_file_layout& layout, uint64_t size)
+uint64_t Striper::get_num_objects(const ceph_file_layout& layout,
+				  uint64_t size)
 {
   __u32 object_size = layout.fl_object_size;
   __u32 stripe_unit = layout.fl_stripe_unit;
@@ -226,19 +247,23 @@ uint64_t Striper::get_num_objects(const ceph_file_layout& layout, uint64_t size)
   uint64_t num_periods = (size + period - 1) / period;
   uint64_t remainder_bytes = size % period;
   uint64_t remainder_objs = 0;
-  if ((remainder_bytes > 0) && (remainder_bytes < (uint64_t)stripe_count * stripe_unit))
-    remainder_objs = stripe_count - ((remainder_bytes + stripe_unit - 1) / stripe_unit);
+  if ((remainder_bytes > 0) && (remainder_bytes < (uint64_t)stripe_count
+				* stripe_unit))
+    remainder_objs = stripe_count - ((remainder_bytes + stripe_unit - 1)
+				     / stripe_unit);
   return num_periods * stripe_count - remainder_objs;
 }
 
 // StripedReadResult
 
-void Striper::StripedReadResult::add_partial_result(CephContext *cct,
-						    bufferlist& bl,
-						    const vector<pair<uint64_t,uint64_t> >& buffer_extents)
+void Striper::StripedReadResult::add_partial_result(
+  CephContext *cct, bufferlist& bl,
+  const vector<pair<uint64_t,uint64_t> >& buffer_extents)
 {
-  ldout(cct, 10) << "add_partial_result(" << this << ") " << bl.length() << " to " << buffer_extents << dendl;
-  for (vector<pair<uint64_t,uint64_t> >::const_iterator p = buffer_extents.begin();
+  ldout(cct, 10) << "add_partial_result(" << this << ") " << bl.length()
+		 << " to " << buffer_extents << dendl;
+  for (vector<pair<uint64_t,uint64_t> >::const_iterator p
+	 = buffer_extents.begin();
        p != buffer_extents.end();
        ++p) {
     pair<bufferlist, uint64_t>& r = partial[p->first];
@@ -248,16 +273,16 @@ void Striper::StripedReadResult::add_partial_result(CephContext *cct,
   }
 }
 
-void Striper::StripedReadResult::add_partial_sparse_result(CephContext *cct,
-							 bufferlist& bl, const map<uint64_t, uint64_t>& bl_map,
-							 uint64_t bl_off,
-							 const vector<pair<uint64_t,uint64_t> >& buffer_extents)
+void Striper::StripedReadResult::add_partial_sparse_result(
+  CephContext *cct, bufferlist& bl, const map<uint64_t, uint64_t>& bl_map,
+  uint64_t bl_off, const vector<pair<uint64_t,uint64_t> >& buffer_extents)
 {
   ldout(cct, 10) << "add_partial_sparse_result(" << this << ") " << bl.length()
 		 << " covering " << bl_map << " (offset " << bl_off << ")"
 		 << " to " << buffer_extents << dendl;
   map<uint64_t, uint64_t>::const_iterator s = bl_map.begin();
-  for (vector<pair<uint64_t,uint64_t> >::const_iterator p = buffer_extents.begin();
+  for (vector<pair<uint64_t,uint64_t> >::const_iterator p
+	 = buffer_extents.begin();
        p != buffer_extents.end();
        ++p) {
     uint64_t tofs = p->first;
@@ -319,21 +344,25 @@ void Striper::StripedReadResult::add_partial_sparse_result(CephContext *cct,
   }
 }
 
-void Striper::StripedReadResult::assemble_result(CephContext *cct, bufferlist& bl, bool zero_tail)
+void Striper::StripedReadResult::assemble_result(CephContext *cct,
+						 bufferlist& bl,
+						 bool zero_tail)
 {
-  ldout(cct, 10) << "assemble_result(" << this << ") zero_tail=" << zero_tail << dendl;
+  ldout(cct, 10) << "assemble_result(" << this << ") zero_tail=" << zero_tail
+		 << dendl;
 
   // go backwards, so that we can efficiently discard zeros
-  map<uint64_t,pair<bufferlist,uint64_t> >::reverse_iterator p = partial.rbegin();
+  map<uint64_t,pair<bufferlist,uint64_t> >::reverse_iterator p
+    = partial.rbegin();
   if (p == partial.rend())
     return;
 
   uint64_t end = p->first + p->second.second;
   while (p != partial.rend()) {
     // sanity check
-    ldout(cct, 20) << "assemble_result(" << this << ") " << p->first << "~" << p->second.second
-		   << " " << p->second.first.length() << " bytes"
-		   << dendl;
+    ldout(cct, 20) << "assemble_result(" << this << ") " << p->first << "~"
+		   << p->second.second << " " << p->second.first.length()
+		   << " bytes" << dendl;
     assert(p->first == end - p->second.second);
     end = p->first;
 
diff --git a/src/osdc/Striper.h b/src/osdc/Striper.h
index ec90f15..228045a 100644
--- a/src/osdc/Striper.h
+++ b/src/osdc/Striper.h
@@ -1,4 +1,4 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
@@ -7,9 +7,9 @@
  *
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
+ * License version 2.1, as published by the Free Software
  * Foundation.  See file COPYING.
- * 
+ *
  */
 
 #ifndef CEPH_STRIPER_H
@@ -30,19 +30,22 @@ class CephContext;
      */
     static void file_to_extents(CephContext *cct, const char *object_format,
 				const ceph_file_layout *layout,
-				uint64_t offset, uint64_t len, uint64_t trunc_size,
+				uint64_t offset, uint64_t len,
+				uint64_t trunc_size,
 				map<object_t, vector<ObjectExtent> >& extents,
 				uint64_t buffer_offset=0);
 
     static void file_to_extents(CephContext *cct, const char *object_format,
 				const ceph_file_layout *layout,
-				uint64_t offset, uint64_t len, uint64_t trunc_size,
+				uint64_t offset, uint64_t len,
+				uint64_t trunc_size,
 				vector<ObjectExtent>& extents,
 				uint64_t buffer_offset=0);
 
     static void file_to_extents(CephContext *cct, inodeno_t ino,
 				const ceph_file_layout *layout,
-				uint64_t offset, uint64_t len, uint64_t trunc_size,
+				uint64_t offset, uint64_t len,
+				uint64_t trunc_size,
 				vector<ObjectExtent>& extents) {
       // generate prefix/format
       char buf[32];
@@ -51,8 +54,9 @@ class CephContext;
       file_to_extents(cct, buf, layout, offset, len, trunc_size, extents);
     }
 
-    static void assimilate_extents(map<object_t,vector<ObjectExtent> >& object_extents,
-				   vector<ObjectExtent>& extents);
+    static void assimilate_extents(
+      map<object_t, vector<ObjectExtent> >& object_extents,
+      vector<ObjectExtent>& extents);
 
     /**
      * reverse map an object extent to file extents
@@ -61,32 +65,36 @@ class CephContext;
 			       uint64_t objectno, uint64_t off, uint64_t len,
 			       vector<pair<uint64_t, uint64_t> >& extents);
 
-    static uint64_t object_truncate_size(CephContext *cct, const ceph_file_layout *layout,
-					 uint64_t objectno, uint64_t trunc_size);
+    static uint64_t object_truncate_size(
+      CephContext *cct, const ceph_file_layout *layout,
+      uint64_t objectno, uint64_t trunc_size);
 
-    static uint64_t get_num_objects(const ceph_file_layout& layout, uint64_t size);
+    static uint64_t get_num_objects(const ceph_file_layout& layout,
+				    uint64_t size);
     /*
      * helper to assemble a striped result
      */
     class StripedReadResult {
-      map<uint64_t, pair<bufferlist, uint64_t> > partial;  // offset -> (data, intended length)
+      // offset -> (data, intended length)
+      map<uint64_t, pair<bufferlist, uint64_t> > partial;
 
     public:
-      void add_partial_result(CephContext *cct,
-			      bufferlist& bl,
-			      const vector<pair<uint64_t,uint64_t> >& buffer_extents);
+      void add_partial_result(
+	CephContext *cct, bufferlist& bl,
+	const vector<pair<uint64_t,uint64_t> >& buffer_extents);
       /**
        * add sparse read into results
        *
        * @param bl buffer
        * @param bl_map map of which logical source extents this covers
-       * @param bl_off logical buffer offset (e.g., first bl_map key if the buffer is not sparse)
+       * @param bl_off logical buffer offset (e.g., first bl_map key
+       *               if the buffer is not sparse)
        * @param buffer_extents output buffer extents the data maps to
        */
-      void add_partial_sparse_result(CephContext *cct,
-				     bufferlist& bl, const map<uint64_t, uint64_t>& bl_map,
-				     uint64_t bl_off,
-				     const vector<pair<uint64_t,uint64_t> >& buffer_extents);
+      void add_partial_sparse_result(
+	CephContext *cct, bufferlist& bl,
+	const map<uint64_t, uint64_t>& bl_map, uint64_t bl_off,
+	const vector<pair<uint64_t,uint64_t> >& buffer_extents);
 
       void assemble_result(CephContext *cct, bufferlist& bl, bool zero_tail);
     };
diff --git a/src/osdc/WritebackHandler.h b/src/osdc/WritebackHandler.h
index 0e51cb0..f0efd20 100644
--- a/src/osdc/WritebackHandler.h
+++ b/src/osdc/WritebackHandler.h
@@ -19,24 +19,35 @@ class WritebackHandler {
   /**
    * check if a given extent read result may change due to a write
    *
-   * Check if the content we see at the given read offset may change due to a write to
-   * this object.
+   * Check if the content we see at the given read offset may change
+   * due to a write to this object.
    *
    * @param oid object
    * @param read_off read offset
    * @param read_len read length
    * @param snapid read snapid
    */
-  virtual bool may_copy_on_write(const object_t& oid, uint64_t read_off, uint64_t read_len, snapid_t snapid) = 0;
+  virtual bool may_copy_on_write(const object_t& oid, uint64_t read_off,
+				 uint64_t read_len, snapid_t snapid) = 0;
   virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
-			   uint64_t off, uint64_t len, const SnapContext& snapc,
-			   const bufferlist &bl, utime_t mtime,
+			   uint64_t off, uint64_t len,
+			   const SnapContext& snapc,
+			   const bufferlist &bl, ceph::real_time mtime,
 			   uint64_t trunc_size, __u32 trunc_seq,
                            ceph_tid_t journal_tid, Context *oncommit) = 0;
 
   virtual void overwrite_extent(const object_t& oid, uint64_t off, uint64_t len,
                                 ceph_tid_t journal_tid) {}
 
+  virtual bool can_scattered_write() { return false; }
+  virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
+			   vector<pair<uint64_t, bufferlist> >& io_vec,
+			   const SnapContext& snapc, ceph::real_time mtime,
+			   uint64_t trunc_size, __u32 trunc_seq,
+			   Context *oncommit) {
+    return 0;
+  }
+
   virtual void get_client_lock() {}
   virtual void put_client_lock() {}
 };
diff --git a/src/pybind/ceph_volume_client.py b/src/pybind/ceph_volume_client.py
new file mode 100644
index 0000000..2e284b2
--- /dev/null
+++ b/src/pybind/ceph_volume_client.py
@@ -0,0 +1,791 @@
+"""
+Copyright (C) 2015 Red Hat, Inc.
+
+LGPL2.  See file COPYING.
+"""
+
+import json
+import logging
+import os
+import threading
+import errno
+import time
+
+import rados
+import cephfs
+from ceph_argparse import json_command
+
+# Generate missing lib errors at load time, rather than the
+# first time someone tries to use the FS
+try:
+    cephfs.load_libcephfs()
+except EnvironmentError as e:
+    raise ImportError(e.__str__())
+
+
+class RadosError(Exception):
+    """
+    Something went wrong talking to Ceph with librados
+    """
+    pass
+
+
+RADOS_TIMEOUT = 10
+SNAP_DIR = ".snap"
+
+log = logging.getLogger(__name__)
+
+
+# Reserved volume group name which we use in paths for volumes
+# that are not assigned to a group (i.e. created with group=None)
+NO_GROUP_NAME = "_nogroup"
+
+
+class VolumePath(object):
+    """
+    Identify a volume's path as group->volume
+    The Volume ID is a unique identifier, but this is a much more
+    helpful thing to pass around.
+    """
+    def __init__(self, group_id, volume_id):
+        self.group_id = group_id
+        self.volume_id = volume_id
+        assert self.group_id != NO_GROUP_NAME
+
+    def __str__(self):
+        return "{0}/{1}".format(self.group_id, self.volume_id)
+
+
+class ClusterTimeout(Exception):
+    """
+    Exception indicating that we timed out trying to talk to the Ceph cluster,
+    either to the mons, or to any individual daemon that the mons indicate ought
+    to be up but isn't responding to us.
+    """
+    pass
+
+
+class ClusterError(Exception):
+    """
+    Exception indicating that the cluster returned an error to a command that
+    we thought should be successful based on our last knowledge of the cluster
+    state.
+    """
+    def __init__(self, action, result_code, result_str):
+        self._action = action
+        self._result_code = result_code
+        self._result_str = result_str
+
+    def __str__(self):
+        return "Error {0} (\"{1}\") while {2}".format(
+            self._result_code, self._result_str, self._action)
+
+
+class RankEvicter(threading.Thread):
+    """
+    Thread for evicting client(s) from a particular MDS daemon instance.
+
+    This is more complex than simply sending a command, because we have to
+    handle cases where MDS daemons might not be fully up yet, and/or might
+    be transiently unresponsive to commands.
+    """
+    class GidGone(Exception):
+        pass
+
+    POLL_PERIOD = 5
+
+    def __init__(self, volume_client, client_spec, rank, gid, mds_map, ready_timeout):
+        """
+        :param client_spec: list of strings, used as filter arguments to "session evict"
+                            pass ["id=123"] to evict a single client with session id 123.
+        """
+        self.rank = rank
+        self.gid = gid
+        self._mds_map = mds_map
+        self._client_spec = client_spec
+        self._volume_client = volume_client
+        self._ready_timeout = ready_timeout
+        self._ready_waited = 0
+
+        self.success = False
+        self.exception = None
+
+        super(RankEvicter, self).__init__()
+
+    def _ready_to_evict(self):
+        if self._mds_map['up'].get("mds_{0}".format(self.rank), None) != self.gid:
+            log.info("Evicting {0} from {1}/{2}: rank no longer associated with gid, done.".format(
+                self._client_spec, self.rank, self.gid
+            ))
+            raise RankEvicter.GidGone()
+
+        info = self._mds_map['info']["gid_{0}".format(self.gid)]
+        log.debug("_ready_to_evict: state={0}".format(info['state']))
+        return info['state'] in ["up:active", "up:clientreplay"]
+
+    def _wait_for_ready(self):
+        """
+        Wait for that MDS rank to reach an active or clientreplay state, and
+        not be laggy.
+        """
+        while not self._ready_to_evict():
+            if self._ready_waited > self._ready_timeout:
+                raise ClusterTimeout()
+
+            time.sleep(self.POLL_PERIOD)
+            self._ready_waited += self.POLL_PERIOD
+
+            self._mds_map = self._volume_client._rados_command("mds dump", {})
+
+    def _evict(self):
+        """
+        Run the eviction procedure.  Return true on success, false on errors.
+        """
+
+        # Wait til the MDS is believed by the mon to be available for commands
+        try:
+            self._wait_for_ready()
+        except self.GidGone:
+            return True
+
+        # Then send it an evict
+        ret = errno.ETIMEDOUT
+        while ret == errno.ETIMEDOUT:
+            log.debug("mds_command: {0}, {1}".format(
+                "%s" % self.gid, ["session", "evict"] + self._client_spec
+            ))
+            ret, outb, outs = self._volume_client.fs.mds_command(
+                "%s" % self.gid,
+                [json.dumps({
+                                "prefix": "session evict",
+                                "filters": self._client_spec
+                })], "")
+            log.debug("mds_command: complete {0} {1}".format(ret, outs))
+
+            # If we get a clean response, great, it's gone from that rank.
+            if ret == 0:
+                return True
+            elif ret == errno.ETIMEDOUT:
+                # Oh no, the MDS went laggy (that's how libcephfs knows to emit this error)
+                self._mds_map = self._volume_client._rados_command("mds dump", {})
+                try:
+                    self._wait_for_ready()
+                except self.GidGone:
+                    return True
+            else:
+                raise ClusterError("Sending evict to mds.{0}".format(self.gid), ret, outs)
+
+    def run(self):
+        try:
+            self._evict()
+        except Exception, e:
+            self.success = False
+            self.exception = e
+        else:
+            self.success = True
+
+
+class EvictionError(Exception):
+    pass
+
+
+class CephFSVolumeClient(object):
+    """
+    Combine libcephfs and librados interfaces to implement a
+    'Volume' concept implemented as a cephfs directory and
+    client capabilities which restrict mount access to this
+    directory.
+
+    Additionally, volumes may be in a 'Group'.  Conveniently,
+    volumes are a lot like manila shares, and groups are a lot
+    like manila consistency groups.
+
+    Refer to volumes with VolumePath, which specifies the
+    volume and group IDs (both strings).  The group ID may
+    be None.
+
+    In general, functions in this class are allowed raise rados.Error
+    or cephfs.Error exceptions in unexpected situations.
+    """
+
+    # Where shall we create our volumes?
+    VOLUME_PREFIX = "/volumes"
+    POOL_PREFIX = "fsvolume_"
+
+    def __init__(self, auth_id, conf_path, cluster_name):
+        self.fs = None
+        self.rados = None
+        self.connected = False
+        self.conf_path = conf_path
+        self.cluster_name = cluster_name
+        self.auth_id = auth_id
+
+    def evict(self, auth_id, timeout=30):
+        """
+        Evict all clients using this authorization ID. Assumes that the
+        authorisation key has been revoked prior to calling this function.
+
+        This operation can throw an exception if the mon cluster is unresponsive, or
+        any individual MDS daemon is unresponsive for longer than the timeout passed in.
+        """
+
+        log.info("evict: {0}".format(auth_id))
+
+        mds_map = self._rados_command("mds dump", {})
+
+        up = {}
+        for name, gid in mds_map['up'].items():
+            # Quirk of the MDSMap JSON dump: keys in the up dict are like "mds_0"
+            assert name.startswith("mds_")
+            up[int(name[4:])] = gid
+
+        # For all MDS ranks held by a daemon
+        # Do the parallelism in python instead of using "tell mds.*", because
+        # the latter doesn't give us per-mds output
+        threads = []
+        for rank, gid in up.items():
+            thread = RankEvicter(self, ["auth_name={0}".format(auth_id)], rank, gid, mds_map, timeout)
+            thread.start()
+            threads.append(thread)
+
+        for t in threads:
+            t.join()
+
+        log.info("evict: joined all")
+
+        for t in threads:
+            if not t.success:
+                msg = "Failed to evict client {0} from mds {1}/{2}: {3}".format(
+                    auth_id, t.rank, t.gid, t.exception
+                )
+                log.error(msg)
+                raise EvictionError(msg)
+
+    def _get_path(self, volume_path):
+        """
+        Determine the path within CephFS where this volume will live
+        :return: absolute path (string)
+        """
+        return os.path.join(
+            self.VOLUME_PREFIX,
+            volume_path.group_id if volume_path.group_id is not None else NO_GROUP_NAME,
+            volume_path.volume_id)
+
+    def _get_group_path(self, group_id):
+        if group_id is None:
+            raise ValueError("group_id may not be None")
+
+        return os.path.join(
+            self.VOLUME_PREFIX,
+            group_id
+        )
+
+    def connect(self, premount_evict = None):
+        """
+
+        :param premount_evict: Optional auth_id to evict before mounting the filesystem: callers
+                               may want to use this to specify their own auth ID if they expect
+                               to be a unique instance and don't want to wait for caps to time
+                               out after failure of another instance of themselves.
+        """
+        log.debug("Connecting to RADOS with config {0}...".format(self.conf_path))
+        self.rados = rados.Rados(
+            name="client.{0}".format(self.auth_id),
+            clustername=self.cluster_name,
+            conffile=self.conf_path,
+            conf={}
+        )
+        self.rados.connect()
+
+        log.debug("Connection to RADOS complete")
+
+        log.debug("Connecting to cephfs...")
+        self.fs = cephfs.LibCephFS(rados_inst=self.rados)
+        log.debug("CephFS initializing...")
+        self.fs.init()
+        if premount_evict is not None:
+            log.debug("Premount eviction of {0} starting".format(premount_evict))
+            self.evict(premount_evict)
+            log.debug("Premount eviction of {0} completes".format(premount_evict))
+        log.debug("CephFS mounting...")
+        self.fs.mount()
+        log.debug("Connection to cephfs complete")
+
+    def get_mon_addrs(self):
+        log.info("get_mon_addrs")
+        result = []
+        mon_map = self._rados_command("mon dump")
+        for mon in mon_map['mons']:
+            ip_port = mon['addr'].split("/")[0]
+            result.append(ip_port)
+
+        return result
+
+    def disconnect(self):
+        log.info("disconnect")
+        if self.fs:
+            log.debug("Disconnecting cephfs...")
+            self.fs.shutdown()
+            self.fs = None
+            log.debug("Disconnecting cephfs complete")
+
+        if self.rados:
+            log.debug("Disconnecting rados...")
+            self.rados.shutdown()
+            self.rados = None
+            log.debug("Disconnecting rados complete")
+
+    def __del__(self):
+        self.disconnect()
+
+    def _get_pool_id(self, osd_map, pool_name):
+        # Maybe borrow the OSDMap wrapper class from calamari if more helpers like this aren't needed.
+        for pool in osd_map['pools']:
+            if pool['pool_name'] == pool_name:
+                return pool['pool']
+
+        return None
+
+    def _create_volume_pool(self, pool_name):
+        """
+        Idempotently create a pool for use as a CephFS data pool, with the given name
+
+        :return The ID of the created pool
+        """
+        osd_map = self._rados_command('osd dump', {})
+
+        existing_id = self._get_pool_id(osd_map, pool_name)
+        if existing_id is not None:
+            log.info("Pool {0} already exists".format(pool_name))
+            return existing_id
+
+        osd_count = len(osd_map['osds'])
+
+        # We can't query the actual cluster config remotely, but since this is
+        # just a heuristic we'll assume that the ceph.conf we have locally reflects
+        # that in use in the rest of the cluster.
+        pg_warn_max_per_osd = int(self.rados.conf_get('mon_pg_warn_max_per_osd'))
+
+        other_pgs = 0
+        for pool in osd_map['pools']:
+            if not pool['pool_name'].startswith(self.POOL_PREFIX):
+                other_pgs += pool['pg_num']
+
+        # A basic heuristic for picking pg_num: work out the max number of
+        # PGs we can have without tripping a warning, then subtract the number
+        # of PGs already created by non-manila pools, then divide by ten.  That'll
+        # give you a reasonable result on a system where you have "a few" manila
+        # shares.
+        pg_num = ((pg_warn_max_per_osd * osd_count) - other_pgs) / 10
+        # TODO Alternatively, respect an override set by the user.
+
+        self._rados_command(
+            'osd pool create',
+            {
+                'pool': pool_name,
+                'pg_num': pg_num
+            }
+        )
+
+        osd_map = self._rados_command('osd dump', {})
+        pool_id = self._get_pool_id(osd_map, pool_name)
+
+        if pool_id is None:
+            # If the pool isn't there, that's either a ceph bug, or it's some outside influence
+            # removing it right after we created it.
+            log.error("OSD map doesn't contain expected pool '{0}':\n{1}".format(
+                pool_name, json.dumps(osd_map, indent=2)
+            ))
+            raise RuntimeError("Pool '{0}' not present in map after creation".format(pool_name))
+        else:
+            return pool_id
+
+    def create_group(self, group_id):
+        path = self._get_group_path(group_id)
+        self._mkdir_p(path)
+
+    def destroy_group(self, group_id):
+        path = self._get_group_path(group_id)
+        try:
+            self.fs.stat(self.VOLUME_PREFIX)
+        except cephfs.ObjectNotFound:
+            pass
+        else:
+            self.fs.rmdir(path)
+
+    def _mkdir_p(self, path):
+        try:
+            self.fs.stat(path)
+        except cephfs.ObjectNotFound:
+            pass
+        else:
+            return
+
+        parts = path.split(os.path.sep)
+
+        for i in range(1, len(parts) + 1):
+            subpath = os.path.join(*parts[0:i])
+            try:
+                self.fs.stat(subpath)
+            except cephfs.ObjectNotFound:
+                self.fs.mkdir(subpath, 0755)
+
+    def create_volume(self, volume_path, size=None, data_isolated=False):
+        """
+        Set up metadata, pools and auth for a volume.
+
+        This function is idempotent.  It is safe to call this again
+        for an already-created volume, even if it is in use.
+
+        :param volume_path: VolumePath instance
+        :param size: In bytes, or None for no size limit
+        :param data_isolated: If true, create a separate OSD pool for this volume
+        :return:
+        """
+        log.info("create_volume: {0}".format(volume_path))
+        path = self._get_path(volume_path)
+
+        self._mkdir_p(path)
+
+        if size is not None:
+            self.fs.setxattr(path, 'ceph.quota.max_bytes', size.__str__(), 0)
+
+        if data_isolated:
+            pool_name = "{0}{1}".format(self.POOL_PREFIX, volume_path.volume_id)
+            pool_id = self._create_volume_pool(pool_name)
+            mds_map = self._rados_command("mds dump", {})
+            if pool_id not in mds_map['data_pools']:
+                self._rados_command("mds add_data_pool", {
+                    'pool': pool_name
+                })
+            self.fs.setxattr(path, 'ceph.dir.layout.pool', pool_name, 0)
+
+        return {
+            'mount_path': path
+        }
+
+    def delete_volume(self, volume_path, data_isolated=False):
+        """
+        Make a volume inaccessible to guests.  This function is
+        idempotent.  This is the fast part of tearing down a volume: you must
+        also later call purge_volume, which is the slow part.
+
+        :param volume_path: Same identifier used in create_volume
+        :return:
+        """
+
+        log.info("delete_volume: {0}".format(volume_path))
+
+        # Create the trash folder if it doesn't already exist
+        trash = os.path.join(self.VOLUME_PREFIX, "_deleting")
+        self._mkdir_p(trash)
+
+        # We'll move it to here
+        trashed_volume = os.path.join(trash, volume_path.volume_id)
+
+        # Move the volume's data to the trash folder
+        path = self._get_path(volume_path)
+        try:
+            self.fs.stat(path)
+        except cephfs.ObjectNotFound:
+            log.warning("Trying to delete volume '{0}' but it's already gone".format(
+                path))
+        else:
+            self.fs.rename(path, trashed_volume)
+
+    def purge_volume(self, volume_path, data_isolated=False):
+        """
+        Finish clearing up a volume that was previously passed to delete_volume.  This
+        function is idempotent.
+        """
+
+        trash = os.path.join(self.VOLUME_PREFIX, "_deleting")
+        trashed_volume = os.path.join(trash, volume_path.volume_id)
+
+        try:
+            self.fs.stat(trashed_volume)
+        except cephfs.ObjectNotFound:
+            log.warning("Trying to purge volume '{0}' but it's already been purged".format(
+                trashed_volume))
+            return
+
+        def rmtree(root_path):
+            log.debug("rmtree {0}".format(root_path))
+            dir_handle = self.fs.opendir(root_path)
+            d = self.fs.readdir(dir_handle)
+            while d:
+                if d.d_name not in [".", ".."]:
+                    d_full = os.path.join(root_path, d.d_name)
+                    if d.is_dir():
+                        rmtree(d_full)
+                    else:
+                        self.fs.unlink(d_full)
+
+                d = self.fs.readdir(dir_handle)
+            self.fs.closedir(dir_handle)
+
+            self.fs.rmdir(root_path)
+
+        rmtree(trashed_volume)
+
+        if data_isolated:
+            pool_name = "{0}{1}".format(self.POOL_PREFIX, volume_path.volume_id)
+            osd_map = self._rados_command("osd dump", {})
+            pool_id = self._get_pool_id(osd_map, pool_name)
+            mds_map = self._rados_command("mds dump", {})
+            if pool_id in mds_map['data_pools']:
+                self._rados_command("mds remove_data_pool", {
+                    'pool': pool_name
+                })
+            self._rados_command("osd pool delete",
+                                {
+                                    "pool": pool_name,
+                                    "pool2": pool_name,
+                                    "sure": "--yes-i-really-really-mean-it"
+                                })
+
+    def _get_ancestor_xattr(self, path, attr):
+        """
+        Helper for reading layout information: if this xattr is missing
+        on the requested path, keep checking parents until we find it.
+        """
+        try:
+            result = self.fs.getxattr(path, attr)
+            if result == "":
+                # Annoying!  cephfs gives us empty instead of an error when attr not found
+                raise cephfs.NoData()
+            else:
+                return result
+        except cephfs.NoData:
+            if path == "/":
+                raise
+            else:
+                return self._get_ancestor_xattr(os.path.split(path)[0], attr)
+
+    def authorize(self, volume_path, auth_id):
+        """
+        Get-or-create a Ceph auth identity for `auth_id` and grant them access
+        to
+        :param volume_path:
+        :param auth_id:
+        :return:
+        """
+
+        # First I need to work out what the data pool is for this share:
+        # read the layout
+        path = self._get_path(volume_path)
+        pool_name = self._get_ancestor_xattr(path, "ceph.dir.layout.pool")
+
+        # Now construct auth capabilities that give the guest just enough
+        # permissions to access the share
+        client_entity = "client.{0}".format(auth_id)
+        want_mds_cap = 'allow rw path={0}'.format(path)
+        want_osd_cap = 'allow rw pool={0}'.format(pool_name)
+        try:
+            existing = self._rados_command(
+                'auth get',
+                {
+                    'entity': client_entity
+                }
+            )
+            # FIXME: rados raising Error instead of ObjectNotFound in auth get failure
+        except rados.Error:
+            caps = self._rados_command(
+                'auth get-or-create',
+                {
+                    'entity': client_entity,
+                    'caps': [
+                        'mds', want_mds_cap,
+                        'osd', want_osd_cap,
+                        'mon', 'allow r']
+                })
+        else:
+            # entity exists, extend it
+            cap = existing[0]
+
+            def cap_extend(orig, want):
+                cap_tokens = orig.split(",")
+                if want not in cap_tokens:
+                    cap_tokens.append(want)
+
+                return ",".join(cap_tokens)
+
+            osd_cap_str = cap_extend(cap['caps'].get('osd', ""), want_osd_cap)
+            mds_cap_str = cap_extend(cap['caps'].get('mds', ""), want_mds_cap)
+
+            caps = self._rados_command(
+                'auth caps',
+                {
+                    'entity': client_entity,
+                    'caps': [
+                        'mds', mds_cap_str,
+                        'osd', osd_cap_str,
+                        'mon', cap['caps'].get('mon')]
+                })
+            caps = self._rados_command(
+                'auth get',
+                {
+                    'entity': client_entity
+                }
+            )
+
+        # Result expected like this:
+        # [
+        #     {
+        #         "entity": "client.foobar",
+        #         "key": "AQBY0\/pViX\/wBBAAUpPs9swy7rey1qPhzmDVGQ==",
+        #         "caps": {
+        #             "mds": "allow *",
+        #             "mon": "allow *"
+        #         }
+        #     }
+        # ]
+        assert len(caps) == 1
+        assert caps[0]['entity'] == client_entity
+        key = caps[0]['key']
+
+        return {
+            'auth_key': key
+        }
+
+    def deauthorize(self, volume_path, auth_id):
+        """
+        The volume must still exist.
+        """
+        client_entity = "client.{0}".format(auth_id)
+        path = self._get_path(volume_path)
+        pool_name = self._get_ancestor_xattr(path, "ceph.dir.layout.pool")
+
+        want_mds_cap = 'allow rw path={0}'.format(path)
+        want_osd_cap = 'allow rw pool={0}'.format(pool_name)
+
+        try:
+            existing = self._rados_command(
+                'auth get',
+                {
+                    'entity': client_entity
+                }
+            )
+
+            def cap_remove(orig, want):
+                cap_tokens = orig.split(",")
+                if want in cap_tokens:
+                    cap_tokens.remove(want)
+
+                return ",".join(cap_tokens)
+
+            cap = existing[0]
+            osd_cap_str = cap_remove(cap['caps'].get('osd', ""), want_osd_cap)
+            mds_cap_str = cap_remove(cap['caps'].get('mds', ""), want_mds_cap)
+            if (not osd_cap_str) and (not mds_cap_str):
+                self._rados_command('auth del', {'entity': client_entity}, decode=False)
+            else:
+                self._rados_command(
+                    'auth caps',
+                    {
+                        'entity': client_entity,
+                        'caps': [
+                            'mds', mds_cap_str,
+                            'osd', osd_cap_str,
+                            'mon', cap['caps'].get('mon')]
+                    })
+
+        # FIXME: rados raising Error instead of ObjectNotFound in auth get failure
+        except rados.Error:
+            # Already gone, great.
+            return
+
+    def _rados_command(self, prefix, args=None, decode=True):
+        """
+        Safer wrapper for ceph_argparse.json_command, which raises
+        Error exception instead of relying on caller to check return
+        codes.
+
+        Error exception can result from:
+        * Timeout
+        * Actual legitimate errors
+        * Malformed JSON output
+
+        return: Decoded object from ceph, or None if empty string returned.
+                If decode is False, return a string (the data returned by
+                ceph command)
+        """
+        if args is None:
+            args = {}
+
+        argdict = args.copy()
+        argdict['format'] = 'json'
+
+        ret, outbuf, outs = json_command(self.rados,
+                                         prefix=prefix,
+                                         argdict=argdict,
+                                         timeout=RADOS_TIMEOUT)
+        if ret != 0:
+            raise rados.Error(outs)
+        else:
+            if decode:
+                if outbuf:
+                    try:
+                        return json.loads(outbuf)
+                    except (ValueError, TypeError):
+                        raise RadosError("Invalid JSON output for command {0}".format(argdict))
+                else:
+                    return None
+            else:
+                return outbuf
+
+    def get_used_bytes(self, volume_path):
+        return int(self.fs.getxattr(self._get_path(volume_path), "ceph.dir.rbytes"))
+
+    def set_max_bytes(self, volume_path, max_bytes):
+        self.fs.setxattr(self._get_path(volume_path), 'ceph.quota.max_bytes',
+                         max_bytes.__str__() if max_bytes is not None else "0",
+                         0)
+
+    def _snapshot_path(self, dir_path, snapshot_name):
+        return os.path.join(
+            dir_path, SNAP_DIR, snapshot_name
+        )
+
+    def _snapshot_create(self, dir_path, snapshot_name):
+        # TODO: raise intelligible exception for clusters where snaps are disabled
+        self.fs.mkdir(self._snapshot_path(dir_path, snapshot_name), 0755)
+
+    def _snapshot_destroy(self, dir_path, snapshot_name):
+        """
+        Remove a snapshot, or do nothing if it already doesn't exist.
+        """
+        try:
+            self.fs.rmdir(self._snapshot_path(dir_path, snapshot_name))
+        except cephfs.ObjectNotFound:
+            log.warn("Snapshot was already gone: {0}".format(snapshot_name))
+
+    def create_snapshot_volume(self, volume_path, snapshot_name):
+        self._snapshot_create(self._get_path(volume_path), snapshot_name)
+
+    def destroy_snapshot_volume(self, volume_path, snapshot_name):
+        self._snapshot_destroy(self._get_path(volume_path), snapshot_name)
+
+    def create_snapshot_group(self, group_id, snapshot_name):
+        if group_id is None:
+            raise RuntimeError("Group ID may not be None")
+
+        return self._snapshot_create(self._get_group_path(group_id), snapshot_name)
+
+    def destroy_snapshot_group(self, group_id, snapshot_name):
+        if group_id is None:
+            raise RuntimeError("Group ID may not be None")
+        if snapshot_name is None:
+            raise RuntimeError("Snapshot name may not be None")
+
+        return self._snapshot_destroy(self._get_group_path(group_id), snapshot_name)
+
+    def _cp_r(self, src, dst):
+        # TODO
+        raise NotImplementedError()
+
+    def clone_volume_to_existing(self, dest_volume_path, src_volume_path, src_snapshot_name):
+        dest_fs_path = self._get_path(dest_volume_path)
+        src_snapshot_path = self._snapshot_path(self._get_path(src_volume_path), src_snapshot_name)
+
+        self._cp_r(src_snapshot_path, dest_fs_path)
diff --git a/src/pybind/cephfs.py b/src/pybind/cephfs.py
index f11b6dc..71c0d40 100644
--- a/src/pybind/cephfs.py
+++ b/src/pybind/cephfs.py
@@ -194,13 +194,36 @@ class LibCephFS(object):
         raise LibCephFSStateError("You cannot perform that operation on a "
                                   "CephFS object in state %s." % (self.state))
 
-    def __init__(self, conf=None, conffile=None):
+    def __init__(self, conf=None, conffile=None, auth_id=None, rados_inst=None):
         self.libcephfs = load_libcephfs()
         self.cluster = c_void_p()
 
+        self.state = "uninitialized"
+        if rados_inst is not None:
+            if auth_id is not None or conffile is not None or conf is not None:
+                raise InvalidValue("May not pass RADOS instance as well as other configuration")
+
+            return self.create_with_rados(rados_inst)
+        else:
+            return self.create(conf, conffile, auth_id)
+
+    def create_with_rados(self, rados_inst):
+        ret = self.libcephfs.ceph_create_from_rados(
+                byref(self.cluster),
+                rados_inst.cluster)
+        if ret != 0:
+            raise Error("libcephfs_initialize failed with error code: %d" % ret)
+        self.state = "configuring"
+
+    def create(self, conf=None, conffile=None, auth_id=None, rados_inst=None):
         if conffile is not None and not isinstance(conffile, basestring):
             raise TypeError('conffile must be a string or None')
-        ret = self.libcephfs.ceph_create(byref(self.cluster), c_char_p(0))
+
+        if auth_id is not None and not isinstance(auth_id, basestring):
+            raise TypeError('auth_id must be a string or None')
+
+        ret = self.libcephfs.ceph_create(byref(self.cluster),
+                c_char_p(auth_id) if auth_id else c_char_p(0))
         if ret != 0:
             raise Error("libcephfs_initialize failed with error code: %d" % ret)
         self.state = "configuring"
diff --git a/src/pybind/rbd.pyx b/src/pybind/rbd.pyx
index 9318997..a03d975 100644
--- a/src/pybind/rbd.pyx
+++ b/src/pybind/rbd.pyx
@@ -30,6 +30,8 @@ cdef extern from "Python.h":
     char* PyBytes_AsString(PyObject *string) except NULL
     int _PyBytes_Resize(PyObject **string, Py_ssize_t newsize) except -1
 
+ctypedef int (*librbd_progress_fn_t)(uint64_t offset, uint64_t total, void* ptr)
+
 cdef extern from "rbd/librbd.h" nogil:
     enum:
         _RBD_FEATURE_LAYERING "RBD_FEATURE_LAYERING"
@@ -76,7 +78,6 @@ cdef extern from "rbd/librbd.h" nogil:
         uint64_t size
         char *name
 
-
     void rbd_version(int *major, int *minor, int *extra)
 
     void rbd_image_options_create(rbd_image_options_t* opts)
@@ -146,6 +147,8 @@ cdef extern from "rbd/librbd.h" nogil:
                               int *is_protected)
     int rbd_snap_set(rbd_image_t image, const char *snapname)
     int rbd_flatten(rbd_image_t image)
+    int rbd_rebuild_object_map(rbd_image_t image, librbd_progress_fn_t cb,
+                               void *cbdata)
     ssize_t rbd_list_children(rbd_image_t image, char *pools, size_t *pools_len,
                               char *images, size_t *images_len)
     ssize_t rbd_list_lockers(rbd_image_t image, int *exclusive,
@@ -296,6 +299,9 @@ cdef make_ex(ret, msg):
 cdef rados_ioctx_t convert_ioctx(ioctx) except? NULL:
     return <rados_ioctx_t><uintptr_t>ioctx.io.value
 
+cdef int no_op_progress_callback(uint64_t offset, uint64_t total, void* ptr):
+    return 0
+
 def cstr(val, name, encoding="utf-8", opt=False):
     """
     Create a byte string from a Python string
@@ -1236,6 +1242,16 @@ written." % (self.name, ret, length))
         if ret < 0:
             raise make_ex(ret, "error flattening %s" % self.name)
 
+    def rebuild_object_map(self):
+        """
+        Rebuilds the object map for the image HEAD or currently set snapshot
+        """
+        cdef librbd_progress_fn_t prog_cb = &no_op_progress_callback
+        with nogil:
+            ret = rbd_rebuild_object_map(self.image, prog_cb, NULL)
+        if ret < 0:
+            raise make_ex(ret, "error rebuilding object map %s" % self.name)
+
     def list_children(self):
         """
         List children of the currently set snapshot (set via set_snap()).
diff --git a/src/rbd_fuse/rbd-fuse.cc b/src/rbd_fuse/rbd-fuse.cc
index 8abfe45..9e92441 100644
--- a/src/rbd_fuse/rbd-fuse.cc
+++ b/src/rbd_fuse/rbd-fuse.cc
@@ -18,6 +18,7 @@
 #include <unistd.h>
 #include <getopt.h>
 #include <assert.h>
+#include <string>
 
 #if defined(__FreeBSD__)
 #include <sys/param.h>
@@ -522,16 +523,59 @@ rbdfs_destroy(void *unused)
 	rados_shutdown(cluster);
 }
 
+int
+rbdfs_checkname(const char *checkname)
+{
+    const char *extra[] = {"@", "/"};
+    std::string strCheckName(checkname);
+    
+    if (strCheckName.empty())
+        return -EINVAL;
+
+    unsigned int sz = sizeof(extra) / sizeof(const char*);
+    for (unsigned int i = 0; i < sz; i++)
+    {
+        std::string ex(extra[i]);
+        if (std::string::npos != strCheckName.find(ex))
+            return -EINVAL;
+    }
+
+    return 0;
+}
+
 // return -errno on error.  fi->fh is not set until open time
 
 int
 rbdfs_create(const char *path, mode_t mode, struct fuse_file_info *fi)
 {
-	int r;
-	int order = imageorder;
+         int r;
+         int order = imageorder;
 
-	r = rbd_create2(ioctx, path+1, imagesize, imagefeatures, &order);
-	return r;
+         r = rbdfs_checkname(path+1);
+         if (r != 0)
+         {
+            return r;  
+         }
+
+         r = rbd_create2(ioctx, path+1, imagesize, imagefeatures, &order);
+         return r;
+}
+
+int
+rbdfs_rename(const char *path, const char *destname)
+{
+    int r;
+
+    r = rbdfs_checkname(destname+1);
+    if (r != 0)
+    {
+      return r;
+    }
+
+    if (strcmp(path, "/") == 0)
+        return -EINVAL;
+
+    return rbd_rename(ioctx, path+1, destname+1);
 }
 
 int
@@ -678,7 +722,7 @@ const static struct fuse_operations rbdfs_oper = {
   unlink:     rbdfs_unlink,
   rmdir:      0,
   symlink:    0,
-  rename:     0,
+  rename:     rbdfs_rename,
   link:       0,
   chmod:      0,
   chown:      0,
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index 5f34bc7..c9365fa 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -88,6 +88,8 @@ void _usage()
   cout << "  log list                   list log objects\n";
   cout << "  log show                   dump a log from specific object or (bucket + date\n";
   cout << "                             + bucket-id)\n";
+  cout << "                             (NOTE: required to specify formatting of date\n";
+  cout << "                             to \"YYYY-MM-DD-hh\")\n";
   cout << "  log rm                     remove log object\n";
   cout << "  usage show                 show usage (by user, date range)\n";
   cout << "  usage trim                 trim usage (by user, date range)\n";
@@ -696,10 +698,9 @@ static int read_decode_json(const string& infile, T& t)
     return ret;
   }
   JSONParser p;
-  ret = p.parse(bl.c_str(), bl.length());
-  if (ret < 0) {
+  if (!p.parse(bl.c_str(), bl.length())) {
     cout << "failed to parse JSON" << std::endl;
-    return ret;
+    return -EINVAL;
   }
 
   try {
@@ -721,10 +722,9 @@ static int read_decode_json(const string& infile, T& t, K *k)
     return ret;
   }
   JSONParser p;
-  ret = p.parse(bl.c_str(), bl.length());
-  if (ret < 0) {
+  if (!p.parse(bl.c_str(), bl.length())) {
     cout << "failed to parse JSON" << std::endl;
-    return ret;
+    return -EINVAL;
   }
 
   try {
@@ -1778,6 +1778,7 @@ int main(int argc, char **argv)
   bucket_op.set_object(object);
   bucket_op.set_check_objects(check_objects);
   bucket_op.set_delete_children(delete_child_objects);
+  bucket_op.set_fix_index(fix);
 
   // required to gather errors from operations
   std::string err_msg;
diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc
index f4a245f..248dc83 100644
--- a/src/rgw/rgw_bucket.cc
+++ b/src/rgw/rgw_bucket.cc
@@ -88,6 +88,7 @@ int rgw_read_user_buckets(RGWRados * store,
                           const rgw_user& user_id,
                           RGWUserBuckets& buckets,
                           const string& marker,
+                          const string& end_marker,
                           uint64_t max,
                           bool need_stats,
                           uint64_t default_amount)
@@ -111,7 +112,7 @@ int rgw_read_user_buckets(RGWRados * store,
   }
 
   do {
-    ret = store->cls_user_list_buckets(obj, m, max - total, entries, &m, &truncated);
+    ret = store->cls_user_list_buckets(obj, m, end_marker, max - total, entries, &m, &truncated);
     if (ret == -ENOENT)
       ret = 0;
 
@@ -367,7 +368,8 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id, boo
   size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk;
 
   do {
-    int ret = rgw_read_user_buckets(store, user_id, user_buckets, marker, max_entries, false);
+    int ret = rgw_read_user_buckets(store, user_id, user_buckets,
+                                    marker, string(), max_entries, false);
     if (ret < 0) {
       ldout(store->ctx(), 0) << "failed to read user buckets: " << cpp_strerror(-ret) << dendl;
       return;
@@ -1126,7 +1128,8 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
     bool done;
 
     do {
-      ret = rgw_read_user_buckets(store, user_id, buckets, marker, max_entries, false);
+      ret = rgw_read_user_buckets(store, user_id, buckets,
+                                  marker, string(), max_entries, false);
       if (ret < 0)
         return ret;
 
@@ -1157,9 +1160,10 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
     if (store->list_buckets_init(&handle) >= 0) {
       RGWObjEnt obj;
       while (store->list_buckets_next(obj, &handle) >= 0) {
-	formatter->dump_string("bucket", obj.key.name);
         if (show_stats)
           bucket_stats(store, user_id.tenant, obj.key.name, formatter);
+        else
+          formatter->dump_string("bucket", obj.key.name);
       }
     }
 
@@ -1605,7 +1609,11 @@ public:
   int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
           time_t mtime, JSONObj *obj, sync_type_t sync_type) {
     RGWBucketEntryPoint be, old_be;
-    decode_json_obj(be, obj);
+    try {
+      decode_json_obj(be, obj);
+    } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+    }
 
     time_t orig_mtime;
     map<string, bufferlist> attrs;
@@ -1756,7 +1764,11 @@ public:
   int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
           time_t mtime, JSONObj *obj, sync_type_t sync_type) {
     RGWBucketCompleteInfo bci, old_bci;
-    decode_json_obj(bci, obj);
+    try {
+      decode_json_obj(bci, obj);
+    } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+    }
 
     time_t orig_mtime;
     RGWObjectCtx obj_ctx(store);
diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h
index 9191fbe..a905010 100644
--- a/src/rgw/rgw_bucket.h
+++ b/src/rgw/rgw_bucket.h
@@ -119,6 +119,7 @@ extern int rgw_read_user_buckets(RGWRados *store,
                                  const rgw_user& user_id,
                                  RGWUserBuckets& buckets,
                                  const string& marker,
+                                 const string& end_marker,
                                  uint64_t max,
                                  bool need_stats,
                                  uint64_t default_amount = 1000);
@@ -375,7 +376,7 @@ public:
     }
 
     renew_thread = new ChangesRenewThread(cct, this);
-    renew_thread->create();
+    renew_thread->create("rgw_dt_lg_renew");
   }
 
   ~RGWDataChangesLog();
diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc
index 5c075f9..4919377 100644
--- a/src/rgw/rgw_civetweb.cc
+++ b/src/rgw/rgw_civetweb.cc
@@ -27,7 +27,8 @@ int RGWMongoose::write_data(const char *buf, int len)
   return r;
 }
 
-RGWMongoose::RGWMongoose(mg_connection *_conn, int _port) : conn(_conn), port(_port), header_done(false), sent_header(false), has_content_length(false),
+RGWMongoose::RGWMongoose(mg_connection *_conn, int _port) : conn(_conn), port(_port), status_num(0), header_done(false),
+                                                 sent_header(false), has_content_length(false),
                                                  explicit_keepalive(false), explicit_conn_close(false)
 {
 }
@@ -45,9 +46,16 @@ int RGWMongoose::complete_request()
 {
   if (!sent_header) {
     if (!has_content_length) {
+
       header_done = false; /* let's go back to writing the header */
 
-      if (0 && data.length() == 0) {
+      /*
+       * Status 204 should not include a content-length header
+       * RFC7230 says so
+       */
+      if (status_num == 204) {
+        has_content_length = true;
+      } else if (0 && data.length() == 0) {
         has_content_length = true;
         print("Transfer-Enconding: %s\r\n", "chunked");
         data.append("0\r\n\r\n", sizeof("0\r\n\r\n")-1);
@@ -75,6 +83,7 @@ void RGWMongoose::init_env(CephContext *cct)
 {
   env.init(cct);
   struct mg_request_info *info = mg_get_request_info(conn);
+
   if (!info)
     return;
 
@@ -114,7 +123,7 @@ void RGWMongoose::init_env(CephContext *cct)
       *dest = c;
     }
     *dest = '\0';
-    
+
     env.set(buf, header->value);
   }
 
@@ -136,21 +145,21 @@ void RGWMongoose::init_env(CephContext *cct)
   }
 }
 
-int RGWMongoose::send_status(const char *status, const char *status_name)
+int RGWMongoose::send_status(int status, const char *status_name)
 {
   char buf[128];
 
   if (!status_name)
     status_name = "";
 
-  snprintf(buf, sizeof(buf), "HTTP/1.1 %s %s\r\n", status, status_name);
+  snprintf(buf, sizeof(buf), "HTTP/1.1 %d %s\r\n", status, status_name);
 
   bufferlist bl;
   bl.append(buf);
   bl.append(header_data);
   header_data = bl;
 
-  int status_num = atoi(status);
+  status_num = status;
   mg_set_http_status(conn, status_num);
 
   return 0;
diff --git a/src/rgw/rgw_civetweb.h b/src/rgw/rgw_civetweb.h
index 1cee5c8..bf7d64a 100644
--- a/src/rgw/rgw_civetweb.h
+++ b/src/rgw/rgw_civetweb.h
@@ -19,6 +19,7 @@ class RGWMongoose : public RGWClientIO
   bufferlist data;
 
   int port;
+  int status_num;
 
   bool header_done;
   bool sent_header;
@@ -32,7 +33,7 @@ public:
   int write_data(const char *buf, int len);
   int read_data(char *buf, int len);
 
-  int send_status(const char *status, const char *status_name);
+  int send_status(int status, const char *status_name);
   int send_100_continue();
   int complete_header();
   int complete_request();
diff --git a/src/rgw/rgw_client_io.h b/src/rgw/rgw_client_io.h
index 1191d0c..46e6684 100644
--- a/src/rgw/rgw_client_io.h
+++ b/src/rgw/rgw_client_io.h
@@ -36,7 +36,7 @@ public:
   virtual void flush() = 0;
   int read(char *buf, int max, int *actual);
 
-  virtual int send_status(const char *status, const char *status_name) = 0;
+  virtual int send_status(int status, const char *status_name) = 0;
   virtual int send_100_continue() = 0;
   virtual int complete_header() = 0;
   virtual int complete_request() = 0;
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc
index 9e20fa3..dfd3105 100644
--- a/src/rgw/rgw_common.cc
+++ b/src/rgw/rgw_common.cc
@@ -1010,7 +1010,7 @@ int RGWUserCaps::get_cap(const string& cap, string& type, uint32_t *pperm)
   }
 
   if (!is_valid_cap_type(type))
-    return -EINVAL;
+    return -ERR_INVALID_CAP;
 
   string cap_perm;
   uint32_t perm = 0;
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h
index c40f0b4..5989352 100644
--- a/src/rgw/rgw_common.h
+++ b/src/rgw/rgw_common.h
@@ -156,6 +156,11 @@ using ceph::crypto::MD5;
 #define ERR_MALFORMED_XML        2029
 #define ERR_USER_EXIST           2030
 #define ERR_NOT_SLO_MANIFEST     2031
+#define ERR_EMAIL_EXIST          2032
+#define ERR_KEY_EXIST            2033
+#define ERR_INVALID_SECRET_KEY   2034
+#define ERR_INVALID_KEY_TYPE     2035
+#define ERR_INVALID_CAP          2036
 #define ERR_USER_SUSPENDED       2100
 #define ERR_INTERNAL_ERROR       2200
 #define ERR_NOT_IMPLEMENTED      2201
diff --git a/src/rgw/rgw_fcgi.cc b/src/rgw/rgw_fcgi.cc
index 0006834..bbc19d8 100644
--- a/src/rgw/rgw_fcgi.cc
+++ b/src/rgw/rgw_fcgi.cc
@@ -31,14 +31,15 @@ void RGWFCGX::init_env(CephContext *cct)
   env.init(cct, (char **)fcgx->envp);
 }
 
-int RGWFCGX::send_status(const char *status, const char *status_name)
+int RGWFCGX::send_status(int status, const char *status_name)
 {
-  return print("Status: %s %s\r\n", status, status_name);
+  status_num = status;
+  return print("Status: %d %s\r\n", status, status_name);
 }
 
 int RGWFCGX::send_100_continue()
 {
-  int r = send_status("100", "Continue");
+  int r = send_status(100, "Continue");
   if (r >= 0) {
     flush();
   }
@@ -47,6 +48,13 @@ int RGWFCGX::send_100_continue()
 
 int RGWFCGX::send_content_length(uint64_t len)
 {
+  /*
+   * Status 204 should not include a content-length header
+   * RFC7230 says so
+   */
+  if (status_num == 204)
+    return 0;
+
   char buf[21];
   snprintf(buf, sizeof(buf), "%" PRIu64, len);
   return print("Content-Length: %s\r\n", buf);
@@ -56,4 +64,3 @@ int RGWFCGX::complete_header()
 {
   return print("\r\n");
 }
-
diff --git a/src/rgw/rgw_fcgi.h b/src/rgw/rgw_fcgi.h
index 8fc96fc..88889b5 100644
--- a/src/rgw/rgw_fcgi.h
+++ b/src/rgw/rgw_fcgi.h
@@ -13,18 +13,21 @@ struct FCGX_Request;
 class RGWFCGX : public RGWClientIO
 {
   FCGX_Request *fcgx;
+
+  int status_num;
+
 protected:
   void init_env(CephContext *cct);
   int write_data(const char *buf, int len);
   int read_data(char *buf, int len);
 
-  int send_status(const char *status, const char *status_name);
+  int send_status(int status, const char *status_name);
   int send_100_continue();
   int complete_header();
   int complete_request() { return 0; }
   int send_content_length(uint64_t len);
 public:
-  RGWFCGX(FCGX_Request *_fcgx) : fcgx(_fcgx) {}
+  RGWFCGX(FCGX_Request *_fcgx) : fcgx(_fcgx), status_num(0) {}
   void flush();
 };
 
diff --git a/src/rgw/rgw_gc.cc b/src/rgw/rgw_gc.cc
index 3a949b6..05fcbe3 100644
--- a/src/rgw/rgw_gc.cc
+++ b/src/rgw/rgw_gc.cc
@@ -259,7 +259,7 @@ bool RGWGC::going_down()
 void RGWGC::start_processor()
 {
   worker = new GCWorker(cct, this);
-  worker->create();
+  worker->create("rgw_gc");
 }
 
 void RGWGC::stop_processor()
diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h
index 7750d13..fbe805f 100644
--- a/src/rgw/rgw_http_errors.h
+++ b/src/rgw/rgw_http_errors.h
@@ -51,6 +51,11 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = {
     { ETIMEDOUT, 408, "RequestTimeout" },
     { EEXIST, 409, "BucketAlreadyExists" },
     { ERR_USER_EXIST, 409, "UserAlreadyExists" },
+    { ERR_EMAIL_EXIST, 409, "EmailExists" },
+    { ERR_KEY_EXIST, 409, "KeyExists"},
+    { ERR_INVALID_SECRET_KEY, 400, "InvalidSecretKey"},
+    { ERR_INVALID_KEY_TYPE, 400, "InvalidKeyType"},
+    { ERR_INVALID_CAP, 400, "InvalidCapability"},
     { ENOTEMPTY, 409, "BucketNotEmpty" },
     { ERR_PRECONDITION_FAILED, 412, "PreconditionFailed" },
     { ERANGE, 416, "InvalidRange" },
diff --git a/src/rgw/rgw_loadgen.cc b/src/rgw/rgw_loadgen.cc
index 59b9462..14f63a1 100644
--- a/src/rgw/rgw_loadgen.cc
+++ b/src/rgw/rgw_loadgen.cc
@@ -92,7 +92,7 @@ void RGWLoadGenIO::init_env(CephContext *cct)
   env.set("SERVER_PORT", port_buf);
 }
 
-int RGWLoadGenIO::send_status(const char *status, const char *status_name)
+int RGWLoadGenIO::send_status(int status, const char *status_name)
 {
   return 0;
 }
diff --git a/src/rgw/rgw_loadgen.h b/src/rgw/rgw_loadgen.h
index 5a65ff4..e5636ed 100644
--- a/src/rgw/rgw_loadgen.h
+++ b/src/rgw/rgw_loadgen.h
@@ -34,7 +34,7 @@ public:
   int write_data(const char *buf, int len);
   int read_data(char *buf, int len);
 
-  int send_status(const char *status, const char *status_name);
+  int send_status(int status, const char *status_name);
   int send_100_continue();
   int complete_header();
   int complete_request();
diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc
index 2246b6a..a19b462 100644
--- a/src/rgw/rgw_main.cc
+++ b/src/rgw/rgw_main.cc
@@ -243,7 +243,7 @@ protected:
 
 public:
   RGWProcess(CephContext *cct, RGWProcessEnv *pe, int num_threads, RGWFrontendConfig *_conf)
-    : store(pe->store), olog(pe->olog), m_tp(cct, "RGWProcess::m_tp", num_threads),
+    : store(pe->store), olog(pe->olog), m_tp(cct, "RGWProcess::m_tp", "tp_rgw_process", num_threads),
       req_throttle(cct, "rgw_ops", num_threads * 2),
       rest(pe->rest),
       conf(_conf),
@@ -884,7 +884,7 @@ public:
   int run() {
     assert(pprocess); /* should have initialized by init() */
     thread = new RGWProcessControlThread(pprocess);
-    thread->create();
+    thread->create("rgw_frontend");
     return 0;
   }
 
@@ -1168,6 +1168,16 @@ int main(int argc, const char **argv)
   for (list<string>::iterator iter = frontends.begin(); iter != frontends.end(); ++iter) {
     string& f = *iter;
 
+    if (f.find("civetweb") != string::npos) {
+      if (f.find("port") != string::npos) {
+	// check for the most common ws problems
+	if ((f.find("port=") == string::npos) ||
+	    (f.find("port= ") != string::npos)) {
+	  derr << "WARNING: civetweb frontend config found unexpected spacing around 'port' (ensure civetweb port parameter has the form 'port=80' with no spaces before or after '=')" << dendl;
+	}
+      }
+    }
+
     RGWFrontendConfig *config = new RGWFrontendConfig(f);
     int r = config->init();
     if (r < 0) {
diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc
index cf4a0eb..80ed822 100644
--- a/src/rgw/rgw_metadata.cc
+++ b/src/rgw/rgw_metadata.cc
@@ -355,9 +355,13 @@ int RGWMetadataManager::put(string& metadata_key, bufferlist& bl,
 
   time_t mtime = 0;
 
-  JSONDecoder::decode_json("key", metadata_key, &parser);
-  JSONDecoder::decode_json("ver", *objv, &parser);
-  JSONDecoder::decode_json("mtime", mtime, &parser);
+  try {
+    JSONDecoder::decode_json("key", metadata_key, &parser);
+    JSONDecoder::decode_json("ver", *objv, &parser);
+    JSONDecoder::decode_json("mtime", mtime, &parser);
+  } catch (JSONDecoder::err& e) {
+    return -EINVAL;
+  }
 
   JSONObj *jo = parser.find_obj("data");
   if (!jo) {
diff --git a/src/rgw/rgw_object_expirer_core.cc b/src/rgw/rgw_object_expirer_core.cc
index 14957d7..56bb59f 100644
--- a/src/rgw/rgw_object_expirer_core.cc
+++ b/src/rgw/rgw_object_expirer_core.cc
@@ -218,7 +218,7 @@ bool RGWObjectExpirer::going_down()
 void RGWObjectExpirer::start_processor()
 {
   worker = new OEWorker(store->ctx(), this);
-  worker->create();
+  worker->create("rgw_obj_expirer");
 }
 
 void RGWObjectExpirer::stop_processor()
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index d1e8b71..e912a2e 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -1312,7 +1312,7 @@ void RGWListBuckets::execute()
     }
 
     ret = rgw_read_user_buckets(store, s->user.user_id, buckets,
-                                marker, read_count, should_get_stats(), 0);
+                                marker, end_marker, read_count, should_get_stats(), 0);
 
     if (ret < 0) {
       /* hmm.. something wrong here.. the user was authenticated, so it
@@ -1369,7 +1369,8 @@ void RGWStatAccount::execute()
   do {
     RGWUserBuckets buckets;
 
-    ret = rgw_read_user_buckets(store, s->user.user_id, buckets, marker, max_buckets, false);
+    ret = rgw_read_user_buckets(store, s->user.user_id, buckets,
+                                marker, string(), max_buckets, false);
     if (ret < 0) {
       /* hmm.. something wrong here.. the user was authenticated, so it
          should exist */
@@ -1571,7 +1572,8 @@ int RGWCreateBucket::verify_permission()
   if (s->user.max_buckets) {
     RGWUserBuckets buckets;
     string marker;
-    int ret = rgw_read_user_buckets(store, s->user.user_id, buckets, marker, s->user.max_buckets, false);
+    int ret = rgw_read_user_buckets(store, s->user.user_id, buckets,
+                                    marker, string(), s->user.max_buckets, false);
     if (ret < 0)
       return ret;
 
@@ -1599,10 +1601,9 @@ static int forward_request_to_master(struct req_state *s, obj_version *objv, RGW
     return ret;
 
   ldout(s->cct, 20) << "response: " << response.c_str() << dendl;
-  ret = jp->parse(response.c_str(), response.length());
-  if (ret < 0) {
+  if (!jp->parse(response.c_str(), response.length())) {
     ldout(s->cct, 0) << "failed parsing response from master region" << dendl;
-    return ret;
+    return -EINVAL;
   }
 
   return 0;
diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h
index 3c3d873..880c634 100644
--- a/src/rgw/rgw_op.h
+++ b/src/rgw/rgw_op.h
@@ -285,6 +285,7 @@ protected:
   int ret;
   bool sent_data;
   string marker;
+  string end_marker;
   int64_t limit;
   uint64_t limit_max;
   uint32_t buckets_count;
diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc
index 0bf34d8..f59e1f7 100644
--- a/src/rgw/rgw_orphan.cc
+++ b/src/rgw/rgw_orphan.cc
@@ -165,17 +165,13 @@ int RGWOrphanSearch::init(const string& job_name, RGWOrphanSearchInfo *info) {
     return r;
   }
 
-  uint64_t num_shards = (info->num_shards ? info->num_shards : DEFAULT_NUM_SHARDS);
   if (r == 0) {
-    if (num_shards != state.info.num_shards) {
-      return -EINVAL;
-    }
     search_info = state.info;
     search_stage = state.stage;
-  } else { /* r == -ENOENT */
+  } else if (info) { /* r == -ENOENT, initiate a new job if info was provided */ 
     search_info = *info;
     search_info.job_name = job_name;
-    search_info.num_shards = num_shards;
+    search_info.num_shards = (info->num_shards ? info->num_shards : DEFAULT_NUM_SHARDS);
     search_info.start_time = ceph_clock_now(store->ctx());
     search_stage = RGWOrphanSearchStage(ORPHAN_SEARCH_STAGE_INIT);
 
@@ -184,6 +180,9 @@ int RGWOrphanSearch::init(const string& job_name, RGWOrphanSearchInfo *info) {
       lderr(store->ctx()) << "ERROR: failed to write state ret=" << r << dendl;
       return r;
     }
+  } else {
+      lderr(store->ctx()) << "ERROR: job not found" << dendl;
+      return r;
   }
 
   index_objs_prefix = RGW_ORPHAN_INDEX_PREFIX + string(".");
diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc
index 03c152d..c300c44 100644
--- a/src/rgw/rgw_quota.cc
+++ b/src/rgw/rgw_quota.cc
@@ -516,9 +516,9 @@ public:
                                         rwlock("RGWUserStatsCache::rwlock") {
     if (quota_threads) {
       buckets_sync_thread = new BucketsSyncThread(store->ctx(), this);
-      buckets_sync_thread->create();
+      buckets_sync_thread->create("rgw_buck_st_syn");
       user_sync_thread = new UserSyncThread(store->ctx(), this);
-      user_sync_thread->create();
+      user_sync_thread->create("rgw_user_st_syn");
     } else {
       buckets_sync_thread = NULL;
       user_sync_thread = NULL;
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 3e38e9e..aa5b3b4 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -8767,9 +8767,12 @@ int RGWRados::update_user_bucket_stats(const string& user_id, rgw_bucket& bucket
 }
 
 int RGWRados::cls_user_list_buckets(rgw_obj& obj,
-                                    const string& in_marker, int max_entries,
+                                    const string& in_marker,
+                                    const string& end_marker,
+                                    const int max_entries,
                                     list<cls_user_bucket_entry>& entries,
-                                    string *out_marker, bool *truncated)
+                                    string * const out_marker,
+                                    bool * const truncated)
 {
   rgw_rados_ref ref;
   rgw_bucket bucket;
@@ -8781,7 +8784,7 @@ int RGWRados::cls_user_list_buckets(rgw_obj& obj,
   librados::ObjectReadOperation op;
   int rc;
 
-  cls_user_bucket_list(op, in_marker, max_entries, entries, out_marker, truncated, &rc);
+  cls_user_bucket_list(op, in_marker, end_marker, max_entries, entries, out_marker, truncated, &rc);
   bufferlist ibl;
   r = ref.ioctx.operate(ref.oid, &op, &ibl);
   if (r < 0)
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index 67adc60..f0f11b4 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -2182,9 +2182,12 @@ public:
   int cls_user_sync_bucket_stats(rgw_obj& user_obj, rgw_bucket& bucket);
   int update_user_bucket_stats(const string& user_id, rgw_bucket& bucket, RGWStorageStats& stats);
   int cls_user_list_buckets(rgw_obj& obj,
-                            const string& in_marker, int max_entries,
+                            const string& in_marker,
+                            const string& end_marker,
+                            int max_entries,
                             list<cls_user_bucket_entry>& entries,
-                            string *out_marker, bool *truncated);
+                            string *out_marker,
+                            bool *truncated);
   int cls_user_add_bucket(rgw_obj& obj, const cls_user_bucket_entry& entry);
   int cls_user_update_buckets(rgw_obj& obj, list<cls_user_bucket_entry>& entries, bool add);
   int cls_user_complete_stats_sync(rgw_obj& obj);
diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc
index c557bc5..d7f6b60 100644
--- a/src/rgw/rgw_rest.cc
+++ b/src/rgw/rgw_rest.cc
@@ -247,7 +247,7 @@ static bool rgw_find_host_in_domains(const string& host, string *domain, string
   return false;
 }
 
-static void dump_status(struct req_state *s, const char *status, const char *status_name)
+static void dump_status(struct req_state *s, int status, const char *status_name)
 {
   int r = s->cio->send_status(status, status_name);
   if (r < 0) {
@@ -326,16 +326,12 @@ void dump_errno(const struct rgw_err &err, string& out) {
 
 void dump_errno(struct req_state *s)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%d", s->err.http_ret);
-  dump_status(s, buf, http_status_names[s->err.http_ret]);
+  dump_status(s, s->err.http_ret, http_status_names[s->err.http_ret]);
 }
 
 void dump_errno(struct req_state *s, int http_ret)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), "%d", http_ret);
-  dump_status(s, buf, http_status_names[http_ret]);
+  dump_status(s, http_ret, http_status_names[http_ret]);
 }
 
 void dump_string_header(struct req_state *s, const char *name, const char *val)
diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h
index 9b49a1e..4ba3c96 100644
--- a/src/rgw/rgw_rest.h
+++ b/src/rgw/rgw_rest.h
@@ -53,9 +53,14 @@ int rgw_rest_get_json_input(CephContext *cct, req_state *s, T& out, int max_len,
     return -EINVAL;
   }
 
-  decode_json_obj(out, &parser);
-
   free(data);
+
+  try {
+      decode_json_obj(out, &parser);
+  } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+  }
+
   return 0;
 }
 
@@ -82,7 +87,11 @@ int rgw_rest_get_json_input_keep_data(CephContext *cct, req_state *s, T& out, in
     return -EINVAL;
   }
 
-  decode_json_obj(out, &parser);
+  try {
+      decode_json_obj(out, &parser);
+  } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+  }
 
   *pdata = data;
   return 0;
diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc
index 6fed37c..b170272 100644
--- a/src/rgw/rgw_rest_swift.cc
+++ b/src/rgw/rgw_rest_swift.cc
@@ -17,6 +17,7 @@
 int RGWListBuckets_ObjStore_SWIFT::get_params()
 {
   marker = s->info.args.get("marker");
+  end_marker = s->info.args.get("end_marker");
 
   string limit_str = s->info.args.get("limit");
   if (!limit_str.empty()) {
diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc
index 8d73602..b51d37f 100644
--- a/src/rgw/rgw_swift.cc
+++ b/src/rgw/rgw_swift.cc
@@ -716,7 +716,7 @@ void RGWSwift::init_keystone()
   keystone_token_cache = new RGWKeystoneTokenCache(cct, cct->_conf->rgw_keystone_token_cache_size);
 
   keystone_revoke_thread = new KeystoneRevokeThread(cct, this);
-  keystone_revoke_thread->create();
+  keystone_revoke_thread->create("rgw_swift_k_rev");
 }
 
 
diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc
index 5063cd0..81b96bb 100644
--- a/src/rgw/rgw_user.cc
+++ b/src/rgw/rgw_user.cc
@@ -55,7 +55,8 @@ int rgw_user_sync_all_stats(RGWRados *store, const rgw_user& user_id)
 
   do {
     RGWUserBuckets user_buckets;
-    ret = rgw_read_user_buckets(store, user_id, user_buckets, marker, max_entries, false);
+    ret = rgw_read_user_buckets(store, user_id, user_buckets,
+                                marker, string(), max_entries, false);
     if (ret < 0) {
       ldout(cct, 0) << "failed to read user buckets: ret=" << ret << dendl;
       return ret;
@@ -148,8 +149,6 @@ int rgw_store_user_info(RGWRados *store,
 
   RGWUID ui;
   ui.user_id = info.user_id;
-  // P3
-  ldout(store->ctx(), 0) << "DEBUG: rgw_store_user_info: user_id " << ui.user_id << dendl;
 
   bufferlist link_bl;
   ::encode(ui, link_bl);
@@ -413,7 +412,8 @@ int rgw_delete_user(RGWRados *store, RGWUserInfo& info, RGWObjVersionTracker& ob
 
   do {
     RGWUserBuckets user_buckets;
-    ret = rgw_read_user_buckets(store, info.user_id, user_buckets, marker, max_buckets, false);
+    ret = rgw_read_user_buckets(store, info.user_id, user_buckets,
+                                marker, string(), max_buckets, false);
     if (ret < 0)
       return ret;
 
@@ -850,7 +850,7 @@ int RGWAccessKeyPool::check_op(RGWUserAdminOpState& op_state,
   if (key_type == KEY_TYPE_S3 && !op_state.will_gen_access() && 
       op_state.get_access_key().empty()) {
     set_err_msg(err_msg, "empty access key");
-    return -EINVAL;
+    return -ERR_INVALID_ACCESS_KEY;
   }
 
   // don't check for secret key because we may be doing a removal
@@ -882,7 +882,7 @@ int RGWAccessKeyPool::generate_key(RGWUserAdminOpState& op_state, std::string *e
 
   if (op_state.has_existing_key()) {
     set_err_msg(err_msg, "cannot create existing key");
-    return -EEXIST;
+    return -ERR_KEY_EXIST;
   }
 
   if (!gen_access) {
@@ -894,13 +894,13 @@ int RGWAccessKeyPool::generate_key(RGWUserAdminOpState& op_state, std::string *e
     case KEY_TYPE_SWIFT:
       if (rgw_get_user_info_by_swift(store, id, duplicate_check) >= 0) {
         set_err_msg(err_msg, "existing swift key in RGW system:" + id);
-        return -EEXIST;
+        return -ERR_KEY_EXIST;
       }
       break;
     case KEY_TYPE_S3:
       if (rgw_get_user_info_by_access_key(store, id, duplicate_check) >= 0) {
         set_err_msg(err_msg, "existing S3 key in RGW system:" + id);
-        return -EEXIST;
+        return -ERR_KEY_EXIST;
       }
     }
   }
@@ -917,7 +917,7 @@ int RGWAccessKeyPool::generate_key(RGWUserAdminOpState& op_state, std::string *e
   if (!gen_secret) {
     if (op_state.get_secret_key().empty()) {
       set_err_msg(err_msg, "empty secret key");
-      return -EINVAL; 
+      return -ERR_INVALID_SECRET_KEY;
     }
   
     key = op_state.get_secret_key();
@@ -958,13 +958,13 @@ int RGWAccessKeyPool::generate_key(RGWUserAdminOpState& op_state, std::string *e
     id = op_state.build_default_swift_kid();
     if (id.empty()) {
       set_err_msg(err_msg, "empty swift access key");
-      return -EINVAL;
+      return -ERR_INVALID_ACCESS_KEY;
     }
 
     // check that the access key doesn't exist
     if (rgw_get_user_info_by_swift(store, id, duplicate_check) >= 0) {
       set_err_msg(err_msg, "cannot create existing swift key");
-      return -EEXIST;
+      return -ERR_KEY_EXIST;
     }
   }
 
@@ -1001,7 +1001,7 @@ int RGWAccessKeyPool::modify_key(RGWUserAdminOpState& op_state, std::string *err
     id = op_state.get_access_key();
     if (id.empty()) {
       set_err_msg(err_msg, "no access key specified");
-      return -EINVAL;
+      return -ERR_INVALID_ACCESS_KEY;
     }
     break;
   case KEY_TYPE_SWIFT:
@@ -1013,12 +1013,12 @@ int RGWAccessKeyPool::modify_key(RGWUserAdminOpState& op_state, std::string *err
     break;
   default:
     set_err_msg(err_msg, "invalid key type");
-    return -EINVAL;
+    return -ERR_INVALID_KEY_TYPE;
   }
 
   if (!op_state.has_existing_key()) {
     set_err_msg(err_msg, "key does not exist");
-    return -EINVAL;
+    return -ERR_INVALID_ACCESS_KEY;
   }
 
   key_pair.first = id;
@@ -1049,7 +1049,7 @@ int RGWAccessKeyPool::modify_key(RGWUserAdminOpState& op_state, std::string *err
 
   if (key.empty()) {
       set_err_msg(err_msg, "empty secret key");
-      return  -EINVAL;
+      return -ERR_INVALID_SECRET_KEY;
   }
 
   // update the access key with the new secret key
@@ -1139,7 +1139,7 @@ int RGWAccessKeyPool::execute_remove(RGWUserAdminOpState& op_state, std::string
 
   if (!op_state.has_existing_key()) {
     set_err_msg(err_msg, "unable to find access key");
-    return -EINVAL;
+    return -ERR_INVALID_ACCESS_KEY;
   }
 
   if (key_type == KEY_TYPE_S3) {
@@ -1149,13 +1149,13 @@ int RGWAccessKeyPool::execute_remove(RGWUserAdminOpState& op_state, std::string
   } else {
     keys_map = NULL;
     set_err_msg(err_msg, "invalid access key");
-    return -EINVAL;
+    return -ERR_INVALID_ACCESS_KEY;
   }
 
   kiter = keys_map->find(id);
   if (kiter == keys_map->end()) {
     set_err_msg(err_msg, "key not found");
-    return -EINVAL;
+    return -ERR_INVALID_ACCESS_KEY;
   }
 
   rgw_remove_key_index(store, kiter->second);
@@ -1196,6 +1196,63 @@ int RGWAccessKeyPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg
   return 0;
 }
 
+// remove all keys associated with a subuser
+int RGWAccessKeyPool::remove_subuser_keys(RGWUserAdminOpState& op_state,
+        std::string *err_msg, bool defer_user_update)
+{
+  int ret = 0;
+
+  if (!op_state.is_populated()) {
+    set_err_msg(err_msg, "user info was not populated");
+    return -EINVAL;
+  }
+
+  if (!op_state.has_subuser()) {
+    set_err_msg(err_msg, "no subuser specified");
+    return -EINVAL;
+  }
+
+  std::string swift_kid = op_state.build_default_swift_kid();
+  if (swift_kid.empty()) {
+    set_err_msg(err_msg, "empty swift access key");
+    return -EINVAL;
+  }
+
+  map<std::string, RGWAccessKey>::iterator kiter;
+  map<std::string, RGWAccessKey> *keys_map;
+
+  // a subuser can have at most one swift key
+  keys_map = swift_keys;
+  kiter = keys_map->find(swift_kid);
+  if (kiter != keys_map->end()) {
+    rgw_remove_key_index(store, kiter->second);
+    keys_map->erase(kiter);
+  }
+
+  // a subuser may have multiple s3 key pairs
+  std::string subuser_str = op_state.get_subuser();
+  keys_map = access_keys;
+  RGWUserInfo user_info = op_state.get_user_info();
+  map<std::string, RGWAccessKey>::iterator user_kiter = user_info.access_keys.begin();
+  for (; user_kiter != user_info.access_keys.end(); ++user_kiter) {
+    if (user_kiter->second.subuser == subuser_str) {
+      kiter = keys_map->find(user_kiter->first);
+      if (kiter != keys_map->end()) {
+        rgw_remove_key_index(store, kiter->second);
+        keys_map->erase(kiter);
+      }
+    }
+  }
+
+  if (!defer_user_update)
+    ret = user->update(op_state, err_msg);
+
+  if (ret < 0)
+    return ret;
+
+  return 0;
+}
+
 RGWSubUserPool::RGWSubUserPool(RGWUser *usr)
 {
   subusers_allowed = (usr != NULL);
@@ -1377,12 +1434,10 @@ int RGWSubUserPool::execute_remove(RGWUserAdminOpState& op_state,
     return -EINVAL;
   }
 
-  if (op_state.will_purge_keys()) {
-    // error would be non-existance so don't check
-    user->keys.remove(op_state, &subprocess_msg, true);
-  }
+  // always purge all associate keys
+  user->keys.remove_subuser_keys(op_state, &subprocess_msg, defer_user_update);
 
-  //remove the subuser from the user info
+  // remove the subuser from the user info
   subuser_map->erase(siter);
 
   // attempt to save the subuser
@@ -1521,7 +1576,7 @@ int RGWUserCapPool::init(RGWUserAdminOpState& op_state)
   caps = op_state.get_caps_obj();
   if (!caps) {
     caps_allowed = false;
-    return -EINVAL;
+    return -ERR_INVALID_CAP;
   }
 
   caps_allowed = true;
@@ -1551,7 +1606,7 @@ int RGWUserCapPool::add(RGWUserAdminOpState& op_state, std::string *err_msg, boo
 
   if (caps_str.empty()) {
     set_err_msg(err_msg, "empty user caps");
-    return -EINVAL;
+    return -ERR_INVALID_CAP;
   }
 
   int r = caps->add_from_string(caps_str);
@@ -1592,7 +1647,7 @@ int RGWUserCapPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg,
 
   if (caps_str.empty()) {
     set_err_msg(err_msg, "empty user caps");
-    return -EINVAL;
+    return -ERR_INVALID_CAP;
   }
 
   int r = caps->remove_from_string(caps_str);
@@ -1836,12 +1891,15 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
 
     if (op_state.found_by_email) {
       set_err_msg(err_msg, "email: " + user_email + " exists");
+      ret = -ERR_EMAIL_EXIST;
     } else if (op_state.found_by_key) {
       set_err_msg(err_msg, "duplicate key provided");
+      ret = -ERR_KEY_EXIST;
     } else {
       set_err_msg(err_msg, "user: " + op_state.user_id.to_str() + " exists");
+      ret = -EEXIST;
     }
-    return -EEXIST;
+    return ret;
   }
 
   // fail if the user_info has already been populated
@@ -1967,7 +2025,8 @@ int RGWUser::execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg)
   size_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk;
   do {
     RGWUserBuckets buckets;
-    ret = rgw_read_user_buckets(store, uid, buckets, marker, max_buckets, false);
+    ret = rgw_read_user_buckets(store, uid, buckets,
+                                marker, string(), max_buckets, false);
     if (ret < 0) {
       set_err_msg(err_msg, "unable to read user bucket info");
       return ret;
@@ -2066,7 +2125,7 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg)
       ret = rgw_get_user_info_by_email(store, op_email, duplicate_check);
       if (ret >= 0 && duplicate_check.user_id.compare(user_id) != 0) {
         set_err_msg(err_msg, "cannot add duplicate email");
-        return -EEXIST;
+        return -ERR_EMAIL_EXIST;
       }
     }
     user_info.user_email = op_email;
@@ -2116,7 +2175,8 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg)
     CephContext *cct = store->ctx();
     size_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk;
     do {
-      ret = rgw_read_user_buckets(store, user_id, buckets, marker, max_buckets, false);
+      ret = rgw_read_user_buckets(store, user_id, buckets,
+                                  marker, string(), max_buckets, false);
       if (ret < 0) {
         set_err_msg(err_msg, "could not get buckets for uid:  " + user_id.to_str());
         return ret;
@@ -2552,7 +2612,11 @@ public:
           time_t mtime, JSONObj *obj, sync_type_t sync_mode) {
     RGWUserCompleteInfo uci;
 
-    decode_json_obj(uci, obj);
+    try {
+      decode_json_obj(uci, obj);
+    } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+    }
 
     map<string, bufferlist> *pattrs = NULL;
     if (uci.has_attrs) {
@@ -2628,8 +2692,13 @@ public:
 
     int ret = store->list_raw_objects(store->zone.user_uid_pool, no_filter,
                                       max, info->ctx, unfiltered_keys, truncated);
-    if (ret < 0)
-      return ret;
+    if (ret < 0 && ret != -ENOENT)
+      return ret;		        
+    if (ret == -ENOENT) {
+      if (truncated)
+        *truncated = false;
+      return -ENOENT;
+    }
 
     // now filter out the buckets entries
     list<string>::iterator iter;
diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h
index 6e877fe..57d40fa 100644
--- a/src/rgw/rgw_user.h
+++ b/src/rgw/rgw_user.h
@@ -267,9 +267,8 @@ struct RGWUserAdminOpState {
       return;
 
     size_t pos = _subuser.find(":");
-
     if (pos != string::npos) {
-      user_id.id = _subuser.substr(0, pos);
+      user_id.from_str(_subuser.substr(0, pos));
       subuser = _subuser.substr(pos+1);
     } else {
       subuser = _subuser;
@@ -522,6 +521,7 @@ private:
   /* API Contract Fulfilment */
   int execute_add(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
   int execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
+  int remove_subuser_keys(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
 
   int add(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
   int remove(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save);
diff --git a/src/rocksdb/.travis.yml b/src/rocksdb/.travis.yml
index 804554c..b6fa63c 100644
--- a/src/rocksdb/.travis.yml
+++ b/src/rocksdb/.travis.yml
@@ -34,7 +34,7 @@ before_script:
 # as EnvPosixTest::AllocateTest expects within the Travis OpenVZ environment.
 script:
   - if [[ "${TRAVIS_OS_NAME}" == 'linux' ]]; then OPT=-DTRAVIS CLANG_FORMAT_DIFF=/tmp/clang-format-diff.py make format || true; fi
-  - OPT=-DTRAVIS V=1 make -j4 check && OPT=-DTRAVIS V=1 make clean jclean rocksdbjava jtest
+  - OPT=-DTRAVIS V=1 make -j4 check && OPT=-DTRAVIS V=1 make clean jclean rocksdbjava jtest && make clean && OPT="-DTRAVIS -DROCKSDB_LITE" V=1 make -j4 check
 
 notifications:
     email:
diff --git a/src/rocksdb/CMakeLists.txt b/src/rocksdb/CMakeLists.txt
index 446d481..3294408 100644
--- a/src/rocksdb/CMakeLists.txt
+++ b/src/rocksdb/CMakeLists.txt
@@ -14,10 +14,16 @@
 # 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries.
 #    See thirdparty.inc for more information.
 #        sample command: cmake -G "Visual Studio 12 Win64" -DGFLAGS=1 -DSNAPPY=1 -DJEMALLOC=1 ..
-# 4. Then build the project in debug mode (you may want to add /m:<N> flag to run msbuild in <N> parallel threads)
-#        msbuild ALL_BUILD.vcxproj
+#        OR for VS Studio 15 cmake -G "Visual Studio 14 Win64" -DGFLAGS=1 -DSNAPPY=1 -DJEMALLOC=1 ..
+# 4. Then build the project in debug mode (you may want to add /m[:<N>] flag to run msbuild in <N> parallel threads
+#                                          or simply /m ot use all avail cores)
+#        msbuild rocksdb.sln
+#
+#        rocksdb.sln build features exclusions of test only code in Release. If you build ALL_BUILD then everything
+#        will be attempted but test only code does not build in Release mode.
+#
 # 5. And release mode (/m[:<N>] is also supported)
-#        msbuild ALL_BUILD.vcxproj /p:Configuration=Release
+#        msbuild rocksdb.sln /p:Configuration=Release
 #
 
 cmake_minimum_required(VERSION 2.6)
@@ -31,7 +37,14 @@ string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" DATE ${DATE})
 string(REGEX REPLACE "(..):(.....).*" " \\1:\\2" TIME ${TIME})
 string(CONCAT GIT_DATE_TIME ${DATE} ${TIME})
 
-execute_process(COMMAND $ENV{COMSPEC} " /C git rev-parse HEAD 2>nil" OUTPUT_VARIABLE GIT_SHA)
+find_package(Git)
+
+if (GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
+    execute_process(COMMAND $ENV{COMSPEC} /C ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR} rev-parse HEAD OUTPUT_VARIABLE GIT_SHA)
+else()
+    set(GIT_SHA 0)
+endif()
+
 string(REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA ${GIT_SHA})
 
 set(BUILD_VERSION_CC ${CMAKE_CURRENT_SOURCE_DIR}/util/build_version.cc)
@@ -46,7 +59,8 @@ add_custom_command(OUTPUT ${BUILD_VERSION_CC}
 add_custom_target(GenerateBuildVersion DEPENDS ${BUILD_VERSION_CC})
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /nologo  /EHsc /GS /Gd /GR /GF /fp:precise /Zc:wchar_t /Zc:forScope /errorReport:queue")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC /d2Zi+ /W3 /WX /wd4018 /wd4100 /wd4101 /wd4127 /wd4189 /wd4200 /wd4244 /wd4267 /wd4296 /wd4305 /wd4307 /wd4309 /wd4512 /wd4701 /wd4702 /wd4800 /wd4804 /wd4996")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC /d2Zi+ /W3 /WX /wd4127 /wd4244 /wd4800 /wd4996")
 
 # Used to run CI build and tests so we can run faster
 set(OPTIMIZE_DEBUG_DEFAULT 0)        # Debug build is unoptimized by default use -DOPTDBG=1 to optimize
@@ -83,6 +97,7 @@ set(LIBS ${ROCKSDB_LIBS} ${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
 
 add_subdirectory(third-party/gtest-1.7.0/fused-src/gtest)
 
+# Main library source code
 set(SOURCES
         db/builder.cc
         db/c.cc
@@ -130,6 +145,9 @@ set(SOURCES
         db/write_batch_base.cc
         db/write_controller.cc
         db/write_thread.cc
+        memtable/hash_cuckoo_rep.cc
+        memtable/hash_linklist_rep.cc
+        memtable/hash_skiplist_rep.cc
         port/stack_trace.cc
         port/win/env_win.cc
         port/win/port_win.cc
@@ -163,6 +181,7 @@ set(SOURCES
         table/plain_table_reader.cc
         table/table_properties.cc
         table/two_level_iterator.cc
+        tools/sst_dump_tool.cc
         tools/dump/db_dump_tool.cc
         util/arena.cc
         util/auto_roll_logger.cc
@@ -175,7 +194,6 @@ set(SOURCES
         util/crc32c.cc
         util/db_info_dumper.cc
         util/delete_scheduler_impl.cc
-        util/db_test_util.cc
         util/dynamic_bloom.cc
         util/env.cc
         util/env_hdfs.cc
@@ -184,14 +202,11 @@ set(SOURCES
         util/file_reader_writer.cc
         util/filter_policy.cc
         util/hash.cc
-        util/hash_cuckoo_rep.cc
-        util/hash_linklist_rep.cc
-        util/hash_skiplist_rep.cc
         util/histogram.cc
         util/instrumented_mutex.cc
         util/iostats_context.cc
-        util/ldb_cmd.cc
-        util/ldb_tool.cc
+        tools/ldb_cmd.cc
+        tools/ldb_tool.cc
         util/logging.cc
         util/log_buffer.cc
         util/memenv.cc
@@ -202,12 +217,13 @@ set(SOURCES
         util/options_builder.cc
         util/options_helper.cc
         util/options_parser.cc
+        util/options_sanity_check.cc
         util/perf_context.cc
         util/perf_level.cc
+        util/random.cc
         util/rate_limiter.cc
         util/skiplistrep.cc
         util/slice.cc
-        util/sst_dump_tool.cc
         util/statistics.cc
         util/status.cc
         util/status_message.cc
@@ -218,7 +234,6 @@ set(SOURCES
         util/thread_local.cc
         util/thread_status_impl.cc
         util/thread_status_updater.cc
-        util/thread_status_updater_debug.cc
         util/thread_status_util.cc
         util/thread_status_util_debug.cc
         util/vectorrep.cc
@@ -229,13 +244,16 @@ set(SOURCES
         utilities/document/document_db.cc
         utilities/document/json_document.cc
         utilities/document/json_document_builder.cc
+	utilities/env_mirror.cc
         utilities/flashcache/flashcache.cc
         utilities/geodb/geodb_impl.cc
         utilities/leveldb_options/leveldb_options.cc
+        utilities/memory/memory_util.cc
         utilities/merge_operators/string_append/stringappend.cc
         utilities/merge_operators/string_append/stringappend2.cc
         utilities/merge_operators/put.cc
         utilities/merge_operators/uint64add.cc
+        utilities/options/options_util.cc
         utilities/redis/redis_lists.cc
         utilities/spatialdb/spatial_db.cc
         utilities/table_properties_collectors/compact_on_deletion_collector.cc
@@ -252,6 +270,13 @@ set(SOURCES
         utilities/write_batch_with_index/write_batch_with_index_internal.cc
 )
 
+# For test util library that is build only in DEBUG mode
+# and linked to tests. Add test only code that is not #ifdefed for Release here.
+set(TESTUTIL_SOURCE
+    db/db_test_util.cc
+    util/thread_status_updater_debug.cc
+)
+
 add_library(rocksdblib${ARTIFACT_SUFFIX} ${SOURCES})
 set_target_properties(rocksdblib${ARTIFACT_SUFFIX} PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/rocksdblib${ARTIFACT_SUFFIX}.pdb")
 add_dependencies(rocksdblib${ARTIFACT_SUFFIX} GenerateBuildVersion)
@@ -266,6 +291,7 @@ set(APPS
         db/memtablerep_bench.cc
         table/table_reader_bench.cc
         tools/db_stress.cc
+        tools/write_stress.cc
         tools/db_repl_stress.cc
         tools/sst_dump.cc
         tools/dump/rocksdb_dump.cc
@@ -278,6 +304,7 @@ set(C_TESTS db/c_test.c)
 set(TESTS
         db/column_family_test.cc
         db/compact_files_test.cc
+        db/compaction_iterator_test.cc
         db/compaction_job_test.cc
         db/compaction_job_stats_test.cc
         db/compaction_picker_test.cc
@@ -294,17 +321,21 @@ set(TESTS
         db/db_universal_compaction_test.cc
         db/db_wal_test.cc
         db/db_tailing_iter_test.cc
+        db/db_table_properties_test.cc
         db/dbformat_test.cc
         db/deletefile_test.cc
         db/fault_injection_test.cc
         db/file_indexer_test.cc
         db/filename_test.cc
         db/flush_job_test.cc
+        db/inlineskiplist_test.cc
         db/listener_test.cc
         db/log_test.cc
+        db/manual_compaction_test.cc
         db/memtable_list_test.cc
         db/merge_test.cc
         db/merge_helper_test.cc
+        db/options_file_test.cc
         db/perf_context_test.cc
         db/plain_table_db_test.cc
         db/prefix_test.cc
@@ -326,7 +357,9 @@ set(TESTS
         table/merger_test.cc
         table/table_test.cc
         tools/db_sanity_test.cc
+        tools/ldb_cmd_test.cc
         tools/reduce_levels_test.cc
+        tools/sst_dump_test.cc
         util/arena_test.cc
         util/autovector_test.cc
         util/auto_roll_logger_test.cc
@@ -334,6 +367,7 @@ set(TESTS
         util/cache_test.cc
         util/coding_test.cc
         util/crc32c_test.cc
+        util/delete_scheduler_test.cc
         util/dynamic_bloom_test.cc
         util/env_test.cc
         util/event_logger_test.cc
@@ -341,14 +375,11 @@ set(TESTS
         util/file_reader_writer_test.cc
         util/heap_test.cc
         util/histogram_test.cc
-        util/ldb_cmd_test.cc
-        util/manual_compaction_test.cc
         util/memenv_test.cc
         util/mock_env_test.cc
         util/options_test.cc
         util/rate_limiter_test.cc
         util/slice_transform_test.cc
-        util/sst_dump_test.cc
         util/thread_list_test.cc
         util/thread_local_test.cc
         utilities/backupable/backupable_db_test.cc
@@ -356,7 +387,9 @@ set(TESTS
         utilities/document/document_db_test.cc
         utilities/document/json_document_test.cc
         utilities/geodb/geodb_test.cc
+        utilities/memory/memory_test.cc
         utilities/merge_operators/string_append/stringappend_test.cc
+        utilities/options/options_util_test.cc
         utilities/redis/redis_lists_test.cc
         utilities/spatialdb/spatial_db_test.cc
         utilities/table_properties_collectors/compact_on_deletion_collector_test.cc
@@ -366,7 +399,7 @@ set(TESTS
         utilities/write_batch_with_index/write_batch_with_index_test.cc
 )
 
-set(EXES ${APPS} ${TESTS})
+set(EXES ${APPS})
 
 foreach(sourcefile ${EXES})
     string(REPLACE ".cc" "" exename ${sourcefile})
@@ -375,12 +408,42 @@ foreach(sourcefile ${EXES})
     target_link_libraries(${exename}${ARTIFACT_SUFFIX} ${LIBS})
 endforeach(sourcefile ${EXES})
 
+# test utilities are only build in debug
+set(TESTUTILLIB testutillib${ARTIFACT_SUFFIX})
+add_library(${TESTUTILLIB} STATIC ${TESTUTIL_SOURCE})
+set_target_properties(${TESTUTILLIB} PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/testutillib${ARTIFACT_SUFFIX}.pdb")
+set_target_properties(${TESTUTILLIB}
+      PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
+      EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
+      EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
+      )
+
+# Tests are excluded from Release builds
+set(TEST_EXES ${TESTS})
+
+foreach(sourcefile ${TEST_EXES})
+    string(REPLACE ".cc" "" exename ${sourcefile})
+    string(REGEX REPLACE "^((.+)/)+" "" exename ${exename})
+    add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile})
+    set_target_properties(${exename}${ARTIFACT_SUFFIX}
+      PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
+      EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
+      EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
+      )
+    target_link_libraries(${exename}${ARTIFACT_SUFFIX} ${LIBS} testutillib${ARTIFACT_SUFFIX})
+endforeach(sourcefile ${TEST_EXES})
+
 # C executables must link to a shared object
-set(C_EXES ${C_TESTS})
+set(C_TEST_EXES ${C_TESTS})
 
-foreach(sourcefile ${C_EXES})
+foreach(sourcefile ${C_TEST_EXES})
     string(REPLACE ".c" "" exename ${sourcefile})
     string(REGEX REPLACE "^((.+)/)+" "" exename ${exename})
     add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile})
-    target_link_libraries(${exename}${ARTIFACT_SUFFIX} rocksdb${ARTIFACT_SUFFIX})
-endforeach(sourcefile ${C_TESTS})
+    set_target_properties(${exename}${ARTIFACT_SUFFIX}
+      PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
+      EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
+      EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
+      )
+    target_link_libraries(${exename}${ARTIFACT_SUFFIX} rocksdb${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX})
+endforeach(sourcefile ${C_TEST_EXES})
diff --git a/src/rocksdb/HISTORY.md b/src/rocksdb/HISTORY.md
index 7b64daf..fee65c8 100644
--- a/src/rocksdb/HISTORY.md
+++ b/src/rocksdb/HISTORY.md
@@ -1,5 +1,33 @@
 # Rocksdb Change Log
 
+## Unreleased
+### Public API Changes
+* Change names in CompactionPri and add a new one.
+* Deprecate options.soft_rate_limit and add options.soft_pending_compaction_bytes_limit.
+
+## 4.3.0 (12/8/2015)
+### New Features
+* CompactionFilter has new member function called IgnoreSnapshots which allows CompactionFilter to be called even if there are snapshots later than the key.
+* RocksDB will now persist options under the same directory as the RocksDB database on successful DB::Open, CreateColumnFamily, DropColumnFamily, and SetOptions.
+* Introduce LoadLatestOptions() in rocksdb/utilities/options_util.h.  This function can construct the latest DBOptions / ColumnFamilyOptions used by the specified RocksDB intance.
+* Introduce CheckOptionsCompatibility() in rocksdb/utilities/options_util.h.  This function checks whether the input set of options is able to open the specified DB successfully.
+
+### Public API Changes
+* When options.db_write_buffer_size triggers, only the column family with the largest column family size will be flushed, not all the column families.
+
+## 4.2.0 (11/9/2015)
+### New Features
+* Introduce CreateLoggerFromOptions(), this function create a Logger for provided DBOptions. 
+* Add GetAggregatedIntProperty(), which returns the sum of the GetIntProperty of all the column families. 
+* Add MemoryUtil in rocksdb/utilities/memory.h.  It currently offers a way to get the memory usage by type from a list rocksdb instances.
+
+### Public API Changes
+* CompactionFilter::Context includes information of Column Family ID
+* The need-compaction hint given by TablePropertiesCollector::NeedCompact() will be persistent and recoverable after DB recovery. This introduces a breaking format change. If you use this experimental feature, including NewCompactOnDeletionCollectorFactory() in the new version, you may not be able to directly downgrade the DB back to version 4.0 or lower.
+* TablePropertiesCollectorFactory::CreateTablePropertiesCollector() now takes an option Context, containing the information of column family ID for the file being written.
+* Remove DefaultCompactionFilterFactory.
+
+
 ## 4.1.0 (10/8/2015)
 ### New Features
 * Added single delete operation as a more efficient way to delete keys that have not been overwritten.
@@ -187,7 +215,7 @@
 * Support Multiple DB paths in universal style compactions
 * Add feature of storing plain table index and bloom filter in SST file.
 * CompactRange() will never output compacted files to level 0. This used to be the case when all the compaction input files were at level 0.
-* Added iterate_upper_bound to define the extent upto which the forward iterator will return entries. This will prevent iterating over delete markers and overwritten entries for edge cases where you want to break out the iterator anyways. This may improve perfomance in case there are a large number of delete markers or overwritten entries.
+* Added iterate_upper_bound to define the extent upto which the forward iterator will return entries. This will prevent iterating over delete markers and overwritten entries for edge cases where you want to break out the iterator anyways. This may improve performance in case there are a large number of delete markers or overwritten entries.
 
 ### Public API changes
 * DBOptions.db_paths now is a vector of a DBPath structure which indicates both of path and target size
diff --git a/src/rocksdb/INSTALL.md b/src/rocksdb/INSTALL.md
index 50b27c8..bff7515 100644
--- a/src/rocksdb/INSTALL.md
+++ b/src/rocksdb/INSTALL.md
@@ -1,19 +1,24 @@
 ## Compilation
 
+**Important**: If you plan to run RocksDB in production, don't compile using default 
+`make` or `make all`. That will compile RocksDB in debug mode, which is much slower
+than release mode.
+
 RocksDB's library should be able to compile without any dependency installed,
 although we recommend installing some compression libraries (see below).
 We do depend on newer gcc/clang with C++11 support.
 
 There are few options when compiling RocksDB:
 
-* [recommended] `make static_lib` will compile librocksdb.a, RocksDB static library.
+* [recommended] `make static_lib` will compile librocksdb.a, RocksDB static library. Compiles static library in release mode.
 
-* `make shared_lib` will compile librocksdb.so, RocksDB shared library.
+* `make shared_lib` will compile librocksdb.so, RocksDB shared library. Compiles shared library in release mode.
 
-* `make check` will compile and run all the unit tests
+* `make check` will compile and run all the unit tests. `make check` will compile RocksDB in debug mode.
 
 * `make all` will compile our static library, and all our tools and unit tests. Our tools
-depend on gflags. You will need to have gflags installed to run `make all`.
+depend on gflags. You will need to have gflags installed to run `make all`. This will compile RocksDB in debug mode. Don't
+use binaries compiled by `make all` in production.
 
 * By default the binary we produce is optimized for the platform you're compiling on
 (-march=native). If you want to build a portable binary, add 'PORTABLE=1' before
@@ -82,4 +87,5 @@ your make commands, like this: `PORTABLE=1 make static_lib`
   * Run: `TARGET_OS=IOS make static_lib`. When building the project which uses rocksdb iOS library, make sure to define two important pre-processing macros: `ROCKSDB_LITE` and `IOS_CROSS_COMPILE`.
 
 * **Windows**:
+  * For building with MS Visual Studio 13 you will need Update 4 installed.
   * Read and follow the instructions at CMakeLists.txt
diff --git a/src/rocksdb/Makefile b/src/rocksdb/Makefile
index 009f467..c64ea36 100644
--- a/src/rocksdb/Makefile
+++ b/src/rocksdb/Makefile
@@ -33,12 +33,22 @@ quoted_perl_command = $(subst ','\'',$(perl_command))
 # with debug level 0. To compile with level 0, run `make shared_lib`,
 # `make install-shared`, `make static_lib`, `make install-static` or
 # `make install`
-DEBUG_LEVEL=1
+
+# Set the default DEBUG_LEVEL to 1
+DEBUG_LEVEL?=1
 
 ifeq ($(MAKECMDGOALS),dbg)
 	DEBUG_LEVEL=2
 endif
 
+ifeq ($(MAKECMDGOALS),clean)
+	DEBUG_LEVEL=0
+endif
+
+ifeq ($(MAKECMDGOALS),release)
+	DEBUG_LEVEL=0
+endif
+
 ifeq ($(MAKECMDGOALS),shared_lib)
 	DEBUG_LEVEL=0
 endif
@@ -63,6 +73,14 @@ ifeq ($(MAKECMDGOALS),rocksdbjavastatic)
 	DEBUG_LEVEL=0
 endif
 
+ifeq ($(MAKECMDGOALS),rocksdbjavastaticrelease)
+	DEBUG_LEVEL=0
+endif
+
+ifeq ($(MAKECMDGOALS),rocksdbjavastaticpublish)
+	DEBUG_LEVEL=0
+endif
+
 # compile with -O2 if debug level is not 2
 ifneq ($(DEBUG_LEVEL), 2)
 OPT += -O2 -fno-omit-frame-pointer
@@ -76,6 +94,8 @@ endif
 ifeq ($(DEBUG_LEVEL),0)
 OPT += -DNDEBUG
 DISABLE_WARNING_AS_ERROR=1
+else
+$(warning Warning: Compiling in debug mode. Don't use the resulting binary in production)
 endif
 
 #-----------------------------------------------
@@ -228,6 +248,7 @@ TESTS = \
 	db_tailing_iter_test \
 	db_universal_compaction_test \
 	db_wal_test \
+	db_table_properties_test \
 	block_hash_index_test \
 	autovector_test \
 	column_family_test \
@@ -253,14 +274,17 @@ TESTS = \
 	block_based_filter_block_test \
 	full_filter_block_test \
 	histogram_test \
+	inlineskiplist_test \
 	log_test \
 	manual_compaction_test \
 	memenv_test \
 	mock_env_test \
 	memtable_list_test \
 	merge_helper_test \
+	memory_test \
 	merge_test \
 	merger_test \
+	options_file_test \
 	redis_test \
 	reduce_levels_test \
 	plain_table_db_test \
@@ -288,6 +312,7 @@ TESTS = \
 	rate_limiter_test \
 	delete_scheduler_test \
 	options_test \
+	options_util_test \
 	event_logger_test \
 	cuckoo_table_builder_test \
 	cuckoo_table_reader_test \
@@ -315,17 +340,23 @@ TOOLS = \
 	sst_dump \
 	db_sanity_test \
 	db_stress \
+	write_stress \
 	ldb \
 	db_repl_stress \
 	rocksdb_dump \
 	rocksdb_undump
 
+# TODO: add back forward_iterator_bench, after making it build in all environemnts.
 BENCHMARKS = db_bench table_reader_bench cache_bench memtablerep_bench
 
-# The library name is configurable since we are maintaining libraries of both
-# debug/release mode.
+# if user didn't config LIBNAME, set the default
 ifeq ($(LIBNAME),)
+# we should only run rocksdb in production with DEBUG_LEVEL 0
+ifeq ($(DEBUG_LEVEL),0)
         LIBNAME=librocksdb
+else
+        LIBNAME=librocksdb_debug
+endif
 endif
 LIBRARY = ${LIBNAME}.a
 
@@ -371,7 +402,7 @@ $(SHARED3): $(SHARED4)
 endif
 
 $(SHARED4):
-	$(CXX) $(PLATFORM_SHARED_LDFLAGS)$(SHARED3) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(LIB_SOURCES) \
+	$(CXX) $(PLATFORM_SHARED_LDFLAGS)$(SHARED3) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(LIB_SOURCES) $(TOOL_SOURCES) \
 		$(LDFLAGS) -o $@
 
 endif  # PLATFORM_SHARED_EXT
@@ -395,7 +426,7 @@ dbg: $(LIBRARY) $(BENCHMARKS) tools $(TESTS)
 # creates static library and programs
 release:
 	$(MAKE) clean
-	OPT="-DNDEBUG -O2" $(MAKE) static_lib tools db_bench
+	DEBUG_LEVEL=0 $(MAKE) static_lib tools db_bench
 
 coverage:
 	$(MAKE) clean
@@ -544,8 +575,10 @@ check: all
 	      echo "===== Running $$t"; ./$$t || exit 1; done;          \
 	fi
 	rm -rf $(TMPD)
+ifeq ($(filter -DROCKSDB_LITE,$(OPT)),)
 	python tools/ldb_test.py
 	sh tools/rocksdb_dump_test.sh
+endif
 
 check_some: $(SUBSET) ldb_tests
 	for t in $(SUBSET); do echo "===== Running $$t"; ./$$t || exit 1; done
@@ -557,12 +590,12 @@ ldb_tests: ldb
 crash_test: whitebox_crash_test blackbox_crash_test
 
 blackbox_crash_test: db_stress
-	python -u tools/db_crashtest.py -s
-	python -u tools/db_crashtest.py
+	python -u tools/db_crashtest.py --simple blackbox 
+	python -u tools/db_crashtest.py blackbox
 
 whitebox_crash_test: db_stress
-	python -u tools/db_crashtest2.py -s
-	python -u tools/db_crashtest2.py
+	python -u tools/db_crashtest.py --simple whitebox
+	python -u tools/db_crashtest.py whitebox
 
 asan_check:
 	$(MAKE) clean
@@ -575,7 +608,7 @@ asan_crash_test:
 	$(MAKE) clean
 
 valgrind_check: $(TESTS)
-	for t in $(filter-out skiplist_test,$(TESTS)); do \
+	for t in $(filter-out %skiplist_test,$(TESTS)); do \
 		$(VALGRIND_VER) $(VALGRIND_OPTS) ./$$t; \
 		ret_code=$$?; \
 		if [ $$ret_code -ne 0 ]; then \
@@ -603,7 +636,7 @@ unity.a: unity.o
 	$(AM_V_at)$(AR) $(ARFLAGS) $@ unity.o
 
 # try compiling db_test with unity
-unity_test: db/db_test.o util/db_test_util.o $(TESTHARNESS) unity.a
+unity_test: db/db_test.o db/db_test_util.o $(TESTHARNESS) unity.a
 	$(AM_LINK)
 	./unity_test
 
@@ -649,6 +682,9 @@ block_hash_index_test: table/block_hash_index_test.o $(LIBOBJECTS) $(TESTHARNESS
 db_stress: tools/db_stress.o $(LIBOBJECTS) $(TESTUTIL)
 	$(AM_LINK)
 
+write_stress: tools/write_stress.o $(LIBOBJECTS) $(TESTUTIL)
+	$(AM_LINK)
+
 db_sanity_test: tools/db_sanity_test.o $(LIBOBJECTS) $(TESTUTIL)
 	$(AM_LINK)
 
@@ -703,34 +739,37 @@ crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
 slice_transform_test: util/slice_transform_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_test: db/db_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_test: db/db_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_log_iter_test: db/db_log_iter_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_log_iter_test: db/db_log_iter_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_compaction_filter_test: db/db_compaction_filter_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_compaction_filter_test: db/db_compaction_filter_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_compaction_test: db/db_compaction_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_compaction_test: db/db_compaction_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_dynamic_level_test: db/db_dynamic_level_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_dynamic_level_test: db/db_dynamic_level_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_inplace_update_test: db/db_inplace_update_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_inplace_update_test: db/db_inplace_update_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_tailing_iter_test: db/db_tailing_iter_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_tailing_iter_test: db/db_tailing_iter_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
 db_iter_test: db/db_iter_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_universal_compaction_test: db/db_universal_compaction_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_universal_compaction_test: db/db_universal_compaction_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-db_wal_test: db/db_wal_test.o util/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+db_wal_test: db/db_wal_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
+	$(AM_LINK)
+
+db_table_properties_test: db/db_table_properties_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
 log_write_bench: util/log_write_bench.o $(LIBOBJECTS) $(TESTHARNESS)
@@ -766,6 +805,9 @@ json_document_test: utilities/document/json_document_test.o $(LIBOBJECTS) $(TEST
 spatial_db_test: utilities/spatialdb/spatial_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
+env_mirror_test: utilities/env_mirror_test.o $(LIBOBJECTS) $(TESTHARNESS)
+	$(AM_LINK)
+
 ttl_test: utilities/ttl/ttl_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
@@ -826,6 +868,9 @@ table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
 block_test: table/block_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
+inlineskiplist_test: db/inlineskiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
+	$(AM_LINK)
+
 skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
@@ -856,12 +901,18 @@ write_controller_test: db/write_controller_test.o $(LIBOBJECTS) $(TESTHARNESS)
 merge_helper_test: db/merge_helper_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
+memory_test: utilities/memory/memory_test.o $(LIBOBJECTS) $(TESTHARNESS)
+	$(AM_LINK)
+
 merge_test: db/merge_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
 merger_test: table/merger_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
+options_file_test: db/options_file_test.o $(LIBOBJECTS) $(TESTHARNESS)
+	$(AM_LINK)
+
 deletefile_test: db/deletefile_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
@@ -895,10 +946,13 @@ compact_files_test: db/compact_files_test.o $(LIBOBJECTS) $(TESTHARNESS)
 options_test: util/options_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
+options_util_test: utilities/options/options_util_test.o $(LIBOBJECTS) $(TESTHARNESS)
+	$(AM_LINK)
+
 event_logger_test: util/event_logger_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-sst_dump_test: util/sst_dump_test.o $(LIBOBJECTS) $(TESTHARNESS)
+sst_dump_test: tools/sst_dump_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
 memenv_test : util/memenv_test.o $(LIBOBJECTS) $(TESTHARNESS)
@@ -910,7 +964,7 @@ optimistic_transaction_test: utilities/transactions/optimistic_transaction_test.
 mock_env_test : util/mock_env_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
-manual_compaction_test: util/manual_compaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
+manual_compaction_test: db/manual_compaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
 filelock_test: util/filelock_test.o $(LIBOBJECTS) $(TESTHARNESS)
@@ -934,7 +988,7 @@ transaction_test: utilities/transactions/transaction_test.o $(LIBOBJECTS) $(TEST
 sst_dump: tools/sst_dump.o $(LIBOBJECTS)
 	$(AM_LINK)
 
-ldb_cmd_test: util/ldb_cmd_test.o $(LIBOBJECTS) $(TESTHARNESS)
+ldb_cmd_test: tools/ldb_cmd_test.o $(LIBOBJECTS) $(TESTHARNESS)
 	$(AM_LINK)
 
 ldb: tools/ldb.o $(LIBOBJECTS)
@@ -1029,20 +1083,23 @@ liblz4.a:
 	   cd lz4-r127/lib && make CFLAGS='-fPIC' all
 	   cp lz4-r127/lib/liblz4.a .
 
-# A version of each $(LIBOBJECTS) compiled with -fPIC
-java_libobjects = $(patsubst %,jl/%,$(LIBOBJECTS))
-CLEAN_FILES += jl
+# A version of each $(LIBOBJECTS) compiled with -fPIC and a fixed set of static compression libraries
+java_static_libobjects = $(patsubst %,jls/%,$(LIBOBJECTS))
+CLEAN_FILES += jls
 
-$(java_libobjects): jl/%.o: %.cc
-	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@ $(COVERAGEFLAGS)
+JAVA_STATIC_FLAGS = -DZLIB -DBZIP2 -DSNAPPY -DLZ4
+JAVA_STATIC_INCLUDES = -I./zlib-1.2.8 -I./bzip2-1.0.6 -I./snappy-1.1.1 -I./lz4-r127/lib
 
-rocksdbjavastatic: $(java_libobjects) libz.a libbz2.a libsnappy.a liblz4.a
+$(java_static_libobjects): jls/%.o: %.cc libz.a libbz2.a libsnappy.a liblz4.a
+	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) $(JAVA_STATIC_FLAGS) $(JAVA_STATIC_INCLUDES) -fPIC -c $< -o $@ $(COVERAGEFLAGS)
+
+rocksdbjavastatic: $(java_static_libobjects)
 	cd java;$(MAKE) javalib;
 	rm -f ./java/target/$(ROCKSDBJNILIB)
 	$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC \
 	  -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) \
-	  $(java_libobjects) $(COVERAGEFLAGS) \
-	  libz.a libbz2.a libsnappy.a liblz4.a $(LDFLAGS)
+	  $(java_static_libobjects) $(COVERAGEFLAGS) \
+	  libz.a libbz2.a libsnappy.a liblz4.a $(JAVA_STATIC_LDFLAGS)
 	cd java/target;strip -S -x $(ROCKSDBJNILIB)
 	cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
 	cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
@@ -1053,7 +1110,7 @@ rocksdbjavastatic: $(java_libobjects) libz.a libbz2.a libsnappy.a liblz4.a
 rocksdbjavastaticrelease: rocksdbjavastatic
 	cd java/crossbuild && vagrant destroy -f && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64
 	cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md
-	cd java;jar -uf target/$(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib
+	cd java/target;jar -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib
 	cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class
 
 rocksdbjavastaticpublish: rocksdbjavastaticrelease
@@ -1064,6 +1121,13 @@ rocksdbjavastaticpublish: rocksdbjavastaticrelease
 	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar -Dclassifier=osx
 	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar
 
+# A version of each $(LIBOBJECTS) compiled with -fPIC
+java_libobjects = $(patsubst %,jl/%,$(LIBOBJECTS))
+CLEAN_FILES += jl
+
+$(java_libobjects): jl/%.o: %.cc
+	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@ $(COVERAGEFLAGS)
+
 rocksdbjava: $(java_libobjects)
 	$(AM_V_GEN)cd java;$(MAKE) javalib;
 	$(AM_V_at)rm -f ./java/target/$(ROCKSDBJNILIB)
diff --git a/src/rocksdb/appveyor.yml b/src/rocksdb/appveyor.yml
index e13e2d2..4ee3ab4 100644
--- a/src/rocksdb/appveyor.yml
+++ b/src/rocksdb/appveyor.yml
@@ -2,10 +2,14 @@ version: 1.0.{build}
 before_build:
 - md %APPVEYOR_BUILD_FOLDER%\build
 - cd %APPVEYOR_BUILD_FOLDER%\build
-- cmake -G "Visual Studio 12 Win64" ..
+- cmake -G "Visual Studio 12 Win64" -DOPTDBG=1 ..
 - cd ..
 build:
-  project: build\ALL_BUILD.vcxproj
+  project: build\rocksdb.sln
   parallel: true
   verbosity: minimal
-test: off
+test:
+test_script:
+- ps: build_tools\run_ci_db_test.ps1 -EnableRerun -Run db_test -Exclude DBTest.Randomized,DBTest.FileCreationRandomFailure -Concurrency 18
+- ps: build_tools\run_ci_db_test.ps1 -Run env_test -Concurrency 1
+
diff --git a/src/rocksdb/appveyordailytests.yml b/src/rocksdb/appveyordailytests.yml
deleted file mode 100644
index a8b4af6..0000000
--- a/src/rocksdb/appveyordailytests.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-version: 1.0.{build}
-before_build:
-- md %APPVEYOR_BUILD_FOLDER%\build
-- cd %APPVEYOR_BUILD_FOLDER%\build
-- cmake -G "Visual Studio 12 Win64" -DOPTDBG=1 ..
-- cd ..
-build:
-  project: build\ALL_BUILD.vcxproj
-  parallel: true
-  verbosity: minimal
-test:
-test_script:
-- ps: build_tools\run_ci_db_test.ps1
-notifications:
-  - provider: Email
-    to:
-      - svmtrocksdb at microsoft.com
-    subject: "Build {{status}}"
-    message: "{{message}}, {{commitId}}, ..."
-    on_build_success: false
-    on_build_failure: true
-    on_build_status_changed: true
diff --git a/src/rocksdb/arcanist_util/cpp_linter/FbcodeCppLinter.php b/src/rocksdb/arcanist_util/cpp_linter/FbcodeCppLinter.php
index 66eefa0..3dac9bf 100644
--- a/src/rocksdb/arcanist_util/cpp_linter/FbcodeCppLinter.php
+++ b/src/rocksdb/arcanist_util/cpp_linter/FbcodeCppLinter.php
@@ -88,6 +88,9 @@ class FbcodeCppLinter extends ArcanistLinter {
   }
 
   private function getCppLintOutput($path) {
+     if (!array_key_exists($path, $this->rawLintOutput)) {
+       return array();
+     }
     list($output) = $this->rawLintOutput[$path];
 
     $msgs = array();
diff --git a/src/rocksdb/build_tools/build_detect_platform b/src/rocksdb/build_tools/build_detect_platform
index 0e40ac5..fc099a5 100755
--- a/src/rocksdb/build_tools/build_detect_platform
+++ b/src/rocksdb/build_tools/build_detect_platform
@@ -8,6 +8,7 @@
 #   CXX                         C++ Compiler path
 #   PLATFORM_LDFLAGS            Linker flags
 #   JAVA_LDFLAGS                Linker flags for RocksDBJava
+#   JAVA_STATIC_LDFLAGS         Linker flags for RocksDBJava static build
 #   PLATFORM_SHARED_EXT         Extension for shared libraries
 #   PLATFORM_SHARED_LDFLAGS     Flags for building shared library
 #   PLATFORM_SHARED_CFLAGS      Flags for compiling objects for shared library
@@ -44,7 +45,7 @@ fi
 # we depend on C++11
 PLATFORM_CXXFLAGS="-std=c++11"
 # we currently depend on POSIX platform
-COMMON_FLAGS="-DROCKSDB_PLATFORM_POSIX"
+COMMON_FLAGS="-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX"
 
 # Default to fbcode gcc on internal fb machines
 if [ -z "$ROCKSDB_NO_FBCODE" -a -d /mnt/gvfs/third-party ]; then
@@ -181,6 +182,7 @@ esac
 
 PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS ${CXXFLAGS}"
 JAVA_LDFLAGS="$PLATFORM_LDFLAGS"
+JAVA_STATIC_LDFLAGS="$PLATFORM_LDFLAGS"
 
 if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then
     # Cross-compiling; do not try any compilation tests.
@@ -374,6 +376,7 @@ echo "CXX=$CXX" >> "$OUTPUT"
 echo "PLATFORM=$PLATFORM" >> "$OUTPUT"
 echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> "$OUTPUT"
 echo "JAVA_LDFLAGS=$JAVA_LDFLAGS" >> "$OUTPUT"
+echo "JAVA_STATIC_LDFLAGS=$JAVA_STATIC_LDFLAGS" >> "$OUTPUT"
 echo "VALGRIND_VER=$VALGRIND_VER" >> "$OUTPUT"
 echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> "$OUTPUT"
 echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> "$OUTPUT"
diff --git a/src/rocksdb/build_tools/fbcode_config.sh b/src/rocksdb/build_tools/fbcode_config.sh
index 572c0fe..6046ff3 100644
--- a/src/rocksdb/build_tools/fbcode_config.sh
+++ b/src/rocksdb/build_tools/fbcode_config.sh
@@ -43,9 +43,9 @@ if test -z $PIC_BUILD; then
   LZ4_LIBS=" /mnt/gvfs/third-party2/lz4/79d2943e2dd7208a3e0b06cf95e9f85f05fe9e1b/r124/gcc-4.9-glibc-2.20/4230243/lib/liblz4.a"
   CFLAGS+=" -DLZ4"
 
-  ZSTD_REV=8df2d01673ae6afcc8c8d16fec862b2d67ecc1e9
-  ZSTD_INCLUDE=" -I /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.1.1/gcc-4.8.1-glibc-2.17/c3f970a/include"
-  ZSTD_LIBS=" /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.1.1/gcc-4.8.1-glibc-2.17/c3f970a/lib/libzstd.a"
+  ZSTD_REV=810b81b4705def5243e998b54701f3c504e4009e
+  ZSTD_INCLUDE=" -I /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.4.2/gcc-4.8.1-glibc-2.17/c3f970a/include"
+  ZSTD_LIBS=" /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.4.2/gcc-4.8.1-glibc-2.17/c3f970a/lib/libzstd.a"
   CFLAGS+=" -DZSTD"
 fi
 
@@ -116,7 +116,7 @@ else
 fi
 
 CFLAGS+=" $DEPS_INCLUDE"
-CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE"
+CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE"
 CXXFLAGS+=" $CFLAGS"
 
 EXEC_LDFLAGS=" $SNAPPY_LIBS $ZLIB_LIBS $BZIP_LIBS $LZ4_LIBS $ZSTD_LIBS $GFLAGS_LIBS $NUMA_LIB"
diff --git a/src/rocksdb/build_tools/fbcode_config4.8.1.sh b/src/rocksdb/build_tools/fbcode_config4.8.1.sh
index 524a5ed..516bbeb 100644
--- a/src/rocksdb/build_tools/fbcode_config4.8.1.sh
+++ b/src/rocksdb/build_tools/fbcode_config4.8.1.sh
@@ -5,61 +5,66 @@
 # uses jemalloc
 
 # location of libgcc
-LIBGCC_BASE="/mnt/gvfs/third-party2/libgcc/7712e757d7355cb51292454ee0b7b46a467fdfed/4.8.1/gcc-4.8.1-glibc-2.17/8aac7fc"
+LIBGCC_BASE="/mnt/gvfs/third-party2/libgcc/d00277f4559e261ed0a81f30f23c0ce5564e359e/4.8.1/gcc-4.8.1-glibc-2.17/8aac7fc"
 LIBGCC_INCLUDE="$LIBGCC_BASE/include"
 LIBGCC_LIBS=" -L $LIBGCC_BASE/libs"
 
 # location of glibc
-GLIBC_REV=6e40560b4e0b6d690fd1cf8c7a43ad7452b04cfa
+GLIBC_REV=0600c95b31226b5e535614c590677d87c62d8016
 GLIBC_INCLUDE="/mnt/gvfs/third-party2/glibc/$GLIBC_REV/2.17/gcc-4.8.1-glibc-2.17/99df8fc/include"
 GLIBC_LIBS=" -L /mnt/gvfs/third-party2/glibc/$GLIBC_REV/2.17/gcc-4.8.1-glibc-2.17/99df8fc/lib"
 
 # location of snappy headers and libraries
-SNAPPY_INCLUDE=" -I /mnt/gvfs/third-party2/snappy/aef17f6c0b44b4fe408bd06f67c93701ab0a6ceb/1.0.3/gcc-4.8.1-glibc-2.17/43d84e2/include"
-SNAPPY_LIBS=" /mnt/gvfs/third-party2/snappy/aef17f6c0b44b4fe408bd06f67c93701ab0a6ceb/1.0.3/gcc-4.8.1-glibc-2.17/43d84e2/lib/libsnappy.a"
+SNAPPY_REV=cbf6f1f209e5bd160bdc5d971744e039f36b1566
+SNAPPY_INCLUDE=" -I /mnt/gvfs/third-party2/snappy/$SNAPPY_REV/1.1.3/gcc-4.8.1-glibc-2.17/c3f970a/include"
+SNAPPY_LIBS=" /mnt/gvfs/third-party2/snappy/$SNAPPY_REV/1.1.3/gcc-4.8.1-glibc-2.17/c3f970a/lib/libsnappy.a"
 
 # location of zlib headers and libraries
-ZLIB_INCLUDE=" -I /mnt/gvfs/third-party2/zlib/25c6216928b4d77b59ddeca0990ff6fe9ac16b81/1.2.5/gcc-4.8.1-glibc-2.17/c3f970a/include"
-ZLIB_LIBS=" /mnt/gvfs/third-party2/zlib/25c6216928b4d77b59ddeca0990ff6fe9ac16b81/1.2.5/gcc-4.8.1-glibc-2.17/c3f970a/lib/libz.a"
+ZLIB_REV=6d39cb54708049f527e713ad19f2aadb9d3667e8
+ZLIB_INCLUDE=" -I /mnt/gvfs/third-party2/zlib/$ZLIB_REV/1.2.8/gcc-4.8.1-glibc-2.17/c3f970a/include"
+ZLIB_LIBS=" /mnt/gvfs/third-party2/zlib/$ZLIB_REV/1.2.8/gcc-4.8.1-glibc-2.17/c3f970a/lib/libz.a"
 
 # location of bzip headers and libraries
-BZIP_INCLUDE=" -I /mnt/gvfs/third-party2/bzip2/c9ef7629c2aa0024f7a416e87602f06eb88f5eac/1.0.6/gcc-4.8.1-glibc-2.17/c3f970a/include/"
-BZIP_LIBS=" /mnt/gvfs/third-party2/bzip2/c9ef7629c2aa0024f7a416e87602f06eb88f5eac/1.0.6/gcc-4.8.1-glibc-2.17/c3f970a/lib/libbz2.a"
+BZIP_REV=d6c789bfc2ec4c51a63d66df2878926b8158cde8
+BZIP_INCLUDE=" -I /mnt/gvfs/third-party2/bzip2/$BZIP_REV/1.0.6/gcc-4.8.1-glibc-2.17/c3f970a/include/"
+BZIP_LIBS=" /mnt/gvfs/third-party2/bzip2/$BZIP_REV/1.0.6/gcc-4.8.1-glibc-2.17/c3f970a/lib/libbz2.a"
 
-LZ4_REV=065ec7e38fe83329031f6668c43bef83eff5808b
-LZ4_INCLUDE=" -I /mnt/gvfs/third-party2/lz4/$LZ4_REV/r108/gcc-4.8.1-glibc-2.17/c3f970a/include"
-LZ4_LIBS=" /mnt/gvfs/third-party2/lz4/$LZ4_REV/r108/gcc-4.8.1-glibc-2.17/c3f970a/lib/liblz4.a"
+LZ4_REV=6858fac689e0f92e584224d91bdb0e39f6c8320d
+LZ4_INCLUDE=" -I /mnt/gvfs/third-party2/lz4/$LZ4_REV/r131/gcc-4.8.1-glibc-2.17/c3f970a/include"
+LZ4_LIBS=" /mnt/gvfs/third-party2/lz4/$LZ4_REV/r131/gcc-4.8.1-glibc-2.17/c3f970a/lib/liblz4.a"
 
-ZSTD_REV=8df2d01673ae6afcc8c8d16fec862b2d67ecc1e9
-ZSTD_INCLUDE=" -I /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.1.1/gcc-4.8.1-glibc-2.17/c3f970a/include"
-ZSTD_LIBS=" /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.1.1/gcc-4.8.1-glibc-2.17/c3f970a/lib/libzstd.a"
+ZSTD_REV=810b81b4705def5243e998b54701f3c504e4009e
+ZSTD_INCLUDE=" -I /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.4.2/gcc-4.8.1-glibc-2.17/c3f970a/include"
+ZSTD_LIBS=" /mnt/gvfs/third-party2/zstd/$ZSTD_REV/0.4.2/gcc-4.8.1-glibc-2.17/c3f970a/lib/libzstd.a"
 
 # location of gflags headers and libraries
-GFLAGS_INCLUDE=" -I /mnt/gvfs/third-party2/gflags/1ad047a6e6f6673991918ecadc670868205a243a/1.6/gcc-4.8.1-glibc-2.17/c3f970a/include/"
-GFLAGS_LIBS=" /mnt/gvfs/third-party2/gflags/1ad047a6e6f6673991918ecadc670868205a243a/1.6/gcc-4.8.1-glibc-2.17/c3f970a/lib/libgflags.a"
+GFLAGS_REV=c7275a4ceae0aca0929e56964a31dafc53c1ee96
+GFLAGS_INCLUDE=" -I /mnt/gvfs/third-party2/gflags/$GFLAGS_REV/2.1.1/gcc-4.8.1-glibc-2.17/c3f970a/include/"
+GFLAGS_LIBS=" /mnt/gvfs/third-party2/gflags/$GFLAGS_REV/2.1.1/gcc-4.8.1-glibc-2.17/c3f970a/lib/libgflags.a"
 
 # location of jemalloc
-JEMALLOC_INCLUDE=" -I /mnt/gvfs/third-party2/jemalloc/3691c776ac26dd8781e84f8888b6a0fbdbc0a9ed/dev/gcc-4.8.1-glibc-2.17/4d53c6f/include"
-JEMALLOC_LIB="/mnt/gvfs/third-party2/jemalloc/3691c776ac26dd8781e84f8888b6a0fbdbc0a9ed/dev/gcc-4.8.1-glibc-2.17/4d53c6f/lib/libjemalloc.a"
+JEMALLOC_REV=c370265e58c4b6602e798df23335a1e9913dae52
+JEMALLOC_INCLUDE=" -I /mnt/gvfs/third-party2/jemalloc/$JEMALLOC_REV/4.0.3/gcc-4.8.1-glibc-2.17/8d31e51/include"
+JEMALLOC_LIB="/mnt/gvfs/third-party2/jemalloc/$JEMALLOC_REV/4.0.3/gcc-4.8.1-glibc-2.17/8d31e51/lib/libjemalloc.a"
 
 # location of numa
-NUMA_REV=829d10dac0230f99cd7e1778869d2adf3da24b65
+NUMA_REV=ae54a5ed22cdabb1c6446dce4e8ffae5b4446d73
 NUMA_INCLUDE=" -I /mnt/gvfs/third-party2/numa/$NUMA_REV/2.0.8/gcc-4.8.1-glibc-2.17/c3f970a/include/"
 NUMA_LIB=" /mnt/gvfs/third-party2/numa/$NUMA_REV/2.0.8/gcc-4.8.1-glibc-2.17/c3f970a/lib/libnuma.a"
 
 # location of libunwind
-LIBUNWIND_REV=2c060e64064559905d46fd194000d61592087bdc
-LIBUNWIND="/mnt/gvfs/third-party2/libunwind/$LIBUNWIND_REV/1.1/gcc-4.8.1-glibc-2.17/675d945/lib/libunwind.a"
+LIBUNWIND_REV=121f1a75c4414683aea8c70b761bfaf187f7c1a3
+LIBUNWIND="/mnt/gvfs/third-party2/libunwind/$LIBUNWIND_REV/trunk/gcc-4.8.1-glibc-2.17/675d945/lib/libunwind.a"
 
 # use Intel SSE support for checksum calculations
 export USE_SSE=1
 
-BINUTILS="/mnt/gvfs/third-party2/binutils/2aff2e7b474cd3e6ab23495ad1224b7d214b9f8e/2.21.1/centos6-native/da39a3e/bin"
+BINUTILS="/mnt/gvfs/third-party2/binutils/75670d0d8ef4891fd1ec2a7513ef01cd002c823b/2.25/centos6-native/da39a3e/bin"
 AR="$BINUTILS/ar"
 
 DEPS_INCLUDE="$SNAPPY_INCLUDE $ZLIB_INCLUDE $BZIP_INCLUDE $LZ4_INCLUDE $ZSTD_INCLUDE $GFLAGS_INCLUDE $NUMA_INCLUDE"
 
-GCC_BASE="/mnt/gvfs/third-party2/gcc/1ec615e23800f0815d474478ba476a0adc3fe788/4.8.1/centos6-native/cc6c9dc"
+GCC_BASE="/mnt/gvfs/third-party2/gcc/c0064002d2609ab649603f769f0bd110bbe48029/4.8.1/centos6-native/cc6c9dc"
 STDLIBS="-L $GCC_BASE/lib64"
 
 if [ -z "$USE_CLANG" ]; then
@@ -72,12 +77,12 @@ if [ -z "$USE_CLANG" ]; then
   CFLAGS+=" -isystem $LIBGCC_INCLUDE"
 else
   # clang 
-  CLANG_BASE="/mnt/gvfs/third-party2/clang/9ab68376f938992c4eb5946ca68f90c3185cffc8/3.4"
+  CLANG_BASE="/mnt/gvfs/third-party2/clang/ab054e9a490a8fd4537c0b6ec56e5c91c0f81c91/3.4"
   CLANG_INCLUDE="$CLANG_BASE/gcc-4.8.1-glibc-2.17/fb0f730/lib/clang/3.4/include"
   CC="$CLANG_BASE/centos6-native/9cefd8a/bin/clang"
   CXX="$CLANG_BASE/centos6-native/9cefd8a/bin/clang++"
 
-  KERNEL_HEADERS_INCLUDE="/mnt/gvfs/third-party2/kernel-headers/a683ed7135276731065a9d76d3016c9731f4e2f9/3.2.18_70_fbk11_00129_gc8882d0/gcc-4.8.1-glibc-2.17/da39a3e/include/"
+  KERNEL_HEADERS_INCLUDE="/mnt/gvfs/third-party2/kernel-headers/1a48835975c66d30e47770ec419758ed3b9ba010/3.10.62-62_fbk17_03959_ge29cc63/gcc-4.8.1-glibc-2.17/da39a3e/include/"
 
   CFLAGS="-B$BINUTILS/gold -nostdinc -nostdlib"
   CFLAGS+=" -isystem $LIBGCC_BASE/include/c++/4.8.1 "
@@ -91,7 +96,7 @@ else
 fi
 
 CFLAGS+=" $DEPS_INCLUDE"
-CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE"
+CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_MALLOC_USABLE_SIZE"
 CFLAGS+=" -DSNAPPY -DGFLAGS=google -DZLIB -DBZIP2 -DLZ4 -DZSTD -DNUMA"
 CXXFLAGS+=" $CFLAGS"
 
@@ -104,7 +109,7 @@ PLATFORM_LDFLAGS="$LIBGCC_LIBS $GLIBC_LIBS $STDLIBS -lgcc -lstdc++"
 
 EXEC_LDFLAGS_SHARED="$SNAPPY_LIBS $ZLIB_LIBS $BZIP_LIBS $LZ4_LIBS $ZSTD_LIBS $GFLAGS_LIBS"
 
-VALGRIND_REV=b2a9f85e4b70cd03abc85a7f3027fbc4cef35bd0
+VALGRIND_REV=af85c56f424cd5edfc2c97588299b44ecdec96bb
 VALGRIND_VER="/mnt/gvfs/third-party2/valgrind/$VALGRIND_REV/3.8.1/gcc-4.8.1-glibc-2.17/c3f970a/bin/"
 
 export CC CXX AR CFLAGS CXXFLAGS EXEC_LDFLAGS EXEC_LDFLAGS_SHARED VALGRIND_VER JEMALLOC_LIB JEMALLOC_INCLUDE
diff --git a/src/rocksdb/build_tools/rocksdb-lego-determinator b/src/rocksdb/build_tools/rocksdb-lego-determinator
index 392231c..10f2c5a 100755
--- a/src/rocksdb/build_tools/rocksdb-lego-determinator
+++ b/src/rocksdb/build_tools/rocksdb-lego-determinator
@@ -68,6 +68,14 @@ CLANG="USE_CLANG=1"
 LITE="OPT=-DROCKSDB_LITE"
 TSAN="COMPILE_WITH_TSAN=1"
 DISABLE_JEMALLOC="DISABLE_JEMALLOC=1"
+PARSER="'parser':'egrep \'Failure|^#|Abort\''"
+
+ARTIFACTS=" 'artifacts': [
+    {
+        'name':'database',
+        'paths':[ '/dev/shm/rocksdb' ],
+    }
+]"
 
 #
 # A mechanism to disable tests temporarily
@@ -100,13 +108,15 @@ PARALLEL_UNIT_TEST_COMMANDS="[
             {
                 'name':'Build and test RocksDB debug version',
                 'shell':'$DEBUG make -j$(nproc) all && $SHM make check > /dev/null 2>&1 || cat t/log-*',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
             $CLEANUP_ENV,
             {
                 'name':'Build and test RocksDB debug version under gcc-4.8.1',
                 'shell':'$GCC_481 $DEBUG make -j$(nproc) all && $SHM make check > /dev/null 2>&1 || cat t/log-*',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -125,7 +135,8 @@ UNIT_TEST_COMMANDS="[
             {
                 'name':'Build and test RocksDB debug version',
                 'shell':'$SHM $DEBUG make J=1 check',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -144,7 +155,8 @@ UNIT_TEST_COMMANDS_481="[
             {
                 'name':'Build and test RocksDB debug version',
                 'shell':'$SHM $GCC_481 $DEBUG make J=1 check',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -163,7 +175,8 @@ CLANG_UNIT_TEST_COMMANDS="[
             {
                 'name':'Build and test RocksDB debug',
                 'shell':'$CLANG $SHM $DEBUG make J=1 check',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -182,7 +195,8 @@ CLANG_ANALYZE_COMMANDS="[
             {
                 'name':'RocksDB build and analyze',
                 'shell':'$CLANG $SHM $DEBUG make J=1 analyze',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -201,7 +215,8 @@ CODE_COV_COMMANDS="[
             {
                 'name':'Build, test and collect code coverage info',
                 'shell':'$SHM $DEBUG make J=1 coverage',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -220,7 +235,8 @@ UNITY_COMMANDS="[
             {
                 'name':'Build, test unity test',
                 'shell':'$SHM $DEBUG V=1 make J=1 unity_test',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -239,7 +255,28 @@ LITE_BUILD_COMMANDS="[
             {
                 'name':'Build RocksDB debug version',
                 'shell':'$LITE $DEBUG make J=1 static_lib',
-                'user':'root'
+                'user':'root',
+                $PARSER
+            },
+        ],
+        $REPORT
+    }
+]"
+
+#
+# RocksDB lite tests
+#
+LITE_UNIT_TEST_COMMANDS="[
+    {
+        'name':'Rocksdb Lite Unit Test',
+        'oncall':'$ONCALL',
+        'steps': [
+            $CLEANUP_ENV,
+            {
+                'name':'Build RocksDB debug version',
+                'shell':'$SHM $LITE $DEBUG make J=1 check',
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -259,19 +296,44 @@ STRESS_CRASH_TEST_COMMANDS="[
             {
                 'name':'Build and run RocksDB debug stress tests',
                 'shell':'$SHM $DEBUG make J=1 db_stress',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
             {
                 'name':'Build and run RocksDB debug crash tests',
                 'timeout': 86400,
                 'shell':'$SHM $DEBUG make J=1 crash_test',
-                'user':'root'
+                'user':'root',
+                $PARSER
+            }
+        ],
+        $ARTIFACTS,
+        $REPORT
+    }
+]"
+
+# RocksDB write stress test.
+# We run on disk device on purpose (i.e. no $SHM)
+# because we want to add some randomness to fsync commands
+WRITE_STRESS_COMMANDS="[
+    {
+        'name':'Rocksdb Write Stress Test',
+        'oncall':'$ONCALL',
+        'steps': [
+            $CLEANUP_ENV,
+            {
+                'name':'Build and run RocksDB write stress tests',
+                'shell':'make write_stress && python tools/write_stress_runner.py --runtime_sec=3600 --db=/tmp/rocksdb_write_stress',
+                'user':'root',
+                $PARSER
             }
         ],
+        'artifacts': [{'name': 'database', 'paths': ['/tmp/rocksdb_write_stress']}],
         $REPORT
     }
 ]"
 
+
 #
 # RocksDB test under address sanitizer
 #
@@ -284,7 +346,8 @@ ASAN_TEST_COMMANDS="[
             {
                 'name':'Test RocksDB debug under ASAN',
                 'shell':'set -o pipefail && $SHM $ASAN $DEBUG make J=1 asan_check |& /usr/facebook/ops/scripts/asan_symbolize.py -d',
-                'user':'root'
+                'user':'root',
+                $PARSER
             }
         ],
         $REPORT
@@ -305,7 +368,8 @@ ASAN_CRASH_TEST_COMMANDS="[
                 'name':'Build and run RocksDB debug asan_crash_test',
                 'timeout': 86400,
                 'shell':'$SHM $DEBUG make J=1 asan_crash_test',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -324,7 +388,8 @@ VALGRIND_TEST_COMMANDS="[
             {
                 'name':'Run RocksDB debug unit tests',
                 'shell':'$DISABLE_JEMALLOC $SHM $DEBUG make valgrind_check',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -343,7 +408,8 @@ TSAN_UNIT_TEST_COMMANDS="[
             {
                 'name':'Run RocksDB debug unit test',
                 'shell':'set -o pipefail && $SHM $DEBUG $TSAN make J=1 check',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -364,13 +430,16 @@ TSAN_CRASH_TEST_COMMANDS="[
                 'name':'Compile and run',
                 'timeout': 86400,
                 'shell':'set -o pipefail && $SHM $DEBUG $TSAN make J=1 crash_test',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
     }
 ]"
 
+TSAN_CRASH_TEST_COMMANDS=$DISABLE_COMMANDS
+
 #
 # RocksDB format compatible
 #
@@ -425,7 +494,8 @@ FORMAT_COMPATIBLE_COMMANDS="[
             {
                 'name':'Run RocksDB debug unit test',
                 'shell':'build_tools/rocksdb-lego-determinator run_format_compatible',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -457,7 +527,8 @@ NO_COMPRESSION_COMMANDS="[
             {
                 'name':'Run RocksDB debug unit test',
                 'shell':'build_tools/rocksdb-lego-determinator run_no_compression',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -513,7 +584,8 @@ REGRESSION_COMMANDS="[
             {
                 'name':'Make and run script',
                 'shell':'build_tools/rocksdb-lego-determinator run_regression',
-                'user':'root'
+                'user':'root',
+                $PARSER
             },
         ],
         $REPORT
@@ -545,9 +617,15 @@ case $1 in
   lite)
     echo $LITE_BUILD_COMMANDS
     ;;
+  lite_test)
+    echo $LITE_UNIT_TEST_COMMANDS
+    ;;
   stress_crash)
     echo $STRESS_CRASH_TEST_COMMANDS
     ;;
+  write_stress)
+    echo $WRITE_STRESS_COMMANDS
+    ;;
   asan)
     echo $ASAN_TEST_COMMANDS
     ;;
diff --git a/src/rocksdb/build_tools/run_ci_db_test.ps1 b/src/rocksdb/build_tools/run_ci_db_test.ps1
index 5f47f3d..bf7c2b7 100644
--- a/src/rocksdb/build_tools/run_ci_db_test.ps1
+++ b/src/rocksdb/build_tools/run_ci_db_test.ps1
@@ -1,14 +1,19 @@
 # This script enables you running RocksDB tests by running
-# All the tests in paralell and utilizing all the cores
+# All the tests in parallel and utilizing all the cores
 # For db_test the script first lists and parses the tests
 # and then fires them up in parallel using async PS Job functionality
 # Run the script from the enlistment
 Param(
   [switch]$EnableJE = $false,  # Use je executable
+  [switch]$EnableRerun = $false, # Rerun failed tests sequentially at the end
   [string]$WorkFolder = "",  # Direct tests to use that folder
   [int]$Limit = -1, # -1 means run all otherwise limit for testing purposes
   [string]$Exclude = "", # Expect a comma separated list, no spaces
-  [string]$Run = "db_test"  # Run db_test|tests
+  [string]$Run = "db_test",  # Run db_test|tests|testname1,testname2...
+   # Number of async tasks that would run concurrently. Recommend a number below 64.
+   # However, CPU utlization really depends on the storage media. Recommend ram based disk.
+   # a value of 1 will run everything serially
+  [int]$Concurrency = 16
 )
 
 # Folders and commands must be fullpath to run assuming
@@ -49,7 +54,7 @@ if($EnableJE) {
 }
 
 Write-Output "Root: $RootFolder, WorkFolder: $WorkFolder"
-Write-Output "Binaries: $BinariesFolder exe: $db_test"
+Write-Output "Binaries: $BinariesFolder db_test: $db_test"
 
 #Exclusions that we do not want to run
 $ExcludeTests = New-Object System.Collections.Generic.HashSet[string]
@@ -57,7 +62,7 @@ $ExcludeTests = New-Object System.Collections.Generic.HashSet[string]
 
 if($Exclude -ne "") {
     Write-Host "Exclude: $Exclude"
-    $l = $Exclude -split ','
+    $l = $Exclude -split ' '
     ForEach($t in $l) { $ExcludeTests.Add($t) | Out-Null }
 }
 
@@ -109,38 +114,69 @@ function Normalize-DbTests($HashTable) {
 
         $test_log = $test -replace '[\./]','_'
         $test_log += ".log"
+        $log_path = -join ($LogFolder, $test_log)
 
         # Add to a hashtable
-        $HashTable.Add($test, $test_log);
+        $HashTable.Add($test, $log_path);
       }
     }
 }
 
+# The function removes trailing .exe siffix if any,
+# creates a name for the log file
+function MakeAndAdd([string]$token, $HashTable) {
+    $test_name = $token -replace '.exe$', ''
+    $log_name =  -join ($test_name, ".log")
+    $log_path = -join ($LogFolder, $log_name)
+    if(!$ExcludeTests.Contains($test_name)) {
+        $HashTable.Add($test_name, $log_path)
+    } else {
+        Write-Warning "Test $test_name is excluded"
+    }
+}
+
 # The function scans build\Debug folder to discover
 # Test executables. It then populates a table with
 # Test executable name -> Log file
-function Discover-TestBinaries($HashTable) {
+function Discover-TestBinaries([string]$Pattern, $HashTable) {
 
     $Exclusions = @("db_test*", "db_sanity_test*")
-    $p = -join ($BinariesFolder, "*_test*.exe")
+
+    $p = -join ($BinariesFolder, $pattern)
+
+    Write-Host "Path: $p"
 
     dir -Path $p -Exclude $Exclusions | ForEach-Object {
-       $t = ($_.Name) -replace '.exe$', ''
-       $test_log = -join ($t, ".log")
-       $HashTable.Add($t, $test_log)
+       MakeAndAdd -token ($_.Name) -HashTable $HashTable
     }
 }
 
-$TestToLog = [ordered]@{}
+$TestsToRun = [ordered]@{}
 
 if($Run -ceq "db_test") {
-    Normalize-DbTests -HashTable $TestToLog
+    Normalize-DbTests -HashTable $TestsToRun
 } elseif($Run -ceq "tests") {
-    Discover-TestBinaries -HashTable $TestToLog
+    if($EnableJE) {
+        $pattern = "*_test_je.exe"
+    } else {
+        $pattern = "*_test.exe"
+    }
+    Discover-TestBinaries -Pattern $pattern -HashTable $TestsToRun
+} else {
+
+    $test_list = $Run -split ' '
+
+    ForEach($t in $test_list) {
+       MakeAndAdd -token $t -HashTable $TestsToRun
+    }
 }
 
+$NumTestsToStart = $TestsToRun.Count
+if($Limit -ge 0 -and $NumTestsToStart -gt $Limit) {
+    $NumTestsToStart = $Limit
+}
 
-Write-Host "Attempting to start: " ($TestToLog.Count) " tests"
+Write-Host "Attempting to start: $NumTestsToStart tests"
 
 # Invoke a test with a filter and redirect all output
 $InvokeTestCase = {
@@ -154,93 +190,123 @@ $InvokeTestAsync = {
     &$exe > $log 2>&1
 }
 
-$jobs = @()
-$JobToLog = @{}
+# Hash that contains tests to rerun if any failed
+# Those tests will be rerun sequentially
+$Rerun = [ordered]@{}
 # Test limiting factor here
 $count = 0
+# Overall status
+[bool]$success = $true;
 
-ForEach($k in $TestToLog.keys) {
+function RunJobs($TestToLog, [int]$ConcurrencyVal, [bool]$AddForRerun)
+{
+    # Array to wait for any of the running jobs
+    $jobs = @()
+    # Hash JobToLog
+    $JobToLog = @{}
 
-    Write-Host "Starting $k"
-    $log_path = -join ($LogFolder, ($TestToLog.$k))
+    # Wait for all to finish and get the results
+    while(($JobToLog.Count -gt 0) -or
+          ($TestToLog.Count -gt 0)) {
 
-    if($Run -ceq "db_test") {
-        $job = Start-Job -Name $k -ScriptBlock $InvokeTestCase -ArgumentList @($db_test,$k,$log_path)
-    } else {
-        [string]$Exe =  -Join ($BinariesFolder, $k)
-        $job = Start-Job -Name $k -ScriptBlock $InvokeTestAsync -ArgumentList @($exe,$log_path)
-    }
+        # Make sure we have maximum concurrent jobs running if anything
+        # and the $Limit either not set or allows to proceed
+        while(($JobToLog.Count -lt $ConcurrencyVal) -and
+              (($TestToLog.Count -gt 0) -and
+              (($Limit -lt 0) -or ($count -lt $Limit)))) {
 
-    $JobToLog.Add($job, $log_path)
 
-    # Limiting trial runs
-    if(($Limit -gt 0) -and (++$count -ge $Limit)) {
-         break
-    }
-}
+            # We only need the first key
+            foreach($key in $TestToLog.keys) {
+                $k = $key
+                break
+            }
 
-[bool]$success = $true;
+            Write-Host "Starting $k"
+            $log_path = ($TestToLog.$k)
 
-# Wait for all to finish and get the results
-while($JobToLog.Count -gt 0) {
+            if($Run -ceq "db_test") {
+              $job = Start-Job -Name $k -ScriptBlock $InvokeTestCase -ArgumentList @($db_test,$k,$log_path)
+            } else {
+              [string]$Exe =  -Join ($BinariesFolder, $k)
+               $job = Start-Job -Name $k -ScriptBlock $InvokeTestAsync -ArgumentList @($exe,$log_path)
+            }
 
-    $jobs = @()
-    foreach($k in $JobToLog.Keys) { $jobs += $k }
+            $JobToLog.Add($job, $log_path)
+            $TestToLog.Remove($k)
 
-<#
-    if(!$success) {
-        break
-    }
-#>
+            ++$count
+        }
 
-    $completed = Wait-Job -Job $jobs -Any
-    $log = $JobToLog[$completed]
-    $JobToLog.Remove($completed)
+        if($JobToLog.Count -lt 1) {
+          break
+        }
 
-    $message = -join @($completed.Name, " State: ", ($completed.State))
+        $jobs = @()
+        foreach($k in $JobToLog.Keys) { $jobs += $k }
 
-    $log_content = @(Get-Content $log)
+        $completed = Wait-Job -Job $jobs -Any
+        $log = $JobToLog[$completed]
+        $JobToLog.Remove($completed)
 
-    if($completed.State -ne "Completed") {
-        $success = $false
-        Write-Warning $message
-        $log_content | Write-Warning
-    } else {
-        # Scan the log. If we find PASSED and no occurence of FAILED
-        # then it is a success
-        [bool]$pass_found = $false
-        ForEach($l in $log_content) {
-
-            if(($l -match "^\[\s+FAILED") -or
-               ($l -match "Assertion failed:")) {
-                $pass_found = $false
-                break
-            }
+        $message = -join @($completed.Name, " State: ", ($completed.State))
 
-            if(($l -match "^\[\s+PASSED") -or
-               ($l -match " : PASSED$") -or
-                ($l -match "^PASSED") -or
-                ($l -match "Passed all tests!") ) {
-                $pass_found = $true
-            }
-        }
+        $log_content = @(Get-Content $log)
 
-        if(!$pass_found) {
-            $success = $false;
+        if($completed.State -ne "Completed") {
+            $success = $false
             Write-Warning $message
             $log_content | Write-Warning
         } else {
-            Write-Host $message
+            # Scan the log. If we find PASSED and no occurrence of FAILED
+            # then it is a success
+            [bool]$pass_found = $false
+            ForEach($l in $log_content) {
+
+                if(($l -match "^\[\s+FAILED") -or
+                   ($l -match "Assertion failed:")) {
+                    $pass_found = $false
+                    break
+                }
+
+                if(($l -match "^\[\s+PASSED") -or
+                   ($l -match " : PASSED$") -or
+                    ($l -match "^PASS$") -or   # Special c_test case
+                    ($l -match "Passed all tests!") ) {
+                    $pass_found = $true
+                }
+            }
+
+            if(!$pass_found) {
+                $success = $false;
+                Write-Warning $message
+                $log_content | Write-Warning
+                if($AddForRerun) {
+                    $Rerun.Add($completed.Name, $log)
+                }
+            } else {
+                Write-Host $message
+            }
         }
+
+        # Remove cached job info from the system
+        # Should be no output
+        Receive-Job -Job $completed | Out-Null
     }
+}
 
-    # Remove cached job info from the system
-    # Should be no output
-    Receive-Job -Job $completed | Out-Null
+RunJobs -TestToLog $TestsToRun -ConcurrencyVal $Concurrency -AddForRerun $EnableRerun
+
+if($Rerun.Count -gt 0) {
+    Write-Host "Rerunning " ($Rerun.Count) " tests sequentially"
+    $success = $true
+    $count = 0
+    RunJobs -TestToLog $Rerun -ConcurrencyVal 1 -AddForRerun $false
 }
 
 Get-Date
 
+
 if(!$success) {
 # This does not succeed killing off jobs quick
 # So we simply exit
@@ -249,4 +315,4 @@ if(!$success) {
     exit 12345
  }
 
- 
\ No newline at end of file
+ 
diff --git a/src/rocksdb/db/builder.cc b/src/rocksdb/db/builder.cc
index 3d07a0f..68b9fe8 100644
--- a/src/rocksdb/db/builder.cc
+++ b/src/rocksdb/db/builder.cc
@@ -26,6 +26,7 @@
 #include "rocksdb/options.h"
 #include "rocksdb/table.h"
 #include "table/block_based_table_builder.h"
+#include "table/internal_iterator.h"
 #include "util/file_reader_writer.h"
 #include "util/iostats_context_imp.h"
 #include "util/stop_watch.h"
@@ -40,22 +41,25 @@ TableBuilder* NewTableBuilder(
     const InternalKeyComparator& internal_comparator,
     const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
         int_tbl_prop_collector_factories,
-    WritableFileWriter* file, const CompressionType compression_type,
+    uint32_t column_family_id, WritableFileWriter* file,
+    const CompressionType compression_type,
     const CompressionOptions& compression_opts, const bool skip_filters) {
   return ioptions.table_factory->NewTableBuilder(
       TableBuilderOptions(ioptions, internal_comparator,
                           int_tbl_prop_collector_factories, compression_type,
                           compression_opts, skip_filters),
-      file);
+      column_family_id, file);
 }
 
 Status BuildTable(
     const std::string& dbname, Env* env, const ImmutableCFOptions& ioptions,
-    const EnvOptions& env_options, TableCache* table_cache, Iterator* iter,
-    FileMetaData* meta, const InternalKeyComparator& internal_comparator,
+    const EnvOptions& env_options, TableCache* table_cache,
+    InternalIterator* iter, FileMetaData* meta,
+    const InternalKeyComparator& internal_comparator,
     const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
         int_tbl_prop_collector_factories,
-    std::vector<SequenceNumber> snapshots, const CompressionType compression,
+    uint32_t column_family_id, std::vector<SequenceNumber> snapshots,
+    const CompressionType compression,
     const CompressionOptions& compression_opts, bool paranoid_file_checks,
     InternalStats* internal_stats, const Env::IOPriority io_priority,
     TableProperties* table_properties) {
@@ -72,7 +76,7 @@ Status BuildTable(
     unique_ptr<WritableFileWriter> file_writer;
     {
       unique_ptr<WritableFile> file;
-      s = env->NewWritableFile(fname, &file, env_options);
+      s = NewWritableFile(env, fname, &file, env_options);
       if (!s.ok()) {
         return s;
       }
@@ -82,7 +86,7 @@ Status BuildTable(
 
       builder = NewTableBuilder(
           ioptions, internal_comparator, int_tbl_prop_collector_factories,
-          file_writer.get(), compression, compression_opts);
+          column_family_id, file_writer.get(), compression, compression_opts);
     }
 
     MergeHelper merge(env, internal_comparator.user_comparator(),
@@ -92,7 +96,8 @@ Status BuildTable(
                       snapshots.empty() ? 0 : snapshots.back());
 
     CompactionIterator c_iter(iter, internal_comparator.user_comparator(),
-                              &merge, kMaxSequenceNumber, &snapshots, env,
+                              &merge, kMaxSequenceNumber, &snapshots,
+                              kMaxSequenceNumber, env,
                               true /* internal key corruption is not ok */);
     c_iter.SeekToFirst();
     for (; c_iter.Valid(); c_iter.Next()) {
@@ -139,7 +144,7 @@ Status BuildTable(
 
     if (s.ok() && !empty) {
       // Verify that the table is usable
-      std::unique_ptr<Iterator> it(table_cache->NewIterator(
+      std::unique_ptr<InternalIterator> it(table_cache->NewIterator(
           ReadOptions(), env_options, internal_comparator, meta->fd, nullptr,
           (internal_stats == nullptr) ? nullptr
                                       : internal_stats->GetFileReadHist(0),
diff --git a/src/rocksdb/db/builder.h b/src/rocksdb/db/builder.h
index 09d81bf..cdafa4a 100644
--- a/src/rocksdb/db/builder.h
+++ b/src/rocksdb/db/builder.h
@@ -31,13 +31,15 @@ class VersionEdit;
 class TableBuilder;
 class WritableFileWriter;
 class InternalStats;
+class InternalIterator;
 
 TableBuilder* NewTableBuilder(
     const ImmutableCFOptions& options,
     const InternalKeyComparator& internal_comparator,
     const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
         int_tbl_prop_collector_factories,
-    WritableFileWriter* file, const CompressionType compression_type,
+    uint32_t column_family_id, WritableFileWriter* file,
+    const CompressionType compression_type,
     const CompressionOptions& compression_opts,
     const bool skip_filters = false);
 
@@ -48,11 +50,13 @@ TableBuilder* NewTableBuilder(
 // zero, and no Table file will be produced.
 extern Status BuildTable(
     const std::string& dbname, Env* env, const ImmutableCFOptions& options,
-    const EnvOptions& env_options, TableCache* table_cache, Iterator* iter,
-    FileMetaData* meta, const InternalKeyComparator& internal_comparator,
+    const EnvOptions& env_options, TableCache* table_cache,
+    InternalIterator* iter, FileMetaData* meta,
+    const InternalKeyComparator& internal_comparator,
     const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
         int_tbl_prop_collector_factories,
-    std::vector<SequenceNumber> snapshots, const CompressionType compression,
+    uint32_t column_family_id, std::vector<SequenceNumber> snapshots,
+    const CompressionType compression,
     const CompressionOptions& compression_opts, bool paranoid_file_checks,
     InternalStats* internal_stats,
     const Env::IOPriority io_priority = Env::IO_HIGH,
diff --git a/src/rocksdb/db/c.cc b/src/rocksdb/db/c.cc
index 8cd0826..3c98429 100644
--- a/src/rocksdb/db/c.cc
+++ b/src/rocksdb/db/c.cc
@@ -1288,6 +1288,11 @@ void rocksdb_block_based_options_set_cache_index_and_filter_blocks(
   options->rep.cache_index_and_filter_blocks = v;
 }
 
+void rocksdb_block_based_options_set_skip_table_builder_flush(
+    rocksdb_block_based_table_options_t* options, unsigned char v) {
+  options->rep.skip_table_builder_flush = v;
+}
+
 void rocksdb_options_set_block_based_table_factory(
     rocksdb_options_t *opt,
     rocksdb_block_based_table_options_t* table_options) {
@@ -1687,6 +1692,11 @@ void rocksdb_options_set_keep_log_file_num(rocksdb_options_t* opt, size_t v) {
   opt->rep.keep_log_file_num = v;
 }
 
+void rocksdb_options_set_recycle_log_file_num(rocksdb_options_t* opt,
+                                              size_t v) {
+  opt->rep.recycle_log_file_num = v;
+}
+
 void rocksdb_options_set_soft_rate_limit(rocksdb_options_t* opt, double v) {
   opt->rep.soft_rate_limit = v;
 }
diff --git a/src/rocksdb/db/column_family.cc b/src/rocksdb/db/column_family.cc
index 88bf033..a6fae98 100644
--- a/src/rocksdb/db/column_family.cc
+++ b/src/rocksdb/db/column_family.cc
@@ -27,9 +27,9 @@
 #include "db/version_set.h"
 #include "db/write_controller.h"
 #include "db/writebuffer.h"
+#include "memtable/hash_skiplist_rep.h"
 #include "util/autovector.h"
 #include "util/compression.h"
-#include "util/hash_skiplist_rep.h"
 #include "util/options_helper.h"
 #include "util/thread_status_util.h"
 #include "util/xfunc.h"
@@ -175,6 +175,12 @@ ColumnFamilyOptions SanitizeOptions(const DBOptions& db_options,
     result.level0_stop_writes_trigger = std::numeric_limits<int>::max();
   }
 
+  if (result.level0_file_num_compaction_trigger == 0) {
+    Warn(db_options.info_log.get(),
+         "level0_file_num_compaction_trigger cannot be 0");
+    result.level0_file_num_compaction_trigger = 1;
+  }
+
   if (result.level0_stop_writes_trigger <
           result.level0_slowdown_writes_trigger ||
       result.level0_slowdown_writes_trigger <
@@ -431,8 +437,6 @@ void ColumnFamilyData::RecalculateWriteStallConditions(
       const MutableCFOptions& mutable_cf_options) {
   if (current_ != nullptr) {
     auto* vstorage = current_->storage_info();
-    const double score = vstorage->max_compaction_score();
-    const int max_level = vstorage->max_compaction_score_level();
     auto write_controller = column_family_set_->write_controller_;
 
     if (imm()->NumNotFlushed() >= mutable_cf_options.max_write_buffer_number) {
@@ -461,8 +465,8 @@ void ColumnFamilyData::RecalculateWriteStallConditions(
       internal_stats_->AddCFStats(
           InternalStats::HARD_PENDING_COMPACTION_BYTES_LIMIT, 1);
       Log(InfoLogLevel::WARN_LEVEL, ioptions_.info_log,
-          "[%s] Stopping writes because estimated pending compaction "
-          "bytes exceed %" PRIu64,
+          "[%s] Stopping writes because of estimated pending compaction "
+          "bytes %" PRIu64,
           name_.c_str(), vstorage->estimated_compaction_needed_bytes());
     } else if (mutable_cf_options.level0_slowdown_writes_trigger >= 0 &&
                vstorage->l0_delay_trigger_count() >=
@@ -476,13 +480,16 @@ void ColumnFamilyData::RecalculateWriteStallConditions(
       Log(InfoLogLevel::WARN_LEVEL, ioptions_.info_log,
           "[%s] Stalling writes because we have %d level-0 files",
           name_.c_str(), vstorage->l0_delay_trigger_count());
-    } else if (mutable_cf_options.soft_rate_limit > 0.0 &&
-               score > mutable_cf_options.soft_rate_limit) {
+    } else if (mutable_cf_options.soft_pending_compaction_bytes_limit > 0 &&
+               vstorage->estimated_compaction_needed_bytes() >=
+                   mutable_cf_options.soft_pending_compaction_bytes_limit) {
       write_controller_token_ = write_controller->GetDelayToken();
-      internal_stats_->RecordLevelNSlowdown(max_level, true);
+      internal_stats_->AddCFStats(
+          InternalStats::SOFT_PENDING_COMPACTION_BYTES_LIMIT, 1);
       Log(InfoLogLevel::WARN_LEVEL, ioptions_.info_log,
-          "[%s] Stalling writes because we hit soft limit on level %d",
-          name_.c_str(), max_level);
+          "[%s] Stalling writes because of estimated pending compaction "
+          "bytes %" PRIu64,
+          name_.c_str(), vstorage->estimated_compaction_needed_bytes());
     } else {
       write_controller_token_.reset();
     }
diff --git a/src/rocksdb/db/column_family_test.cc b/src/rocksdb/db/column_family_test.cc
index a258b83..b877ea8 100644
--- a/src/rocksdb/db/column_family_test.cc
+++ b/src/rocksdb/db/column_family_test.cc
@@ -23,8 +23,6 @@
 #include "util/sync_point.h"
 #include "utilities/merge_operators.h"
 
-#if !(defined NDEBUG) || !defined(OS_WIN)
-
 namespace rocksdb {
 
 namespace {
@@ -59,6 +57,7 @@ class ColumnFamilyTest : public testing::Test {
     env_ = new EnvCounter(Env::Default());
     dbname_ = test::TmpDir() + "/column_family_test";
     db_options_.create_if_missing = true;
+    db_options_.fail_if_options_file_error = true;
     db_options_.env = env_;
     DestroyDB(dbname_, Options(db_options_, column_family_options_));
   }
@@ -69,7 +68,9 @@ class ColumnFamilyTest : public testing::Test {
 
   void Close() {
     for (auto h : handles_) {
-      delete h;
+      if (h) {
+        delete h;
+      }
     }
     handles_.clear();
     names_.clear();
@@ -721,7 +722,7 @@ TEST_F(ColumnFamilyTest, DifferentWriteBufferSizes) {
   two.max_write_buffer_number = 10;
   two.min_write_buffer_number_to_merge = 3;
   two.max_write_buffer_number_to_maintain = 2;
-  three.write_buffer_size = 4096 * 22 + 2048;
+  three.write_buffer_size = 4096 * 22;
   three.arena_block_size = 4096;
   three.max_write_buffer_number = 10;
   three.min_write_buffer_number_to_merge = 4;
@@ -746,15 +747,15 @@ TEST_F(ColumnFamilyTest, DifferentWriteBufferSizes) {
   env_->SleepForMicroseconds(micros_wait_for_flush);
   AssertNumberOfImmutableMemtables({0, 1, 2, 0});
   AssertCountLiveLogFiles(4);
-  PutRandomData(3, 91, 990);
+  PutRandomData(3, 93, 990);
   env_->SleepForMicroseconds(micros_wait_for_flush);
   AssertNumberOfImmutableMemtables({0, 1, 2, 1});
   AssertCountLiveLogFiles(5);
-  PutRandomData(3, 90, 990);
+  PutRandomData(3, 88, 990);
   env_->SleepForMicroseconds(micros_wait_for_flush);
   AssertNumberOfImmutableMemtables({0, 1, 2, 2});
   AssertCountLiveLogFiles(6);
-  PutRandomData(3, 90, 990);
+  PutRandomData(3, 88, 990);
   env_->SleepForMicroseconds(micros_wait_for_flush);
   AssertNumberOfImmutableMemtables({0, 1, 2, 3});
   AssertCountLiveLogFiles(7);
@@ -766,11 +767,11 @@ TEST_F(ColumnFamilyTest, DifferentWriteBufferSizes) {
   WaitForFlush(2);
   AssertNumberOfImmutableMemtables({0, 1, 0, 3});
   AssertCountLiveLogFiles(9);
-  PutRandomData(3, 90, 990);
+  PutRandomData(3, 88, 990);
   WaitForFlush(3);
   AssertNumberOfImmutableMemtables({0, 1, 0, 0});
   AssertCountLiveLogFiles(10);
-  PutRandomData(3, 90, 990);
+  PutRandomData(3, 88, 990);
   env_->SleepForMicroseconds(micros_wait_for_flush);
   AssertNumberOfImmutableMemtables({0, 1, 0, 1});
   AssertCountLiveLogFiles(11);
@@ -778,9 +779,9 @@ TEST_F(ColumnFamilyTest, DifferentWriteBufferSizes) {
   WaitForFlush(1);
   AssertNumberOfImmutableMemtables({0, 0, 0, 1});
   AssertCountLiveLogFiles(5);
-  PutRandomData(3, 90 * 3, 990);
+  PutRandomData(3, 88 * 3, 990);
   WaitForFlush(3);
-  PutRandomData(3, 90 * 4, 990);
+  PutRandomData(3, 88 * 4, 990);
   WaitForFlush(3);
   AssertNumberOfImmutableMemtables({0, 0, 0, 0});
   AssertCountLiveLogFiles(12);
@@ -1261,14 +1262,93 @@ TEST_F(ColumnFamilyTest, FlushAndDropRaceCondition) {
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
 
+#ifndef ROCKSDB_LITE
+// skipped as persisting options is not supported in ROCKSDB_LITE
+namespace {
+std::atomic<int> test_stage(0);
+const int kMainThreadStartPersistingOptionsFile = 1;
+const int kChildThreadFinishDroppingColumnFamily = 2;
+const int kChildThreadWaitingMainThreadPersistOptions = 3;
+void DropSingleColumnFamily(ColumnFamilyTest* cf_test, int cf_id,
+                            std::vector<Comparator*>* comparators) {
+  while (test_stage < kMainThreadStartPersistingOptionsFile) {
+    Env::Default()->SleepForMicroseconds(100);
+  }
+  cf_test->DropColumnFamilies({cf_id});
+  if ((*comparators)[cf_id]) {
+    delete (*comparators)[cf_id];
+    (*comparators)[cf_id] = nullptr;
+  }
+  test_stage = kChildThreadFinishDroppingColumnFamily;
+}
+}  // namespace
+
+TEST_F(ColumnFamilyTest, CreateAndDropRace) {
+  const int kCfCount = 5;
+  std::vector<ColumnFamilyOptions> cf_opts;
+  std::vector<Comparator*> comparators;
+  for (int i = 0; i < kCfCount; ++i) {
+    cf_opts.emplace_back();
+    comparators.push_back(new test::SimpleSuffixReverseComparator());
+    cf_opts.back().comparator = comparators.back();
+  }
+  db_options_.create_if_missing = true;
+  db_options_.create_missing_column_families = true;
+
+  auto main_thread_id = std::this_thread::get_id();
+
+  rocksdb::SyncPoint::GetInstance()->SetCallBack("PersistRocksDBOptions:start",
+                                                 [&](void* arg) {
+    auto current_thread_id = std::this_thread::get_id();
+    // If it's the main thread hitting this sync-point, then it
+    // will be blocked until some other thread update the test_stage.
+    if (main_thread_id == current_thread_id) {
+      test_stage = kMainThreadStartPersistingOptionsFile;
+      while (test_stage < kChildThreadFinishDroppingColumnFamily) {
+        Env::Default()->SleepForMicroseconds(100);
+      }
+    }
+  });
+
+  rocksdb::SyncPoint::GetInstance()->SetCallBack(
+      "WriteThread::EnterUnbatched:Wait", [&](void* arg) {
+        // This means a thread doing DropColumnFamily() is waiting for
+        // other thread to finish persisting options.
+        // In such case, we update the test_stage to unblock the main thread.
+        test_stage = kChildThreadWaitingMainThreadPersistOptions;
+
+        // Note that based on the test setting, this must not be the
+        // main thread.
+        ASSERT_NE(main_thread_id, std::this_thread::get_id());
+      });
+
+  // Create a database with four column families
+  Open({"default", "one", "two", "three"},
+       {cf_opts[0], cf_opts[1], cf_opts[2], cf_opts[3]});
+
+  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
+
+  // Start a thread that will drop the first column family
+  // and its comparator
+  std::thread drop_cf_thread(DropSingleColumnFamily, this, 1, &comparators);
+
+  DropColumnFamilies({2});
+
+  drop_cf_thread.join();
+  Close();
+  Destroy();
+  rocksdb::SyncPoint::GetInstance()->DisableProcessing();
+  for (auto* comparator : comparators) {
+    if (comparator) {
+      delete comparator;
+    }
+  }
+}
+#endif  // !ROCKSDB_LITE
+
 }  // namespace rocksdb
-#endif
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
 }
diff --git a/src/rocksdb/db/compact_files_test.cc b/src/rocksdb/db/compact_files_test.cc
index cbd9d7a..b2a131e 100644
--- a/src/rocksdb/db/compact_files_test.cc
+++ b/src/rocksdb/db/compact_files_test.cc
@@ -12,6 +12,7 @@
 #include "rocksdb/db.h"
 #include "rocksdb/env.h"
 #include "util/string_util.h"
+#include "util/sync_point.h"
 #include "util/testharness.h"
 
 namespace rocksdb {
@@ -53,6 +54,62 @@ class FlushedFileCollector : public EventListener {
   std::mutex mutex_;
 };
 
+TEST_F(CompactFilesTest, L0ConflictsFiles) {
+  Options options;
+  // to trigger compaction more easily
+  const int kWriteBufferSize = 10000;
+  const int kLevel0Trigger = 2;
+  options.create_if_missing = true;
+  options.compaction_style = kCompactionStyleLevel;
+  // Small slowdown and stop trigger for experimental purpose.
+  options.level0_slowdown_writes_trigger = 20;
+  options.level0_stop_writes_trigger = 20;
+  options.level0_stop_writes_trigger = 20;
+  options.write_buffer_size = kWriteBufferSize;
+  options.level0_file_num_compaction_trigger = kLevel0Trigger;
+  options.compression = kNoCompression;
+
+  DB* db = nullptr;
+  DestroyDB(db_name_, options);
+  Status s = DB::Open(options, db_name_, &db);
+  assert(s.ok());
+  assert(db);
+
+  rocksdb::SyncPoint::GetInstance()->LoadDependency({
+      {"CompactFilesImpl:0", "BackgroundCallCompaction:0"},
+      {"BackgroundCallCompaction:1", "CompactFilesImpl:1"},
+  });
+  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
+
+  // create couple files
+  // Background compaction starts and waits in BackgroundCallCompaction:0
+  for (int i = 0; i < kLevel0Trigger * 4; ++i) {
+    db->Put(WriteOptions(), ToString(i), "");
+    db->Put(WriteOptions(), ToString(100 - i), "");
+    db->Flush(FlushOptions());
+  }
+
+  rocksdb::ColumnFamilyMetaData meta;
+  db->GetColumnFamilyMetaData(&meta);
+  std::string file1;
+  for (auto& file : meta.levels[0].files) {
+    ASSERT_EQ(0, meta.levels[0].level);
+    if (file1 == "") {
+      file1 = file.db_path + "/" + file.name;
+    } else {
+      std::string file2 = file.db_path + "/" + file.name;
+      // Another thread starts a compact files and creates an L0 compaction
+      // The background compaction then notices that there is an L0 compaction
+      // already in progress and doesn't do an L0 compaction
+      // Once the background compaction finishes, the compact files finishes
+      ASSERT_OK(
+          db->CompactFiles(rocksdb::CompactionOptions(), {file1, file2}, 0));
+      break;
+    }
+  }
+  delete db;
+}
+
 TEST_F(CompactFilesTest, ObsoleteFiles) {
   Options options;
   // to trigger compaction more easily
diff --git a/src/rocksdb/db/compaction.cc b/src/rocksdb/db/compaction.cc
index bb80665..43b0b37 100644
--- a/src/rocksdb/db/compaction.cc
+++ b/src/rocksdb/db/compaction.cc
@@ -128,8 +128,8 @@ bool Compaction::TEST_IsBottommostLevel(
 bool Compaction::IsFullCompaction(
     VersionStorageInfo* vstorage,
     const std::vector<CompactionInputFiles>& inputs) {
-  int num_files_in_compaction = 0;
-  int total_num_files = 0;
+  size_t num_files_in_compaction = 0;
+  size_t total_num_files = 0;
   for (int l = 0; l < vstorage->num_levels(); l++) {
     total_num_files += vstorage->NumLevelFiles(l);
   }
@@ -439,6 +439,7 @@ std::unique_ptr<CompactionFilter> Compaction::CreateCompactionFilter() const {
   CompactionFilter::Context context;
   context.is_full_compaction = is_full_compaction_;
   context.is_manual_compaction = is_manual_compaction_;
+  context.column_family_id = cfd_->GetID();
   return cfd_->ioptions()->compaction_filter_factory->CreateCompactionFilter(
       context);
 }
diff --git a/src/rocksdb/db/compaction.h b/src/rocksdb/db/compaction.h
index 36c62ff..0bf63e6 100644
--- a/src/rocksdb/db/compaction.h
+++ b/src/rocksdb/db/compaction.h
@@ -210,6 +210,14 @@ class Compaction {
       int output_level, VersionStorageInfo* vstorage,
       const std::vector<CompactionInputFiles>& inputs);
 
+  TablePropertiesCollection GetOutputTableProperties() const {
+    return output_table_properties_;
+  }
+
+  void SetOutputTableProperties(TablePropertiesCollection tp) {
+    output_table_properties_ = std::move(tp);
+  }
+
  private:
   // mark (or clear) all files that are being compacted
   void MarkFilesBeingCompacted(bool mark_as_compacted);
@@ -273,6 +281,9 @@ class Compaction {
 
   // Does input compression match the output compression?
   bool InputCompressionMatchesOutput() const;
+
+  // table properties of output files
+  TablePropertiesCollection output_table_properties_;
 };
 
 // Utility function
diff --git a/src/rocksdb/db/compaction_iterator.cc b/src/rocksdb/db/compaction_iterator.cc
index d242291..2ae5750 100644
--- a/src/rocksdb/db/compaction_iterator.cc
+++ b/src/rocksdb/db/compaction_iterator.cc
@@ -6,18 +6,21 @@
 //  of patent rights can be found in the PATENTS file in the same directory.
 
 #include "db/compaction_iterator.h"
+#include "table/internal_iterator.h"
 
 namespace rocksdb {
 
 CompactionIterator::CompactionIterator(
-    Iterator* input, const Comparator* cmp, MergeHelper* merge_helper,
+    InternalIterator* input, const Comparator* cmp, MergeHelper* merge_helper,
     SequenceNumber last_sequence, std::vector<SequenceNumber>* snapshots,
-    Env* env, bool expect_valid_internal_key, Compaction* compaction,
+    SequenceNumber earliest_write_conflict_snapshot, Env* env,
+    bool expect_valid_internal_key, Compaction* compaction,
     const CompactionFilter* compaction_filter, LogBuffer* log_buffer)
     : input_(input),
       cmp_(cmp),
       merge_helper_(merge_helper),
       snapshots_(snapshots),
+      earliest_write_conflict_snapshot_(earliest_write_conflict_snapshot),
       env_(env),
       expect_valid_internal_key_(expect_valid_internal_key),
       compaction_(compaction),
@@ -41,6 +44,11 @@ CompactionIterator::CompactionIterator(
     earliest_snapshot_ = snapshots_->at(0);
     latest_snapshot_ = snapshots_->back();
   }
+  if (compaction_filter_ != nullptr && compaction_filter_->IgnoreSnapshots()) {
+    ignore_snapshots_ = true;
+  } else {
+    ignore_snapshots_ = false;
+  }
 }
 
 void CompactionIterator::ResetRecordCounts() {
@@ -89,6 +97,11 @@ void CompactionIterator::Next() {
     NextFromInput();
   }
 
+  if (valid_) {
+    // Record that we've ouputted a record for the current key.
+    has_outputted_key_ = true;
+  }
+
   PrepareOutput();
 }
 
@@ -135,11 +148,14 @@ void CompactionIterator::NextFromInput() {
       key_ = current_key_.SetKey(key_, &ikey_);
       current_user_key_ = ikey_.user_key;
       has_current_user_key_ = true;
+      has_outputted_key_ = false;
       current_user_key_sequence_ = kMaxSequenceNumber;
       current_user_key_snapshot_ = 0;
+
       // apply the compaction filter to the first occurrence of the user key
       if (compaction_filter_ != nullptr && ikey_.type == kTypeValue &&
-          (visible_at_tip_ || ikey_.sequence > latest_snapshot_)) {
+          (visible_at_tip_ || ikey_.sequence > latest_snapshot_ ||
+           ignore_snapshots_)) {
         // If the user has specified a compaction filter and the sequence
         // number is greater than any external snapshot, then invoke the
         // filter. If the return value of the compaction filter is true,
@@ -169,6 +185,9 @@ void CompactionIterator::NextFromInput() {
     } else {
       // Update the current key to reflect the new sequence number/type without
       // copying the user key.
+      // TODO(rven): Compaction filter does not process keys in this path
+      // Need to have the compaction filter process multiple versions
+      // if we have versions on both sides of a snapshot
       current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
       key_ = current_key_.GetKey();
       ikey_.user_key = current_key_.GetUserKey();
@@ -186,31 +205,99 @@ void CompactionIterator::NextFromInput() {
         visible_at_tip_ ? visible_at_tip_ : findEarliestVisibleSnapshot(
                                                 ikey_.sequence, &prev_snapshot);
 
-    if (ikey_.type == kTypeSingleDeletion) {
+    if (clear_and_output_next_key_) {
+      // In the previous iteration we encountered a single delete that we could
+      // not compact out.  We will keep this Put, but can drop it's data.
+      // (See Optimization 3, below.)
+      assert(ikey_.type == kTypeValue);
+      assert(current_user_key_snapshot_ == last_snapshot);
+
+      value_.clear();
+      valid_ = true;
+      clear_and_output_next_key_ = false;
+    } else if (ikey_.type == kTypeSingleDeletion) {
+      // We can compact out a SingleDelete if:
+      // 1) We encounter the corresponding PUT -OR- we know that this key
+      //    doesn't appear past this output level
+      // =AND=
+      // 2) We've already returned a record in this snapshot -OR-
+      //    there are no earlier earliest_write_conflict_snapshot.
+      //
+      // Rule 1 is needed for SingleDelete correctness.  Rule 2 is needed to
+      // allow Transactions to do write-conflict checking (if we compacted away
+      // all keys, then we wouldn't know that a write happened in this
+      // snapshot).  If there is no earlier snapshot, then we know that there
+      // are no active transactions that need to know about any writes.
+      //
+      // Optimization 3:
+      // If we encounter a SingleDelete followed by a PUT and Rule 2 is NOT
+      // true, then we must output a SingleDelete.  In this case, we will decide
+      // to also output the PUT.  While we are compacting less by outputting the
+      // PUT now, hopefully this will lead to better compaction in the future
+      // when Rule 2 is later true (Ie, We are hoping we can later compact out
+      // both the SingleDelete and the Put, while we couldn't if we only
+      // outputted the SingleDelete now).
+      // In this case, we can save space by removing the PUT's value as it will
+      // never be read.
+      //
+      // Deletes and Merges are not supported on the same key that has a
+      // SingleDelete as it is not possible to correctly do any partial
+      // compaction of such a combination of operations.  The result of mixing
+      // those operations for a given key is documented as being undefined.  So
+      // we can choose how to handle such a combinations of operations.  We will
+      // try to compact out as much as we can in these cases.
+
+      // The easiest way to process a SingleDelete during iteration is to peek
+      // ahead at the next key.
       ParsedInternalKey next_ikey;
       input_->Next();
 
-      // Check whether the current key is valid, not corrupt and the same
+      // Check whether the next key exists, is not corrupt, and is the same key
       // as the single delete.
       if (input_->Valid() && ParseInternalKey(input_->key(), &next_ikey) &&
           cmp_->Equal(ikey_.user_key, next_ikey.user_key)) {
-        // Mixing single deletes and merges is not supported. Consecutive
-        // single deletes are not valid.
-        if (next_ikey.type != kTypeValue) {
-          assert(false);
-          status_ =
-              Status::InvalidArgument("Put expected after single delete.");
-          break;
-        }
-
-        // Check whether the current key belongs to the same snapshot as the
-        // single delete.
+        // Check whether the next key belongs to the same snapshot as the
+        // SingleDelete.
         if (prev_snapshot == 0 || next_ikey.sequence > prev_snapshot) {
-          // Found the matching value, we can drop the single delete and the
-          // value.
-          ++iter_stats_.num_record_drop_hidden;
-          ++iter_stats_.num_record_drop_obsolete;
-          input_->Next();
+          if (next_ikey.type == kTypeSingleDeletion) {
+            // We encountered two SingleDeletes in a row.  This could be due to
+            // unexpected user input.
+            // Skip the first SingleDelete and let the next iteration decide how
+            // to handle the second SingleDelete
+
+            // First SingleDelete has been skipped since we already called
+            // input_->Next().
+            ++iter_stats_.num_record_drop_obsolete;
+          } else if ((ikey_.sequence <= earliest_write_conflict_snapshot_) ||
+                     has_outputted_key_) {
+            // Found a matching value, we can drop the single delete and the
+            // value.  It is safe to drop both records since we've already
+            // outputted a key in this snapshot, or there is no earlier
+            // snapshot (Rule 2 above).
+
+            // Note: it doesn't matter whether the second key is a Put or if it
+            // is an unexpected Merge or Delete.  We will compact it out
+            // either way.
+            ++iter_stats_.num_record_drop_hidden;
+            ++iter_stats_.num_record_drop_obsolete;
+            // Already called input_->Next() once.  Call it a second time to
+            // skip past the second key.
+            input_->Next();
+          } else {
+            // Found a matching value, but we cannot drop both keys since
+            // there is an earlier snapshot and we need to leave behind a record
+            // to know that a write happened in this snapshot (Rule 2 above).
+            // Clear the value and output the SingleDelete. (The value will be
+            // outputted on the next iteration.)
+            ++iter_stats_.num_record_drop_hidden;
+
+            // Setting valid_ to true will output the current SingleDelete
+            valid_ = true;
+
+            // Set up the Put to be outputted in the next iteration.
+            // (Optimization 3).
+            clear_and_output_next_key_ = true;
+          }
         } else {
           // We hit the next snapshot without hitting a put, so the iterator
           // returns the single delete.
@@ -225,11 +312,14 @@ void CompactionIterator::NextFromInput() {
         // iteration. If the next key is corrupt, we return before the
         // comparison, so the value of has_current_user_key does not matter.
         has_current_user_key_ = false;
-        if (compaction_ != nullptr &&
+        if (compaction_ != nullptr && ikey_.sequence <= earliest_snapshot_ &&
             compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
                                                        &level_ptrs_)) {
+          // Key doesn't exist outside of this range.
+          // Can compact out this SingleDelete.
           ++iter_stats_.num_record_drop_obsolete;
         } else {
+          // Output SingleDelete
           valid_ = true;
         }
       }
diff --git a/src/rocksdb/db/compaction_iterator.h b/src/rocksdb/db/compaction_iterator.h
index da242f6..cc8e4a5 100644
--- a/src/rocksdb/db/compaction_iterator.h
+++ b/src/rocksdb/db/compaction_iterator.h
@@ -37,9 +37,10 @@ struct CompactionIteratorStats {
 
 class CompactionIterator {
  public:
-  CompactionIterator(Iterator* input, const Comparator* cmp,
+  CompactionIterator(InternalIterator* input, const Comparator* cmp,
                      MergeHelper* merge_helper, SequenceNumber last_sequence,
-                     std::vector<SequenceNumber>* snapshots, Env* env,
+                     std::vector<SequenceNumber>* snapshots,
+                     SequenceNumber earliest_write_conflict_snapshot, Env* env,
                      bool expect_valid_internal_key,
                      Compaction* compaction = nullptr,
                      const CompactionFilter* compaction_filter = nullptr,
@@ -84,10 +85,11 @@ class CompactionIterator {
   inline SequenceNumber findEarliestVisibleSnapshot(
       SequenceNumber in, SequenceNumber* prev_snapshot);
 
-  Iterator* input_;
+  InternalIterator* input_;
   const Comparator* cmp_;
   MergeHelper* merge_helper_;
   const std::vector<SequenceNumber>* snapshots_;
+  const SequenceNumber earliest_write_conflict_snapshot_;
   Env* env_;
   bool expect_valid_internal_key_;
   Compaction* compaction_;
@@ -98,6 +100,7 @@ class CompactionIterator {
   SequenceNumber visible_at_tip_;
   SequenceNumber earliest_snapshot_;
   SequenceNumber latest_snapshot_;
+  bool ignore_snapshots_;
 
   // State
   //
@@ -124,6 +127,14 @@ class CompactionIterator {
   Slice current_user_key_;
   SequenceNumber current_user_key_sequence_;
   SequenceNumber current_user_key_snapshot_;
+
+  // True if the iterator has already returned a record for the current key.
+  bool has_outputted_key_ = false;
+
+  // truncated the value of the next key and output it without applying any
+  // compaction rules.  This is used for outputting a put after a single delete.
+  bool clear_and_output_next_key_ = false;
+
   MergeOutputIterator merge_out_iter_;
   std::string compaction_filter_value_;
   // "level_ptrs" holds indices that remember which file of an associated
diff --git a/src/rocksdb/db/compaction_iterator_test.cc b/src/rocksdb/db/compaction_iterator_test.cc
index 1148c2a..a59f567 100644
--- a/src/rocksdb/db/compaction_iterator_test.cc
+++ b/src/rocksdb/db/compaction_iterator_test.cc
@@ -20,9 +20,9 @@ class CompactionIteratorTest : public testing::Test {
                                         nullptr, 0U, false, 0));
     iter_.reset(new test::VectorIterator(ks, vs));
     iter_->SeekToFirst();
-    c_iter_.reset(new CompactionIterator(iter_.get(), cmp_, merge_helper_.get(),
-                                         last_sequence, &snapshots_,
-                                         Env::Default(), false));
+    c_iter_.reset(new CompactionIterator(
+        iter_.get(), cmp_, merge_helper_.get(), last_sequence, &snapshots_,
+        kMaxSequenceNumber, Env::Default(), false));
   }
 
   const Comparator* cmp_;
diff --git a/src/rocksdb/db/compaction_job.cc b/src/rocksdb/db/compaction_job.cc
index 4d6656d..4806eff 100644
--- a/src/rocksdb/db/compaction_job.cc
+++ b/src/rocksdb/db/compaction_job.cc
@@ -77,6 +77,7 @@ struct CompactionJob::SubcompactionState {
   struct Output {
     FileMetaData meta;
     bool finished;
+    std::shared_ptr<const TableProperties> table_properties;
   };
 
   // State kept for output being generated
@@ -211,6 +212,7 @@ CompactionJob::CompactionJob(
     std::atomic<bool>* shutting_down, LogBuffer* log_buffer,
     Directory* db_directory, Directory* output_directory, Statistics* stats,
     std::vector<SequenceNumber> existing_snapshots,
+    SequenceNumber earliest_write_conflict_snapshot,
     std::shared_ptr<Cache> table_cache, EventLogger* event_logger,
     bool paranoid_file_checks, bool measure_io_stats, const std::string& dbname,
     CompactionJobStats* compaction_job_stats)
@@ -229,6 +231,7 @@ CompactionJob::CompactionJob(
       output_directory_(output_directory),
       stats_(stats),
       existing_snapshots_(std::move(existing_snapshots)),
+      earliest_write_conflict_snapshot_(earliest_write_conflict_snapshot),
       table_cache_(std::move(table_cache)),
       event_logger_(event_logger),
       paranoid_file_checks_(paranoid_file_checks),
@@ -487,6 +490,16 @@ Status CompactionJob::Run() {
     }
   }
 
+  TablePropertiesCollection tp;
+  for (const auto& state : compact_->sub_compact_states) {
+    for (const auto& output : state.outputs) {
+      auto fn = TableFileName(db_options_.db_paths, output.meta.fd.GetNumber(),
+                              output.meta.fd.GetPathId());
+      tp[fn] = output.table_properties;
+    }
+  }
+  compact_->compaction->SetOutputTableProperties(std::move(tp));
+
   // Finish up all book-keeping to unify the subcompaction results
   AggregateStatistics();
   UpdateCompactionStats();
@@ -574,7 +587,7 @@ Status CompactionJob::Install(const MutableCFOptions& mutable_cf_options,
 
 void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
   assert(sub_compact != nullptr);
-  std::unique_ptr<Iterator> input(
+  std::unique_ptr<InternalIterator> input(
       versions_->MakeInputIterator(sub_compact->compaction));
 
   AutoThreadOperationStageUpdater stage_updater(
@@ -590,10 +603,10 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
   if (measure_io_stats_) {
     prev_perf_level = GetPerfLevel();
     SetPerfLevel(PerfLevel::kEnableTime);
-    prev_write_nanos = iostats_context.write_nanos;
-    prev_fsync_nanos = iostats_context.fsync_nanos;
-    prev_range_sync_nanos = iostats_context.range_sync_nanos;
-    prev_prepare_write_nanos = iostats_context.prepare_write_nanos;
+    prev_write_nanos = IOSTATS(write_nanos);
+    prev_fsync_nanos = IOSTATS(fsync_nanos);
+    prev_range_sync_nanos = IOSTATS(range_sync_nanos);
+    prev_prepare_write_nanos = IOSTATS(prepare_write_nanos);
   }
 
   ColumnFamilyData* cfd = sub_compact->compaction->column_family_data();
@@ -627,8 +640,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
   Status status;
   sub_compact->c_iter.reset(new CompactionIterator(
       input.get(), cfd->user_comparator(), &merge, versions_->LastSequence(),
-      &existing_snapshots_, env_, false, sub_compact->compaction,
-      compaction_filter));
+      &existing_snapshots_, earliest_write_conflict_snapshot_, env_, false,
+      sub_compact->compaction, compaction_filter));
   auto c_iter = sub_compact->c_iter.get();
   c_iter->SeekToFirst();
   const auto& c_iter_stats = c_iter->iter_stats();
@@ -717,13 +730,13 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
 
   if (measure_io_stats_) {
     sub_compact->compaction_job_stats.file_write_nanos +=
-        iostats_context.write_nanos - prev_write_nanos;
+        IOSTATS(write_nanos) - prev_write_nanos;
     sub_compact->compaction_job_stats.file_fsync_nanos +=
-        iostats_context.fsync_nanos - prev_fsync_nanos;
+        IOSTATS(fsync_nanos) - prev_fsync_nanos;
     sub_compact->compaction_job_stats.file_range_sync_nanos +=
-        iostats_context.range_sync_nanos - prev_range_sync_nanos;
+        IOSTATS(range_sync_nanos) - prev_range_sync_nanos;
     sub_compact->compaction_job_stats.file_prepare_write_nanos +=
-        iostats_context.prepare_write_nanos - prev_prepare_write_nanos;
+        IOSTATS(prepare_write_nanos) - prev_prepare_write_nanos;
     if (prev_perf_level != PerfLevel::kEnableTime) {
       SetPerfLevel(prev_perf_level);
     }
@@ -800,7 +813,7 @@ Status CompactionJob::FinishCompactionOutputFile(
   if (s.ok() && current_entries > 0) {
     // Verify that the table is usable
     ColumnFamilyData* cfd = sub_compact->compaction->column_family_data();
-    Iterator* iter = cfd->table_cache()->NewIterator(
+    InternalIterator* iter = cfd->table_cache()->NewIterator(
         ReadOptions(), env_options_, cfd->internal_comparator(), meta->fd,
         nullptr, cfd->internal_stats()->GetFileReadHist(
                      compact_->compaction->output_level()),
@@ -814,7 +827,10 @@ Status CompactionJob::FinishCompactionOutputFile(
 
     delete iter;
     if (s.ok()) {
-      TableFileCreationInfo info(sub_compact->builder->GetTableProperties());
+      auto tp = sub_compact->builder->GetTableProperties();
+      sub_compact->current_output()->table_properties =
+          std::make_shared<TableProperties>(tp);
+      TableFileCreationInfo info(std::move(tp));
       info.db_name = dbname_;
       info.cf_name = cfd->GetName();
       info.file_path =
@@ -897,7 +913,7 @@ Status CompactionJob::OpenCompactionOutputFile(
   unique_ptr<WritableFile> writable_file;
   std::string fname = TableFileName(db_options_.db_paths, file_number,
                                     sub_compact->compaction->output_path_id());
-  Status s = env_->NewWritableFile(fname, &writable_file, env_options_);
+  Status s = NewWritableFile(env_, fname, &writable_file, env_options_);
   if (!s.ok()) {
     Log(InfoLogLevel::ERROR_LEVEL, db_options_.info_log,
         "[%s] [JOB %d] OpenCompactionOutputFiles for table #%" PRIu64
@@ -927,8 +943,8 @@ Status CompactionJob::OpenCompactionOutputFile(
       cfd->ioptions()->optimize_filters_for_hits && bottommost_level_;
   sub_compact->builder.reset(NewTableBuilder(
       *cfd->ioptions(), cfd->internal_comparator(),
-      cfd->int_tbl_prop_collector_factories(), sub_compact->outfile.get(),
-      sub_compact->compaction->output_compression(),
+      cfd->int_tbl_prop_collector_factories(), cfd->GetID(),
+      sub_compact->outfile.get(), sub_compact->compaction->output_compression(),
       cfd->ioptions()->compression_opts, skip_filters));
   LogFlush(db_options_.info_log);
   return s;
diff --git a/src/rocksdb/db/compaction_job.h b/src/rocksdb/db/compaction_job.h
index 1054fec..e4d5244 100644
--- a/src/rocksdb/db/compaction_job.h
+++ b/src/rocksdb/db/compaction_job.h
@@ -35,9 +35,9 @@
 #include "rocksdb/env.h"
 #include "rocksdb/memtablerep.h"
 #include "rocksdb/transaction_log.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/autovector.h"
 #include "util/event_logger.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/stop_watch.h"
 #include "util/thread_local.h"
 
@@ -58,6 +58,7 @@ class CompactionJob {
                 Directory* db_directory, Directory* output_directory,
                 Statistics* stats,
                 std::vector<SequenceNumber> existing_snapshots,
+                SequenceNumber earliest_write_conflict_snapshot,
                 std::shared_ptr<Cache> table_cache, EventLogger* event_logger,
                 bool paranoid_file_checks, bool measure_io_stats,
                 const std::string& dbname,
@@ -134,6 +135,12 @@ class CompactionJob {
   // entirely within s1 and s2, then the earlier version of k1 can be safely
   // deleted because that version is not visible in any snapshot.
   std::vector<SequenceNumber> existing_snapshots_;
+
+  // This is the earliest snapshot that could be used for write-conflict
+  // checking by a transaction.  For any user-key newer than this snapshot, we
+  // should make sure not to remove evidence that a write occurred.
+  SequenceNumber earliest_write_conflict_snapshot_;
+
   std::shared_ptr<Cache> table_cache_;
 
   EventLogger* event_logger_;
diff --git a/src/rocksdb/db/compaction_job_stats_test.cc b/src/rocksdb/db/compaction_job_stats_test.cc
index 8641c8a..c7d8eb8 100644
--- a/src/rocksdb/db/compaction_job_stats_test.cc
+++ b/src/rocksdb/db/compaction_job_stats_test.cc
@@ -27,6 +27,7 @@
 #include "db/job_context.h"
 #include "db/version_set.h"
 #include "db/write_batch_internal.h"
+#include "memtable/hash_linklist_rep.h"
 #include "port/stack_trace.h"
 #include "rocksdb/cache.h"
 #include "rocksdb/compaction_filter.h"
@@ -47,14 +48,13 @@
 #include "table/block_based_table_factory.h"
 #include "table/mock_table.h"
 #include "table/plain_table_factory.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/compression.h"
 #include "util/hash.h"
-#include "util/hash_linklist_rep.h"
 #include "util/logging.h"
 #include "util/mock_env.h"
 #include "util/mutexlock.h"
 #include "util/rate_limiter.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/statistics.h"
 #include "util/string_util.h"
 #include "util/sync_point.h"
@@ -64,7 +64,7 @@
 #include "util/xfunc.h"
 #include "utilities/merge_operators.h"
 
-#if !defined(IOS_CROSS_COMPILE) && (!defined(NDEBUG) || !defined(OS_WIN))
+#if !defined(IOS_CROSS_COMPILE)
 #ifndef ROCKSDB_LITE
 namespace rocksdb {
 
diff --git a/src/rocksdb/db/compaction_job_test.cc b/src/rocksdb/db/compaction_job_test.cc
index b1a8909..0746b4c 100644
--- a/src/rocksdb/db/compaction_job_test.cc
+++ b/src/rocksdb/db/compaction_job_test.cc
@@ -3,6 +3,8 @@
 //  LICENSE file in the root directory of this source tree. An additional grant
 //  of patent rights can be found in the PATENTS file in the same directory.
 
+#ifndef ROCKSDB_LITE
+
 #include <algorithm>
 #include <map>
 #include <string>
@@ -196,7 +198,7 @@ class CompactionJobTest : public testing::Test {
     unique_ptr<WritableFileWriter> file_writer(
         new WritableFileWriter(std::move(file), env_options_));
     {
-      log::Writer log(std::move(file_writer));
+      log::Writer log(std::move(file_writer), 0, false);
       std::string record;
       new_db.EncodeTo(&record);
       s = log.AddRecord(record);
@@ -215,9 +217,11 @@ class CompactionJobTest : public testing::Test {
     cfd_ = versions_->GetColumnFamilySet()->GetDefault();
   }
 
-  void RunCompaction(const std::vector<std::vector<FileMetaData*>>& input_files,
-                     const stl_wrappers::KVMap& expected_results,
-                     const std::vector<SequenceNumber>& snapshots = {}) {
+  void RunCompaction(
+      const std::vector<std::vector<FileMetaData*>>& input_files,
+      const stl_wrappers::KVMap& expected_results,
+      const std::vector<SequenceNumber>& snapshots = {},
+      SequenceNumber earliest_write_conflict_snapshot = kMaxSequenceNumber) {
     auto cfd = versions_->GetColumnFamilySet()->GetDefault();
 
     size_t num_input_files = 0;
@@ -241,11 +245,11 @@ class CompactionJobTest : public testing::Test {
     LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, db_options_.info_log.get());
     mutex_.Lock();
     EventLogger event_logger(db_options_.info_log.get());
-    CompactionJob compaction_job(0, &compaction, db_options_, env_options_,
-                                 versions_.get(), &shutting_down_, &log_buffer,
-                                 nullptr, nullptr, nullptr, snapshots,
-                                 table_cache_, &event_logger, false, false,
-                                 dbname_, &compaction_job_stats_);
+    CompactionJob compaction_job(
+        0, &compaction, db_options_, env_options_, versions_.get(),
+        &shutting_down_, &log_buffer, nullptr, nullptr, nullptr, snapshots,
+        earliest_write_conflict_snapshot, table_cache_, &event_logger, false,
+        false, dbname_, &compaction_job_stats_);
 
     VerifyInitializationOfCompactionJobStats(compaction_job_stats_);
 
@@ -557,34 +561,144 @@ TEST_F(CompactionJobTest, SimpleSingleDelete) {
 TEST_F(CompactionJobTest, SingleDeleteSnapshots) {
   NewDB();
 
-  auto file1 = mock::MakeMockFile({{KeyStr("A", 12U, kTypeSingleDeletion), ""},
-                                   {KeyStr("a", 12U, kTypeSingleDeletion), ""},
-                                   {KeyStr("b", 21U, kTypeSingleDeletion), ""},
-                                   {KeyStr("c", 22U, kTypeSingleDeletion), ""},
-                                   {KeyStr("d", 9U, kTypeSingleDeletion), ""}});
+  auto file1 = mock::MakeMockFile({
+      {KeyStr("A", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("a", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("b", 21U, kTypeSingleDeletion), ""},
+      {KeyStr("c", 22U, kTypeSingleDeletion), ""},
+      {KeyStr("d", 9U, kTypeSingleDeletion), ""},
+      {KeyStr("f", 21U, kTypeSingleDeletion), ""},
+      {KeyStr("j", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("j", 9U, kTypeSingleDeletion), ""},
+      {KeyStr("k", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("k", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("l", 3U, kTypeSingleDeletion), ""},
+      {KeyStr("l", 2U, kTypeSingleDeletion), ""},
+  });
   AddMockFile(file1);
 
-  auto file2 = mock::MakeMockFile({{KeyStr("0", 2U, kTypeSingleDeletion), ""},
-                                   {KeyStr("a", 11U, kTypeValue), "val1"},
-                                   {KeyStr("b", 11U, kTypeValue), "val2"},
-                                   {KeyStr("c", 21U, kTypeValue), "val3"},
-                                   {KeyStr("d", 8U, kTypeValue), "val4"},
-                                   {KeyStr("e", 2U, kTypeSingleDeletion), ""}});
+  auto file2 = mock::MakeMockFile({
+      {KeyStr("0", 2U, kTypeSingleDeletion), ""},
+      {KeyStr("a", 11U, kTypeValue), "val1"},
+      {KeyStr("b", 11U, kTypeValue), "val2"},
+      {KeyStr("c", 21U, kTypeValue), "val3"},
+      {KeyStr("d", 8U, kTypeValue), "val4"},
+      {KeyStr("e", 2U, kTypeSingleDeletion), ""},
+      {KeyStr("f", 1U, kTypeValue), "val1"},
+      {KeyStr("g", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("h", 2U, kTypeSingleDeletion), ""},
+      {KeyStr("m", 12U, kTypeValue), "val1"},
+      {KeyStr("m", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("m", 8U, kTypeValue), "val2"},
+  });
   AddMockFile(file2);
 
-  auto file3 = mock::MakeMockFile({{KeyStr("A", 1U, kTypeValue), "val"},
-                                   {KeyStr("e", 1U, kTypeValue), "val"}});
+  auto file3 = mock::MakeMockFile({
+      {KeyStr("A", 1U, kTypeValue), "val"},
+      {KeyStr("e", 1U, kTypeValue), "val"},
+  });
   AddMockFile(file3, 2);
 
-  auto expected_results =
-      mock::MakeMockFile({{KeyStr("A", 12U, kTypeSingleDeletion), ""},
-                          {KeyStr("b", 21U, kTypeSingleDeletion), ""},
-                          {KeyStr("b", 11U, kTypeValue), "val2"},
-                          {KeyStr("e", 2U, kTypeSingleDeletion), ""}});
+  auto expected_results = mock::MakeMockFile({
+      {KeyStr("A", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("a", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("a", 11U, kTypeValue), ""},
+      {KeyStr("b", 21U, kTypeSingleDeletion), ""},
+      {KeyStr("b", 11U, kTypeValue), "val2"},
+      {KeyStr("c", 22U, kTypeSingleDeletion), ""},
+      {KeyStr("c", 21U, kTypeValue), ""},
+      {KeyStr("e", 2U, kTypeSingleDeletion), ""},
+      {KeyStr("f", 21U, kTypeSingleDeletion), ""},
+      {KeyStr("f", 1U, kTypeValue), "val1"},
+      {KeyStr("g", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("j", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("k", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("m", 12U, kTypeValue), "val1"},
+      {KeyStr("m", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("m", 8U, kTypeValue), "val2"},
+  });
 
   SetLastSequence(22U);
   auto files = cfd_->current()->storage_info()->LevelFiles(0);
-  RunCompaction({files}, expected_results, {10U, 20U});
+  RunCompaction({files}, expected_results, {10U, 20U}, 10U);
+}
+
+TEST_F(CompactionJobTest, EarliestWriteConflictSnapshot) {
+  NewDB();
+
+  // Test multiple snapshots where the earliest snapshot is not a
+  // write-conflic-snapshot.
+
+  auto file1 = mock::MakeMockFile({
+      {KeyStr("A", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("A", 23U, kTypeValue), "val"},
+      {KeyStr("B", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("B", 23U, kTypeValue), "val"},
+      {KeyStr("D", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 32U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 31U, kTypeValue), "val"},
+      {KeyStr("G", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 23U, kTypeValue), "val2"},
+      {KeyStr("H", 31U, kTypeValue), "val"},
+      {KeyStr("H", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("H", 23U, kTypeValue), "val"},
+      {KeyStr("I", 35U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 34U, kTypeValue), "val2"},
+      {KeyStr("I", 33U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 32U, kTypeValue), "val3"},
+      {KeyStr("I", 31U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 34U, kTypeValue), "val"},
+      {KeyStr("J", 33U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 25U, kTypeValue), "val2"},
+      {KeyStr("J", 24U, kTypeSingleDeletion), ""},
+  });
+  AddMockFile(file1);
+
+  auto file2 = mock::MakeMockFile({
+      {KeyStr("A", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("A", 13U, kTypeValue), "val2"},
+      {KeyStr("C", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("C", 13U, kTypeValue), "val"},
+      {KeyStr("E", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("F", 4U, kTypeSingleDeletion), ""},
+      {KeyStr("F", 3U, kTypeValue), "val"},
+      {KeyStr("G", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 13U, kTypeValue), "val3"},
+      {KeyStr("H", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("H", 13U, kTypeValue), "val2"},
+      {KeyStr("I", 13U, kTypeValue), "val4"},
+      {KeyStr("I", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 11U, kTypeValue), "val5"},
+      {KeyStr("J", 15U, kTypeValue), "val3"},
+      {KeyStr("J", 14U, kTypeSingleDeletion), ""},
+  });
+  AddMockFile(file2);
+
+  auto expected_results = mock::MakeMockFile({
+      {KeyStr("A", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("A", 23U, kTypeValue), ""},
+      {KeyStr("B", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("B", 23U, kTypeValue), ""},
+      {KeyStr("D", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("E", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 32U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 31U, kTypeValue), ""},
+      {KeyStr("H", 31U, kTypeValue), "val"},
+      {KeyStr("I", 35U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 34U, kTypeValue), ""},
+      {KeyStr("I", 31U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 13U, kTypeValue), "val4"},
+      {KeyStr("J", 34U, kTypeValue), "val"},
+      {KeyStr("J", 33U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 25U, kTypeValue), "val2"},
+      {KeyStr("J", 24U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 15U, kTypeValue), "val3"},
+      {KeyStr("J", 14U, kTypeSingleDeletion), ""},
+  });
+
+  SetLastSequence(24U);
+  auto files = cfd_->current()->storage_info()->LevelFiles(0);
+  RunCompaction({files}, expected_results, {10U, 20U, 30U}, 20U);
 }
 
 TEST_F(CompactionJobTest, SingleDeleteZeroSeq) {
@@ -614,9 +728,22 @@ TEST_F(CompactionJobTest, MultiSingleDelete) {
   // Tests three scenarios involving multiple single delete/put pairs:
   //
   // A: Put Snapshot SDel Put SDel -> Put Snapshot SDel
-  // B: Put SDel Put SDel -> (Removed)
+  // B: Snapshot Put SDel Put SDel Snapshot -> Snapshot SDel Snapshot
   // C: SDel Put SDel Snapshot Put -> Snapshot Put
-  // D: (Put) SDel Snapshot Put SDel -> (Put) SDel Snapshot
+  // D: (Put) SDel Snapshot Put SDel -> (Put) SDel Snapshot SDel
+  // E: Put SDel Snapshot Put SDel -> Snapshot SDel
+  // F: Put SDel Put Sdel Snapshot -> removed
+  // G: Snapshot SDel Put SDel Put -> Snapshot Put SDel
+  // H: (Put) Put SDel Put Sdel Snapshot -> Removed
+  // I: (Put) Snapshot Put SDel Put SDel -> SDel
+  // J: Put Put SDel Put SDel SDel Snapshot Put Put SDel SDel Put
+  //      -> Snapshot Put
+  // K: SDel SDel Put SDel Put Put Snapshot SDel Put SDel SDel Put SDel
+  //      -> Snapshot Put Snapshot SDel
+  // L: SDel Put Del Put SDel Snapshot Del Put Del SDel Put SDel
+  //      -> Snapshot SDel
+  // M: (Put) SDel Put Del Put SDel Snapshot Put Del SDel Put SDel Del
+  //      -> SDel Snapshot Del
   NewDB();
 
   auto file1 = mock::MakeMockFile({
@@ -628,6 +755,34 @@ TEST_F(CompactionJobTest, MultiSingleDelete) {
       {KeyStr("C", 14U, kTypeValue), "val3"},
       {KeyStr("D", 12U, kTypeSingleDeletion), ""},
       {KeyStr("D", 11U, kTypeValue), "val4"},
+      {KeyStr("G", 15U, kTypeValue), "val"},
+      {KeyStr("G", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("G", 13U, kTypeValue), "val"},
+      {KeyStr("I", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 13U, kTypeValue), "val"},
+      {KeyStr("J", 15U, kTypeValue), "val"},
+      {KeyStr("J", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 13U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 12U, kTypeValue), "val"},
+      {KeyStr("J", 11U, kTypeValue), "val"},
+      {KeyStr("K", 16U, kTypeSingleDeletion), ""},
+      {KeyStr("K", 15U, kTypeValue), "val1"},
+      {KeyStr("K", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("K", 13U, kTypeSingleDeletion), ""},
+      {KeyStr("K", 12U, kTypeValue), "val2"},
+      {KeyStr("K", 11U, kTypeSingleDeletion), ""},
+      {KeyStr("L", 16U, kTypeSingleDeletion), ""},
+      {KeyStr("L", 15U, kTypeValue), "val"},
+      {KeyStr("L", 14U, kTypeSingleDeletion), ""},
+      {KeyStr("L", 13U, kTypeDeletion), ""},
+      {KeyStr("L", 12U, kTypeValue), "val"},
+      {KeyStr("L", 11U, kTypeDeletion), ""},
+      {KeyStr("M", 16U, kTypeDeletion), ""},
+      {KeyStr("M", 15U, kTypeSingleDeletion), ""},
+      {KeyStr("M", 14U, kTypeValue), "val"},
+      {KeyStr("M", 13U, kTypeSingleDeletion), ""},
+      {KeyStr("M", 12U, kTypeDeletion), ""},
+      {KeyStr("M", 11U, kTypeValue), "val"},
   });
   AddMockFile(file1);
 
@@ -639,24 +794,87 @@ TEST_F(CompactionJobTest, MultiSingleDelete) {
       {KeyStr("C", 9U, kTypeValue), "val6"},
       {KeyStr("C", 8U, kTypeSingleDeletion), ""},
       {KeyStr("D", 10U, kTypeSingleDeletion), ""},
+      {KeyStr("E", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("E", 11U, kTypeValue), "val"},
+      {KeyStr("E", 5U, kTypeSingleDeletion), ""},
+      {KeyStr("E", 4U, kTypeValue), "val"},
+      {KeyStr("F", 6U, kTypeSingleDeletion), ""},
+      {KeyStr("F", 5U, kTypeValue), "val"},
+      {KeyStr("F", 4U, kTypeSingleDeletion), ""},
+      {KeyStr("F", 3U, kTypeValue), "val"},
+      {KeyStr("G", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("H", 6U, kTypeSingleDeletion), ""},
+      {KeyStr("H", 5U, kTypeValue), "val"},
+      {KeyStr("H", 4U, kTypeSingleDeletion), ""},
+      {KeyStr("H", 3U, kTypeValue), "val"},
+      {KeyStr("I", 12U, kTypeSingleDeletion), ""},
+      {KeyStr("I", 11U, kTypeValue), "val"},
+      {KeyStr("J", 6U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 5U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 4U, kTypeValue), "val"},
+      {KeyStr("J", 3U, kTypeSingleDeletion), ""},
+      {KeyStr("J", 2U, kTypeValue), "val"},
+      {KeyStr("K", 8U, kTypeValue), "val3"},
+      {KeyStr("K", 7U, kTypeValue), "val4"},
+      {KeyStr("K", 6U, kTypeSingleDeletion), ""},
+      {KeyStr("K", 5U, kTypeValue), "val5"},
+      {KeyStr("K", 2U, kTypeSingleDeletion), ""},
+      {KeyStr("K", 1U, kTypeSingleDeletion), ""},
+      {KeyStr("L", 5U, kTypeSingleDeletion), ""},
+      {KeyStr("L", 4U, kTypeValue), "val"},
+      {KeyStr("L", 3U, kTypeDeletion), ""},
+      {KeyStr("L", 2U, kTypeValue), "val"},
+      {KeyStr("L", 1U, kTypeSingleDeletion), ""},
+      {KeyStr("M", 10U, kTypeSingleDeletion), ""},
+      {KeyStr("M", 7U, kTypeValue), "val"},
+      {KeyStr("M", 5U, kTypeDeletion), ""},
+      {KeyStr("M", 4U, kTypeValue), "val"},
+      {KeyStr("M", 3U, kTypeSingleDeletion), ""},
   });
   AddMockFile(file2);
 
   auto file3 = mock::MakeMockFile({
-      {KeyStr("D", 11U, kTypeValue), "val"},
+      {KeyStr("D", 1U, kTypeValue), "val"},
+      {KeyStr("H", 1U, kTypeValue), "val"},
+      {KeyStr("I", 2U, kTypeValue), "val"},
   });
   AddMockFile(file3, 2);
 
-  auto expected_results = mock::MakeMockFile({
-      {KeyStr("A", 12U, kTypeSingleDeletion), ""},
-      {KeyStr("A", 10U, kTypeValue), "val"},
-      {KeyStr("C", 14U, kTypeValue), "val3"},
-      {KeyStr("D", 10U, kTypeSingleDeletion), ""},
+  auto file4 = mock::MakeMockFile({
+      {KeyStr("M", 1U, kTypeValue), "val"},
   });
+  AddMockFile(file4, 2);
+
+  auto expected_results =
+      mock::MakeMockFile({{KeyStr("A", 14U, kTypeSingleDeletion), ""},
+                          {KeyStr("A", 13U, kTypeValue), ""},
+                          {KeyStr("A", 12U, kTypeSingleDeletion), ""},
+                          {KeyStr("A", 10U, kTypeValue), "val"},
+                          {KeyStr("B", 14U, kTypeSingleDeletion), ""},
+                          {KeyStr("B", 13U, kTypeValue), ""},
+                          {KeyStr("C", 14U, kTypeValue), "val3"},
+                          {KeyStr("D", 12U, kTypeSingleDeletion), ""},
+                          {KeyStr("D", 11U, kTypeValue), ""},
+                          {KeyStr("D", 10U, kTypeSingleDeletion), ""},
+                          {KeyStr("E", 12U, kTypeSingleDeletion), ""},
+                          {KeyStr("E", 11U, kTypeValue), ""},
+                          {KeyStr("G", 15U, kTypeValue), "val"},
+                          {KeyStr("G", 12U, kTypeSingleDeletion), ""},
+                          {KeyStr("I", 14U, kTypeSingleDeletion), ""},
+                          {KeyStr("I", 13U, kTypeValue), ""},
+                          {KeyStr("J", 15U, kTypeValue), "val"},
+                          {KeyStr("K", 16U, kTypeSingleDeletion), ""},
+                          {KeyStr("K", 15U, kTypeValue), ""},
+                          {KeyStr("K", 11U, kTypeSingleDeletion), ""},
+                          {KeyStr("K", 8U, kTypeValue), "val3"},
+                          {KeyStr("L", 16U, kTypeSingleDeletion), ""},
+                          {KeyStr("L", 15U, kTypeValue), ""},
+                          {KeyStr("M", 16U, kTypeDeletion), ""},
+                          {KeyStr("M", 3U, kTypeSingleDeletion), ""}});
 
   SetLastSequence(22U);
   auto files = cfd_->current()->storage_info()->LevelFiles(0);
-  RunCompaction({files}, expected_results, {10U});
+  RunCompaction({files}, expected_results, {10U}, 10U);
 }
 
 // This test documents the behavior where a corrupt key follows a deletion or a
@@ -695,3 +913,14 @@ int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }
+
+#else
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+  fprintf(stderr,
+          "SKIPPED as CompactionJobStats is not supported in ROCKSDB_LITE\n");
+  return 0;
+}
+
+#endif  // ROCKSDB_LITE
diff --git a/src/rocksdb/db/compaction_picker.cc b/src/rocksdb/db/compaction_picker.cc
index 2793508..d27bd3c 100644
--- a/src/rocksdb/db/compaction_picker.cc
+++ b/src/rocksdb/db/compaction_picker.cc
@@ -255,16 +255,30 @@ Compaction* CompactionPicker::FormCompaction(
     const CompactionOptions& compact_options,
     const std::vector<CompactionInputFiles>& input_files, int output_level,
     VersionStorageInfo* vstorage, const MutableCFOptions& mutable_cf_options,
-    uint32_t output_path_id) const {
+    uint32_t output_path_id) {
   uint64_t max_grandparent_overlap_bytes =
       output_level + 1 < vstorage->num_levels() ?
           mutable_cf_options.MaxGrandParentOverlapBytes(output_level + 1) :
           std::numeric_limits<uint64_t>::max();
   assert(input_files.size());
-  return new Compaction(
+
+  // TODO(rven ): we might be able to run concurrent level 0 compaction
+  // if the key ranges of the two compactions do not overlap, but for now
+  // we do not allow it.
+  if ((input_files[0].level == 0) && !level0_compactions_in_progress_.empty()) {
+    return nullptr;
+  }
+  auto c = new Compaction(
       vstorage, mutable_cf_options, input_files, output_level,
       compact_options.output_file_size_limit, max_grandparent_overlap_bytes,
       output_path_id, compact_options.compression, /* grandparents */ {}, true);
+
+  // If it's level 0 compaction, make sure we don't execute any other level 0
+  // compactions in parallel
+  if ((c != nullptr) && (input_files[0].level == 0)) {
+    level0_compactions_in_progress_.insert(c);
+  }
+  return c;
 }
 
 Status CompactionPicker::GetCompactionInputsFromFileNumbers(
@@ -1234,8 +1248,9 @@ Compaction* UniversalCompactionPicker::PickCompaction(
   std::vector<SortedRun> sorted_runs =
       CalculateSortedRuns(*vstorage, ioptions_);
 
-  if (sorted_runs.size() <
-      (unsigned int)mutable_cf_options.level0_file_num_compaction_trigger) {
+  if (sorted_runs.size() == 0 ||
+      sorted_runs.size() <
+          (unsigned int)mutable_cf_options.level0_file_num_compaction_trigger) {
     LogToBuffer(log_buffer, "[%s] Universal: nothing to do\n", cf_name.c_str());
     return nullptr;
   }
diff --git a/src/rocksdb/db/compaction_picker.h b/src/rocksdb/db/compaction_picker.h
index e7d8bf6..062fa06 100644
--- a/src/rocksdb/db/compaction_picker.h
+++ b/src/rocksdb/db/compaction_picker.h
@@ -94,7 +94,7 @@ class CompactionPicker {
       const CompactionOptions& compact_options,
       const std::vector<CompactionInputFiles>& input_files, int output_level,
       VersionStorageInfo* vstorage, const MutableCFOptions& mutable_cf_options,
-      uint32_t output_path_id) const;
+      uint32_t output_path_id);
 
   // Converts a set of compaction input file numbers into
   // a list of CompactionInputFiles.
diff --git a/src/rocksdb/db/comparator_db_test.cc b/src/rocksdb/db/comparator_db_test.cc
index cb944a7..530c910 100644
--- a/src/rocksdb/db/comparator_db_test.cc
+++ b/src/rocksdb/db/comparator_db_test.cc
@@ -7,10 +7,11 @@
 #include <map>
 #include <string>
 
+#include "memtable/stl_wrappers.h"
 #include "rocksdb/db.h"
 #include "rocksdb/env.h"
 #include "util/hash.h"
-#include "util/stl_wrappers.h"
+#include "util/kv_map.h"
 #include "util/string_util.h"
 #include "util/testharness.h"
 #include "util/testutil.h"
diff --git a/src/rocksdb/db/corruption_test.cc b/src/rocksdb/db/corruption_test.cc
index 81cff97..475b1bb 100644
--- a/src/rocksdb/db/corruption_test.cc
+++ b/src/rocksdb/db/corruption_test.cc
@@ -232,8 +232,16 @@ class CorruptionTest : public testing::Test {
 
   // Return the value to associate with the specified key
   Slice Value(int k, std::string* storage) {
-    Random r(k);
-    return test::RandomString(&r, kValueSize, storage);
+    if (k == 0) {
+      // Ugh.  Random seed of 0 used to produce no entropy.  This code
+      // preserves the implementation that was in place when all of the
+      // magic values in this file were picked.
+      *storage = std::string(kValueSize, ' ');
+      return Slice(*storage);
+    } else {
+      Random r(k);
+      return test::RandomString(&r, kValueSize, storage);
+    }
   }
 };
 
diff --git a/src/rocksdb/db/db_bench.cc b/src/rocksdb/db/db_bench.cc
index 1092297..cb3d13b 100644
--- a/src/rocksdb/db/db_bench.cc
+++ b/src/rocksdb/db/db_bench.cc
@@ -39,6 +39,7 @@ int main() {
 #include <condition_variable>
 #include <mutex>
 #include <thread>
+#include <unordered_map>
 
 #include "db/db_impl.h"
 #include "db/version_set.h"
@@ -315,7 +316,7 @@ DEFINE_int32(compaction_style, (int32_t) rocksdb::Options().compaction_style,
              "style of compaction: level-based vs universal");
 
 static rocksdb::CompactionPri FLAGS_compaction_pri_e;
-DEFINE_int32(compaction_pri, (int32_t)rocksdb::Options().compaction_style,
+DEFINE_int32(compaction_pri, (int32_t)rocksdb::Options().compaction_pri,
              "priority of files to compaction: by size or by data age");
 
 DEFINE_int32(universal_size_ratio, 0,
@@ -373,6 +374,15 @@ DEFINE_int32(new_table_reader_for_compaction_inputs, true,
 
 DEFINE_int32(compaction_readahead_size, 0, "Compaction readahead size");
 
+DEFINE_int32(random_access_max_buffer_size, 1024 * 1024,
+             "Maximum windows randomaccess buffer size");
+
+DEFINE_int32(writable_file_max_buffer_size, 1024 * 1024,
+             "Maximum write buffer for Writable File");
+
+DEFINE_int32(skip_table_builder_flush, false, "Skip flushing block in "
+             "table builder ");
+
 DEFINE_int32(bloom_bits, -1, "Bloom filter bits per key. Negative means"
              " use default settings.");
 DEFINE_int32(memtable_bloom_bits, 0, "Bloom filter bits per key for memtable. "
@@ -486,6 +496,7 @@ DEFINE_int32(deletepercent, 2, "Percentage of deletes out of reads/writes/"
 DEFINE_uint64(delete_obsolete_files_period_micros, 0,
               "Ignored. Left here for backward compatibility");
 
+#ifndef ROCKSDB_LITE
 DEFINE_bool(optimistic_transaction_db, false,
             "Open a OptimisticTransactionDB instance. "
             "Required for randomtransaction benchmark.");
@@ -509,6 +520,7 @@ DEFINE_int32(transaction_sleep, 0,
 DEFINE_uint64(transaction_lock_timeout, 100,
               "If using a transaction_db, specifies the lock wait timeout in"
               " milliseconds before failing a transaction waiting on a lock");
+#endif  // ROCKSDB_LITE
 
 DEFINE_bool(compaction_measure_io_stats, false,
             "Measure times spents on I/Os while in compactions. ");
@@ -620,11 +632,14 @@ static bool ValidateRateLimit(const char* flagname, double value) {
   }
   return true;
 }
-DEFINE_double(soft_rate_limit, 0.0, "");
+DEFINE_double(soft_rate_limit, 0.0, "DEPRECATED");
 
 DEFINE_double(hard_rate_limit, 0.0, "DEPRECATED");
 
-DEFINE_uint64(hard_pending_compaction_bytes_limit, 128u * 1024 * 1024 * 1024,
+DEFINE_uint64(soft_pending_compaction_bytes_limit, 64ull * 1024 * 1024 * 1024,
+              "Slowdown writes if pending compaction bytes exceed this number");
+
+DEFINE_uint64(hard_pending_compaction_bytes_limit, 128ull * 1024 * 1024 * 1024,
               "Stop writes if pending compaction bytes exceed this number");
 
 DEFINE_uint64(delayed_write_rate, 2097152u,
@@ -645,7 +660,9 @@ DEFINE_int32(max_grandparent_overlap_factor, 10, "Control maximum bytes of "
              "overlaps in grandparent (i.e., level+2) before we stop building a"
              " single file in a level->level+1 compaction.");
 
+#ifndef ROCKSDB_LITE
 DEFINE_bool(readonly, false, "Run read only benchmarks.");
+#endif  // ROCKSDB_LITE
 
 DEFINE_bool(disable_auto_compactions, false, "Do not auto trigger compactions");
 
@@ -728,11 +745,6 @@ DEFINE_bool(identity_as_first_hash, false, "the first hash function of cuckoo "
             "table becomes an identity function. This is only valid when key "
             "is 8 bytes");
 
-enum PutOrMerge {
-  kPut,
-  kMerge
-};
-
 enum RepFactory {
   kSkipList,
   kPrefixHash,
@@ -983,7 +995,9 @@ static void AppendWithSpace(std::string* str, Slice msg) {
 struct DBWithColumnFamilies {
   std::vector<ColumnFamilyHandle*> cfh;
   DB* db;
+#ifndef ROCKSDB_LITE
   OptimisticTransactionDB* opt_txn_db;
+#endif  // ROCKSDB_LITE
   std::atomic<size_t> num_created;  // Need to be updated after all the
                                     // new entries in cfh are set.
   size_t num_hot;  // Number of column families to be queried at each moment.
@@ -991,7 +1005,12 @@ struct DBWithColumnFamilies {
                    // Column families will be created and used to be queried.
   port::Mutex create_cf_mutex;  // Only one thread can execute CreateNewCf()
 
-  DBWithColumnFamilies() : db(nullptr), opt_txn_db(nullptr) {
+  DBWithColumnFamilies()
+      : db(nullptr)
+#ifndef ROCKSDB_LITE
+        , opt_txn_db(nullptr)
+#endif  // ROCKSDB_LITE
+  {
     cfh.clear();
     num_created = 0;
     num_hot = 0;
@@ -1000,7 +1019,9 @@ struct DBWithColumnFamilies {
   DBWithColumnFamilies(const DBWithColumnFamilies& other)
       : cfh(other.cfh),
         db(other.db),
+#ifndef ROCKSDB_LITE
         opt_txn_db(other.opt_txn_db),
+#endif  // ROCKSDB_LITE
         num_created(other.num_created.load()),
         num_hot(other.num_hot) {}
 
@@ -1008,13 +1029,18 @@ struct DBWithColumnFamilies {
     std::for_each(cfh.begin(), cfh.end(),
                   [](ColumnFamilyHandle* cfhi) { delete cfhi; });
     cfh.clear();
+#ifndef ROCKSDB_LITE
     if (opt_txn_db) {
       delete opt_txn_db;
       opt_txn_db = nullptr;
     } else {
       delete db;
+      db = nullptr;
     }
+#else
+    delete db;
     db = nullptr;
+#endif  // ROCKSDB_LITE
   }
 
   ColumnFamilyHandle* GetCfh(int64_t rand_num) {
@@ -1136,6 +1162,35 @@ class ReporterAgent {
   bool stop_;
 };
 
+enum OperationType : unsigned char {
+  kRead = 0,
+  kWrite,
+  kDelete,
+  kSeek,
+  kMerge,
+  kUpdate,
+  kCompress,
+  kUncompress,
+  kCrc,
+  kHash,
+  kOthers
+};
+
+static std::unordered_map<OperationType, std::string, std::hash<unsigned char>>
+                          OperationTypeString = {
+  {kRead, "read"},
+  {kWrite, "write"},
+  {kDelete, "delete"},
+  {kSeek, "seek"},
+  {kMerge, "merge"},
+  {kUpdate, "update"},
+  {kCompress, "compress"},
+  {kCompress, "uncompress"},
+  {kCrc, "crc"},
+  {kHash, "hash"},
+  {kOthers, "op"}
+};
+
 class Stats {
  private:
   int id_;
@@ -1148,7 +1203,8 @@ class Stats {
   int64_t bytes_;
   double last_op_finish_;
   double last_report_finish_;
-  HistogramImpl hist_;
+  std::unordered_map<OperationType, HistogramImpl,
+                     std::hash<unsigned char>> hist_;
   std::string message_;
   bool exclude_from_merge_;
   ReporterAgent* reporter_agent_;  // does not own
@@ -1164,7 +1220,7 @@ class Stats {
     id_ = id;
     next_report_ = FLAGS_stats_interval ? FLAGS_stats_interval : 100;
     last_op_finish_ = start_;
-    hist_.Clear();
+    hist_.clear();
     done_ = 0;
     last_report_done_ = 0;
     bytes_ = 0;
@@ -1181,7 +1237,15 @@ class Stats {
     if (other.exclude_from_merge_)
       return;
 
-    hist_.Merge(other.hist_);
+    for (auto it = other.hist_.begin(); it != other.hist_.end(); ++it) {
+      auto this_it = hist_.find(it->first);
+      if (this_it != hist_.end()) {
+        this_it->second.Merge(other.hist_.at(it->first));
+      } else {
+        hist_.insert({ it->first, it->second });
+      }
+    }
+
     done_ += other.done_;
     bytes_ += other.bytes_;
     seconds_ += other.seconds_;
@@ -1234,14 +1298,22 @@ class Stats {
     }
   }
 
-  void FinishedOps(DBWithColumnFamilies* db_with_cfh, DB* db, int64_t num_ops) {
+  void FinishedOps(DBWithColumnFamilies* db_with_cfh, DB* db, int64_t num_ops,
+                   enum OperationType op_type = kOthers) {
     if (reporter_agent_) {
       reporter_agent_->ReportFinishedOps(num_ops);
     }
     if (FLAGS_histogram) {
       double now = FLAGS_env->NowMicros();
       double micros = now - last_op_finish_;
-      hist_.Add(micros);
+
+      if (hist_.find(op_type) == hist_.end())
+      {
+        HistogramImpl hist_temp;
+        hist_.insert({op_type, hist_temp});
+      }
+      hist_[op_type].Add(micros);
+
       if (micros > 20000 && !FLAGS_stats_interval) {
         fprintf(stderr, "long op: %.1f micros%30s\r", micros, "");
         fflush(stderr);
@@ -1370,7 +1442,11 @@ class Stats {
             (extra.empty() ? "" : " "),
             extra.c_str());
     if (FLAGS_histogram) {
-      fprintf(stdout, "Microseconds per op:\n%s\n", hist_.ToString().c_str());
+      for (auto it = hist_.begin(); it != hist_.end(); ++it) {
+        fprintf(stdout, "Microseconds per %s:\n%s\n",
+                OperationTypeString[it->first].c_str(),
+                it->second.ToString().c_str());
+      }
     }
     if (FLAGS_report_file_operations) {
       ReportFileOpEnv* env = static_cast<ReportFileOpEnv*>(FLAGS_env);
@@ -1940,9 +2016,11 @@ class Benchmark {
         method = &Benchmark::Compress;
       } else if (name == "uncompress") {
         method = &Benchmark::Uncompress;
+#ifndef ROCKSDB_LITE
       } else if (name == "randomtransaction") {
         method = &Benchmark::RandomTransaction;
         post_process_method = &Benchmark::RandomTransactionVerify;
+#endif  // ROCKSDB_LITE
       } else if (name == "randomreplacekeys") {
         fresh_db = true;
         method = &Benchmark::RandomReplaceKeys;
@@ -2109,7 +2187,7 @@ class Benchmark {
     uint32_t crc = 0;
     while (bytes < 500 * 1048576) {
       crc = crc32c::Value(data.data(), size);
-      thread->stats.FinishedOps(nullptr, nullptr, 1);
+      thread->stats.FinishedOps(nullptr, nullptr, 1, kCrc);
       bytes += size;
     }
     // Print so result is not dead
@@ -2128,7 +2206,7 @@ class Benchmark {
     unsigned int xxh32 = 0;
     while (bytes < 500 * 1048576) {
       xxh32 = XXH32(data.data(), size, 0);
-      thread->stats.FinishedOps(nullptr, nullptr, 1);
+      thread->stats.FinishedOps(nullptr, nullptr, 1, kHash);
       bytes += size;
     }
     // Print so result is not dead
@@ -2149,7 +2227,7 @@ class Benchmark {
         ptr = ap.load(std::memory_order_acquire);
       }
       count++;
-      thread->stats.FinishedOps(nullptr, nullptr, 1);
+      thread->stats.FinishedOps(nullptr, nullptr, 1, kOthers);
     }
     if (ptr == nullptr) exit(1); // Disable unused variable warning.
   }
@@ -2167,7 +2245,7 @@ class Benchmark {
       ok = CompressSlice(input, &compressed);
       produced += compressed.size();
       bytes += input.size();
-      thread->stats.FinishedOps(nullptr, nullptr, 1);
+      thread->stats.FinishedOps(nullptr, nullptr, 1, kCompress);
     }
 
     if (!ok) {
@@ -2192,12 +2270,19 @@ class Benchmark {
     while (ok && bytes < 1024 * 1048576) {
       char *uncompressed = nullptr;
       switch (FLAGS_compression_type_e) {
-      case rocksdb::kSnappyCompression:
-        // allocate here to make comparison fair
-        uncompressed = new char[input.size()];
-        ok = Snappy_Uncompress(compressed.data(), compressed.size(),
-                               uncompressed);
-        break;
+        case rocksdb::kSnappyCompression: {
+          // get size and allocate here to make comparison fair
+          size_t ulength = 0;
+          if (!Snappy_GetUncompressedLength(compressed.data(),
+                                            compressed.size(), &ulength)) {
+            ok = false;
+            break;
+          }
+          uncompressed = new char[ulength];
+          ok = Snappy_Uncompress(compressed.data(), compressed.size(),
+                                 uncompressed);
+          break;
+        }
       case rocksdb::kZlibCompression:
         uncompressed = Zlib_Uncompress(compressed.data(), compressed.size(),
                                        &decompress_size, 2);
@@ -2228,7 +2313,7 @@ class Benchmark {
       }
       delete[] uncompressed;
       bytes += input.size();
-      thread->stats.FinishedOps(nullptr, nullptr, 1);
+      thread->stats.FinishedOps(nullptr, nullptr, 1, kUncompress);
     }
 
     if (!ok) {
@@ -2275,6 +2360,8 @@ class Benchmark {
     options.new_table_reader_for_compaction_inputs =
         FLAGS_new_table_reader_for_compaction_inputs;
     options.compaction_readahead_size = FLAGS_compaction_readahead_size;
+    options.random_access_max_buffer_size = FLAGS_random_access_max_buffer_size;
+    options.writable_file_max_buffer_size = FLAGS_writable_file_max_buffer_size;
     options.statistics = dbstats;
     if (FLAGS_enable_io_prio) {
       FLAGS_env->LowerThreadPoolIOPriority(Env::LOW);
@@ -2417,6 +2504,8 @@ class Benchmark {
       block_based_options.block_size = FLAGS_block_size;
       block_based_options.block_restart_interval = FLAGS_block_restart_interval;
       block_based_options.filter_policy = filter_policy_;
+      block_based_options.skip_table_builder_flush =
+          FLAGS_skip_table_builder_flush;
       block_based_options.format_version = 2;
       options.table_factory.reset(
           NewBlockBasedTableFactory(block_based_options));
@@ -2518,10 +2607,12 @@ class Benchmark {
           NewGenericRateLimiter(FLAGS_rate_limiter_bytes_per_sec));
     }
 
+#ifndef ROCKSDB_LITE
     if (FLAGS_readonly && FLAGS_transaction_db) {
       fprintf(stderr, "Cannot use readonly flag with transaction_db\n");
       exit(1);
     }
+#endif  // ROCKSDB_LITE
 
     if (FLAGS_num_multi_db <= 1) {
       OpenDb(options, FLAGS_db, &db_);
@@ -2554,6 +2645,7 @@ class Benchmark {
         column_families.push_back(ColumnFamilyDescriptor(
               ColumnFamilyName(i), ColumnFamilyOptions(options)));
       }
+#ifndef ROCKSDB_LITE
       if (FLAGS_readonly) {
         s = DB::OpenForReadOnly(options, db_name, column_families,
             &db->cfh, &db->db);
@@ -2574,9 +2666,13 @@ class Benchmark {
       } else {
         s = DB::Open(options, db_name, column_families, &db->cfh, &db->db);
       }
+#else
+      s = DB::Open(options, db_name, column_families, &db->cfh, &db->db);
+#endif  // ROCKSDB_LITE
       db->cfh.resize(FLAGS_num_column_families);
       db->num_created = num_hot;
       db->num_hot = num_hot;
+#ifndef ROCKSDB_LITE
     } else if (FLAGS_readonly) {
       s = DB::OpenForReadOnly(options, db_name, &db->db);
     } else if (FLAGS_optimistic_transaction_db) {
@@ -2591,7 +2687,7 @@ class Benchmark {
       if (s.ok()) {
         db->db = ptr;
       }
-
+#endif  // ROCKSDB_LITE
     } else {
       s = DB::Open(options, db_name, &db->db);
     }
@@ -2748,7 +2844,7 @@ class Benchmark {
       }
       s = db_with_cfh->db->Write(write_options_, &batch);
       thread->stats.FinishedOps(db_with_cfh, db_with_cfh->db,
-                                entries_per_batch_);
+                                entries_per_batch_, kWrite);
       if (!s.ok()) {
         fprintf(stderr, "put error: %s\n", s.ToString().c_str());
         exit(1);
@@ -2776,7 +2872,7 @@ class Benchmark {
     int64_t bytes = 0;
     for (iter->SeekToFirst(); i < reads_ && iter->Valid(); iter->Next()) {
       bytes += iter->key().size() + iter->value().size();
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kRead);
       ++i;
     }
     delete iter;
@@ -2799,7 +2895,7 @@ class Benchmark {
     int64_t bytes = 0;
     for (iter->SeekToLast(); i < reads_ && iter->Valid(); iter->Prev()) {
       bytes += iter->key().size() + iter->value().size();
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kRead);
       ++i;
     }
     delete iter;
@@ -2839,7 +2935,7 @@ class Benchmark {
           ++nonexist;
         }
       }
-      thread->stats.FinishedOps(nullptr, db, 100);
+      thread->stats.FinishedOps(nullptr, db, 100, kRead);
     } while (!duration.Done(100));
 
     char msg[100];
@@ -2907,7 +3003,7 @@ class Benchmark {
         fprintf(stderr, "Get returned an error: %s\n", s.ToString().c_str());
         abort();
       }
-      thread->stats.FinishedOps(db_with_cfh, db_with_cfh->db, 1);
+      thread->stats.FinishedOps(db_with_cfh, db_with_cfh->db, 1, kRead);
     }
 
     char msg[100];
@@ -2955,7 +3051,7 @@ class Benchmark {
           abort();
         }
       }
-      thread->stats.FinishedOps(nullptr, db, entries_per_batch_);
+      thread->stats.FinishedOps(nullptr, db, entries_per_batch_, kRead);
     }
 
     char msg[100];
@@ -2971,7 +3067,7 @@ class Benchmark {
       DB* db = SelectDB(thread);
       Iterator* iter = db->NewIterator(options);
       delete iter;
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kOthers);
     }
   }
 
@@ -2979,7 +3075,7 @@ class Benchmark {
     if (thread->tid > 0) {
       IteratorCreation(thread);
     } else {
-      BGWriter(thread, kPut);
+      BGWriter(thread, kWrite);
     }
   }
 
@@ -3048,7 +3144,7 @@ class Benchmark {
         assert(iter_to_use->status().ok());
       }
 
-      thread->stats.FinishedOps(&db_, db_.db, 1);
+      thread->stats.FinishedOps(&db_, db_.db, 1, kSeek);
     }
     delete single_iter;
     for (auto iter : multi_iters) {
@@ -3069,7 +3165,7 @@ class Benchmark {
     if (thread->tid > 0) {
       SeekRandom(thread);
     } else {
-      BGWriter(thread, kPut);
+      BGWriter(thread, kWrite);
     }
   }
 
@@ -3097,7 +3193,7 @@ class Benchmark {
         batch.Delete(key);
       }
       auto s = db->Write(write_options_, &batch);
-      thread->stats.FinishedOps(nullptr, db, entries_per_batch_);
+      thread->stats.FinishedOps(nullptr, db, entries_per_batch_, kDelete);
       if (!s.ok()) {
         fprintf(stderr, "del error: %s\n", s.ToString().c_str());
         exit(1);
@@ -3118,7 +3214,7 @@ class Benchmark {
     if (thread->tid > 0) {
       ReadRandom(thread);
     } else {
-      BGWriter(thread, kPut);
+      BGWriter(thread, kWrite);
     }
   }
 
@@ -3130,7 +3226,7 @@ class Benchmark {
     }
   }
 
-  void BGWriter(ThreadState* thread, enum PutOrMerge write_merge) {
+  void BGWriter(ThreadState* thread, enum OperationType write_merge) {
     // Special thread that keeps writing until other threads are done.
     RandomGenerator gen;
     double last = FLAGS_env->NowMicros();
@@ -3163,7 +3259,7 @@ class Benchmark {
       GenerateKeyFromInt(thread->rand.Next() % FLAGS_num, FLAGS_num, &key);
       Status s;
 
-      if (write_merge == kPut) {
+      if (write_merge == kWrite) {
           s = db->Put(write_options_, key, gen.Generate(value_size_));
       } else {
           s = db->Merge(write_options_, key, gen.Generate(value_size_));
@@ -3174,7 +3270,7 @@ class Benchmark {
         exit(1);
       }
       bytes += key.size() + value_size_;
-      thread->stats.FinishedOps(&db_, db_.db, 1);
+      thread->stats.FinishedOps(&db_, db_.db, 1, kWrite);
 
       ++num_writes;
       if (writes_per_second_by_10 && num_writes >= writes_per_second_by_10) {
@@ -3315,6 +3411,7 @@ class Benchmark {
         }
         get_weight--;
         gets_done++;
+        thread->stats.FinishedOps(&db_, db_.db, 1, kRead);
       } else if (put_weight > 0) {
         // then do all the corresponding number of puts
         // for all the gets we have done earlier
@@ -3325,6 +3422,7 @@ class Benchmark {
         }
         put_weight--;
         puts_done++;
+        thread->stats.FinishedOps(&db_, db_.db, 1, kWrite);
       } else if (delete_weight > 0) {
         Status s = DeleteMany(db, write_options_, key);
         if (!s.ok()) {
@@ -3333,9 +3431,8 @@ class Benchmark {
         }
         delete_weight--;
         deletes_done++;
+        thread->stats.FinishedOps(&db_, db_.db, 1, kDelete);
       }
-
-      thread->stats.FinishedOps(&db_, db_.db, 1);
     }
     char msg[100];
     snprintf(msg, sizeof(msg),
@@ -3382,6 +3479,7 @@ class Benchmark {
         }
         get_weight--;
         reads_done++;
+        thread->stats.FinishedOps(nullptr, db, 1, kRead);
       } else  if (put_weight > 0) {
         // then do all the corresponding number of puts
         // for all the gets we have done earlier
@@ -3392,8 +3490,8 @@ class Benchmark {
         }
         put_weight--;
         writes_done++;
+        thread->stats.FinishedOps(nullptr, db, 1, kWrite);
       }
-      thread->stats.FinishedOps(nullptr, db, 1);
     }
     char msg[100];
     snprintf(msg, sizeof(msg), "( reads:%" PRIu64 " writes:%" PRIu64 \
@@ -3435,7 +3533,7 @@ class Benchmark {
         exit(1);
       }
       bytes += key.size() + value_size_;
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kUpdate);
     }
     char msg[100];
     snprintf(msg, sizeof(msg),
@@ -3490,7 +3588,7 @@ class Benchmark {
         exit(1);
       }
       bytes += key.size() + value.size();
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kUpdate);
     }
 
     char msg[100];
@@ -3528,7 +3626,7 @@ class Benchmark {
         exit(1);
       }
       bytes += key.size() + value_size_;
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kMerge);
     }
 
     // Print some statistics
@@ -3570,9 +3668,8 @@ class Benchmark {
           fprintf(stderr, "merge error: %s\n", s.ToString().c_str());
           exit(1);
         }
-
         num_merges++;
-
+        thread->stats.FinishedOps(nullptr, db, 1, kMerge);
       } else {
         Status s = db->Get(options, key, &value);
         if (value.length() > max_length)
@@ -3585,12 +3682,9 @@ class Benchmark {
         } else if (!s.IsNotFound()) {
           num_hits++;
         }
-
         num_gets++;
-
+        thread->stats.FinishedOps(nullptr, db, 1, kRead);
       }
-
-      thread->stats.FinishedOps(nullptr, db, 1);
     }
 
     char msg[100];
@@ -3617,7 +3711,7 @@ class Benchmark {
       GenerateKeyFromInt(i, FLAGS_num, &key);
       iter->Seek(key);
       assert(iter->Valid() && iter->key() == key);
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kSeek);
 
       for (int j = 0; j < FLAGS_seek_nexts && i + 1 < FLAGS_num; ++j) {
         if (!FLAGS_reverse_iterator) {
@@ -3627,15 +3721,16 @@ class Benchmark {
         }
         GenerateKeyFromInt(++i, FLAGS_num, &key);
         assert(iter->Valid() && iter->key() == key);
-        thread->stats.FinishedOps(nullptr, db, 1);
+        thread->stats.FinishedOps(nullptr, db, 1, kSeek);
       }
 
       iter->Seek(key);
       assert(iter->Valid() && iter->key() == key);
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kSeek);
     }
   }
 
+#ifndef ROCKSDB_LITE
   // This benchmark stress tests Transactions.  For a given --duration (or
   // total number of --writes, a Transaction will perform a read-modify-write
   // to increment the value of a key in each of N(--transaction-sets) sets of
@@ -3793,7 +3888,7 @@ class Benchmark {
       }
 
       if (!failed) {
-        thread->stats.FinishedOps(nullptr, db, 1);
+        thread->stats.FinishedOps(nullptr, db, 1, kOthers);
       }
 
       transactions_done++;
@@ -3868,6 +3963,7 @@ class Benchmark {
 
     fprintf(stdout, "RandomTransactionVerify Success!\n");
   }
+#endif  // ROCKSDB_LITE
 
   // Writes and deletes random keys without overwriting keys.
   //
@@ -3918,7 +4014,7 @@ class Benchmark {
         exit(1);
       }
 
-      thread->stats.FinishedOps(nullptr, db, 1);
+      thread->stats.FinishedOps(nullptr, db, 1, kOthers);
     }
 
     char msg[200];
diff --git a/src/rocksdb/db/db_compaction_filter_test.cc b/src/rocksdb/db/db_compaction_filter_test.cc
index a1587f2..2b9a1a0 100644
--- a/src/rocksdb/db/db_compaction_filter_test.cc
+++ b/src/rocksdb/db/db_compaction_filter_test.cc
@@ -7,8 +7,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
 
 namespace rocksdb {
 
@@ -47,6 +47,24 @@ class DeleteFilter : public CompactionFilter {
   virtual const char* Name() const override { return "DeleteFilter"; }
 };
 
+class DeleteISFilter : public CompactionFilter {
+ public:
+  virtual bool Filter(int level, const Slice& key, const Slice& value,
+                      std::string* new_value,
+                      bool* value_changed) const override {
+    cfilter_count++;
+    int i = std::stoi(key.ToString());
+    if (i > 5 && i <= 105) {
+      return true;
+    }
+    return false;
+  }
+
+  virtual bool IgnoreSnapshots() const override { return true; }
+
+  virtual const char* Name() const override { return "DeleteFilter"; }
+};
+
 class DelayFilter : public CompactionFilter {
  public:
   explicit DelayFilter(DBTestBase* d) : db_test(d) {}
@@ -97,8 +115,11 @@ class ChangeFilter : public CompactionFilter {
 
 class KeepFilterFactory : public CompactionFilterFactory {
  public:
-  explicit KeepFilterFactory(bool check_context = false)
-      : check_context_(check_context) {}
+  explicit KeepFilterFactory(bool check_context = false,
+                             bool check_context_cf_id = false)
+      : check_context_(check_context),
+        check_context_cf_id_(check_context_cf_id),
+        compaction_filter_created_(false) {}
 
   virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
       const CompactionFilter::Context& context) override {
@@ -106,13 +127,22 @@ class KeepFilterFactory : public CompactionFilterFactory {
       EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction);
       EXPECT_EQ(expect_manual_compaction_.load(), context.is_manual_compaction);
     }
+    if (check_context_cf_id_) {
+      EXPECT_EQ(expect_cf_id_.load(), context.column_family_id);
+    }
+    compaction_filter_created_ = true;
     return std::unique_ptr<CompactionFilter>(new KeepFilter());
   }
 
+  bool compaction_filter_created() const { return compaction_filter_created_; }
+
   virtual const char* Name() const override { return "KeepFilterFactory"; }
   bool check_context_;
+  bool check_context_cf_id_;
   std::atomic_bool expect_full_compaction_;
   std::atomic_bool expect_manual_compaction_;
+  std::atomic<uint32_t> expect_cf_id_;
+  bool compaction_filter_created_;
 };
 
 class DeleteFilterFactory : public CompactionFilterFactory {
@@ -129,6 +159,21 @@ class DeleteFilterFactory : public CompactionFilterFactory {
   virtual const char* Name() const override { return "DeleteFilterFactory"; }
 };
 
+// Delete Filter Factory which ignores snapshots
+class DeleteISFilterFactory : public CompactionFilterFactory {
+ public:
+  virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
+      const CompactionFilter::Context& context) override {
+    if (context.is_manual_compaction) {
+      return std::unique_ptr<CompactionFilter>(new DeleteISFilter());
+    } else {
+      return std::unique_ptr<CompactionFilter>(nullptr);
+    }
+  }
+
+  virtual const char* Name() const override { return "DeleteFilterFactory"; }
+};
+
 class DelayFilterFactory : public CompactionFilterFactory {
  public:
   explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {}
@@ -174,6 +219,7 @@ class ChangeFilterFactory : public CompactionFilterFactory {
   virtual const char* Name() const override { return "ChangeFilterFactory"; }
 };
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTestCompactionFilter, CompactionFilter) {
   Options options = CurrentOptions();
   options.max_open_files = -1;
@@ -216,7 +262,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) {
   Arena arena;
   {
     ScopedArenaIterator iter(
-        dbfull()->TEST_NewInternalIterator(&arena, handles_[1]));
+        dbfull()->NewInternalIterator(&arena, handles_[1]));
     iter->SeekToFirst();
     ASSERT_OK(iter->status());
     while (iter->Valid()) {
@@ -304,7 +350,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) {
   count = 0;
   {
     ScopedArenaIterator iter(
-        dbfull()->TEST_NewInternalIterator(&arena, handles_[1]));
+        dbfull()->NewInternalIterator(&arena, handles_[1]));
     iter->SeekToFirst();
     ASSERT_OK(iter->status());
     while (iter->Valid()) {
@@ -350,6 +396,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterDeletesAll) {
 
   delete itr;
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTestCompactionFilter, CompactionFilterWithValueChange) {
   do {
@@ -481,8 +528,9 @@ TEST_F(DBTestCompactionFilter, CompactionFilterWithMergeOperator) {
   ASSERT_EQ(newvalue, four);
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTestCompactionFilter, CompactionFilterContextManual) {
-  KeepFilterFactory* filter = new KeepFilterFactory();
+  KeepFilterFactory* filter = new KeepFilterFactory(true, true);
 
   Options options = CurrentOptions();
   options.compaction_style = kCompactionStyleUniversal;
@@ -504,22 +552,24 @@ TEST_F(DBTestCompactionFilter, CompactionFilterContextManual) {
     // be triggered.
     num_keys_per_file /= 2;
   }
+  dbfull()->TEST_WaitForCompact();
 
   // Force a manual compaction
   cfilter_count = 0;
   filter->expect_manual_compaction_.store(true);
-  filter->expect_full_compaction_.store(false);  // Manual compaction always
-                                                 // set this flag.
+  filter->expect_full_compaction_.store(true);
+  filter->expect_cf_id_.store(0);
   dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
   ASSERT_EQ(cfilter_count, 700);
   ASSERT_EQ(NumSortedRuns(0), 1);
+  ASSERT_TRUE(filter->compaction_filter_created());
 
   // Verify total number of keys is correct after manual compaction.
   {
     int count = 0;
     int total = 0;
     Arena arena;
-    ScopedArenaIterator iter(dbfull()->TEST_NewInternalIterator(&arena));
+    ScopedArenaIterator iter(dbfull()->NewInternalIterator(&arena));
     iter->SeekToFirst();
     ASSERT_OK(iter->status());
     while (iter->Valid()) {
@@ -536,7 +586,38 @@ TEST_F(DBTestCompactionFilter, CompactionFilterContextManual) {
     ASSERT_EQ(count, 1);
   }
 }
+#endif  // ROCKSDB_LITE
+
+TEST_F(DBTestCompactionFilter, CompactionFilterContextCfId) {
+  KeepFilterFactory* filter = new KeepFilterFactory(false, true);
+  filter->expect_cf_id_.store(1);
+
+  Options options = CurrentOptions();
+  options.compaction_filter_factory.reset(filter);
+  options.compression = kNoCompression;
+  options.level0_file_num_compaction_trigger = 2;
+  CreateAndReopenWithCF({"pikachu"}, options);
+
+  int num_keys_per_file = 400;
+  for (int j = 0; j < 3; j++) {
+    // Write several keys.
+    const std::string value(10, 'x');
+    for (int i = 0; i < num_keys_per_file; i++) {
+      char key[100];
+      snprintf(key, sizeof(key), "B%08d%02d", i, j);
+      Put(1, key, value);
+    }
+    Flush(1);
+    // Make sure next file is much smaller so automatic compaction will not
+    // be triggered.
+    num_keys_per_file /= 2;
+  }
+  dbfull()->TEST_WaitForCompact();
+
+  ASSERT_TRUE(filter->compaction_filter_created());
+}
 
+#ifndef ROCKSDB_LITE
 // Compaction filters should only be applied to records that are newer than the
 // latest snapshot. This test inserts records and applies a delete filter.
 TEST_F(DBTestCompactionFilter, CompactionFilterSnapshot) {
@@ -573,14 +654,73 @@ TEST_F(DBTestCompactionFilter, CompactionFilterSnapshot) {
   ASSERT_EQ(0U, CountLiveFiles());
 }
 
+// Compaction filters should only be applied to records that are newer than the
+// latest snapshot. However, if the compaction filter asks to ignore snapshots
+// records newer than the snapshot will also be processed
+TEST_F(DBTestCompactionFilter, CompactionFilterIgnoreSnapshot) {
+  std::string five = ToString(5);
+  Options options;
+  options.compaction_filter_factory = std::make_shared<DeleteISFilterFactory>();
+  options.disable_auto_compactions = true;
+  options.create_if_missing = true;
+  options = CurrentOptions(options);
+  DestroyAndReopen(options);
+
+  // Put some data.
+  const Snapshot* snapshot = nullptr;
+  for (int table = 0; table < 4; ++table) {
+    for (int i = 0; i < 10; ++i) {
+      Put(ToString(table * 100 + i), "val");
+    }
+    Flush();
+
+    if (table == 0) {
+      snapshot = db_->GetSnapshot();
+    }
+  }
+  assert(snapshot != nullptr);
+
+  cfilter_count = 0;
+  ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
+  // The filter should delete 40 records.
+  ASSERT_EQ(40U, cfilter_count);
+
+  {
+    // Scan the entire database as of the snapshot to ensure
+    // that nothing is left
+    ReadOptions read_options;
+    read_options.snapshot = snapshot;
+    std::unique_ptr<Iterator> iter(db_->NewIterator(read_options));
+    iter->SeekToFirst();
+    int count = 0;
+    while (iter->Valid()) {
+      count++;
+      iter->Next();
+    }
+    ASSERT_EQ(count, 6);
+    read_options.snapshot = 0;
+    std::unique_ptr<Iterator> iter1(db_->NewIterator(read_options));
+    iter1->SeekToFirst();
+    count = 0;
+    while (iter1->Valid()) {
+      count++;
+      iter1->Next();
+    }
+    // We have deleted 10 keys from 40 using the compaction filter
+    //  Keys 6-9 before the snapshot and 100-105 after the snapshot
+    ASSERT_EQ(count, 30);
+  }
+
+  // Release the snapshot and compact again -> now all records should be
+  // removed.
+  db_->ReleaseSnapshot(snapshot);
+}
+#endif  // ROCKSDB_LITE
+
 }  // namespace rocksdb
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
 }
diff --git a/src/rocksdb/db/db_compaction_test.cc b/src/rocksdb/db/db_compaction_test.cc
index e052fc7..72b2b70 100644
--- a/src/rocksdb/db/db_compaction_test.cc
+++ b/src/rocksdb/db/db_compaction_test.cc
@@ -7,15 +7,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
 #include "rocksdb/experimental.h"
-#include "util/db_test_util.h"
 #include "util/sync_point.h"
 namespace rocksdb {
 
 // SYNC_POINT is not supported in released Windows mode.
-#if !(defined NDEBUG) || !defined(OS_WIN)
-
+#if !defined(ROCKSDB_LITE)
 
 class DBCompactionTest : public DBTestBase {
  public:
@@ -161,7 +160,7 @@ const SstFileMetaData* PickFileRandomly(
       auto result = rand->Uniform(file_id);
       return &(level_meta.files[result]);
     }
-    file_id -= level_meta.files.size();
+    file_id -= static_cast<uint32_t>(level_meta.files.size());
   }
   assert(false);
   return nullptr;
@@ -240,9 +239,12 @@ TEST_F(DBCompactionTest, SkipStatsUpdateTest) {
   env_->random_file_open_counter_.store(0);
   Reopen(options);
 
-  // As stats-update is disabled, we expect a very low
-  // number of random file open.
-  ASSERT_LT(env_->random_file_open_counter_.load(), 5);
+  // As stats-update is disabled, we expect a very low number of
+  // random file open.
+  // Note that this number must be changed accordingly if we change
+  // the number of files needed to be opened in the DB::Open process.
+  const int kMaxFileOpenCount = 10;
+  ASSERT_LT(env_->random_file_open_counter_.load(), kMaxFileOpenCount);
 
   // Repeat the reopen process, but this time we enable
   // stats-update.
@@ -252,7 +254,7 @@ TEST_F(DBCompactionTest, SkipStatsUpdateTest) {
 
   // Since we do a normal stats update on db-open, there
   // will be more random open files.
-  ASSERT_GT(env_->random_file_open_counter_.load(), 5);
+  ASSERT_GT(env_->random_file_open_counter_.load(), kMaxFileOpenCount);
 }
 
 TEST_F(DBCompactionTest, TestTableReaderForCompaction) {
@@ -459,12 +461,15 @@ TEST_F(DBCompactionTest, DisableStatsUpdateReopen) {
 
 
 TEST_P(DBCompactionTestWithParam, CompactionTrigger) {
+  const int kNumKeysPerFile = 100;
+
   Options options;
   options.write_buffer_size = 110 << 10;  // 110KB
   options.arena_block_size = 4 << 10;
   options.num_levels = 3;
   options.level0_file_num_compaction_trigger = 3;
   options.max_subcompactions = max_subcompactions_;
+  options.memtable_factory.reset(new SpecialSkipListFactory(kNumKeysPerFile));
   options = CurrentOptions(options);
   CreateAndReopenWithCF({"pikachu"}, options);
 
@@ -474,20 +479,24 @@ TEST_P(DBCompactionTestWithParam, CompactionTrigger) {
        num++) {
     std::vector<std::string> values;
     // Write 100KB (100 values, each 1K)
-    for (int i = 0; i < 100; i++) {
+    for (int i = 0; i < kNumKeysPerFile; i++) {
       values.push_back(RandomString(&rnd, 990));
       ASSERT_OK(Put(1, Key(i), values[i]));
     }
+    // put extra key to trigger flush
+    ASSERT_OK(Put(1, "", ""));
     dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
     ASSERT_EQ(NumTableFilesAtLevel(0, 1), num + 1);
   }
 
   // generate one more file in level-0, and should trigger level-0 compaction
   std::vector<std::string> values;
-  for (int i = 0; i < 100; i++) {
+  for (int i = 0; i < kNumKeysPerFile; i++) {
     values.push_back(RandomString(&rnd, 990));
     ASSERT_OK(Put(1, Key(i), values[i]));
   }
+  // put extra key to trigger flush
+  ASSERT_OK(Put(1, "", ""));
   dbfull()->TEST_WaitForCompact();
 
   ASSERT_EQ(NumTableFilesAtLevel(0, 1), 0);
@@ -847,6 +856,8 @@ TEST_P(DBCompactionTestWithParam, LevelCompactionThirdPath) {
   options.db_paths.emplace_back(dbname_, 500 * 1024);
   options.db_paths.emplace_back(dbname_ + "_2", 4 * 1024 * 1024);
   options.db_paths.emplace_back(dbname_ + "_3", 1024 * 1024 * 1024);
+  options.memtable_factory.reset(
+      new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1));
   options.compaction_style = kCompactionStyleLevel;
   options.write_buffer_size = 110 << 10;  // 110KB
   options.arena_block_size = 4 << 10;
@@ -962,6 +973,8 @@ TEST_P(DBCompactionTestWithParam, LevelCompactionPathUse) {
   options.db_paths.emplace_back(dbname_, 500 * 1024);
   options.db_paths.emplace_back(dbname_ + "_2", 4 * 1024 * 1024);
   options.db_paths.emplace_back(dbname_ + "_3", 1024 * 1024 * 1024);
+  options.memtable_factory.reset(
+      new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1));
   options.compaction_style = kCompactionStyleLevel;
   options.write_buffer_size = 110 << 10;  // 110KB
   options.arena_block_size = 4 << 10;
@@ -1228,6 +1241,7 @@ TEST_F(DBCompactionTest, L0_CompactionBug_Issue44_b) {
 TEST_P(DBCompactionTestWithParam, ManualCompaction) {
   Options options = CurrentOptions();
   options.max_subcompactions = max_subcompactions_;
+  options.statistics = rocksdb::CreateDBStatistics();
   CreateAndReopenWithCF({"pikachu"}, options);
 
   // iter - 0 with 7 levels
@@ -1259,7 +1273,14 @@ TEST_P(DBCompactionTestWithParam, ManualCompaction) {
     // Compact all
     MakeTables(1, "a", "z", 1);
     ASSERT_EQ("1,0,2", FilesPerLevel(1));
+
+    uint64_t prev_block_cache_add =
+        options.statistics->getTickerCount(BLOCK_CACHE_ADD);
     db_->CompactRange(CompactRangeOptions(), handles_[1], nullptr, nullptr);
+    // Verify manual compaction doesn't fill block cache
+    ASSERT_EQ(prev_block_cache_add,
+              options.statistics->getTickerCount(BLOCK_CACHE_ADD));
+
     ASSERT_EQ("0,0,1", FilesPerLevel(1));
 
     if (iter == 0) {
@@ -1267,6 +1288,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompaction) {
       options.max_background_flushes = 0;
       options.num_levels = 3;
       options.create_if_missing = true;
+      options.statistics = rocksdb::CreateDBStatistics();
       DestroyAndReopen(options);
       CreateAndReopenWithCF({"pikachu"}, options);
     }
@@ -1593,6 +1615,8 @@ TEST_P(DBCompactionTestWithParam, CompressLevelCompaction) {
     return;
   }
   Options options = CurrentOptions();
+  options.memtable_factory.reset(
+      new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1));
   options.compaction_style = kCompactionStyleLevel;
   options.write_buffer_size = 110 << 10;  // 110KB
   options.arena_block_size = 4 << 10;
@@ -1844,11 +1868,58 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
 
 INSTANTIATE_TEST_CASE_P(DBCompactionTestWithParam, DBCompactionTestWithParam,
                         ::testing::Values(1, 4));
-#endif  // !(defined NDEBUG) || !defined(OS_WIN)
+
+class CompactionPriTest : public DBTestBase,
+                          public testing::WithParamInterface<uint32_t> {
+ public:
+  CompactionPriTest() : DBTestBase("/compaction_pri_test") {
+    compaction_pri_ = GetParam();
+  }
+
+  // Required if inheriting from testing::WithParamInterface<>
+  static void SetUpTestCase() {}
+  static void TearDownTestCase() {}
+
+  uint32_t compaction_pri_;
+};
+
+TEST_P(CompactionPriTest, Test) {
+  Options options;
+  options.write_buffer_size = 16 * 1024;
+  options.compaction_pri = static_cast<CompactionPri>(compaction_pri_);
+  options.hard_pending_compaction_bytes_limit = 256 * 1024;
+  options.max_bytes_for_level_base = 64 * 1024;
+  options.max_bytes_for_level_multiplier = 4;
+  options.compression = kNoCompression;
+  options = CurrentOptions(options);
+  DestroyAndReopen(options);
+
+  Random rnd(301);
+  const int kNKeys = 5000;
+  int keys[kNKeys];
+  for (int i = 0; i < kNKeys; i++) {
+    keys[i] = i;
+  }
+  std::random_shuffle(std::begin(keys), std::end(keys));
+
+  for (int i = 0; i < kNKeys; i++) {
+    ASSERT_OK(Put(Key(keys[i]), RandomString(&rnd, 102)));
+  }
+
+  dbfull()->TEST_WaitForCompact();
+  for (int i = 0; i < kNKeys; i++) {
+    ASSERT_NE("NOT_FOUND", Get(Key(i)));
+  }
+}
+
+INSTANTIATE_TEST_CASE_P(CompactionPriTest, CompactionPriTest,
+                        ::testing::Values(0, 1, 2));
+
+#endif // !defined(ROCKSDB_LITE)
 }  // namespace rocksdb
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
diff --git a/src/rocksdb/db/db_dynamic_level_test.cc b/src/rocksdb/db/db_dynamic_level_test.cc
index f4d2b81..f29985e 100644
--- a/src/rocksdb/db/db_dynamic_level_test.cc
+++ b/src/rocksdb/db/db_dynamic_level_test.cc
@@ -10,10 +10,10 @@
 // Introduction of SyncPoint effectively disabled building and running this test
 // in Release build.
 // which is a pity, it is a good test
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
 
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
 
 namespace rocksdb {
 class DBTestDynamicLevel : public DBTestBase {
@@ -484,10 +484,10 @@ TEST_F(DBTestDynamicLevel, MigrateToDynamicLevelMaxBytesBase) {
 }
 }  // namespace rocksdb
 
-#endif  // !(defined NDEBUG) || !defined(OS_WIN)
+#endif  // !defined(ROCKSDB_LITE)
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
diff --git a/src/rocksdb/db/db_impl.cc b/src/rocksdb/db/db_impl.cc
index cf4fa74..148fe17 100644
--- a/src/rocksdb/db/db_impl.cc
+++ b/src/rocksdb/db/db_impl.cc
@@ -19,6 +19,7 @@
 #include <algorithm>
 #include <climits>
 #include <cstdio>
+#include <map>
 #include <set>
 #include <stdexcept>
 #include <string>
@@ -50,6 +51,8 @@
 #include "db/write_batch_internal.h"
 #include "db/write_callback.h"
 #include "db/writebuffer.h"
+#include "memtable/hash_linklist_rep.h"
+#include "memtable/hash_skiplist_rep.h"
 #include "port/likely.h"
 #include "port/port.h"
 #include "rocksdb/cache.h"
@@ -63,6 +66,7 @@
 #include "rocksdb/status.h"
 #include "rocksdb/table.h"
 #include "rocksdb/version.h"
+#include "rocksdb/wal_filter.h"
 #include "table/block.h"
 #include "table/block_based_table_factory.h"
 #include "table/merger.h"
@@ -77,12 +81,12 @@
 #include "util/db_info_dumper.h"
 #include "util/file_reader_writer.h"
 #include "util/file_util.h"
-#include "util/hash_linklist_rep.h"
-#include "util/hash_skiplist_rep.h"
 #include "util/iostats_context_imp.h"
 #include "util/log_buffer.h"
 #include "util/logging.h"
 #include "util/mutexlock.h"
+#include "util/options_helper.h"
+#include "util/options_parser.h"
 #include "util/perf_context_imp.h"
 #include "util/stop_watch.h"
 #include "util/string_util.h"
@@ -132,8 +136,7 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
   }
 
   if (result.info_log == nullptr) {
-    Status s = CreateLoggerFromOptions(dbname, result.db_log_dir, src.env,
-                                       result, &result.info_log);
+    Status s = CreateLoggerFromOptions(dbname, result, &result.info_log);
     if (!s.ok()) {
       // No place suitable for logging
       result.info_log = nullptr;
@@ -150,6 +153,10 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
     }
   }
 
+  if (result.WAL_ttl_seconds > 0 || result.WAL_size_limit_MB > 0) {
+    result.recycle_log_file_num = false;
+  }
+
   if (result.wal_dir.empty()) {
     // Use dbname as default
     result.wal_dir = dbname;
@@ -245,8 +252,10 @@ DBImpl::DBImpl(const DBOptions& options, const std::string& dbname)
       unscheduled_flushes_(0),
       unscheduled_compactions_(0),
       bg_compaction_scheduled_(0),
+      num_running_compactions_(0),
       bg_manual_only_(0),
       bg_flush_scheduled_(0),
+      num_running_flushes_(0),
       manual_compaction_(nullptr),
       disable_delete_obsolete_files_(0),
       delete_obsolete_files_next_run_(
@@ -407,14 +416,14 @@ Status DBImpl::NewDB() {
   {
     unique_ptr<WritableFile> file;
     EnvOptions env_options = env_->OptimizeForManifestWrite(env_options_);
-    s = env_->NewWritableFile(manifest, &file, env_options);
+    s = NewWritableFile(env_, manifest, &file, env_options);
     if (!s.ok()) {
       return s;
     }
     file->SetPreallocationBlockSize(db_options_.manifest_preallocation_size);
     unique_ptr<WritableFileWriter> file_writer(
         new WritableFileWriter(std::move(file), env_options));
-    log::Writer log(std::move(file_writer));
+    log::Writer log(std::move(file_writer), 0, false);
     std::string record;
     new_db.EncodeTo(&record);
     s = log.AddRecord(record);
@@ -599,7 +608,13 @@ void DBImpl::FindObsoleteFiles(JobContext* job_context, bool force,
     // find newly obsoleted log files
     while (alive_log_files_.begin()->number < min_log_number) {
       auto& earliest = *alive_log_files_.begin();
-      job_context->log_delete_files.push_back(earliest.number);
+      if (db_options_.recycle_log_file_num > log_recycle_files.size()) {
+        Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
+            "adding log %" PRIu64 " to recycle list\n", earliest.number);
+        log_recycle_files.push_back(earliest.number);
+      } else {
+        job_context->log_delete_files.push_back(earliest.number);
+      }
       total_log_size_ -= earliest.size;
       alive_log_files_.pop_front();
       // Current log should always stay alive since it can't have
@@ -722,8 +737,12 @@ void DBImpl::PurgeObsoleteFiles(const JobContext& state) {
         // Also, SetCurrentFile creates a temp file when writing out new
         // manifest, which is equal to state.pending_manifest_file_number. We
         // should not delete that file
+        //
+        // TODO(yhchiang): carefully modify the third condition to safely
+        //                 remove the temp options files.
         keep = (sst_live_map.find(number) != sst_live_map.end()) ||
-               (number == state.pending_manifest_file_number);
+               (number == state.pending_manifest_file_number) ||
+               (to_delete.find(kOptionsFileNamePrefix) != std::string::npos);
         break;
       case kInfoLogFile:
         keep = true;
@@ -735,6 +754,7 @@ void DBImpl::PurgeObsoleteFiles(const JobContext& state) {
       case kDBLockFile:
       case kIdentityFile:
       case kMetaDatabase:
+      case kOptionsFile:
         keep = true;
         break;
     }
@@ -1107,28 +1127,14 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
     // paranoid_checks==false so that corruptions cause entire commits
     // to be skipped instead of propagating bad information (like overly
     // large sequence numbers).
-    log::Reader reader(std::move(file_reader), &reporter, true /*checksum*/,
-                       0 /*initial_offset*/);
+    log::Reader reader(db_options_.info_log, std::move(file_reader), &reporter,
+                       true /*checksum*/, 0 /*initial_offset*/, log_number,
+		       &db_options_);
     Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
         "Recovering log #%" PRIu64 " mode %d skip-recovery %d", log_number,
         db_options_.wal_recovery_mode, !continue_replay_log);
 
     // Determine if we should tolerate incomplete records at the tail end of the
-    // log
-    bool report_eof_inconsistency;
-    if (db_options_.wal_recovery_mode ==
-        WALRecoveryMode::kAbsoluteConsistency) {
-      // in clean shutdown we don't expect any error in the log files
-      report_eof_inconsistency = true;
-    } else {
-      // for other modes ignore only incomplete records in the last log file
-      // which is presumably due to write in progress during restart
-      report_eof_inconsistency = false;
-
-      // TODO krad: Evaluate if we need to move to a more strict mode where we
-      // restrict the inconsistency to only the last log
-    }
-
     // Read all the records and add to a memtable
     std::string scratch;
     Slice record;
@@ -1143,9 +1149,10 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
       }
     }
 
-    while (continue_replay_log &&
-           reader.ReadRecord(&record, &scratch, report_eof_inconsistency) &&
-           status.ok()) {
+    while (
+        continue_replay_log &&
+        reader.ReadRecord(&record, &scratch, db_options_.wal_recovery_mode) &&
+        status.ok()) {
       if (record.size() < 12) {
         reporter.Corruption(record.size(),
                             Status::Corruption("log record too small"));
@@ -1153,6 +1160,80 @@ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
       }
       WriteBatchInternal::SetContents(&batch, record);
 
+#ifndef ROCKSDB_LITE
+      if (db_options_.wal_filter != nullptr) {
+        WriteBatch new_batch;
+        bool batch_changed = false;
+
+        WalFilter::WalProcessingOption wal_processing_option =
+            db_options_.wal_filter->LogRecord(batch, &new_batch,
+                                              &batch_changed);
+
+        switch (wal_processing_option) {
+          case WalFilter::WalProcessingOption::kContinueProcessing:
+            // do nothing, proceeed normally
+            break;
+          case WalFilter::WalProcessingOption::kIgnoreCurrentRecord:
+            // skip current record
+            continue;
+          case WalFilter::WalProcessingOption::kStopReplay:
+            // skip current record and stop replay
+            continue_replay_log = false;
+            continue;
+          case WalFilter::WalProcessingOption::kCorruptedRecord: {
+            status = Status::Corruption("Corruption reported by Wal Filter ",
+                                        db_options_.wal_filter->Name());
+            MaybeIgnoreError(&status);
+            if (!status.ok()) {
+              reporter.Corruption(record.size(), status);
+              continue;
+            }
+            break;
+          }
+          default: {
+            assert(false);  // unhandled case
+            status = Status::NotSupported(
+                "Unknown WalProcessingOption returned"
+                " by Wal Filter ",
+                db_options_.wal_filter->Name());
+            MaybeIgnoreError(&status);
+            if (!status.ok()) {
+              return status;
+            } else {
+              // Ignore the error with current record processing.
+              continue;
+            }
+          }
+        }
+
+        if (batch_changed) {
+          // Make sure that the count in the new batch is
+          // within the orignal count.
+          int new_count = WriteBatchInternal::Count(&new_batch);
+          int original_count = WriteBatchInternal::Count(&batch);
+          if (new_count > original_count) {
+            Log(InfoLogLevel::FATAL_LEVEL, db_options_.info_log,
+                "Recovering log #%" PRIu64
+                " mode %d log filter %s returned "
+                "more records (%d) than original (%d) which is not allowed. "
+                "Aborting recovery.",
+                log_number, db_options_.wal_recovery_mode,
+                db_options_.wal_filter->Name(), new_count, original_count);
+            status = Status::NotSupported(
+                "More than original # of records "
+                "returned by Wal Filter ",
+                db_options_.wal_filter->Name());
+            return status;
+          }
+          // Set the same sequence number in the new_batch
+          // as the original batch.
+          WriteBatchInternal::SetSequence(&new_batch,
+                                          WriteBatchInternal::Sequence(&batch));
+          batch = new_batch;
+        }
+      }
+#endif  // ROCKSDB_LITE
+
       // If column family was not found, it might mean that the WAL write
       // batch references to the column family that was dropped after the
       // insert. We don't want to fail the whole write batch in that case --
@@ -1317,8 +1398,8 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
       s = BuildTable(
           dbname_, env_, *cfd->ioptions(), env_options_, cfd->table_cache(),
           iter.get(), &meta, cfd->internal_comparator(),
-          cfd->int_tbl_prop_collector_factories(), snapshots_.GetAll(),
-          GetCompressionFlush(*cfd->ioptions()),
+          cfd->int_tbl_prop_collector_factories(), cfd->GetID(),
+          snapshots_.GetAll(), GetCompressionFlush(*cfd->ioptions()),
           cfd->ioptions()->compression_opts, paranoid_file_checks,
           cfd->internal_stats(), Env::IO_HIGH, &info.table_properties);
       LogFlush(db_options_.info_log);
@@ -1412,15 +1493,16 @@ Status DBImpl::FlushMemTableToOutputFile(
   if (s.ok()) {
     // may temporarily unlock and lock the mutex.
     NotifyOnFlushCompleted(cfd, &file_meta, mutable_cf_options,
-                           job_context->job_id);
+                           job_context->job_id, flush_job.GetTableProperties());
   }
 #endif  // ROCKSDB_LITE
   return s;
 }
 
-void DBImpl::NotifyOnFlushCompleted(
-    ColumnFamilyData* cfd, FileMetaData* file_meta,
-    const MutableCFOptions& mutable_cf_options, int job_id) {
+void DBImpl::NotifyOnFlushCompleted(ColumnFamilyData* cfd,
+                                    FileMetaData* file_meta,
+                                    const MutableCFOptions& mutable_cf_options,
+                                    int job_id, TableProperties prop) {
 #ifndef ROCKSDB_LITE
   if (db_options_.listeners.size() == 0U) {
     return;
@@ -1450,6 +1532,7 @@ void DBImpl::NotifyOnFlushCompleted(
     info.triggered_writes_stop = triggered_writes_stop;
     info.smallest_seqno = file_meta->smallest_seqno;
     info.largest_seqno = file_meta->largest_seqno;
+    info.table_properties = prop;
     for (auto listener : db_options_.listeners) {
       listener->OnFlushCompleted(this, info);
     }
@@ -1690,17 +1773,23 @@ Status DBImpl::CompactFilesImpl(
   c.reset(cfd->compaction_picker()->FormCompaction(
       compact_options, input_files, output_level, version->storage_info(),
       *cfd->GetLatestMutableCFOptions(), output_path_id));
-  assert(c);
+  if (!c) {
+    return Status::Aborted("Another Level 0 compaction is running");
+  }
   c->SetInputVersion(version);
   // deletion compaction currently not allowed in CompactFiles.
   assert(!c->deletion_compaction());
 
+  SequenceNumber earliest_write_conflict_snapshot;
+  std::vector<SequenceNumber> snapshot_seqs =
+      snapshots_.GetAll(&earliest_write_conflict_snapshot);
+
   assert(is_snapshot_supported_ || snapshots_.empty());
   CompactionJob compaction_job(
       job_context->job_id, c.get(), db_options_, env_options_, versions_.get(),
       &shutting_down_, log_buffer, directories_.GetDbDir(),
-      directories_.GetDataDir(c->output_path_id()), stats_, snapshots_.GetAll(),
-      table_cache_, &event_logger_,
+      directories_.GetDataDir(c->output_path_id()), stats_, snapshot_seqs,
+      earliest_write_conflict_snapshot, table_cache_, &event_logger_,
       c->mutable_cf_options()->paranoid_file_checks,
       c->mutable_cf_options()->compaction_measure_io_stats, dbname_,
       nullptr);  // Here we pass a nullptr for CompactionJobStats because
@@ -1719,6 +1808,8 @@ Status DBImpl::CompactFilesImpl(
   compaction_job.Prepare();
 
   mutex_.Unlock();
+  TEST_SYNC_POINT("CompactFilesImpl:0");
+  TEST_SYNC_POINT("CompactFilesImpl:1");
   compaction_job.Run();
   mutex_.Lock();
 
@@ -1764,6 +1855,9 @@ Status DBImpl::PauseBackgroundWork() {
 
 Status DBImpl::ContinueBackgroundWork() {
   InstrumentedMutexLock guard_lock(&mutex_);
+  if (bg_work_paused_ == 0) {
+    return Status::InvalidArgument();
+  }
   assert(bg_work_paused_ > 0);
   bg_work_paused_--;
   if (bg_work_paused_ == 0) {
@@ -1795,12 +1889,19 @@ void DBImpl::NotifyOnCompactionCompleted(
     info.base_input_level = c->start_level();
     info.output_level = c->output_level();
     info.stats = compaction_job_stats;
+    info.table_properties = c->GetOutputTableProperties();
     for (size_t i = 0; i < c->num_input_levels(); ++i) {
       for (const auto fmd : *c->inputs(i)) {
-        info.input_files.push_back(
-            TableFileName(db_options_.db_paths,
-                          fmd->fd.GetNumber(),
-                          fmd->fd.GetPathId()));
+        auto fn = TableFileName(db_options_.db_paths, fmd->fd.GetNumber(),
+                                fmd->fd.GetPathId());
+        info.input_files.push_back(fn);
+        if (info.table_properties.count(fn) == 0) {
+          std::shared_ptr<const TableProperties> tp;
+          auto s = cfd->current()->GetTableProperties(&tp, fmd, &fn);
+          if (s.ok()) {
+            info.table_properties[fn] = tp;
+          }
+        }
       }
     }
     for (const auto newf : c->edit()->GetNewFiles()) {
@@ -1834,12 +1935,22 @@ Status DBImpl::SetOptions(ColumnFamilyHandle* column_family,
 
   MutableCFOptions new_options;
   Status s;
+  Status persist_options_status;
   {
     InstrumentedMutexLock l(&mutex_);
     s = cfd->SetOptions(options_map);
     if (s.ok()) {
       new_options = *cfd->GetLatestMutableCFOptions();
     }
+    if (s.ok()) {
+      // Persist RocksDB options under the single write thread
+      WriteThread::Writer w;
+      write_thread_.EnterUnbatched(&w, &mutex_);
+
+      persist_options_status = WriteOptionsFile();
+
+      write_thread_.ExitUnbatched(&w);
+    }
   }
 
   Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
@@ -1854,6 +1965,16 @@ Status DBImpl::SetOptions(ColumnFamilyHandle* column_family,
         db_options_.info_log, "[%s] SetOptions succeeded",
         cfd->GetName().c_str());
     new_options.Dump(db_options_.info_log.get());
+    if (!persist_options_status.ok()) {
+      if (db_options_.fail_if_options_file_error) {
+        s = Status::IOError(
+            "SetOptions succeeded, but unable to persist options",
+            persist_options_status.ToString());
+      }
+      Warn(db_options_.info_log,
+           "Unable to persist options in SetOptions() -- %s",
+           persist_options_status.ToString().c_str());
+    }
   } else {
     Log(InfoLogLevel::WARN_LEVEL, db_options_.info_log,
         "[%s] SetOptions failed", cfd->GetName().c_str());
@@ -2158,6 +2279,23 @@ Status DBImpl::RunManualCompaction(ColumnFamilyData* cfd, int input_level,
   return manual.status;
 }
 
+InternalIterator* DBImpl::NewInternalIterator(
+    Arena* arena, ColumnFamilyHandle* column_family) {
+  ColumnFamilyData* cfd;
+  if (column_family == nullptr) {
+    cfd = default_cf_handle_->cfd();
+  } else {
+    auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
+    cfd = cfh->cfd();
+  }
+
+  mutex_.Lock();
+  SuperVersion* super_version = cfd->GetSuperVersion()->Ref();
+  mutex_.Unlock();
+  ReadOptions roptions;
+  return NewInternalIterator(roptions, cfd, super_version, arena);
+}
+
 Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
                              const FlushOptions& flush_options) {
   Status s;
@@ -2208,6 +2346,24 @@ Status DBImpl::WaitForFlushMemTable(ColumnFamilyData* cfd) {
   return s;
 }
 
+Status DBImpl::EnableAutoCompaction(
+    const std::vector<ColumnFamilyHandle*>& column_family_handles) {
+  Status s;
+  for (auto cf_ptr : column_family_handles) {
+    // check options here, enable only if didn't initially disable
+    if (s.ok()) {
+      s = this->SetOptions(cf_ptr, {{"disable_auto_compactions", "false"}});
+    }
+  }
+
+  if (s.ok()) {
+    InstrumentedMutexLock guard_lock(&mutex_);
+    MaybeScheduleFlushOrCompaction();
+  }
+
+  return s;
+}
+
 void DBImpl::MaybeScheduleFlushOrCompaction() {
   mutex_.AssertHeld();
   if (!opened_successfully_) {
@@ -2377,6 +2533,7 @@ void DBImpl::BackgroundCallFlush() {
   LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, db_options_.info_log.get());
   {
     InstrumentedMutexLock l(&mutex_);
+    num_running_flushes_++;
 
     auto pending_outputs_inserted_elem =
         CaptureCurrentFileNumberInPendingOutputs();
@@ -2422,6 +2579,8 @@ void DBImpl::BackgroundCallFlush() {
       mutex_.Lock();
     }
 
+    assert(num_running_flushes_ > 0);
+    num_running_flushes_--;
     bg_flush_scheduled_--;
     // See if there's more work to be done
     MaybeScheduleFlushOrCompaction();
@@ -2437,17 +2596,19 @@ void DBImpl::BackgroundCallFlush() {
 void DBImpl::BackgroundCallCompaction() {
   bool made_progress = false;
   JobContext job_context(next_job_id_.fetch_add(1), true);
-
+  TEST_SYNC_POINT("BackgroundCallCompaction:0");
   MaybeDumpStats();
   LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, db_options_.info_log.get());
   {
     InstrumentedMutexLock l(&mutex_);
+    num_running_compactions_++;
 
     auto pending_outputs_inserted_elem =
         CaptureCurrentFileNumberInPendingOutputs();
 
     assert(bg_compaction_scheduled_);
     Status s = BackgroundCompaction(&made_progress, &job_context, &log_buffer);
+    TEST_SYNC_POINT("BackgroundCallCompaction:1");
     if (!s.ok() && !s.IsShutdownInProgress()) {
       // Wait a little bit before retrying background compaction in
       // case this is an environmental problem and we do not want to
@@ -2490,6 +2651,8 @@ void DBImpl::BackgroundCallCompaction() {
       mutex_.Lock();
     }
 
+    assert(num_running_compactions_ > 0);
+    num_running_compactions_--;
     bg_compaction_scheduled_--;
 
     versions_->GetColumnFamilySet()->FreeDeadColumnFamilies();
@@ -2717,12 +2880,17 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
     int output_level  __attribute__((unused)) = c->output_level();
     TEST_SYNC_POINT_CALLBACK("DBImpl::BackgroundCompaction:NonTrivial",
                              &output_level);
+
+    SequenceNumber earliest_write_conflict_snapshot;
+    std::vector<SequenceNumber> snapshot_seqs =
+        snapshots_.GetAll(&earliest_write_conflict_snapshot);
+
     assert(is_snapshot_supported_ || snapshots_.empty());
     CompactionJob compaction_job(
         job_context->job_id, c.get(), db_options_, env_options_,
         versions_.get(), &shutting_down_, log_buffer, directories_.GetDbDir(),
-        directories_.GetDataDir(c->output_path_id()), stats_,
-        snapshots_.GetAll(), table_cache_, &event_logger_,
+        directories_.GetDataDir(c->output_path_id()), stats_, snapshot_seqs,
+        earliest_write_conflict_snapshot, table_cache_, &event_logger_,
         c->mutable_cf_options()->paranoid_file_checks,
         c->mutable_cf_options()->compaction_measure_io_stats, dbname_,
         &compaction_job_stats);
@@ -2835,11 +3003,11 @@ static void CleanupIteratorState(void* arg1, void* arg2) {
 }
 }  // namespace
 
-Iterator* DBImpl::NewInternalIterator(const ReadOptions& read_options,
-                                      ColumnFamilyData* cfd,
-                                      SuperVersion* super_version,
-                                      Arena* arena) {
-  Iterator* internal_iter;
+InternalIterator* DBImpl::NewInternalIterator(const ReadOptions& read_options,
+                                              ColumnFamilyData* cfd,
+                                              SuperVersion* super_version,
+                                              Arena* arena) {
+  InternalIterator* internal_iter;
   assert(arena != nullptr);
   // Need to create internal iterator from the arena.
   MergeIteratorBuilder merge_iter_builder(&cfd->internal_comparator(), arena);
@@ -3138,7 +3306,8 @@ Status DBImpl::AddFile(ColumnFamilyHandle* column_family,
   file_info.num_entries = table_reader->GetTableProperties()->num_entries;
 
   ParsedInternalKey key;
-  std::unique_ptr<Iterator> iter(table_reader->NewIterator(ReadOptions()));
+  std::unique_ptr<InternalIterator> iter(
+      table_reader->NewIterator(ReadOptions()));
 
   // Get first (smallest) key from file
   iter->SeekToFirst();
@@ -3169,10 +3338,6 @@ Status DBImpl::AddFile(ColumnFamilyHandle* column_family,
   auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
   ColumnFamilyData* cfd = cfh->cfd();
 
-  if (cfd->NumberLevels() <= 1) {
-    return Status::NotSupported(
-        "AddFile requires a database with at least 2 levels");
-  }
   if (file_info->version != 1) {
     return Status::InvalidArgument("Generated table version is not supported");
   }
@@ -3219,48 +3384,44 @@ Status DBImpl::AddFile(ColumnFamilyHandle* column_family,
     WriteThread::Writer w;
     write_thread_.EnterUnbatched(&w, &mutex_);
 
-    // Make sure memtables are empty
-    if (!cfd->mem()->IsEmpty() || cfd->imm()->NumNotFlushed() > 0) {
-      // Cannot add the file since the keys in memtable
-      // will hide the keys in file
-      status = Status::NotSupported("Memtable is not empty");
-    }
-
-    // Make sure last sequence number is 0, if there are existing files then
-    // they should have sequence number = 0
-    if (status.ok() && versions_->LastSequence() > 0) {
-      status = Status::NotSupported("Last Sequence number is not zero");
+    if (!snapshots_.empty()) {
+      // Check that no snapshots are being held
+      status =
+          Status::NotSupported("Cannot add a file while holding snapshots");
     }
 
-    auto* vstorage = cfd->current()->storage_info();
     if (status.ok()) {
-      // Make sure that the key range in the file we will add does not overlap
-      // with previously added files
-      Slice smallest_user_key = meta.smallest.user_key();
-      Slice largest_user_key = meta.largest.user_key();
-      for (int level = 0; level < vstorage->num_non_empty_levels(); level++) {
-        if (vstorage->OverlapInLevel(level, &smallest_user_key,
-                                     &largest_user_key)) {
-          status = Status::NotSupported("Cannot add overlapping files");
-          break;
+      // Verify that added file key range dont overlap with any keys in DB
+      SuperVersion* sv = cfd->GetSuperVersion()->Ref();
+      Arena arena;
+      ReadOptions ro;
+      ro.total_order_seek = true;
+      ScopedArenaIterator iter(NewInternalIterator(ro, cfd, sv, &arena));
+
+      InternalKey range_start(file_info->smallest_key, kMaxSequenceNumber,
+                              kTypeValue);
+      iter->Seek(range_start.Encode());
+      status = iter->status();
+
+      if (status.ok() && iter->Valid()) {
+        ParsedInternalKey seek_result;
+        if (ParseInternalKey(iter->key(), &seek_result)) {
+          auto* vstorage = cfd->current()->storage_info();
+          if (vstorage->InternalComparator()->user_comparator()->Compare(
+                  seek_result.user_key, file_info->largest_key) <= 0) {
+            status = Status::NotSupported("Cannot add overlapping range");
+          }
+        } else {
+          status = Status::Corruption("DB have corrupted keys");
         }
       }
     }
 
     if (status.ok()) {
-      // We add the file to the last level
-      int target_level = cfd->NumberLevels() - 1;
-      if (cfd->ioptions()->level_compaction_dynamic_level_bytes == false) {
-        // If we are using dynamic level compaction we add the file to
-        // last level with files
-        target_level = vstorage->num_non_empty_levels() - 1;
-        if (target_level <= 0) {
-          target_level = 1;
-        }
-      }
+      // Add file to L0
       VersionEdit edit;
       edit.SetColumnFamily(cfd->GetID());
-      edit.AddFile(target_level, meta.fd.GetNumber(), meta.fd.GetPathId(),
+      edit.AddFile(0, meta.fd.GetNumber(), meta.fd.GetPathId(),
                    meta.fd.GetFileSize(), meta.smallest, meta.largest,
                    meta.smallest_seqno, meta.largest_seqno,
                    meta.marked_for_compaction);
@@ -3302,6 +3463,7 @@ Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& cf_options,
                                   const std::string& column_family_name,
                                   ColumnFamilyHandle** handle) {
   Status s;
+  Status persist_options_status;
   *handle = nullptr;
 
   s = CheckCompressionSupported(cf_options);
@@ -3334,6 +3496,12 @@ Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& cf_options,
       s = versions_->LogAndApply(
           nullptr, MutableCFOptions(opt, ImmutableCFOptions(opt)), &edit,
           &mutex_, directories_.GetDbDir(), false, &cf_options);
+
+      if (s.ok()) {
+        // If the column family was created successfully, we then persist
+        // the updated RocksDB options under the same single write thread
+        persist_options_status = WriteOptionsFile();
+      }
       write_thread_.ExitUnbatched(&w);
     }
     if (s.ok()) {
@@ -3363,6 +3531,17 @@ Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& cf_options,
   if (s.ok()) {
     NewThreadStatusCfInfo(
         reinterpret_cast<ColumnFamilyHandleImpl*>(*handle)->cfd());
+    if (!persist_options_status.ok()) {
+      if (db_options_.fail_if_options_file_error) {
+        s = Status::IOError(
+            "ColumnFamily has been created, but unable to persist"
+            "options in CreateColumnFamily()",
+            persist_options_status.ToString().c_str());
+      }
+      Warn(db_options_.info_log,
+           "Unable to persist options in CreateColumnFamily() -- %s",
+           persist_options_status.ToString().c_str());
+    }
   }
   return s;
 }
@@ -3381,6 +3560,7 @@ Status DBImpl::DropColumnFamily(ColumnFamilyHandle* column_family) {
   edit.SetColumnFamily(cfd->GetID());
 
   Status s;
+  Status options_persist_status;
   {
     InstrumentedMutexLock l(&mutex_);
     if (cfd->IsDropped()) {
@@ -3392,6 +3572,11 @@ Status DBImpl::DropColumnFamily(ColumnFamilyHandle* column_family) {
       write_thread_.EnterUnbatched(&w, &mutex_);
       s = versions_->LogAndApply(cfd, *cfd->GetLatestMutableCFOptions(),
                                  &edit, &mutex_);
+      if (s.ok()) {
+        // If the column family was dropped successfully, we then persist
+        // the updated RocksDB options under the same single write thread
+        options_persist_status = WriteOptionsFile();
+      }
       write_thread_.ExitUnbatched(&w);
     }
 
@@ -3419,8 +3604,19 @@ Status DBImpl::DropColumnFamily(ColumnFamilyHandle* column_family) {
     max_total_in_memory_state_ -= mutable_cf_options->write_buffer_size *
                                   mutable_cf_options->max_write_buffer_number;
     Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
-        "Dropped column family with id %u\n",
-        cfd->GetID());
+        "Dropped column family with id %u\n", cfd->GetID());
+
+    if (!options_persist_status.ok()) {
+      if (db_options_.fail_if_options_file_error) {
+        s = Status::IOError(
+            "ColumnFamily has been dropped, but unable to persist "
+            "options in DropColumnFamily()",
+            options_persist_status.ToString().c_str());
+      }
+      Warn(db_options_.info_log,
+           "Unable to persist options in DropColumnFamily() -- %s",
+           options_persist_status.ToString().c_str());
+    }
   } else {
     Log(InfoLogLevel::ERROR_LEVEL, db_options_.info_log,
         "Dropping column family with id %u FAILED -- %s\n",
@@ -3476,10 +3672,11 @@ Iterator* DBImpl::NewIterator(const ReadOptions& read_options,
 #else
     SuperVersion* sv = cfd->GetReferencedSuperVersion(&mutex_);
     auto iter = new ForwardIterator(this, read_options, cfd, sv);
-    return NewDBIterator(env_, *cfd->ioptions(), cfd->user_comparator(), iter,
+    return NewDBIterator(
+        env_, *cfd->ioptions(), cfd->user_comparator(), iter,
         kMaxSequenceNumber,
         sv->mutable_cf_options.max_sequential_skip_in_iterations,
-        read_options.iterate_upper_bound);
+        read_options.iterate_upper_bound, read_options.prefix_same_as_start);
 #endif
   } else {
     SequenceNumber latest_snapshot = versions_->LastSequence();
@@ -3534,11 +3731,11 @@ Iterator* DBImpl::NewIterator(const ReadOptions& read_options,
     // likely that any iterator pointer is close to the iterator it points to so
     // that they are likely to be in the same cache line and/or page.
     ArenaWrappedDBIter* db_iter = NewArenaWrappedDbIterator(
-        env_, *cfd->ioptions(), cfd->user_comparator(),
-        snapshot, sv->mutable_cf_options.max_sequential_skip_in_iterations,
-        read_options.iterate_upper_bound);
+        env_, *cfd->ioptions(), cfd->user_comparator(), snapshot,
+        sv->mutable_cf_options.max_sequential_skip_in_iterations,
+        read_options.iterate_upper_bound, read_options.prefix_same_as_start);
 
-    Iterator* internal_iter =
+    InternalIterator* internal_iter =
         NewInternalIterator(read_options, cfd, sv, db_iter->GetArena());
     db_iter->SetIterUnderDBIter(internal_iter);
 
@@ -3605,8 +3802,8 @@ Status DBImpl::NewIterators(
       ArenaWrappedDBIter* db_iter = NewArenaWrappedDbIterator(
           env_, *cfd->ioptions(), cfd->user_comparator(), snapshot,
           sv->mutable_cf_options.max_sequential_skip_in_iterations);
-      Iterator* internal_iter = NewInternalIterator(
-          read_options, cfd, sv, db_iter->GetArena());
+      InternalIterator* internal_iter =
+          NewInternalIterator(read_options, cfd, sv, db_iter->GetArena());
       db_iter->SetIterUnderDBIter(internal_iter);
       iterators->push_back(db_iter);
     }
@@ -3615,7 +3812,15 @@ Status DBImpl::NewIterators(
   return Status::OK();
 }
 
-const Snapshot* DBImpl::GetSnapshot() {
+const Snapshot* DBImpl::GetSnapshot() { return GetSnapshotImpl(false); }
+
+#ifndef ROCKSDB_LITE
+const Snapshot* DBImpl::GetSnapshotForWriteConflictBoundary() {
+  return GetSnapshotImpl(true);
+}
+#endif  // ROCKSDB_LITE
+
+const Snapshot* DBImpl::GetSnapshotImpl(bool is_write_conflict_boundary) {
   int64_t unix_time = 0;
   env_->GetCurrentTime(&unix_time);  // Ignore error
   SnapshotImpl* s = new SnapshotImpl;
@@ -3626,7 +3831,8 @@ const Snapshot* DBImpl::GetSnapshot() {
     delete s;
     return nullptr;
   }
-  return snapshots_.New(s, versions_->LastSequence(), unix_time);
+  return snapshots_.New(s, versions_->LastSequence(), unix_time,
+                        is_write_conflict_boundary);
 }
 
 void DBImpl::ReleaseSnapshot(const Snapshot* s) {
@@ -3769,25 +3975,36 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
     MaybeScheduleFlushOrCompaction();
   } else if (UNLIKELY(write_buffer_.ShouldFlush())) {
     Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
-        "Flushing all column families. Write buffer is using %" PRIu64
-        " bytes out of a total of %" PRIu64 ".",
+        "Flushing column family with largest mem table size. Write buffer is "
+        "using %" PRIu64 " bytes out of a total of %" PRIu64 ".",
         write_buffer_.memory_usage(), write_buffer_.buffer_size());
     // no need to refcount because drop is happening in write thread, so can't
     // happen while we're in the write thread
+    ColumnFamilyData* largest_cfd = nullptr;
+    size_t largest_cfd_size = 0;
+
     for (auto cfd : *versions_->GetColumnFamilySet()) {
       if (cfd->IsDropped()) {
         continue;
       }
       if (!cfd->mem()->IsEmpty()) {
-        status = SwitchMemtable(cfd, &context);
-        if (!status.ok()) {
-          break;
+        // We only consider active mem table, hoping immutable memtable is
+        // already in the process of flushing.
+        size_t cfd_size = cfd->mem()->ApproximateMemoryUsage();
+        if (largest_cfd == nullptr || cfd_size > largest_cfd_size) {
+          largest_cfd = cfd;
+          largest_cfd_size = cfd_size;
         }
-        cfd->imm()->FlushRequested();
-        SchedulePendingFlush(cfd);
       }
     }
-    MaybeScheduleFlushOrCompaction();
+    if (largest_cfd != nullptr) {
+      status = SwitchMemtable(largest_cfd, &context);
+      if (status.ok()) {
+        largest_cfd->imm()->FlushRequested();
+        SchedulePendingFlush(largest_cfd);
+        MaybeScheduleFlushOrCompaction();
+      }
+    }
   }
 
   if (UNLIKELY(status.ok() && !bg_error_.ok())) {
@@ -3850,33 +4067,48 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
   // At this point the mutex is unlocked
 
   if (status.ok()) {
-      WriteBatch* updates = nullptr;
-      if (write_batch_group.size() == 1) {
-        updates = write_batch_group[0];
-      } else {
-        updates = &tmp_batch_;
-        for (size_t i = 0; i < write_batch_group.size(); ++i) {
-          WriteBatchInternal::Append(updates, write_batch_group[i]);
-        }
+      int total_count = 0;
+      uint64_t total_byte_size = 0;
+      for (auto b : write_batch_group) {
+        total_count += WriteBatchInternal::Count(b);
+        total_byte_size = WriteBatchInternal::AppendedByteSize(
+            total_byte_size, WriteBatchInternal::ByteSize(b));
       }
 
       const SequenceNumber current_sequence = last_sequence + 1;
-      WriteBatchInternal::SetSequence(updates, current_sequence);
-      int my_batch_count = WriteBatchInternal::Count(updates);
-      last_sequence += my_batch_count;
-      const uint64_t batch_size = WriteBatchInternal::ByteSize(updates);
+      last_sequence += total_count;
+
       // Record statistics
-      RecordTick(stats_, NUMBER_KEYS_WRITTEN, my_batch_count);
-      RecordTick(stats_, BYTES_WRITTEN, batch_size);
+      RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count);
+      RecordTick(stats_, BYTES_WRITTEN, total_byte_size);
+      PERF_TIMER_STOP(write_pre_and_post_process_time);
+
       if (write_options.disableWAL) {
         flush_on_destroy_ = true;
       }
-      PERF_TIMER_STOP(write_pre_and_post_process_time);
 
       uint64_t log_size = 0;
       if (!write_options.disableWAL) {
         PERF_TIMER_GUARD(write_wal_time);
-        Slice log_entry = WriteBatchInternal::Contents(updates);
+
+        WriteBatch* merged_batch = nullptr;
+        if (write_batch_group.size() == 1) {
+          merged_batch = write_batch_group[0];
+        } else {
+          // WAL needs all of the batches flattened into a single batch.
+          // We could avoid copying here with an iov-like AddRecord
+          // interface
+          merged_batch = &tmp_batch_;
+          for (auto b : write_batch_group) {
+            WriteBatchInternal::Append(merged_batch, b);
+          }
+        }
+        WriteBatchInternal::SetSequence(merged_batch, current_sequence);
+
+        assert(WriteBatchInternal::Count(merged_batch) == total_count);
+        assert(WriteBatchInternal::ByteSize(merged_batch) == total_byte_size);
+
+        Slice log_entry = WriteBatchInternal::Contents(merged_batch);
         status = logs_.back().writer->AddRecord(log_entry);
         total_log_size_ += log_entry.size();
         alive_log_files_.back().AddSize(log_entry.size());
@@ -3906,34 +4138,41 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
             status = directories_.GetWalDir()->Fsync();
           }
         }
+
+        if (merged_batch == &tmp_batch_) {
+          tmp_batch_.Clear();
+        }
       }
       if (status.ok()) {
         PERF_TIMER_GUARD(write_memtable_time);
 
         status = WriteBatchInternal::InsertInto(
-            updates, column_family_memtables_.get(),
-            write_options.ignore_missing_column_families, 0, this, false);
-        // A non-OK status here indicates iteration failure (either in-memory
-        // writebatch corruption (very bad), or the client specified invalid
-        // column family).  This will later on trigger bg_error_.
+            write_batch_group, current_sequence, column_family_memtables_.get(),
+            write_options.ignore_missing_column_families,
+            /*log_number*/ 0, this, /*dont_filter_deletes*/ false);
+
+        // A non-OK status here indicates that the state implied by the
+        // WAL has diverged from the in-memory state.  This could be
+        // because of a corrupt write_batch (very bad), or because the
+        // client specified an invalid column family and didn't specify
+        // ignore_missing_column_families.
         //
-        // Note that existing logic was not sound. Any partial failure writing
-        // into the memtable would result in a state that some write ops might
-        // have succeeded in memtable but Status reports error for all writes.
+        // Is setting bg_error_ enough here?  This will at least stop
+        // compaction and fail any further writes.
+        if (!status.ok() && bg_error_.ok()) {
+          bg_error_ = status;
+        }
 
         SetTickerCount(stats_, SEQUENCE_NUMBER, last_sequence);
       }
       PERF_TIMER_START(write_pre_and_post_process_time);
-      if (updates == &tmp_batch_) {
-        tmp_batch_.Clear();
-      }
       mutex_.Lock();
 
       // internal stats
-      default_cf_internal_stats_->AddDBStats(
-          InternalStats::BYTES_WRITTEN, batch_size);
+      default_cf_internal_stats_->AddDBStats(InternalStats::BYTES_WRITTEN,
+                                             total_byte_size);
       default_cf_internal_stats_->AddDBStats(InternalStats::NUMBER_KEYS_WRITTEN,
-                                             my_batch_count);
+                                             total_count);
       if (!write_options.disableWAL) {
         if (write_options.sync) {
           default_cf_internal_stats_->AddDBStats(InternalStats::WAL_FILE_SYNCED,
@@ -4036,6 +4275,12 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
   // Do this without holding the dbmutex lock.
   assert(versions_->prev_log_number() == 0);
   bool creating_new_log = !log_empty_;
+  uint64_t recycle_log_number = 0;
+  if (creating_new_log && db_options_.recycle_log_file_num &&
+      !log_recycle_files.empty()) {
+    recycle_log_number = log_recycle_files.front();
+    log_recycle_files.pop_front();
+  }
   uint64_t new_log_number =
       creating_new_log ? versions_->NewFileNumber() : logfile_number_;
   SuperVersion* new_superversion = nullptr;
@@ -4046,17 +4291,29 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
     if (creating_new_log) {
       EnvOptions opt_env_opt =
           env_->OptimizeForLogWrite(env_options_, db_options_);
-      s = env_->NewWritableFile(
-          LogFileName(db_options_.wal_dir, new_log_number), &lfile,
-          opt_env_opt);
+      if (recycle_log_number) {
+        Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
+            "reusing log %" PRIu64 " from recycle list\n", recycle_log_number);
+        s = env_->ReuseWritableFile(
+            LogFileName(db_options_.wal_dir, new_log_number),
+            LogFileName(db_options_.wal_dir, recycle_log_number), &lfile,
+            opt_env_opt);
+      } else {
+        s = NewWritableFile(env_,
+                            LogFileName(db_options_.wal_dir, new_log_number),
+                            &lfile, opt_env_opt);
+      }
       if (s.ok()) {
         // Our final size should be less than write_buffer_size
         // (compression, etc) but err on the side of caution.
-        lfile->SetPreallocationBlockSize(
-            1.1 * mutable_cf_options.write_buffer_size);
+        lfile->SetPreallocationBlockSize(1.1 *
+                                         mutable_cf_options.write_buffer_size);
         unique_ptr<WritableFileWriter> file_writer(
             new WritableFileWriter(std::move(lfile), opt_env_opt));
-        new_log = new log::Writer(std::move(file_writer));
+        new_log = new log::Writer(std::move(file_writer),
+				  new_log_number,
+                                  db_options_.recycle_log_file_num > 0,
+				  &db_options_);
       }
     }
 
@@ -4125,6 +4382,29 @@ Status DBImpl::GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
 
   return s;
 }
+
+Status DBImpl::GetPropertiesOfTablesInRange(ColumnFamilyHandle* column_family,
+                                            const Range* range, std::size_t n,
+                                            TablePropertiesCollection* props) {
+  auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
+  auto cfd = cfh->cfd();
+
+  // Increment the ref count
+  mutex_.Lock();
+  auto version = cfd->current();
+  version->Ref();
+  mutex_.Unlock();
+
+  auto s = version->GetPropertiesOfTablesInRange(range, n, props);
+
+  // Decrement the ref count
+  mutex_.Lock();
+  version->Unref();
+  mutex_.Unlock();
+
+  return s;
+}
+
 #endif  // ROCKSDB_LITE
 
 const std::string& DBImpl::GetName() const {
@@ -4150,17 +4430,16 @@ bool DBImpl::GetProperty(ColumnFamilyHandle* column_family,
       GetPropertyType(property, &is_int_property, &need_out_of_mutex);
 
   value->clear();
+  auto cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family)->cfd();
   if (is_int_property) {
     uint64_t int_value;
-    bool ret_value = GetIntPropertyInternal(column_family, property_type,
-                                            need_out_of_mutex, &int_value);
+    bool ret_value = GetIntPropertyInternal(
+        cfd, property_type, need_out_of_mutex, false, &int_value);
     if (ret_value) {
       *value = ToString(int_value);
     }
     return ret_value;
   } else {
-    auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
-    auto cfd = cfh->cfd();
     InstrumentedMutexLock l(&mutex_);
     return cfd->internal_stats()->GetStringProperty(property_type, property,
                                                     value);
@@ -4176,31 +4455,70 @@ bool DBImpl::GetIntProperty(ColumnFamilyHandle* column_family,
   if (!is_int_property) {
     return false;
   }
-  return GetIntPropertyInternal(column_family, property_type, need_out_of_mutex,
+  auto cfd = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family)->cfd();
+  return GetIntPropertyInternal(cfd, property_type, need_out_of_mutex, false,
                                 value);
 }
 
-bool DBImpl::GetIntPropertyInternal(ColumnFamilyHandle* column_family,
+bool DBImpl::GetIntPropertyInternal(ColumnFamilyData* cfd,
                                     DBPropertyType property_type,
-                                    bool need_out_of_mutex, uint64_t* value) {
-  auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
-  auto cfd = cfh->cfd();
-
+                                    bool need_out_of_mutex, bool is_locked,
+                                    uint64_t* value) {
   if (!need_out_of_mutex) {
-    InstrumentedMutexLock l(&mutex_);
-    return cfd->internal_stats()->GetIntProperty(property_type, value, this);
+    if (is_locked) {
+      mutex_.AssertHeld();
+      return cfd->internal_stats()->GetIntProperty(property_type, value, this);
+    } else {
+      InstrumentedMutexLock l(&mutex_);
+      return cfd->internal_stats()->GetIntProperty(property_type, value, this);
+    }
   } else {
-    SuperVersion* sv = GetAndRefSuperVersion(cfd);
+    SuperVersion* sv = nullptr;
+    if (!is_locked) {
+      sv = GetAndRefSuperVersion(cfd);
+    } else {
+      sv = cfd->GetSuperVersion();
+    }
 
     bool ret = cfd->internal_stats()->GetIntPropertyOutOfMutex(
         property_type, sv->current, value);
 
-    ReturnAndCleanupSuperVersion(cfd, sv);
+    if (!is_locked) {
+      ReturnAndCleanupSuperVersion(cfd, sv);
+    }
 
     return ret;
   }
 }
 
+bool DBImpl::GetAggregatedIntProperty(const Slice& property,
+                                      uint64_t* aggregated_value) {
+  bool need_out_of_mutex;
+  bool is_int_property;
+  DBPropertyType property_type =
+      GetPropertyType(property, &is_int_property, &need_out_of_mutex);
+  if (!is_int_property) {
+    return false;
+  }
+
+  uint64_t sum = 0;
+  {
+    // Needs mutex to protect the list of column families.
+    InstrumentedMutexLock l(&mutex_);
+    uint64_t value;
+    for (auto* cfd : *versions_->GetColumnFamilySet()) {
+      if (GetIntPropertyInternal(cfd, property_type, need_out_of_mutex, true,
+                                 &value)) {
+        sum += value;
+      } else {
+        return false;
+      }
+    }
+  }
+  *aggregated_value = sum;
+  return true;
+}
+
 SuperVersion* DBImpl::GetAndRefSuperVersion(ColumnFamilyData* cfd) {
   // TODO(ljin): consider using GetReferencedSuperVersion() directly
   return cfd->GetThreadLocalSuperVersion(&mutex_);
@@ -4664,16 +4982,19 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
     EnvOptions soptions(db_options);
     EnvOptions opt_env_options =
         impl->db_options_.env->OptimizeForLogWrite(soptions, impl->db_options_);
-    s = impl->db_options_.env->NewWritableFile(
-        LogFileName(impl->db_options_.wal_dir, new_log_number), &lfile,
-        opt_env_options);
+    s = NewWritableFile(impl->db_options_.env,
+                        LogFileName(impl->db_options_.wal_dir, new_log_number),
+                        &lfile, opt_env_options);
     if (s.ok()) {
       lfile->SetPreallocationBlockSize(1.1 * max_write_buffer_size);
       impl->logfile_number_ = new_log_number;
       unique_ptr<WritableFileWriter> file_writer(
           new WritableFileWriter(std::move(lfile), opt_env_options));
-      impl->logs_.emplace_back(new_log_number,
-                               new log::Writer(std::move(file_writer)));
+      impl->logs_.emplace_back(
+          new_log_number,
+          new log::Writer(std::move(file_writer), new_log_number,
+                          impl->db_options_.recycle_log_file_num > 0,
+			  &impl->db_options_));
 
       // set column family handles
       for (auto cf : column_families) {
@@ -4743,7 +5064,13 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
     }
   }
   TEST_SYNC_POINT("DBImpl::Open:Opened");
+  Status persist_options_status;
   if (s.ok()) {
+    // Persist RocksDB Options before scheduling the compaction.
+    // The WriteOptionsFile() will release and lock the mutex internally.
+    persist_options_status = impl->WriteOptionsFile();
+
+    *dbptr = impl;
     impl->opened_successfully_ = true;
     impl->MaybeScheduleFlushOrCompaction();
   }
@@ -4753,14 +5080,24 @@ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
     Log(InfoLogLevel::INFO_LEVEL, impl->db_options_.info_log, "DB pointer %p",
         impl);
     LogFlush(impl->db_options_.info_log);
-
-    *dbptr = impl;
-  } else {
+    if (!persist_options_status.ok()) {
+      if (db_options.fail_if_options_file_error) {
+        s = Status::IOError(
+            "DB::Open() failed --- Unable to persist Options file",
+            persist_options_status.ToString());
+      }
+      Warn(impl->db_options_.info_log,
+           "Unable to persist options in DB::Open() -- %s",
+           persist_options_status.ToString().c_str());
+    }
+  }
+  if (!s.ok()) {
     for (auto* h : *handles) {
       delete h;
     }
     handles->clear();
     delete impl;
+    *dbptr = nullptr;
   }
   return s;
 }
@@ -4857,6 +5194,7 @@ Status DestroyDB(const std::string& dbname, const Options& options) {
         }
       }
     }
+
     // ignore case where no archival directory is present.
     env->DeleteDir(archivedir);
 
@@ -4868,6 +5206,107 @@ Status DestroyDB(const std::string& dbname, const Options& options) {
   return result;
 }
 
+Status DBImpl::WriteOptionsFile() {
+#ifndef ROCKSDB_LITE
+  mutex_.AssertHeld();
+
+  std::vector<std::string> cf_names;
+  std::vector<ColumnFamilyOptions> cf_opts;
+
+  // This part requires mutex to protect the column family options
+  for (auto cfd : *versions_->GetColumnFamilySet()) {
+    if (cfd->IsDropped()) {
+      continue;
+    }
+    cf_names.push_back(cfd->GetName());
+    cf_opts.push_back(BuildColumnFamilyOptions(
+        *cfd->options(), *cfd->GetLatestMutableCFOptions()));
+  }
+
+  // Unlock during expensive operations.  New writes cannot get here
+  // because the single write thread ensures all new writes get queued.
+  mutex_.Unlock();
+
+  std::string file_name =
+      TempOptionsFileName(GetName(), versions_->NewFileNumber());
+  Status s = PersistRocksDBOptions(GetDBOptions(), cf_names, cf_opts, file_name,
+                                   GetEnv());
+
+  if (s.ok()) {
+    s = RenameTempFileToOptionsFile(file_name);
+  }
+  mutex_.Lock();
+  return s;
+#else
+  return Status::OK();
+#endif  // !ROCKSDB_LITE
+}
+
+#ifndef ROCKSDB_LITE
+namespace {
+void DeleteOptionsFilesHelper(const std::map<uint64_t, std::string>& filenames,
+                              const size_t num_files_to_keep,
+                              const std::shared_ptr<Logger>& info_log,
+                              Env* env) {
+  if (filenames.size() <= num_files_to_keep) {
+    return;
+  }
+  for (auto iter = std::next(filenames.begin(), num_files_to_keep);
+       iter != filenames.end(); ++iter) {
+    if (!env->DeleteFile(iter->second).ok()) {
+      Warn(info_log, "Unable to delete options file %s", iter->second.c_str());
+    }
+  }
+}
+}  // namespace
+#endif  // !ROCKSDB_LITE
+
+Status DBImpl::DeleteObsoleteOptionsFiles() {
+#ifndef ROCKSDB_LITE
+  std::vector<std::string> filenames;
+  // use ordered map to store keep the filenames sorted from the newest
+  // to the oldest.
+  std::map<uint64_t, std::string> options_filenames;
+  Status s;
+  s = GetEnv()->GetChildren(GetName(), &filenames);
+  if (!s.ok()) {
+    return s;
+  }
+  for (auto& filename : filenames) {
+    uint64_t file_number;
+    FileType type;
+    if (ParseFileName(filename, &file_number, &type) && type == kOptionsFile) {
+      options_filenames.insert(
+          {std::numeric_limits<uint64_t>::max() - file_number,
+           GetName() + "/" + filename});
+    }
+  }
+
+  // Keeps the latest 2 Options file
+  const size_t kNumOptionsFilesKept = 2;
+  DeleteOptionsFilesHelper(options_filenames, kNumOptionsFilesKept,
+                           db_options_.info_log, GetEnv());
+  return Status::OK();
+#else
+  return Status::OK();
+#endif  // !ROCKSDB_LITE
+}
+
+Status DBImpl::RenameTempFileToOptionsFile(const std::string& file_name) {
+#ifndef ROCKSDB_LITE
+  Status s;
+  std::string options_file_name =
+      OptionsFileName(GetName(), versions_->NewFileNumber());
+  // Retry if the file name happen to conflict with an existing one.
+  s = GetEnv()->RenameFile(file_name, options_file_name);
+
+  DeleteObsoleteOptionsFiles();
+  return s;
+#else
+  return Status::OK();
+#endif  // !ROCKSDB_LITE
+}
+
 #if ROCKSDB_USING_THREAD_STATUS
 
 void DBImpl::NewThreadStatusCfInfo(
diff --git a/src/rocksdb/db/db_impl.h b/src/rocksdb/db/db_impl.h
index d7cc9db..a02f47b 100644
--- a/src/rocksdb/db/db_impl.h
+++ b/src/rocksdb/db/db_impl.h
@@ -36,11 +36,11 @@
 #include "rocksdb/env.h"
 #include "rocksdb/memtablerep.h"
 #include "rocksdb/transaction_log.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/autovector.h"
 #include "util/event_logger.h"
 #include "util/hash.h"
 #include "util/instrumented_mutex.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/stop_watch.h"
 #include "util/thread_local.h"
 
@@ -122,6 +122,9 @@ class DBImpl : public DB {
   using DB::GetIntProperty;
   virtual bool GetIntProperty(ColumnFamilyHandle* column_family,
                               const Slice& property, uint64_t* value) override;
+  using DB::GetAggregatedIntProperty;
+  virtual bool GetAggregatedIntProperty(const Slice& property,
+                                        uint64_t* aggregated_value) override;
   using DB::GetApproximateSizes;
   virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
                                    const Range* range, int n, uint64_t* sizes,
@@ -141,6 +144,9 @@ class DBImpl : public DB {
   virtual Status PauseBackgroundWork() override;
   virtual Status ContinueBackgroundWork() override;
 
+  virtual Status EnableAutoCompaction(
+      const std::vector<ColumnFamilyHandle*>& column_family_handles) override;
+
   using DB::SetOptions;
   Status SetOptions(
       ColumnFamilyHandle* column_family,
@@ -237,6 +243,12 @@ class DBImpl : public DB {
 
 #endif  // ROCKSDB_LITE
 
+  // Similar to GetSnapshot(), but also lets the db know that this snapshot
+  // will be used for transaction write-conflict checking.  The DB can then
+  // make sure not to compact any keys that would prevent a write-conflict from
+  // being detected.
+  const Snapshot* GetSnapshotForWriteConflictBoundary();
+
   // checks if all live files exist on file system and that their file sizes
   // match to our in-memory records
   virtual Status CheckConsistency();
@@ -248,7 +260,13 @@ class DBImpl : public DB {
                              const Slice* begin, const Slice* end,
                              bool disallow_trivial_move = false);
 
-#ifndef ROCKSDB_LITE
+  // Return an internal iterator over the current state of the database.
+  // The keys of this iterator are internal keys (see format.h).
+  // The returned iterator should be deleted when no longer needed.
+  InternalIterator* NewInternalIterator(
+      Arena* arena, ColumnFamilyHandle* column_family = nullptr);
+
+#ifndef NDEBUG
   // Extra methods (for testing) that are not in the public DB interface
   // Implemented in db_impl_debug.cc
 
@@ -266,12 +284,6 @@ class DBImpl : public DB {
   // Wait for any compaction
   Status TEST_WaitForCompact();
 
-  // Return an internal iterator over the current state of the database.
-  // The keys of this iterator are internal keys (see format.h).
-  // The returned iterator should be deleted when no longer needed.
-  Iterator* TEST_NewInternalIterator(
-      Arena* arena, ColumnFamilyHandle* column_family = nullptr);
-
   // Return the maximum overlapping data (in bytes) at next level for any
   // file at a level >= 1.
   int64_t TEST_MaxNextLevelOverlappingBytes(ColumnFamilyHandle* column_family =
@@ -305,7 +317,17 @@ class DBImpl : public DB {
 
   uint64_t TEST_LogfileNumber();
 
-#endif  // ROCKSDB_LITE
+  // Returns column family name to ImmutableCFOptions map.
+  Status TEST_GetAllImmutableCFOptions(
+      std::unordered_map<std::string, const ImmutableCFOptions*>* iopts_map);
+
+  Cache* TEST_table_cache() { return table_cache_.get(); }
+
+  const WriteController& TEST_write_controler() const {
+    return write_controller_;
+  }
+
+#endif  // NDEBUG
 
   // Returns the list of live files in 'live' and the list
   // of all files in the filesystem in 'candidate_files'.
@@ -363,6 +385,20 @@ class DBImpl : public DB {
   // Same as above, should called without mutex held and not on write thread.
   ColumnFamilyHandle* GetColumnFamilyHandleUnlocked(uint32_t column_family_id);
 
+  // Returns the number of currently running flushes.
+  // REQUIREMENT: mutex_ must be held when calling this function.
+  int num_running_flushes() {
+    mutex_.AssertHeld();
+    return num_running_flushes_;
+  }
+
+  // Returns the number of currently running compactions.
+  // REQUIREMENT: mutex_ must be held when calling this function.
+  int num_running_compactions() {
+    mutex_.AssertHeld();
+    return num_running_compactions_;
+  }
+
  protected:
   Env* const env_;
   const std::string dbname_;
@@ -370,12 +406,25 @@ class DBImpl : public DB {
   const DBOptions db_options_;
   Statistics* stats_;
 
-  Iterator* NewInternalIterator(const ReadOptions&, ColumnFamilyData* cfd,
-                                SuperVersion* super_version, Arena* arena);
+  InternalIterator* NewInternalIterator(const ReadOptions&,
+                                        ColumnFamilyData* cfd,
+                                        SuperVersion* super_version,
+                                        Arena* arena);
+
+  // Except in DB::Open(), WriteOptionsFile can only be called when:
+  // 1. WriteThread::Writer::EnterUnbatched() is used.
+  // 2. db_mutex is held
+  Status WriteOptionsFile();
+
+  // The following two functions can only be called when:
+  // 1. WriteThread::Writer::EnterUnbatched() is used.
+  // 2. db_mutex is NOT held
+  Status RenameTempFileToOptionsFile(const std::string& file_name);
+  Status DeleteObsoleteOptionsFiles();
 
   void NotifyOnFlushCompleted(ColumnFamilyData* cfd, FileMetaData* file_meta,
                               const MutableCFOptions& mutable_cf_options,
-                              int job_id);
+                              int job_id, TableProperties prop);
 
   void NotifyOnCompactionCompleted(ColumnFamilyData* cfd,
                                    Compaction *c, const Status &st,
@@ -521,14 +570,21 @@ class DBImpl : public DB {
   // helper function to call after some of the logs_ were synced
   void MarkLogsSynced(uint64_t up_to, bool synced_dir, const Status& status);
 
+  const Snapshot* GetSnapshotImpl(bool is_write_conflict_boundary);
+
   // table_cache_ provides its own synchronization
   std::shared_ptr<Cache> table_cache_;
 
   // Lock over the persistent DB state.  Non-nullptr iff successfully acquired.
   FileLock* db_lock_;
 
+  // The mutex for options file related operations.
+  // NOTE: should never acquire options_file_mutex_ and mutex_ at the
+  //       same time.
+  InstrumentedMutex options_files_mutex_;
   // State below is protected by mutex_
   InstrumentedMutex mutex_;
+
   std::atomic<bool> shutting_down_;
   // This condition variable is signaled on these conditions:
   // * whenever bg_compaction_scheduled_ goes down to 0
@@ -540,6 +596,8 @@ class DBImpl : public DB {
   // * whenever there is an error in background flush or compaction
   InstrumentedCondVar bg_cv_;
   uint64_t logfile_number_;
+  std::deque<uint64_t>
+      log_recycle_files;  // a list of log files that we can recycle
   bool log_dir_synced_;
   bool log_empty_;
   ColumnFamilyHandleImpl* default_cf_handle_;
@@ -685,6 +743,9 @@ class DBImpl : public DB {
   // count how many background compactions are running or have been scheduled
   int bg_compaction_scheduled_;
 
+  // stores the number of compactions are currently running
+  int num_running_compactions_;
+
   // If non-zero, MaybeScheduleFlushOrCompaction() will only schedule manual
   // compactions (if manual_compaction_ is not null). This mechanism enables
   // manual compactions to wait until all other compactions are finished.
@@ -693,6 +754,9 @@ class DBImpl : public DB {
   // number of background memtable flush jobs, submitted to the HIGH pool
   int bg_flush_scheduled_;
 
+  // stores the number of flushes are currently running
+  int num_running_flushes_;
+
   // Information for a manual compaction
   struct ManualCompaction {
     ColumnFamilyData* cfd;
@@ -788,6 +852,10 @@ class DBImpl : public DB {
   virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
                                           TablePropertiesCollection* props)
       override;
+  virtual Status GetPropertiesOfTablesInRange(
+      ColumnFamilyHandle* column_family, const Range* range, std::size_t n,
+      TablePropertiesCollection* props) override;
+
 #endif  // ROCKSDB_LITE
 
   // Function that Get and KeyMayExist call with no_io true or false
@@ -796,9 +864,10 @@ class DBImpl : public DB {
                  const Slice& key, std::string* value,
                  bool* value_found = nullptr);
 
-  bool GetIntPropertyInternal(ColumnFamilyHandle* column_family,
+  bool GetIntPropertyInternal(ColumnFamilyData* cfd,
                               DBPropertyType property_type,
-                              bool need_out_of_mutex, uint64_t* value);
+                              bool need_out_of_mutex, bool is_locked,
+                              uint64_t* value);
 };
 
 // Sanitize db options.  The caller should delete result.info_log if
diff --git a/src/rocksdb/db/db_impl_debug.cc b/src/rocksdb/db/db_impl_debug.cc
index dc40fef..ef8a12d 100644
--- a/src/rocksdb/db/db_impl_debug.cc
+++ b/src/rocksdb/db/db_impl_debug.cc
@@ -7,7 +7,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#ifndef ROCKSDB_LITE
+#ifndef NDEBUG
 
 #include "db/db_impl.h"
 #include "util/thread_status_updater.h"
@@ -19,23 +19,6 @@ uint64_t DBImpl::TEST_GetLevel0TotalSize() {
   return default_cf_handle_->cfd()->current()->storage_info()->NumLevelBytes(0);
 }
 
-Iterator* DBImpl::TEST_NewInternalIterator(Arena* arena,
-                                           ColumnFamilyHandle* column_family) {
-  ColumnFamilyData* cfd;
-  if (column_family == nullptr) {
-    cfd = default_cf_handle_->cfd();
-  } else {
-    auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
-    cfd = cfh->cfd();
-  }
-
-  mutex_.Lock();
-  SuperVersion* super_version = cfd->GetSuperVersion()->Ref();
-  mutex_.Unlock();
-  ReadOptions roptions;
-  return NewInternalIterator(roptions, cfd, super_version, arena);
-}
-
 int64_t DBImpl::TEST_MaxNextLevelOverlappingBytes(
     ColumnFamilyHandle* column_family) {
   ColumnFamilyData* cfd;
@@ -152,5 +135,24 @@ uint64_t DBImpl::TEST_LogfileNumber() {
   return logfile_number_;
 }
 
+Status DBImpl::TEST_GetAllImmutableCFOptions(
+    std::unordered_map<std::string, const ImmutableCFOptions*>* iopts_map) {
+  std::vector<std::string> cf_names;
+  std::vector<const ImmutableCFOptions*> iopts;
+  {
+    InstrumentedMutexLock l(&mutex_);
+    for (auto cfd : *versions_->GetColumnFamilySet()) {
+      cf_names.push_back(cfd->GetName());
+      iopts.push_back(cfd->ioptions());
+    }
+  }
+  iopts_map->clear();
+  for (size_t i = 0; i < cf_names.size(); ++i) {
+    iopts_map->insert({cf_names[i], iopts[i]});
+  }
+
+  return Status::OK();
+}
+
 }  // namespace rocksdb
-#endif  // ROCKSDB_LITE
+#endif  // NDEBUG
diff --git a/src/rocksdb/db/db_inplace_update_test.cc b/src/rocksdb/db/db_inplace_update_test.cc
index a04c2f5..046ddea 100644
--- a/src/rocksdb/db/db_inplace_update_test.cc
+++ b/src/rocksdb/db/db_inplace_update_test.cc
@@ -6,8 +6,8 @@
 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
 
 namespace rocksdb {
 
diff --git a/src/rocksdb/db/db_iter.cc b/src/rocksdb/db/db_iter.cc
index 065b8e4..74558d5 100644
--- a/src/rocksdb/db/db_iter.cc
+++ b/src/rocksdb/db/db_iter.cc
@@ -15,11 +15,12 @@
 
 #include "db/filename.h"
 #include "db/dbformat.h"
+#include "port/port.h"
 #include "rocksdb/env.h"
 #include "rocksdb/options.h"
 #include "rocksdb/iterator.h"
 #include "rocksdb/merge_operator.h"
-#include "port/port.h"
+#include "table/internal_iterator.h"
 #include "util/arena.h"
 #include "util/logging.h"
 #include "util/mutexlock.h"
@@ -58,10 +59,11 @@ class DBIter: public Iterator {
     kReverse
   };
 
-  DBIter(Env* env, const ImmutableCFOptions& ioptions,
-         const Comparator* cmp, Iterator* iter, SequenceNumber s,
-         bool arena_mode, uint64_t max_sequential_skip_in_iterations,
-         const Slice* iterate_upper_bound = nullptr)
+  DBIter(Env* env, const ImmutableCFOptions& ioptions, const Comparator* cmp,
+         InternalIterator* iter, SequenceNumber s, bool arena_mode,
+         uint64_t max_sequential_skip_in_iterations,
+         const Slice* iterate_upper_bound = nullptr,
+         bool prefix_same_as_start = false)
       : arena_mode_(arena_mode),
         env_(env),
         logger_(ioptions.info_log),
@@ -73,7 +75,8 @@ class DBIter: public Iterator {
         valid_(false),
         current_entry_is_merged_(false),
         statistics_(ioptions.statistics),
-        iterate_upper_bound_(iterate_upper_bound) {
+        iterate_upper_bound_(iterate_upper_bound),
+        prefix_same_as_start_(prefix_same_as_start) {
     RecordTick(statistics_, NO_ITERATORS);
     prefix_extractor_ = ioptions.prefix_extractor;
     max_skip_ = max_sequential_skip_in_iterations;
@@ -83,10 +86,10 @@ class DBIter: public Iterator {
     if (!arena_mode_) {
       delete iter_;
     } else {
-      iter_->~Iterator();
+      iter_->~InternalIterator();
     }
   }
-  virtual void SetIter(Iterator* iter) {
+  virtual void SetIter(InternalIterator* iter) {
     assert(iter_ == nullptr);
     iter_ = iter;
   }
@@ -142,7 +145,7 @@ class DBIter: public Iterator {
   Logger* logger_;
   const Comparator* const user_comparator_;
   const MergeOperator* const user_merge_operator_;
-  Iterator* iter_;
+  InternalIterator* iter_;
   SequenceNumber const sequence_;
 
   Status status_;
@@ -154,6 +157,8 @@ class DBIter: public Iterator {
   Statistics* statistics_;
   uint64_t max_skip_;
   const Slice* iterate_upper_bound_;
+  IterKey prefix_start_;
+  bool prefix_same_as_start_;
 
   // No copying allowed
   DBIter(const DBIter&);
@@ -181,9 +186,18 @@ void DBIter::Next() {
     if (!iter_->Valid()) {
       iter_->SeekToFirst();
     }
+  } else if (iter_->Valid() && !current_entry_is_merged_) {
+    // If the current value is not a merge, the iter position is the
+    // current key, which is already returned. We can safely issue a
+    // Next() without checking the current key.
+    // If the current key is a merge, very likely iter already points
+    // to the next internal position.
+    iter_->Next();
+    PERF_COUNTER_ADD(internal_key_skipped_count, 1);
   }
 
-  // If the current value is merged, we might already hit end of iter_
+  // Now we point to the next internal position, for both of merge and
+  // not merge cases.
   if (!iter_->Valid()) {
     valid_ = false;
     return;
@@ -196,6 +210,11 @@ void DBIter::Next() {
       RecordTick(statistics_, ITER_BYTES_READ, key().size() + value().size());
     }
   }
+  if (valid_ && prefix_extractor_ && prefix_same_as_start_ &&
+      prefix_extractor_->Transform(saved_key_.GetKey())
+              .compare(prefix_start_.GetKey()) != 0) {
+    valid_ = false;
+  }
 }
 
 // PRE: saved_key_ has the current user key if skipping
@@ -366,6 +385,11 @@ void DBIter::Prev() {
       RecordTick(statistics_, ITER_BYTES_READ, key().size() + value().size());
     }
   }
+  if (valid_ && prefix_extractor_ && prefix_same_as_start_ &&
+      prefix_extractor_->Transform(saved_key_.GetKey())
+              .compare(prefix_start_.GetKey()) != 0) {
+    valid_ = false;
+  }
 }
 
 void DBIter::ReverseToBackward() {
@@ -667,6 +691,9 @@ void DBIter::Seek(const Slice& target) {
   } else {
     valid_ = false;
   }
+  if (valid_ && prefix_extractor_ && prefix_same_as_start_) {
+    prefix_start_.SetKey(prefix_extractor_->Transform(target));
+  }
 }
 
 void DBIter::SeekToFirst() {
@@ -695,6 +722,9 @@ void DBIter::SeekToFirst() {
   } else {
     valid_ = false;
   }
+  if (valid_ && prefix_extractor_ && prefix_same_as_start_) {
+    prefix_start_.SetKey(prefix_extractor_->Transform(saved_key_.GetKey()));
+  }
 }
 
 void DBIter::SeekToLast() {
@@ -740,24 +770,28 @@ void DBIter::SeekToLast() {
       RecordTick(statistics_, ITER_BYTES_READ, key().size() + value().size());
     }
   }
+  if (valid_ && prefix_extractor_ && prefix_same_as_start_) {
+    prefix_start_.SetKey(prefix_extractor_->Transform(saved_key_.GetKey()));
+  }
 }
 
 Iterator* NewDBIterator(Env* env, const ImmutableCFOptions& ioptions,
                         const Comparator* user_key_comparator,
-                        Iterator* internal_iter,
+                        InternalIterator* internal_iter,
                         const SequenceNumber& sequence,
                         uint64_t max_sequential_skip_in_iterations,
-                        const Slice* iterate_upper_bound) {
+                        const Slice* iterate_upper_bound,
+                        bool prefix_same_as_start) {
   return new DBIter(env, ioptions, user_key_comparator, internal_iter, sequence,
                     false, max_sequential_skip_in_iterations,
-                    iterate_upper_bound);
+                    iterate_upper_bound, prefix_same_as_start);
 }
 
 ArenaWrappedDBIter::~ArenaWrappedDBIter() { db_iter_->~DBIter(); }
 
 void ArenaWrappedDBIter::SetDBIter(DBIter* iter) { db_iter_ = iter; }
 
-void ArenaWrappedDBIter::SetIterUnderDBIter(Iterator* iter) {
+void ArenaWrappedDBIter::SetIterUnderDBIter(InternalIterator* iter) {
   static_cast<DBIter*>(db_iter_)->SetIter(iter);
 }
 
@@ -779,16 +813,16 @@ void ArenaWrappedDBIter::RegisterCleanup(CleanupFunction function, void* arg1,
 
 ArenaWrappedDBIter* NewArenaWrappedDbIterator(
     Env* env, const ImmutableCFOptions& ioptions,
-    const Comparator* user_key_comparator,
-    const SequenceNumber& sequence,
+    const Comparator* user_key_comparator, const SequenceNumber& sequence,
     uint64_t max_sequential_skip_in_iterations,
-    const Slice* iterate_upper_bound) {
+    const Slice* iterate_upper_bound, bool prefix_same_as_start) {
   ArenaWrappedDBIter* iter = new ArenaWrappedDBIter();
   Arena* arena = iter->GetArena();
   auto mem = arena->AllocateAligned(sizeof(DBIter));
-  DBIter* db_iter = new (mem) DBIter(env, ioptions, user_key_comparator,
-      nullptr, sequence, true, max_sequential_skip_in_iterations,
-      iterate_upper_bound);
+  DBIter* db_iter =
+      new (mem) DBIter(env, ioptions, user_key_comparator, nullptr, sequence,
+                       true, max_sequential_skip_in_iterations,
+                       iterate_upper_bound, prefix_same_as_start);
 
   iter->SetDBIter(db_iter);
 
diff --git a/src/rocksdb/db/db_iter.h b/src/rocksdb/db/db_iter.h
index c676d6c..740d8c5 100644
--- a/src/rocksdb/db/db_iter.h
+++ b/src/rocksdb/db/db_iter.h
@@ -10,6 +10,7 @@
 #pragma once
 #include <stdint.h>
 #include "rocksdb/db.h"
+#include "rocksdb/iterator.h"
 #include "db/dbformat.h"
 #include "util/arena.h"
 #include "util/autovector.h"
@@ -18,18 +19,18 @@ namespace rocksdb {
 
 class Arena;
 class DBIter;
+class InternalIterator;
 
 // Return a new iterator that converts internal keys (yielded by
 // "*internal_iter") that were live at the specified "sequence" number
 // into appropriate user keys.
-extern Iterator* NewDBIterator(
-    Env* env,
-    const ImmutableCFOptions& options,
-    const Comparator *user_key_comparator,
-    Iterator* internal_iter,
-    const SequenceNumber& sequence,
-    uint64_t max_sequential_skip_in_iterations,
-    const Slice* iterate_upper_bound = nullptr);
+extern Iterator* NewDBIterator(Env* env, const ImmutableCFOptions& options,
+                               const Comparator* user_key_comparator,
+                               InternalIterator* internal_iter,
+                               const SequenceNumber& sequence,
+                               uint64_t max_sequential_skip_in_iterations,
+                               const Slice* iterate_upper_bound = nullptr,
+                               bool prefix_same_as_start = false);
 
 // A wrapper iterator which wraps DB Iterator and the arena, with which the DB
 // iterator is supposed be allocated. This class is used as an entry point of
@@ -50,7 +51,7 @@ class ArenaWrappedDBIter : public Iterator {
 
   // Set the internal iterator wrapped inside the DB Iterator. Usually it is
   // a merging iterator.
-  virtual void SetIterUnderDBIter(Iterator* iter);
+  virtual void SetIterUnderDBIter(InternalIterator* iter);
   virtual bool Valid() const override;
   virtual void SeekToFirst() override;
   virtual void SeekToLast() override;
@@ -60,6 +61,7 @@ class ArenaWrappedDBIter : public Iterator {
   virtual Slice key() const override;
   virtual Slice value() const override;
   virtual Status status() const override;
+
   void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
 
  private:
@@ -70,8 +72,9 @@ class ArenaWrappedDBIter : public Iterator {
 // Generate the arena wrapped iterator class.
 extern ArenaWrappedDBIter* NewArenaWrappedDbIterator(
     Env* env, const ImmutableCFOptions& options,
-    const Comparator* user_key_comparator,
-    const SequenceNumber& sequence, uint64_t max_sequential_skip_in_iterations,
-    const Slice* iterate_upper_bound = nullptr);
+    const Comparator* user_key_comparator, const SequenceNumber& sequence,
+    uint64_t max_sequential_skip_in_iterations,
+    const Slice* iterate_upper_bound = nullptr,
+    bool prefix_same_as_start = false);
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/db/db_iter_test.cc b/src/rocksdb/db/db_iter_test.cc
index 68c5b15..f1e3324 100644
--- a/src/rocksdb/db/db_iter_test.cc
+++ b/src/rocksdb/db/db_iter_test.cc
@@ -29,7 +29,7 @@ static uint64_t TestGetTickerCount(const Options& options,
   return options.statistics->getTickerCount(ticker_type);
 }
 
-class TestIterator : public Iterator {
+class TestIterator : public InternalIterator {
  public:
   explicit TestIterator(const Comparator* comparator)
       : initialized_(false),
@@ -1864,11 +1864,12 @@ class DBIterWithMergeIterTest : public testing::Test {
     internal_iter2_->Add("d", kTypeValue, "7", 3u);
     internal_iter2_->Finish();
 
-    std::vector<Iterator*> child_iters;
+    std::vector<InternalIterator*> child_iters;
     child_iters.push_back(internal_iter1_);
     child_iters.push_back(internal_iter2_);
     InternalKeyComparator icomp(BytewiseComparator());
-    Iterator* merge_iter = NewMergingIterator(&icomp_, &child_iters[0], 2u);
+    InternalIterator* merge_iter =
+        NewMergingIterator(&icomp_, &child_iters[0], 2u);
 
     db_iter_.reset(NewDBIterator(env_, ImmutableCFOptions(options_),
                                  BytewiseComparator(), merge_iter,
@@ -1942,8 +1943,6 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIterator2) {
   ASSERT_EQ(db_iter_->value().ToString(), "4");
 }
 
-#if !(defined NDEBUG) || !defined(OS_WIN)
-
 TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace1) {
   // Test Prev() when one child iterator is at its end but more rows
   // are added.
@@ -2294,7 +2293,6 @@ TEST_F(DBIterWithMergeIterTest, InnerMergeIteratorDataRace8) {
 
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
-#endif // #if !(defined NDEBUG) || !defined(OS_WIN)
 }  // namespace rocksdb
 
 int main(int argc, char** argv) {
diff --git a/src/rocksdb/db/db_log_iter_test.cc b/src/rocksdb/db/db_log_iter_test.cc
index a1e8d20..64a74e0 100644
--- a/src/rocksdb/db/db_log_iter_test.cc
+++ b/src/rocksdb/db/db_log_iter_test.cc
@@ -10,10 +10,10 @@
 // Introduction of SyncPoint effectively disabled building and running this test
 // in Release build.
 // which is a pity, it is a good test
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
 
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
 
 namespace rocksdb {
 
@@ -277,10 +277,10 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorBlobs) {
 }
 }  // namespace rocksdb
 
-#endif  // !(defined NDEBUG) || !defined(OS_WIN)
+#endif  // !defined(ROCKSDB_LITE)
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
diff --git a/src/rocksdb/db/db_table_properties_test.cc b/src/rocksdb/db/db_table_properties_test.cc
new file mode 100644
index 0000000..becf76e
--- /dev/null
+++ b/src/rocksdb/db/db_table_properties_test.cc
@@ -0,0 +1,226 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+
+#include <unordered_set>
+#include <vector>
+
+#include "db/db_test_util.h"
+#include "port/stack_trace.h"
+#include "rocksdb/db.h"
+#include "util/testharness.h"
+#include "util/testutil.h"
+
+#ifndef ROCKSDB_LITE
+
+namespace rocksdb {
+
+// A helper function that ensures the table properties returned in
+// `GetPropertiesOfAllTablesTest` is correct.
+// This test assumes entries size is different for each of the tables.
+namespace {
+
+void VerifyTableProperties(DB* db, uint64_t expected_entries_size) {
+  TablePropertiesCollection props;
+  ASSERT_OK(db->GetPropertiesOfAllTables(&props));
+
+  ASSERT_EQ(4U, props.size());
+  std::unordered_set<uint64_t> unique_entries;
+
+  // Indirect test
+  uint64_t sum = 0;
+  for (const auto& item : props) {
+    unique_entries.insert(item.second->num_entries);
+    sum += item.second->num_entries;
+  }
+
+  ASSERT_EQ(props.size(), unique_entries.size());
+  ASSERT_EQ(expected_entries_size, sum);
+}
+}  // namespace
+
+class DBTablePropertiesTest : public DBTestBase {
+ public:
+  DBTablePropertiesTest() : DBTestBase("/db_table_properties_test") {}
+  TablePropertiesCollection TestGetPropertiesOfTablesInRange(
+      std::vector<Range> ranges, std::size_t* num_properties = nullptr,
+      std::size_t* num_files = nullptr);
+};
+
+TEST_F(DBTablePropertiesTest, GetPropertiesOfAllTablesTest) {
+  Options options = CurrentOptions();
+  options.level0_file_num_compaction_trigger = 8;
+  Reopen(options);
+  // Create 4 tables
+  for (int table = 0; table < 4; ++table) {
+    for (int i = 0; i < 10 + table; ++i) {
+      db_->Put(WriteOptions(), ToString(table * 100 + i), "val");
+    }
+    db_->Flush(FlushOptions());
+  }
+
+  // 1. Read table properties directly from file
+  Reopen(options);
+  VerifyTableProperties(db_, 10 + 11 + 12 + 13);
+
+  // 2. Put two tables to table cache and
+  Reopen(options);
+  // fetch key from 1st and 2nd table, which will internally place that table to
+  // the table cache.
+  for (int i = 0; i < 2; ++i) {
+    Get(ToString(i * 100 + 0));
+  }
+
+  VerifyTableProperties(db_, 10 + 11 + 12 + 13);
+
+  // 3. Put all tables to table cache
+  Reopen(options);
+  // fetch key from 1st and 2nd table, which will internally place that table to
+  // the table cache.
+  for (int i = 0; i < 4; ++i) {
+    Get(ToString(i * 100 + 0));
+  }
+  VerifyTableProperties(db_, 10 + 11 + 12 + 13);
+}
+
+TablePropertiesCollection
+DBTablePropertiesTest::TestGetPropertiesOfTablesInRange(
+    std::vector<Range> ranges, std::size_t* num_properties,
+    std::size_t* num_files) {
+
+  // Since we deref zero element in the vector it can not be empty
+  // otherwise we pass an address to some random memory
+  EXPECT_GT(ranges.size(), 0U);
+  // run the query
+  TablePropertiesCollection props;
+  EXPECT_OK(db_->GetPropertiesOfTablesInRange(
+      db_->DefaultColumnFamily(), &ranges[0], ranges.size(), &props));
+
+  // Make sure that we've received properties for those and for those files
+  // only which fall within requested ranges
+  std::vector<LiveFileMetaData> vmd;
+  db_->GetLiveFilesMetaData(&vmd);
+  for (auto& md : vmd) {
+    std::string fn = md.db_path + md.name;
+    bool in_range = false;
+    for (auto& r : ranges) {
+      // smallestkey < limit && largestkey >= start
+      if (r.limit.compare(md.smallestkey) >= 0 &&
+          r.start.compare(md.largestkey) <= 0) {
+        in_range = true;
+        EXPECT_GT(props.count(fn), 0);
+      }
+    }
+    if (!in_range) {
+      EXPECT_EQ(props.count(fn), 0);
+    }
+  }
+
+  if (num_properties) {
+    *num_properties = props.size();
+  }
+
+  if (num_files) {
+    *num_files = vmd.size();
+  }
+  return props;
+}
+
+TEST_F(DBTablePropertiesTest, GetPropertiesOfTablesInRange) {
+  // Fixed random sead
+  Random rnd(301);
+
+  Options options;
+  options.create_if_missing = true;
+  options.write_buffer_size = 4096;
+  options.max_write_buffer_number = 8;
+  options.level0_file_num_compaction_trigger = 2;
+  options.level0_slowdown_writes_trigger = 2;
+  options.level0_stop_writes_trigger = 4;
+  options.target_file_size_base = 2048;
+  options.max_bytes_for_level_base = 10240;
+  options.max_bytes_for_level_multiplier = 4;
+  options.soft_rate_limit = 1.1;
+  options.num_levels = 8;
+
+  DestroyAndReopen(options);
+
+  // build a decent LSM
+  for (int i = 0; i < 10000; i++) {
+    ASSERT_OK(Put(test::RandomKey(&rnd, 5), RandomString(&rnd, 102)));
+  }
+  Flush();
+  db_->PauseBackgroundWork();
+
+  // Ensure that we have at least L0, L1 and L2
+  ASSERT_GT(NumTableFilesAtLevel(0), 0);
+  ASSERT_GT(NumTableFilesAtLevel(1), 0);
+  ASSERT_GT(NumTableFilesAtLevel(2), 0);
+
+  // Query the largest range
+  std::size_t num_properties, num_files;
+  TestGetPropertiesOfTablesInRange(
+      {Range(test::RandomKey(&rnd, 5, test::RandomKeyType::SMALLEST),
+             test::RandomKey(&rnd, 5, test::RandomKeyType::LARGEST))},
+      &num_properties, &num_files);
+  ASSERT_EQ(num_properties, num_files);
+
+  // Query the empty range
+  TestGetPropertiesOfTablesInRange(
+      {Range(test::RandomKey(&rnd, 5, test::RandomKeyType::LARGEST),
+             test::RandomKey(&rnd, 5, test::RandomKeyType::SMALLEST))},
+      &num_properties, &num_files);
+  ASSERT_GT(num_files, 0);
+  ASSERT_EQ(num_properties, 0);
+
+  // Query the middle rangee
+  TestGetPropertiesOfTablesInRange(
+      {Range(test::RandomKey(&rnd, 5, test::RandomKeyType::MIDDLE),
+             test::RandomKey(&rnd, 5, test::RandomKeyType::LARGEST))},
+      &num_properties, &num_files);
+  ASSERT_GT(num_files, 0);
+  ASSERT_GT(num_files, num_properties);
+  ASSERT_GT(num_properties, 0);
+
+  // Query a bunch of random ranges
+  for (int j = 0; j < 100; j++) {
+    // create a bunch of ranges
+    std::vector<std::string> random_keys;
+    // Random returns numbers with zero included
+    // when we pass empty ranges TestGetPropertiesOfTablesInRange()
+    // derefs random memory in the empty ranges[0]
+    // so want to be greater than zero and even since
+    // the below loop requires that random_keys.size() to be even.
+    auto n = 2 * (rnd.Uniform(50) + 1);
+
+    for (uint32_t i = 0; i < n; ++i) {
+      random_keys.push_back(test::RandomKey(&rnd, 5));
+    }
+
+    ASSERT_GT(random_keys.size(), 0U);
+    ASSERT_EQ((random_keys.size() % 2), 0U);
+
+    std::vector<Range> ranges;
+    auto it = random_keys.begin();
+    while (it != random_keys.end()) {
+      ranges.push_back(Range(*it, *(it + 1)));
+      it += 2;
+    }
+
+    TestGetPropertiesOfTablesInRange(std::move(ranges));
+  }
+}
+}  // namespace rocksdb
+
+#endif  // ROCKSDB_LITE
+
+int main(int argc, char** argv) {
+  rocksdb::port::InstallStackTraceHandler();
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
diff --git a/src/rocksdb/db/db_tailing_iter_test.cc b/src/rocksdb/db/db_tailing_iter_test.cc
index 4ca5e90..d83c5ee 100644
--- a/src/rocksdb/db/db_tailing_iter_test.cc
+++ b/src/rocksdb/db/db_tailing_iter_test.cc
@@ -10,11 +10,11 @@
 // Introduction of SyncPoint effectively disabled building and running this test
 // in Release build.
 // which is a pity, it is a good test
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
 
+#include "db/db_test_util.h"
 #include "db/forward_iterator.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
 
 namespace rocksdb {
 
@@ -140,6 +140,8 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
   std::unique_ptr<Iterator> iterh(db_->NewIterator(read_options, handles_[1]));
   std::string value(1024, 'a');
   bool file_iters_deleted = false;
+  bool file_iters_renewed_null = false;
+  bool file_iters_renewed_copy = false;
   rocksdb::SyncPoint::GetInstance()->SetCallBack(
       "ForwardIterator::SeekInternal:Return", [&](void* arg) {
         ForwardIterator* fiter = reinterpret_cast<ForwardIterator*>(arg);
@@ -152,6 +154,12 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
         ASSERT_TRUE(!file_iters_deleted ||
                     fiter->TEST_CheckDeletedIters(&deleted_iters, &num_iters));
       });
+  rocksdb::SyncPoint::GetInstance()->SetCallBack(
+      "ForwardIterator::RenewIterators:Null",
+      [&](void* arg) { file_iters_renewed_null = true; });
+  rocksdb::SyncPoint::GetInstance()->SetCallBack(
+      "ForwardIterator::RenewIterators:Copy",
+      [&](void* arg) { file_iters_renewed_copy = true; });
   rocksdb::SyncPoint::GetInstance()->EnableProcessing();
   const int num_records = 1000;
   for (int i = 1; i < num_records; ++i) {
@@ -203,6 +211,8 @@ TEST_F(DBTestTailingIterator, TailingIteratorTrimSeekToNext) {
     ASSERT_LE(num_iters, 1);
     file_iters_deleted = false;
   }
+  ASSERT_TRUE(file_iters_renewed_null);
+  ASSERT_TRUE(file_iters_renewed_copy);
   iter = 0;
   itern = 0;
   iterh = 0;
@@ -646,10 +656,10 @@ TEST_F(DBTestTailingIterator, ManagedTailingIteratorSeekToSame) {
 
 }  // namespace rocksdb
 
-#endif  // !(defined NDEBUG) || !defined(OS_WIN)
+#endif  // !defined(ROCKSDB_LITE)
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
diff --git a/src/rocksdb/db/db_test.cc b/src/rocksdb/db/db_test.cc
index 4bfe4db..8364f64 100644
--- a/src/rocksdb/db/db_test.cc
+++ b/src/rocksdb/db/db_test.cc
@@ -10,8 +10,6 @@
 // Introduction of SyncPoint effectively disabled building and running this test
 // in Release build.
 // which is a pity, it is a good test
-#if !(defined NDEBUG) || !defined(OS_WIN)
-
 #include <algorithm>
 #include <iostream>
 #include <set>
@@ -26,9 +24,11 @@
 #include "db/filename.h"
 #include "db/dbformat.h"
 #include "db/db_impl.h"
+#include "db/db_test_util.h"
 #include "db/job_context.h"
 #include "db/version_set.h"
 #include "db/write_batch_internal.h"
+#include "memtable/hash_linklist_rep.h"
 #include "port/stack_trace.h"
 #include "rocksdb/cache.h"
 #include "rocksdb/compaction_filter.h"
@@ -47,16 +47,16 @@
 #include "rocksdb/table.h"
 #include "rocksdb/table_properties.h"
 #include "rocksdb/thread_status.h"
+#include "rocksdb/wal_filter.h"
 #include "rocksdb/utilities/write_batch_with_index.h"
 #include "rocksdb/utilities/checkpoint.h"
 #include "rocksdb/utilities/optimistic_transaction_db.h"
 #include "table/block_based_table_factory.h"
 #include "table/mock_table.h"
 #include "table/plain_table_factory.h"
-#include "util/db_test_util.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/file_reader_writer.h"
 #include "util/hash.h"
-#include "util/hash_linklist_rep.h"
 #include "utilities/merge_operators.h"
 #include "util/logging.h"
 #include "util/compression.h"
@@ -64,7 +64,6 @@
 #include "util/rate_limiter.h"
 #include "util/statistics.h"
 #include "util/testharness.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/sync_point.h"
 #include "util/testutil.h"
 #include "util/mock_env.h"
@@ -78,29 +77,12 @@ static long TestGetTickerCount(const Options& options, Tickers ticker_type) {
   return options.statistics->getTickerCount(ticker_type);
 }
 
+#ifndef ROCKSDB_LITE
 // A helper function that ensures the table properties returned in
 // `GetPropertiesOfAllTablesTest` is correct.
 // This test assumes entries size is different for each of the tables.
 namespace {
 
-void VerifyTableProperties(DB* db, uint64_t expected_entries_size) {
-  TablePropertiesCollection props;
-  ASSERT_OK(db->GetPropertiesOfAllTables(&props));
-
-  ASSERT_EQ(4U, props.size());
-  std::unordered_set<uint64_t> unique_entries;
-
-  // Indirect test
-  uint64_t sum = 0;
-  for (const auto& item : props) {
-    unique_entries.insert(item.second->num_entries);
-    sum += item.second->num_entries;
-  }
-
-  ASSERT_EQ(props.size(), unique_entries.size());
-  ASSERT_EQ(expected_entries_size, sum);
-}
-
 uint64_t GetNumberOfSstFilesForColumnFamily(DB* db,
                                             std::string column_family_name) {
   std::vector<LiveFileMetaData> metadata;
@@ -113,6 +95,7 @@ uint64_t GetNumberOfSstFilesForColumnFamily(DB* db,
 }
 
 }  // namespace
+#endif  // ROCKSDB_LITE
 
 class DBTest : public DBTestBase {
  public:
@@ -131,46 +114,7 @@ class DBTestWithParam : public DBTest,
   uint32_t max_subcompactions_;
 };
 
-class BloomStatsTestWithParam
-    : public DBTest,
-      public testing::WithParamInterface<std::tuple<bool, bool>> {
- public:
-  BloomStatsTestWithParam() {
-    use_block_table_ = std::get<0>(GetParam());
-    use_block_based_builder_ = std::get<1>(GetParam());
-
-    options_.create_if_missing = true;
-    options_.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(4));
-    options_.memtable_prefix_bloom_bits = 8 * 1024;
-    if (use_block_table_) {
-      BlockBasedTableOptions table_options;
-      table_options.hash_index_allow_collision = false;
-      table_options.filter_policy.reset(
-          NewBloomFilterPolicy(10, use_block_based_builder_));
-      options_.table_factory.reset(NewBlockBasedTableFactory(table_options));
-    } else {
-      PlainTableOptions table_options;
-      options_.table_factory.reset(NewPlainTableFactory(table_options));
-    }
-
-    perf_context.Reset();
-    DestroyAndReopen(options_);
-  }
-
-  ~BloomStatsTestWithParam() {
-    perf_context.Reset();
-    Destroy(options_);
-  }
-
-  // Required if inheriting from testing::WithParamInterface<>
-  static void SetUpTestCase() {}
-  static void TearDownTestCase() {}
-
-  bool use_block_table_;
-  bool use_block_based_builder_;
-  Options options_;
-};
-
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, Empty) {
   do {
     Options options;
@@ -232,6 +176,7 @@ TEST_F(DBTest, Empty) {
     ASSERT_EQ("0", num);
   } while (ChangeOptions());
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, WriteEmptyBatch) {
   Options options;
@@ -254,6 +199,60 @@ TEST_F(DBTest, WriteEmptyBatch) {
   ASSERT_EQ("bar", Get(1, "foo"));
 }
 
+#ifndef ROCKSDB_LITE
+TEST_F(DBTest, GetAggregatedIntPropertyTest) {
+  const int kKeySize = 100;
+  const int kValueSize = 500;
+  const int kKeyNum = 100;
+
+  Options options;
+  options.env = env_;
+  options.create_if_missing = true;
+  options.write_buffer_size = (kKeySize + kValueSize) * kKeyNum / 10;
+  // Make them never flush
+  options.min_write_buffer_number_to_merge = 1000;
+  options.max_write_buffer_number = 1000;
+  options = CurrentOptions(options);
+  CreateAndReopenWithCF({"one", "two", "three", "four"}, options);
+
+  Random rnd(301);
+  for (auto* handle : handles_) {
+    for (int i = 0; i < kKeyNum; ++i) {
+      db_->Put(WriteOptions(), handle, RandomString(&rnd, kKeySize),
+               RandomString(&rnd, kValueSize));
+    }
+  }
+
+  uint64_t manual_sum = 0;
+  uint64_t api_sum = 0;
+  uint64_t value = 0;
+  for (auto* handle : handles_) {
+    ASSERT_TRUE(
+        db_->GetIntProperty(handle, DB::Properties::kSizeAllMemTables, &value));
+    manual_sum += value;
+  }
+  ASSERT_TRUE(db_->GetAggregatedIntProperty(DB::Properties::kSizeAllMemTables,
+                                            &api_sum));
+  ASSERT_GT(manual_sum, 0);
+  ASSERT_EQ(manual_sum, api_sum);
+
+  ASSERT_FALSE(db_->GetAggregatedIntProperty(DB::Properties::kDBStats, &value));
+
+  uint64_t before_flush_trm;
+  uint64_t after_flush_trm;
+  for (auto* handle : handles_) {
+    ASSERT_TRUE(db_->GetAggregatedIntProperty(
+        DB::Properties::kEstimateTableReadersMem, &before_flush_trm));
+
+    // Issue flush and expect larger memory usage of table readers.
+    db_->Flush(FlushOptions(), handle);
+
+    ASSERT_TRUE(db_->GetAggregatedIntProperty(
+        DB::Properties::kEstimateTableReadersMem, &after_flush_trm));
+    ASSERT_GT(after_flush_trm, before_flush_trm);
+  }
+}
+
 TEST_F(DBTest, ReadOnlyDB) {
   ASSERT_OK(Put("foo", "v1"));
   ASSERT_OK(Put("bar", "v2"));
@@ -475,42 +474,6 @@ TEST_F(DBTest, ParanoidFileChecks) {
             TestGetTickerCount(options, BLOCK_CACHE_ADD));
 }
 
-TEST_F(DBTest, GetPropertiesOfAllTablesTest) {
-  Options options = CurrentOptions();
-  options.level0_file_num_compaction_trigger = 8;
-  Reopen(options);
-  // Create 4 tables
-  for (int table = 0; table < 4; ++table) {
-    for (int i = 0; i < 10 + table; ++i) {
-      db_->Put(WriteOptions(), ToString(table * 100 + i), "val");
-    }
-    db_->Flush(FlushOptions());
-  }
-
-  // 1. Read table properties directly from file
-  Reopen(options);
-  VerifyTableProperties(db_, 10 + 11 + 12 + 13);
-
-  // 2. Put two tables to table cache and
-  Reopen(options);
-  // fetch key from 1st and 2nd table, which will internally place that table to
-  // the table cache.
-  for (int i = 0; i < 2; ++i) {
-    Get(ToString(i * 100 + 0));
-  }
-
-  VerifyTableProperties(db_, 10 + 11 + 12 + 13);
-
-  // 3. Put all tables to table cache
-  Reopen(options);
-  // fetch key from 1st and 2nd table, which will internally place that table to
-  // the table cache.
-  for (int i = 0; i < 4; ++i) {
-    Get(ToString(i * 100 + 0));
-  }
-  VerifyTableProperties(db_, 10 + 11 + 12 + 13);
-}
-
 namespace {
 void ResetTableProperties(TableProperties* tp) {
   tp->data_size = 0;
@@ -642,10 +605,10 @@ TEST_F(DBTest, AggregatedTableProperties) {
 TEST_F(DBTest, ReadLatencyHistogramByLevel) {
   Options options = CurrentOptions();
   options.write_buffer_size = 110 << 10;
-  options.level0_file_num_compaction_trigger = 3;
+  options.level0_file_num_compaction_trigger = 6;
   options.num_levels = 4;
   options.compression = kNoCompression;
-  options.max_bytes_for_level_base = 450 << 10;
+  options.max_bytes_for_level_base = 4500 << 10;
   options.target_file_size_base = 98 << 10;
   options.max_write_buffer_number = 2;
   options.statistics = rocksdb::CreateDBStatistics();
@@ -657,16 +620,18 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
   DestroyAndReopen(options);
   int key_index = 0;
   Random rnd(301);
-  for (int num = 0; num < 5; num++) {
+  for (int num = 0; num < 8; num++) {
     Put("foo", "bar");
     GenerateNewFile(&rnd, &key_index);
+    dbfull()->TEST_WaitForCompact();
   }
+  dbfull()->TEST_WaitForCompact();
 
   std::string prop;
   ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop));
 
   // Get() after flushes, See latency histogram tracked.
-  for (int key = 0; key < 500; key++) {
+  for (int key = 0; key < key_index; key++) {
     Get(Key(key));
   }
   ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop));
@@ -676,7 +641,8 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
 
   // Reopen and issue Get(). See thee latency tracked
   Reopen(options);
-  for (int key = 0; key < 500; key++) {
+  dbfull()->TEST_WaitForCompact();
+  for (int key = 0; key < key_index; key++) {
     Get(Key(key));
   }
   ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop));
@@ -707,7 +673,7 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
   ASSERT_NE(std::string::npos, prop.find("** Level 0 read latency histogram"));
   ASSERT_NE(std::string::npos, prop.find("** Level 1 read latency histogram"));
   ASSERT_EQ(std::string::npos, prop.find("** Level 2 read latency histogram"));
-  for (int key = 0; key < 500; key++) {
+  for (int key = 0; key < key_index; key++) {
     Get(Key(key));
   }
   ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop));
@@ -787,6 +753,7 @@ TEST_F(DBTest, AggregatedTablePropertiesAtLevel) {
     }
   }
 }
+#endif  // ROCKSDB_LITE
 
 class CoutingUserTblPropCollector : public TablePropertiesCollector {
  public:
@@ -819,21 +786,35 @@ class CoutingUserTblPropCollector : public TablePropertiesCollector {
 class CoutingUserTblPropCollectorFactory
     : public TablePropertiesCollectorFactory {
  public:
-  virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
+  explicit CoutingUserTblPropCollectorFactory(
+      uint32_t expected_column_family_id)
+      : expected_column_family_id_(expected_column_family_id),
+        num_created_(0) {}
+  virtual TablePropertiesCollector* CreateTablePropertiesCollector(
+      TablePropertiesCollectorFactory::Context context) override {
+    EXPECT_EQ(expected_column_family_id_, context.column_family_id);
+    num_created_++;
     return new CoutingUserTblPropCollector();
   }
   const char* Name() const override {
     return "CoutingUserTblPropCollectorFactory";
   }
+  void set_expected_column_family_id(uint32_t v) {
+    expected_column_family_id_ = v;
+  }
+  uint32_t expected_column_family_id_;
+  uint32_t num_created_;
 };
 
-TEST_F(DBTest, GetUserDefinedTablaProperties) {
+#ifndef ROCKSDB_LITE
+TEST_F(DBTest, GetUserDefinedTableProperties) {
   Options options = CurrentOptions();
   options.level0_file_num_compaction_trigger = (1<<30);
   options.max_background_flushes = 0;
   options.table_properties_collector_factories.resize(1);
-  options.table_properties_collector_factories[0] =
-      std::make_shared<CoutingUserTblPropCollectorFactory>();
+  std::shared_ptr<CoutingUserTblPropCollectorFactory> collector_factory =
+      std::make_shared<CoutingUserTblPropCollectorFactory>(0);
+  options.table_properties_collector_factories[0] = collector_factory;
   Reopen(options);
   // Create 4 tables
   for (int table = 0; table < 4; ++table) {
@@ -859,8 +840,76 @@ TEST_F(DBTest, GetUserDefinedTablaProperties) {
     sum += count;
   }
   ASSERT_EQ(10u + 11u + 12u + 13u, sum);
+
+  ASSERT_GT(collector_factory->num_created_, 0U);
+  collector_factory->num_created_ = 0;
+  dbfull()->TEST_CompactRange(0, nullptr, nullptr);
+  ASSERT_GT(collector_factory->num_created_, 0U);
+}
+#endif  // ROCKSDB_LITE
+
+TEST_F(DBTest, UserDefinedTablePropertiesContext) {
+  Options options = CurrentOptions();
+  options.level0_file_num_compaction_trigger = 3;
+  options.max_background_flushes = 0;
+  options.table_properties_collector_factories.resize(1);
+  std::shared_ptr<CoutingUserTblPropCollectorFactory> collector_factory =
+      std::make_shared<CoutingUserTblPropCollectorFactory>(1);
+  options.table_properties_collector_factories[0] = collector_factory,
+  CreateAndReopenWithCF({"pikachu"}, options);
+  // Create 2 files
+  for (int table = 0; table < 2; ++table) {
+    for (int i = 0; i < 10 + table; ++i) {
+      Put(1, ToString(table * 100 + i), "val");
+    }
+    Flush(1);
+  }
+  ASSERT_GT(collector_factory->num_created_, 0U);
+
+  collector_factory->num_created_ = 0;
+  // Trigger automatic compactions.
+  for (int table = 0; table < 3; ++table) {
+    for (int i = 0; i < 10 + table; ++i) {
+      Put(1, ToString(table * 100 + i), "val");
+    }
+    Flush(1);
+    dbfull()->TEST_WaitForCompact();
+  }
+  ASSERT_GT(collector_factory->num_created_, 0U);
+
+  collector_factory->num_created_ = 0;
+  dbfull()->TEST_CompactRange(0, nullptr, nullptr, handles_[1]);
+  ASSERT_GT(collector_factory->num_created_, 0U);
+
+  // Come back to write to default column family
+  collector_factory->num_created_ = 0;
+  collector_factory->set_expected_column_family_id(0);  // default CF
+  // Create 4 tables in default column family
+  for (int table = 0; table < 2; ++table) {
+    for (int i = 0; i < 10 + table; ++i) {
+      Put(ToString(table * 100 + i), "val");
+    }
+    Flush();
+  }
+  ASSERT_GT(collector_factory->num_created_, 0U);
+
+  collector_factory->num_created_ = 0;
+  // Trigger automatic compactions.
+  for (int table = 0; table < 3; ++table) {
+    for (int i = 0; i < 10 + table; ++i) {
+      Put(ToString(table * 100 + i), "val");
+    }
+    Flush();
+    dbfull()->TEST_WaitForCompact();
+  }
+  ASSERT_GT(collector_factory->num_created_, 0U);
+
+  collector_factory->num_created_ = 0;
+  dbfull()->TEST_CompactRange(0, nullptr, nullptr);
+  ASSERT_GT(collector_factory->num_created_, 0U);
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, LevelLimitReopen) {
   Options options = CurrentOptions();
   CreateAndReopenWithCF({"pikachu"}, options);
@@ -882,6 +931,7 @@ TEST_F(DBTest, LevelLimitReopen) {
   options.max_bytes_for_level_multiplier_additional.resize(10, 1);
   ASSERT_OK(TryReopenWithColumnFamilies({"default", "pikachu"}, options));
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, PutDeleteGet) {
   do {
@@ -1028,6 +1078,7 @@ TEST_F(DBTest, GetFromVersions) {
   } while (ChangeOptions());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, GetSnapshot) {
   anon::OptionsOverride options_override;
   options_override.skip_policy = kSkipNoSnapshot;
@@ -1053,6 +1104,7 @@ TEST_F(DBTest, GetSnapshot) {
     }
   } while (ChangeOptions());
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, GetLevel0Ordering) {
   do {
@@ -1080,6 +1132,7 @@ TEST_F(DBTest, WrongLevel0Config) {
   ASSERT_OK(DB::Open(options, dbname_, &db_));
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, GetOrderedByLevels) {
   do {
     CreateAndReopenWithCF({"pikachu"}, CurrentOptions());
@@ -1151,6 +1204,7 @@ TEST_F(DBTest, GetEncountersEmptyLevel) {
     ASSERT_EQ(NumTableFilesAtLevel(0, 1), 1);  // XXX
   } while (ChangeOptions(kSkipUniversalCompaction | kSkipFIFOCompaction));
 }
+#endif  // ROCKSDB_LITE
 
 // KeyMayExist can lead to a few false positives, but not false negatives.
 // To make test deterministic, use a much larger number of bits per key-20 than
@@ -1283,6 +1337,7 @@ TEST_F(DBTest, NonBlockingIteration) {
                          kSkipMmapReads));
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, ManagedNonBlockingIteration) {
   do {
     ReadOptions non_blocking_opts, regular_opts;
@@ -1347,6 +1402,7 @@ TEST_F(DBTest, ManagedNonBlockingIteration) {
   } while (ChangeOptions(kSkipPlainTable | kSkipNoSeekToLast | kSkipHashCuckoo |
                          kSkipMmapReads));
 }
+#endif  // ROCKSDB_LITE
 
 // A delete is skipped for key if KeyMayExist(key) returns False
 // Tests Writebatch consistency and proper delete behaviour
@@ -1854,9 +1910,10 @@ TEST_F(DBTest, IterReseek) {
   DestroyAndReopen(options);
   CreateAndReopenWithCF({"pikachu"}, options);
 
-  // insert two keys with same userkey and verify that
+  // insert three keys with same userkey and verify that
   // reseek is not invoked. For each of these test cases,
   // verify that we can find the next key "b".
+  ASSERT_OK(Put(1, "a", "zero"));
   ASSERT_OK(Put(1, "a", "one"));
   ASSERT_OK(Put(1, "a", "two"));
   ASSERT_OK(Put(1, "b", "bone"));
@@ -2115,7 +2172,7 @@ TEST_F(DBTest, RecoverWithTableHandle) {
 
     std::vector<std::vector<FileMetaData>> files;
     dbfull()->TEST_GetFilesMetaData(handles_[1], &files);
-    int total_files = 0;
+    size_t total_files = 0;
     for (const auto& level : files) {
       total_files += level.size();
     }
@@ -2251,6 +2308,7 @@ TEST_F(DBTest, FlushMultipleMemtable) {
   } while (ChangeCompactOptions());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, NumImmutableMemTable) {
   do {
     Options options = CurrentOptions();
@@ -2324,9 +2382,9 @@ TEST_F(DBTest, NumImmutableMemTable) {
     ASSERT_EQ(num, "0");
     ASSERT_TRUE(dbfull()->GetProperty(
         handles_[1], "rocksdb.cur-size-active-mem-table", &num));
-    // "200" is the size of the metadata of an empty skiplist, this would
+    // "192" is the size of the metadata of an empty skiplist, this would
     // break if we change the default skiplist implementation
-    ASSERT_EQ(num, "200");
+    ASSERT_EQ(num, "192");
 
     uint64_t int_num;
     uint64_t base_total_size;
@@ -2360,6 +2418,7 @@ TEST_F(DBTest, NumImmutableMemTable) {
     ASSERT_TRUE(GetPerfLevel() == kDisable);
   } while (ChangeCompactOptions());
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, FlushEmptyColumnFamily) {
   // Block flush thread and disable compaction thread
@@ -2405,6 +2464,7 @@ TEST_F(DBTest, FlushEmptyColumnFamily) {
   sleeping_task_low.WaitUntilDone();
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, GetProperty) {
   // Set sizes to both background thread pool to be 1 and block them.
   env_->SetBackgroundThreads(1, Env::HIGH);
@@ -2710,6 +2770,7 @@ TEST_F(DBTest, EstimatePendingCompBytes) {
       "rocksdb.estimate-pending-compaction-bytes", &int_num));
   ASSERT_EQ(int_num, 0U);
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, FLUSH) {
   do {
@@ -2769,7 +2830,7 @@ TEST_F(DBTest, RecoveryWithEmptyLog) {
   } while (ChangeOptions());
 }
 
-
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, FlushSchedule) {
   Options options = CurrentOptions();
   options.disable_auto_compactions = true;
@@ -2810,7 +2871,7 @@ TEST_F(DBTest, FlushSchedule) {
   ASSERT_LE(pikachu_tables, static_cast<uint64_t>(10));
   ASSERT_GT(pikachu_tables, static_cast<uint64_t>(0));
 }
-
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, ManifestRollOver) {
   do {
@@ -2858,6 +2919,7 @@ TEST_F(DBTest, IdentityAcrossRestarts) {
   } while (ChangeCompactOptions());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, RecoverWithLargeLog) {
   do {
     {
@@ -2884,6 +2946,7 @@ TEST_F(DBTest, RecoverWithLargeLog) {
     ASSERT_GT(NumTableFilesAtLevel(0, 1), 1);
   } while (ChangeCompactOptions());
 }
+#endif  // ROCKSDB_LITE
 
 namespace {
 class KeepFilter : public CompactionFilter {
@@ -2948,6 +3011,7 @@ class DelayFilterFactory : public CompactionFilterFactory {
 };
 }  // namespace
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, CompressedCache) {
   if (!Snappy_Supported()) {
     return;
@@ -3071,6 +3135,7 @@ static std::string CompressibleString(Random* rnd, int len) {
   test::CompressibleString(rnd, 0.8, len, &r);
   return r;
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, FailMoreDbPaths) {
   Options options = CurrentOptions();
@@ -3101,6 +3166,7 @@ void CheckColumnFamilyMeta(const ColumnFamilyMetaData& cf_meta) {
   ASSERT_EQ(cf_meta.size, cf_size);
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, ColumnFamilyMetaDataTest) {
   Options options = CurrentOptions();
   options.create_if_missing = true;
@@ -3247,6 +3313,7 @@ TEST_F(DBTest, RepeatedWritesToSameKey) {
     }
   } while (ChangeCompactOptions());
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, SparseMerge) {
   do {
@@ -3293,6 +3360,7 @@ TEST_F(DBTest, SparseMerge) {
   } while (ChangeCompactOptions());
 }
 
+#ifndef ROCKSDB_LITE
 static bool Between(uint64_t val, uint64_t low, uint64_t high) {
   bool result = (val >= low) && (val <= high);
   if (!result) {
@@ -3505,6 +3573,7 @@ TEST_F(DBTest, ApproximateSizes_MixOfSmallAndLarge) {
     // ApproximateOffsetOf() is not yet implemented in plain table format.
   } while (ChangeOptions(kSkipPlainTable));
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, IteratorPinsRef) {
   do {
@@ -3532,6 +3601,7 @@ TEST_F(DBTest, IteratorPinsRef) {
   } while (ChangeCompactOptions());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, Snapshot) {
   anon::OptionsOverride options_override;
   options_override.skip_policy = kSkipNoSnapshot;
@@ -3634,6 +3704,7 @@ TEST_F(DBTest, HiddenValuesAreRemoved) {
   } while (ChangeOptions(kSkipUniversalCompaction | kSkipFIFOCompaction |
                          kSkipPlainTable | kSkipHashCuckoo));
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, CompactBetweenSnapshots) {
   anon::OptionsOverride options_override;
@@ -3739,6 +3810,7 @@ TEST_F(DBTest, UnremovableSingleDelete) {
                          kSkipUniversalCompaction | kSkipMergePut));
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, DeletionMarkers1) {
   Options options = CurrentOptions();
   options.max_background_flushes = 0;
@@ -3848,6 +3920,7 @@ TEST_F(DBTest, OverlapInLevel0) {
     ASSERT_EQ("NOT_FOUND", Get(1, "600"));
   } while (ChangeOptions(kSkipUniversalCompaction | kSkipFIFOCompaction));
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, ComparatorCheck) {
   class NewComparator : public Comparator {
@@ -4040,6 +4113,7 @@ TEST_F(DBTest, DestroyDBMetaDatabase) {
   ASSERT_TRUE(!(DB::Open(options, metametadbname, &db)).ok());
 }
 
+#ifndef ROCKSDB_LITE
 // Check that number of files does not grow when writes are dropped
 TEST_F(DBTest, DropWrites) {
   do {
@@ -4110,6 +4184,7 @@ TEST_F(DBTest, DropWritesFlush) {
     env_->drop_writes_.store(false, std::memory_order_release);
   } while (ChangeCompactOptions());
 }
+#endif  // ROCKSDB_LITE
 
 // Check that CompactRange() returns failure if there is not enough space left
 // on device
@@ -4159,6 +4234,7 @@ TEST_F(DBTest, NonWritableFileSystem) {
   } while (ChangeCompactOptions());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, ManifestWriteError) {
   // Test for the following problem:
   // (a) Compaction produces file F
@@ -4200,6 +4276,7 @@ TEST_F(DBTest, ManifestWriteError) {
     ASSERT_EQ("bar", Get("foo"));
   }
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, PutFailsParanoid) {
   // Test the following:
@@ -4458,6 +4535,7 @@ TEST_F(DBTest, BloomFilterWrapper) {
   ASSERT_EQ(2U * maxKey, policy->GetCounter());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, SnapshotFiles) {
   do {
     Options options = CurrentOptions();
@@ -4585,6 +4663,7 @@ TEST_F(DBTest, SnapshotFiles) {
     dbfull()->DisableFileDeletions();
   } while (ChangeCompactOptions());
 }
+#endif
 
 TEST_F(DBTest, CompactOnFlush) {
   anon::OptionsOverride options_override;
@@ -4724,6 +4803,7 @@ TEST_F(DBTest, FlushOneColumnFamily) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 // In https://reviews.facebook.net/D20661 we change
 // recovery behavior: previously for each log file each column family
 // memtable was flushed, even it was empty. Now it's changed:
@@ -4856,7 +4936,7 @@ TEST_F(DBTest, SharedWriteBuffer) {
   options.write_buffer_size    = 500000;  // this is never hit
   CreateAndReopenWithCF({"pikachu", "dobrynia", "nikitich"}, options);
 
-  // Trigger a flush on every CF
+  // Trigger a flush on CF "nikitich"
   ASSERT_OK(Put(0, Key(1), DummyString(1)));
   ASSERT_OK(Put(1, Key(1), DummyString(1)));
   ASSERT_OK(Put(3, Key(1), DummyString(90000)));
@@ -4868,67 +4948,110 @@ TEST_F(DBTest, SharedWriteBuffer) {
   dbfull()->TEST_WaitForFlushMemTable(handles_[3]);
   {
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
-              static_cast<uint64_t>(1));
+              static_cast<uint64_t>(0));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "pikachu"),
+              static_cast<uint64_t>(0));
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "dobrynia"),
+              static_cast<uint64_t>(0));
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "nikitich"),
               static_cast<uint64_t>(1));
+  }
+
+  // "dobrynia": 20KB
+  // Flush 'dobrynia'
+  ASSERT_OK(Put(3, Key(2), DummyString(40000)));
+  ASSERT_OK(Put(2, Key(2), DummyString(70000)));
+  ASSERT_OK(Put(0, Key(1), DummyString(1)));
+  dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
+  dbfull()->TEST_WaitForFlushMemTable(handles_[2]);
+  dbfull()->TEST_WaitForFlushMemTable(handles_[3]);
+  {
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
+              static_cast<uint64_t>(0));
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "pikachu"),
+              static_cast<uint64_t>(0));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "dobrynia"),
               static_cast<uint64_t>(1));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "nikitich"),
               static_cast<uint64_t>(1));
   }
 
-  // Flush 'dobrynia' and 'nikitich'
-  ASSERT_OK(Put(2, Key(2), DummyString(50000)));
-  ASSERT_OK(Put(3, Key(2), DummyString(40000)));
-  ASSERT_OK(Put(2, Key(3), DummyString(20000)));
+  // "nikitich" still has has data of 80KB
+  // Inserting Data in "dobrynia" triggers "nikitich" flushing.
   ASSERT_OK(Put(3, Key(2), DummyString(40000)));
+  ASSERT_OK(Put(2, Key(2), DummyString(40000)));
+  ASSERT_OK(Put(0, Key(1), DummyString(1)));
   dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
   dbfull()->TEST_WaitForFlushMemTable(handles_[2]);
   dbfull()->TEST_WaitForFlushMemTable(handles_[3]);
   {
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
-              static_cast<uint64_t>(1));
+              static_cast<uint64_t>(0));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "pikachu"),
-              static_cast<uint64_t>(1));
+              static_cast<uint64_t>(0));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "dobrynia"),
-              static_cast<uint64_t>(2));
+              static_cast<uint64_t>(1));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "nikitich"),
               static_cast<uint64_t>(2));
   }
 
-  // Make 'dobrynia' and 'nikitich' both take up 40% of space
-  // When 'pikachu' puts us over 100%, all 3 flush.
-  ASSERT_OK(Put(2, Key(2), DummyString(40000)));
+  // "dobrynia" still has 40KB
   ASSERT_OK(Put(1, Key(2), DummyString(20000)));
+  ASSERT_OK(Put(0, Key(1), DummyString(10000)));
   ASSERT_OK(Put(0, Key(1), DummyString(1)));
+  dbfull()->TEST_WaitForFlushMemTable(handles_[0]);
+  dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
   dbfull()->TEST_WaitForFlushMemTable(handles_[2]);
   dbfull()->TEST_WaitForFlushMemTable(handles_[3]);
+  // This should triggers no flush
   {
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
-              static_cast<uint64_t>(1));
+              static_cast<uint64_t>(0));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "pikachu"),
+              static_cast<uint64_t>(0));
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "dobrynia"),
+              static_cast<uint64_t>(1));
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "nikitich"),
               static_cast<uint64_t>(2));
+  }
+
+  // "default": 10KB, "pikachu": 20KB, "dobrynia": 40KB
+  ASSERT_OK(Put(1, Key(2), DummyString(40000)));
+  ASSERT_OK(Put(0, Key(1), DummyString(1)));
+  dbfull()->TEST_WaitForFlushMemTable(handles_[0]);
+  dbfull()->TEST_WaitForFlushMemTable(handles_[1]);
+  dbfull()->TEST_WaitForFlushMemTable(handles_[2]);
+  dbfull()->TEST_WaitForFlushMemTable(handles_[3]);
+  // This should triggers flush of "pikachu"
+  {
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
+              static_cast<uint64_t>(0));
+    ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "pikachu"),
+              static_cast<uint64_t>(1));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "dobrynia"),
-              static_cast<uint64_t>(3));
+              static_cast<uint64_t>(1));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "nikitich"),
-              static_cast<uint64_t>(3));
+              static_cast<uint64_t>(2));
   }
 
-  // Some remaining writes so 'default' and 'nikitich' flush on closure.
+  // "default": 10KB, "dobrynia": 40KB
+  // Some remaining writes so 'default', 'dobrynia' and 'nikitich' flush on
+  // closure.
   ASSERT_OK(Put(3, Key(1), DummyString(1)));
   ReopenWithColumnFamilies({"default", "pikachu", "dobrynia", "nikitich"},
                            options);
   {
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "default"),
-              static_cast<uint64_t>(2));
+              static_cast<uint64_t>(1));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "pikachu"),
-              static_cast<uint64_t>(2));
+              static_cast<uint64_t>(1));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "dobrynia"),
-              static_cast<uint64_t>(3));
+              static_cast<uint64_t>(2));
     ASSERT_EQ(GetNumberOfSstFilesForColumnFamily(db_, "nikitich"),
-              static_cast<uint64_t>(4));
+              static_cast<uint64_t>(3));
   }
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, PurgeInfoLogs) {
   Options options = CurrentOptions();
@@ -5001,6 +5124,7 @@ TEST_F(DBTest, SyncMultipleLogs) {
   ASSERT_OK(dbfull()->SyncWAL());
 }
 
+#ifndef ROCKSDB_LITE
 //
 // Test WAL recovery for the various modes available
 //
@@ -5045,7 +5169,9 @@ class RecoveryTestHelper {
       ASSERT_OK(db_options.env->NewWritableFile(fname, &file, env_options));
       unique_ptr<WritableFileWriter> file_writer(
           new WritableFileWriter(std::move(file), env_options));
-      current_log_writer.reset(new log::Writer(std::move(file_writer)));
+      current_log_writer.reset(
+          new log::Writer(std::move(file_writer), current_log_number,
+                          db_options.recycle_log_file_num > 0));
 
       for (int i = 0; i < kKeysPerWALFile; i++) {
         std::string key = "key" + ToString(count++);
@@ -5110,7 +5236,7 @@ class RecoveryTestHelper {
   // Overwrite data with 'a' from offset for length len
   static void InduceCorruption(const std::string& filename, uint32_t offset,
                                uint32_t len) {
-    ASSERT_GT(len, 0);
+    ASSERT_GT(len, 0U);
 
     int fd = open(filename.c_str(), O_RDWR);
 
@@ -5283,7 +5409,6 @@ TEST_F(DBTest, kSkipAnyCorruptedRecords) {
   }
 }
 
-
 // Multi-threaded test:
 namespace {
 
@@ -5450,6 +5575,7 @@ TEST_P(MultiThreadedDBTest, MultiThreaded) {
 INSTANTIATE_TEST_CASE_P(
     MultiThreaded, MultiThreadedDBTest,
     ::testing::ValuesIn(MultiThreadedDBTest::GenerateOptionConfigs()));
+#endif  // ROCKSDB_LITE
 
 // Group commit test:
 namespace {
@@ -5590,6 +5716,7 @@ class ModelDB: public DB {
     return s;
   }
 
+#ifndef ROCKSDB_LITE
   using DB::AddFile;
   virtual Status AddFile(ColumnFamilyHandle* column_family,
                          const ExternalSstFileInfo* file_path,
@@ -5609,6 +5736,13 @@ class ModelDB: public DB {
     return Status();
   }
 
+  virtual Status GetPropertiesOfTablesInRange(
+      ColumnFamilyHandle* column_family, const Range* range, std::size_t n,
+      TablePropertiesCollection* props) override {
+    return Status();
+  }
+#endif  // ROCKSDB_LITE
+
   using DB::KeyMayExist;
   virtual bool KeyMayExist(const ReadOptions& options,
                            ColumnFamilyHandle* column_family, const Slice& key,
@@ -5679,6 +5813,11 @@ class ModelDB: public DB {
                               const Slice& property, uint64_t* value) override {
     return false;
   }
+  using DB::GetAggregatedIntProperty;
+  virtual bool GetAggregatedIntProperty(const Slice& property,
+                                        uint64_t* value) override {
+    return false;
+  }
   using DB::GetApproximateSizes;
   virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
                                    const Range* range, int n, uint64_t* sizes,
@@ -5711,6 +5850,11 @@ class ModelDB: public DB {
     return Status::NotSupported("Not supported operation.");
   }
 
+  Status EnableAutoCompaction(
+      const std::vector<ColumnFamilyHandle*>& column_family_handles) override {
+    return Status::NotSupported("Not supported operation.");
+  }
+
   using DB::NumberLevels;
   virtual int NumberLevels(ColumnFamilyHandle* column_family) override {
     return 1;
@@ -5752,7 +5896,9 @@ class ModelDB: public DB {
     return Status::OK();
   }
 
+#ifndef ROCKSDB_LITE
   virtual Status DisableFileDeletions() override { return Status::OK(); }
+
   virtual Status EnableFileDeletions(bool force) override {
     return Status::OK();
   }
@@ -5767,11 +5913,6 @@ class ModelDB: public DB {
 
   virtual Status DeleteFile(std::string name) override { return Status::OK(); }
 
-  virtual Status GetDbIdentity(std::string& identity) const override {
-    return Status::OK();
-  }
-
-  virtual SequenceNumber GetLatestSequenceNumber() const override { return 0; }
   virtual Status GetUpdatesSince(
       rocksdb::SequenceNumber, unique_ptr<rocksdb::TransactionLogIterator>*,
       const TransactionLogIterator::ReadOptions&
@@ -5779,13 +5920,20 @@ class ModelDB: public DB {
     return Status::NotSupported("Not supported in Model DB");
   }
 
-  virtual ColumnFamilyHandle* DefaultColumnFamily() const override {
-    return nullptr;
-  }
-
   virtual void GetColumnFamilyMetaData(
       ColumnFamilyHandle* column_family,
       ColumnFamilyMetaData* metadata) override {}
+#endif  // ROCKSDB_LITE
+
+  virtual Status GetDbIdentity(std::string& identity) const override {
+    return Status::OK();
+  }
+
+  virtual SequenceNumber GetLatestSequenceNumber() const override { return 0; }
+
+  virtual ColumnFamilyHandle* DefaultColumnFamily() const override {
+    return nullptr;
+  }
 
  private:
   class ModelIter: public Iterator {
@@ -6046,6 +6194,7 @@ TEST_F(DBTest, MultiGetEmpty) {
   } while (ChangeCompactOptions());
 }
 
+#ifndef ROCKSDB_LITE
 namespace {
 void PrefixScanInit(DBTest *dbtest) {
   char buf[100];
@@ -6148,6 +6297,7 @@ TEST_F(DBTest, PrefixScan) {
   }  // end of while
   XFUNC_TEST("", "dbtest_prefix", prefix_skip1, XFuncPoint::SetSkip, 0);
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, BlockBasedTablePrefixIndexTest) {
   // create a DB with block prefix index
@@ -6209,6 +6359,7 @@ TEST_F(DBTest, ChecksumTest) {
   ASSERT_EQ("h", Get("g"));
 }
 
+#ifndef ROCKSDB_LITE
 TEST_P(DBTestWithParam, FIFOCompactionTest) {
   for (int iter = 0; iter < 2; ++iter) {
     // first iteration -- auto compaction
@@ -6248,6 +6399,7 @@ TEST_P(DBTestWithParam, FIFOCompactionTest) {
     }
   }
 }
+#endif  // ROCKSDB_LITE
 
 // verify that we correctly deprecated timeout_hint_us
 TEST_F(DBTest, SimpleWriteTimeoutTest) {
@@ -6258,6 +6410,7 @@ TEST_F(DBTest, SimpleWriteTimeoutTest) {
   ASSERT_NOK(Put(Key(1), Key(1) + std::string(100, 'v'), write_opt));
 }
 
+#ifndef ROCKSDB_LITE
 /*
  * This test is not reliable enough as it heavily depends on disk behavior.
  */
@@ -6350,6 +6503,7 @@ TEST_F(DBTest, TableOptionsSanitizeTest) {
   options.prefix_extractor.reset(NewFixedPrefixTransform(1));
   ASSERT_OK(TryReopen(options));
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, SanitizeNumThreads) {
   for (int attempt = 0; attempt < 2; attempt++) {
@@ -6595,6 +6749,7 @@ TEST_F(DBTest, DisableDataSyncTest) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, DynamicMemtableOptions) {
   const uint64_t k64KB = 1 << 16;
   const uint64_t k128KB = 1 << 17;
@@ -6736,6 +6891,7 @@ TEST_F(DBTest, DynamicMemtableOptions) {
 
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
+#endif  // ROCKSDB_LITE
 
 #if ROCKSDB_USING_THREAD_STATUS
 namespace {
@@ -6844,6 +7000,10 @@ TEST_F(DBTest, ThreadStatusFlush) {
   ASSERT_EQ("v1", Get(1, "foo"));
   VerifyOperationCount(env_, ThreadStatus::OP_FLUSH, 0);
 
+  uint64_t num_running_flushes = 0;
+  db_->GetIntProperty(DB::Properties::kNumRunningFlushes, &num_running_flushes);
+  ASSERT_EQ(num_running_flushes, 0);
+
   Put(1, "k1", std::string(100000, 'x'));  // Fill memtable
   Put(1, "k2", std::string(100000, 'y'));  // Trigger flush
 
@@ -6851,10 +7011,11 @@ TEST_F(DBTest, ThreadStatusFlush) {
   // running when we perform VerifyOperationCount().
   TEST_SYNC_POINT("DBTest::ThreadStatusFlush:1");
   VerifyOperationCount(env_, ThreadStatus::OP_FLUSH, 1);
+  db_->GetIntProperty(DB::Properties::kNumRunningFlushes, &num_running_flushes);
+  ASSERT_EQ(num_running_flushes, 1);
   // This second sync point is to ensure the flush job will not
   // be completed until we already perform VerifyOperationCount().
   TEST_SYNC_POINT("DBTest::ThreadStatusFlush:2");
-
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
 
@@ -6899,6 +7060,10 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
     }
     // This makes sure a compaction won't be scheduled until
     // we have done with the above Put Phase.
+    uint64_t num_running_compactions = 0;
+    db_->GetIntProperty(DB::Properties::kNumRunningCompactions,
+                        &num_running_compactions);
+    ASSERT_EQ(num_running_compactions, 0);
     TEST_SYNC_POINT("DBTest::ThreadStatusSingleCompaction:0");
     ASSERT_GE(NumTableFilesAtLevel(0),
               options.level0_file_num_compaction_trigger);
@@ -6913,6 +7078,9 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
       // If thread tracking is not enabled, compaction count should be 0.
       VerifyOperationCount(env_, ThreadStatus::OP_COMPACTION, 0);
     }
+    db_->GetIntProperty(DB::Properties::kNumRunningCompactions,
+                        &num_running_compactions);
+    ASSERT_EQ(num_running_compactions, 1);
     // TODO(yhchiang): adding assert to verify each compaction stage.
     TEST_SYNC_POINT("DBTest::ThreadStatusSingleCompaction:2");
 
@@ -7161,6 +7329,7 @@ TEST_P(DBTestWithParam, PreShutdownCompactionMiddle) {
 
 #endif  // ROCKSDB_USING_THREAD_STATUS
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, FlushOnDestroy) {
   WriteOptions wo;
   wo.disableWAL = true;
@@ -7301,7 +7470,7 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
   options.level0_file_num_compaction_trigger = 2;
   options.level0_slowdown_writes_trigger = 2;
   options.level0_stop_writes_trigger = 2;
-  options.soft_rate_limit = 1.1;
+  options.soft_pending_compaction_bytes_limit = 1024 * 1024;
 
   // Use file size to distinguish levels
   // L1: 10, L2: 20, L3 40, L4 80
@@ -7345,8 +7514,14 @@ TEST_F(DBTest, DynamicLevelCompressionPerLevel2) {
 
   for (int i = 0; i < 100; i++) {
     ASSERT_OK(Put(Key(keys[i]), RandomString(&rnd, 200)));
+
+    if (i % 25 == 0) {
+      dbfull()->TEST_WaitForFlushMemTable();
+    }
   }
+
   Flush();
+  dbfull()->TEST_WaitForFlushMemTable();
   dbfull()->TEST_WaitForCompact();
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
   rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();
@@ -7411,7 +7586,7 @@ TEST_F(DBTest, DynamicCompactionOptions) {
   options.env = env_;
   options.create_if_missing = true;
   options.compression = kNoCompression;
-  options.soft_rate_limit = 1.1;
+  options.soft_pending_compaction_bytes_limit = 1024 * 1024;
   options.write_buffer_size = k64KB;
   options.arena_block_size = 4 * k4KB;
   options.max_write_buffer_number = 2;
@@ -7523,28 +7698,25 @@ TEST_F(DBTest, DynamicCompactionOptions) {
   // Clean up memtable and L0. Block compaction threads. If continue to write
   // and flush memtables. We should see put stop after 8 memtable flushes
   // since level0_stop_writes_trigger = 8
+  dbfull()->TEST_FlushMemTable(true);
   dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
   // Block compaction
   test::SleepingBackgroundTask sleeping_task_low;
   env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task_low,
                  Env::Priority::LOW);
-
-  rocksdb::SyncPoint::GetInstance()->SetCallBack(
-      "DBImpl::DelayWrite:Wait",
-      [&](void* arg) { sleeping_task_low.WakeUp(); });
-  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
-
+  sleeping_task_low.WaitUntilSleeping();
   ASSERT_EQ(NumTableFilesAtLevel(0), 0);
   int count = 0;
   Random rnd(301);
   WriteOptions wo;
   while (count < 64) {
     ASSERT_OK(Put(Key(count), RandomString(&rnd, 1024), wo));
-    if (sleeping_task_low.WokenUp()) {
-      break;
-    }
     dbfull()->TEST_FlushMemTable(true);
     count++;
+    if (dbfull()->TEST_write_controler().IsStopped()) {
+      sleeping_task_low.WakeUp();
+      break;
+    }
   }
   // Stop trigger = 8
   ASSERT_EQ(count, 8);
@@ -7557,6 +7729,7 @@ TEST_F(DBTest, DynamicCompactionOptions) {
   ASSERT_OK(dbfull()->SetOptions({
     {"level0_stop_writes_trigger", "6"}
   }));
+  dbfull()->TEST_FlushMemTable(true);
   dbfull()->CompactRange(CompactRangeOptions(), nullptr, nullptr);
   ASSERT_EQ(NumTableFilesAtLevel(0), 0);
 
@@ -7564,14 +7737,16 @@ TEST_F(DBTest, DynamicCompactionOptions) {
   sleeping_task_low.Reset();
   env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task_low,
                  Env::Priority::LOW);
+  sleeping_task_low.WaitUntilSleeping();
   count = 0;
   while (count < 64) {
     ASSERT_OK(Put(Key(count), RandomString(&rnd, 1024), wo));
-    if (sleeping_task_low.WokenUp()) {
-      break;
-    }
     dbfull()->TEST_FlushMemTable(true);
     count++;
+    if (dbfull()->TEST_write_controler().IsStopped()) {
+      sleeping_task_low.WakeUp();
+      break;
+    }
   }
   ASSERT_EQ(count, 6);
   // Unblock
@@ -7611,9 +7786,8 @@ TEST_F(DBTest, DynamicCompactionOptions) {
   }
   dbfull()->TEST_WaitForCompact();
   ASSERT_LT(NumTableFilesAtLevel(0), 4);
-
-  rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, FileCreationRandomFailure) {
   Options options;
@@ -7675,6 +7849,7 @@ TEST_F(DBTest, FileCreationRandomFailure) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, DynamicMiscOptions) {
   // Test max_sequential_skip_in_iterations
   Options options;
@@ -7724,6 +7899,7 @@ TEST_F(DBTest, DynamicMiscOptions) {
   // No reseek
   assert_reseek_count(300, 1);
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, DontDeletePendingOutputs) {
   Options options;
@@ -7757,6 +7933,7 @@ TEST_F(DBTest, DontDeletePendingOutputs) {
   Compact("a", "b");
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, DontDeleteMovedFile) {
   // This test triggers move compaction and verifies that the file is not
   // deleted when it's part of move compaction
@@ -7859,6 +8036,7 @@ TEST_F(DBTest, OptimizeFiltersForHits) {
     ASSERT_EQ(Get(1, Key(i)), "val");
   }
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, L0L1L2AndUpHitCounter) {
   Options options = CurrentOptions();
@@ -7958,6 +8136,7 @@ TEST_F(DBTest, MutexWaitStats) {
       ThreadStatus::STATE_MUTEX_WAIT, 0);
 }
 
+#ifndef ROCKSDB_LITE
 // This reproduces a bug where we don't delete a file because when it was
 // supposed to be deleted, it was blocked by pending_outputs
 // Consider:
@@ -8053,6 +8232,7 @@ TEST_F(DBTest, DeleteObsoleteFilesPendingOutputs) {
   ASSERT_EQ(Status::NotFound(), env_->FileExists(dbname_ + file_on_L2));
   listener->VerifyMatchedCount(1);
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, CloseSpeedup) {
   Options options = CurrentOptions();
@@ -8109,16 +8289,18 @@ TEST_F(DBTest, CloseSpeedup) {
   Destroy(options);
 }
 
-class DelayedMergeOperator : public AssociativeMergeOperator {
+class DelayedMergeOperator : public MergeOperator {
  private:
   DBTest* db_test_;
 
  public:
   explicit DelayedMergeOperator(DBTest* d) : db_test_(d) {}
-  virtual bool Merge(const Slice& key, const Slice* existing_value,
-                     const Slice& value, std::string* new_value,
-                     Logger* logger) const override {
+  virtual bool FullMerge(const Slice& key, const Slice* existing_value,
+                         const std::deque<std::string>& operand_list,
+                         std::string* new_value,
+                         Logger* logger) const override {
     db_test_->env_->addon_time_.fetch_add(1000);
+    *new_value = "";
     return true;
   }
 
@@ -8134,6 +8316,8 @@ TEST_F(DBTest, MergeTestTime) {
   // Enable time profiling
   SetPerfLevel(kEnableTime);
   this->env_->addon_time_.store(0);
+  this->env_->time_elapse_only_sleep_ = true;
+  this->env_->no_sleep_ = true;
   Options options;
   options = CurrentOptions(options);
   options.statistics = rocksdb::CreateDBStatistics();
@@ -8154,8 +8338,7 @@ TEST_F(DBTest, MergeTestTime) {
   std::string result;
   db_->Get(opt, "foo", &result);
 
-  ASSERT_LT(TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME), 2800000);
-  ASSERT_GT(TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME), 1200000);
+  ASSERT_EQ(1000000, TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME));
 
   ReadOptions read_options;
   std::unique_ptr<Iterator> iter(db_->NewIterator(read_options));
@@ -8166,14 +8349,14 @@ TEST_F(DBTest, MergeTestTime) {
   }
 
   ASSERT_EQ(1, count);
-
-  ASSERT_LT(TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME), 6000000);
-  ASSERT_GT(TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME), 3200000);
+  ASSERT_EQ(2000000, TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME));
 #if ROCKSDB_USING_THREAD_STATUS
   ASSERT_GT(TestGetTickerCount(options, FLUSH_WRITE_BYTES), 0);
 #endif  // ROCKSDB_USING_THREAD_STATUS
+  this->env_->time_elapse_only_sleep_ = false;
 }
 
+#ifndef ROCKSDB_LITE
 TEST_P(DBTestWithParam, MergeCompactionTimeTest) {
   SetPerfLevel(kEnableTime);
   Options options;
@@ -8224,6 +8407,7 @@ TEST_P(DBTestWithParam, FilterCompactionTimeTest) {
   ASSERT_NE(TestGetTickerCount(options, FILTER_OPERATION_TOTAL_TIME), 0);
   delete itr;
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, TestLogCleanup) {
   Options options = CurrentOptions();
@@ -8240,6 +8424,7 @@ TEST_F(DBTest, TestLogCleanup) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, EmptyCompactedDB) {
   Options options;
   options.max_open_files = -1;
@@ -8250,6 +8435,7 @@ TEST_F(DBTest, EmptyCompactedDB) {
   ASSERT_TRUE(s.IsNotSupported());
   Close();
 }
+#endif  // ROCKSDB_LITE
 
 class CountingDeleteTabPropCollector : public TablePropertiesCollector {
  public:
@@ -8282,7 +8468,8 @@ class CountingDeleteTabPropCollector : public TablePropertiesCollector {
 class CountingDeleteTabPropCollectorFactory
     : public TablePropertiesCollectorFactory {
  public:
-  virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
+  virtual TablePropertiesCollector* CreateTablePropertiesCollector(
+      TablePropertiesCollectorFactory::Context context) override {
     return new CountingDeleteTabPropCollector();
   }
   const char* Name() const override {
@@ -8290,6 +8477,7 @@ class CountingDeleteTabPropCollectorFactory
   }
 };
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, TablePropertiesNeedCompactTest) {
   Random rnd(301);
 
@@ -8303,11 +8491,11 @@ TEST_F(DBTest, TablePropertiesNeedCompactTest) {
   options.target_file_size_base = 2048;
   options.max_bytes_for_level_base = 10240;
   options.max_bytes_for_level_multiplier = 4;
-  options.soft_rate_limit = 1.1;
+  options.soft_pending_compaction_bytes_limit = 1024 * 1024;
   options.num_levels = 8;
 
-  std::shared_ptr<TablePropertiesCollectorFactory> collector_factory(
-      new CountingDeleteTabPropCollectorFactory);
+  std::shared_ptr<TablePropertiesCollectorFactory> collector_factory =
+      std::make_shared<CountingDeleteTabPropCollectorFactory>();
   options.table_properties_collector_factories.resize(1);
   options.table_properties_collector_factories[0] = collector_factory;
 
@@ -8366,9 +8554,64 @@ TEST_F(DBTest, TablePropertiesNeedCompactTest) {
   }
 }
 
-TEST_F(DBTest, SuggestCompactRangeTest) {
-  class CompactionFilterFactoryGetContext : public CompactionFilterFactory {
-   public:
+TEST_F(DBTest, NeedCompactHintPersistentTest) {
+  Random rnd(301);
+
+  Options options;
+  options.create_if_missing = true;
+  options.max_write_buffer_number = 8;
+  options.level0_file_num_compaction_trigger = 10;
+  options.level0_slowdown_writes_trigger = 10;
+  options.level0_stop_writes_trigger = 10;
+  options.disable_auto_compactions = true;
+
+  std::shared_ptr<TablePropertiesCollectorFactory> collector_factory =
+      std::make_shared<CountingDeleteTabPropCollectorFactory>();
+  options.table_properties_collector_factories.resize(1);
+  options.table_properties_collector_factories[0] = collector_factory;
+
+  DestroyAndReopen(options);
+
+  const int kMaxKey = 100;
+  for (int i = 0; i < kMaxKey; i++) {
+    ASSERT_OK(Put(Key(i), ""));
+  }
+  Flush();
+  dbfull()->TEST_WaitForFlushMemTable();
+
+  for (int i = 1; i < kMaxKey - 1; i++) {
+    Delete(Key(i));
+  }
+  Flush();
+  dbfull()->TEST_WaitForFlushMemTable();
+  ASSERT_EQ(NumTableFilesAtLevel(0), 2);
+
+  // Restart the DB. Although number of files didn't reach
+  // options.level0_file_num_compaction_trigger, compaction should
+  // still be triggered because of the need-compaction hint.
+  options.disable_auto_compactions = false;
+  Reopen(options);
+  dbfull()->TEST_WaitForCompact();
+  ASSERT_EQ(NumTableFilesAtLevel(0), 0);
+  {
+    SetPerfLevel(kEnableCount);
+    perf_context.Reset();
+    int c = 0;
+    std::unique_ptr<Iterator> iter(db_->NewIterator(ReadOptions()));
+    for (iter->Seek(Key(0)); iter->Valid(); iter->Next()) {
+      c++;
+    }
+    ASSERT_EQ(c, 2);
+    ASSERT_EQ(perf_context.internal_delete_skipped_count, 0);
+    // We iterate every key twice. Is it a bug?
+    ASSERT_LE(perf_context.internal_key_skipped_count, 2);
+    SetPerfLevel(kDisable);
+  }
+}
+
+TEST_F(DBTest, SuggestCompactRangeTest) {
+  class CompactionFilterFactoryGetContext : public CompactionFilterFactory {
+   public:
     virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
         const CompactionFilter::Context& context) override {
       saved_context = context;
@@ -8386,10 +8629,12 @@ TEST_F(DBTest, SuggestCompactRangeTest) {
   };
 
   Options options = CurrentOptions();
+  options.memtable_factory.reset(
+      new SpecialSkipListFactory(DBTestBase::kNumKeysByGenerateNewRandomFile));
   options.compaction_style = kCompactionStyleLevel;
   options.compaction_filter_factory.reset(
       new CompactionFilterFactoryGetContext());
-  options.write_buffer_size = 100 << 10;
+  options.write_buffer_size = 200 << 10;
   options.arena_block_size = 4 << 10;
   options.level0_file_num_compaction_trigger = 4;
   options.num_levels = 4;
@@ -8444,10 +8689,12 @@ TEST_F(DBTest, SuggestCompactRangeTest) {
     dbfull()->TEST_WaitForCompact();
   }
 
-  ASSERT_EQ("0,0,13", FilesPerLevel(0));
+  // All files are compacted
+  ASSERT_EQ(0, NumTableFilesAtLevel(0));
+  ASSERT_EQ(0, NumTableFilesAtLevel(1));
 
   GenerateNewRandomFile(&rnd);
-  ASSERT_EQ("1,0,13", FilesPerLevel(0));
+  ASSERT_EQ(1, NumTableFilesAtLevel(0));
 
   // nonoverlapping with the file on level 0
   Slice start("a"), end("b");
@@ -8455,7 +8702,7 @@ TEST_F(DBTest, SuggestCompactRangeTest) {
   dbfull()->TEST_WaitForCompact();
 
   // should not compact the level 0 file
-  ASSERT_EQ("1,0,13", FilesPerLevel(0));
+  ASSERT_EQ(1, NumTableFilesAtLevel(0));
 
   start = Slice("j");
   end = Slice("m");
@@ -8465,7 +8712,8 @@ TEST_F(DBTest, SuggestCompactRangeTest) {
       options.compaction_filter_factory.get()));
 
   // now it should compact the level 0 file
-  ASSERT_EQ("0,1,13", FilesPerLevel(0));
+  ASSERT_EQ(0, NumTableFilesAtLevel(0));
+  ASSERT_EQ(1, NumTableFilesAtLevel(1));
 }
 
 TEST_F(DBTest, PromoteL0) {
@@ -8533,6 +8781,7 @@ TEST_F(DBTest, PromoteL0Failure) {
   status = experimental::PromoteL0(db_, db_->DefaultColumnFamily());
   ASSERT_TRUE(status.IsInvalidArgument());
 }
+#endif  // ROCKSDB_LITE
 
 // Github issue #596
 TEST_F(DBTest, HugeNumberOfLevels) {
@@ -8566,7 +8815,7 @@ TEST_F(DBTest, LargeBatchWithColumnFamilies) {
     for (int pass = 1; pass <= 3; pass++) {
       WriteBatch batch;
       size_t write_size = 1024 * 1024 * (5 + i);
-      fprintf(stderr, "prepare: %ld MB, pass:%d\n", (write_size / 1024 / 1024),
+      fprintf(stderr, "prepare: %" ROCKSDB_PRIszt " MB, pass:%d\n", (write_size / 1024 / 1024),
               pass);
       for (;;) {
         std::string data(3000, j++ % 127 + 20);
@@ -8576,7 +8825,7 @@ TEST_F(DBTest, LargeBatchWithColumnFamilies) {
           break;
         }
       }
-      fprintf(stderr, "write: %ld MB\n", (batch.GetDataSize() / 1024 / 1024));
+      fprintf(stderr, "write: %" ROCKSDB_PRIszt " MB\n", (batch.GetDataSize() / 1024 / 1024));
       ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
       fprintf(stderr, "done\n");
     }
@@ -8678,7 +8927,7 @@ TEST_F(DBTest, DelayedWriteRate) {
     WriteOptions wo;
     Put(Key(i), std::string(entry_size, 'x'), wo);
     estimated_total_size += entry_size + 20;
-    // Ocassionally sleep a while
+    // Occasionally sleep a while
     if (rnd.Uniform(20) == 6) {
       env_->SleepForMicroseconds(2666);
     }
@@ -8739,125 +8988,125 @@ TEST_F(DBTest, HardLimit) {
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, SoftLimit) {
   Options options;
   options.env = env_;
   options = CurrentOptions(options);
   options.write_buffer_size = 100000;  // Small write buffer
   options.max_write_buffer_number = 256;
-  options.level0_file_num_compaction_trigger = 3;
+  options.level0_file_num_compaction_trigger = 1;
   options.level0_slowdown_writes_trigger = 3;
   options.level0_stop_writes_trigger = 999999;
-  options.delayed_write_rate = 200000;  // About 200KB/s limited rate
-  options.soft_rate_limit = 1.1;
+  options.delayed_write_rate = 20000;  // About 200KB/s limited rate
+  options.soft_pending_compaction_bytes_limit = 200000;
   options.target_file_size_base = 99999999;  // All into one file
   options.max_bytes_for_level_base = 50000;
+  options.max_bytes_for_level_multiplier = 10;
+  options.max_background_compactions = 1;
   options.compression = kNoCompression;
 
   Reopen(options);
   Put(Key(0), "");
 
-  // Only allow two compactions
-  port::Mutex mut;
-  port::CondVar cv(&mut);
-  std::atomic<int> compaction_cnt(0);
-  rocksdb::SyncPoint::GetInstance()->SetCallBack(
-      "VersionSet::LogAndApply:WriteManifest", [&](void* arg) {
-        // Three flushes and the first compaction,
-        // three flushes and the second compaction go through.
-        MutexLock l(&mut);
-        while (compaction_cnt.load() >= 8) {
-          cv.Wait();
-        }
-        compaction_cnt.fetch_add(1);
-      });
-
-  std::atomic<int> sleep_count(0);
-  rocksdb::SyncPoint::GetInstance()->SetCallBack(
-      "DBImpl::DelayWrite:Sleep", [&](void* arg) { sleep_count.fetch_add(1); });
-  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
+  test::SleepingBackgroundTask sleeping_task_low;
+  // Block compactions
+  env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task_low,
+                 Env::Priority::LOW);
+  sleeping_task_low.WaitUntilSleeping();
 
+  // Create 3 L0 files, making score of L0 to be 3.
   for (int i = 0; i < 3; i++) {
     Put(Key(i), std::string(5000, 'x'));
     Put(Key(100 - i), std::string(5000, 'x'));
+    // Flush the file. File size is around 30KB.
     Flush();
   }
-  while (compaction_cnt.load() < 4 || NumTableFilesAtLevel(0) > 0) {
-    env_->SleepForMicroseconds(1000);
-  }
+  ASSERT_TRUE(dbfull()->TEST_write_controler().NeedsDelay());
+
+  sleeping_task_low.WakeUp();
+  sleeping_task_low.WaitUntilDone();
+  sleeping_task_low.Reset();
+  dbfull()->TEST_WaitForCompact();
+
   // Now there is one L1 file but doesn't trigger soft_rate_limit
+  // The L1 file size is around 30KB.
   ASSERT_EQ(NumTableFilesAtLevel(1), 1);
-  ASSERT_EQ(sleep_count.load(), 0);
+  ASSERT_TRUE(!dbfull()->TEST_write_controler().NeedsDelay());
+
+  // Only allow one compactin going through.
+  rocksdb::SyncPoint::GetInstance()->SetCallBack(
+      "BackgroundCallCompaction:0", [&](void* arg) {
+        // Schedule a sleeping task.
+        sleeping_task_low.Reset();
+        env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
+                       &sleeping_task_low, Env::Priority::LOW);
+      });
 
+  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
+
+  env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task_low,
+                 Env::Priority::LOW);
+  sleeping_task_low.WaitUntilSleeping();
+  // Create 3 L0 files, making score of L0 to be 3
   for (int i = 0; i < 3; i++) {
     Put(Key(10 + i), std::string(5000, 'x'));
     Put(Key(90 - i), std::string(5000, 'x'));
+    // Flush the file. File size is around 30KB.
     Flush();
   }
-  while (compaction_cnt.load() < 8 || NumTableFilesAtLevel(0) > 0) {
-    env_->SleepForMicroseconds(1000);
-  }
+
+  // Wake up sleep task to enable compaction to run and waits
+  // for it to go to sleep state again to make sure one compaction
+  // goes through.
+  sleeping_task_low.WakeUp();
+  sleeping_task_low.WaitUntilSleeping();
+
+  // Now there is one L1 file (around 60KB) which exceeds 50KB base by 10KB
+  // Given level multiplier 10, estimated pending compaction is around 100KB
+  // doesn't trigger soft_pending_compaction_bytes_limit
   ASSERT_EQ(NumTableFilesAtLevel(1), 1);
-  ASSERT_EQ(sleep_count.load(), 0);
+  ASSERT_TRUE(!dbfull()->TEST_write_controler().NeedsDelay());
 
-  // Slowdown is triggered now
-  for (int i = 0; i < 10; i++) {
-    Put(Key(i), std::string(100, 'x'));
+  // Create 3 L0 files, making score of L0 to be 3, higher than L0.
+  for (int i = 0; i < 3; i++) {
+    Put(Key(20 + i), std::string(5000, 'x'));
+    Put(Key(80 - i), std::string(5000, 'x'));
+    // Flush the file. File size is around 30KB.
+    Flush();
   }
-  ASSERT_GT(sleep_count.load(), 0);
+  // Wake up sleep task to enable compaction to run and waits
+  // for it to go to sleep state again to make sure one compaction
+  // goes through.
+  sleeping_task_low.WakeUp();
+  sleeping_task_low.WaitUntilSleeping();
 
-  {
-    MutexLock l(&mut);
-    compaction_cnt.store(7);
-    cv.SignalAll();
-  }
-  while (NumTableFilesAtLevel(1) > 0) {
-    env_->SleepForMicroseconds(1000);
-  }
+  // Now there is one L1 file (around 90KB) which exceeds 50KB base by 40KB
+  // Given level multiplier 10, estimated pending compaction is around 400KB
+  // triggerring soft_pending_compaction_bytes_limit
+  ASSERT_EQ(NumTableFilesAtLevel(1), 1);
+  ASSERT_TRUE(dbfull()->TEST_write_controler().NeedsDelay());
 
-  // Slowdown is not triggered any more.
-  sleep_count.store(0);
-  // Slowdown is not triggered now
-  for (int i = 0; i < 10; i++) {
-    Put(Key(i), std::string(100, 'x'));
-  }
-  ASSERT_EQ(sleep_count.load(), 0);
+  sleeping_task_low.WakeUp();
+  sleeping_task_low.WaitUntilSleeping();
+
+  ASSERT_TRUE(!dbfull()->TEST_write_controler().NeedsDelay());
 
   // shrink level base so L2 will hit soft limit easier.
   ASSERT_OK(dbfull()->SetOptions({
       {"max_bytes_for_level_base", "5000"},
   }));
-  compaction_cnt.store(7);
-  Flush();
-
-  while (NumTableFilesAtLevel(0) == 0) {
-    env_->SleepForMicroseconds(1000);
-  }
-
-  // Slowdown is triggered now
-  for (int i = 0; i < 10; i++) {
-    Put(Key(i), std::string(100, 'x'));
-  }
-  ASSERT_GT(sleep_count.load(), 0);
 
-  {
-    MutexLock l(&mut);
-    compaction_cnt.store(7);
-    cv.SignalAll();
-  }
-
-  while (NumTableFilesAtLevel(2) != 0) {
-    env_->SleepForMicroseconds(1000);
-  }
+  Put("", "");
+  Flush();
+  ASSERT_TRUE(dbfull()->TEST_write_controler().NeedsDelay());
 
-  // Slowdown is not triggered anymore
-  sleep_count.store(0);
-  for (int i = 0; i < 10; i++) {
-    Put(Key(i), std::string(100, 'x'));
-  }
-  ASSERT_EQ(sleep_count.load(), 0);
+  sleeping_task_low.WaitUntilSleeping();
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
+  sleeping_task_low.WakeUp();
+  sleeping_task_low.WaitUntilDone();
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, FailWhenCompressionNotSupportedTest) {
   CompressionType compressions[] = {kZlibCompression, kBZip2Compression,
@@ -8879,6 +9128,7 @@ TEST_F(DBTest, FailWhenCompressionNotSupportedTest) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, RowCache) {
   Options options = CurrentOptions();
   options.statistics = rocksdb::CreateDBStatistics();
@@ -8897,6 +9147,7 @@ TEST_F(DBTest, RowCache) {
   ASSERT_EQ(TestGetTickerCount(options, ROW_CACHE_HIT), 1);
   ASSERT_EQ(TestGetTickerCount(options, ROW_CACHE_MISS), 1);
 }
+#endif  // ROCKSDB_LITE
 
 // TODO(3.13): fix the issue of Seek() + Prev() which might not necessary
 //             return the biggest key which is smaller than the seek key.
@@ -8957,6 +9208,7 @@ TEST_F(DBTest, DeletingOldWalAfterDrop) {
   EXPECT_GT(lognum2, lognum1);
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, RateLimitedDelete) {
   rocksdb::SyncPoint::GetInstance()->LoadDependency({
       {"DBTest::RateLimitedDelete:1",
@@ -9111,7 +9363,7 @@ TEST_F(DBTest, DestroyDBWithRateLimitedDelete) {
   // We created 4 sst files in L0
   ASSERT_EQ("4", FilesPerLevel(0));
 
-  // Close DB and destory it using DeleteScheduler
+  // Close DB and destroy it using DeleteScheduler
   Close();
   std::string trash_dir = test::TmpDir(env_) + "/trash";
   int64_t rate_bytes_per_sec = 1024 * 1024;  // 1 Mb / Sec
@@ -9125,6 +9377,7 @@ TEST_F(DBTest, DestroyDBWithRateLimitedDelete) {
   // We have deleted the 4 sst files in the delete_scheduler
   ASSERT_EQ(bg_delete_file, 4);
 }
+#endif  // ROCKSDB_LITE
 
 TEST_F(DBTest, UnsupportedManualSync) {
   DestroyAndReopen(CurrentOptions());
@@ -9133,6 +9386,7 @@ TEST_F(DBTest, UnsupportedManualSync) {
   ASSERT_TRUE(s.IsNotSupported());
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(DBTest, OpenDBWithInfiniteMaxOpenFiles) {
   // Open DB with infinite max open files
   //  - First iteration use 1 thread to open files
@@ -9463,9 +9717,15 @@ TEST_F(DBTest, AddExternalSstFile) {
       ASSERT_EQ(Get(Key(k)), Key(k) + "_val");
     }
 
-    // Add file using file info
-    s = db_->AddFile(&file2_info);
-    ASSERT_TRUE(s.ok()) << s.ToString();
+    // Add file while holding a snapshot will fail
+    const Snapshot* s1 = db_->GetSnapshot();
+    if (s1 != nullptr) {
+      ASSERT_NOK(db_->AddFile(&file2_info));
+      db_->ReleaseSnapshot(s1);
+    }
+    // We can add the file after releaseing the snapshot
+    ASSERT_OK(db_->AddFile(&file2_info));
+
     ASSERT_EQ(db_->GetLatestSequenceNumber(), 0U);
     for (int k = 0; k < 200; k++) {
       ASSERT_EQ(Get(Key(k)), Key(k) + "_val");
@@ -9485,9 +9745,8 @@ TEST_F(DBTest, AddExternalSstFile) {
     }
     ASSERT_NE(db_->GetLatestSequenceNumber(), 0U);
 
-    // DB have values in memtable now, we cannot add files anymore
-    s = db_->AddFile(file5);
-    ASSERT_FALSE(s.ok()) << s.ToString();
+    // Key range of file5 (400 => 499) dont overlap with any keys in DB
+    ASSERT_OK(db_->AddFile(file5));
 
     // Make sure values are correct before and after flush/compaction
     for (int i = 0; i < 2; i++) {
@@ -9498,13 +9757,37 @@ TEST_F(DBTest, AddExternalSstFile) {
         }
         ASSERT_EQ(Get(Key(k)), value);
       }
+      for (int k = 400; k < 500; k++) {
+        std::string value = Key(k) + "_val";
+        ASSERT_EQ(Get(Key(k)), value);
+      }
       ASSERT_OK(Flush());
       ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
     }
 
-    // DB sequence number is not zero, cannot add files anymore
-    s = db_->AddFile(file5);
-    ASSERT_FALSE(s.ok()) << s.ToString();
+    Close();
+    options.disable_auto_compactions = true;
+    Reopen(options);
+
+    // Delete keys in range (400 => 499)
+    for (int k = 400; k < 500; k++) {
+      ASSERT_OK(Delete(Key(k)));
+    }
+    // We deleted range (400 => 499) but cannot add file5 because
+    // of the range tombstones
+    ASSERT_NOK(db_->AddFile(file5));
+
+    // Compacting the DB will remove the tombstones
+    ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
+
+    // Now we can add the file
+    ASSERT_OK(db_->AddFile(file5));
+
+    // Verify values of file5 in DB
+    for (int k = 400; k < 500; k++) {
+      std::string value = Key(k) + "_val";
+      ASSERT_EQ(Get(Key(k)), value);
+    }
   } while (ChangeOptions(kSkipPlainTable | kSkipUniversalCompaction |
                          kSkipFIFOCompaction));
 }
@@ -9678,6 +9961,108 @@ TEST_F(DBTest, AddExternalSstFileMultiThreaded) {
                          kSkipFIFOCompaction));
 }
 
+TEST_F(DBTest, AddExternalSstFileOverlappingRanges) {
+  std::string sst_files_folder = test::TmpDir(env_) + "/sst_files/";
+  Random rnd(301);
+  do {
+    env_->CreateDir(sst_files_folder);
+    Options options = CurrentOptions();
+    DestroyAndReopen(options);
+    const ImmutableCFOptions ioptions(options);
+    SstFileWriter sst_file_writer(EnvOptions(), ioptions, options.comparator);
+
+    printf("Option config = %d\n", option_config_);
+    std::vector<std::pair<int, int>> key_ranges;
+    for (int i = 0; i < 500; i++) {
+      int range_start = rnd.Uniform(20000);
+      int keys_per_range = 10 + rnd.Uniform(41);
+
+      key_ranges.emplace_back(range_start, range_start + keys_per_range);
+    }
+
+    int memtable_add = 0;
+    int success_add_file = 0;
+    int failed_add_file = 0;
+    std::map<std::string, std::string> true_data;
+    for (size_t i = 0; i < key_ranges.size(); i++) {
+      int range_start = key_ranges[i].first;
+      int range_end = key_ranges[i].second;
+
+      Status s;
+      std::string range_val = "range_" + ToString(i);
+
+      // For 20% of ranges we use DB::Put, for 80% we use DB::AddFile
+      if (i && i % 5 == 0) {
+        // Use DB::Put to insert range (insert into memtable)
+        range_val += "_put";
+        for (int k = range_start; k <= range_end; k++) {
+          s = Put(Key(k), range_val);
+          ASSERT_OK(s);
+        }
+        memtable_add++;
+      } else {
+        // Use DB::AddFile to insert range
+        range_val += "_add_file";
+
+        // Generate the file containing the range
+        std::string file_name = sst_files_folder + env_->GenerateUniqueId();
+        ASSERT_OK(sst_file_writer.Open(file_name));
+        for (int k = range_start; k <= range_end; k++) {
+          s = sst_file_writer.Add(Key(k), range_val);
+          ASSERT_OK(s);
+        }
+        ExternalSstFileInfo file_info;
+        s = sst_file_writer.Finish(&file_info);
+        ASSERT_OK(s);
+
+        // Insert the generated file
+        s = db_->AddFile(&file_info);
+
+        auto it = true_data.lower_bound(Key(range_start));
+        if (it != true_data.end() && it->first <= Key(range_end)) {
+          // This range overlap with data already exist in DB
+          ASSERT_NOK(s);
+          failed_add_file++;
+        } else {
+          ASSERT_OK(s);
+          success_add_file++;
+        }
+      }
+
+      if (s.ok()) {
+        // Update true_data map to include the new inserted data
+        for (int k = range_start; k <= range_end; k++) {
+          true_data[Key(k)] = range_val;
+        }
+      }
+
+      // Flush / Compact the DB
+      if (i && i % 50 == 0) {
+        Flush();
+      }
+      if (i && i % 75 == 0) {
+        db_->CompactRange(CompactRangeOptions(), nullptr, nullptr);
+      }
+    }
+
+    printf(
+        "Total: %zu ranges\n"
+        "AddFile()|Success: %d ranges\n"
+        "AddFile()|RangeConflict: %d ranges\n"
+        "Put(): %d ranges\n",
+        key_ranges.size(), success_add_file, failed_add_file, memtable_add);
+
+    // Verify the correctness of the data
+    for (const auto& kv : true_data) {
+      ASSERT_EQ(Get(kv.first), kv.second);
+    }
+    printf("keys/values verified\n");
+  } while (ChangeOptions(kSkipPlainTable | kSkipUniversalCompaction |
+                         kSkipFIFOCompaction));
+}
+
+#endif  // ROCKSDB_LITE
+
 // 1 Create some SST files by inserting K-V pairs into DB
 // 2 Close DB and change suffix from ".sst" to ".ldb" for every other SST file
 // 3 Open DB and check if all key can be read
@@ -9749,6 +10134,445 @@ TEST_F(DBTest, PauseBackgroundWorkTest) {
   ASSERT_EQ(true, done.load());
 }
 
+#ifndef ROCKSDB_LITE
+namespace {
+void ValidateKeyExistence(DB* db, const std::vector<Slice>& keys_must_exist,
+                          const std::vector<Slice>& keys_must_not_exist) {
+  // Ensure that expected keys exist
+  std::vector<std::string> values;
+  if (keys_must_exist.size() > 0) {
+    std::vector<Status> status_list =
+        db->MultiGet(ReadOptions(), keys_must_exist, &values);
+    for (size_t i = 0; i < keys_must_exist.size(); i++) {
+      ASSERT_OK(status_list[i]);
+    }
+  }
+
+  // Ensure that given keys don't exist
+  if (keys_must_not_exist.size() > 0) {
+    std::vector<Status> status_list =
+        db->MultiGet(ReadOptions(), keys_must_not_exist, &values);
+    for (size_t i = 0; i < keys_must_not_exist.size(); i++) {
+      ASSERT_TRUE(status_list[i].IsNotFound());
+    }
+  }
+}
+
+}  // namespace
+
+TEST_F(DBTest, WalFilterTest) {
+  class TestWalFilter : public WalFilter {
+   private:
+    // Processing option that is requested to be applied at the given index
+    WalFilter::WalProcessingOption wal_processing_option_;
+    // Index at which to apply wal_processing_option_
+    // At other indexes default wal_processing_option::kContinueProcessing is
+    // returned.
+    size_t apply_option_at_record_index_;
+    // Current record index, incremented with each record encountered.
+    size_t current_record_index_;
+
+   public:
+    TestWalFilter(WalFilter::WalProcessingOption wal_processing_option,
+                  size_t apply_option_for_record_index)
+        : wal_processing_option_(wal_processing_option),
+          apply_option_at_record_index_(apply_option_for_record_index),
+          current_record_index_(0) {}
+
+    virtual WalProcessingOption LogRecord(const WriteBatch& batch,
+                                          WriteBatch* new_batch,
+                                          bool* batch_changed) const override {
+      WalFilter::WalProcessingOption option_to_return;
+
+      if (current_record_index_ == apply_option_at_record_index_) {
+        option_to_return = wal_processing_option_;
+      } else {
+        option_to_return = WalProcessingOption::kContinueProcessing;
+      }
+
+      // Filter is passed as a const object for RocksDB to not modify the
+      // object, however we modify it for our own purpose here and hence
+      // cast the constness away.
+      (const_cast<TestWalFilter*>(this)->current_record_index_)++;
+
+      return option_to_return;
+    }
+
+    virtual const char* Name() const override { return "TestWalFilter"; }
+  };
+
+  // Create 3 batches with two keys each
+  std::vector<std::vector<std::string>> batch_keys(3);
+
+  batch_keys[0].push_back("key1");
+  batch_keys[0].push_back("key2");
+  batch_keys[1].push_back("key3");
+  batch_keys[1].push_back("key4");
+  batch_keys[2].push_back("key5");
+  batch_keys[2].push_back("key6");
+
+  // Test with all WAL processing options
+  for (int option = 0;
+       option < static_cast<int>(
+                    WalFilter::WalProcessingOption::kWalProcessingOptionMax);
+       option++) {
+    Options options = OptionsForLogIterTest();
+    DestroyAndReopen(options);
+    CreateAndReopenWithCF({"pikachu"}, options);
+
+    // Write given keys in given batches
+    for (size_t i = 0; i < batch_keys.size(); i++) {
+      WriteBatch batch;
+      for (size_t j = 0; j < batch_keys[i].size(); j++) {
+        batch.Put(handles_[0], batch_keys[i][j], DummyString(1024));
+      }
+      dbfull()->Write(WriteOptions(), &batch);
+    }
+
+    WalFilter::WalProcessingOption wal_processing_option =
+        static_cast<WalFilter::WalProcessingOption>(option);
+
+    // Create a test filter that would apply wal_processing_option at the first
+    // record
+    size_t apply_option_for_record_index = 1;
+    TestWalFilter test_wal_filter(wal_processing_option,
+                                  apply_option_for_record_index);
+
+    // Reopen database with option to use WAL filter
+    options = OptionsForLogIterTest();
+    options.wal_filter = &test_wal_filter;
+    Status status =
+        TryReopenWithColumnFamilies({"default", "pikachu"}, options);
+    if (wal_processing_option ==
+        WalFilter::WalProcessingOption::kCorruptedRecord) {
+      assert(!status.ok());
+      // In case of corruption we can turn off paranoid_checks to reopen
+      // databse
+      options.paranoid_checks = false;
+      ReopenWithColumnFamilies({"default", "pikachu"}, options);
+    } else {
+      assert(status.ok());
+    }
+
+    // Compute which keys we expect to be found
+    // and which we expect not to be found after recovery.
+    std::vector<Slice> keys_must_exist;
+    std::vector<Slice> keys_must_not_exist;
+    switch (wal_processing_option) {
+      case WalFilter::WalProcessingOption::kCorruptedRecord:
+      case WalFilter::WalProcessingOption::kContinueProcessing: {
+        fprintf(stderr, "Testing with complete WAL processing\n");
+        // we expect all records to be processed
+        for (size_t i = 0; i < batch_keys.size(); i++) {
+          for (size_t j = 0; j < batch_keys[i].size(); j++) {
+            keys_must_exist.push_back(Slice(batch_keys[i][j]));
+          }
+        }
+        break;
+      }
+      case WalFilter::WalProcessingOption::kIgnoreCurrentRecord: {
+        fprintf(stderr,
+                "Testing with ignoring record %" ROCKSDB_PRIszt " only\n",
+                apply_option_for_record_index);
+        // We expect the record with apply_option_for_record_index to be not
+        // found.
+        for (size_t i = 0; i < batch_keys.size(); i++) {
+          for (size_t j = 0; j < batch_keys[i].size(); j++) {
+            if (i == apply_option_for_record_index) {
+              keys_must_not_exist.push_back(Slice(batch_keys[i][j]));
+            } else {
+              keys_must_exist.push_back(Slice(batch_keys[i][j]));
+            }
+          }
+        }
+        break;
+      }
+      case WalFilter::WalProcessingOption::kStopReplay: {
+        fprintf(stderr,
+                "Testing with stopping replay from record %" ROCKSDB_PRIszt
+                "\n",
+                apply_option_for_record_index);
+        // We expect records beyond apply_option_for_record_index to be not
+        // found.
+        for (size_t i = 0; i < batch_keys.size(); i++) {
+          for (size_t j = 0; j < batch_keys[i].size(); j++) {
+            if (i >= apply_option_for_record_index) {
+              keys_must_not_exist.push_back(Slice(batch_keys[i][j]));
+            } else {
+              keys_must_exist.push_back(Slice(batch_keys[i][j]));
+            }
+          }
+        }
+        break;
+      }
+      default:
+        assert(false);  // unhandled case
+    }
+
+    bool checked_after_reopen = false;
+
+    while (true) {
+      // Ensure that expected keys exists
+      // and not expected keys don't exist after recovery
+      ValidateKeyExistence(db_, keys_must_exist, keys_must_not_exist);
+
+      if (checked_after_reopen) {
+        break;
+      }
+
+      // reopen database again to make sure previous log(s) are not used
+      //(even if they were skipped)
+      // reopn database with option to use WAL filter
+      options = OptionsForLogIterTest();
+      ReopenWithColumnFamilies({"default", "pikachu"}, options);
+
+      checked_after_reopen = true;
+    }
+  }
+}
+
+TEST_F(DBTest, WalFilterTestWithChangeBatch) {
+  class ChangeBatchHandler : public WriteBatch::Handler {
+   private:
+    // Batch to insert keys in
+    WriteBatch* new_write_batch_;
+    // Number of keys to add in the new batch
+    size_t num_keys_to_add_in_new_batch_;
+    // Number of keys added to new batch
+    size_t num_keys_added_;
+
+   public:
+    ChangeBatchHandler(WriteBatch* new_write_batch,
+                       size_t num_keys_to_add_in_new_batch)
+        : new_write_batch_(new_write_batch),
+          num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch),
+          num_keys_added_(0) {}
+    virtual void Put(const Slice& key, const Slice& value) override {
+      if (num_keys_added_ < num_keys_to_add_in_new_batch_) {
+        new_write_batch_->Put(key, value);
+        ++num_keys_added_;
+      }
+    }
+  };
+
+  class TestWalFilterWithChangeBatch : public WalFilter {
+   private:
+    // Index at which to start changing records
+    size_t change_records_from_index_;
+    // Number of keys to add in the new batch
+    size_t num_keys_to_add_in_new_batch_;
+    // Current record index, incremented with each record encountered.
+    size_t current_record_index_;
+
+   public:
+    TestWalFilterWithChangeBatch(size_t change_records_from_index,
+                                 size_t num_keys_to_add_in_new_batch)
+        : change_records_from_index_(change_records_from_index),
+          num_keys_to_add_in_new_batch_(num_keys_to_add_in_new_batch),
+          current_record_index_(0) {}
+
+    virtual WalProcessingOption LogRecord(const WriteBatch& batch,
+                                          WriteBatch* new_batch,
+                                          bool* batch_changed) const override {
+      if (current_record_index_ >= change_records_from_index_) {
+        ChangeBatchHandler handler(new_batch, num_keys_to_add_in_new_batch_);
+        batch.Iterate(&handler);
+        *batch_changed = true;
+      }
+
+      // Filter is passed as a const object for RocksDB to not modify the
+      // object, however we modify it for our own purpose here and hence
+      // cast the constness away.
+      (const_cast<TestWalFilterWithChangeBatch*>(this)
+           ->current_record_index_)++;
+
+      return WalProcessingOption::kContinueProcessing;
+    }
+
+    virtual const char* Name() const override {
+      return "TestWalFilterWithChangeBatch";
+    }
+  };
+
+  std::vector<std::vector<std::string>> batch_keys(3);
+
+  batch_keys[0].push_back("key1");
+  batch_keys[0].push_back("key2");
+  batch_keys[1].push_back("key3");
+  batch_keys[1].push_back("key4");
+  batch_keys[2].push_back("key5");
+  batch_keys[2].push_back("key6");
+
+  Options options = OptionsForLogIterTest();
+  DestroyAndReopen(options);
+  CreateAndReopenWithCF({"pikachu"}, options);
+
+  // Write given keys in given batches
+  for (size_t i = 0; i < batch_keys.size(); i++) {
+    WriteBatch batch;
+    for (size_t j = 0; j < batch_keys[i].size(); j++) {
+      batch.Put(handles_[0], batch_keys[i][j], DummyString(1024));
+    }
+    dbfull()->Write(WriteOptions(), &batch);
+  }
+
+  // Create a test filter that would apply wal_processing_option at the first
+  // record
+  size_t change_records_from_index = 1;
+  size_t num_keys_to_add_in_new_batch = 1;
+  TestWalFilterWithChangeBatch test_wal_filter_with_change_batch(
+      change_records_from_index, num_keys_to_add_in_new_batch);
+
+  // Reopen database with option to use WAL filter
+  options = OptionsForLogIterTest();
+  options.wal_filter = &test_wal_filter_with_change_batch;
+  ReopenWithColumnFamilies({"default", "pikachu"}, options);
+
+  // Ensure that all keys exist before change_records_from_index_
+  // And after that index only single key exists
+  // as our filter adds only single key for each batch
+  std::vector<Slice> keys_must_exist;
+  std::vector<Slice> keys_must_not_exist;
+
+  for (size_t i = 0; i < batch_keys.size(); i++) {
+    for (size_t j = 0; j < batch_keys[i].size(); j++) {
+      if (i >= change_records_from_index && j >= num_keys_to_add_in_new_batch) {
+        keys_must_not_exist.push_back(Slice(batch_keys[i][j]));
+      } else {
+        keys_must_exist.push_back(Slice(batch_keys[i][j]));
+      }
+    }
+  }
+
+  bool checked_after_reopen = false;
+
+  while (true) {
+    // Ensure that expected keys exists
+    // and not expected keys don't exist after recovery
+    ValidateKeyExistence(db_, keys_must_exist, keys_must_not_exist);
+
+    if (checked_after_reopen) {
+      break;
+    }
+
+    // reopen database again to make sure previous log(s) are not used
+    //(even if they were skipped)
+    // reopn database with option to use WAL filter
+    options = OptionsForLogIterTest();
+    ReopenWithColumnFamilies({"default", "pikachu"}, options);
+
+    checked_after_reopen = true;
+  }
+}
+
+TEST_F(DBTest, WalFilterTestWithChangeBatchExtraKeys) {
+  class TestWalFilterWithChangeBatchAddExtraKeys : public WalFilter {
+   public:
+    virtual WalProcessingOption LogRecord(const WriteBatch& batch,
+                                          WriteBatch* new_batch,
+                                          bool* batch_changed) const override {
+      *new_batch = batch;
+      new_batch->Put("key_extra", "value_extra");
+      *batch_changed = true;
+      return WalProcessingOption::kContinueProcessing;
+    }
+
+    virtual const char* Name() const override {
+      return "WalFilterTestWithChangeBatchExtraKeys";
+    }
+  };
+
+  std::vector<std::vector<std::string>> batch_keys(3);
+
+  batch_keys[0].push_back("key1");
+  batch_keys[0].push_back("key2");
+  batch_keys[1].push_back("key3");
+  batch_keys[1].push_back("key4");
+  batch_keys[2].push_back("key5");
+  batch_keys[2].push_back("key6");
+
+  Options options = OptionsForLogIterTest();
+  DestroyAndReopen(options);
+  CreateAndReopenWithCF({"pikachu"}, options);
+
+  // Write given keys in given batches
+  for (size_t i = 0; i < batch_keys.size(); i++) {
+    WriteBatch batch;
+    for (size_t j = 0; j < batch_keys[i].size(); j++) {
+      batch.Put(handles_[0], batch_keys[i][j], DummyString(1024));
+    }
+    dbfull()->Write(WriteOptions(), &batch);
+  }
+
+  // Create a test filter that would add extra keys
+  TestWalFilterWithChangeBatchAddExtraKeys test_wal_filter_extra_keys;
+
+  // Reopen database with option to use WAL filter
+  options = OptionsForLogIterTest();
+  options.wal_filter = &test_wal_filter_extra_keys;
+  Status status = TryReopenWithColumnFamilies({"default", "pikachu"}, options);
+  ASSERT_TRUE(status.IsNotSupported());
+
+  // Reopen without filter, now reopen should succeed - previous
+  // attempt to open must not have altered the db.
+  options = OptionsForLogIterTest();
+  ReopenWithColumnFamilies({"default", "pikachu"}, options);
+
+  std::vector<Slice> keys_must_exist;
+  std::vector<Slice> keys_must_not_exist;  // empty vector
+
+  for (size_t i = 0; i < batch_keys.size(); i++) {
+    for (size_t j = 0; j < batch_keys[i].size(); j++) {
+      keys_must_exist.push_back(Slice(batch_keys[i][j]));
+    }
+  }
+
+  ValidateKeyExistence(db_, keys_must_exist, keys_must_not_exist);
+}
+
+#endif  // ROCKSDB_LITE
+
+#ifndef ROCKSDB_LITE
+class BloomStatsTestWithParam
+    : public DBTest,
+      public testing::WithParamInterface<std::tuple<bool, bool>> {
+ public:
+  BloomStatsTestWithParam() {
+    use_block_table_ = std::get<0>(GetParam());
+    use_block_based_builder_ = std::get<1>(GetParam());
+
+    options_.create_if_missing = true;
+    options_.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(4));
+    options_.memtable_prefix_bloom_bits = 8 * 1024;
+    if (use_block_table_) {
+      BlockBasedTableOptions table_options;
+      table_options.hash_index_allow_collision = false;
+      table_options.filter_policy.reset(
+          NewBloomFilterPolicy(10, use_block_based_builder_));
+      options_.table_factory.reset(NewBlockBasedTableFactory(table_options));
+    } else {
+      PlainTableOptions table_options;
+      options_.table_factory.reset(NewPlainTableFactory(table_options));
+    }
+
+    perf_context.Reset();
+    DestroyAndReopen(options_);
+  }
+
+  ~BloomStatsTestWithParam() {
+    perf_context.Reset();
+    Destroy(options_);
+  }
+
+  // Required if inheriting from testing::WithParamInterface<>
+  static void SetUpTestCase() {}
+  static void TearDownTestCase() {}
+
+  bool use_block_table_;
+  bool use_block_based_builder_;
+  Options options_;
+};
+
 // 1 Insert 2 K-V pairs into DB
 // 2 Call Get() for both keys - expext memtable bloom hit stat to be 2
 // 3 Call Get() for nonexisting key - expect memtable bloom miss stat to be 1
@@ -9838,7 +10662,7 @@ TEST_P(BloomStatsTestWithParam, BloomStatsTestWithIter) {
 
   iter.reset(dbfull()->NewIterator(ReadOptions()));
 
-  // check SST bloom stats
+  // Check SST bloom stats
   iter->Seek(key1);
   ASSERT_OK(iter->status());
   ASSERT_TRUE(iter->Valid());
@@ -9862,16 +10686,12 @@ INSTANTIATE_TEST_CASE_P(BloomStatsTestWithParam, BloomStatsTestWithParam,
                         ::testing::Values(std::make_tuple(true, true),
                                           std::make_tuple(true, false),
                                           std::make_tuple(false, false)));
+#endif  // ROCKSDB_LITE
 }  // namespace rocksdb
 
-#endif
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
 }
diff --git a/src/rocksdb/util/db_test_util.cc b/src/rocksdb/db/db_test_util.cc
similarity index 86%
rename from src/rocksdb/util/db_test_util.cc
rename to src/rocksdb/db/db_test_util.cc
index 6b494ea..0d342cc 100644
--- a/src/rocksdb/util/db_test_util.cc
+++ b/src/rocksdb/db/db_test_util.cc
@@ -7,7 +7,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#include "util/db_test_util.h"
+#include "db/db_test_util.h"
 
 namespace rocksdb {
 
@@ -18,6 +18,7 @@ SpecialEnv::SpecialEnv(Env* base)
       rnd_(301),
       sleep_counter_(this),
       addon_time_(0),
+      time_elapse_only_sleep_(false),
       no_sleep_(false) {
   delay_sstable_sync_.store(false, std::memory_order_release);
   drop_writes_.store(false, std::memory_order_release);
@@ -38,11 +39,10 @@ SpecialEnv::SpecialEnv(Env* base)
   table_write_callback_ = nullptr;
 }
 
-
-DBTestBase::DBTestBase(const std::string path) : option_config_(kDefault),
-           mem_env_(!getenv("MEM_ENV") ? nullptr :
-                                         new MockEnv(Env::Default())),
-           env_(new SpecialEnv(mem_env_ ? mem_env_ : Env::Default())) {
+DBTestBase::DBTestBase(const std::string path)
+    : option_config_(kDefault),
+      mem_env_(!getenv("MEM_ENV") ? nullptr : new MockEnv(Env::Default())),
+      env_(new SpecialEnv(mem_env_ ? mem_env_ : Env::Default())) {
   env_->SetBackgroundThreads(1, Env::LOW);
   env_->SetBackgroundThreads(1, Env::HIGH);
   dbname_ = test::TmpDir(env_) + path;
@@ -56,15 +56,13 @@ DBTestBase::DBTestBase(const std::string path) : option_config_(kDefault),
   EXPECT_OK(DestroyDB(dbname_, options));
   db_ = nullptr;
   Reopen(options);
+  Random::GetTLSInstance()->Reset(0xdeadbeef);
 }
 
 DBTestBase::~DBTestBase() {
-// SyncPoint is not supported in Released Windows Mode.
-#if !(defined NDEBUG) || !defined(OS_WIN)
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
   rocksdb::SyncPoint::GetInstance()->LoadDependency({});
   rocksdb::SyncPoint::GetInstance()->ClearAllCallBacks();
-#endif  // !(defined NDEBUG) || !defined(OS_WIN)
   Close();
   Options options;
   options.db_paths.emplace_back(dbname_, 0);
@@ -79,6 +77,23 @@ DBTestBase::~DBTestBase() {
 // test.  Return false if there are no more configurations to test.
 bool DBTestBase::ChangeOptions(int skip_mask) {
   for (option_config_++; option_config_ < kEnd; option_config_++) {
+#ifdef ROCKSDB_LITE
+    // These options are not supported in ROCKSDB_LITE
+    if (option_config_ == kHashSkipList ||
+        option_config_ == kPlainTableFirstBytePrefix ||
+        option_config_ == kPlainTableCappedPrefix ||
+        option_config_ == kPlainTableCappedPrefixNonMmap ||
+        option_config_ == kPlainTableAllBytesPrefix ||
+        option_config_ == kVectorRep || option_config_ == kHashLinkList ||
+        option_config_ == kHashCuckoo ||
+        option_config_ == kUniversalCompaction ||
+        option_config_ == kUniversalCompactionMultiLevel ||
+        option_config_ == kUniversalSubcompactions ||
+        option_config_ == kFIFOCompaction) {
+      continue;
+    }
+#endif
+
     if ((skip_mask & kSkipDeletesFilterFirst) &&
         option_config_ == kDeletesFilterFirst) {
       continue;
@@ -92,8 +107,7 @@ bool DBTestBase::ChangeOptions(int skip_mask) {
       continue;
     }
     if ((skip_mask & kSkipNoSeekToLast) &&
-        (option_config_ == kHashLinkList ||
-         option_config_ == kHashSkipList)) {;
+        (option_config_ == kHashLinkList || option_config_ == kHashSkipList)) {
       continue;
     }
     if ((skip_mask & kSkipPlainTable) &&
@@ -115,8 +129,7 @@ bool DBTestBase::ChangeOptions(int skip_mask) {
         option_config_ == kFIFOCompaction) {
       continue;
     }
-    if ((skip_mask & kSkipMmapReads) &&
-        option_config_ == kWalDirAndMmapReads) {
+    if ((skip_mask & kSkipMmapReads) && option_config_ == kWalDirAndMmapReads) {
       continue;
     }
     break;
@@ -205,10 +218,10 @@ Options DBTestBase::CurrentOptions(
   BlockBasedTableOptions table_options;
   bool set_block_based_table_factory = true;
   switch (option_config_) {
+#ifndef ROCKSDB_LITE
     case kHashSkipList:
       options.prefix_extractor.reset(NewFixedPrefixTransform(1));
-      options.memtable_factory.reset(
-          NewHashSkipListRepFactory(16));
+      options.memtable_factory.reset(NewHashSkipListRepFactory(16));
       break;
     case kPlainTableFirstBytePrefix:
       options.table_factory.reset(new PlainTableFactory());
@@ -238,6 +251,19 @@ Options DBTestBase::CurrentOptions(
       options.max_sequential_skip_in_iterations = 999999;
       set_block_based_table_factory = false;
       break;
+    case kVectorRep:
+      options.memtable_factory.reset(new VectorRepFactory(100));
+      break;
+    case kHashLinkList:
+      options.prefix_extractor.reset(NewFixedPrefixTransform(1));
+      options.memtable_factory.reset(
+          NewHashLinkListRepFactory(4, 0, 3, true, 4));
+      break;
+    case kHashCuckoo:
+      options.memtable_factory.reset(
+          NewHashCuckooRepFactory(options.write_buffer_size));
+      break;
+#endif  // ROCKSDB_LITE
     case kMergePut:
       options.merge_operator = MergeOperators::CreatePutOperator();
       break;
@@ -274,18 +300,6 @@ Options DBTestBase::CurrentOptions(
     case kDeletesFilterFirst:
       options.filter_deletes = true;
       break;
-    case kVectorRep:
-      options.memtable_factory.reset(new VectorRepFactory(100));
-      break;
-    case kHashLinkList:
-      options.prefix_extractor.reset(NewFixedPrefixTransform(1));
-      options.memtable_factory.reset(
-          NewHashLinkListRepFactory(4, 0, 3, true, 4));
-      break;
-    case kHashCuckoo:
-      options.memtable_factory.reset(
-          NewHashCuckooRepFactory(options.write_buffer_size));
-      break;
     case kUniversalCompaction:
       options.compaction_style = kCompactionStyleUniversal;
       options.num_levels = 1;
@@ -296,7 +310,7 @@ Options DBTestBase::CurrentOptions(
       break;
     case kCompressedBlockCache:
       options.allow_mmap_writes = true;
-      table_options.block_cache_compressed = NewLRUCache(8*1024*1024);
+      table_options.block_cache_compressed = NewLRUCache(8 * 1024 * 1024);
       break;
     case kInfiniteMaxOpenFiles:
       options.max_open_files = -1;
@@ -328,6 +342,10 @@ Options DBTestBase::CurrentOptions(
       options.row_cache = NewLRUCache(1024 * 1024);
       break;
     }
+    case kRecycleLogFiles: {
+      options.recycle_log_file_num = 2;
+      break;
+    }
     case kLevelSubcompactions: {
       options.max_subcompactions = 4;
       break;
@@ -351,11 +369,12 @@ Options DBTestBase::CurrentOptions(
   }
   options.env = env_;
   options.create_if_missing = true;
+  options.fail_if_options_file_error = true;
   return options;
 }
 
 void DBTestBase::CreateColumnFamilies(const std::vector<std::string>& cfs,
-                          const Options& options) {
+                                      const Options& options) {
   ColumnFamilyOptions cf_opts(options);
   size_t cfi = handles_.size();
   handles_.resize(cfi + cfs.size());
@@ -365,7 +384,7 @@ void DBTestBase::CreateColumnFamilies(const std::vector<std::string>& cfs,
 }
 
 void DBTestBase::CreateAndReopenWithCF(const std::vector<std::string>& cfs,
-                           const Options& options) {
+                                       const Options& options) {
   CreateColumnFamilies(cfs, options);
   std::vector<std::string> cfs_plus_default = cfs;
   cfs_plus_default.insert(cfs_plus_default.begin(), kDefaultColumnFamilyName);
@@ -373,18 +392,17 @@ void DBTestBase::CreateAndReopenWithCF(const std::vector<std::string>& cfs,
 }
 
 void DBTestBase::ReopenWithColumnFamilies(const std::vector<std::string>& cfs,
-                              const std::vector<Options>& options) {
+                                          const std::vector<Options>& options) {
   ASSERT_OK(TryReopenWithColumnFamilies(cfs, options));
 }
 
 void DBTestBase::ReopenWithColumnFamilies(const std::vector<std::string>& cfs,
-                              const Options& options) {
+                                          const Options& options) {
   ASSERT_OK(TryReopenWithColumnFamilies(cfs, options));
 }
 
 Status DBTestBase::TryReopenWithColumnFamilies(
-    const std::vector<std::string>& cfs,
-    const std::vector<Options>& options) {
+    const std::vector<std::string>& cfs, const std::vector<Options>& options) {
   Close();
   EXPECT_EQ(cfs.size(), options.size());
   std::vector<ColumnFamilyDescriptor> column_families;
@@ -396,8 +414,7 @@ Status DBTestBase::TryReopenWithColumnFamilies(
 }
 
 Status DBTestBase::TryReopenWithColumnFamilies(
-    const std::vector<std::string>& cfs,
-    const Options& options) {
+    const std::vector<std::string>& cfs, const Options& options) {
   Close();
   std::vector<Options> v_opts(cfs.size(), options);
   return TryReopenWithColumnFamilies(cfs, v_opts);
@@ -454,7 +471,7 @@ Status DBTestBase::Put(const Slice& k, const Slice& v, WriteOptions wo) {
 }
 
 Status DBTestBase::Put(int cf, const Slice& k, const Slice& v,
-           WriteOptions wo) {
+                       WriteOptions wo) {
   if (kMergePut == option_config_) {
     return db_->Merge(wo, handles_[cf], k, v);
   } else {
@@ -493,7 +510,7 @@ std::string DBTestBase::Get(const std::string& k, const Snapshot* snapshot) {
 }
 
 std::string DBTestBase::Get(int cf, const std::string& k,
-                const Snapshot* snapshot) {
+                            const Snapshot* snapshot) {
   ReadOptions options;
   options.verify_checksums = true;
   options.snapshot = snapshot;
@@ -552,9 +569,9 @@ std::string DBTestBase::AllEntriesFor(const Slice& user_key, int cf) {
   Arena arena;
   ScopedArenaIterator iter;
   if (cf == 0) {
-    iter.set(dbfull()->TEST_NewInternalIterator(&arena));
+    iter.set(dbfull()->NewInternalIterator(&arena));
   } else {
-    iter.set(dbfull()->TEST_NewInternalIterator(&arena, handles_[cf]));
+    iter.set(dbfull()->NewInternalIterator(&arena, handles_[cf]));
   }
   InternalKey target(user_key, kMaxSequenceNumber, kTypeValue);
   iter->Seek(target.Encode());
@@ -605,6 +622,7 @@ std::string DBTestBase::AllEntriesFor(const Slice& user_key, int cf) {
   return result;
 }
 
+#ifndef ROCKSDB_LITE
 int DBTestBase::NumSortedRuns(int cf) {
   ColumnFamilyMetaData cf_meta;
   if (cf == 0) {
@@ -631,20 +649,6 @@ uint64_t DBTestBase::TotalSize(int cf) {
   return cf_meta.size;
 }
 
-int DBTestBase::NumTableFilesAtLevel(int level, int cf) {
-  std::string property;
-  if (cf == 0) {
-    // default cfd
-    EXPECT_TRUE(db_->GetProperty(
-        "rocksdb.num-files-at-level" + NumberToString(level), &property));
-  } else {
-    EXPECT_TRUE(db_->GetProperty(
-        handles_[cf], "rocksdb.num-files-at-level" + NumberToString(level),
-        &property));
-  }
-  return atoi(property.c_str());
-}
-
 uint64_t DBTestBase::SizeAtLevel(int level) {
   std::vector<LiveFileMetaData> metadata;
   db_->GetLiveFilesMetaData(&metadata);
@@ -657,20 +661,41 @@ uint64_t DBTestBase::SizeAtLevel(int level) {
   return sum;
 }
 
-int DBTestBase::TotalLiveFiles(int cf) {
+size_t DBTestBase::TotalLiveFiles(int cf) {
   ColumnFamilyMetaData cf_meta;
   if (cf == 0) {
     db_->GetColumnFamilyMetaData(&cf_meta);
   } else {
     db_->GetColumnFamilyMetaData(handles_[cf], &cf_meta);
   }
-  int num_files = 0;
+  size_t num_files = 0;
   for (auto& level : cf_meta.levels) {
     num_files += level.files.size();
   }
   return num_files;
 }
 
+size_t DBTestBase::CountLiveFiles() {
+  std::vector<LiveFileMetaData> metadata;
+  db_->GetLiveFilesMetaData(&metadata);
+  return metadata.size();
+}
+#endif  // ROCKSDB_LITE
+
+int DBTestBase::NumTableFilesAtLevel(int level, int cf) {
+  std::string property;
+  if (cf == 0) {
+    // default cfd
+    EXPECT_TRUE(db_->GetProperty(
+        "rocksdb.num-files-at-level" + NumberToString(level), &property));
+  } else {
+    EXPECT_TRUE(db_->GetProperty(
+        handles_[cf], "rocksdb.num-files-at-level" + NumberToString(level),
+        &property));
+  }
+  return atoi(property.c_str());
+}
+
 int DBTestBase::TotalTableFiles(int cf, int levels) {
   if (levels == -1) {
     levels = CurrentOptions().num_levels;
@@ -713,12 +738,6 @@ size_t DBTestBase::CountFiles() {
   return files.size() + logfiles.size();
 }
 
-size_t DBTestBase::CountLiveFiles() {
-  std::vector<LiveFileMetaData> metadata;
-  db_->GetLiveFilesMetaData(&metadata);
-  return metadata.size();
-}
-
 uint64_t DBTestBase::Size(const Slice& start, const Slice& limit, int cf) {
   Range r(start, limit);
   uint64_t size;
@@ -731,7 +750,7 @@ uint64_t DBTestBase::Size(const Slice& start, const Slice& limit, int cf) {
 }
 
 void DBTestBase::Compact(int cf, const Slice& start, const Slice& limit,
-             uint32_t target_path_id) {
+                         uint32_t target_path_id) {
   CompactRangeOptions compact_options;
   compact_options.target_path_id = target_path_id;
   ASSERT_OK(db_->CompactRange(compact_options, handles_[cf], &start, &limit));
@@ -748,9 +767,8 @@ void DBTestBase::Compact(const Slice& start, const Slice& limit) {
 
 // Do n memtable compactions, each of which produces an sstable
 // covering the range [small,large].
-void DBTestBase::MakeTables(
-    int n, const std::string& small,
-    const std::string& large, int cf) {
+void DBTestBase::MakeTables(int n, const std::string& small,
+                            const std::string& large, int cf) {
   for (int i = 0; i < n; i++) {
     ASSERT_OK(Put(cf, small, "begin"));
     ASSERT_OK(Put(cf, large, "end"));
@@ -761,8 +779,8 @@ void DBTestBase::MakeTables(
 
 // Prevent pushing of new sstables into deeper levels by adding
 // tables that cover a specified range to all levels.
-void DBTestBase::FillLevels(
-    const std::string& smallest, const std::string& largest, int cf) {
+void DBTestBase::FillLevels(const std::string& smallest,
+                            const std::string& largest, int cf) {
   MakeTables(db_->NumberLevels(handles_[cf]), smallest, largest, cf);
 }
 
@@ -779,7 +797,7 @@ void DBTestBase::MoveFilesToLevel(int level, int cf) {
 void DBTestBase::DumpFileCounts(const char* label) {
   fprintf(stderr, "---\n%s:\n", label);
   fprintf(stderr, "maxoverlap: %" PRIu64 "\n",
-      dbfull()->TEST_MaxNextLevelOverlappingBytes());
+          dbfull()->TEST_MaxNextLevelOverlappingBytes());
   for (int level = 0; level < db_->NumberLevels(); level++) {
     int num = NumTableFilesAtLevel(level);
     if (num > 0) {
@@ -815,7 +833,7 @@ int DBTestBase::GetSstFileCount(std::string path) {
 // this will generate non-overlapping files since it keeps increasing key_idx
 void DBTestBase::GenerateNewFile(int cf, Random* rnd, int* key_idx,
                                  bool nowait) {
-  for (int i = 0; i < 100; i++) {
+  for (int i = 0; i < KNumKeysByGenerateNewFile; i++) {
     ASSERT_OK(Put(cf, Key(*key_idx), RandomString(rnd, (i == 99) ? 1 : 990)));
     (*key_idx)++;
   }
@@ -827,7 +845,7 @@ void DBTestBase::GenerateNewFile(int cf, Random* rnd, int* key_idx,
 
 // this will generate non-overlapping files since it keeps increasing key_idx
 void DBTestBase::GenerateNewFile(Random* rnd, int* key_idx, bool nowait) {
-  for (int i = 0; i < 100; i++) {
+  for (int i = 0; i < KNumKeysByGenerateNewFile; i++) {
     ASSERT_OK(Put(Key(*key_idx), RandomString(rnd, (i == 99) ? 1 : 990)));
     (*key_idx)++;
   }
@@ -837,8 +855,10 @@ void DBTestBase::GenerateNewFile(Random* rnd, int* key_idx, bool nowait) {
   }
 }
 
+const int DBTestBase::kNumKeysByGenerateNewRandomFile = 51;
+
 void DBTestBase::GenerateNewRandomFile(Random* rnd, bool nowait) {
-  for (int i = 0; i < 51; i++) {
+  for (int i = 0; i < kNumKeysByGenerateNewRandomFile; i++) {
     ASSERT_OK(Put("key" + RandomString(rnd, 7), RandomString(rnd, 2000)));
   }
   ASSERT_OK(Put("key" + RandomString(rnd, 7), RandomString(rnd, 200)));
@@ -888,9 +908,10 @@ void DBTestBase::VerifyIterLast(std::string expected_key, int cf) {
 //   sets newValue with delta
 // If previous value is not empty,
 //   updates previous value with 'b' string of previous value size - 1.
-UpdateStatus DBTestBase::updateInPlaceSmallerSize(
-    char* prevValue, uint32_t* prevSize,
-    Slice delta, std::string* newValue) {
+UpdateStatus DBTestBase::updateInPlaceSmallerSize(char* prevValue,
+                                                  uint32_t* prevSize,
+                                                  Slice delta,
+                                                  std::string* newValue) {
   if (prevValue == nullptr) {
     *newValue = std::string(delta.size(), 'c');
     return UpdateStatus::UPDATED;
@@ -902,9 +923,10 @@ UpdateStatus DBTestBase::updateInPlaceSmallerSize(
   }
 }
 
-UpdateStatus DBTestBase::updateInPlaceSmallerVarintSize(
-    char* prevValue, uint32_t* prevSize,
-    Slice delta, std::string* newValue) {
+UpdateStatus DBTestBase::updateInPlaceSmallerVarintSize(char* prevValue,
+                                                        uint32_t* prevSize,
+                                                        Slice delta,
+                                                        std::string* newValue) {
   if (prevValue == nullptr) {
     *newValue = std::string(delta.size(), 'c');
     return UpdateStatus::UPDATED;
@@ -916,16 +938,17 @@ UpdateStatus DBTestBase::updateInPlaceSmallerVarintSize(
   }
 }
 
-UpdateStatus DBTestBase::updateInPlaceLargerSize(
-    char* prevValue, uint32_t* prevSize,
-    Slice delta, std::string* newValue) {
+UpdateStatus DBTestBase::updateInPlaceLargerSize(char* prevValue,
+                                                 uint32_t* prevSize,
+                                                 Slice delta,
+                                                 std::string* newValue) {
   *newValue = std::string(delta.size(), 'c');
   return UpdateStatus::UPDATED;
 }
 
-UpdateStatus DBTestBase::updateInPlaceNoAction(
-    char* prevValue, uint32_t* prevSize,
-    Slice delta, std::string* newValue) {
+UpdateStatus DBTestBase::updateInPlaceNoAction(char* prevValue,
+                                               uint32_t* prevSize, Slice delta,
+                                               std::string* newValue) {
   return UpdateStatus::UPDATE_FAILED;
 }
 
@@ -934,9 +957,9 @@ void DBTestBase::validateNumberOfEntries(int numValues, int cf) {
   ScopedArenaIterator iter;
   Arena arena;
   if (cf != 0) {
-    iter.set(dbfull()->TEST_NewInternalIterator(&arena, handles_[cf]));
+    iter.set(dbfull()->NewInternalIterator(&arena, handles_[cf]));
   } else {
-    iter.set(dbfull()->TEST_NewInternalIterator(&arena));
+    iter.set(dbfull()->NewInternalIterator(&arena));
   }
   iter->SeekToFirst();
   ASSERT_EQ(iter->status().ok(), true);
@@ -953,9 +976,8 @@ void DBTestBase::validateNumberOfEntries(int numValues, int cf) {
   ASSERT_EQ(0, seq);
 }
 
-void DBTestBase::CopyFile(
-    const std::string& source, const std::string& destination,
-    uint64_t size) {
+void DBTestBase::CopyFile(const std::string& source,
+                          const std::string& destination, uint64_t size) {
   const EnvOptions soptions;
   unique_ptr<SequentialFile> srcfile;
   ASSERT_OK(env_->NewSequentialFile(source, &srcfile, soptions));
diff --git a/src/rocksdb/util/db_test_util.h b/src/rocksdb/db/db_test_util.h
similarity index 79%
rename from src/rocksdb/util/db_test_util.h
rename to src/rocksdb/db/db_test_util.h
index 774cce8..c13ebbd 100644
--- a/src/rocksdb/util/db_test_util.h
+++ b/src/rocksdb/db/db_test_util.h
@@ -27,8 +27,10 @@
 #include <vector>
 
 #include "db/db_impl.h"
+#include "db/db_test_util.h"
 #include "db/dbformat.h"
 #include "db/filename.h"
+#include "memtable/hash_linklist_rep.h"
 #include "rocksdb/cache.h"
 #include "rocksdb/compaction_filter.h"
 #include "rocksdb/convenience.h"
@@ -42,12 +44,11 @@
 #include "table/block_based_table_factory.h"
 #include "table/mock_table.h"
 #include "table/plain_table_factory.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/compression.h"
-#include "util/db_test_util.h"
-#include "util/hash_linklist_rep.h"
 #include "util/mock_env.h"
 #include "util/mutexlock.h"
-#include "util/scoped_arena_iterator.h"
+
 #include "util/string_util.h"
 // SyncPoint is not supported in Released Windows Mode.
 #if !(defined NDEBUG) || !defined(OS_WIN)
@@ -117,6 +118,84 @@ struct OptionsOverride {
 
 }  // namespace anon
 
+// A hacky skip list mem table that triggers flush after number of entries.
+class SpecialMemTableRep : public MemTableRep {
+ public:
+  explicit SpecialMemTableRep(MemTableAllocator* allocator,
+                              MemTableRep* memtable, int num_entries_flush)
+      : MemTableRep(allocator),
+        memtable_(memtable),
+        num_entries_flush_(num_entries_flush),
+        num_entries_(0) {}
+
+  virtual KeyHandle Allocate(const size_t len, char** buf) override {
+    return memtable_->Allocate(len, buf);
+  }
+
+  // Insert key into the list.
+  // REQUIRES: nothing that compares equal to key is currently in the list.
+  virtual void Insert(KeyHandle handle) override {
+    memtable_->Insert(handle);
+    num_entries_++;
+  }
+
+  // Returns true iff an entry that compares equal to key is in the list.
+  virtual bool Contains(const char* key) const override {
+    return memtable_->Contains(key);
+  }
+
+  virtual size_t ApproximateMemoryUsage() override {
+    // Return a high memory usage when number of entries exceeds the threshold
+    // to trigger a flush.
+    return (num_entries_ < num_entries_flush_) ? 0 : 1024 * 1024 * 1024;
+  }
+
+  virtual void Get(const LookupKey& k, void* callback_args,
+                   bool (*callback_func)(void* arg,
+                                         const char* entry)) override {
+    memtable_->Get(k, callback_args, callback_func);
+  }
+
+  uint64_t ApproximateNumEntries(const Slice& start_ikey,
+                                 const Slice& end_ikey) override {
+    return memtable_->ApproximateNumEntries(start_ikey, end_ikey);
+  }
+
+  virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override {
+    return memtable_->GetIterator(arena);
+  }
+
+  virtual ~SpecialMemTableRep() override {}
+
+ private:
+  unique_ptr<MemTableRep> memtable_;
+  int num_entries_flush_;
+  int num_entries_;
+};
+
+// The factory for the hacky skip list mem table that triggers flush after
+// number of entries exceeds a threshold.
+class SpecialSkipListFactory : public MemTableRepFactory {
+ public:
+  // After number of inserts exceeds `num_entries_flush` in a mem table, trigger
+  // flush.
+  explicit SpecialSkipListFactory(int num_entries_flush)
+      : num_entries_flush_(num_entries_flush) {}
+
+  virtual MemTableRep* CreateMemTableRep(
+      const MemTableRep::KeyComparator& compare, MemTableAllocator* allocator,
+      const SliceTransform* transform, Logger* logger) override {
+    return new SpecialMemTableRep(
+        allocator, factory_.CreateMemTableRep(compare, allocator, transform, 0),
+        num_entries_flush_);
+  }
+  virtual const char* Name() const override { return "SkipListFactory"; }
+
+ private:
+  SkipListFactory factory_;
+  int num_entries_flush_;
+};
+
 // Special Env used to delay background operations
 class SpecialEnv : public EnvWrapper {
  public:
@@ -131,9 +210,7 @@ class SpecialEnv : public EnvWrapper {
 
      public:
       SSTableFile(SpecialEnv* env, unique_ptr<WritableFile>&& base)
-          : env_(env),
-            base_(std::move(base)) {
-      }
+          : env_(env), base_(std::move(base)) {}
       Status Append(const Slice& data) override {
         if (env_->table_write_callback_) {
           (*env_->table_write_callback_)();
@@ -148,9 +225,7 @@ class SpecialEnv : public EnvWrapper {
           return base_->Append(data);
         }
       }
-      Status Truncate(uint64_t size) override {
-        return base_->Truncate(size);
-      }
+      Status Truncate(uint64_t size) override { return base_->Truncate(size); }
       Status Close() override {
 // SyncPoint is not supported in Released Windows Mode.
 #if !(defined NDEBUG) || !defined(OS_WIN)
@@ -180,7 +255,7 @@ class SpecialEnv : public EnvWrapper {
     class ManifestFile : public WritableFile {
      public:
       ManifestFile(SpecialEnv* env, unique_ptr<WritableFile>&& b)
-          : env_(env), base_(std::move(b)) { }
+          : env_(env), base_(std::move(b)) {}
       Status Append(const Slice& data) override {
         if (env_->manifest_write_error_.load(std::memory_order_acquire)) {
           return Status::IOError("simulated writer error");
@@ -283,8 +358,7 @@ class SpecialEnv : public EnvWrapper {
      public:
       CountingFile(unique_ptr<RandomAccessFile>&& target,
                    anon::AtomicCounter* counter)
-          : target_(std::move(target)), counter_(counter) {
-      }
+          : target_(std::move(target)), counter_(counter) {}
       virtual Status Read(uint64_t offset, size_t n, Slice* result,
                           char* scratch) const override {
         counter_->Increment();
@@ -329,18 +403,21 @@ class SpecialEnv : public EnvWrapper {
     return s;
   }
 
-
   virtual void SleepForMicroseconds(int micros) override {
     sleep_counter_.Increment();
-    if (no_sleep_) {
+    if (no_sleep_ || time_elapse_only_sleep_) {
       addon_time_.fetch_add(micros);
-    } else {
+    }
+    if (!no_sleep_) {
       target()->SleepForMicroseconds(micros);
     }
   }
 
   virtual Status GetCurrentTime(int64_t* unix_time) override {
-    Status s = target()->GetCurrentTime(unix_time);
+    Status s;
+    if (!time_elapse_only_sleep_) {
+      s = target()->GetCurrentTime(unix_time);
+    }
     if (s.ok()) {
       *unix_time += addon_time_.load();
     }
@@ -348,11 +425,13 @@ class SpecialEnv : public EnvWrapper {
   }
 
   virtual uint64_t NowNanos() override {
-    return target()->NowNanos() + addon_time_.load() * 1000;
+    return (time_elapse_only_sleep_ ? 0 : target()->NowNanos()) +
+           addon_time_.load() * 1000;
   }
 
   virtual uint64_t NowMicros() override {
-    return target()->NowMicros() + addon_time_.load();
+    return (time_elapse_only_sleep_ ? 0 : target()->NowMicros()) +
+           addon_time_.load();
   }
 
   Random rnd_;
@@ -404,9 +483,12 @@ class SpecialEnv : public EnvWrapper {
   std::function<void()>* table_write_callback_;
 
   std::atomic<int64_t> addon_time_;
+
+  bool time_elapse_only_sleep_;
+
   bool no_sleep_;
 
-  std::atomic<bool> is_wal_sync_thread_safe_ {true};
+  std::atomic<bool> is_wal_sync_thread_safe_{true};
 };
 
 class DBTestBase : public testing::Test {
@@ -442,9 +524,10 @@ class DBTestBase : public testing::Test {
     kFIFOCompaction = 26,
     kOptimizeFiltersForHits = 27,
     kRowCache = 28,
-    kLevelSubcompactions = 29,
-    kUniversalSubcompactions = 30,
-    kEnd = 29
+    kRecycleLogFiles = 29,
+    kLevelSubcompactions = 30,
+    kUniversalSubcompactions = 31,
+    kEnd = 30
   };
   int option_config_;
 
@@ -509,9 +592,7 @@ class DBTestBase : public testing::Test {
       const Options& defaultOptions,
       const anon::OptionsOverride& options_override = anon::OptionsOverride());
 
-  DBImpl* dbfull() {
-    return reinterpret_cast<DBImpl*>(db_);
-  }
+  DBImpl* dbfull() { return reinterpret_cast<DBImpl*>(db_); }
 
   void CreateColumnFamilies(const std::vector<std::string>& cfs,
                             const Options& options);
@@ -525,9 +606,8 @@ class DBTestBase : public testing::Test {
   void ReopenWithColumnFamilies(const std::vector<std::string>& cfs,
                                 const Options& options);
 
-  Status TryReopenWithColumnFamilies(
-      const std::vector<std::string>& cfs,
-      const std::vector<Options>& options);
+  Status TryReopenWithColumnFamilies(const std::vector<std::string>& cfs,
+                                     const std::vector<Options>& options);
 
   Status TryReopenWithColumnFamilies(const std::vector<std::string>& cfs,
                                      const Options& options);
@@ -574,15 +654,19 @@ class DBTestBase : public testing::Test {
 
   std::string AllEntriesFor(const Slice& user_key, int cf = 0);
 
+#ifndef ROCKSDB_LITE
   int NumSortedRuns(int cf = 0);
 
   uint64_t TotalSize(int cf = 0);
 
-  int NumTableFilesAtLevel(int level, int cf = 0);
-
   uint64_t SizeAtLevel(int level);
 
-  int TotalLiveFiles(int cf = 0);
+  size_t TotalLiveFiles(int cf = 0);
+
+  size_t CountLiveFiles();
+#endif  // ROCKSDB_LITE
+
+  int NumTableFilesAtLevel(int level, int cf = 0);
 
   int TotalTableFiles(int cf = 0, int levels = -1);
 
@@ -591,8 +675,6 @@ class DBTestBase : public testing::Test {
 
   size_t CountFiles();
 
-  size_t CountLiveFiles();
-
   uint64_t Size(const Slice& start, const Slice& limit, int cf = 0);
 
   void Compact(int cf, const Slice& start, const Slice& limit,
@@ -627,6 +709,9 @@ class DBTestBase : public testing::Test {
 
   void GenerateNewFile(int fd, Random* rnd, int* key_idx, bool nowait = false);
 
+  static const int kNumKeysByGenerateNewRandomFile;
+  static const int KNumKeysByGenerateNewFile = 100;
+
   void GenerateNewRandomFile(Random* rnd, bool nowait = false);
 
   std::string IterStatus(Iterator* iter);
@@ -643,21 +728,21 @@ class DBTestBase : public testing::Test {
   //   sets newValue with delta
   // If previous value is not empty,
   //   updates previous value with 'b' string of previous value size - 1.
-  static UpdateStatus updateInPlaceSmallerSize(
-      char* prevValue, uint32_t* prevSize,
-      Slice delta, std::string* newValue);
+  static UpdateStatus updateInPlaceSmallerSize(char* prevValue,
+                                               uint32_t* prevSize, Slice delta,
+                                               std::string* newValue);
 
-  static UpdateStatus updateInPlaceSmallerVarintSize(
-      char* prevValue, uint32_t* prevSize,
-      Slice delta, std::string* newValue);
+  static UpdateStatus updateInPlaceSmallerVarintSize(char* prevValue,
+                                                     uint32_t* prevSize,
+                                                     Slice delta,
+                                                     std::string* newValue);
 
-  static UpdateStatus updateInPlaceLargerSize(
-      char* prevValue, uint32_t* prevSize,
-      Slice delta, std::string* newValue);
+  static UpdateStatus updateInPlaceLargerSize(char* prevValue,
+                                              uint32_t* prevSize, Slice delta,
+                                              std::string* newValue);
 
-  static UpdateStatus updateInPlaceNoAction(
-      char* prevValue, uint32_t* prevSize,
-      Slice delta, std::string* newValue);
+  static UpdateStatus updateInPlaceNoAction(char* prevValue, uint32_t* prevSize,
+                                            Slice delta, std::string* newValue);
 
   // Utility method to test InplaceUpdate
   void validateNumberOfEntries(int numValues, int cf = 0);
diff --git a/src/rocksdb/db/db_universal_compaction_test.cc b/src/rocksdb/db/db_universal_compaction_test.cc
index 8e18699..15f871b 100644
--- a/src/rocksdb/db/db_universal_compaction_test.cc
+++ b/src/rocksdb/db/db_universal_compaction_test.cc
@@ -7,9 +7,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
 #include "util/sync_point.h"
 
 namespace rocksdb {
@@ -112,6 +112,44 @@ class DelayFilterFactory : public CompactionFilterFactory {
 };
 }  // namespace
 
+// Make sure we don't trigger a problem if the trigger conditon is given
+// to be 0, which is invalid.
+TEST_P(DBTestUniversalCompaction, UniversalCompactionSingleSortedRun) {
+  Options options;
+  options = CurrentOptions(options);
+
+  options.compaction_style = kCompactionStyleUniversal;
+  options.num_levels = num_levels_;
+  // Config universal compaction to always compact to one single sorted run.
+  options.level0_file_num_compaction_trigger = 0;
+  options.compaction_options_universal.size_ratio = 10;
+  options.compaction_options_universal.min_merge_width = 2;
+  options.compaction_options_universal.max_size_amplification_percent = 1;
+
+  options.write_buffer_size = 105 << 10;  // 105KB
+  options.arena_block_size = 4 << 10;
+  options.target_file_size_base = 32 << 10;  // 32KB
+  // trigger compaction if there are >= 4 files
+  KeepFilterFactory* filter = new KeepFilterFactory(true);
+  filter->expect_manual_compaction_.store(false);
+  options.compaction_filter_factory.reset(filter);
+
+  DestroyAndReopen(options);
+  ASSERT_EQ(1, db_->GetOptions().level0_file_num_compaction_trigger);
+
+  Random rnd(301);
+  int key_idx = 0;
+
+  filter->expect_full_compaction_.store(true);
+
+  for (int num = 0; num < 16; num++) {
+    // Write 100KB file. And immediately it should be compacted to one file.
+    GenerateNewFile(&rnd, &key_idx);
+    dbfull()->TEST_WaitForCompact();
+    ASSERT_EQ(NumSortedRuns(0), 1);
+  }
+}
+
 // TODO(kailiu) The tests on UniversalCompaction has some issues:
 //  1. A lot of magic numbers ("11" or "12").
 //  2. Made assumption on the memtable flush conditions, which may change from
@@ -119,6 +157,7 @@ class DelayFilterFactory : public CompactionFilterFactory {
 TEST_P(DBTestUniversalCompaction, UniversalCompactionTrigger) {
   Options options;
   options.compaction_style = kCompactionStyleUniversal;
+  options.compaction_options_universal.size_ratio = 5;
   options.num_levels = num_levels_;
   options.write_buffer_size = 105 << 10;  // 105KB
   options.arena_block_size = 4 << 10;
@@ -851,7 +890,10 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionFourPaths) {
   options.db_paths.emplace_back(dbname_ + "_2", 300 * 1024);
   options.db_paths.emplace_back(dbname_ + "_3", 500 * 1024);
   options.db_paths.emplace_back(dbname_ + "_4", 1024 * 1024 * 1024);
+  options.memtable_factory.reset(
+      new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1));
   options.compaction_style = kCompactionStyleUniversal;
+  options.compaction_options_universal.size_ratio = 5;
   options.write_buffer_size = 110 << 10;  // 105KB
   options.arena_block_size = 4 << 10;
   options.level0_file_num_compaction_trigger = 2;
@@ -968,13 +1010,15 @@ TEST_P(DBTestUniversalCompaction, IncreaseUniversalCompactionNumLevels) {
   int max_key1 = 200;
   int max_key2 = 600;
   int max_key3 = 800;
+  const int KNumKeysPerFile = 10;
 
   // Stage 1: open a DB with universal compaction, num_levels=1
   Options options = CurrentOptions();
   options.compaction_style = kCompactionStyleUniversal;
   options.num_levels = 1;
-  options.write_buffer_size = 100 << 10;  // 100KB
+  options.write_buffer_size = 200 << 10;  // 200KB
   options.level0_file_num_compaction_trigger = 3;
+  options.memtable_factory.reset(new SpecialSkipListFactory(KNumKeysPerFile));
   options = CurrentOptions(options);
   CreateAndReopenWithCF({"pikachu"}, options);
 
@@ -1047,11 +1091,14 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionSecondPathRatio) {
   options.db_paths.emplace_back(dbname_, 500 * 1024);
   options.db_paths.emplace_back(dbname_ + "_2", 1024 * 1024 * 1024);
   options.compaction_style = kCompactionStyleUniversal;
+  options.compaction_options_universal.size_ratio = 5;
   options.write_buffer_size = 110 << 10;  // 105KB
   options.arena_block_size = 4 * 1024;
   options.arena_block_size = 4 << 10;
   options.level0_file_num_compaction_trigger = 2;
   options.num_levels = 1;
+  options.memtable_factory.reset(
+      new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1));
   options = CurrentOptions(options);
 
   std::vector<std::string> filenames;
@@ -1210,10 +1257,10 @@ INSTANTIATE_TEST_CASE_P(DBTestUniversalManualCompactionOutputPathId,
 
 }  // namespace rocksdb
 
-#endif  // !(defined NDEBUG) || !defined(OS_WIN)
+#endif  // !defined(ROCKSDB_LITE)
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
+#if !defined(ROCKSDB_LITE)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
diff --git a/src/rocksdb/db/db_wal_test.cc b/src/rocksdb/db/db_wal_test.cc
index 531021e..9e8a19d 100644
--- a/src/rocksdb/db/db_wal_test.cc
+++ b/src/rocksdb/db/db_wal_test.cc
@@ -7,11 +7,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "db/db_test_util.h"
 #include "port/stack_trace.h"
-#include "util/db_test_util.h"
-#if !(defined NDEBUG) || !defined(OS_WIN)
 #include "util/sync_point.h"
-#endif
 
 namespace rocksdb {
 class DBWALTest : public DBTestBase {
@@ -70,7 +68,6 @@ TEST_F(DBWALTest, RollLog) {
   } while (ChangeOptions());
 }
 
-#if !(defined NDEBUG) || !defined(OS_WIN)
 TEST_F(DBWALTest, SyncWALNotBlockWrite) {
   Options options = CurrentOptions();
   options.max_write_buffer_number = 4;
@@ -130,15 +127,10 @@ TEST_F(DBWALTest, SyncWALNotWaitWrite) {
   ASSERT_EQ(Get("foo2"), "bar2");
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
 }
-#endif
 }  // namespace rocksdb
 
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
 }
diff --git a/src/rocksdb/db/event_helpers.cc b/src/rocksdb/db/event_helpers.cc
index 9035c0c..7191e4c 100644
--- a/src/rocksdb/db/event_helpers.cc
+++ b/src/rocksdb/db/event_helpers.cc
@@ -53,7 +53,7 @@ void EventHelpers::LogAndNotifyTableFileCreation(
                 info.table_properties.filter_policy_name;
 
     // user collected properties
-    for (const auto& prop : info.table_properties.user_collected_properties) {
+    for (const auto& prop : info.table_properties.readable_properties) {
       jwriter << prop.first << prop.second;
     }
     jwriter.EndObject();
diff --git a/src/rocksdb/db/fault_injection_test.cc b/src/rocksdb/db/fault_injection_test.cc
index 84a6e9a..03d829b 100644
--- a/src/rocksdb/db/fault_injection_test.cc
+++ b/src/rocksdb/db/fault_injection_test.cc
@@ -11,8 +11,6 @@
 // the last "sync". It then checks for data loss errors by purposely dropping
 // file data (or entire files) not protected by a "sync".
 
-#if !(defined NDEBUG) || !defined(OS_WIN)
-
 #include <map>
 #include <set>
 #include "db/db_impl.h"
@@ -902,13 +900,7 @@ INSTANTIATE_TEST_CASE_P(FaultTest, FaultInjectionTest, ::testing::Bool());
 
 }  // namespace rocksdb
 
-#endif // #if !(defined NDEBUG) || !defined(OS_WIN)
-
 int main(int argc, char** argv) {
-#if !(defined NDEBUG) || !defined(OS_WIN)
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
 }
diff --git a/src/rocksdb/db/file_indexer.h b/src/rocksdb/db/file_indexer.h
index 3a335be..418ae0f 100644
--- a/src/rocksdb/db/file_indexer.h
+++ b/src/rocksdb/db/file_indexer.h
@@ -26,9 +26,9 @@ struct FileLevel;
 // The file tree structure in Version is prebuilt and the range of each file
 // is known. On Version::Get(), it uses binary search to find a potential file
 // and then check if a target key can be found in the file by comparing the key
-// to each file's smallest and largest key. The results of these comparisions
+// to each file's smallest and largest key. The results of these comparisons
 // can be reused beyond checking if a key falls into a file's range.
-// With some pre-calculated knowledge, each key comparision that has been done
+// With some pre-calculated knowledge, each key comparison that has been done
 // can serve as a hint to narrow down further searches: if a key compared to
 // be smaller than a file's smallest or largest, that comparison can be used
 // to find out the right bound of next binary search. Similarly, if a key
@@ -48,7 +48,7 @@ class FileIndexer {
   size_t LevelIndexSize(size_t level) const;
 
   // Return a file index range in the next level to search for a key based on
-  // smallest and largest key comparision for the current file specified by
+  // smallest and largest key comparison for the current file specified by
   // level and file_index. When *left_index < *right_index, both index should
   // be valid and fit in the vector size.
   void GetNextLevelIndex(const size_t level, const size_t file_index,
diff --git a/src/rocksdb/db/filename.cc b/src/rocksdb/db/filename.cc
index e152037..32cd875 100644
--- a/src/rocksdb/db/filename.cc
+++ b/src/rocksdb/db/filename.cc
@@ -21,6 +21,8 @@
 #include "util/file_reader_writer.h"
 #include "util/logging.h"
 #include "util/stop_watch.h"
+#include "util/string_util.h"
+#include "util/sync_point.h"
 
 namespace rocksdb {
 
@@ -46,8 +48,9 @@ static size_t GetInfoLogPrefix(const std::string& path, char* dest, int len) {
         path[i] == '_'){
       dest[write_idx++] = path[i];
     } else {
-      if (i > 0)
+      if (i > 0) {
         dest[write_idx++] = '_';
+      }
     }
     i++;
   }
@@ -145,7 +148,7 @@ std::string LockFileName(const std::string& dbname) {
 }
 
 std::string TempFileName(const std::string& dbname, uint64_t number) {
-  return MakeFileName(dbname, number, "dbtmp");
+  return MakeFileName(dbname, number, kTempFileNameSuffix.c_str());
 }
 
 InfoLogPrefix::InfoLogPrefix(bool has_log_dir,
@@ -185,6 +188,21 @@ std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts,
   return log_dir + "/" + info_log_prefix.buf + ".old." + buf;
 }
 
+std::string OptionsFileName(const std::string& dbname, uint64_t file_num) {
+  char buffer[256];
+  snprintf(buffer, sizeof(buffer), "%s%06" PRIu64,
+           kOptionsFileNamePrefix.c_str(), file_num);
+  return dbname + "/" + buffer;
+}
+
+std::string TempOptionsFileName(const std::string& dbname, uint64_t file_num) {
+  char buffer[256];
+  snprintf(buffer, sizeof(buffer), "%s%06" PRIu64 ".%s",
+           kOptionsFileNamePrefix.c_str(), file_num,
+           kTempFileNameSuffix.c_str());
+  return dbname + "/" + buffer;
+}
+
 std::string MetaDatabaseName(const std::string& dbname, uint64_t number) {
   char buf[100];
   snprintf(buf, sizeof(buf), "/METADB-%llu",
@@ -205,6 +223,8 @@ std::string IdentityFileName(const std::string& dbname) {
 //    dbname/MANIFEST-[0-9]+
 //    dbname/[0-9]+.(log|sst)
 //    dbname/METADB-[0-9]+
+//    dbname/OPTIONS-[0-9]+
+//    dbname/OPTIONS-[0-9]+.dbtmp
 //    Disregards / at the beginning
 bool ParseFileName(const std::string& fname,
                    uint64_t* number,
@@ -267,6 +287,21 @@ bool ParseFileName(const std::string& fname, uint64_t* number,
     }
     *type = kMetaDatabase;
     *number = num;
+  } else if (rest.starts_with(kOptionsFileNamePrefix)) {
+    uint64_t ts_suffix;
+    bool is_temp_file = false;
+    rest.remove_prefix(kOptionsFileNamePrefix.size());
+    const std::string kTempFileNameSuffixWithDot =
+        std::string(".") + kTempFileNameSuffix;
+    if (rest.ends_with(kTempFileNameSuffixWithDot)) {
+      rest.remove_suffix(kTempFileNameSuffixWithDot.size());
+      is_temp_file = true;
+    }
+    if (!ConsumeDecimalNumber(&rest, &ts_suffix)) {
+      return false;
+    }
+    *number = ts_suffix;
+    *type = is_temp_file ? kTempFile : kOptionsFile;
   } else {
     // Avoid strtoull() to keep filename format independent of the
     // current locale
@@ -301,7 +336,7 @@ bool ParseFileName(const std::string& fname, uint64_t* number,
     } else if (suffix == Slice(kRocksDbTFileExt) ||
                suffix == Slice(kLevelDbTFileExt)) {
       *type = kTableFile;
-    } else if (suffix == Slice("dbtmp")) {
+    } else if (suffix == Slice(kTempFileNameSuffix)) {
       *type = kTempFile;
     } else {
       return false;
@@ -322,7 +357,9 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
   std::string tmp = TempFileName(dbname, descriptor_number);
   Status s = WriteStringToFile(env, contents.ToString() + "\n", tmp, true);
   if (s.ok()) {
+    TEST_KILL_RANDOM("SetCurrentFile:0", rocksdb_kill_odds * REDUCE_ODDS2);
     s = env->RenameFile(tmp, CurrentFileName(dbname));
+    TEST_KILL_RANDOM("SetCurrentFile:1", rocksdb_kill_odds * REDUCE_ODDS2);
   }
   if (s.ok()) {
     if (directory_to_fsync != nullptr) {
@@ -351,6 +388,7 @@ Status SetIdentityFile(Env* env, const std::string& dbname) {
 
 Status SyncManifest(Env* env, const DBOptions* db_options,
                     WritableFileWriter* file) {
+  TEST_KILL_RANDOM("SyncManifest:0", rocksdb_kill_odds * REDUCE_ODDS2);
   if (db_options->disableDataSync) {
     return Status::OK();
   } else {
diff --git a/src/rocksdb/db/filename.h b/src/rocksdb/db/filename.h
index 926f027..f7196c9 100644
--- a/src/rocksdb/db/filename.h
+++ b/src/rocksdb/db/filename.h
@@ -36,7 +36,8 @@ enum FileType {
   kTempFile,
   kInfoLogFile,  // Either the current one, or an old one
   kMetaDatabase,
-  kIdentityFile
+  kIdentityFile,
+  kOptionsFile
 };
 
 // Return the name of the log file with the specified number
@@ -114,6 +115,19 @@ extern std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts,
                                       const std::string& db_path = "",
                                       const std::string& log_dir = "");
 
+static const std::string kOptionsFileNamePrefix = "OPTIONS-";
+static const std::string kTempFileNameSuffix = "dbtmp";
+
+// Return a options file name given the "dbname" and file number.
+// Format:  OPTIONS-[number].dbtmp
+extern std::string OptionsFileName(const std::string& dbname,
+                                   uint64_t file_num);
+
+// Return a temp options file name given the "dbname" and file number.
+// Format:  OPTIONS-[number]
+extern std::string TempOptionsFileName(const std::string& dbname,
+                                       uint64_t file_num);
+
 // Return the name to use for a metadatabase. The result will be prefixed with
 // "dbname".
 extern std::string MetaDatabaseName(const std::string& dbname,
diff --git a/src/rocksdb/db/flush_job.cc b/src/rocksdb/db/flush_job.cc
index 410108a..a20a0ba 100644
--- a/src/rocksdb/db/flush_job.cc
+++ b/src/rocksdb/db/flush_job.cc
@@ -197,7 +197,7 @@ Status FlushJob::WriteLevel0Table(const autovector<MemTable*>& mems,
     if (log_buffer_) {
       log_buffer_->FlushBufferToLog();
     }
-    std::vector<Iterator*> memtables;
+    std::vector<InternalIterator*> memtables;
     ReadOptions ro;
     ro.total_order_seek = true;
     Arena arena;
@@ -231,13 +231,15 @@ Status FlushJob::WriteLevel0Table(const autovector<MemTable*>& mems,
 
       TEST_SYNC_POINT_CALLBACK("FlushJob::WriteLevel0Table:output_compression",
                                &output_compression_);
-      s = BuildTable(
-          dbname_, db_options_.env, *cfd_->ioptions(), env_options_,
-          cfd_->table_cache(), iter.get(), meta, cfd_->internal_comparator(),
-          cfd_->int_tbl_prop_collector_factories(), existing_snapshots_,
-          output_compression_, cfd_->ioptions()->compression_opts,
-          mutable_cf_options_.paranoid_file_checks, cfd_->internal_stats(),
-          Env::IO_HIGH, &info.table_properties);
+      s = BuildTable(dbname_, db_options_.env, *cfd_->ioptions(), env_options_,
+                     cfd_->table_cache(), iter.get(), meta,
+                     cfd_->internal_comparator(),
+                     cfd_->int_tbl_prop_collector_factories(), cfd_->GetID(),
+                     existing_snapshots_, output_compression_,
+                     cfd_->ioptions()->compression_opts,
+                     mutable_cf_options_.paranoid_file_checks,
+                     cfd_->internal_stats(), Env::IO_HIGH, &table_properties_);
+      info.table_properties = table_properties_;
       LogFlush(db_options_.info_log);
     }
     Log(InfoLogLevel::INFO_LEVEL, db_options_.info_log,
diff --git a/src/rocksdb/db/flush_job.h b/src/rocksdb/db/flush_job.h
index 14555ef..dbc4113 100644
--- a/src/rocksdb/db/flush_job.h
+++ b/src/rocksdb/db/flush_job.h
@@ -27,12 +27,12 @@
 #include "rocksdb/env.h"
 #include "rocksdb/memtablerep.h"
 #include "rocksdb/transaction_log.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/autovector.h"
 #include "util/event_logger.h"
 #include "util/instrumented_mutex.h"
 #include "util/stop_watch.h"
 #include "util/thread_local.h"
-#include "util/scoped_arena_iterator.h"
 #include "db/internal_stats.h"
 #include "db/write_controller.h"
 #include "db/flush_scheduler.h"
@@ -66,6 +66,7 @@ class FlushJob {
   ~FlushJob();
 
   Status Run(FileMetaData* file_meta = nullptr);
+  TableProperties GetTableProperties() const { return table_properties_; }
 
  private:
   void ReportStartedFlush();
@@ -89,6 +90,7 @@ class FlushJob {
   CompressionType output_compression_;
   Statistics* stats_;
   EventLogger* event_logger_;
+  TableProperties table_properties_;
 };
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/db/flush_job_test.cc b/src/rocksdb/db/flush_job_test.cc
index d2c423c..d20cf5e 100644
--- a/src/rocksdb/db/flush_job_test.cc
+++ b/src/rocksdb/db/flush_job_test.cc
@@ -61,7 +61,7 @@ class FlushJobTest : public testing::Test {
     unique_ptr<WritableFileWriter> file_writer(
         new WritableFileWriter(std::move(file), EnvOptions()));
     {
-      log::Writer log(std::move(file_writer));
+      log::Writer log(std::move(file_writer), 0, false);
       std::string record;
       new_db.EncodeTo(&record);
       s = log.AddRecord(record);
diff --git a/src/rocksdb/db/forward_iterator.cc b/src/rocksdb/db/forward_iterator.cc
index c0d7647..20cde56 100644
--- a/src/rocksdb/db/forward_iterator.cc
+++ b/src/rocksdb/db/forward_iterator.cc
@@ -28,7 +28,7 @@ namespace rocksdb {
 //     iter.SetFileIndex(file_index);
 //     iter.Seek(target);
 //     iter.Next()
-class LevelIterator : public Iterator {
+class LevelIterator : public InternalIterator {
  public:
   LevelIterator(const ColumnFamilyData* const cfd,
       const ReadOptions& read_options,
@@ -113,7 +113,7 @@ class LevelIterator : public Iterator {
   bool valid_;
   uint32_t file_index_;
   Status status_;
-  std::unique_ptr<Iterator> file_iter_;
+  std::unique_ptr<InternalIterator> file_iter_;
 };
 
 ForwardIterator::ForwardIterator(DBImpl* db, const ReadOptions& read_options,
@@ -144,12 +144,29 @@ ForwardIterator::~ForwardIterator() {
   Cleanup(true);
 }
 
+void ForwardIterator::SVCleanup() {
+  if (sv_ != nullptr && sv_->Unref()) {
+    // Job id == 0 means that this is not our background process, but rather
+    // user thread
+    JobContext job_context(0);
+    db_->mutex_.Lock();
+    sv_->Cleanup();
+    db_->FindObsoleteFiles(&job_context, false, true);
+    db_->mutex_.Unlock();
+    delete sv_;
+    if (job_context.HaveSomethingToDelete()) {
+      db_->PurgeObsoleteFiles(job_context);
+    }
+    job_context.Clean();
+  }
+}
+
 void ForwardIterator::Cleanup(bool release_sv) {
   if (mutable_iter_ != nullptr) {
-    mutable_iter_->~Iterator();
+    mutable_iter_->~InternalIterator();
   }
   for (auto* m : imm_iters_) {
-    m->~Iterator();
+    m->~InternalIterator();
   }
   imm_iters_.clear();
   for (auto* f : l0_iters_) {
@@ -162,20 +179,7 @@ void ForwardIterator::Cleanup(bool release_sv) {
   level_iters_.clear();
 
   if (release_sv) {
-    if (sv_ != nullptr && sv_->Unref()) {
-      // Job id == 0 means that this is not our background process, but rather
-      // user thread
-      JobContext job_context(0);
-      db_->mutex_.Lock();
-      sv_->Cleanup();
-      db_->FindObsoleteFiles(&job_context, false, true);
-      db_->mutex_.Unlock();
-      delete sv_;
-      if (job_context.HaveSomethingToDelete()) {
-        db_->PurgeObsoleteFiles(job_context);
-      }
-      job_context.Clean();
-    }
+    SVCleanup();
   }
 }
 
@@ -185,9 +189,10 @@ bool ForwardIterator::Valid() const {
 }
 
 void ForwardIterator::SeekToFirst() {
-  if (sv_ == nullptr ||
-      sv_ ->version_number != cfd_->GetSuperVersionNumber()) {
+  if (sv_ == nullptr) {
     RebuildIterators(true);
+  } else if (sv_->version_number != cfd_->GetSuperVersionNumber()) {
+    RenewIterators();
   } else if (immutable_status_.IsIncomplete()) {
     ResetIncompleteIterators();
   }
@@ -205,9 +210,10 @@ void ForwardIterator::Seek(const Slice& internal_key) {
   if (IsOverUpperBound(internal_key)) {
     valid_ = false;
   }
-  if (sv_ == nullptr ||
-      sv_ ->version_number != cfd_->GetSuperVersionNumber()) {
+  if (sv_ == nullptr) {
     RebuildIterators(true);
+  } else if (sv_->version_number != cfd_->GetSuperVersionNumber()) {
+    RenewIterators();
   } else if (immutable_status_.IsIncomplete()) {
     ResetIncompleteIterators();
   }
@@ -227,7 +233,9 @@ void ForwardIterator::SeekInternal(const Slice& internal_key,
   // an option to turn it off.
   if (seek_to_first || NeedToSeekImmutable(internal_key)) {
     immutable_status_ = Status::OK();
-    if (has_iter_trimmed_for_upper_bound_) {
+    if ((has_iter_trimmed_for_upper_bound_) &&
+        (cfd_->internal_comparator().InternalKeyComparator::Compare(
+             prev_key_.GetKey(), internal_key) > 0)) {
       // Some iterators are trimmed. Need to rebuild.
       RebuildIterators(true);
       // Already seeked mutable iter, so seek again
@@ -393,7 +401,11 @@ void ForwardIterator::Next() {
     std::string current_key = key().ToString();
     Slice old_key(current_key.data(), current_key.size());
 
-    RebuildIterators(true);
+    if (sv_ == nullptr) {
+      RebuildIterators(true);
+    } else {
+      RenewIterators();
+    }
     SeekInternal(old_key, false);
     if (!valid_ || key().compare(old_key) != 0) {
       return;
@@ -484,10 +496,81 @@ void ForwardIterator::RebuildIterators(bool refresh_sv) {
     l0_iters_.push_back(cfd_->table_cache()->NewIterator(
         read_options_, *cfd_->soptions(), cfd_->internal_comparator(), l0->fd));
   }
+  BuildLevelIterators(vstorage);
+  current_ = nullptr;
+  is_prev_set_ = false;
+}
+
+void ForwardIterator::RenewIterators() {
+  SuperVersion* svnew;
+  assert(sv_);
+  svnew = cfd_->GetReferencedSuperVersion(&(db_->mutex_));
+
+  if (mutable_iter_ != nullptr) {
+    mutable_iter_->~InternalIterator();
+  }
+  for (auto* m : imm_iters_) {
+    m->~InternalIterator();
+  }
+  imm_iters_.clear();
+
+  mutable_iter_ = svnew->mem->NewIterator(read_options_, &arena_);
+  svnew->imm->AddIterators(read_options_, &imm_iters_, &arena_);
+
+  const auto* vstorage = sv_->current->storage_info();
+  const auto& l0_files = vstorage->LevelFiles(0);
+  const auto* vstorage_new = svnew->current->storage_info();
+  const auto& l0_files_new = vstorage_new->LevelFiles(0);
+  uint32_t iold, inew;
+  bool found;
+  std::vector<InternalIterator*> l0_iters_new;
+  l0_iters_new.reserve(l0_files_new.size());
+
+  for (inew = 0; inew < l0_files_new.size(); inew++) {
+    found = false;
+    for (iold = 0; iold < l0_files.size(); iold++) {
+      if (l0_files[iold] == l0_files_new[inew]) {
+        found = true;
+        break;
+      }
+    }
+    if (found) {
+      if (l0_iters_[iold] == nullptr) {
+        l0_iters_new.push_back(nullptr);
+        TEST_SYNC_POINT_CALLBACK("ForwardIterator::RenewIterators:Null", this);
+      } else {
+        l0_iters_new.push_back(l0_iters_[iold]);
+        l0_iters_[iold] = nullptr;
+        TEST_SYNC_POINT_CALLBACK("ForwardIterator::RenewIterators:Copy", this);
+      }
+      continue;
+    }
+    l0_iters_new.push_back(cfd_->table_cache()->NewIterator(
+        read_options_, *cfd_->soptions(), cfd_->internal_comparator(),
+        l0_files_new[inew]->fd));
+  }
+
+  for (auto* f : l0_iters_) {
+    delete f;
+  }
+  l0_iters_.clear();
+  l0_iters_ = l0_iters_new;
+
+  for (auto* l : level_iters_) {
+    delete l;
+  }
+  level_iters_.clear();
+  BuildLevelIterators(vstorage_new);
+  current_ = nullptr;
+  is_prev_set_ = false;
+  SVCleanup();
+  sv_ = svnew;
+}
+
+void ForwardIterator::BuildLevelIterators(const VersionStorageInfo* vstorage) {
   level_iters_.reserve(vstorage->num_levels() - 1);
   for (int32_t level = 1; level < vstorage->num_levels(); ++level) {
     const auto& level_files = vstorage->LevelFiles(level);
-
     if ((level_files.empty()) ||
         ((read_options_.iterate_upper_bound != nullptr) &&
          (user_comparator_->Compare(*read_options_.iterate_upper_bound,
@@ -502,9 +585,6 @@ void ForwardIterator::RebuildIterators(bool refresh_sv) {
           new LevelIterator(cfd_, read_options_, level_files));
     }
   }
-
-  current_ = nullptr;
-  is_prev_set_ = false;
 }
 
 void ForwardIterator::ResetIncompleteIterators() {
diff --git a/src/rocksdb/db/forward_iterator.h b/src/rocksdb/db/forward_iterator.h
index e6ef0bd..1c4d497 100644
--- a/src/rocksdb/db/forward_iterator.h
+++ b/src/rocksdb/db/forward_iterator.h
@@ -14,6 +14,7 @@
 #include "rocksdb/iterator.h"
 #include "rocksdb/options.h"
 #include "db/dbformat.h"
+#include "table/internal_iterator.h"
 #include "util/arena.h"
 
 namespace rocksdb {
@@ -23,6 +24,7 @@ class Env;
 struct SuperVersion;
 class ColumnFamilyData;
 class LevelIterator;
+class VersionStorageInfo;
 struct FileMetaData;
 
 class MinIterComparator {
@@ -30,16 +32,15 @@ class MinIterComparator {
   explicit MinIterComparator(const Comparator* comparator) :
     comparator_(comparator) {}
 
-  bool operator()(Iterator* a, Iterator* b) {
+  bool operator()(InternalIterator* a, InternalIterator* b) {
     return comparator_->Compare(a->key(), b->key()) > 0;
   }
  private:
   const Comparator* comparator_;
 };
 
-typedef std::priority_queue<Iterator*,
-          std::vector<Iterator*>,
-          MinIterComparator> MinIterHeap;
+typedef std::priority_queue<InternalIterator*, std::vector<InternalIterator*>,
+                            MinIterComparator> MinIterHeap;
 
 /**
  * ForwardIterator is a special type of iterator that only supports Seek()
@@ -48,7 +49,7 @@ typedef std::priority_queue<Iterator*,
  * the iterator. At the current implementation, snapshot is taken at the
  * time Seek() is called. The Next() followed do not see new values after.
  */
-class ForwardIterator : public Iterator {
+class ForwardIterator : public InternalIterator {
  public:
   ForwardIterator(DBImpl* db, const ReadOptions& read_options,
                   ColumnFamilyData* cfd, SuperVersion* current_sv = nullptr);
@@ -74,7 +75,10 @@ class ForwardIterator : public Iterator {
 
  private:
   void Cleanup(bool release_sv);
+  void SVCleanup();
   void RebuildIterators(bool refresh_sv);
+  void RenewIterators();
+  void BuildLevelIterators(const VersionStorageInfo* vstorage);
   void ResetIncompleteIterators();
   void SeekInternal(const Slice& internal_key, bool seek_to_first);
   void UpdateCurrent();
@@ -94,11 +98,11 @@ class ForwardIterator : public Iterator {
   MinIterHeap immutable_min_heap_;
 
   SuperVersion* sv_;
-  Iterator* mutable_iter_;
-  std::vector<Iterator*> imm_iters_;
-  std::vector<Iterator*> l0_iters_;
+  InternalIterator* mutable_iter_;
+  std::vector<InternalIterator*> imm_iters_;
+  std::vector<InternalIterator*> l0_iters_;
   std::vector<LevelIterator*> level_iters_;
-  Iterator* current_;
+  InternalIterator* current_;
   bool valid_;
 
   // Internal iterator status; set only by one of the unsupported methods.
diff --git a/src/rocksdb/db/forward_iterator_bench.cc b/src/rocksdb/db/forward_iterator_bench.cc
new file mode 100644
index 0000000..69833a4
--- /dev/null
+++ b/src/rocksdb/db/forward_iterator_bench.cc
@@ -0,0 +1,374 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
+#if !defined(GFLAGS) || defined(ROCKSDB_LITE)
+#include <cstdio>
+int main() {
+  fprintf(stderr, "Please install gflags to run rocksdb tools\n");
+  return 1;
+}
+#elif defined(OS_MACOSX) || defined(OS_WIN)
+// Block forward_iterator_bench under MAC and Windows
+int main() { return 0; }
+#else
+#include <gflags/gflags.h>
+#include <semaphore.h>
+#include <atomic>
+#include <bitset>
+#include <chrono>
+#include <climits>
+#include <condition_variable>
+#include <limits>
+#include <mutex>
+#include <queue>
+#include <random>
+#include <thread>
+
+#include "rocksdb/cache.h"
+#include "rocksdb/db.h"
+#include "rocksdb/status.h"
+#include "rocksdb/table.h"
+#include "util/testharness.h"
+
+const int MAX_SHARDS = 100000;
+
+DEFINE_int32(writers, 8, "");
+DEFINE_int32(readers, 8, "");
+DEFINE_int64(rate, 100000, "");
+DEFINE_int64(value_size, 300, "");
+DEFINE_int64(shards, 1000, "");
+DEFINE_int64(memtable_size, 500000000, "");
+DEFINE_int64(block_cache_size, 300000000, "");
+DEFINE_int64(block_size, 65536, "");
+DEFINE_double(runtime, 300.0, "");
+DEFINE_bool(cache_only_first, true, "");
+DEFINE_bool(iterate_upper_bound, true, "");
+
+struct Stats {
+  char pad1[128] __attribute__((__unused__));
+  std::atomic<uint64_t> written{0};
+  char pad2[128] __attribute__((__unused__));
+  std::atomic<uint64_t> read{0};
+  std::atomic<uint64_t> cache_misses{0};
+  char pad3[128] __attribute__((__unused__));
+} stats;
+
+struct Key {
+  Key() {}
+  Key(uint64_t shard_in, uint64_t seqno_in)
+      : shard_be(htobe64(shard_in)), seqno_be(htobe64(seqno_in)) {}
+
+  uint64_t shard() const { return be64toh(shard_be); }
+  uint64_t seqno() const { return be64toh(seqno_be); }
+
+ private:
+  uint64_t shard_be;
+  uint64_t seqno_be;
+} __attribute__((__packed__));
+
+struct Reader;
+struct Writer;
+
+struct ShardState {
+  char pad1[128] __attribute__((__unused__));
+  std::atomic<uint64_t> last_written{0};
+  Writer* writer;
+  Reader* reader;
+  char pad2[128] __attribute__((__unused__));
+  std::atomic<uint64_t> last_read{0};
+  std::unique_ptr<rocksdb::Iterator> it;
+  std::unique_ptr<rocksdb::Iterator> it_cacheonly;
+  Key upper_bound;
+  rocksdb::Slice upper_bound_slice;
+  char pad3[128] __attribute__((__unused__));
+};
+
+struct Reader {
+ public:
+  explicit Reader(std::vector<ShardState>* shard_states, rocksdb::DB* db)
+      : shard_states_(shard_states), db_(db) {
+    sem_init(&sem_, 0, 0);
+    thread_ = std::thread(&Reader::run, this);
+  }
+
+  void run() {
+    while (1) {
+      sem_wait(&sem_);
+      if (done_.load()) {
+        break;
+      }
+
+      uint64_t shard;
+      {
+        std::lock_guard<std::mutex> guard(queue_mutex_);
+        assert(!shards_pending_queue_.empty());
+        shard = shards_pending_queue_.front();
+        shards_pending_queue_.pop();
+        shards_pending_set_.reset(shard);
+      }
+      readOnceFromShard(shard);
+    }
+  }
+
+  void readOnceFromShard(uint64_t shard) {
+    ShardState& state = (*shard_states_)[shard];
+    if (!state.it) {
+      // Initialize iterators
+      rocksdb::ReadOptions options;
+      options.tailing = true;
+      if (FLAGS_iterate_upper_bound) {
+        state.upper_bound = Key(shard, std::numeric_limits<uint64_t>::max());
+        state.upper_bound_slice = rocksdb::Slice(
+            (const char*)&state.upper_bound, sizeof(state.upper_bound));
+        options.iterate_upper_bound = &state.upper_bound_slice;
+      }
+
+      state.it.reset(db_->NewIterator(options));
+
+      if (FLAGS_cache_only_first) {
+        options.read_tier = rocksdb::ReadTier::kBlockCacheTier;
+        state.it_cacheonly.reset(db_->NewIterator(options));
+      }
+    }
+
+    const uint64_t upto = state.last_written.load();
+    for (rocksdb::Iterator* it : {state.it_cacheonly.get(), state.it.get()}) {
+      if (it == nullptr) {
+        continue;
+      }
+      if (state.last_read.load() >= upto) {
+        break;
+      }
+      bool need_seek = true;
+      for (uint64_t seq = state.last_read.load() + 1; seq <= upto; ++seq) {
+        if (need_seek) {
+          Key from(shard, state.last_read.load() + 1);
+          it->Seek(rocksdb::Slice((const char*)&from, sizeof(from)));
+          need_seek = false;
+        } else {
+          it->Next();
+        }
+        if (it->status().IsIncomplete()) {
+          ++::stats.cache_misses;
+          break;
+        }
+        assert(it->Valid());
+        assert(it->key().size() == sizeof(Key));
+        Key key;
+        memcpy(&key, it->key().data(), it->key().size());
+        // fprintf(stderr, "Expecting (%ld, %ld) read (%ld, %ld)\n",
+        //         shard, seq, key.shard(), key.seqno());
+        assert(key.shard() == shard);
+        assert(key.seqno() == seq);
+        state.last_read.store(seq);
+        ++::stats.read;
+      }
+    }
+  }
+
+  void onWrite(uint64_t shard) {
+    {
+      std::lock_guard<std::mutex> guard(queue_mutex_);
+      if (!shards_pending_set_.test(shard)) {
+        shards_pending_queue_.push(shard);
+        shards_pending_set_.set(shard);
+        sem_post(&sem_);
+      }
+    }
+  }
+
+  ~Reader() {
+    done_.store(true);
+    sem_post(&sem_);
+    thread_.join();
+  }
+
+ private:
+  char pad1[128] __attribute__((__unused__));
+  std::vector<ShardState>* shard_states_;
+  rocksdb::DB* db_;
+  std::thread thread_;
+  sem_t sem_;
+  std::mutex queue_mutex_;
+  std::bitset<MAX_SHARDS + 1> shards_pending_set_;
+  std::queue<uint64_t> shards_pending_queue_;
+  std::atomic<bool> done_{false};
+  char pad2[128] __attribute__((__unused__));
+};
+
+struct Writer {
+  explicit Writer(std::vector<ShardState>* shard_states, rocksdb::DB* db)
+      : shard_states_(shard_states), db_(db) {}
+
+  void start() { thread_ = std::thread(&Writer::run, this); }
+
+  void run() {
+    std::queue<std::chrono::steady_clock::time_point> workq;
+    std::chrono::steady_clock::time_point deadline(
+        std::chrono::steady_clock::now() +
+        std::chrono::nanoseconds((uint64_t)(1000000000 * FLAGS_runtime)));
+    std::vector<uint64_t> my_shards;
+    for (int i = 1; i <= FLAGS_shards; ++i) {
+      if ((*shard_states_)[i].writer == this) {
+        my_shards.push_back(i);
+      }
+    }
+
+    std::mt19937 rng{std::random_device()()};
+    std::uniform_int_distribution<int> shard_dist(
+        0, static_cast<int>(my_shards.size()) - 1);
+    std::string value(FLAGS_value_size, '*');
+
+    while (1) {
+      auto now = std::chrono::steady_clock::now();
+      if (FLAGS_runtime >= 0 && now >= deadline) {
+        break;
+      }
+      if (workq.empty()) {
+        for (int i = 0; i < FLAGS_rate; i += FLAGS_writers) {
+          std::chrono::nanoseconds offset(1000000000LL * i / FLAGS_rate);
+          workq.push(now + offset);
+        }
+      }
+      while (!workq.empty() && workq.front() < now) {
+        workq.pop();
+        uint64_t shard = my_shards[shard_dist(rng)];
+        ShardState& state = (*shard_states_)[shard];
+        uint64_t seqno = state.last_written.load() + 1;
+        Key key(shard, seqno);
+        // fprintf(stderr, "Writing (%ld, %ld)\n", shard, seqno);
+        rocksdb::Status status =
+            db_->Put(rocksdb::WriteOptions(),
+                     rocksdb::Slice((const char*)&key, sizeof(key)),
+                     rocksdb::Slice(value));
+        assert(status.ok());
+        state.last_written.store(seqno);
+        state.reader->onWrite(shard);
+        ++::stats.written;
+      }
+      std::this_thread::sleep_for(std::chrono::milliseconds(1));
+    }
+    // fprintf(stderr, "Writer done\n");
+  }
+
+  ~Writer() { thread_.join(); }
+
+ private:
+  char pad1[128] __attribute__((__unused__));
+  std::vector<ShardState>* shard_states_;
+  rocksdb::DB* db_;
+  std::thread thread_;
+  char pad2[128] __attribute__((__unused__));
+};
+
+struct StatsThread {
+  explicit StatsThread(rocksdb::DB* db)
+      : db_(db), thread_(&StatsThread::run, this) {}
+
+  void run() {
+    //    using namespace std::chrono;
+    auto tstart = std::chrono::steady_clock::now(), tlast = tstart;
+    uint64_t wlast = 0, rlast = 0;
+    while (!done_.load()) {
+      {
+        std::unique_lock<std::mutex> lock(cvm_);
+        cv_.wait_for(lock, std::chrono::seconds(1));
+      }
+      auto now = std::chrono::steady_clock::now();
+      double elapsed =
+          std::chrono::duration_cast<std::chrono::duration<double> >(
+              now - tlast).count();
+      uint64_t w = ::stats.written.load();
+      uint64_t r = ::stats.read.load();
+      fprintf(stderr,
+              "%s elapsed %4lds | written %10ld | w/s %10.0f | read %10ld | "
+              "r/s %10.0f | cache misses %10ld\n",
+              db_->GetEnv()->TimeToString(time(nullptr)).c_str(),
+              std::chrono::duration_cast<std::chrono::seconds>(now - tstart)
+                  .count(),
+              w, (w - wlast) / elapsed, r, (r - rlast) / elapsed,
+              ::stats.cache_misses.load());
+      wlast = w;
+      rlast = r;
+      tlast = now;
+    }
+  }
+
+  ~StatsThread() {
+    {
+      std::lock_guard<std::mutex> guard(cvm_);
+      done_.store(true);
+    }
+    cv_.notify_all();
+    thread_.join();
+  }
+
+ private:
+  rocksdb::DB* db_;
+  std::mutex cvm_;
+  std::condition_variable cv_;
+  std::thread thread_;
+  std::atomic<bool> done_{false};
+};
+
+int main(int argc, char** argv) {
+  GFLAGS::ParseCommandLineFlags(&argc, &argv, true);
+
+  std::mt19937 rng{std::random_device()()};
+  rocksdb::Status status;
+  std::string path = rocksdb::test::TmpDir() + "/forward_iterator_test";
+  fprintf(stderr, "db path is %s\n", path.c_str());
+  rocksdb::Options options;
+  options.create_if_missing = true;
+  options.compression = rocksdb::CompressionType::kNoCompression;
+  options.compaction_style = rocksdb::CompactionStyle::kCompactionStyleNone;
+  options.level0_slowdown_writes_trigger = 99999;
+  options.level0_stop_writes_trigger = 99999;
+  options.allow_os_buffer = false;
+  options.write_buffer_size = FLAGS_memtable_size;
+  rocksdb::BlockBasedTableOptions table_options;
+  table_options.block_cache = rocksdb::NewLRUCache(FLAGS_block_cache_size);
+  table_options.block_size = FLAGS_block_size;
+  options.table_factory.reset(
+      rocksdb::NewBlockBasedTableFactory(table_options));
+
+  status = rocksdb::DestroyDB(path, options);
+  assert(status.ok());
+  rocksdb::DB* db_raw;
+  status = rocksdb::DB::Open(options, path, &db_raw);
+  assert(status.ok());
+  std::unique_ptr<rocksdb::DB> db(db_raw);
+
+  std::vector<ShardState> shard_states(FLAGS_shards + 1);
+  std::deque<Reader> readers;
+  while (static_cast<int>(readers.size()) < FLAGS_readers) {
+    readers.emplace_back(&shard_states, db_raw);
+  }
+  std::deque<Writer> writers;
+  while (static_cast<int>(writers.size()) < FLAGS_writers) {
+    writers.emplace_back(&shard_states, db_raw);
+  }
+
+  // Each shard gets a random reader and random writer assigned to it
+  for (int i = 1; i <= FLAGS_shards; ++i) {
+    std::uniform_int_distribution<int> reader_dist(0, FLAGS_readers - 1);
+    std::uniform_int_distribution<int> writer_dist(0, FLAGS_writers - 1);
+    shard_states[i].reader = &readers[reader_dist(rng)];
+    shard_states[i].writer = &writers[writer_dist(rng)];
+  }
+
+  StatsThread stats_thread(db_raw);
+  for (Writer& w : writers) {
+    w.start();
+  }
+
+  writers.clear();
+  readers.clear();
+}
+#endif  // !defined(GFLAGS) || defined(ROCKSDB_LITE)
diff --git a/src/rocksdb/db/skiplist.h b/src/rocksdb/db/inlineskiplist.h
similarity index 50%
copy from src/rocksdb/db/skiplist.h
copy to src/rocksdb/db/inlineskiplist.h
index 787fad5..a4fb5ab 100644
--- a/src/rocksdb/db/skiplist.h
+++ b/src/rocksdb/db/inlineskiplist.h
@@ -1,85 +1,102 @@
 //  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
 //  This source code is licensed under the BSD-style license found in the
-//  LICENSE file in the root directory of this source tree. An additional grant
-//  of patent rights can be found in the PATENTS file in the same directory.
+//  LICENSE file in the root directory of this source tree. An additional
+//  grant of patent rights can be found in the PATENTS file in the same
+//  directory.
 //
-// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file. See the AUTHORS file for names of contributors.
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.  Use of
+// this source code is governed by a BSD-style license that can be found
+// in the LICENSE file. See the AUTHORS file for names of contributors.
 //
-// Thread safety
-// -------------
+// InlineSkipList is derived from SkipList (skiplist.h), but it optimizes
+// the memory layout by requiring that the key storage be allocated through
+// the skip list instance.  For the common case of SkipList<const char*,
+// Cmp> this saves 1 pointer per skip list node and gives better cache
+// locality, at the expense of wasted padding from using AllocateAligned
+// instead of Allocate for the keys.  The unused padding will be from
+// 0 to sizeof(void*)-1 bytes, and the space savings are sizeof(void*)
+// bytes, so despite the padding the space used is always less than
+// SkipList<const char*, ..>.
 //
-// Writes require external synchronization, most likely a mutex.
-// Reads require a guarantee that the SkipList will not be destroyed
-// while the read is in progress.  Apart from that, reads progress
-// without any internal locking or synchronization.
+// Thread safety -------------
+//
+// Writes require external synchronization, most likely a mutex.  Reads
+// require a guarantee that the InlineSkipList will not be destroyed while
+// the read is in progress.  Apart from that, reads progress without any
+// internal locking or synchronization.
 //
 // Invariants:
 //
-// (1) Allocated nodes are never deleted until the SkipList is
-// destroyed.  This is trivially guaranteed by the code since we
-// never delete any skip list nodes.
+// (1) Allocated nodes are never deleted until the InlineSkipList is
+// destroyed.  This is trivially guaranteed by the code since we never
+// delete any skip list nodes.
 //
 // (2) The contents of a Node except for the next/prev pointers are
-// immutable after the Node has been linked into the SkipList.
-// Only Insert() modifies the list, and it is careful to initialize
-// a node and use release-stores to publish the nodes in one or
-// more lists.
+// immutable after the Node has been linked into the InlineSkipList.
+// Only Insert() modifies the list, and it is careful to initialize a
+// node and use release-stores to publish the nodes in one or more lists.
 //
 // ... prev vs. next pointer ordering ...
 //
 
 #pragma once
 #include <assert.h>
-#include <atomic>
 #include <stdlib.h>
+#include <atomic>
 #include "port/port.h"
 #include "util/allocator.h"
 #include "util/random.h"
 
 namespace rocksdb {
 
-template<typename Key, class Comparator>
-class SkipList {
+template <class Comparator>
+class InlineSkipList {
  private:
   struct Node;
 
  public:
-  // Create a new SkipList object that will use "cmp" for comparing keys,
-  // and will allocate memory using "*allocator".  Objects allocated in the
-  // allocator must remain allocated for the lifetime of the skiplist object.
-  explicit SkipList(Comparator cmp, Allocator* allocator,
-                    int32_t max_height = 12, int32_t branching_factor = 4);
-
-  // Insert key into the list.
+  // Create a new InlineSkipList object that will use "cmp" for comparing
+  // keys, and will allocate memory using "*allocator".  Objects allocated
+  // in the allocator must remain allocated for the lifetime of the
+  // skiplist object.
+  explicit InlineSkipList(Comparator cmp, Allocator* allocator,
+                          int32_t max_height = 12,
+                          int32_t branching_factor = 4);
+
+  // Allocates a key and a skip-list node, returning a pointer to the
+  // key portion of the node.
+  char* AllocateKey(size_t key_size);
+
+  // Inserts a key allocated by AllocateKey, after the actual key value
+  // has been filled in.
+  //
   // REQUIRES: nothing that compares equal to key is currently in the list.
-  void Insert(const Key& key);
+  void Insert(const char* key);
 
   // Returns true iff an entry that compares equal to key is in the list.
-  bool Contains(const Key& key) const;
+  bool Contains(const char* key) const;
 
   // Return estimated number of entries smaller than `key`.
-  uint64_t EstimateCount(const Key& key) const;
+  uint64_t EstimateCount(const char* key) const;
 
   // Iteration over the contents of a skip list
   class Iterator {
    public:
     // Initialize an iterator over the specified list.
     // The returned iterator is not valid.
-    explicit Iterator(const SkipList* list);
+    explicit Iterator(const InlineSkipList* list);
 
     // Change the underlying skiplist used for this iterator
     // This enables us not changing the iterator without deallocating
     // an old one and then allocating a new one
-    void SetList(const SkipList* list);
+    void SetList(const InlineSkipList* list);
 
     // Returns true iff the iterator is positioned at a valid node.
     bool Valid() const;
 
     // Returns the key at the current position.
     // REQUIRES: Valid()
-    const Key& key() const;
+    const char* key() const;
 
     // Advances to the next position.
     // REQUIRES: Valid()
@@ -90,7 +107,7 @@ class SkipList {
     void Prev();
 
     // Advance to the first entry with a key >= target
-    void Seek(const Key& target);
+    void Seek(const char* target);
 
     // Position at the first entry in list.
     // Final state of iterator is Valid() iff list is not empty.
@@ -101,18 +118,19 @@ class SkipList {
     void SeekToLast();
 
    private:
-    const SkipList* list_;
+    const InlineSkipList* list_;
     Node* node_;
     // Intentionally copyable
   };
 
  private:
-  const int32_t kMaxHeight_;
-  const int32_t kBranching_;
+  const uint16_t kMaxHeight_;
+  const uint16_t kBranching_;
+  const uint32_t kScaledInverseBranching_;
 
   // Immutable after construction
   Comparator const compare_;
-  Allocator* const allocator_;    // Allocator used for allocations of nodes
+  Allocator* const allocator_;  // Allocator used for allocations of nodes
 
   Node* const head_;
 
@@ -131,142 +149,163 @@ class SkipList {
     return max_height_.load(std::memory_order_relaxed);
   }
 
-  // Read/written only by Insert().
-  Random rnd_;
-
-  Node* NewNode(const Key& key, int height);
   int RandomHeight();
-  bool Equal(const Key& a, const Key& b) const { return (compare_(a, b) == 0); }
 
-  // Return true if key is greater than the data stored in "n"
-  bool KeyIsAfterNode(const Key& key, Node* n) const;
+  Node* AllocateNode(size_t key_size, int height);
+
+  bool Equal(const char* a, const char* b) const {
+    return (compare_(a, b) == 0);
+  }
+
+  // Return true if key is greater than the data stored in "n".  Null n
+  // is considered infinite.
+  bool KeyIsAfterNode(const char* key, Node* n) const;
 
   // Returns the earliest node with a key >= key.
   // Return nullptr if there is no such node.
-  Node* FindGreaterOrEqual(const Key& key) const;
+  Node* FindGreaterOrEqual(const char* key) const;
 
   // Return the latest node with a key < key.
   // Return head_ if there is no such node.
   // Fills prev[level] with pointer to previous node at "level" for every
   // level in [0..max_height_-1], if prev is non-null.
-  Node* FindLessThan(const Key& key, Node** prev = nullptr) const;
+  Node* FindLessThan(const char* key, Node** prev = nullptr) const;
 
   // Return the last node in the list.
   // Return head_ if list is empty.
   Node* FindLast() const;
 
   // No copying allowed
-  SkipList(const SkipList&);
-  void operator=(const SkipList&);
+  InlineSkipList(const InlineSkipList&);
+  InlineSkipList& operator=(const InlineSkipList&);
 };
 
 // Implementation details follow
-template<typename Key, class Comparator>
-struct SkipList<Key, Comparator>::Node {
-  explicit Node(const Key& k) : key(k) { }
 
-  Key const key;
+// The Node data type is more of a pointer into custom-managed memory than
+// a traditional C++ struct.  The key is stored in the bytes immediately
+// after the struct, and the next_ pointers for nodes with height > 1 are
+// stored immediately _before_ the struct.  This avoids the need to include
+// any pointer or sizing data, which reduces per-node memory overheads.
+template <class Comparator>
+struct InlineSkipList<Comparator>::Node {
+  // Stores the height of the node in the memory location normally used for
+  // next_[0].  This is used for passing data from AllocateKey to Insert.
+  void StashHeight(const int height) {
+    assert(sizeof(int) <= sizeof(next_[0]));
+    memcpy(&next_[0], &height, sizeof(int));
+  }
+
+  // Retrieves the value passed to StashHeight.  Undefined after a call
+  // to SetNext or NoBarrier_SetNext.
+  int UnstashHeight() const {
+    int rv;
+    memcpy(&rv, &next_[0], sizeof(int));
+    return rv;
+  }
+
+  const char* Key() const { return reinterpret_cast<const char*>(&next_[1]); }
 
-  // Accessors/mutators for links.  Wrapped in methods so we can
-  // add the appropriate barriers as necessary.
+  // Accessors/mutators for links.  Wrapped in methods so we can add
+  // the appropriate barriers as necessary, and perform the necessary
+  // addressing trickery for storing links below the Node in memory.
   Node* Next(int n) {
     assert(n >= 0);
     // Use an 'acquire load' so that we observe a fully initialized
     // version of the returned Node.
-    return (next_[n].load(std::memory_order_acquire));
+    return (next_[-n].load(std::memory_order_acquire));
   }
+
   void SetNext(int n, Node* x) {
     assert(n >= 0);
     // Use a 'release store' so that anybody who reads through this
     // pointer observes a fully initialized version of the inserted node.
-    next_[n].store(x, std::memory_order_release);
+    next_[-n].store(x, std::memory_order_release);
   }
 
   // No-barrier variants that can be safely used in a few locations.
   Node* NoBarrier_Next(int n) {
     assert(n >= 0);
-    return next_[n].load(std::memory_order_relaxed);
+    return next_[-n].load(std::memory_order_relaxed);
   }
+
   void NoBarrier_SetNext(int n, Node* x) {
     assert(n >= 0);
-    next_[n].store(x, std::memory_order_relaxed);
+    next_[-n].store(x, std::memory_order_relaxed);
   }
 
  private:
-  // Array of length equal to the node height.  next_[0] is lowest level link.
+  // next_[0] is the lowest level link (level 0).  Higher levels are
+  // stored _earlier_, so level 1 is at next_[-1].
   std::atomic<Node*> next_[1];
 };
 
-template<typename Key, class Comparator>
-typename SkipList<Key, Comparator>::Node*
-SkipList<Key, Comparator>::NewNode(const Key& key, int height) {
-  char* mem = allocator_->AllocateAligned(
-      sizeof(Node) + sizeof(std::atomic<Node*>) * (height - 1));
-  return new (mem) Node(key);
-}
-
-template<typename Key, class Comparator>
-inline SkipList<Key, Comparator>::Iterator::Iterator(const SkipList* list) {
+template <class Comparator>
+inline InlineSkipList<Comparator>::Iterator::Iterator(
+    const InlineSkipList* list) {
   SetList(list);
 }
 
-template<typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::SetList(const SkipList* list) {
+template <class Comparator>
+inline void InlineSkipList<Comparator>::Iterator::SetList(
+    const InlineSkipList* list) {
   list_ = list;
   node_ = nullptr;
 }
 
-template<typename Key, class Comparator>
-inline bool SkipList<Key, Comparator>::Iterator::Valid() const {
+template <class Comparator>
+inline bool InlineSkipList<Comparator>::Iterator::Valid() const {
   return node_ != nullptr;
 }
 
-template<typename Key, class Comparator>
-inline const Key& SkipList<Key, Comparator>::Iterator::key() const {
+template <class Comparator>
+inline const char* InlineSkipList<Comparator>::Iterator::key() const {
   assert(Valid());
-  return node_->key;
+  return node_->Key();
 }
 
-template<typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::Next() {
+template <class Comparator>
+inline void InlineSkipList<Comparator>::Iterator::Next() {
   assert(Valid());
   node_ = node_->Next(0);
 }
 
-template<typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::Prev() {
+template <class Comparator>
+inline void InlineSkipList<Comparator>::Iterator::Prev() {
   // Instead of using explicit "prev" links, we just search for the
   // last node that falls before key.
   assert(Valid());
-  node_ = list_->FindLessThan(node_->key);
+  node_ = list_->FindLessThan(node_->Key());
   if (node_ == list_->head_) {
     node_ = nullptr;
   }
 }
 
-template<typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::Seek(const Key& target) {
+template <class Comparator>
+inline void InlineSkipList<Comparator>::Iterator::Seek(const char* target) {
   node_ = list_->FindGreaterOrEqual(target);
 }
 
-template<typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::SeekToFirst() {
+template <class Comparator>
+inline void InlineSkipList<Comparator>::Iterator::SeekToFirst() {
   node_ = list_->head_->Next(0);
 }
 
-template<typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::SeekToLast() {
+template <class Comparator>
+inline void InlineSkipList<Comparator>::Iterator::SeekToLast() {
   node_ = list_->FindLast();
   if (node_ == list_->head_) {
     node_ = nullptr;
   }
 }
 
-template<typename Key, class Comparator>
-int SkipList<Key, Comparator>::RandomHeight() {
+template <class Comparator>
+int InlineSkipList<Comparator>::RandomHeight() {
+  auto rnd = Random::GetTLSInstance();
+
   // Increase height with probability 1 in kBranching
   int height = 1;
-  while (height < kMaxHeight_ && ((rnd_.Next() % kBranching_) == 0)) {
+  while (height < kMaxHeight_ && rnd->Next() < kScaledInverseBranching_) {
     height++;
   }
   assert(height > 0);
@@ -274,15 +313,16 @@ int SkipList<Key, Comparator>::RandomHeight() {
   return height;
 }
 
-template<typename Key, class Comparator>
-bool SkipList<Key, Comparator>::KeyIsAfterNode(const Key& key, Node* n) const {
+template <class Comparator>
+bool InlineSkipList<Comparator>::KeyIsAfterNode(const char* key,
+                                                Node* n) const {
   // nullptr n is considered infinite
-  return (n != nullptr) && (compare_(n->key, key) < 0);
+  return (n != nullptr) && (compare_(n->Key(), key) < 0);
 }
 
-template<typename Key, class Comparator>
-typename SkipList<Key, Comparator>::Node* SkipList<Key, Comparator>::
-  FindGreaterOrEqual(const Key& key) const {
+template <class Comparator>
+typename InlineSkipList<Comparator>::Node*
+InlineSkipList<Comparator>::FindGreaterOrEqual(const char* key) const {
   // Note: It looks like we could reduce duplication by implementing
   // this function as FindLessThan(key)->Next(0), but we wouldn't be able
   // to exit early on equality and the result wouldn't even be correct.
@@ -294,11 +334,12 @@ typename SkipList<Key, Comparator>::Node* SkipList<Key, Comparator>::
   while (true) {
     Node* next = x->Next(level);
     // Make sure the lists are sorted
-    assert(x == head_ || next == nullptr || KeyIsAfterNode(next->key, x));
+    assert(x == head_ || next == nullptr || KeyIsAfterNode(next->Key(), x));
     // Make sure we haven't overshot during our search
     assert(x == head_ || KeyIsAfterNode(key, x));
     int cmp = (next == nullptr || next == last_bigger)
-        ? 1 : compare_(next->key, key);
+                  ? 1
+                  : compare_(next->Key(), key);
     if (cmp == 0 || (cmp > 0 && level == 0)) {
       return next;
     } else if (cmp < 0) {
@@ -312,16 +353,16 @@ typename SkipList<Key, Comparator>::Node* SkipList<Key, Comparator>::
   }
 }
 
-template<typename Key, class Comparator>
-typename SkipList<Key, Comparator>::Node*
-SkipList<Key, Comparator>::FindLessThan(const Key& key, Node** prev) const {
+template <class Comparator>
+typename InlineSkipList<Comparator>::Node*
+InlineSkipList<Comparator>::FindLessThan(const char* key, Node** prev) const {
   Node* x = head_;
   int level = GetMaxHeight() - 1;
   // KeyIsAfter(key, last_not_after) is definitely false
   Node* last_not_after = nullptr;
   while (true) {
     Node* next = x->Next(level);
-    assert(x == head_ || next == nullptr || KeyIsAfterNode(next->key, x));
+    assert(x == head_ || next == nullptr || KeyIsAfterNode(next->Key(), x));
     assert(x == head_ || KeyIsAfterNode(key, x));
     if (next != last_not_after && KeyIsAfterNode(key, next)) {
       // Keep searching in this list
@@ -341,9 +382,9 @@ SkipList<Key, Comparator>::FindLessThan(const Key& key, Node** prev) const {
   }
 }
 
-template<typename Key, class Comparator>
-typename SkipList<Key, Comparator>::Node* SkipList<Key, Comparator>::FindLast()
-    const {
+template <class Comparator>
+typename InlineSkipList<Comparator>::Node*
+InlineSkipList<Comparator>::FindLast() const {
   Node* x = head_;
   int level = GetMaxHeight() - 1;
   while (true) {
@@ -361,16 +402,16 @@ typename SkipList<Key, Comparator>::Node* SkipList<Key, Comparator>::FindLast()
   }
 }
 
-template <typename Key, class Comparator>
-uint64_t SkipList<Key, Comparator>::EstimateCount(const Key& key) const {
+template <class Comparator>
+uint64_t InlineSkipList<Comparator>::EstimateCount(const char* key) const {
   uint64_t count = 0;
 
   Node* x = head_;
   int level = GetMaxHeight() - 1;
   while (true) {
-    assert(x == head_ || compare_(x->key, key) < 0);
+    assert(x == head_ || compare_(x->Key(), key) < 0);
     Node* next = x->Next(level);
-    if (next == nullptr || compare_(next->key, key) >= 0) {
+    if (next == nullptr || compare_(next->Key(), key) >= 0) {
       if (level == 0) {
         return count;
       } else {
@@ -385,33 +426,65 @@ uint64_t SkipList<Key, Comparator>::EstimateCount(const Key& key) const {
   }
 }
 
-template <typename Key, class Comparator>
-SkipList<Key, Comparator>::SkipList(const Comparator cmp, Allocator* allocator,
-                                    int32_t max_height,
-                                    int32_t branching_factor)
+template <class Comparator>
+InlineSkipList<Comparator>::InlineSkipList(const Comparator cmp,
+                                           Allocator* allocator,
+                                           int32_t max_height,
+                                           int32_t branching_factor)
     : kMaxHeight_(max_height),
       kBranching_(branching_factor),
+      kScaledInverseBranching_((Random::kMaxNext + 1) / kBranching_),
       compare_(cmp),
       allocator_(allocator),
-      head_(NewNode(0 /* any key will do */, max_height)),
+      head_(AllocateNode(0, max_height)),
       max_height_(1),
-      prev_height_(1),
-      rnd_(0xdeadbeef) {
-  assert(kMaxHeight_ > 0);
-  assert(kBranching_ > 0);
+      prev_height_(1) {
+  assert(max_height > 0 && kMaxHeight_ == static_cast<uint32_t>(max_height));
+  assert(branching_factor > 0 &&
+         kBranching_ == static_cast<uint32_t>(branching_factor));
+  assert(kScaledInverseBranching_ > 0);
   // Allocate the prev_ Node* array, directly from the passed-in allocator.
   // prev_ does not need to be freed, as its life cycle is tied up with
   // the allocator as a whole.
   prev_ = reinterpret_cast<Node**>(
-            allocator_->AllocateAligned(sizeof(Node*) * kMaxHeight_));
+      allocator_->AllocateAligned(sizeof(Node*) * kMaxHeight_));
   for (int i = 0; i < kMaxHeight_; i++) {
     head_->SetNext(i, nullptr);
     prev_[i] = head_;
   }
 }
 
-template<typename Key, class Comparator>
-void SkipList<Key, Comparator>::Insert(const Key& key) {
+template <class Comparator>
+char* InlineSkipList<Comparator>::AllocateKey(size_t key_size) {
+  return const_cast<char*>(AllocateNode(key_size, RandomHeight())->Key());
+}
+
+template <class Comparator>
+typename InlineSkipList<Comparator>::Node*
+InlineSkipList<Comparator>::AllocateNode(size_t key_size, int height) {
+  auto prefix = sizeof(std::atomic<Node*>) * (height - 1);
+
+  // prefix is space for the height - 1 pointers that we store before
+  // the Node instance (next_[-(height - 1) .. -1]).  Node starts at
+  // raw + prefix, and holds the bottom-mode (level 0) skip list pointer
+  // next_[0].  key_size is the bytes for the key, which comes just after
+  // the Node.
+  char* raw = allocator_->AllocateAligned(prefix + sizeof(Node) + key_size);
+  Node* x = reinterpret_cast<Node*>(raw + prefix);
+
+  // Once we've linked the node into the skip list we don't actually need
+  // to know its height, because we can implicitly use the fact that we
+  // traversed into a node at level h to known that h is a valid level
+  // for that node.  We need to convey the height to the Insert step,
+  // however, so that it can perform the proper links.  Since we're not
+  // using the pointers at the moment, StashHeight temporarily borrow
+  // storage from next_[0] for that purpose.
+  x->StashHeight(height);
+  return x;
+}
+
+template <class Comparator>
+void InlineSkipList<Comparator>::Insert(const char* key) {
   // fast path for sequential insertion
   if (!KeyIsAfterNode(key, prev_[0]->NoBarrier_Next(0)) &&
       (prev_[0] == head_ || KeyIsAfterNode(key, prev_[0]))) {
@@ -432,14 +505,17 @@ void SkipList<Key, Comparator>::Insert(const Key& key) {
   }
 
   // Our data structure does not allow duplicate insertion
-  assert(prev_[0]->Next(0) == nullptr || !Equal(key, prev_[0]->Next(0)->key));
+  assert(prev_[0]->Next(0) == nullptr || !Equal(key, prev_[0]->Next(0)->Key()));
+
+  // Find the Node that we placed before the key in AllocateKey
+  Node* x = reinterpret_cast<Node*>(const_cast<char*>(key)) - 1;
+  int height = x->UnstashHeight();
+  assert(height >= 1 && height <= kMaxHeight_);
 
-  int height = RandomHeight();
   if (height > GetMaxHeight()) {
     for (int i = GetMaxHeight(); i < height; i++) {
       prev_[i] = head_;
     }
-    //fprintf(stderr, "Change height from %d to %d\n", max_height_, height);
 
     // It is ok to mutate max_height_ without any synchronization
     // with concurrent readers.  A concurrent reader that observes
@@ -451,7 +527,6 @@ void SkipList<Key, Comparator>::Insert(const Key& key) {
     max_height_.store(height, std::memory_order_relaxed);
   }
 
-  Node* x = NewNode(key, height);
   for (int i = 0; i < height; i++) {
     // NoBarrier_SetNext() suffices since we will add a barrier when
     // we publish a pointer to "x" in prev[i].
@@ -462,10 +537,10 @@ void SkipList<Key, Comparator>::Insert(const Key& key) {
   prev_height_ = height;
 }
 
-template<typename Key, class Comparator>
-bool SkipList<Key, Comparator>::Contains(const Key& key) const {
+template <class Comparator>
+bool InlineSkipList<Comparator>::Contains(const char* key) const {
   Node* x = FindGreaterOrEqual(key);
-  if (x != nullptr && Equal(key, x->key)) {
+  if (x != nullptr && Equal(key, x->Key())) {
     return true;
   } else {
     return false;
diff --git a/src/rocksdb/db/inlineskiplist_test.cc b/src/rocksdb/db/inlineskiplist_test.cc
new file mode 100644
index 0000000..70fd97a
--- /dev/null
+++ b/src/rocksdb/db/inlineskiplist_test.cc
@@ -0,0 +1,391 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+
+#include "db/inlineskiplist.h"
+#include <set>
+#include "rocksdb/env.h"
+#include "util/arena.h"
+#include "util/hash.h"
+#include "util/random.h"
+#include "util/testharness.h"
+
+namespace rocksdb {
+
+// Our test skip list stores 8-byte unsigned integers
+typedef uint64_t Key;
+
+static const char* Encode(const uint64_t* key) {
+  return reinterpret_cast<const char*>(key);
+}
+
+static Key Decode(const char* key) {
+  Key rv;
+  memcpy(&rv, key, sizeof(Key));
+  return rv;
+}
+
+struct TestComparator {
+  int operator()(const char* a, const char* b) const {
+    if (Decode(a) < Decode(b)) {
+      return -1;
+    } else if (Decode(a) > Decode(b)) {
+      return +1;
+    } else {
+      return 0;
+    }
+  }
+};
+
+class InlineSkipTest : public testing::Test {};
+
+TEST_F(InlineSkipTest, Empty) {
+  Arena arena;
+  TestComparator cmp;
+  InlineSkipList<TestComparator> list(cmp, &arena);
+  Key key = 10;
+  ASSERT_TRUE(!list.Contains(Encode(&key)));
+
+  InlineSkipList<TestComparator>::Iterator iter(&list);
+  ASSERT_TRUE(!iter.Valid());
+  iter.SeekToFirst();
+  ASSERT_TRUE(!iter.Valid());
+  key = 100;
+  iter.Seek(Encode(&key));
+  ASSERT_TRUE(!iter.Valid());
+  iter.SeekToLast();
+  ASSERT_TRUE(!iter.Valid());
+}
+
+TEST_F(InlineSkipTest, InsertAndLookup) {
+  const int N = 2000;
+  const int R = 5000;
+  Random rnd(1000);
+  std::set<Key> keys;
+  Arena arena;
+  TestComparator cmp;
+  InlineSkipList<TestComparator> list(cmp, &arena);
+  for (int i = 0; i < N; i++) {
+    Key key = rnd.Next() % R;
+    if (keys.insert(key).second) {
+      char* buf = list.AllocateKey(sizeof(Key));
+      memcpy(buf, &key, sizeof(Key));
+      list.Insert(buf);
+    }
+  }
+
+  for (Key i = 0; i < R; i++) {
+    if (list.Contains(Encode(&i))) {
+      ASSERT_EQ(keys.count(i), 1U);
+    } else {
+      ASSERT_EQ(keys.count(i), 0U);
+    }
+  }
+
+  // Simple iterator tests
+  {
+    InlineSkipList<TestComparator>::Iterator iter(&list);
+    ASSERT_TRUE(!iter.Valid());
+
+    uint64_t zero = 0;
+    iter.Seek(Encode(&zero));
+    ASSERT_TRUE(iter.Valid());
+    ASSERT_EQ(*(keys.begin()), Decode(iter.key()));
+
+    iter.SeekToFirst();
+    ASSERT_TRUE(iter.Valid());
+    ASSERT_EQ(*(keys.begin()), Decode(iter.key()));
+
+    iter.SeekToLast();
+    ASSERT_TRUE(iter.Valid());
+    ASSERT_EQ(*(keys.rbegin()), Decode(iter.key()));
+  }
+
+  // Forward iteration test
+  for (Key i = 0; i < R; i++) {
+    InlineSkipList<TestComparator>::Iterator iter(&list);
+    iter.Seek(Encode(&i));
+
+    // Compare against model iterator
+    std::set<Key>::iterator model_iter = keys.lower_bound(i);
+    for (int j = 0; j < 3; j++) {
+      if (model_iter == keys.end()) {
+        ASSERT_TRUE(!iter.Valid());
+        break;
+      } else {
+        ASSERT_TRUE(iter.Valid());
+        ASSERT_EQ(*model_iter, Decode(iter.key()));
+        ++model_iter;
+        iter.Next();
+      }
+    }
+  }
+
+  // Backward iteration test
+  {
+    InlineSkipList<TestComparator>::Iterator iter(&list);
+    iter.SeekToLast();
+
+    // Compare against model iterator
+    for (std::set<Key>::reverse_iterator model_iter = keys.rbegin();
+         model_iter != keys.rend(); ++model_iter) {
+      ASSERT_TRUE(iter.Valid());
+      ASSERT_EQ(*model_iter, Decode(iter.key()));
+      iter.Prev();
+    }
+    ASSERT_TRUE(!iter.Valid());
+  }
+}
+
+// We want to make sure that with a single writer and multiple
+// concurrent readers (with no synchronization other than when a
+// reader's iterator is created), the reader always observes all the
+// data that was present in the skip list when the iterator was
+// constructor.  Because insertions are happening concurrently, we may
+// also observe new values that were inserted since the iterator was
+// constructed, but we should never miss any values that were present
+// at iterator construction time.
+//
+// We generate multi-part keys:
+//     <key,gen,hash>
+// where:
+//     key is in range [0..K-1]
+//     gen is a generation number for key
+//     hash is hash(key,gen)
+//
+// The insertion code picks a random key, sets gen to be 1 + the last
+// generation number inserted for that key, and sets hash to Hash(key,gen).
+//
+// At the beginning of a read, we snapshot the last inserted
+// generation number for each key.  We then iterate, including random
+// calls to Next() and Seek().  For every key we encounter, we
+// check that it is either expected given the initial snapshot or has
+// been concurrently added since the iterator started.
+class ConcurrentTest {
+ private:
+  static const uint32_t K = 4;
+
+  static uint64_t key(Key key) { return (key >> 40); }
+  static uint64_t gen(Key key) { return (key >> 8) & 0xffffffffu; }
+  static uint64_t hash(Key key) { return key & 0xff; }
+
+  static uint64_t HashNumbers(uint64_t k, uint64_t g) {
+    uint64_t data[2] = {k, g};
+    return Hash(reinterpret_cast<char*>(data), sizeof(data), 0);
+  }
+
+  static Key MakeKey(uint64_t k, uint64_t g) {
+    assert(sizeof(Key) == sizeof(uint64_t));
+    assert(k <= K);  // We sometimes pass K to seek to the end of the skiplist
+    assert(g <= 0xffffffffu);
+    return ((k << 40) | (g << 8) | (HashNumbers(k, g) & 0xff));
+  }
+
+  static bool IsValidKey(Key k) {
+    return hash(k) == (HashNumbers(key(k), gen(k)) & 0xff);
+  }
+
+  static Key RandomTarget(Random* rnd) {
+    switch (rnd->Next() % 10) {
+      case 0:
+        // Seek to beginning
+        return MakeKey(0, 0);
+      case 1:
+        // Seek to end
+        return MakeKey(K, 0);
+      default:
+        // Seek to middle
+        return MakeKey(rnd->Next() % K, 0);
+    }
+  }
+
+  // Per-key generation
+  struct State {
+    std::atomic<int> generation[K];
+    void Set(int k, int v) {
+      generation[k].store(v, std::memory_order_release);
+    }
+    int Get(int k) { return generation[k].load(std::memory_order_acquire); }
+
+    State() {
+      for (unsigned int k = 0; k < K; k++) {
+        Set(k, 0);
+      }
+    }
+  };
+
+  // Current state of the test
+  State current_;
+
+  Arena arena_;
+
+  // InlineSkipList is not protected by mu_.  We just use a single writer
+  // thread to modify it.
+  InlineSkipList<TestComparator> list_;
+
+ public:
+  ConcurrentTest() : list_(TestComparator(), &arena_) {}
+
+  // REQUIRES: External synchronization
+  void WriteStep(Random* rnd) {
+    const uint32_t k = rnd->Next() % K;
+    const int g = current_.Get(k) + 1;
+    const Key new_key = MakeKey(k, g);
+    char* buf = list_.AllocateKey(sizeof(Key));
+    memcpy(buf, &new_key, sizeof(Key));
+    list_.Insert(buf);
+    current_.Set(k, g);
+  }
+
+  void ReadStep(Random* rnd) {
+    // Remember the initial committed state of the skiplist.
+    State initial_state;
+    for (unsigned int k = 0; k < K; k++) {
+      initial_state.Set(k, current_.Get(k));
+    }
+
+    Key pos = RandomTarget(rnd);
+    InlineSkipList<TestComparator>::Iterator iter(&list_);
+    iter.Seek(Encode(&pos));
+    while (true) {
+      Key current;
+      if (!iter.Valid()) {
+        current = MakeKey(K, 0);
+      } else {
+        current = Decode(iter.key());
+        ASSERT_TRUE(IsValidKey(current)) << current;
+      }
+      ASSERT_LE(pos, current) << "should not go backwards";
+
+      // Verify that everything in [pos,current) was not present in
+      // initial_state.
+      while (pos < current) {
+        ASSERT_LT(key(pos), K) << pos;
+
+        // Note that generation 0 is never inserted, so it is ok if
+        // <*,0,*> is missing.
+        ASSERT_TRUE((gen(pos) == 0U) ||
+                    (gen(pos) > static_cast<uint64_t>(initial_state.Get(
+                                    static_cast<int>(key(pos))))))
+            << "key: " << key(pos) << "; gen: " << gen(pos)
+            << "; initgen: " << initial_state.Get(static_cast<int>(key(pos)));
+
+        // Advance to next key in the valid key space
+        if (key(pos) < key(current)) {
+          pos = MakeKey(key(pos) + 1, 0);
+        } else {
+          pos = MakeKey(key(pos), gen(pos) + 1);
+        }
+      }
+
+      if (!iter.Valid()) {
+        break;
+      }
+
+      if (rnd->Next() % 2) {
+        iter.Next();
+        pos = MakeKey(key(pos), gen(pos) + 1);
+      } else {
+        Key new_target = RandomTarget(rnd);
+        if (new_target > pos) {
+          pos = new_target;
+          iter.Seek(Encode(&new_target));
+        }
+      }
+    }
+  }
+};
+const uint32_t ConcurrentTest::K;
+
+// Simple test that does single-threaded testing of the ConcurrentTest
+// scaffolding.
+TEST_F(InlineSkipTest, ConcurrentWithoutThreads) {
+  ConcurrentTest test;
+  Random rnd(test::RandomSeed());
+  for (int i = 0; i < 10000; i++) {
+    test.ReadStep(&rnd);
+    test.WriteStep(&rnd);
+  }
+}
+
+class TestState {
+ public:
+  ConcurrentTest t_;
+  int seed_;
+  std::atomic<bool> quit_flag_;
+
+  enum ReaderState { STARTING, RUNNING, DONE };
+
+  explicit TestState(int s)
+      : seed_(s), quit_flag_(false), state_(STARTING), state_cv_(&mu_) {}
+
+  void Wait(ReaderState s) {
+    mu_.Lock();
+    while (state_ != s) {
+      state_cv_.Wait();
+    }
+    mu_.Unlock();
+  }
+
+  void Change(ReaderState s) {
+    mu_.Lock();
+    state_ = s;
+    state_cv_.Signal();
+    mu_.Unlock();
+  }
+
+ private:
+  port::Mutex mu_;
+  ReaderState state_;
+  port::CondVar state_cv_;
+};
+
+static void ConcurrentReader(void* arg) {
+  TestState* state = reinterpret_cast<TestState*>(arg);
+  Random rnd(state->seed_);
+  int64_t reads = 0;
+  state->Change(TestState::RUNNING);
+  while (!state->quit_flag_.load(std::memory_order_acquire)) {
+    state->t_.ReadStep(&rnd);
+    ++reads;
+  }
+  state->Change(TestState::DONE);
+}
+
+static void RunConcurrent(int run) {
+  const int seed = test::RandomSeed() + (run * 100);
+  Random rnd(seed);
+  const int N = 1000;
+  const int kSize = 1000;
+  for (int i = 0; i < N; i++) {
+    if ((i % 100) == 0) {
+      fprintf(stderr, "Run %d of %d\n", i, N);
+    }
+    TestState state(seed + 1);
+    Env::Default()->Schedule(ConcurrentReader, &state);
+    state.Wait(TestState::RUNNING);
+    for (int k = 0; k < kSize; k++) {
+      state.t_.WriteStep(&rnd);
+    }
+    state.quit_flag_.store(true, std::memory_order_release);
+    state.Wait(TestState::DONE);
+  }
+}
+
+TEST_F(InlineSkipTest, Concurrent1) { RunConcurrent(1); }
+TEST_F(InlineSkipTest, Concurrent2) { RunConcurrent(2); }
+TEST_F(InlineSkipTest, Concurrent3) { RunConcurrent(3); }
+TEST_F(InlineSkipTest, Concurrent4) { RunConcurrent(4); }
+TEST_F(InlineSkipTest, Concurrent5) { RunConcurrent(5); }
+
+}  // namespace rocksdb
+
+int main(int argc, char** argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
diff --git a/src/rocksdb/db/internal_stats.cc b/src/rocksdb/db/internal_stats.cc
index 4e37c1d..417c88c 100644
--- a/src/rocksdb/db/internal_stats.cc
+++ b/src/rocksdb/db/internal_stats.cc
@@ -35,8 +35,7 @@ void PrintLevelStatsHeader(char* buf, size_t len, const std::string& cf_name) {
       "\n** Compaction Stats [%s] **\n"
       "Level    Files   Size(MB) Score Read(GB)  Rn(GB) Rnp1(GB) "
       "Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) "
-      "Comp(sec) Comp(cnt) Avg(sec) "
-      "Stall(cnt)  KeyIn KeyDrop\n"
+      "Comp(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop\n"
       "--------------------------------------------------------------------"
       "-----------------------------------------------------------"
       "--------------------------------------\n",
@@ -44,9 +43,9 @@ void PrintLevelStatsHeader(char* buf, size_t len, const std::string& cf_name) {
 }
 
 void PrintLevelStats(char* buf, size_t len, const std::string& name,
-    int num_files, int being_compacted, double total_file_size, double score,
-    double w_amp, uint64_t stalls,
-    const InternalStats::CompactionStats& stats) {
+                     int num_files, int being_compacted, double total_file_size,
+                     double score, double w_amp,
+                     const InternalStats::CompactionStats& stats) {
   uint64_t bytes_read =
       stats.bytes_read_non_output_levels + stats.bytes_read_output_level;
   int64_t bytes_new =
@@ -70,10 +69,8 @@ void PrintLevelStats(char* buf, size_t len, const std::string& name,
            "%9.0f "                    /* Comp(sec) */
            "%9d "                      /* Comp(cnt) */
            "%8.3f "                    /* Avg(sec) */
-           "%10" PRIu64
-           " "      /* Stall(cnt) */
-           "%7s "   /* KeyIn */
-           "%6s\n", /* KeyDrop */
+           "%7s "                      /* KeyIn */
+           "%6s\n",                    /* KeyDrop */
            name.c_str(),
            num_files, being_compacted, total_file_size / kMB, score,
            bytes_read / kGB, stats.bytes_read_non_output_levels / kGB,
@@ -82,7 +79,7 @@ void PrintLevelStats(char* buf, size_t len, const std::string& name,
            bytes_read / kMB / elapsed, stats.bytes_written / kMB / elapsed,
            stats.micros / kMicrosInSec, stats.count,
            stats.count == 0 ? 0 : stats.micros / kMicrosInSec / stats.count,
-           stalls, num_input_records.c_str(), num_dropped_records.c_str());
+           num_input_records.c_str(), num_dropped_records.c_str());
 }
 }
 
@@ -130,6 +127,8 @@ static const std::string aggregated_table_properties =
     "aggregated-table-properties";
 static const std::string aggregated_table_properties_at_level =
     aggregated_table_properties + "-at-level";
+static const std::string num_running_compactions = "num-running-compactions";
+static const std::string num_running_flushes = "num-running-flushes";
 
 const std::string DB::Properties::kNumFilesAtLevelPrefix =
                       rocksdb_prefix + num_files_at_level_prefix;
@@ -143,6 +142,10 @@ const std::string DB::Properties::kMemTableFlushPending =
                       rocksdb_prefix + mem_table_flush_pending;
 const std::string DB::Properties::kCompactionPending =
                       rocksdb_prefix + compaction_pending;
+const std::string DB::Properties::kNumRunningCompactions =
+    rocksdb_prefix + num_running_compactions;
+const std::string DB::Properties::kNumRunningFlushes =
+    rocksdb_prefix + num_running_flushes;
 const std::string DB::Properties::kBackgroundErrors =
                       rocksdb_prefix + background_errors;
 const std::string DB::Properties::kCurSizeActiveMemTable =
@@ -260,6 +263,10 @@ DBPropertyType GetPropertyType(const Slice& property, bool* is_int_property,
     return kTotalSstFilesSize;
   } else if (in == estimate_pending_comp_bytes) {
     return kEstimatePendingCompactionBytes;
+  } else if (in == num_running_flushes) {
+    return kNumRunningFlushes;
+  } else if (in == num_running_compactions) {
+    return kNumRunningCompactions;
   }
   return kUnknown;
 }
@@ -388,11 +395,17 @@ bool InternalStats::GetIntProperty(DBPropertyType property_type,
       // Return number of mem tables that are ready to flush (made immutable)
       *value = (cfd_->imm()->IsFlushPending() ? 1 : 0);
       return true;
+    case kNumRunningFlushes:
+      *value = db->num_running_flushes();
+      return true;
     case kCompactionPending:
       // 1 if the system already determines at least one compaction is needed.
       // 0 otherwise,
       *value = (cfd_->compaction_picker()->NeedsCompaction(vstorage) ? 1 : 0);
       return true;
+    case kNumRunningCompactions:
+      *value = db->num_running_compactions_;
+      return true;
     case kBackgroundErrors:
       // Accumulated number of  errors in background flushes or compactions.
       *value = GetBackgroundErrorCount();
@@ -661,27 +674,13 @@ void InternalStats::DumpCFStats(std::string* value) {
   int total_files = 0;
   int total_files_being_compacted = 0;
   double total_file_size = 0;
-  uint64_t total_slowdown_count_soft = 0;
-  uint64_t total_slowdown_count_hard = 0;
-  uint64_t total_stall_count = 0;
   for (int level = 0; level < number_levels_; level++) {
     int files = vstorage->NumLevelFiles(level);
     total_files += files;
     total_files_being_compacted += files_being_compacted[level];
     if (comp_stats_[level].micros > 0 || files > 0) {
-      uint64_t stalls =
-          level == 0 ? (cf_stats_count_[LEVEL0_SLOWDOWN_TOTAL] +
-                        cf_stats_count_[LEVEL0_NUM_FILES_TOTAL] +
-                        cf_stats_count_[HARD_PENDING_COMPACTION_BYTES_LIMIT] +
-                        cf_stats_count_[MEMTABLE_COMPACTION])
-                     : (stall_leveln_slowdown_count_soft_[level] +
-                        stall_leveln_slowdown_count_hard_[level]);
-
       stats_sum.Add(comp_stats_[level]);
       total_file_size += vstorage->NumLevelBytes(level);
-      total_stall_count += stalls;
-      total_slowdown_count_soft += stall_leveln_slowdown_count_soft_[level];
-      total_slowdown_count_hard += stall_leveln_slowdown_count_hard_[level];
       double w_amp =
           (comp_stats_[level].bytes_read_non_output_levels == 0) ? 0.0
           : static_cast<double>(comp_stats_[level].bytes_written) /
@@ -689,17 +688,23 @@ void InternalStats::DumpCFStats(std::string* value) {
       PrintLevelStats(buf, sizeof(buf), "L" + ToString(level), files,
                       files_being_compacted[level],
                       vstorage->NumLevelBytes(level), compaction_score[level],
-                      w_amp, stalls, comp_stats_[level]);
+                      w_amp, comp_stats_[level]);
       value->append(buf);
     }
   }
   uint64_t curr_ingest = cf_stats_value_[BYTES_FLUSHED];
   // Cumulative summary
   double w_amp = stats_sum.bytes_written / static_cast<double>(curr_ingest + 1);
+  uint64_t total_stall_count =
+      cf_stats_count_[LEVEL0_SLOWDOWN_TOTAL] +
+      cf_stats_count_[LEVEL0_NUM_FILES_TOTAL] +
+      cf_stats_count_[SOFT_PENDING_COMPACTION_BYTES_LIMIT] +
+      cf_stats_count_[HARD_PENDING_COMPACTION_BYTES_LIMIT] +
+      cf_stats_count_[MEMTABLE_COMPACTION];
   // Stats summary across levels
   PrintLevelStats(buf, sizeof(buf), "Sum", total_files,
-      total_files_being_compacted, total_file_size, 0, w_amp,
-      total_stall_count, stats_sum);
+                  total_files_being_compacted, total_file_size, 0, w_amp,
+                  stats_sum);
   value->append(buf);
   // Interval summary
   uint64_t interval_ingest =
@@ -707,9 +712,7 @@ void InternalStats::DumpCFStats(std::string* value) {
   CompactionStats interval_stats(stats_sum);
   interval_stats.Subtract(cf_stats_snapshot_.comp_stats);
   w_amp = interval_stats.bytes_written / static_cast<double>(interval_ingest);
-  PrintLevelStats(buf, sizeof(buf), "Int", 0, 0, 0, 0,
-      w_amp, total_stall_count - cf_stats_snapshot_.stall_count,
-      interval_stats);
+  PrintLevelStats(buf, sizeof(buf), "Int", 0, 0, 0, 0, w_amp, interval_stats);
   value->append(buf);
 
   snprintf(buf, sizeof(buf),
@@ -726,19 +729,20 @@ void InternalStats::DumpCFStats(std::string* value) {
                              "%" PRIu64
                              " level0_numfiles_with_compaction, "
                              "%" PRIu64
-                             " pending_compaction_bytes, "
+                             " stop for pending_compaction_bytes, "
                              "%" PRIu64
-                             " memtable_compaction, "
+                             " slowdown for pending_compaction_bytes, "
                              "%" PRIu64
-                             " leveln_slowdown_soft, "
-                             "%" PRIu64 " leveln_slowdown_hard\n",
+                             " memtable_compaction, "
+                             "interval %" PRIu64 " total count\n",
            cf_stats_count_[LEVEL0_SLOWDOWN_TOTAL],
            cf_stats_count_[LEVEL0_SLOWDOWN_WITH_COMPACTION],
            cf_stats_count_[LEVEL0_NUM_FILES_TOTAL],
            cf_stats_count_[LEVEL0_NUM_FILES_WITH_COMPACTION],
            cf_stats_count_[HARD_PENDING_COMPACTION_BYTES_LIMIT],
-           cf_stats_count_[MEMTABLE_COMPACTION], total_slowdown_count_soft,
-           total_slowdown_count_hard);
+           cf_stats_count_[SOFT_PENDING_COMPACTION_BYTES_LIMIT],
+           cf_stats_count_[MEMTABLE_COMPACTION],
+           total_stall_count - cf_stats_snapshot_.stall_count);
   value->append(buf);
 
   cf_stats_snapshot_.ingest_bytes = curr_ingest;
diff --git a/src/rocksdb/db/internal_stats.h b/src/rocksdb/db/internal_stats.h
index eeb226e..b22c799 100644
--- a/src/rocksdb/db/internal_stats.h
+++ b/src/rocksdb/db/internal_stats.h
@@ -38,7 +38,10 @@ enum DBPropertyType : uint32_t {
                                  // in memory that have already been flushed
   kMemtableFlushPending,         // Return 1 if mem table flushing is pending,
                                  // otherwise 0.
+  kNumRunningFlushes,      // Return the number of currently running flushes.
   kCompactionPending,      // Return 1 if a compaction is pending. Otherwise 0.
+  kNumRunningCompactions,  // Return the number of currently running
+                           // compactions.
   kBackgroundErrors,       // Return accumulated background errors encountered.
   kCurSizeActiveMemTable,  // Return current size of the active memtable
   kCurSizeAllMemTables,    // Return current size of unflushed
@@ -49,10 +52,10 @@ enum DBPropertyType : uint32_t {
                                    // memtable.
   kNumEntriesInImmutableMemtable,  // Return sum of number of entries in all
                                    // the immutable mem tables.
-  kNumDeletesInMutableMemtable,    // Return number of entries in the mutable
-                                   // memtable.
-  kNumDeletesInImmutableMemtable,  // Return sum of number of deletes in all
-                                   // the immutable mem tables.
+  kNumDeletesInMutableMemtable,    // Return number of deletion entries in the
+                                   // mutable memtable.
+  kNumDeletesInImmutableMemtable,  // Return the total number of deletion
+                                   // entries in all the immutable mem tables.
   kEstimatedNumKeys,  // Estimated total number of keys in the database.
   kEstimatedUsageByTableReaders,  // Estimated memory by table readers.
   kIsFileDeletionEnabled,         // Equals disable_delete_obsolete_files_,
@@ -85,6 +88,7 @@ class InternalStats {
     MEMTABLE_COMPACTION,
     LEVEL0_NUM_FILES_TOTAL,
     LEVEL0_NUM_FILES_WITH_COMPACTION,
+    SOFT_PENDING_COMPACTION_BYTES_LIMIT,
     HARD_PENDING_COMPACTION_BYTES_LIMIT,
     WRITE_STALLS_ENUM_MAX,
     BYTES_FLUSHED,
@@ -108,8 +112,6 @@ class InternalStats {
         cf_stats_value_(INTERNAL_CF_STATS_ENUM_MAX),
         cf_stats_count_(INTERNAL_CF_STATS_ENUM_MAX),
         comp_stats_(num_levels),
-        stall_leveln_slowdown_count_hard_(num_levels),
-        stall_leveln_slowdown_count_soft_(num_levels),
         file_read_latency_(num_levels),
         bg_error_count_(0),
         number_levels_(num_levels),
@@ -123,10 +125,6 @@ class InternalStats {
       cf_stats_value_[i] = 0;
       cf_stats_count_[i] = 0;
     }
-    for (int i = 0; i < num_levels; ++i) {
-      stall_leveln_slowdown_count_hard_[i] = 0;
-      stall_leveln_slowdown_count_soft_[i] = 0;
-    }
   }
 
   // Per level compaction stats.  comp_stats_[level] stores the stats for
@@ -234,14 +232,6 @@ class InternalStats {
     comp_stats_[level].bytes_moved += amount;
   }
 
-  void RecordLevelNSlowdown(int level, bool soft) {
-    if (soft) {
-      ++stall_leveln_slowdown_count_soft_[level];
-    } else {
-      ++stall_leveln_slowdown_count_hard_[level];
-    }
-  }
-
   void AddCFStats(InternalCFStatsType type, uint64_t value) {
     cf_stats_value_[type] += value;
     ++cf_stats_count_[type];
@@ -279,9 +269,6 @@ class InternalStats {
   std::vector<uint64_t> cf_stats_count_;
   // Per-ColumnFamily/level compaction stats
   std::vector<CompactionStats> comp_stats_;
-  // These count the number of microseconds for which MakeRoomForWrite stalls.
-  std::vector<uint64_t> stall_leveln_slowdown_count_hard_;
-  std::vector<uint64_t> stall_leveln_slowdown_count_soft_;
   std::vector<HistogramImpl> file_read_latency_;
 
   // Used to compute per-interval statistics
@@ -358,6 +345,7 @@ class InternalStats {
     MEMTABLE_COMPACTION,
     LEVEL0_NUM_FILES_TOTAL,
     LEVEL0_NUM_FILES_WITH_COMPACTION,
+    SOFT_PENDING_COMPACTION_BYTES_LIMIT,
     HARD_PENDING_COMPACTION_BYTES_LIMIT,
     WRITE_STALLS_ENUM_MAX,
     BYTES_FLUSHED,
@@ -404,8 +392,6 @@ class InternalStats {
 
   void IncBytesMoved(int level, uint64_t amount) {}
 
-  void RecordLevelNSlowdown(int level, bool soft) {}
-
   void AddCFStats(InternalCFStatsType type, uint64_t value) {}
 
   void AddDBStats(InternalDBStatsType type, uint64_t value) {}
diff --git a/src/rocksdb/db/listener_test.cc b/src/rocksdb/db/listener_test.cc
index ce683a5..ae911e7 100644
--- a/src/rocksdb/db/listener_test.cc
+++ b/src/rocksdb/db/listener_test.cc
@@ -8,6 +8,7 @@
 #include "db/filename.h"
 #include "db/version_set.h"
 #include "db/write_batch_internal.h"
+#include "memtable/hash_linklist_rep.h"
 #include "rocksdb/cache.h"
 #include "rocksdb/compaction_filter.h"
 #include "rocksdb/db.h"
@@ -22,7 +23,6 @@
 #include "table/block_based_table_factory.h"
 #include "table/plain_table_factory.h"
 #include "util/hash.h"
-#include "util/hash_linklist_rep.h"
 #include "util/logging.h"
 #include "util/mutexlock.h"
 #include "util/rate_limiter.h"
@@ -152,6 +152,40 @@ class EventListenerTest : public testing::Test {
   std::vector<ColumnFamilyHandle*> handles_;
 };
 
+struct TestPropertiesCollector : public rocksdb::TablePropertiesCollector {
+  virtual rocksdb::Status AddUserKey(const rocksdb::Slice& key,
+                                     const rocksdb::Slice& value,
+                                     rocksdb::EntryType type,
+                                     rocksdb::SequenceNumber seq,
+                                     uint64_t file_size) override {
+    return Status::OK();
+  }
+  virtual rocksdb::Status Finish(
+      rocksdb::UserCollectedProperties* properties) override {
+    properties->insert({"0", "1"});
+    return Status::OK();
+  }
+
+  virtual const char* Name() const override {
+    return "TestTablePropertiesCollector";
+  }
+
+  rocksdb::UserCollectedProperties GetReadableProperties() const override {
+    rocksdb::UserCollectedProperties ret;
+    ret["2"] = "3";
+    return ret;
+  }
+};
+
+class TestPropertiesCollectorFactory : public TablePropertiesCollectorFactory {
+ public:
+  virtual TablePropertiesCollector* CreateTablePropertiesCollector(
+      TablePropertiesCollectorFactory::Context context) override {
+    return new TestPropertiesCollector;
+  }
+  const char* Name() const override { return "TestTablePropertiesCollector"; }
+};
+
 class TestCompactionListener : public EventListener {
  public:
   void OnCompactionCompleted(DB *db, const CompactionJobInfo& ci) override {
@@ -161,6 +195,16 @@ class TestCompactionListener : public EventListener {
     ASSERT_GT(ci.output_files.size(), 0U);
     ASSERT_EQ(db->GetEnv()->GetThreadID(), ci.thread_id);
     ASSERT_GT(ci.thread_id, 0U);
+
+    for (auto fl : {ci.input_files, ci.output_files}) {
+      for (auto fn : fl) {
+        auto it = ci.table_properties.find(fn);
+        ASSERT_NE(it, ci.table_properties.end());
+        auto tp = it->second;
+        ASSERT_TRUE(tp != nullptr);
+        ASSERT_EQ(tp->user_collected_properties.find("0")->second, "1");
+      }
+    }
   }
 
   std::vector<DB*> compacted_dbs_;
@@ -186,6 +230,8 @@ TEST_F(EventListenerTest, OnSingleDBCompactionTest) {
   options.enable_thread_tracking = true;
 #endif  // ROCKSDB_USING_THREAD_STATUS
   options.level0_file_num_compaction_trigger = kNumL0Files;
+  options.table_properties_collector_factories.push_back(
+      std::make_shared<TestPropertiesCollectorFactory>());
 
   TestCompactionListener* listener = new TestCompactionListener();
   options.listeners.emplace_back(listener);
@@ -274,6 +320,8 @@ class TestFlushListener : public EventListener {
     ASSERT_EQ(prev_fc_info_.file_path, info.file_path);
     ASSERT_EQ(db->GetEnv()->GetThreadID(), info.thread_id);
     ASSERT_GT(info.thread_id, 0U);
+    ASSERT_EQ(info.table_properties.user_collected_properties.find("0")->second,
+              "1");
   }
 
   std::vector<std::string> flushed_column_family_names_;
@@ -299,6 +347,8 @@ TEST_F(EventListenerTest, OnSingleDBFlushTest) {
   std::vector<std::string> cf_names = {
       "pikachu", "ilya", "muromec", "dobrynia",
       "nikitich", "alyosha", "popovich"};
+  options.table_properties_collector_factories.push_back(
+      std::make_shared<TestPropertiesCollectorFactory>());
   CreateAndReopenWithCF(cf_names, &options);
 
   ASSERT_OK(Put(1, "pikachu", std::string(90000, 'p')));
@@ -330,6 +380,8 @@ TEST_F(EventListenerTest, MultiCF) {
 #endif  // ROCKSDB_USING_THREAD_STATUS
   TestFlushListener* listener = new TestFlushListener(options.env);
   options.listeners.emplace_back(listener);
+  options.table_properties_collector_factories.push_back(
+      std::make_shared<TestPropertiesCollectorFactory>());
   std::vector<std::string> cf_names = {
       "pikachu", "ilya", "muromec", "dobrynia",
       "nikitich", "alyosha", "popovich"};
@@ -360,6 +412,8 @@ TEST_F(EventListenerTest, MultiDBMultiListeners) {
 #if ROCKSDB_USING_THREAD_STATUS
   options.enable_thread_tracking = true;
 #endif  // ROCKSDB_USING_THREAD_STATUS
+  options.table_properties_collector_factories.push_back(
+      std::make_shared<TestPropertiesCollectorFactory>());
   std::vector<TestFlushListener*> listeners;
   const int kNumDBs = 5;
   const int kNumListeners = 10;
@@ -454,6 +508,8 @@ TEST_F(EventListenerTest, DisableBGCompaction) {
   options.compaction_style = kCompactionStyleNone;
   options.compression = kNoCompression;
   options.write_buffer_size = 100000;  // Small write buffer
+  options.table_properties_collector_factories.push_back(
+      std::make_shared<TestPropertiesCollectorFactory>());
 
   CreateAndReopenWithCF({"pikachu"}, &options);
   ColumnFamilyMetaData cf_meta;
@@ -477,4 +533,3 @@ int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }
-
diff --git a/src/rocksdb/db/log_format.h b/src/rocksdb/db/log_format.h
index 919c087..97eb133 100644
--- a/src/rocksdb/db/log_format.h
+++ b/src/rocksdb/db/log_format.h
@@ -22,14 +22,24 @@ enum RecordType {
   // For fragments
   kFirstType = 2,
   kMiddleType = 3,
-  kLastType = 4
+  kLastType = 4,
+
+  // For recycled log files
+  kRecyclableFullType = 5,
+  kRecyclableFirstType = 6,
+  kRecyclableMiddleType = 7,
+  kRecyclableLastType = 8,
 };
-static const int kMaxRecordType = kLastType;
+static const int kMaxRecordType = kRecyclableLastType;
 
 static const unsigned int kBlockSize = 32768;
 
 // Header is checksum (4 bytes), type (1 byte), length (2 bytes).
 static const int kHeaderSize = 4 + 1 + 2;
 
+// Recyclable header is checksum (4 bytes), type (1 byte), log number
+// (4 bytes), length (2 bytes).
+static const int kRecyclableHeaderSize = 4 + 1 + 4 + 2;
+
 }  // namespace log
 }  // namespace rocksdb
diff --git a/src/rocksdb/db/log_reader.cc b/src/rocksdb/db/log_reader.cc
index 296f1d5..b70d21e 100644
--- a/src/rocksdb/db/log_reader.cc
+++ b/src/rocksdb/db/log_reader.cc
@@ -21,9 +21,14 @@ namespace log {
 Reader::Reporter::~Reporter() {
 }
 
-Reader::Reader(unique_ptr<SequentialFileReader>&& _file, Reporter* reporter,
-               bool checksum, uint64_t initial_offset)
-    : file_(std::move(_file)),
+Reader::Reader(std::shared_ptr<Logger> info_log,
+	       unique_ptr<SequentialFileReader>&& _file,
+               Reporter* reporter, bool checksum, uint64_t initial_offset,
+               uint64_t log_num,
+	       const DBOptions *opt)
+    : db_options_(opt),
+      info_log_(info_log),
+      file_(std::move(_file)),
       reporter_(reporter),
       checksum_(checksum),
       backing_store_(new char[kBlockSize]),
@@ -33,7 +38,9 @@ Reader::Reader(unique_ptr<SequentialFileReader>&& _file, Reporter* reporter,
       eof_offset_(0),
       last_record_offset_(0),
       end_of_buffer_offset_(0),
-      initial_offset_(initial_offset) {}
+      initial_offset_(initial_offset),
+      log_number_(log_num),
+      recycled_(false) {}
 
 Reader::~Reader() {
   delete[] backing_store_;
@@ -62,8 +69,15 @@ bool Reader::SkipToInitialBlock() {
   return true;
 }
 
+// For kAbsoluteConsistency, on clean shutdown we don't expect any error
+// in the log files.  For other modes, we can ignore only incomplete records
+// in the last log file, which are presumably due to a write in progress
+// during restart (or from log recycling).
+//
+// TODO krad: Evaluate if we need to move to a more strict mode where we
+// restrict the inconsistency to only the last log
 bool Reader::ReadRecord(Slice* record, std::string* scratch,
-                        const bool report_eof_inconsistency) {
+                        WALRecoveryMode wal_recovery_mode) {
   if (last_record_offset_ < initial_offset_) {
     if (!SkipToInitialBlock()) {
       return false;
@@ -80,10 +94,11 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
   Slice fragment;
   while (true) {
     uint64_t physical_record_offset = end_of_buffer_offset_ - buffer_.size();
-    const unsigned int record_type =
-        ReadPhysicalRecord(&fragment, report_eof_inconsistency);
+    size_t drop_size;
+    const unsigned int record_type = ReadPhysicalRecord(&fragment, &drop_size);
     switch (record_type) {
       case kFullType:
+      case kRecyclableFullType:
         if (in_fragmented_record && !scratch->empty()) {
           // Handle bug in earlier versions of log::Writer where
           // it could emit an empty kFirstType record at the tail end
@@ -98,6 +113,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
         return true;
 
       case kFirstType:
+      case kRecyclableFirstType:
         if (in_fragmented_record && !scratch->empty()) {
           // Handle bug in earlier versions of log::Writer where
           // it could emit an empty kFirstType record at the tail end
@@ -111,6 +127,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
         break;
 
       case kMiddleType:
+      case kRecyclableMiddleType:
         if (!in_fragmented_record) {
           ReportCorruption(fragment.size(),
                            "missing start of fragmented record(1)");
@@ -120,6 +137,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
         break;
 
       case kLastType:
+      case kRecyclableLastType:
         if (!in_fragmented_record) {
           ReportCorruption(fragment.size(),
                            "missing start of fragmented record(2)");
@@ -131,9 +149,17 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
         }
         break;
 
+      case kBadHeader:
+        if (wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency) {
+          // in clean shutdown we don't expect any error in the log files
+          ReportCorruption(drop_size, "truncated header");
+        }
+      // fall-thru
+
       case kEof:
         if (in_fragmented_record) {
-          if (report_eof_inconsistency) {
+          if (wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency) {
+            // in clean shutdown we don't expect any error in the log files
             ReportCorruption(scratch->size(), "error reading trailing data");
           }
           // This can be caused by the writer dying immediately after
@@ -143,6 +169,23 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
         }
         return false;
 
+      case kOldRecord:
+        if (wal_recovery_mode != WALRecoveryMode::kSkipAnyCorruptedRecords) {
+          // Treat a record from a previous instance of the log as EOF.
+          if (in_fragmented_record) {
+            if (wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency) {
+              // in clean shutdown we don't expect any error in the log files
+              ReportCorruption(scratch->size(), "error reading trailing data");
+            }
+            // This can be caused by the writer dying immediately after
+            //  writing a physical record but before completing the next; don't
+            //  treat it as a corruption, just ignore the entire logical record.
+            scratch->clear();
+          }
+          return false;
+        }
+      // fall-thru
+
       case kBadRecord:
         if (in_fragmented_record) {
           ReportCorruption(scratch->size(), "error in middle of record");
@@ -151,6 +194,36 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
         }
         break;
 
+      case kBadRecordLen:
+        if (recycled_ &&
+            wal_recovery_mode ==
+                WALRecoveryMode::kTolerateCorruptedTailRecords) {
+          scratch->clear();
+          return false;
+        }
+        ReportCorruption(drop_size, "bad record length");
+        if (in_fragmented_record) {
+          ReportCorruption(scratch->size(), "error in middle of record");
+          in_fragmented_record = false;
+          scratch->clear();
+        }
+        break;
+
+      case kBadRecordChecksum:
+        if (recycled_ &&
+            wal_recovery_mode ==
+                WALRecoveryMode::kTolerateCorruptedTailRecords) {
+          scratch->clear();
+          return false;
+        }
+        ReportCorruption(drop_size, "checksum mismatch");
+        if (in_fragmented_record) {
+          ReportCorruption(scratch->size(), "error in middle of record");
+          in_fragmented_record = false;
+          scratch->clear();
+        }
+        break;
+
       default: {
         char buf[40];
         snprintf(buf, sizeof(buf), "unknown record type %u", record_type);
@@ -244,36 +317,49 @@ void Reader::ReportDrop(size_t bytes, const Status& reason) {
   }
 }
 
-unsigned int Reader::ReadPhysicalRecord(Slice* result,
-                                        const bool report_eof_inconsistency) {
+bool Reader::ReadMore(size_t* drop_size, int *error) {
+  if (!eof_ && !read_error_) {
+    // Last read was a full read, so this is a trailer to skip
+    buffer_.clear();
+    Status status = file_->Read(kBlockSize, &buffer_, backing_store_);
+    end_of_buffer_offset_ += buffer_.size();
+    if (!status.ok()) {
+      buffer_.clear();
+      ReportDrop(kBlockSize, status);
+      read_error_ = true;
+      *error = kEof;
+      return false;
+    } else if (buffer_.size() < (size_t)kBlockSize) {
+      eof_ = true;
+      eof_offset_ = buffer_.size();
+    }
+    return true;
+  } else {
+    // Note that if buffer_ is non-empty, we have a truncated header at the
+    //  end of the file, which can be caused by the writer crashing in the
+    //  middle of writing the header. Unless explicitly requested we don't
+    //  considering this an error, just report EOF.
+    if (buffer_.size()) {
+      *drop_size = buffer_.size();
+      buffer_.clear();
+      *error = kBadHeader;
+      return false;
+    }
+    buffer_.clear();
+    *error = kEof;
+    return false;
+  }
+}
+
+unsigned int Reader::ReadPhysicalRecord(Slice* result, size_t* drop_size) {
   while (true) {
+    // We need at least the minimum header size
     if (buffer_.size() < (size_t)kHeaderSize) {
-      if (!eof_ && !read_error_) {
-        // Last read was a full read, so this is a trailer to skip
-        buffer_.clear();
-        Status status = file_->Read(kBlockSize, &buffer_, backing_store_);
-        end_of_buffer_offset_ += buffer_.size();
-        if (!status.ok()) {
-          buffer_.clear();
-          ReportDrop(kBlockSize, status);
-          read_error_ = true;
-          return kEof;
-        } else if (buffer_.size() < (size_t)kBlockSize) {
-          eof_ = true;
-          eof_offset_ = buffer_.size();
-        }
-        continue;
-      } else {
-        // Note that if buffer_ is non-empty, we have a truncated header at the
-        //  end of the file, which can be caused by the writer crashing in the
-        //  middle of writing the header. Unless explicitly requested we don't
-        //  considering this an error, just report EOF.
-        if (buffer_.size() && report_eof_inconsistency) {
-          ReportCorruption(buffer_.size(), "truncated header");
-        }
-        buffer_.clear();
-        return kEof;
+      int r;
+      if (!ReadMore(drop_size, &r)) {
+	return r;
       }
+      continue;
     }
 
     // Parse the header
@@ -282,18 +368,36 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result,
     const uint32_t b = static_cast<uint32_t>(header[5]) & 0xff;
     const unsigned int type = header[6];
     const uint32_t length = a | (b << 8);
-    if (kHeaderSize + length > buffer_.size()) {
-      size_t drop_size = buffer_.size();
+    int header_size = kHeaderSize;
+    if (type >= kRecyclableFullType && type <= kRecyclableLastType) {
+      if (end_of_buffer_offset_ - buffer_.size() == 0) {
+        recycled_ = true;
+      }
+      header_size = kRecyclableHeaderSize;
+      // We need enough for the larger header
+      if (buffer_.size() < (size_t)kRecyclableHeaderSize) {
+	int r;
+	if (!ReadMore(drop_size, &r)) {
+          return r;
+        }
+	continue;
+      }
+      const uint32_t log_num = DecodeFixed32(header + 7);
+      if (log_num != log_number_) {
+        return kOldRecord;
+      }
+    }
+    if (header_size + length > buffer_.size()) {
+      *drop_size = buffer_.size();
       buffer_.clear();
       if (!eof_) {
-        ReportCorruption(drop_size, "bad record length");
-        return kBadRecord;
+        return kBadRecordLen;
       }
       // If the end of the file has been reached without reading |length| bytes
       // of payload, assume the writer died in the middle of writing the record.
       // Don't report a corruption unless requested.
-      if (drop_size && report_eof_inconsistency) {
-        ReportCorruption(drop_size, "truncated header");
+      if (*drop_size) {
+        return kBadHeader;
       }
       return kEof;
     }
@@ -309,31 +413,40 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result,
     }
 
     // Check crc
+    uint32_t actual_crc = 0;
     if (checksum_) {
       uint32_t expected_crc = crc32c::Unmask(DecodeFixed32(header));
-      uint32_t actual_crc = crc32c::Value(header + 6, 1 + length);
+      actual_crc = crc32c::Value(header + 6, length + header_size - 6);
       if (actual_crc != expected_crc) {
         // Drop the rest of the buffer since "length" itself may have
         // been corrupted and if we trust it, we could find some
         // fragment of a real log record that just happens to look
         // like a valid log record.
-        size_t drop_size = buffer_.size();
+        *drop_size = buffer_.size();
         buffer_.clear();
-        ReportCorruption(drop_size, "checksum mismatch");
-        return kBadRecord;
+        return kBadRecordChecksum;
       }
     }
 
-    buffer_.remove_prefix(kHeaderSize + length);
+    buffer_.remove_prefix(header_size + length);
 
     // Skip physical record that started before initial_offset_
-    if (end_of_buffer_offset_ - buffer_.size() - kHeaderSize - length <
+    if (end_of_buffer_offset_ - buffer_.size() - header_size - length <
         initial_offset_) {
       result->clear();
       return kBadRecord;
     }
 
-    *result = Slice(header + kHeaderSize, length);
+    if (db_options_)
+      Log(InfoLogLevel::DEBUG_LEVEL, db_options_->info_log,
+	"ReadPhysicalRecord: log %lld offset %lld len %d crc %d type %d",
+	  (unsigned long long)log_number_,
+	  (unsigned long long)(end_of_buffer_offset_ - buffer_.size() -
+			       header_size - length),
+	  (int)header_size + (int)length, crc32c::Mask(actual_crc),
+	  type);
+    
+    *result = Slice(header + header_size, length);
     return type;
   }
 }
diff --git a/src/rocksdb/db/log_reader.h b/src/rocksdb/db/log_reader.h
index 390696b..2b7aca8 100644
--- a/src/rocksdb/db/log_reader.h
+++ b/src/rocksdb/db/log_reader.h
@@ -14,10 +14,13 @@
 #include "db/log_format.h"
 #include "rocksdb/slice.h"
 #include "rocksdb/status.h"
+#include "rocksdb/options.h"
 
 namespace rocksdb {
 
 class SequentialFileReader;
+class DBOptions;
+class Logger;
 using std::unique_ptr;
 
 namespace log {
@@ -51,8 +54,11 @@ class Reader {
   //
   // The Reader will start reading at the first record located at physical
   // position >= initial_offset within the file.
-  Reader(unique_ptr<SequentialFileReader>&& file, Reporter* reporter,
-         bool checksum, uint64_t initial_offset);
+  Reader(std::shared_ptr<Logger> info_log,
+	 unique_ptr<SequentialFileReader>&& file,
+         Reporter* reporter, bool checksum, uint64_t initial_offset,
+         uint64_t log_num,
+	 const DBOptions *opt = NULL);
 
   ~Reader();
 
@@ -62,7 +68,8 @@ class Reader {
   // will only be valid until the next mutating operation on this
   // reader or the next mutation to *scratch.
   bool ReadRecord(Slice* record, std::string* scratch,
-                  bool report_eof_inconsistency = false);
+                  WALRecoveryMode wal_recovery_mode =
+                      WALRecoveryMode::kTolerateCorruptedTailRecords);
 
   // Returns the physical offset of the last record returned by ReadRecord.
   //
@@ -84,6 +91,8 @@ class Reader {
   SequentialFileReader* file() { return file_.get(); }
 
  private:
+  const DBOptions *db_options_;
+  std::shared_ptr<Logger> info_log_;
   const unique_ptr<SequentialFileReader> file_;
   Reporter* const reporter_;
   bool const checksum_;
@@ -104,6 +113,12 @@ class Reader {
   // Offset at which to start looking for the first record to return
   uint64_t const initial_offset_;
 
+  // which log number this is
+  uint64_t const log_number_;
+
+  // Whether this is a recycled log file
+  bool recycled_;
+
   // Extend record types with the following special values
   enum {
     kEof = kMaxRecordType + 1,
@@ -112,7 +127,15 @@ class Reader {
     // * The record has an invalid CRC (ReadPhysicalRecord reports a drop)
     // * The record is a 0-length record (No drop is reported)
     // * The record is below constructor's initial_offset (No drop is reported)
-    kBadRecord = kMaxRecordType + 2
+    kBadRecord = kMaxRecordType + 2,
+    // Returned when we fail to read a valid header.
+    kBadHeader = kMaxRecordType + 3,
+    // Returned when we read an old record from a previous user of the log.
+    kOldRecord = kMaxRecordType + 4,
+    // Returned when we get a bad record length
+    kBadRecordLen = kMaxRecordType + 5,
+    // Returned when we get a bad record checksum
+    kBadRecordChecksum = kMaxRecordType + 6,
   };
 
   // Skips all blocks that are completely before "initial_offset_".
@@ -121,8 +144,10 @@ class Reader {
   bool SkipToInitialBlock();
 
   // Return type, or one of the preceding special values
-  unsigned int ReadPhysicalRecord(Slice* result,
-                                  bool report_eof_inconsistency = false);
+  unsigned int ReadPhysicalRecord(Slice* result, size_t* drop_size);
+
+  // Read some more
+  bool ReadMore(size_t* drop_size, int *error);
 
   // Reports dropped bytes to the reporter.
   // buffer_ must be updated to remove the dropped bytes prior to invocation.
diff --git a/src/rocksdb/db/log_test.cc b/src/rocksdb/db/log_test.cc
index 5ab41f2..648237b 100644
--- a/src/rocksdb/db/log_test.cc
+++ b/src/rocksdb/db/log_test.cc
@@ -43,7 +43,7 @@ static std::string RandomSkewedString(int i, Random* rnd) {
   return BigString(NumberString(i), rnd->Skewed(17));
 }
 
-class LogTest : public testing::Test {
+class LogTest : public ::testing::TestWithParam<int> {
  private:
   class StringSource : public SequentialFile {
    public:
@@ -153,19 +153,28 @@ class LogTest : public testing::Test {
 
   // Record metadata for testing initial offset functionality
   static size_t initial_offset_record_sizes_[];
-  static uint64_t initial_offset_last_record_offsets_[];
+  uint64_t initial_offset_last_record_offsets_[4];
 
  public:
   LogTest()
       : reader_contents_(),
-        dest_holder_(
-            test::GetWritableFileWriter(
-              new test::StringSink(&reader_contents_))),
+        dest_holder_(test::GetWritableFileWriter(
+            new test::StringSink(&reader_contents_))),
         source_holder_(
             test::GetSequentialFileReader(new StringSource(reader_contents_))),
-        writer_(std::move(dest_holder_)),
-        reader_(std::move(source_holder_), &report_, true /*checksum*/,
-                0 /*initial_offset*/) {}
+        writer_(std::move(dest_holder_), 123, GetParam()),
+        reader_(NULL, std::move(source_holder_), &report_, true /*checksum*/,
+                0 /*initial_offset*/, 123) {
+    int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+    initial_offset_last_record_offsets_[0] = 0;
+    initial_offset_last_record_offsets_[1] = header_size + 10000;
+    initial_offset_last_record_offsets_[2] = 2 * (header_size + 10000);
+    initial_offset_last_record_offsets_[3] = 2 * (header_size + 10000) +
+                                             (2 * log::kBlockSize - 1000) +
+                                             3 * header_size;
+  }
+
+  Slice* get_reader_contents() { return &reader_contents_; }
 
   void Write(const std::string& msg) {
     writer_.AddRecord(Slice(msg));
@@ -175,10 +184,11 @@ class LogTest : public testing::Test {
     return dest_contents().size();
   }
 
-  std::string Read(const bool report_eof_inconsistency = false) {
+  std::string Read(const WALRecoveryMode wal_recovery_mode =
+                       WALRecoveryMode::kTolerateCorruptedTailRecords) {
     std::string scratch;
     Slice record;
-    if (reader_.ReadRecord(&record, &scratch, report_eof_inconsistency)) {
+    if (reader_.ReadRecord(&record, &scratch, wal_recovery_mode)) {
       return record.ToString();
     } else {
       return "EOF";
@@ -200,9 +210,11 @@ class LogTest : public testing::Test {
     dest->Drop(bytes);
   }
 
-  void FixChecksum(int header_offset, int len) {
+  void FixChecksum(int header_offset, int len, bool recyclable) {
     // Compute crc of type/len/data
-    uint32_t crc = crc32c::Value(&dest_contents()[header_offset+6], 1 + len);
+    int header_size = recyclable ? kRecyclableHeaderSize : kHeaderSize;
+    uint32_t crc = crc32c::Value(&dest_contents()[header_offset + 6],
+                                 header_size - 6 + len);
     crc = crc32c::Mask(crc);
     EncodeFixed32(&dest_contents()[header_offset], crc);
   }
@@ -259,8 +271,8 @@ class LogTest : public testing::Test {
     unique_ptr<SequentialFileReader> file_reader(
         test::GetSequentialFileReader(new StringSource(reader_contents_)));
     unique_ptr<Reader> offset_reader(
-        new Reader(std::move(file_reader), &report_, true /*checksum*/,
-                   WrittenBytes() + offset_past_end));
+        new Reader(NULL, std::move(file_reader), &report_,
+                   true /*checksum*/, WrittenBytes() + offset_past_end, 123));
     Slice record;
     std::string scratch;
     ASSERT_TRUE(!offset_reader->ReadRecord(&record, &scratch));
@@ -271,8 +283,9 @@ class LogTest : public testing::Test {
     WriteInitialOffsetLog();
     unique_ptr<SequentialFileReader> file_reader(
         test::GetSequentialFileReader(new StringSource(reader_contents_)));
-    unique_ptr<Reader> offset_reader(new Reader(
-        std::move(file_reader), &report_, true /*checksum*/, initial_offset));
+    unique_ptr<Reader> offset_reader(
+        new Reader(NULL, std::move(file_reader), &report_,
+                   true /*checksum*/, initial_offset, 123));
     Slice record;
     std::string scratch;
     ASSERT_TRUE(offset_reader->ReadRecord(&record, &scratch));
@@ -291,16 +304,9 @@ size_t LogTest::initial_offset_record_sizes_[] =
      2 * log::kBlockSize - 1000,  // Span three blocks
      1};
 
-uint64_t LogTest::initial_offset_last_record_offsets_[] =
-    {0,
-     kHeaderSize + 10000,
-     2 * (kHeaderSize + 10000),
-     2 * (kHeaderSize + 10000) +
-         (2 * log::kBlockSize - 1000) + 3 * kHeaderSize};
+TEST_P(LogTest, Empty) { ASSERT_EQ("EOF", Read()); }
 
-TEST_F(LogTest, Empty) { ASSERT_EQ("EOF", Read()); }
-
-TEST_F(LogTest, ReadWrite) {
+TEST_P(LogTest, ReadWrite) {
   Write("foo");
   Write("bar");
   Write("");
@@ -313,7 +319,7 @@ TEST_F(LogTest, ReadWrite) {
   ASSERT_EQ("EOF", Read());  // Make sure reads at eof work
 }
 
-TEST_F(LogTest, ManyBlocks) {
+TEST_P(LogTest, ManyBlocks) {
   for (int i = 0; i < 100000; i++) {
     Write(NumberString(i));
   }
@@ -323,7 +329,7 @@ TEST_F(LogTest, ManyBlocks) {
   ASSERT_EQ("EOF", Read());
 }
 
-TEST_F(LogTest, Fragmentation) {
+TEST_P(LogTest, Fragmentation) {
   Write("small");
   Write(BigString("medium", 50000));
   Write(BigString("large", 100000));
@@ -333,11 +339,12 @@ TEST_F(LogTest, Fragmentation) {
   ASSERT_EQ("EOF", Read());
 }
 
-TEST_F(LogTest, MarginalTrailer) {
+TEST_P(LogTest, MarginalTrailer) {
   // Make a trailer that is exactly the same length as an empty record.
-  const int n = kBlockSize - 2*kHeaderSize;
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  const int n = kBlockSize - 2 * header_size;
   Write(BigString("foo", n));
-  ASSERT_EQ((unsigned int)(kBlockSize - kHeaderSize), WrittenBytes());
+  ASSERT_EQ((unsigned int)(kBlockSize - header_size), WrittenBytes());
   Write("");
   Write("bar");
   ASSERT_EQ(BigString("foo", n), Read());
@@ -346,11 +353,12 @@ TEST_F(LogTest, MarginalTrailer) {
   ASSERT_EQ("EOF", Read());
 }
 
-TEST_F(LogTest, MarginalTrailer2) {
+TEST_P(LogTest, MarginalTrailer2) {
   // Make a trailer that is exactly the same length as an empty record.
-  const int n = kBlockSize - 2*kHeaderSize;
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  const int n = kBlockSize - 2 * header_size;
   Write(BigString("foo", n));
-  ASSERT_EQ((unsigned int)(kBlockSize - kHeaderSize), WrittenBytes());
+  ASSERT_EQ((unsigned int)(kBlockSize - header_size), WrittenBytes());
   Write("bar");
   ASSERT_EQ(BigString("foo", n), Read());
   ASSERT_EQ("bar", Read());
@@ -359,10 +367,11 @@ TEST_F(LogTest, MarginalTrailer2) {
   ASSERT_EQ("", ReportMessage());
 }
 
-TEST_F(LogTest, ShortTrailer) {
-  const int n = kBlockSize - 2*kHeaderSize + 4;
+TEST_P(LogTest, ShortTrailer) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  const int n = kBlockSize - 2 * header_size + 4;
   Write(BigString("foo", n));
-  ASSERT_EQ((unsigned int)(kBlockSize - kHeaderSize + 4), WrittenBytes());
+  ASSERT_EQ((unsigned int)(kBlockSize - header_size + 4), WrittenBytes());
   Write("");
   Write("bar");
   ASSERT_EQ(BigString("foo", n), Read());
@@ -371,15 +380,16 @@ TEST_F(LogTest, ShortTrailer) {
   ASSERT_EQ("EOF", Read());
 }
 
-TEST_F(LogTest, AlignedEof) {
-  const int n = kBlockSize - 2*kHeaderSize + 4;
+TEST_P(LogTest, AlignedEof) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  const int n = kBlockSize - 2 * header_size + 4;
   Write(BigString("foo", n));
-  ASSERT_EQ((unsigned int)(kBlockSize - kHeaderSize + 4), WrittenBytes());
+  ASSERT_EQ((unsigned int)(kBlockSize - header_size + 4), WrittenBytes());
   ASSERT_EQ(BigString("foo", n), Read());
   ASSERT_EQ("EOF", Read());
 }
 
-TEST_F(LogTest, RandomRead) {
+TEST_P(LogTest, RandomRead) {
   const int N = 500;
   Random write_rnd(301);
   for (int i = 0; i < N; i++) {
@@ -394,7 +404,7 @@ TEST_F(LogTest, RandomRead) {
 
 // Tests of all the error paths in log_reader.cc follow:
 
-TEST_F(LogTest, ReadError) {
+TEST_P(LogTest, ReadError) {
   Write("foo");
   ForceError();
   ASSERT_EQ("EOF", Read());
@@ -402,17 +412,17 @@ TEST_F(LogTest, ReadError) {
   ASSERT_EQ("OK", MatchError("read error"));
 }
 
-TEST_F(LogTest, BadRecordType) {
+TEST_P(LogTest, BadRecordType) {
   Write("foo");
   // Type is stored in header[6]
   IncrementByte(6, 100);
-  FixChecksum(0, 3);
+  FixChecksum(0, 3, false);
   ASSERT_EQ("EOF", Read());
   ASSERT_EQ(3U, DroppedBytes());
   ASSERT_EQ("OK", MatchError("unknown record type"));
 }
 
-TEST_F(LogTest, TruncatedTrailingRecordIsIgnored) {
+TEST_P(LogTest, TruncatedTrailingRecordIsIgnored) {
   Write("foo");
   ShrinkSize(4);   // Drop all payload as well as a header byte
   ASSERT_EQ("EOF", Read());
@@ -421,27 +431,32 @@ TEST_F(LogTest, TruncatedTrailingRecordIsIgnored) {
   ASSERT_EQ("", ReportMessage());
 }
 
-TEST_F(LogTest, TruncatedTrailingRecordIsNotIgnored) {
+TEST_P(LogTest, TruncatedTrailingRecordIsNotIgnored) {
   Write("foo");
   ShrinkSize(4);  // Drop all payload as well as a header byte
-  ASSERT_EQ("EOF", Read(/*report_eof_inconsistency*/ true));
+  ASSERT_EQ("EOF", Read(WALRecoveryMode::kAbsoluteConsistency));
   // Truncated last record is ignored, not treated as an error
   ASSERT_GT(DroppedBytes(), 0U);
   ASSERT_EQ("OK", MatchError("Corruption: truncated header"));
 }
 
-TEST_F(LogTest, BadLength) {
-  const int kPayloadSize = kBlockSize - kHeaderSize;
+TEST_P(LogTest, BadLength) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  const int kPayloadSize = kBlockSize - header_size;
   Write(BigString("bar", kPayloadSize));
   Write("foo");
   // Least significant size byte is stored in header[4].
   IncrementByte(4, 1);
-  ASSERT_EQ("foo", Read());
-  ASSERT_EQ(kBlockSize, DroppedBytes());
-  ASSERT_EQ("OK", MatchError("bad record length"));
+  if (!GetParam()) {
+    ASSERT_EQ("foo", Read());
+    ASSERT_EQ(kBlockSize, DroppedBytes());
+    ASSERT_EQ("OK", MatchError("bad record length"));
+  } else {
+    ASSERT_EQ("EOF", Read());
+  }
 }
 
-TEST_F(LogTest, BadLengthAtEndIsIgnored) {
+TEST_P(LogTest, BadLengthAtEndIsIgnored) {
   Write("foo");
   ShrinkSize(1);
   ASSERT_EQ("EOF", Read());
@@ -449,63 +464,68 @@ TEST_F(LogTest, BadLengthAtEndIsIgnored) {
   ASSERT_EQ("", ReportMessage());
 }
 
-TEST_F(LogTest, BadLengthAtEndIsNotIgnored) {
+TEST_P(LogTest, BadLengthAtEndIsNotIgnored) {
   Write("foo");
   ShrinkSize(1);
-  ASSERT_EQ("EOF", Read(/*report_eof_inconsistency=*/true));
+  ASSERT_EQ("EOF", Read(WALRecoveryMode::kAbsoluteConsistency));
   ASSERT_GT(DroppedBytes(), 0U);
   ASSERT_EQ("OK", MatchError("Corruption: truncated header"));
 }
 
-TEST_F(LogTest, ChecksumMismatch) {
-  Write("foo");
-  IncrementByte(0, 10);
+TEST_P(LogTest, ChecksumMismatch) {
+  Write("foooooo");
+  IncrementByte(0, 14);
   ASSERT_EQ("EOF", Read());
-  ASSERT_EQ(10U, DroppedBytes());
-  ASSERT_EQ("OK", MatchError("checksum mismatch"));
+  if (!GetParam()) {
+    ASSERT_EQ(14U, DroppedBytes());
+    ASSERT_EQ("OK", MatchError("checksum mismatch"));
+  } else {
+    ASSERT_EQ(0U, DroppedBytes());
+    ASSERT_EQ("", ReportMessage());
+  }
 }
 
-TEST_F(LogTest, UnexpectedMiddleType) {
+TEST_P(LogTest, UnexpectedMiddleType) {
   Write("foo");
-  SetByte(6, kMiddleType);
-  FixChecksum(0, 3);
+  SetByte(6, GetParam() ? kRecyclableMiddleType : kMiddleType);
+  FixChecksum(0, 3, !!GetParam());
   ASSERT_EQ("EOF", Read());
   ASSERT_EQ(3U, DroppedBytes());
   ASSERT_EQ("OK", MatchError("missing start"));
 }
 
-TEST_F(LogTest, UnexpectedLastType) {
+TEST_P(LogTest, UnexpectedLastType) {
   Write("foo");
-  SetByte(6, kLastType);
-  FixChecksum(0, 3);
+  SetByte(6, GetParam() ? kRecyclableLastType : kLastType);
+  FixChecksum(0, 3, !!GetParam());
   ASSERT_EQ("EOF", Read());
   ASSERT_EQ(3U, DroppedBytes());
   ASSERT_EQ("OK", MatchError("missing start"));
 }
 
-TEST_F(LogTest, UnexpectedFullType) {
+TEST_P(LogTest, UnexpectedFullType) {
   Write("foo");
   Write("bar");
-  SetByte(6, kFirstType);
-  FixChecksum(0, 3);
+  SetByte(6, GetParam() ? kRecyclableFirstType : kFirstType);
+  FixChecksum(0, 3, !!GetParam());
   ASSERT_EQ("bar", Read());
   ASSERT_EQ("EOF", Read());
   ASSERT_EQ(3U, DroppedBytes());
   ASSERT_EQ("OK", MatchError("partial record without end"));
 }
 
-TEST_F(LogTest, UnexpectedFirstType) {
+TEST_P(LogTest, UnexpectedFirstType) {
   Write("foo");
   Write(BigString("bar", 100000));
-  SetByte(6, kFirstType);
-  FixChecksum(0, 3);
+  SetByte(6, GetParam() ? kRecyclableFirstType : kFirstType);
+  FixChecksum(0, 3, !!GetParam());
   ASSERT_EQ(BigString("bar", 100000), Read());
   ASSERT_EQ("EOF", Read());
   ASSERT_EQ(3U, DroppedBytes());
   ASSERT_EQ("OK", MatchError("partial record without end"));
 }
 
-TEST_F(LogTest, MissingLastIsIgnored) {
+TEST_P(LogTest, MissingLastIsIgnored) {
   Write(BigString("bar", kBlockSize));
   // Remove the LAST block, including header.
   ShrinkSize(14);
@@ -514,16 +534,16 @@ TEST_F(LogTest, MissingLastIsIgnored) {
   ASSERT_EQ(0U, DroppedBytes());
 }
 
-TEST_F(LogTest, MissingLastIsNotIgnored) {
+TEST_P(LogTest, MissingLastIsNotIgnored) {
   Write(BigString("bar", kBlockSize));
   // Remove the LAST block, including header.
   ShrinkSize(14);
-  ASSERT_EQ("EOF", Read(/*report_eof_inconsistency=*/true));
+  ASSERT_EQ("EOF", Read(WALRecoveryMode::kAbsoluteConsistency));
   ASSERT_GT(DroppedBytes(), 0U);
   ASSERT_EQ("OK", MatchError("Corruption: error reading trailing data"));
 }
 
-TEST_F(LogTest, PartialLastIsIgnored) {
+TEST_P(LogTest, PartialLastIsIgnored) {
   Write(BigString("bar", kBlockSize));
   // Cause a bad record length in the LAST block.
   ShrinkSize(1);
@@ -532,18 +552,18 @@ TEST_F(LogTest, PartialLastIsIgnored) {
   ASSERT_EQ(0U, DroppedBytes());
 }
 
-TEST_F(LogTest, PartialLastIsNotIgnored) {
+TEST_P(LogTest, PartialLastIsNotIgnored) {
   Write(BigString("bar", kBlockSize));
   // Cause a bad record length in the LAST block.
   ShrinkSize(1);
-  ASSERT_EQ("EOF", Read(/*report_eof_inconsistency=*/true));
+  ASSERT_EQ("EOF", Read(WALRecoveryMode::kAbsoluteConsistency));
   ASSERT_GT(DroppedBytes(), 0U);
   ASSERT_EQ("OK", MatchError(
                       "Corruption: truncated headerCorruption: "
                       "error reading trailing data"));
 }
 
-TEST_F(LogTest, ErrorJoinsRecords) {
+TEST_P(LogTest, ErrorJoinsRecords) {
   // Consider two fragmented records:
   //    first(R1) last(R1) first(R2) last(R2)
   // where the middle two fragments disappear.  We do not want
@@ -559,53 +579,71 @@ TEST_F(LogTest, ErrorJoinsRecords) {
     SetByte(offset, 'x');
   }
 
-  ASSERT_EQ("correct", Read());
-  ASSERT_EQ("EOF", Read());
-  size_t dropped = DroppedBytes();
-  ASSERT_LE(dropped, 2 * kBlockSize + 100);
-  ASSERT_GE(dropped, 2 * kBlockSize);
+  if (!GetParam()) {
+    ASSERT_EQ("correct", Read());
+    ASSERT_EQ("EOF", Read());
+    size_t dropped = DroppedBytes();
+    ASSERT_LE(dropped, 2 * kBlockSize + 100);
+    ASSERT_GE(dropped, 2 * kBlockSize);
+  } else {
+    ASSERT_EQ("EOF", Read());
+  }
 }
 
-TEST_F(LogTest, ReadStart) { CheckInitialOffsetRecord(0, 0); }
+TEST_P(LogTest, ReadStart) { CheckInitialOffsetRecord(0, 0); }
 
-TEST_F(LogTest, ReadSecondOneOff) { CheckInitialOffsetRecord(1, 1); }
+TEST_P(LogTest, ReadSecondOneOff) { CheckInitialOffsetRecord(1, 1); }
 
-TEST_F(LogTest, ReadSecondTenThousand) { CheckInitialOffsetRecord(10000, 1); }
+TEST_P(LogTest, ReadSecondTenThousand) { CheckInitialOffsetRecord(10000, 1); }
 
-TEST_F(LogTest, ReadSecondStart) { CheckInitialOffsetRecord(10007, 1); }
+TEST_P(LogTest, ReadSecondStart) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  CheckInitialOffsetRecord(10000 + header_size, 1);
+}
 
-TEST_F(LogTest, ReadThirdOneOff) { CheckInitialOffsetRecord(10008, 2); }
+TEST_P(LogTest, ReadThirdOneOff) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  CheckInitialOffsetRecord(10000 + header_size + 1, 2);
+}
 
-TEST_F(LogTest, ReadThirdStart) { CheckInitialOffsetRecord(20014, 2); }
+TEST_P(LogTest, ReadThirdStart) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  CheckInitialOffsetRecord(20000 + 2 * header_size, 2);
+}
 
-TEST_F(LogTest, ReadFourthOneOff) { CheckInitialOffsetRecord(20015, 3); }
+TEST_P(LogTest, ReadFourthOneOff) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  CheckInitialOffsetRecord(20000 + 2 * header_size + 1, 3);
+}
 
-TEST_F(LogTest, ReadFourthFirstBlockTrailer) {
+TEST_P(LogTest, ReadFourthFirstBlockTrailer) {
   CheckInitialOffsetRecord(log::kBlockSize - 4, 3);
 }
 
-TEST_F(LogTest, ReadFourthMiddleBlock) {
+TEST_P(LogTest, ReadFourthMiddleBlock) {
   CheckInitialOffsetRecord(log::kBlockSize + 1, 3);
 }
 
-TEST_F(LogTest, ReadFourthLastBlock) {
+TEST_P(LogTest, ReadFourthLastBlock) {
   CheckInitialOffsetRecord(2 * log::kBlockSize + 1, 3);
 }
 
-TEST_F(LogTest, ReadFourthStart) {
+TEST_P(LogTest, ReadFourthStart) {
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
   CheckInitialOffsetRecord(
-      2 * (kHeaderSize + 1000) + (2 * log::kBlockSize - 1000) + 3 * kHeaderSize,
+      2 * (header_size + 1000) + (2 * log::kBlockSize - 1000) + 3 * header_size,
       3);
 }
 
-TEST_F(LogTest, ReadEnd) { CheckOffsetPastEndReturnsNoRecords(0); }
+TEST_P(LogTest, ReadEnd) { CheckOffsetPastEndReturnsNoRecords(0); }
 
-TEST_F(LogTest, ReadPastEnd) { CheckOffsetPastEndReturnsNoRecords(5); }
+TEST_P(LogTest, ReadPastEnd) { CheckOffsetPastEndReturnsNoRecords(5); }
 
-TEST_F(LogTest, ClearEofSingleBlock) {
+TEST_P(LogTest, ClearEofSingleBlock) {
   Write("foo");
   Write("bar");
-  ForceEOF(3 + kHeaderSize + 2);
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  ForceEOF(3 + header_size + 2);
   ASSERT_EQ("foo", Read());
   UnmarkEOF();
   ASSERT_EQ("bar", Read());
@@ -617,12 +655,13 @@ TEST_F(LogTest, ClearEofSingleBlock) {
   ASSERT_TRUE(IsEOF());
 }
 
-TEST_F(LogTest, ClearEofMultiBlock) {
+TEST_P(LogTest, ClearEofMultiBlock) {
   size_t num_full_blocks = 5;
-  size_t n = (kBlockSize - kHeaderSize) * num_full_blocks + 25;
+  int header_size = GetParam() ? kRecyclableHeaderSize : kHeaderSize;
+  size_t n = (kBlockSize - header_size) * num_full_blocks + 25;
   Write(BigString("foo", n));
   Write(BigString("bar", n));
-  ForceEOF(n + num_full_blocks * kHeaderSize + 10);
+  ForceEOF(n + num_full_blocks * header_size + header_size + 3);
   ASSERT_EQ(BigString("foo", n), Read());
   ASSERT_TRUE(IsEOF());
   UnmarkEOF();
@@ -634,7 +673,7 @@ TEST_F(LogTest, ClearEofMultiBlock) {
   ASSERT_TRUE(IsEOF());
 }
 
-TEST_F(LogTest, ClearEofError) {
+TEST_P(LogTest, ClearEofError) {
   // If an error occurs during Read() in UnmarkEOF(), the records contained
   // in the buffer should be returned on subsequent calls of ReadRecord()
   // until no more full records are left, whereafter ReadRecord() should return
@@ -652,7 +691,7 @@ TEST_F(LogTest, ClearEofError) {
   ASSERT_EQ("EOF", Read());
 }
 
-TEST_F(LogTest, ClearEofError2) {
+TEST_P(LogTest, ClearEofError2) {
   Write("foo");
   Write("bar");
   UnmarkEOF();
@@ -666,6 +705,31 @@ TEST_F(LogTest, ClearEofError2) {
   ASSERT_EQ("OK", MatchError("read error"));
 }
 
+TEST_P(LogTest, Recycle) {
+  if (!GetParam()) {
+    return;  // test is only valid for recycled logs
+  }
+  Write("foo");
+  Write("bar");
+  Write("baz");
+  Write("bif");
+  Write("blitz");
+  while (get_reader_contents()->size() < log::kBlockSize * 2) {
+    Write("xxxxxxxxxxxxxxxx");
+  }
+  unique_ptr<WritableFileWriter> dest_holder(test::GetWritableFileWriter(
+      new test::OverwritingStringSink(get_reader_contents())));
+  Writer recycle_writer(std::move(dest_holder), 123, true);
+  recycle_writer.AddRecord(Slice("foooo"));
+  recycle_writer.AddRecord(Slice("bar"));
+  ASSERT_GE(get_reader_contents()->size(), log::kBlockSize * 2);
+  ASSERT_EQ("foooo", Read());
+  ASSERT_EQ("bar", Read());
+  ASSERT_EQ("EOF", Read());
+}
+
+INSTANTIATE_TEST_CASE_P(bool, LogTest, ::testing::Values(0, 2));
+
 }  // namespace log
 }  // namespace rocksdb
 
diff --git a/src/rocksdb/db/log_writer.cc b/src/rocksdb/db/log_writer.cc
index 32d4afd..98843bd 100644
--- a/src/rocksdb/db/log_writer.cc
+++ b/src/rocksdb/db/log_writer.cc
@@ -11,6 +11,7 @@
 
 #include <stdint.h>
 #include "rocksdb/env.h"
+#include "rocksdb/options.h"
 #include "util/coding.h"
 #include "util/crc32c.h"
 #include "util/file_reader_writer.h"
@@ -18,8 +19,14 @@
 namespace rocksdb {
 namespace log {
 
-Writer::Writer(unique_ptr<WritableFileWriter>&& dest)
-    : dest_(std::move(dest)), block_offset_(0) {
+Writer::Writer(unique_ptr<WritableFileWriter>&& dest,
+               uint64_t log_number, bool recycle_log_files,
+	       const DBOptions *opt)
+    : db_options_(opt),
+      dest_(std::move(dest)),
+      block_offset_(0),
+      log_number_(log_number),
+      recycle_log_files_(recycle_log_files) {
   for (int i = 0; i <= kMaxRecordType; i++) {
     char t = static_cast<char>(i);
     type_crc_[i] = crc32c::Value(&t, 1);
@@ -33,40 +40,46 @@ Status Writer::AddRecord(const Slice& slice) {
   const char* ptr = slice.data();
   size_t left = slice.size();
 
+  // Header size varies depending on whether we are recycling or not.
+  const int header_size =
+      recycle_log_files_ ? kRecyclableHeaderSize : kHeaderSize;
+
   // Fragment the record if necessary and emit it.  Note that if slice
   // is empty, we still want to iterate once to emit a single
   // zero-length record
   Status s;
   bool begin = true;
   do {
-    const int leftover = kBlockSize - block_offset_;
+    const int64_t leftover = kBlockSize - block_offset_;
     assert(leftover >= 0);
-    if (leftover < kHeaderSize) {
+    if (leftover < header_size) {
       // Switch to a new block
       if (leftover > 0) {
-        // Fill the trailer (literal below relies on kHeaderSize being 7)
-        assert(kHeaderSize == 7);
-        dest_->Append(Slice("\x00\x00\x00\x00\x00\x00", leftover));
+        // Fill the trailer (literal below relies on kHeaderSize and
+        // kRecyclableHeaderSize being <= 11)
+        assert(header_size <= 11);
+        dest_->Append(
+            Slice("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", leftover));
       }
       block_offset_ = 0;
     }
 
-    // Invariant: we never leave < kHeaderSize bytes in a block.
-    assert(static_cast<int>(kBlockSize) - block_offset_ >= kHeaderSize);
+    // Invariant: we never leave < header_size bytes in a block.
+    assert(static_cast<int64_t>(kBlockSize - block_offset_) >= header_size);
 
-    const size_t avail = kBlockSize - block_offset_ - kHeaderSize;
+    const size_t avail = kBlockSize - block_offset_ - header_size;
     const size_t fragment_length = (left < avail) ? left : avail;
 
     RecordType type;
     const bool end = (left == fragment_length);
     if (begin && end) {
-      type = kFullType;
+      type = recycle_log_files_ ? kRecyclableFullType : kFullType;
     } else if (begin) {
-      type = kFirstType;
+      type = recycle_log_files_ ? kRecyclableFirstType : kFirstType;
     } else if (end) {
-      type = kLastType;
+      type = recycle_log_files_ ? kRecyclableLastType : kLastType;
     } else {
-      type = kMiddleType;
+      type = recycle_log_files_ ? kRecyclableMiddleType : kMiddleType;
     }
 
     s = EmitPhysicalRecord(type, ptr, fragment_length);
@@ -79,28 +92,56 @@ Status Writer::AddRecord(const Slice& slice) {
 
 Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
   assert(n <= 0xffff);  // Must fit in two bytes
-  assert(block_offset_ + kHeaderSize + n <= kBlockSize);
+
+  size_t header_size;
+  char buf[kRecyclableHeaderSize];
 
   // Format the header
-  char buf[kHeaderSize];
   buf[4] = static_cast<char>(n & 0xff);
   buf[5] = static_cast<char>(n >> 8);
   buf[6] = static_cast<char>(t);
 
+  uint32_t crc = type_crc_[t];
+  if (t < kRecyclableFullType) {
+    // Legacy record format
+    assert(block_offset_ + kHeaderSize + n <= kBlockSize);
+    header_size = kHeaderSize;
+  } else {
+    // Recyclable record format
+    assert(block_offset_ + kRecyclableHeaderSize + n <= kBlockSize);
+    header_size = kRecyclableHeaderSize;
+
+    // Only encode low 32-bits of the 64-bit log number.  This means
+    // we will fail to detect an old record if we recycled a log from
+    // ~4 billion logs ago, but that is effectively impossible, and
+    // even if it were we'dbe far more likely to see a false positive
+    // on the 32-bit CRC.
+    EncodeFixed32(buf + 7, static_cast<uint32_t>(log_number_));
+    crc = crc32c::Extend(crc, buf + 7, 4);
+  }
+
   // Compute the crc of the record type and the payload.
-  uint32_t crc = crc32c::Extend(type_crc_[t], ptr, n);
-  crc = crc32c::Mask(crc);                 // Adjust for storage
+  crc = crc32c::Extend(crc, ptr, n);
+  crc = crc32c::Mask(crc);  // Adjust for storage
   EncodeFixed32(buf, crc);
 
+  if (db_options_)
+    Log(InfoLogLevel::DEBUG_LEVEL, db_options_->info_log,
+	"EmitPhysicalRecord: log %lld offset %lld len %d crc %d",
+	(unsigned long long)log_number_,
+	(unsigned long long)dest_->GetFileSize(),
+	(int)header_size + (int)n,
+	crc);
+
   // Write the header and the payload
-  Status s = dest_->Append(Slice(buf, kHeaderSize));
+  Status s = dest_->Append(Slice(buf, header_size));
   if (s.ok()) {
     s = dest_->Append(Slice(ptr, n));
     if (s.ok()) {
       s = dest_->Flush();
     }
   }
-  block_offset_ += kHeaderSize + n;
+  block_offset_ += header_size + n;
   return s;
 }
 
diff --git a/src/rocksdb/db/log_writer.h b/src/rocksdb/db/log_writer.h
index 6b59bbd..28f94a0 100644
--- a/src/rocksdb/db/log_writer.h
+++ b/src/rocksdb/db/log_writer.h
@@ -19,6 +19,7 @@
 namespace rocksdb {
 
 class WritableFileWriter;
+class DBOptions;
 
 using std::unique_ptr;
 
@@ -43,7 +44,7 @@ namespace log {
  * Data is written out in kBlockSize chunks. If next record does not fit
  * into the space left, the leftover space will be padded with \0.
  *
- * Record format:
+ * Legacy record format:
  *
  * +---------+-----------+-----------+--- ... ---+
  * |CRC (4B) | Size (2B) | Type (1B) | Payload   |
@@ -57,13 +58,24 @@ namespace log {
  *        blocks that are larger than kBlockSize
  * Payload = Byte stream as long as specified by the payload size
  *
+ * Recyclable record format:
+ *
+ * +---------+-----------+-----------+----------------+--- ... ---+
+ * |CRC (4B) | Size (2B) | Type (1B) | Log number (4B)| Payload   |
+ * +---------+-----------+-----------+----------------+--- ... ---+
+ *
+ * Same as above, with the addition of
+ * Log number = 32bit log file number, so that we can distinguish between
+ * records written by the most recent log writer vs a previous one.
  */
 class Writer {
  public:
   // Create a writer that will append data to "*dest".
   // "*dest" must be initially empty.
   // "*dest" must remain live while this Writer is in use.
-  explicit Writer(unique_ptr<WritableFileWriter>&& dest);
+  explicit Writer(unique_ptr<WritableFileWriter>&& dest,
+                  uint64_t log_number, bool recycle_log_files,
+		  const DBOptions *opt = NULL);
   ~Writer();
 
   Status AddRecord(const Slice& slice);
@@ -72,8 +84,11 @@ class Writer {
   const WritableFileWriter* file() const { return dest_.get(); }
 
  private:
+  const DBOptions *db_options_;
   unique_ptr<WritableFileWriter> dest_;
-  int block_offset_;       // Current offset in block
+  size_t block_offset_;       // Current offset in block
+  uint64_t log_number_;
+  bool recycle_log_files_;
 
   // crc32c values for all supported record types.  These are
   // pre-computed to reduce the overhead of computing the crc of the
diff --git a/src/rocksdb/util/manual_compaction_test.cc b/src/rocksdb/db/manual_compaction_test.cc
similarity index 100%
rename from src/rocksdb/util/manual_compaction_test.cc
rename to src/rocksdb/db/manual_compaction_test.cc
diff --git a/src/rocksdb/db/memtable.cc b/src/rocksdb/db/memtable.cc
index 54c119e..e48e75e 100644
--- a/src/rocksdb/db/memtable.cc
+++ b/src/rocksdb/db/memtable.cc
@@ -21,6 +21,7 @@
 #include "rocksdb/iterator.h"
 #include "rocksdb/merge_operator.h"
 #include "rocksdb/slice_transform.h"
+#include "table/internal_iterator.h"
 #include "table/merger.h"
 #include "util/arena.h"
 #include "util/coding.h"
@@ -202,7 +203,7 @@ const char* EncodeKey(std::string* scratch, const Slice& target) {
   return scratch->data();
 }
 
-class MemTableIterator: public Iterator {
+class MemTableIterator : public InternalIterator {
  public:
   MemTableIterator(
       const MemTable& mem, const ReadOptions& read_options, Arena* arena)
@@ -285,7 +286,8 @@ class MemTableIterator: public Iterator {
   void operator=(const MemTableIterator&);
 };
 
-Iterator* MemTable::NewIterator(const ReadOptions& read_options, Arena* arena) {
+InternalIterator* MemTable::NewIterator(const ReadOptions& read_options,
+                                        Arena* arena) {
   assert(arena != nullptr);
   auto mem = arena->AllocateAligned(sizeof(MemTableIterator));
   return new (mem) MemTableIterator(*this, read_options, arena);
diff --git a/src/rocksdb/db/memtable.h b/src/rocksdb/db/memtable.h
index f09082c..11aa8fe 100644
--- a/src/rocksdb/db/memtable.h
+++ b/src/rocksdb/db/memtable.h
@@ -31,6 +31,7 @@ class Mutex;
 class MemTableIterator;
 class MergeContext;
 class WriteBuffer;
+class InternalIterator;
 
 struct MemTableOptions {
   explicit MemTableOptions(
@@ -140,7 +141,7 @@ class MemTable {
   // arena: If not null, the arena needs to be used to allocate the Iterator.
   //        Calling ~Iterator of the iterator will destroy all the states but
   //        those allocated in arena.
-  Iterator* NewIterator(const ReadOptions& read_options, Arena* arena);
+  InternalIterator* NewIterator(const ReadOptions& read_options, Arena* arena);
 
   // Add an entry into memtable that maps key to value at the
   // specified sequence number and with the specified type.
diff --git a/src/rocksdb/db/memtable_list.cc b/src/rocksdb/db/memtable_list.cc
index b2bbbd1..1734eda 100644
--- a/src/rocksdb/db/memtable_list.cc
+++ b/src/rocksdb/db/memtable_list.cc
@@ -138,9 +138,9 @@ bool MemTableListVersion::GetFromList(std::list<MemTable*>* list,
   return false;
 }
 
-void MemTableListVersion::AddIterators(const ReadOptions& options,
-                                       std::vector<Iterator*>* iterator_list,
-                                       Arena* arena) {
+void MemTableListVersion::AddIterators(
+    const ReadOptions& options, std::vector<InternalIterator*>* iterator_list,
+    Arena* arena) {
   for (auto& m : memlist_) {
     iterator_list->push_back(m->NewIterator(options, arena));
   }
diff --git a/src/rocksdb/db/memtable_list.h b/src/rocksdb/db/memtable_list.h
index 63e2773..117b4a5 100644
--- a/src/rocksdb/db/memtable_list.h
+++ b/src/rocksdb/db/memtable_list.h
@@ -74,7 +74,8 @@ class MemTableListVersion {
   }
 
   void AddIterators(const ReadOptions& options,
-                    std::vector<Iterator*>* iterator_list, Arena* arena);
+                    std::vector<InternalIterator*>* iterator_list,
+                    Arena* arena);
 
   void AddIterators(const ReadOptions& options,
                     MergeIteratorBuilder* merge_iter_builder);
diff --git a/src/rocksdb/db/memtablerep_bench.cc b/src/rocksdb/db/memtablerep_bench.cc
index a2a8722..42edfdf 100644
--- a/src/rocksdb/db/memtablerep_bench.cc
+++ b/src/rocksdb/db/memtablerep_bench.cc
@@ -132,8 +132,6 @@ DEFINE_int64(seed, 0,
              "Seed base for random number generators. "
              "When 0 it is deterministic.");
 
-static rocksdb::Env* FLAGS_env = rocksdb::Env::Default();
-
 namespace rocksdb {
 
 namespace {
@@ -592,6 +590,7 @@ int main(int argc, char** argv) {
   std::unique_ptr<rocksdb::MemTableRepFactory> factory;
   if (FLAGS_memtablerep == "skiplist") {
     factory.reset(new rocksdb::SkipListFactory);
+#ifndef ROCKSDB_LITE
   } else if (FLAGS_memtablerep == "vector") {
     factory.reset(new rocksdb::VectorRepFactory);
   } else if (FLAGS_memtablerep == "hashskiplist") {
@@ -613,6 +612,7 @@ int main(int argc, char** argv) {
         static_cast<uint32_t>(FLAGS_hash_function_count)));
     options.prefix_extractor.reset(
         rocksdb::NewFixedPrefixTransform(FLAGS_prefix_length));
+#endif  // ROCKSDB_LITE
   } else {
     fprintf(stdout, "Unknown memtablerep: %s\n", FLAGS_memtablerep.c_str());
     exit(1);
diff --git a/src/rocksdb/db/merge_helper.cc b/src/rocksdb/db/merge_helper.cc
index f9cb67e..c443ca2 100644
--- a/src/rocksdb/db/merge_helper.cc
+++ b/src/rocksdb/db/merge_helper.cc
@@ -12,6 +12,7 @@
 #include "rocksdb/comparator.h"
 #include "rocksdb/db.h"
 #include "rocksdb/merge_operator.h"
+#include "table/internal_iterator.h"
 #include "util/perf_context_imp.h"
 #include "util/statistics.h"
 
@@ -56,7 +57,8 @@ Status MergeHelper::TimedFullMerge(const Slice& key, const Slice* value,
 //       keys_ stores the list of keys encountered while merging.
 //       operands_ stores the list of merge operands encountered while merging.
 //       keys_[i] corresponds to operands_[i] for each i.
-Status MergeHelper::MergeUntil(Iterator* iter, const SequenceNumber stop_before,
+Status MergeHelper::MergeUntil(InternalIterator* iter,
+                               const SequenceNumber stop_before,
                                const bool at_bottom) {
   // Get a copy of the internal key, before it's invalidated by iter->Next()
   // Also maintain the list of merge operands seen.
diff --git a/src/rocksdb/db/merge_helper.h b/src/rocksdb/db/merge_helper.h
index ade3d71..488c7ac 100644
--- a/src/rocksdb/db/merge_helper.h
+++ b/src/rocksdb/db/merge_helper.h
@@ -22,6 +22,7 @@ class Iterator;
 class Logger;
 class MergeOperator;
 class Statistics;
+class InternalIterator;
 
 class MergeHelper {
  public:
@@ -82,7 +83,8 @@ class MergeHelper {
   //   with asserts removed).
   //
   // REQUIRED: The first key in the input is not corrupted.
-  Status MergeUntil(Iterator* iter, const SequenceNumber stop_before = 0,
+  Status MergeUntil(InternalIterator* iter,
+                    const SequenceNumber stop_before = 0,
                     const bool at_bottom = false);
 
   // Filters a merge operand using the compaction filter specified
diff --git a/src/rocksdb/db/options_file_test.cc b/src/rocksdb/db/options_file_test.cc
new file mode 100644
index 0000000..86a9889
--- /dev/null
+++ b/src/rocksdb/db/options_file_test.cc
@@ -0,0 +1,119 @@
+//  Copyright (c) 2015, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+#include <string>
+
+#include "db/db_impl.h"
+#include "db/db_test_util.h"
+#include "rocksdb/options.h"
+#include "rocksdb/table.h"
+#include "util/testharness.h"
+
+namespace rocksdb {
+class OptionsFileTest : public testing::Test {
+ public:
+  OptionsFileTest() : dbname_(test::TmpDir() + "/options_file_test") {}
+
+  std::string dbname_;
+};
+
+namespace {
+void UpdateOptionsFiles(DB* db,
+                        std::unordered_set<std::string>* filename_history,
+                        int* options_files_count) {
+  std::vector<std::string> filenames;
+  db->GetEnv()->GetChildren(db->GetName(), &filenames);
+  uint64_t number;
+  FileType type;
+  *options_files_count = 0;
+  for (auto filename : filenames) {
+    if (ParseFileName(filename, &number, &type) && type == kOptionsFile) {
+      filename_history->insert(filename);
+      (*options_files_count)++;
+    }
+  }
+}
+
+// Verify whether the current Options Files are the latest ones.
+void VerifyOptionsFileName(
+    DB* db, const std::unordered_set<std::string>& past_filenames) {
+  std::vector<std::string> filenames;
+  std::unordered_set<std::string> current_filenames;
+  db->GetEnv()->GetChildren(db->GetName(), &filenames);
+  uint64_t number;
+  FileType type;
+  for (auto filename : filenames) {
+    if (ParseFileName(filename, &number, &type) && type == kOptionsFile) {
+      current_filenames.insert(filename);
+    }
+  }
+  for (auto past_filename : past_filenames) {
+    if (current_filenames.find(past_filename) != current_filenames.end()) {
+      continue;
+    }
+    for (auto filename : current_filenames) {
+      ASSERT_GT(filename, past_filename);
+    }
+  }
+}
+}  // namespace
+
+TEST_F(OptionsFileTest, NumberOfOptionsFiles) {
+  const int kReopenCount = 20;
+  Options opt;
+  opt.create_if_missing = true;
+  DestroyDB(dbname_, opt);
+  std::unordered_set<std::string> filename_history;
+  DB* db;
+  for (int i = 0; i < kReopenCount; ++i) {
+    ASSERT_OK(DB::Open(opt, dbname_, &db));
+    int num_options_files = 0;
+    UpdateOptionsFiles(db, &filename_history, &num_options_files);
+    ASSERT_GT(num_options_files, 0);
+    ASSERT_LE(num_options_files, 2);
+    // Make sure we always keep the latest option files.
+    VerifyOptionsFileName(db, filename_history);
+    delete db;
+  }
+}
+
+TEST_F(OptionsFileTest, OptionsFileName) {
+  const uint64_t kOptionsFileNum = 12345;
+  uint64_t number;
+  FileType type;
+
+  auto options_file_name = OptionsFileName("", kOptionsFileNum);
+  ASSERT_TRUE(ParseFileName(options_file_name, &number, &type, nullptr));
+  ASSERT_EQ(type, kOptionsFile);
+  ASSERT_EQ(number, kOptionsFileNum);
+
+  const uint64_t kTempOptionsFileNum = 54352;
+  auto temp_options_file_name = TempOptionsFileName("", kTempOptionsFileNum);
+  ASSERT_TRUE(ParseFileName(temp_options_file_name, &number, &type, nullptr));
+  ASSERT_NE(temp_options_file_name.find(kTempFileNameSuffix),
+            std::string::npos);
+  ASSERT_EQ(type, kTempFile);
+  ASSERT_EQ(number, kTempOptionsFileNum);
+}
+}  // namespace rocksdb
+
+int main(int argc, char** argv) {
+#if !(defined NDEBUG) || !defined(OS_WIN)
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+#else
+  return 0;
+#endif  // !(defined NDEBUG) || !defined(OS_WIN)
+}
+#else
+
+#include <cstdio>
+
+int main(int argc, char** argv) {
+  printf("Skipped as Options file is not supported in RocksDBLite.\n");
+  return 0;
+}
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/db/perf_context_test.cc b/src/rocksdb/db/perf_context_test.cc
index 359562a..00065dc 100644
--- a/src/rocksdb/db/perf_context_test.cc
+++ b/src/rocksdb/db/perf_context_test.cc
@@ -5,6 +5,7 @@
 //
 #include <algorithm>
 #include <iostream>
+#include <thread>
 #include <vector>
 
 #include "rocksdb/db.h"
@@ -444,6 +445,7 @@ void ProfileQueries(bool enabled_time = false) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(PerfContextTest, KeyComparisonCount) {
   SetPerfLevel(kEnableCount);
   ProfileQueries();
@@ -454,6 +456,7 @@ TEST_F(PerfContextTest, KeyComparisonCount) {
   SetPerfLevel(kEnableTime);
   ProfileQueries(true);
 }
+#endif  // ROCKSDB_LITE
 
 // make perf_context_test
 // export ROCKSDB_TESTS=PerfContextTest.SeekKeyComparison
@@ -539,6 +542,49 @@ TEST_F(PerfContextTest, SeekKeyComparison) {
   }
 }
 
+TEST_F(PerfContextTest, DBMutexLockCounter) {
+  SetPerfLevel(kEnableTime);
+  int stats_code[] = {0, static_cast<int>(DB_MUTEX_WAIT_MICROS)};
+  for (int c = 0; c < 2; ++c) {
+    InstrumentedMutex mutex(nullptr, Env::Default(), stats_code[c]);
+    mutex.Lock();
+    std::thread child_thread([&] {
+      SetPerfLevel(kEnableTime);
+      perf_context.Reset();
+      ASSERT_EQ(perf_context.db_mutex_lock_nanos, 0);
+      mutex.Lock();
+      mutex.Unlock();
+      if (stats_code[c] == DB_MUTEX_WAIT_MICROS) {
+        // increment the counter only when it's a DB Mutex
+        ASSERT_GT(perf_context.db_mutex_lock_nanos, 0);
+      } else {
+        ASSERT_EQ(perf_context.db_mutex_lock_nanos, 0);
+      }
+    });
+    Env::Default()->SleepForMicroseconds(100);
+    mutex.Unlock();
+    child_thread.join();
+  }
+}
+
+TEST_F(PerfContextTest, FalseDBMutexWait) {
+  SetPerfLevel(kEnableTime);
+  int stats_code[] = {0, static_cast<int>(DB_MUTEX_WAIT_MICROS)};
+  for (int c = 0; c < 2; ++c) {
+    InstrumentedMutex mutex(nullptr, Env::Default(), stats_code[c]);
+    InstrumentedCondVar lock(&mutex);
+    perf_context.Reset();
+    mutex.Lock();
+    lock.TimedWait(100);
+    mutex.Unlock();
+    if (stats_code[c] == static_cast<int>(DB_MUTEX_WAIT_MICROS)) {
+      // increment the counter only when it's a DB Mutex
+      ASSERT_GT(perf_context.db_condition_wait_nanos, 0);
+    } else {
+      ASSERT_EQ(perf_context.db_condition_wait_nanos, 0);
+    }
+  }
+}
 }
 
 int main(int argc, char** argv) {
diff --git a/src/rocksdb/db/prefix_test.cc b/src/rocksdb/db/prefix_test.cc
index d095d44..a210e4d 100644
--- a/src/rocksdb/db/prefix_test.cc
+++ b/src/rocksdb/db/prefix_test.cc
@@ -20,9 +20,11 @@ int main() {
 #include <gflags/gflags.h>
 #include "rocksdb/comparator.h"
 #include "rocksdb/db.h"
+#include "rocksdb/filter_policy.h"
 #include "rocksdb/perf_context.h"
 #include "rocksdb/slice_transform.h"
 #include "rocksdb/memtablerep.h"
+#include "rocksdb/table.h"
 #include "util/histogram.h"
 #include "util/stop_watch.h"
 #include "util/string_util.h"
@@ -163,6 +165,12 @@ class PrefixTest : public testing::Test {
     options.memtable_prefix_bloom_huge_page_tlb_size =
         FLAGS_memtable_prefix_bloom_huge_page_tlb_size;
 
+    options.prefix_extractor.reset(NewFixedPrefixTransform(8));
+    BlockBasedTableOptions bbto;
+    bbto.filter_policy.reset(NewBloomFilterPolicy(10, false));
+    bbto.whole_key_filtering = false;
+    options.table_factory.reset(NewBlockBasedTableFactory(bbto));
+
     Status s = DB::Open(options, kDbName,  &db);
     EXPECT_OK(s);
     return std::shared_ptr<DB>(db);
@@ -393,6 +401,55 @@ TEST_F(PrefixTest, TestResult) {
   }
 }
 
+// Show results in prefix
+TEST_F(PrefixTest, PrefixValid) {
+  for (int num_buckets = 1; num_buckets <= 2; num_buckets++) {
+    FirstOption();
+    while (NextOptions(num_buckets)) {
+      std::cout << "*** Mem table: " << options.memtable_factory->Name()
+                << " number of buckets: " << num_buckets << std::endl;
+      DestroyDB(kDbName, Options());
+      auto db = OpenDb();
+      WriteOptions write_options;
+      ReadOptions read_options;
+
+      // Insert keys with common prefix and one key with different
+      Slice v16("v16");
+      Slice v17("v17");
+      Slice v18("v18");
+      Slice v19("v19");
+      PutKey(db.get(), write_options, 12345, 6, v16);
+      PutKey(db.get(), write_options, 12345, 7, v17);
+      PutKey(db.get(), write_options, 12345, 8, v18);
+      PutKey(db.get(), write_options, 12345, 9, v19);
+      PutKey(db.get(), write_options, 12346, 8, v16);
+      db->Flush(FlushOptions());
+      db->Delete(write_options, TestKeyToSlice(TestKey(12346, 8)));
+      db->Flush(FlushOptions());
+      read_options.prefix_same_as_start = true;
+      std::unique_ptr<Iterator> iter(db->NewIterator(read_options));
+      SeekIterator(iter.get(), 12345, 6);
+      ASSERT_TRUE(iter->Valid());
+      ASSERT_TRUE(v16 == iter->value());
+
+      iter->Next();
+      ASSERT_TRUE(iter->Valid());
+      ASSERT_TRUE(v17 == iter->value());
+
+      iter->Next();
+      ASSERT_TRUE(iter->Valid());
+      ASSERT_TRUE(v18 == iter->value());
+
+      iter->Next();
+      ASSERT_TRUE(iter->Valid());
+      ASSERT_TRUE(v19 == iter->value());
+      iter->Next();
+      ASSERT_FALSE(iter->Valid());
+      ASSERT_EQ(kNotFoundResult, Get(db.get(), read_options, 12346, 8));
+    }
+  }
+}
+
 TEST_F(PrefixTest, DynamicPrefixIterator) {
   while (NextOptions(FLAGS_bucket_count)) {
     std::cout << "*** Mem table: " << options.memtable_factory->Name()
diff --git a/src/rocksdb/db/repair.cc b/src/rocksdb/db/repair.cc
index d1ef6db..c27db6e 100644
--- a/src/rocksdb/db/repair.cc
+++ b/src/rocksdb/db/repair.cc
@@ -81,8 +81,8 @@
 #include "rocksdb/env.h"
 #include "rocksdb/options.h"
 #include "rocksdb/immutable_options.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/file_reader_writer.h"
-#include "util/scoped_arena_iterator.h"
 
 namespace rocksdb {
 
@@ -249,8 +249,8 @@ class Repairer {
     // corruptions cause entire commits to be skipped instead of
     // propagating bad information (like overly large sequence
     // numbers).
-    log::Reader reader(std::move(lfile_reader), &reporter,
-                       true /*enable checksum*/, 0 /*initial_offset*/);
+    log::Reader reader(options_.info_log, std::move(lfile_reader), &reporter,
+                       true /*enable checksum*/, 0 /*initial_offset*/, log);
 
     // Read all the records and add to a memtable
     std::string scratch;
@@ -290,10 +290,11 @@ class Repairer {
       ro.total_order_seek = true;
       Arena arena;
       ScopedArenaIterator iter(mem->NewIterator(ro, &arena));
-      status = BuildTable(dbname_, env_, ioptions_, env_options_, table_cache_,
-                          iter.get(), &meta, icmp_,
-                          &int_tbl_prop_collector_factories_, {},
-                          kNoCompression, CompressionOptions(), false, nullptr);
+      status = BuildTable(
+          dbname_, env_, ioptions_, env_options_, table_cache_, iter.get(),
+          &meta, icmp_, &int_tbl_prop_collector_factories_,
+          TablePropertiesCollectorFactory::Context::kUnknownColumnFamily, {},
+          kNoCompression, CompressionOptions(), false, nullptr);
     }
     delete mem->Unref();
     delete cf_mems_default;
@@ -339,7 +340,7 @@ class Repairer {
     t->meta.fd = FileDescriptor(t->meta.fd.GetNumber(), t->meta.fd.GetPathId(),
                                 file_size);
     if (status.ok()) {
-      Iterator* iter = table_cache_->NewIterator(
+      InternalIterator* iter = table_cache_->NewIterator(
           ReadOptions(), env_options_, icmp_, t->meta.fd);
       bool empty = true;
       ParsedInternalKey parsed;
@@ -412,7 +413,7 @@ class Repairer {
     {
       unique_ptr<WritableFileWriter> file_writer(
           new WritableFileWriter(std::move(file), env_options));
-      log::Writer log(std::move(file_writer));
+      log::Writer log(std::move(file_writer), 0, false);
       std::string record;
       edit_->EncodeTo(&record);
       status = log.AddRecord(record);
diff --git a/src/rocksdb/db/skiplist.h b/src/rocksdb/db/skiplist.h
index 787fad5..b80ecf2 100644
--- a/src/rocksdb/db/skiplist.h
+++ b/src/rocksdb/db/skiplist.h
@@ -107,8 +107,9 @@ class SkipList {
   };
 
  private:
-  const int32_t kMaxHeight_;
-  const int32_t kBranching_;
+  const uint16_t kMaxHeight_;
+  const uint16_t kBranching_;
+  const uint32_t kScaledInverseBranching_;
 
   // Immutable after construction
   Comparator const compare_;
@@ -131,9 +132,6 @@ class SkipList {
     return max_height_.load(std::memory_order_relaxed);
   }
 
-  // Read/written only by Insert().
-  Random rnd_;
-
   Node* NewNode(const Key& key, int height);
   int RandomHeight();
   bool Equal(const Key& a, const Key& b) const { return (compare_(a, b) == 0); }
@@ -264,9 +262,11 @@ inline void SkipList<Key, Comparator>::Iterator::SeekToLast() {
 
 template<typename Key, class Comparator>
 int SkipList<Key, Comparator>::RandomHeight() {
+  auto rnd = Random::GetTLSInstance();
+
   // Increase height with probability 1 in kBranching
   int height = 1;
-  while (height < kMaxHeight_ && ((rnd_.Next() % kBranching_) == 0)) {
+  while (height < kMaxHeight_ && rnd->Next() < kScaledInverseBranching_) {
     height++;
   }
   assert(height > 0);
@@ -391,14 +391,16 @@ SkipList<Key, Comparator>::SkipList(const Comparator cmp, Allocator* allocator,
                                     int32_t branching_factor)
     : kMaxHeight_(max_height),
       kBranching_(branching_factor),
+      kScaledInverseBranching_((Random::kMaxNext + 1) / kBranching_),
       compare_(cmp),
       allocator_(allocator),
       head_(NewNode(0 /* any key will do */, max_height)),
       max_height_(1),
-      prev_height_(1),
-      rnd_(0xdeadbeef) {
-  assert(kMaxHeight_ > 0);
-  assert(kBranching_ > 0);
+      prev_height_(1) {
+  assert(max_height > 0 && kMaxHeight_ == static_cast<uint32_t>(max_height));
+  assert(branching_factor > 0 &&
+         kBranching_ == static_cast<uint32_t>(branching_factor));
+  assert(kScaledInverseBranching_ > 0);
   // Allocate the prev_ Node* array, directly from the passed-in allocator.
   // prev_ does not need to be freed, as its life cycle is tied up with
   // the allocator as a whole.
diff --git a/src/rocksdb/db/snapshot_impl.cc b/src/rocksdb/db/snapshot_impl.cc
index 1546d68..d901b61 100644
--- a/src/rocksdb/db/snapshot_impl.cc
+++ b/src/rocksdb/db/snapshot_impl.cc
@@ -12,6 +12,9 @@ namespace rocksdb {
 ManagedSnapshot::ManagedSnapshot(DB* db) : db_(db),
                                            snapshot_(db->GetSnapshot()) {}
 
+ManagedSnapshot::ManagedSnapshot(DB* db, const Snapshot* _snapshot)
+    : db_(db), snapshot_(_snapshot) {}
+
 ManagedSnapshot::~ManagedSnapshot() {
   if (snapshot_) {
     db_->ReleaseSnapshot(snapshot_);
diff --git a/src/rocksdb/db/snapshot_impl.h b/src/rocksdb/db/snapshot_impl.h
index b4d58fd..4fa0bb9 100644
--- a/src/rocksdb/db/snapshot_impl.h
+++ b/src/rocksdb/db/snapshot_impl.h
@@ -34,6 +34,9 @@ class SnapshotImpl : public Snapshot {
   SnapshotList* list_;                 // just for sanity checks
 
   int64_t unix_time_;
+
+  // Will this snapshot be used by a Transaction to do write-conflict checking?
+  bool is_write_conflict_boundary_;
 };
 
 class SnapshotList {
@@ -50,9 +53,10 @@ class SnapshotList {
   SnapshotImpl* newest() const { assert(!empty()); return list_.prev_; }
 
   const SnapshotImpl* New(SnapshotImpl* s, SequenceNumber seq,
-                          uint64_t unix_time) {
+                          uint64_t unix_time, bool is_write_conflict_boundary) {
     s->number_ = seq;
     s->unix_time_ = unix_time;
+    s->is_write_conflict_boundary_ = is_write_conflict_boundary;
     s->list_ = this;
     s->next_ = &list_;
     s->prev_ = list_.prev_;
@@ -71,14 +75,29 @@ class SnapshotList {
   }
 
   // retrieve all snapshot numbers. They are sorted in ascending order.
-  std::vector<SequenceNumber> GetAll() {
+  std::vector<SequenceNumber> GetAll(
+      SequenceNumber* oldest_write_conflict_snapshot = nullptr) {
     std::vector<SequenceNumber> ret;
+
+    if (oldest_write_conflict_snapshot != nullptr) {
+      *oldest_write_conflict_snapshot = kMaxSequenceNumber;
+    }
+
     if (empty()) {
       return ret;
     }
     SnapshotImpl* s = &list_;
     while (s->next_ != &list_) {
       ret.push_back(s->next_->number_);
+
+      if (oldest_write_conflict_snapshot != nullptr &&
+          *oldest_write_conflict_snapshot != kMaxSequenceNumber &&
+          s->next_->is_write_conflict_boundary_) {
+        // If this is the first write-conflict boundary snapshot in the list,
+        // it is the oldest
+        *oldest_write_conflict_snapshot = s->next_->number_;
+      }
+
       s = s->next_;
     }
     return ret;
diff --git a/src/rocksdb/db/table_cache.cc b/src/rocksdb/db/table_cache.cc
index b240fc7..82b52dd 100644
--- a/src/rocksdb/db/table_cache.cc
+++ b/src/rocksdb/db/table_cache.cc
@@ -14,6 +14,7 @@
 #include "db/version_edit.h"
 
 #include "rocksdb/statistics.h"
+#include "table/internal_iterator.h"
 #include "table/iterator_wrapper.h"
 #include "table/table_builder.h"
 #include "table/table_reader.h"
@@ -148,13 +149,11 @@ Status TableCache::FindTable(const EnvOptions& env_options,
   return s;
 }
 
-Iterator* TableCache::NewIterator(const ReadOptions& options,
-                                  const EnvOptions& env_options,
-                                  const InternalKeyComparator& icomparator,
-                                  const FileDescriptor& fd,
-                                  TableReader** table_reader_ptr,
-                                  HistogramImpl* file_read_hist,
-                                  bool for_compaction, Arena* arena) {
+InternalIterator* TableCache::NewIterator(
+    const ReadOptions& options, const EnvOptions& env_options,
+    const InternalKeyComparator& icomparator, const FileDescriptor& fd,
+    TableReader** table_reader_ptr, HistogramImpl* file_read_hist,
+    bool for_compaction, Arena* arena) {
   PERF_TIMER_GUARD(new_table_iterator_nanos);
 
   if (table_reader_ptr != nullptr) {
@@ -171,7 +170,7 @@ Iterator* TableCache::NewIterator(const ReadOptions& options,
         env_options, icomparator, fd, /* sequential mode */ true,
         /* record stats */ false, nullptr, &table_reader_unique_ptr);
     if (!s.ok()) {
-      return NewErrorIterator(s, arena);
+      return NewErrorInternalIterator(s, arena);
     }
     table_reader = table_reader_unique_ptr.release();
   } else {
@@ -182,13 +181,13 @@ Iterator* TableCache::NewIterator(const ReadOptions& options,
                     options.read_tier == kBlockCacheTier /* no_io */,
                     !for_compaction /* record read_stats */, file_read_hist);
       if (!s.ok()) {
-        return NewErrorIterator(s, arena);
+        return NewErrorInternalIterator(s, arena);
       }
       table_reader = GetTableReaderFromHandle(handle);
     }
   }
 
-  Iterator* result = table_reader->NewIterator(options, arena);
+  InternalIterator* result = table_reader->NewIterator(options, arena);
 
   if (create_new_table_reader) {
     assert(handle == nullptr);
diff --git a/src/rocksdb/db/table_cache.h b/src/rocksdb/db/table_cache.h
index d9ae013..631946e 100644
--- a/src/rocksdb/db/table_cache.h
+++ b/src/rocksdb/db/table_cache.h
@@ -29,6 +29,7 @@ class Arena;
 struct FileDescriptor;
 class GetContext;
 class HistogramImpl;
+class InternalIterator;
 
 class TableCache {
  public:
@@ -43,12 +44,12 @@ class TableCache {
   // the returned iterator.  The returned "*tableptr" object is owned by
   // the cache and should not be deleted, and is valid for as long as the
   // returned iterator is live.
-  Iterator* NewIterator(const ReadOptions& options, const EnvOptions& toptions,
-                        const InternalKeyComparator& internal_comparator,
-                        const FileDescriptor& file_fd,
-                        TableReader** table_reader_ptr = nullptr,
-                        HistogramImpl* file_read_hist = nullptr,
-                        bool for_compaction = false, Arena* arena = nullptr);
+  InternalIterator* NewIterator(
+      const ReadOptions& options, const EnvOptions& toptions,
+      const InternalKeyComparator& internal_comparator,
+      const FileDescriptor& file_fd, TableReader** table_reader_ptr = nullptr,
+      HistogramImpl* file_read_hist = nullptr, bool for_compaction = false,
+      Arena* arena = nullptr);
 
   // If a seek to internal key "k" in specified file finds an entry,
   // call (*handle_result)(arg, found_key, found_value) repeatedly until
diff --git a/src/rocksdb/db/table_properties_collector.h b/src/rocksdb/db/table_properties_collector.h
index 51c2ba9..0e5f4e3 100644
--- a/src/rocksdb/db/table_properties_collector.h
+++ b/src/rocksdb/db/table_properties_collector.h
@@ -41,7 +41,8 @@ class IntTblPropCollectorFactory {
  public:
   virtual ~IntTblPropCollectorFactory() {}
   // has to be thread-safe
-  virtual IntTblPropCollector* CreateIntTblPropCollector() = 0;
+  virtual IntTblPropCollector* CreateIntTblPropCollector(
+      uint32_t column_family_id) = 0;
 
   // The name of the properties collector can be used for debugging purpose.
   virtual const char* Name() const = 0;
@@ -69,7 +70,8 @@ class InternalKeyPropertiesCollector : public IntTblPropCollector {
 class InternalKeyPropertiesCollectorFactory
     : public IntTblPropCollectorFactory {
  public:
-  virtual IntTblPropCollector* CreateIntTblPropCollector() override {
+  virtual IntTblPropCollector* CreateIntTblPropCollector(
+      uint32_t column_family_id) override {
     return new InternalKeyPropertiesCollector();
   }
 
@@ -114,9 +116,12 @@ class UserKeyTablePropertiesCollectorFactory
   explicit UserKeyTablePropertiesCollectorFactory(
       std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory)
       : user_collector_factory_(user_collector_factory) {}
-  virtual IntTblPropCollector* CreateIntTblPropCollector() override {
+  virtual IntTblPropCollector* CreateIntTblPropCollector(
+      uint32_t column_family_id) override {
+    TablePropertiesCollectorFactory::Context context;
+    context.column_family_id = column_family_id;
     return new UserKeyTablePropertiesCollector(
-        user_collector_factory_->CreateTablePropertiesCollector());
+        user_collector_factory_->CreateTablePropertiesCollector(context));
   }
 
   virtual const char* Name() const override {
diff --git a/src/rocksdb/db/table_properties_collector_test.cc b/src/rocksdb/db/table_properties_collector_test.cc
index 0eeed81..7cea86f 100644
--- a/src/rocksdb/db/table_properties_collector_test.cc
+++ b/src/rocksdb/db/table_properties_collector_test.cc
@@ -35,6 +35,8 @@ class TablePropertiesTest : public testing::Test,
 
 // Utilities test functions
 namespace {
+static const uint32_t kTestColumnFamilyId = 66;
+
 void MakeBuilder(const Options& options, const ImmutableCFOptions& ioptions,
                  const InternalKeyComparator& internal_comparator,
                  const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
@@ -46,7 +48,8 @@ void MakeBuilder(const Options& options, const ImmutableCFOptions& ioptions,
 
   builder->reset(NewTableBuilder(
       ioptions, internal_comparator, int_tbl_prop_collector_factories,
-      writable->get(), options.compression, options.compression_opts));
+      kTestColumnFamilyId /* column_family_id */, writable->get(),
+      options.compression, options.compression_opts));
 }
 }  // namespace
 
@@ -178,14 +181,17 @@ class RegularKeysStartWithAFactory : public IntTblPropCollectorFactory,
  public:
   explicit RegularKeysStartWithAFactory(bool backward_mode)
       : backward_mode_(backward_mode) {}
-  virtual TablePropertiesCollector* CreateTablePropertiesCollector() override {
+  virtual TablePropertiesCollector* CreateTablePropertiesCollector(
+      TablePropertiesCollectorFactory::Context context) override {
+    EXPECT_EQ(kTestColumnFamilyId, context.column_family_id);
     if (!backward_mode_) {
       return new RegularKeysStartWithA();
     } else {
       return new RegularKeysStartWithABackwardCompatible();
     }
   }
-  virtual IntTblPropCollector* CreateIntTblPropCollector() override {
+  virtual IntTblPropCollector* CreateIntTblPropCollector(
+      uint32_t column_family_id) override {
     return new RegularKeysStartWithAInternal();
   }
   const char* Name() const override { return "RegularKeysStartWithA"; }
diff --git a/src/rocksdb/db/transaction_log_impl.cc b/src/rocksdb/db/transaction_log_impl.cc
index 23bd667..28c4490 100644
--- a/src/rocksdb/db/transaction_log_impl.cc
+++ b/src/rocksdb/db/transaction_log_impl.cc
@@ -262,8 +262,10 @@ Status TransactionLogIteratorImpl::OpenLogReader(const LogFile* logFile) {
     return s;
   }
   assert(file);
-  currentLogReader_.reset(new log::Reader(std::move(file), &reporter_,
-                                          read_options_.verify_checksums_, 0));
+  currentLogReader_.reset(new log::Reader(options_->info_log,
+					  std::move(file), &reporter_,
+                                          read_options_.verify_checksums_, 0,
+                                          logFile->LogNumber()));
   return Status::OK();
 }
 }  //  namespace rocksdb
diff --git a/src/rocksdb/db/version_builder.cc b/src/rocksdb/db/version_builder.cc
index 7444bfc..d6b1858 100644
--- a/src/rocksdb/db/version_builder.cc
+++ b/src/rocksdb/db/version_builder.cc
@@ -82,6 +82,7 @@ class VersionBuilder::Rep {
   };
 
   const EnvOptions& env_options_;
+  Logger* info_log_;
   TableCache* table_cache_;
   VersionStorageInfo* base_vstorage_;
   LevelState* levels_;
@@ -89,9 +90,10 @@ class VersionBuilder::Rep {
   FileComparator level_nonzero_cmp_;
 
  public:
-  Rep(const EnvOptions& env_options, TableCache* table_cache,
+  Rep(const EnvOptions& env_options, Logger* info_log, TableCache* table_cache,
       VersionStorageInfo* base_vstorage)
       : env_options_(env_options),
+        info_log_(info_log),
         table_cache_(table_cache),
         base_vstorage_(base_vstorage) {
     levels_ = new LevelState[base_vstorage_->num_levels()];
@@ -134,7 +136,10 @@ class VersionBuilder::Rep {
         auto f2 = level_files[i];
         if (level == 0) {
           assert(level_zero_cmp_(f1, f2));
-          assert(f1->largest_seqno > f2->largest_seqno);
+          assert(f1->largest_seqno > f2->largest_seqno ||
+                 // We can have multiple files with seqno = 0 as a result of
+                 // using DB::AddFile()
+                 (f1->largest_seqno == 0 && f2->largest_seqno == 0));
         } else {
           assert(level_nonzero_cmp_(f1, f2));
 
@@ -333,17 +338,19 @@ class VersionBuilder::Rep {
 
   void MaybeAddFile(VersionStorageInfo* vstorage, int level, FileMetaData* f) {
     if (levels_[level].deleted_files.count(f->fd.GetNumber()) > 0) {
-      // File is deleted: do nothing
+      // f is to-be-delected table file
+      vstorage->RemoveCurrentStats(f);
     } else {
-      vstorage->AddFile(level, f);
+      vstorage->AddFile(level, f, info_log_);
     }
   }
 };
 
 VersionBuilder::VersionBuilder(const EnvOptions& env_options,
                                TableCache* table_cache,
-                               VersionStorageInfo* base_vstorage)
-    : rep_(new Rep(env_options, table_cache, base_vstorage)) {}
+                               VersionStorageInfo* base_vstorage,
+                               Logger* info_log)
+    : rep_(new Rep(env_options, info_log, table_cache, base_vstorage)) {}
 VersionBuilder::~VersionBuilder() { delete rep_; }
 void VersionBuilder::CheckConsistency(VersionStorageInfo* vstorage) {
   rep_->CheckConsistency(vstorage);
diff --git a/src/rocksdb/db/version_builder.h b/src/rocksdb/db/version_builder.h
index c7ef279..143da99 100644
--- a/src/rocksdb/db/version_builder.h
+++ b/src/rocksdb/db/version_builder.h
@@ -24,7 +24,7 @@ class InternalStats;
 class VersionBuilder {
  public:
   VersionBuilder(const EnvOptions& env_options, TableCache* table_cache,
-                 VersionStorageInfo* base_vstorage);
+                 VersionStorageInfo* base_vstorage, Logger* info_log = nullptr);
   ~VersionBuilder();
   void CheckConsistency(VersionStorageInfo* vstorage);
   void CheckConsistencyForDeletes(VersionEdit* edit, uint64_t number,
diff --git a/src/rocksdb/db/version_edit.cc b/src/rocksdb/db/version_edit.cc
index 0c9efe4..23df641 100644
--- a/src/rocksdb/db/version_edit.cc
+++ b/src/rocksdb/db/version_edit.cc
@@ -12,6 +12,7 @@
 #include "db/version_set.h"
 #include "util/coding.h"
 #include "util/event_logger.h"
+#include "util/sync_point.h"
 #include "rocksdb/slice.h"
 
 namespace rocksdb {
@@ -32,12 +33,22 @@ enum Tag {
   // these are new formats divergent from open source leveldb
   kNewFile2 = 100,
   kNewFile3 = 102,
+  kNewFile4 = 103,      // 4th (the latest) format version of adding files
   kColumnFamily = 200,  // specify column family for version edit
   kColumnFamilyAdd = 201,
   kColumnFamilyDrop = 202,
   kMaxColumnFamily = 203,
 };
 
+enum CustomTag {
+  kTerminate = 1,  // The end of customized fields
+  kNeedCompaction = 2,
+  kPathId = 65,
+};
+// If this bit for the custom tag is set, opening DB should fail if
+// we don't know this field.
+uint32_t kCustomTagNonSafeIgnoreMask = 1 << 6;
+
 uint64_t PackFileNumberAndPathId(uint64_t number, uint64_t path_id) {
   assert(number <= kFileNumberMask);
   return number | (path_id * (kFileNumberMask + 1));
@@ -102,7 +113,11 @@ bool VersionEdit::EncodeTo(std::string* dst) const {
     if (!f.smallest.Valid() || !f.largest.Valid()) {
       return false;
     }
-    if (f.fd.GetPathId() == 0) {
+    bool has_customized_fields = false;
+    if (f.marked_for_compaction) {
+      PutVarint32(dst, kNewFile4);
+      has_customized_fields = true;
+    } else if (f.fd.GetPathId() == 0) {
       // Use older format to make sure user can roll back the build if they
       // don't config multiple DB paths.
       PutVarint32(dst, kNewFile2);
@@ -111,7 +126,8 @@ bool VersionEdit::EncodeTo(std::string* dst) const {
     }
     PutVarint32(dst, new_files_[i].first);  // level
     PutVarint64(dst, f.fd.GetNumber());
-    if (f.fd.GetPathId() != 0) {
+    if (f.fd.GetPathId() != 0 && !has_customized_fields) {
+      // kNewFile3
       PutVarint32(dst, f.fd.GetPathId());
     }
     PutVarint64(dst, f.fd.GetFileSize());
@@ -119,6 +135,48 @@ bool VersionEdit::EncodeTo(std::string* dst) const {
     PutLengthPrefixedSlice(dst, f.largest.Encode());
     PutVarint64(dst, f.smallest_seqno);
     PutVarint64(dst, f.largest_seqno);
+    if (has_customized_fields) {
+      // Customized fields' format:
+      // +-----------------------------+
+      // | 1st field's tag (varint32)  |
+      // +-----------------------------+
+      // | 1st field's size (varint32) |
+      // +-----------------------------+
+      // |    bytes for 1st field      |
+      // |  (based on size decoded)    |
+      // +-----------------------------+
+      // |                             |
+      // |          ......             |
+      // |                             |
+      // +-----------------------------+
+      // | last field's size (varint32)|
+      // +-----------------------------+
+      // |    bytes for last field     |
+      // |  (based on size decoded)    |
+      // +-----------------------------+
+      // | terminating tag (varint32)  |
+      // +-----------------------------+
+      //
+      // Customized encoding for fields:
+      //   tag kPathId: 1 byte as path_id
+      //   tag kNeedCompaction:
+      //        now only can take one char value 1 indicating need-compaction
+      //
+      if (f.fd.GetPathId() != 0) {
+        PutVarint32(dst, CustomTag::kPathId);
+        char p = static_cast<char>(f.fd.GetPathId());
+        PutLengthPrefixedSlice(dst, Slice(&p, 1));
+      }
+      if (f.marked_for_compaction) {
+        PutVarint32(dst, CustomTag::kNeedCompaction);
+        char p = static_cast<char>(1);
+        PutLengthPrefixedSlice(dst, Slice(&p, 1));
+      }
+      TEST_SYNC_POINT_CALLBACK("VersionEdit::EncodeTo:NewFile4:CustomizeFields",
+                               dst);
+
+      PutVarint32(dst, CustomTag::kTerminate);
+    }
   }
 
   // 0 is default and does not need to be explicitly written
@@ -161,6 +219,63 @@ bool VersionEdit::GetLevel(Slice* input, int* level, const char** msg) {
   }
 }
 
+const char* VersionEdit::DecodeNewFile4From(Slice* input) {
+  const char* msg = nullptr;
+  int level;
+  FileMetaData f;
+  uint64_t number;
+  uint32_t path_id = 0;
+  uint64_t file_size;
+  if (GetLevel(input, &level, &msg) && GetVarint64(input, &number) &&
+      GetVarint64(input, &file_size) && GetInternalKey(input, &f.smallest) &&
+      GetInternalKey(input, &f.largest) &&
+      GetVarint64(input, &f.smallest_seqno) &&
+      GetVarint64(input, &f.largest_seqno)) {
+    // See comments in VersionEdit::EncodeTo() for format of customized fields
+    while (true) {
+      uint32_t custom_tag;
+      Slice field;
+      if (!GetVarint32(input, &custom_tag)) {
+        return "new-file4 custom field";
+      }
+      if (custom_tag == kTerminate) {
+        break;
+      }
+      if (!GetLengthPrefixedSlice(input, &field)) {
+        return "new-file4 custom field lenth prefixed slice error";
+      }
+      switch (custom_tag) {
+        case kPathId:
+          if (field.size() != 1) {
+            return "path_id field wrong size";
+          }
+          path_id = field[0];
+          if (path_id > 3) {
+            return "path_id wrong vaue";
+          }
+          break;
+        case kNeedCompaction:
+          if (field.size() != 1) {
+            return "need_compaction field wrong size";
+          }
+          f.marked_for_compaction = (field[0] == 1);
+          break;
+        default:
+          if ((custom_tag & kCustomTagNonSafeIgnoreMask) != 0) {
+            // Should not proceed if cannot understand it
+            return "new-file4 custom field not supported";
+          }
+          break;
+      }
+    }
+  } else {
+    return "new-file4 entry";
+  }
+  f.fd = FileDescriptor(number, path_id, file_size);
+  new_files_.push_back(std::make_pair(level, f));
+  return nullptr;
+}
+
 Status VersionEdit::DecodeFrom(const Slice& src) {
   Clear();
   Slice input = src;
@@ -304,6 +419,11 @@ Status VersionEdit::DecodeFrom(const Slice& src) {
         break;
       }
 
+      case kNewFile4: {
+        msg = DecodeNewFile4From(&input);
+        break;
+      }
+
       case kColumnFamily:
         if (!GetVarint32(&input, &column_family_)) {
           if (!msg) {
diff --git a/src/rocksdb/db/version_edit.h b/src/rocksdb/db/version_edit.h
index 5c55840..412e725 100644
--- a/src/rocksdb/db/version_edit.h
+++ b/src/rocksdb/db/version_edit.h
@@ -237,6 +237,8 @@ class VersionEdit {
   bool EncodeTo(std::string* dst) const;
   Status DecodeFrom(const Slice& src);
 
+  const char* DecodeNewFile4From(Slice* input);
+
   typedef std::set<std::pair<int, uint64_t>> DeletedFileSet;
 
   const DeletedFileSet& GetDeletedFiles() { return deleted_files_; }
diff --git a/src/rocksdb/db/version_edit_test.cc b/src/rocksdb/db/version_edit_test.cc
index 4186e08..629f904 100644
--- a/src/rocksdb/db/version_edit_test.cc
+++ b/src/rocksdb/db/version_edit_test.cc
@@ -8,6 +8,7 @@
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
 #include "db/version_edit.h"
+#include "util/sync_point.h"
 #include "util/testharness.h"
 
 namespace rocksdb {
@@ -45,6 +46,121 @@ TEST_F(VersionEditTest, EncodeDecode) {
   TestEncodeDecode(edit);
 }
 
+TEST_F(VersionEditTest, EncodeDecodeNewFile4) {
+  static const uint64_t kBig = 1ull << 50;
+
+  VersionEdit edit;
+  edit.AddFile(3, 300, 3, 100, InternalKey("foo", kBig + 500, kTypeValue),
+               InternalKey("zoo", kBig + 600, kTypeDeletion), kBig + 500,
+               kBig + 600, true);
+  edit.AddFile(4, 301, 3, 100, InternalKey("foo", kBig + 501, kTypeValue),
+               InternalKey("zoo", kBig + 601, kTypeDeletion), kBig + 501,
+               kBig + 601, false);
+  edit.AddFile(5, 302, 0, 100, InternalKey("foo", kBig + 502, kTypeValue),
+               InternalKey("zoo", kBig + 602, kTypeDeletion), kBig + 502,
+               kBig + 602, true);
+
+  edit.DeleteFile(4, 700);
+
+  edit.SetComparatorName("foo");
+  edit.SetLogNumber(kBig + 100);
+  edit.SetNextFile(kBig + 200);
+  edit.SetLastSequence(kBig + 1000);
+  TestEncodeDecode(edit);
+
+  std::string encoded, encoded2;
+  edit.EncodeTo(&encoded);
+  VersionEdit parsed;
+  Status s = parsed.DecodeFrom(encoded);
+  ASSERT_TRUE(s.ok()) << s.ToString();
+  auto& new_files = parsed.GetNewFiles();
+  ASSERT_TRUE(new_files[0].second.marked_for_compaction);
+  ASSERT_TRUE(!new_files[1].second.marked_for_compaction);
+  ASSERT_TRUE(new_files[2].second.marked_for_compaction);
+  ASSERT_EQ(3, new_files[0].second.fd.GetPathId());
+  ASSERT_EQ(3, new_files[1].second.fd.GetPathId());
+  ASSERT_EQ(0, new_files[2].second.fd.GetPathId());
+}
+
+TEST_F(VersionEditTest, ForwardCompatibleNewFile4) {
+  static const uint64_t kBig = 1ull << 50;
+  VersionEdit edit;
+  edit.AddFile(3, 300, 3, 100, InternalKey("foo", kBig + 500, kTypeValue),
+               InternalKey("zoo", kBig + 600, kTypeDeletion), kBig + 500,
+               kBig + 600, true);
+  edit.AddFile(4, 301, 3, 100, InternalKey("foo", kBig + 501, kTypeValue),
+               InternalKey("zoo", kBig + 601, kTypeDeletion), kBig + 501,
+               kBig + 601, false);
+  edit.DeleteFile(4, 700);
+
+  edit.SetComparatorName("foo");
+  edit.SetLogNumber(kBig + 100);
+  edit.SetNextFile(kBig + 200);
+  edit.SetLastSequence(kBig + 1000);
+
+  std::string encoded;
+
+  // Call back function to add extra customized builds.
+  bool first = true;
+  rocksdb::SyncPoint::GetInstance()->SetCallBack(
+      "VersionEdit::EncodeTo:NewFile4:CustomizeFields", [&](void* arg) {
+        std::string* str = reinterpret_cast<std::string*>(arg);
+        PutVarint32(str, 33);
+        const std::string str1 = "random_string";
+        PutLengthPrefixedSlice(str, str1);
+        if (first) {
+          first = false;
+          PutVarint32(str, 22);
+          const std::string str2 = "s";
+          PutLengthPrefixedSlice(str, str2);
+        }
+      });
+  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
+  edit.EncodeTo(&encoded);
+  rocksdb::SyncPoint::GetInstance()->DisableProcessing();
+
+  VersionEdit parsed;
+  Status s = parsed.DecodeFrom(encoded);
+  ASSERT_TRUE(s.ok()) << s.ToString();
+  ASSERT_TRUE(!first);
+  auto& new_files = parsed.GetNewFiles();
+  ASSERT_TRUE(new_files[0].second.marked_for_compaction);
+  ASSERT_TRUE(!new_files[1].second.marked_for_compaction);
+  ASSERT_EQ(3, new_files[0].second.fd.GetPathId());
+  ASSERT_EQ(3, new_files[1].second.fd.GetPathId());
+  ASSERT_EQ(1u, parsed.GetDeletedFiles().size());
+}
+
+TEST_F(VersionEditTest, NewFile4NotSupportedField) {
+  static const uint64_t kBig = 1ull << 50;
+  VersionEdit edit;
+  edit.AddFile(3, 300, 3, 100, InternalKey("foo", kBig + 500, kTypeValue),
+               InternalKey("zoo", kBig + 600, kTypeDeletion), kBig + 500,
+               kBig + 600, true);
+
+  edit.SetComparatorName("foo");
+  edit.SetLogNumber(kBig + 100);
+  edit.SetNextFile(kBig + 200);
+  edit.SetLastSequence(kBig + 1000);
+
+  std::string encoded;
+
+  // Call back function to add extra customized builds.
+  rocksdb::SyncPoint::GetInstance()->SetCallBack(
+      "VersionEdit::EncodeTo:NewFile4:CustomizeFields", [&](void* arg) {
+        std::string* str = reinterpret_cast<std::string*>(arg);
+        const std::string str1 = "s";
+        PutLengthPrefixedSlice(str, str1);
+      });
+  rocksdb::SyncPoint::GetInstance()->EnableProcessing();
+  edit.EncodeTo(&encoded);
+  rocksdb::SyncPoint::GetInstance()->DisableProcessing();
+
+  VersionEdit parsed;
+  Status s = parsed.DecodeFrom(encoded);
+  ASSERT_NOK(s);
+}
+
 TEST_F(VersionEditTest, EncodeEmptyFile) {
   VersionEdit edit;
   edit.AddFile(0, 0, 0, 0, InternalKey(), InternalKey(), 0, 0, false);
diff --git a/src/rocksdb/db/version_set.cc b/src/rocksdb/db/version_set.cc
index 91471c4..a9422a8 100644
--- a/src/rocksdb/db/version_set.cc
+++ b/src/rocksdb/db/version_set.cc
@@ -35,6 +35,7 @@
 #include "db/writebuffer.h"
 #include "rocksdb/env.h"
 #include "rocksdb/merge_operator.h"
+#include "table/internal_iterator.h"
 #include "table/table_reader.h"
 #include "table/merger.h"
 #include "table/two_level_iterator.h"
@@ -420,7 +421,7 @@ namespace {
 // is the largest key that occurs in the file, and value() is an
 // 16-byte value containing the file number and file size, both
 // encoded using EncodeFixed64.
-class LevelFileNumIterator : public Iterator {
+class LevelFileNumIterator : public InternalIterator {
  public:
   LevelFileNumIterator(const InternalKeyComparator& icmp,
                        const LevelFilesBrief* flevel)
@@ -488,9 +489,9 @@ class LevelFileIteratorState : public TwoLevelIteratorState {
         file_read_hist_(file_read_hist),
         for_compaction_(for_compaction) {}
 
-  Iterator* NewSecondaryIterator(const Slice& meta_handle) override {
+  InternalIterator* NewSecondaryIterator(const Slice& meta_handle) override {
     if (meta_handle.size() != sizeof(FileDescriptor)) {
-      return NewErrorIterator(
+      return NewErrorInternalIterator(
           Status::Corruption("FileReader invoked with unexpected value"));
     } else {
       const FileDescriptor* fd =
@@ -523,7 +524,7 @@ class BaseReferencedVersionBuilder {
   explicit BaseReferencedVersionBuilder(ColumnFamilyData* cfd)
       : version_builder_(new VersionBuilder(
             cfd->current()->version_set()->env_options(), cfd->table_cache(),
-            cfd->current()->storage_info())),
+            cfd->current()->storage_info(), cfd->ioptions()->info_log)),
         version_(cfd->current()) {
     version_->Ref();
   }
@@ -541,7 +542,7 @@ class BaseReferencedVersionBuilder {
 
 Status Version::GetTableProperties(std::shared_ptr<const TableProperties>* tp,
                                    const FileMetaData* file_meta,
-                                   const std::string* fname) {
+                                   const std::string* fname) const {
   auto table_cache = cfd_->table_cache();
   auto ioptions = cfd_->ioptions();
   Status s = table_cache->GetTableProperties(
@@ -623,6 +624,38 @@ Status Version::GetPropertiesOfAllTables(TablePropertiesCollection* props,
   return Status::OK();
 }
 
+Status Version::GetPropertiesOfTablesInRange(
+    const Range* range, std::size_t n, TablePropertiesCollection* props) const {
+  for (int level = 0; level < storage_info_.num_non_empty_levels(); level++) {
+    for (decltype(n) i = 0; i < n; i++) {
+      // Convert user_key into a corresponding internal key.
+      InternalKey k1(range[i].start, kMaxSequenceNumber, kValueTypeForSeek);
+      InternalKey k2(range[i].limit, kMaxSequenceNumber, kValueTypeForSeek);
+      std::vector<FileMetaData*> files;
+      storage_info_.GetOverlappingInputs(level, &k1, &k2, &files, -1, nullptr,
+                                         false);
+      for (const auto& file_meta : files) {
+        auto fname =
+            TableFileName(vset_->db_options_->db_paths,
+                          file_meta->fd.GetNumber(), file_meta->fd.GetPathId());
+        if (props->count(fname) == 0) {
+          // 1. If the table is already present in table cache, load table
+          // properties from there.
+          std::shared_ptr<const TableProperties> table_properties;
+          Status s = GetTableProperties(&table_properties, file_meta, &fname);
+          if (s.ok()) {
+            props->insert({fname, table_properties});
+          } else {
+            return s;
+          }
+        }
+      }
+    }
+  }
+
+  return Status::OK();
+}
+
 Status Version::GetAggregatedTableProperties(
     std::shared_ptr<const TableProperties>* tp, int level) {
   TablePropertiesCollection props;
@@ -705,24 +738,24 @@ uint64_t VersionStorageInfo::GetEstimatedActiveKeys() const {
   // (2) keys are directly overwritten
   // (3) deletion on non-existing keys
   // (4) low number of samples
-  if (num_samples_ == 0) {
+  if (current_num_samples_ == 0) {
     return 0;
   }
 
-  if (accumulated_num_non_deletions_ <= accumulated_num_deletions_) {
+  if (current_num_non_deletions_ <= current_num_deletions_) {
     return 0;
   }
 
-  uint64_t est = accumulated_num_non_deletions_ - accumulated_num_deletions_;
+  uint64_t est = current_num_non_deletions_ - current_num_deletions_;
 
   uint64_t file_count = 0;
   for (int level = 0; level < num_levels_; ++level) {
     file_count += files_[level].size();
   }
 
-  if (num_samples_ < file_count) {
+  if (current_num_samples_ < file_count) {
     // casting to avoid overflowing
-    return (est * static_cast<double>(file_count) / num_samples_);
+    return (est * static_cast<double>(file_count) / current_num_samples_);
   } else {
     return est;
   }
@@ -793,7 +826,9 @@ VersionStorageInfo::VersionStorageInfo(
       accumulated_raw_value_size_(0),
       accumulated_num_non_deletions_(0),
       accumulated_num_deletions_(0),
-      num_samples_(0),
+      current_num_non_deletions_(0),
+      current_num_deletions_(0),
+      current_num_samples_(0),
       estimated_compaction_needed_bytes_(0),
       finalized_(false) {
   if (ref_vstorage != nullptr) {
@@ -803,7 +838,9 @@ VersionStorageInfo::VersionStorageInfo(
     accumulated_num_non_deletions_ =
         ref_vstorage->accumulated_num_non_deletions_;
     accumulated_num_deletions_ = ref_vstorage->accumulated_num_deletions_;
-    num_samples_ = ref_vstorage->num_samples_;
+    current_num_non_deletions_ = ref_vstorage->current_num_non_deletions_;
+    current_num_deletions_ = ref_vstorage->current_num_deletions_;
+    current_num_samples_ = ref_vstorage->current_num_samples_;
   }
 }
 
@@ -960,7 +997,20 @@ void VersionStorageInfo::UpdateAccumulatedStats(FileMetaData* file_meta) {
   accumulated_num_non_deletions_ +=
       file_meta->num_entries - file_meta->num_deletions;
   accumulated_num_deletions_ += file_meta->num_deletions;
-  num_samples_++;
+
+  current_num_non_deletions_ +=
+      file_meta->num_entries - file_meta->num_deletions;
+  current_num_deletions_ += file_meta->num_deletions;
+  current_num_samples_++;
+}
+
+void VersionStorageInfo::RemoveCurrentStats(FileMetaData* file_meta) {
+  if (file_meta->init_stats_from_file) {
+    current_num_non_deletions_ -=
+        file_meta->num_entries - file_meta->num_deletions;
+    current_num_deletions_ -= file_meta->num_deletions;
+    current_num_samples_--;
+  }
 }
 
 void Version::UpdateAccumulatedStats(bool update_stats) {
@@ -1064,7 +1114,7 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
   // We keep doing it to Level 2, 3, etc, until the last level and return the
   // accumulated bytes.
 
-  size_t bytes_compact_to_next_level = 0;
+  uint64_t bytes_compact_to_next_level = 0;
   // Level 0
   bool level0_compact_triggered = false;
   if (static_cast<int>(files_[0].size()) >
@@ -1080,7 +1130,7 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
 
   // Level 1 and up.
   for (int level = base_level(); level <= MaxInputLevel(); level++) {
-    size_t level_size = 0;
+    uint64_t level_size = 0;
     for (auto* f : files_[level]) {
       level_size += f->fd.GetFileSize();
     }
@@ -1091,7 +1141,7 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
     // Add size added by previous compaction
     level_size += bytes_compact_to_next_level;
     bytes_compact_to_next_level = 0;
-    size_t level_target = MaxBytesForLevel(level);
+    uint64_t level_target = MaxBytesForLevel(level);
     if (level_size > level_target) {
       bytes_compact_to_next_level = level_size - level_target;
       // Simplify to assume the actual compaction fan-out ratio is always
@@ -1106,9 +1156,6 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
 void VersionStorageInfo::ComputeCompactionScore(
     const MutableCFOptions& mutable_cf_options,
     const CompactionOptionsFIFO& compaction_options_fifo) {
-  double max_score = 0;
-  int max_score_level = 0;
-
   for (int level = 0; level <= MaxInputLevel(); level++) {
     double score;
     if (level == 0) {
@@ -1159,19 +1206,11 @@ void VersionStorageInfo::ComputeCompactionScore(
       }
       score = static_cast<double>(level_bytes_no_compacting) /
               MaxBytesForLevel(level);
-      if (max_score < score) {
-        max_score = score;
-        max_score_level = level;
-      }
     }
     compaction_level_[level] = level;
     compaction_score_[level] = score;
   }
 
-  // update the max compaction score in levels 1 to n-1
-  max_compaction_score_ = max_score;
-  max_compaction_score_level_ = max_score_level;
-
   // sort all the levels based on their score. Higher scores get listed
   // first. Use bubble sort because the number of entries are small.
   for (int i = 0; i < num_levels() - 2; i++) {
@@ -1229,13 +1268,27 @@ bool CompareCompensatedSizeDescending(const Fsize& first, const Fsize& second) {
 }
 } // anonymous namespace
 
-void VersionStorageInfo::AddFile(int level, FileMetaData* f) {
+void VersionStorageInfo::AddFile(int level, FileMetaData* f, Logger* info_log) {
   auto* level_files = &files_[level];
   // Must not overlap
-  assert(level <= 0 || level_files->empty() ||
-         internal_comparator_->Compare(
-             (*level_files)[level_files->size() - 1]->largest, f->smallest) <
-             0);
+#ifndef NDEBUG
+  if (level > 0 && !level_files->empty() &&
+      internal_comparator_->Compare(
+          (*level_files)[level_files->size() - 1]->largest, f->smallest) >= 0) {
+    auto* f2 = (*level_files)[level_files->size() - 1];
+    if (info_log != nullptr) {
+      Error(info_log, "Adding new file %" PRIu64
+                      " range (%s, %s) to level %d but overlapping "
+                      "with existing file %" PRIu64 " %s %s",
+            f->fd.GetNumber(), f->smallest.DebugString(true).c_str(),
+            f->largest.DebugString(true).c_str(), level, f2->fd.GetNumber(),
+            f2->smallest.DebugString(true).c_str(),
+            f2->largest.DebugString(true).c_str());
+      LogFlush(info_log);
+    }
+    assert(false);
+  }
+#endif
   f->refs++;
   level_files->push_back(f);
 }
@@ -1322,16 +1375,22 @@ void VersionStorageInfo::UpdateFilesByCompactionPri(
       num = temp.size();
     }
     switch (mutable_cf_options.compaction_pri) {
-      case kCompactionPriByCompensatedSize:
+      case kByCompensatedSize:
         std::partial_sort(temp.begin(), temp.begin() + num, temp.end(),
                           CompareCompensatedSizeDescending);
         break;
-      case kCompactionPriByLargestSeq:
+      case kOldestLargestSeqFirst:
         std::sort(temp.begin(), temp.end(),
                   [this](const Fsize& f1, const Fsize& f2) -> bool {
                     return f1.file->largest_seqno < f2.file->largest_seqno;
                   });
         break;
+      case kOldestSmallestSeqFirst:
+        std::sort(temp.begin(), temp.end(),
+                  [this](const Fsize& f1, const Fsize& f2) -> bool {
+                    return f1.file->smallest_seqno < f2.file->smallest_seqno;
+                  });
+        break;
       default:
         assert(false);
     }
@@ -1405,7 +1464,8 @@ bool VersionStorageInfo::OverlapInLevel(int level,
 // The file_index returns a pointer to any file in an overlapping range.
 void VersionStorageInfo::GetOverlappingInputs(
     int level, const InternalKey* begin, const InternalKey* end,
-    std::vector<FileMetaData*>* inputs, int hint_index, int* file_index) {
+    std::vector<FileMetaData*>* inputs, int hint_index, int* file_index,
+    bool expand_range) const {
   if (level >= num_non_empty_levels_) {
     // this level is empty, no overlapping inputs
     return;
@@ -1438,7 +1498,7 @@ void VersionStorageInfo::GetOverlappingInputs(
       // "f" is completely after specified range; skip it
     } else {
       inputs->push_back(files_[level][i-1]);
-      if (level == 0) {
+      if (level == 0 && expand_range) {
         // Level-0 files may overlap each other.  So check if the newly
         // added file has expanded the range.  If so, restart search.
         if (begin != nullptr && user_cmp->Compare(file_start, user_begin) < 0) {
@@ -1464,7 +1524,7 @@ void VersionStorageInfo::GetOverlappingInputs(
 // forwards to find all overlapping files.
 void VersionStorageInfo::GetOverlappingInputsBinarySearch(
     int level, const Slice& user_begin, const Slice& user_end,
-    std::vector<FileMetaData*>* inputs, int hint_index, int* file_index) {
+    std::vector<FileMetaData*>* inputs, int hint_index, int* file_index) const {
   assert(level > 0);
   int min = 0;
   int mid = 0;
@@ -1512,8 +1572,7 @@ void VersionStorageInfo::GetOverlappingInputsBinarySearch(
 // Use FileLevel in searching, make it faster
 void VersionStorageInfo::ExtendOverlappingInputs(
     int level, const Slice& user_begin, const Slice& user_end,
-    std::vector<FileMetaData*>* inputs, unsigned int midIndex) {
-
+    std::vector<FileMetaData*>* inputs, unsigned int midIndex) const {
   const Comparator* user_cmp = user_comparator_;
   const FdWithKeyRange* files = level_files_brief_[level].files;
 #ifndef NDEBUG
@@ -2070,8 +2129,8 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
           "Creating manifest %" PRIu64 "\n", pending_manifest_file_number_);
       unique_ptr<WritableFile> descriptor_file;
       EnvOptions opt_env_opts = env_->OptimizeForManifestWrite(env_options_);
-      s = env_->NewWritableFile(
-          DescriptorFileName(dbname_, pending_manifest_file_number_),
+      s = NewWritableFile(
+          env_, DescriptorFileName(dbname_, pending_manifest_file_number_),
           &descriptor_file, opt_env_opts);
       if (s.ok()) {
         descriptor_file->SetPreallocationBlockSize(
@@ -2079,7 +2138,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
 
         unique_ptr<WritableFileWriter> file_writer(
             new WritableFileWriter(std::move(descriptor_file), opt_env_opts));
-        descriptor_log_.reset(new log::Writer(std::move(file_writer)));
+        descriptor_log_.reset(new log::Writer(std::move(file_writer), 0, false));
         s = WriteSnapshot(descriptor_log_.get());
       }
     }
@@ -2098,6 +2157,8 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
               "Unable to Encode VersionEdit:" + e->DebugString(true));
           break;
         }
+        TEST_KILL_RANDOM("VersionSet::LogAndApply:BeforeAddRecord",
+                         rocksdb_kill_odds * REDUCE_ODDS2);
         s = descriptor_log_->AddRecord(record);
         if (!s.ok()) {
           break;
@@ -2341,8 +2402,8 @@ Status VersionSet::Recover(
   {
     VersionSet::LogReporter reporter;
     reporter.status = &s;
-    log::Reader reader(std::move(manifest_file_reader), &reporter,
-                       true /*checksum*/, 0 /*initial_offset*/);
+    log::Reader reader(NULL, std::move(manifest_file_reader), &reporter,
+                       true /*checksum*/, 0 /*initial_offset*/, 0);
     Slice record;
     std::string scratch;
     while (reader.ReadRecord(&record, &scratch) && s.ok()) {
@@ -2594,8 +2655,8 @@ Status VersionSet::ListColumnFamilies(std::vector<std::string>* column_families,
   column_family_names.insert({0, kDefaultColumnFamilyName});
   VersionSet::LogReporter reporter;
   reporter.status = &s;
-  log::Reader reader(std::move(file_reader), &reporter, true /*checksum*/,
-                     0 /*initial_offset*/);
+  log::Reader reader(NULL, std::move(file_reader), &reporter, true /*checksum*/,
+                     0 /*initial_offset*/, 0);
   Slice record;
   std::string scratch;
   while (reader.ReadRecord(&record, &scratch) && s.ok()) {
@@ -2752,8 +2813,8 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname,
   {
     VersionSet::LogReporter reporter;
     reporter.status = &s;
-    log::Reader reader(std::move(file_reader), &reporter, true /*checksum*/,
-                       0 /*initial_offset*/);
+    log::Reader reader(NULL, std::move(file_reader), &reporter,
+                       true /*checksum*/, 0 /*initial_offset*/, 0);
     Slice record;
     std::string scratch;
     while (reader.ReadRecord(&record, &scratch) && s.ok()) {
@@ -3005,7 +3066,8 @@ bool VersionSet::ManifestContains(uint64_t manifest_file_num,
     }
     file_reader.reset(new SequentialFileReader(std::move(file)));
   }
-  log::Reader reader(std::move(file_reader), nullptr, true /*checksum*/, 0);
+  log::Reader reader(NULL, std::move(file_reader), nullptr,
+                     true /*checksum*/, 0, 0);
   Slice r;
   std::string scratch;
   bool result = false;
@@ -3119,7 +3181,7 @@ uint64_t VersionSet::ApproximateSize(Version* v, const FdWithKeyRange& f,
     // "key" falls in the range for this table.  Add the
     // approximate offset of "key" within the table.
     TableReader* table_reader_ptr;
-    Iterator* iter = v->cfd_->table_cache()->NewIterator(
+    InternalIterator* iter = v->cfd_->table_cache()->NewIterator(
         ReadOptions(), env_options_, v->cfd_->internal_comparator(), f.fd,
         &table_reader_ptr);
     if (table_reader_ptr != nullptr) {
@@ -3166,7 +3228,7 @@ void VersionSet::AddLiveFiles(std::vector<FileDescriptor>* live_list) {
   }
 }
 
-Iterator* VersionSet::MakeInputIterator(Compaction* c) {
+InternalIterator* VersionSet::MakeInputIterator(Compaction* c) {
   auto cfd = c->column_family_data();
   ReadOptions read_options;
   read_options.verify_checksums =
@@ -3182,7 +3244,7 @@ Iterator* VersionSet::MakeInputIterator(Compaction* c) {
   const size_t space = (c->level() == 0 ? c->input_levels(0)->num_files +
                                               c->num_input_levels() - 1
                                         : c->num_input_levels());
-  Iterator** list = new Iterator* [space];
+  InternalIterator** list = new InternalIterator* [space];
   size_t num = 0;
   for (size_t which = 0; which < c->num_input_levels(); which++) {
     if (c->input_levels(which)->num_files != 0) {
@@ -3209,7 +3271,7 @@ Iterator* VersionSet::MakeInputIterator(Compaction* c) {
     }
   }
   assert(num <= space);
-  Iterator* result =
+  InternalIterator* result =
       NewMergingIterator(&c->column_family_data()->internal_comparator(), list,
                          static_cast<int>(num));
   delete[] list;
diff --git a/src/rocksdb/db/version_set.h b/src/rocksdb/db/version_set.h
index 3964600..b748249 100644
--- a/src/rocksdb/db/version_set.h
+++ b/src/rocksdb/db/version_set.h
@@ -48,7 +48,7 @@ class Writer;
 }
 
 class Compaction;
-class Iterator;
+class InternalIterator;
 class LogBuffer;
 class LookupKey;
 class MemTable;
@@ -97,7 +97,7 @@ class VersionStorageInfo {
 
   void Reserve(int level, size_t size) { files_[level].reserve(size); }
 
-  void AddFile(int level, FileMetaData* f);
+  void AddFile(int level, FileMetaData* f, Logger* info_log = nullptr);
 
   void SetFinalized();
 
@@ -111,6 +111,9 @@ class VersionStorageInfo {
   // Update the accumulated stats from a file-meta.
   void UpdateAccumulatedStats(FileMetaData* file_meta);
 
+  // Decrease the current stat form a to-be-delected file-meta
+  void RemoveCurrentStats(FileMetaData* file_meta);
+
   void ComputeCompensatedSizes();
 
   // Updates internal structures that keep track of compaction scores
@@ -143,12 +146,6 @@ class VersionStorageInfo {
 
   int MaxInputLevel() const;
 
-  // Returns the maxmimum compaction score for levels 1 to max
-  double max_compaction_score() const { return max_compaction_score_; }
-
-  // See field declaration
-  int max_compaction_score_level() const { return max_compaction_score_level_; }
-
   // Return level number that has idx'th highest score
   int CompactionScoreLevel(int idx) const { return compaction_level_[idx]; }
 
@@ -159,23 +156,26 @@ class VersionStorageInfo {
       int level, const InternalKey* begin,  // nullptr means before all keys
       const InternalKey* end,               // nullptr means after all keys
       std::vector<FileMetaData*>* inputs,
-      int hint_index = -1,         // index of overlap file
-      int* file_index = nullptr);  // return index of overlap file
+      int hint_index = -1,        // index of overlap file
+      int* file_index = nullptr,  // return index of overlap file
+      bool expand_range = true)   // if set, returns files which overlap the
+      const;                      // range and overlap each other. If false,
+                                  // then just files intersecting the range
 
   void GetOverlappingInputsBinarySearch(
       int level,
       const Slice& begin,  // nullptr means before all keys
       const Slice& end,    // nullptr means after all keys
       std::vector<FileMetaData*>* inputs,
-      int hint_index,    // index of overlap file
-      int* file_index);  // return index of overlap file
+      int hint_index,          // index of overlap file
+      int* file_index) const;  // return index of overlap file
 
   void ExtendOverlappingInputs(
       int level,
       const Slice& begin,  // nullptr means before all keys
       const Slice& end,    // nullptr means after all keys
       std::vector<FileMetaData*>* inputs,
-      unsigned int index);  // start extending from this index
+      unsigned int index) const;  // start extending from this index
 
   // Returns true iff some file in the specified level overlaps
   // some part of [*smallest_user_key,*largest_user_key].
@@ -381,8 +381,6 @@ class VersionStorageInfo {
   // These are used to pick the best compaction level
   std::vector<double> compaction_score_;
   std::vector<int> compaction_level_;
-  double max_compaction_score_ = 0.0;   // max score in l1 to ln-1
-  int max_compaction_score_level_ = 0;  // level on which max score occurs
   int l0_delay_trigger_count_ = 0;  // Count used to trigger slow down and stop
                                     // for number of L0 files.
 
@@ -397,8 +395,12 @@ class VersionStorageInfo {
   uint64_t accumulated_num_non_deletions_;
   // total number of deletion entries
   uint64_t accumulated_num_deletions_;
-  // the number of samples
-  uint64_t num_samples_;
+  // current number of non_deletion entries
+  uint64_t current_num_non_deletions_;
+  // current number of delection entries
+  uint64_t current_num_deletions_;
+  // current number of file samples
+  uint64_t current_num_samples_;
   // Estimated bytes needed to be compacted until all levels' size is down to
   // target sizes.
   uint64_t estimated_compaction_needed_bytes_;
@@ -456,15 +458,16 @@ class Version {
   // file-name conversion.
   Status GetTableProperties(std::shared_ptr<const TableProperties>* tp,
                             const FileMetaData* file_meta,
-                            const std::string* fname = nullptr);
+                            const std::string* fname = nullptr) const;
 
   // REQUIRES: lock is held
   // On success, *props will be populated with all SSTables' table properties.
   // The keys of `props` are the sst file name, the values of `props` are the
   // tables' propertis, represented as shared_ptr.
   Status GetPropertiesOfAllTables(TablePropertiesCollection* props);
-
   Status GetPropertiesOfAllTables(TablePropertiesCollection* props, int level);
+  Status GetPropertiesOfTablesInRange(const Range* range, std::size_t n,
+                                      TablePropertiesCollection* props) const;
 
   // REQUIRES: lock is held
   // On success, "tp" will contains the aggregated table property amoug
@@ -502,7 +505,8 @@ class Version {
     return storage_info_.user_comparator_;
   }
 
-  bool PrefixMayMatch(const ReadOptions& read_options, Iterator* level_iter,
+  bool PrefixMayMatch(const ReadOptions& read_options,
+                      InternalIterator* level_iter,
                       const Slice& internal_prefix) const;
 
   // The helper function of UpdateAccumulatedStats, which may fill the missing
@@ -643,7 +647,7 @@ class VersionSet {
 
   // Create an iterator that reads over the compaction inputs for "*c".
   // The caller should delete the iterator when no longer needed.
-  Iterator* MakeInputIterator(Compaction* c);
+  InternalIterator* MakeInputIterator(Compaction* c);
 
   // Add all files listed in any live version to *live.
   void AddLiveFiles(std::vector<FileDescriptor>* live_list);
diff --git a/src/rocksdb/db/wal_manager.cc b/src/rocksdb/db/wal_manager.cc
index 37861ab..58b0b16 100644
--- a/src/rocksdb/db/wal_manager.cc
+++ b/src/rocksdb/db/wal_manager.cc
@@ -448,8 +448,8 @@ Status WalManager::ReadFirstLine(const std::string& fname,
   reporter.fname = fname.c_str();
   reporter.status = &status;
   reporter.ignore_error = !db_options_.paranoid_checks;
-  log::Reader reader(std::move(file_reader), &reporter, true /*checksum*/,
-                     0 /*initial_offset*/);
+  log::Reader reader(db_options_.info_log, std::move(file_reader), &reporter,
+                     true /*checksum*/, 0 /*initial_offset*/, *sequence);
   std::string scratch;
   Slice record;
 
diff --git a/src/rocksdb/db/wal_manager_test.cc b/src/rocksdb/db/wal_manager_test.cc
index ec56c96..428f4c9 100644
--- a/src/rocksdb/db/wal_manager_test.cc
+++ b/src/rocksdb/db/wal_manager_test.cc
@@ -77,7 +77,7 @@ class WalManagerTest : public testing::Test {
     ASSERT_OK(env_->NewWritableFile(fname, &file, env_options_));
     unique_ptr<WritableFileWriter> file_writer(
         new WritableFileWriter(std::move(file), env_options_));
-    current_log_writer_.reset(new log::Writer(std::move(file_writer)));
+    current_log_writer_.reset(new log::Writer(std::move(file_writer), 0, false));
   }
 
   void CreateArchiveLogs(int num_logs, int entries_per_log) {
@@ -127,7 +127,8 @@ TEST_F(WalManagerTest, ReadFirstRecordCache) {
 
   unique_ptr<WritableFileWriter> file_writer(
       new WritableFileWriter(std::move(file), EnvOptions()));
-  log::Writer writer(std::move(file_writer));
+  log::Writer writer(std::move(file_writer), 1,
+		     db_options_.recycle_log_file_num > 0);
   WriteBatch batch;
   batch.Put("foo", "bar");
   WriteBatchInternal::SetSequence(&batch, 10);
diff --git a/src/rocksdb/db/write_batch.cc b/src/rocksdb/db/write_batch.cc
index 53431b9..e6e1aca 100644
--- a/src/rocksdb/db/write_batch.cc
+++ b/src/rocksdb/db/write_batch.cc
@@ -42,22 +42,91 @@
 
 namespace rocksdb {
 
+// anon namespace for file-local types
+namespace {
+
+enum ContentFlags : uint32_t {
+  DEFERRED = 1,
+  HAS_PUT = 2,
+  HAS_DELETE = 4,
+  HAS_SINGLE_DELETE = 8,
+  HAS_MERGE = 16,
+};
+
+struct BatchContentClassifier : public WriteBatch::Handler {
+  uint32_t content_flags = 0;
+
+  Status PutCF(uint32_t, const Slice&, const Slice&) override {
+    content_flags |= ContentFlags::HAS_PUT;
+    return Status::OK();
+  }
+
+  Status DeleteCF(uint32_t, const Slice&) override {
+    content_flags |= ContentFlags::HAS_DELETE;
+    return Status::OK();
+  }
+
+  Status SingleDeleteCF(uint32_t, const Slice&) override {
+    content_flags |= ContentFlags::HAS_SINGLE_DELETE;
+    return Status::OK();
+  }
+
+  Status MergeCF(uint32_t, const Slice&, const Slice&) override {
+    content_flags |= ContentFlags::HAS_MERGE;
+    return Status::OK();
+  }
+};
+
+}  // anon namespace
+
 // WriteBatch header has an 8-byte sequence number followed by a 4-byte count.
 static const size_t kHeader = 12;
 
 struct SavePoint {
   size_t size;  // size of rep_
   int count;    // count of elements in rep_
-  SavePoint(size_t s, int c) : size(s), count(c) {}
+  uint32_t content_flags;
 };
 
 struct SavePoints {
   std::stack<SavePoint> stack;
 };
 
-WriteBatch::WriteBatch(size_t reserved_bytes) : save_points_(nullptr) {
+WriteBatch::WriteBatch(size_t reserved_bytes)
+    : save_points_(nullptr), content_flags_(0), rep_() {
   rep_.reserve((reserved_bytes > kHeader) ? reserved_bytes : kHeader);
-  Clear();
+  rep_.resize(kHeader);
+}
+
+WriteBatch::WriteBatch(const std::string& rep)
+    : save_points_(nullptr),
+      content_flags_(ContentFlags::DEFERRED),
+      rep_(rep) {}
+
+WriteBatch::WriteBatch(const WriteBatch& src)
+    : save_points_(src.save_points_),
+      content_flags_(src.content_flags_.load(std::memory_order_relaxed)),
+      rep_(src.rep_) {}
+
+WriteBatch::WriteBatch(WriteBatch&& src)
+    : save_points_(std::move(src.save_points_)),
+      content_flags_(src.content_flags_.load(std::memory_order_relaxed)),
+      rep_(std::move(src.rep_)) {}
+
+WriteBatch& WriteBatch::operator=(const WriteBatch& src) {
+  if (&src != this) {
+    this->~WriteBatch();
+    new (this) WriteBatch(src);
+  }
+  return *this;
+}
+
+WriteBatch& WriteBatch::operator=(WriteBatch&& src) {
+  if (&src != this) {
+    this->~WriteBatch();
+    new (this) WriteBatch(std::move(src));
+  }
+  return *this;
 }
 
 WriteBatch::~WriteBatch() {
@@ -81,6 +150,8 @@ void WriteBatch::Clear() {
   rep_.clear();
   rep_.resize(kHeader);
 
+  content_flags_.store(0, std::memory_order_relaxed);
+
   if (save_points_ != nullptr) {
     while (!save_points_->stack.empty()) {
       save_points_->stack.pop();
@@ -92,6 +163,38 @@ int WriteBatch::Count() const {
   return WriteBatchInternal::Count(this);
 }
 
+uint32_t WriteBatch::ComputeContentFlags() const {
+  auto rv = content_flags_.load(std::memory_order_relaxed);
+  if ((rv & ContentFlags::DEFERRED) != 0) {
+    BatchContentClassifier classifier;
+    Iterate(&classifier);
+    rv = classifier.content_flags;
+
+    // this method is conceptually const, because it is performing a lazy
+    // computation that doesn't affect the abstract state of the batch.
+    // content_flags_ is marked mutable so that we can perform the
+    // following assignment
+    content_flags_.store(rv, std::memory_order_relaxed);
+  }
+  return rv;
+}
+
+bool WriteBatch::HasPut() const {
+  return (ComputeContentFlags() & ContentFlags::HAS_PUT) != 0;
+}
+
+bool WriteBatch::HasDelete() const {
+  return (ComputeContentFlags() & ContentFlags::HAS_DELETE) != 0;
+}
+
+bool WriteBatch::HasSingleDelete() const {
+  return (ComputeContentFlags() & ContentFlags::HAS_SINGLE_DELETE) != 0;
+}
+
+bool WriteBatch::HasMerge() const {
+  return (ComputeContentFlags() & ContentFlags::HAS_MERGE) != 0;
+}
+
 Status ReadRecordFromWriteBatch(Slice* input, char* tag,
                                 uint32_t* column_family, Slice* key,
                                 Slice* value, Slice* blob) {
@@ -169,21 +272,29 @@ Status WriteBatch::Iterate(Handler* handler) const {
     switch (tag) {
       case kTypeColumnFamilyValue:
       case kTypeValue:
+        assert(content_flags_.load(std::memory_order_relaxed) &
+               (ContentFlags::DEFERRED | ContentFlags::HAS_PUT));
         s = handler->PutCF(column_family, key, value);
         found++;
         break;
       case kTypeColumnFamilyDeletion:
       case kTypeDeletion:
+        assert(content_flags_.load(std::memory_order_relaxed) &
+               (ContentFlags::DEFERRED | ContentFlags::HAS_DELETE));
         s = handler->DeleteCF(column_family, key);
         found++;
         break;
       case kTypeColumnFamilySingleDeletion:
       case kTypeSingleDeletion:
+        assert(content_flags_.load(std::memory_order_relaxed) &
+               (ContentFlags::DEFERRED | ContentFlags::HAS_SINGLE_DELETE));
         s = handler->SingleDeleteCF(column_family, key);
         found++;
         break;
       case kTypeColumnFamilyMerge:
       case kTypeMerge:
+        assert(content_flags_.load(std::memory_order_relaxed) &
+               (ContentFlags::DEFERRED | ContentFlags::HAS_MERGE));
         s = handler->MergeCF(column_family, key, value);
         found++;
         break;
@@ -233,6 +344,9 @@ void WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
   }
   PutLengthPrefixedSlice(&b->rep_, key);
   PutLengthPrefixedSlice(&b->rep_, value);
+  b->content_flags_.store(
+      b->content_flags_.load(std::memory_order_relaxed) | ContentFlags::HAS_PUT,
+      std::memory_order_relaxed);
 }
 
 void WriteBatch::Put(ColumnFamilyHandle* column_family, const Slice& key,
@@ -251,6 +365,9 @@ void WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
   }
   PutLengthPrefixedSliceParts(&b->rep_, key);
   PutLengthPrefixedSliceParts(&b->rep_, value);
+  b->content_flags_.store(
+      b->content_flags_.load(std::memory_order_relaxed) | ContentFlags::HAS_PUT,
+      std::memory_order_relaxed);
 }
 
 void WriteBatch::Put(ColumnFamilyHandle* column_family, const SliceParts& key,
@@ -268,6 +385,9 @@ void WriteBatchInternal::Delete(WriteBatch* b, uint32_t column_family_id,
     PutVarint32(&b->rep_, column_family_id);
   }
   PutLengthPrefixedSlice(&b->rep_, key);
+  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
+                              ContentFlags::HAS_DELETE,
+                          std::memory_order_relaxed);
 }
 
 void WriteBatch::Delete(ColumnFamilyHandle* column_family, const Slice& key) {
@@ -284,6 +404,9 @@ void WriteBatchInternal::Delete(WriteBatch* b, uint32_t column_family_id,
     PutVarint32(&b->rep_, column_family_id);
   }
   PutLengthPrefixedSliceParts(&b->rep_, key);
+  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
+                              ContentFlags::HAS_DELETE,
+                          std::memory_order_relaxed);
 }
 
 void WriteBatch::Delete(ColumnFamilyHandle* column_family,
@@ -301,6 +424,9 @@ void WriteBatchInternal::SingleDelete(WriteBatch* b, uint32_t column_family_id,
     PutVarint32(&b->rep_, column_family_id);
   }
   PutLengthPrefixedSlice(&b->rep_, key);
+  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
+                              ContentFlags::HAS_SINGLE_DELETE,
+                          std::memory_order_relaxed);
 }
 
 void WriteBatch::SingleDelete(ColumnFamilyHandle* column_family,
@@ -318,6 +444,9 @@ void WriteBatchInternal::SingleDelete(WriteBatch* b, uint32_t column_family_id,
     PutVarint32(&b->rep_, column_family_id);
   }
   PutLengthPrefixedSliceParts(&b->rep_, key);
+  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
+                              ContentFlags::HAS_SINGLE_DELETE,
+                          std::memory_order_relaxed);
 }
 
 void WriteBatch::SingleDelete(ColumnFamilyHandle* column_family,
@@ -336,6 +465,9 @@ void WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
   }
   PutLengthPrefixedSlice(&b->rep_, key);
   PutLengthPrefixedSlice(&b->rep_, value);
+  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
+                              ContentFlags::HAS_MERGE,
+                          std::memory_order_relaxed);
 }
 
 void WriteBatch::Merge(ColumnFamilyHandle* column_family, const Slice& key,
@@ -355,6 +487,9 @@ void WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
   }
   PutLengthPrefixedSliceParts(&b->rep_, key);
   PutLengthPrefixedSliceParts(&b->rep_, value);
+  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
+                              ContentFlags::HAS_MERGE,
+                          std::memory_order_relaxed);
 }
 
 void WriteBatch::Merge(ColumnFamilyHandle* column_family,
@@ -374,7 +509,8 @@ void WriteBatch::SetSavePoint() {
     save_points_ = new SavePoints();
   }
   // Record length and count of current batch of writes.
-  save_points_->stack.push(SavePoint(GetDataSize(), Count()));
+  save_points_->stack.push(SavePoint{
+      GetDataSize(), Count(), content_flags_.load(std::memory_order_relaxed)});
 }
 
 Status WriteBatch::RollbackToSavePoint() {
@@ -387,6 +523,7 @@ Status WriteBatch::RollbackToSavePoint() {
   save_points_->stack.pop();
 
   assert(savepoint.size <= rep_.size());
+  assert(savepoint.count <= Count());
 
   if (savepoint.size == rep_.size()) {
     // No changes to rollback
@@ -396,6 +533,7 @@ Status WriteBatch::RollbackToSavePoint() {
   } else {
     rep_.resize(savepoint.size);
     WriteBatchInternal::SetCount(this, savepoint.count);
+    content_flags_.store(savepoint.content_flags, std::memory_order_relaxed);
   }
 
   return Status::OK();
@@ -453,6 +591,7 @@ class MemTableInserter : public WriteBatch::Handler {
     }
     return true;
   }
+
   virtual Status PutCF(uint32_t column_family_id, const Slice& key,
                        const Slice& value) override {
     Status seek_status;
@@ -509,8 +648,8 @@ class MemTableInserter : public WriteBatch::Handler {
     return Status::OK();
   }
 
-  virtual Status DeleteCF(uint32_t column_family_id,
-                          const Slice& key) override {
+  Status DeleteImpl(uint32_t column_family_id, const Slice& key,
+                    ValueType delete_type) {
     Status seek_status;
     if (!SeekToColumnFamily(column_family_id, &seek_status)) {
       ++sequence_;
@@ -533,40 +672,20 @@ class MemTableInserter : public WriteBatch::Handler {
         return Status::OK();
       }
     }
-    mem->Add(sequence_, kTypeDeletion, key, Slice());
+    mem->Add(sequence_, delete_type, key, Slice());
     sequence_++;
     cf_mems_->CheckMemtableFull();
     return Status::OK();
   }
 
+  virtual Status DeleteCF(uint32_t column_family_id,
+                          const Slice& key) override {
+    return DeleteImpl(column_family_id, key, kTypeDeletion);
+  }
+
   virtual Status SingleDeleteCF(uint32_t column_family_id,
                                 const Slice& key) override {
-    Status seek_status;
-    if (!SeekToColumnFamily(column_family_id, &seek_status)) {
-      ++sequence_;
-      return seek_status;
-    }
-    MemTable* mem = cf_mems_->GetMemTable();
-    auto* moptions = mem->GetMemTableOptions();
-    if (!dont_filter_deletes_ && moptions->filter_deletes) {
-      SnapshotImpl read_from_snapshot;
-      read_from_snapshot.number_ = sequence_;
-      ReadOptions ropts;
-      ropts.snapshot = &read_from_snapshot;
-      std::string value;
-      auto cf_handle = cf_mems_->GetColumnFamilyHandle();
-      if (cf_handle == nullptr) {
-        cf_handle = db_->DefaultColumnFamily();
-      }
-      if (!db_->KeyMayExist(ropts, cf_handle, key, &value)) {
-        RecordTick(moptions->statistics, NUMBER_FILTERED_DELETES);
-        return Status::OK();
-      }
-    }
-    mem->Add(sequence_, kTypeSingleDeletion, key, Slice());
-    sequence_++;
-    cf_mems_->CheckMemtableFull();
-    return Status::OK();
+    return DeleteImpl(column_family_id, key, kTypeSingleDeletion);
   }
 
   virtual Status MergeCF(uint32_t column_family_id, const Slice& key,
@@ -653,29 +772,57 @@ class MemTableInserter : public WriteBatch::Handler {
 
 // This function can only be called in these conditions:
 // 1) During Recovery()
-// 2) during Write(), in a single-threaded write thread
-// The reason is that it calles ColumnFamilyMemTablesImpl::Seek(), which needs
-// to be called from a single-threaded write thread (or while holding DB mutex)
-Status WriteBatchInternal::InsertInto(const WriteBatch* b,
+// 2) During Write(), in a single-threaded write thread
+// The reason is that it calls memtables->Seek(), which has a stateful cache
+Status WriteBatchInternal::InsertInto(const autovector<WriteBatch*>& batches,
+                                      SequenceNumber sequence,
                                       ColumnFamilyMemTables* memtables,
                                       bool ignore_missing_column_families,
                                       uint64_t log_number, DB* db,
                                       const bool dont_filter_deletes) {
-  MemTableInserter inserter(WriteBatchInternal::Sequence(b), memtables,
+  MemTableInserter inserter(sequence, memtables, ignore_missing_column_families,
+                            log_number, db, dont_filter_deletes);
+  Status rv = Status::OK();
+  for (size_t i = 0; i < batches.size() && rv.ok(); ++i) {
+    rv = batches[i]->Iterate(&inserter);
+  }
+  return rv;
+}
+
+Status WriteBatchInternal::InsertInto(const WriteBatch* batch,
+                                      ColumnFamilyMemTables* memtables,
+                                      bool ignore_missing_column_families,
+                                      uint64_t log_number, DB* db,
+                                      const bool dont_filter_deletes) {
+  MemTableInserter inserter(WriteBatchInternal::Sequence(batch), memtables,
                             ignore_missing_column_families, log_number, db,
                             dont_filter_deletes);
-  return b->Iterate(&inserter);
+  return batch->Iterate(&inserter);
 }
 
 void WriteBatchInternal::SetContents(WriteBatch* b, const Slice& contents) {
   assert(contents.size() >= kHeader);
   b->rep_.assign(contents.data(), contents.size());
+  b->content_flags_.store(ContentFlags::DEFERRED, std::memory_order_relaxed);
 }
 
 void WriteBatchInternal::Append(WriteBatch* dst, const WriteBatch* src) {
   SetCount(dst, Count(dst) + Count(src));
   assert(src->rep_.size() >= kHeader);
   dst->rep_.append(src->rep_.data() + kHeader, src->rep_.size() - kHeader);
+  dst->content_flags_.store(
+      dst->content_flags_.load(std::memory_order_relaxed) |
+          src->content_flags_.load(std::memory_order_relaxed),
+      std::memory_order_relaxed);
+}
+
+size_t WriteBatchInternal::AppendedByteSize(size_t leftByteSize,
+                                            size_t rightByteSize) {
+  if (leftByteSize == 0 || rightByteSize == 0) {
+    return leftByteSize + rightByteSize;
+  } else {
+    return leftByteSize + rightByteSize - kHeader;
+  }
 }
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/db/write_batch_internal.h b/src/rocksdb/db/write_batch_internal.h
index 04db461..3ae4edc 100644
--- a/src/rocksdb/db/write_batch_internal.h
+++ b/src/rocksdb/db/write_batch_internal.h
@@ -12,6 +12,7 @@
 #include "rocksdb/write_batch.h"
 #include "rocksdb/db.h"
 #include "rocksdb/options.h"
+#include "util/autovector.h"
 
 namespace rocksdb {
 
@@ -112,17 +113,28 @@ class WriteBatchInternal {
 
   static void SetContents(WriteBatch* batch, const Slice& contents);
 
-  // Inserts batch entries into memtable
-  // If dont_filter_deletes is false AND options.filter_deletes is true,
-  // then --> Drops deletes in batch if db->KeyMayExist returns false
-  // If ignore_missing_column_families == true. WriteBatch referencing
-  // non-existing column family should be ignored.
-  // However, if ignore_missing_column_families == false, any WriteBatch
-  // referencing non-existing column family will return a InvalidArgument()
-  // failure.
+  // Inserts batches[i] into memtable, for i in 0..num_batches-1 inclusive.
+  //
+  // If dont_filter_deletes is false AND options.filter_deletes is true
+  // AND db->KeyMayExist is false, then a Delete won't modify the memtable.
+  //
+  // If ignore_missing_column_families == true. WriteBatch
+  // referencing non-existing column family will be ignored.
+  // If ignore_missing_column_families == false, processing of the
+  // batches will be stopped if a reference is found to a non-existing
+  // column family and InvalidArgument() will be returned.  The writes
+  // in batches may be only partially applied at that point.
   //
   // If log_number is non-zero, the memtable will be updated only if
-  // memtables->GetLogNumber() >= log_number
+  // memtables->GetLogNumber() >= log_number.
+  static Status InsertInto(const autovector<WriteBatch*>& batches,
+                           SequenceNumber sequence,
+                           ColumnFamilyMemTables* memtables,
+                           bool ignore_missing_column_families = false,
+                           uint64_t log_number = 0, DB* db = nullptr,
+                           const bool dont_filter_deletes = true);
+
+  // Convenience form of InsertInto when you have only one batch
   static Status InsertInto(const WriteBatch* batch,
                            ColumnFamilyMemTables* memtables,
                            bool ignore_missing_column_families = false,
@@ -130,6 +142,10 @@ class WriteBatchInternal {
                            const bool dont_filter_deletes = true);
 
   static void Append(WriteBatch* dst, const WriteBatch* src);
+
+  // Returns the byte size of appending a WriteBatch with ByteSize
+  // leftByteSize and a WriteBatch with ByteSize rightByteSize
+  static size_t AppendedByteSize(size_t leftByteSize, size_t rightByteSize);
 };
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/db/write_batch_test.cc b/src/rocksdb/db/write_batch_test.cc
index d8c6f8c..62830da 100644
--- a/src/rocksdb/db/write_batch_test.cc
+++ b/src/rocksdb/db/write_batch_test.cc
@@ -17,10 +17,10 @@
 #include "rocksdb/env.h"
 #include "rocksdb/memtablerep.h"
 #include "rocksdb/utilities/write_batch_with_index.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/logging.h"
 #include "util/string_util.h"
 #include "util/testharness.h"
-#include "util/scoped_arena_iterator.h"
 
 namespace rocksdb {
 
@@ -39,6 +39,10 @@ static std::string PrintContents(WriteBatch* b) {
   ColumnFamilyMemTablesDefault cf_mems_default(mem);
   Status s = WriteBatchInternal::InsertInto(b, &cf_mems_default);
   int count = 0;
+  int put_count = 0;
+  int delete_count = 0;
+  int single_delete_count = 0;
+  int merge_count = 0;
   Arena arena;
   ScopedArenaIterator iter(mem->NewIterator(ReadOptions(), &arena));
   for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
@@ -53,18 +57,21 @@ static std::string PrintContents(WriteBatch* b) {
         state.append(iter->value().ToString());
         state.append(")");
         count++;
+        put_count++;
         break;
       case kTypeDeletion:
         state.append("Delete(");
         state.append(ikey.user_key.ToString());
         state.append(")");
         count++;
+        delete_count++;
         break;
       case kTypeSingleDeletion:
         state.append("SingleDelete(");
         state.append(ikey.user_key.ToString());
         state.append(")");
         count++;
+        single_delete_count++;
         break;
       case kTypeMerge:
         state.append("Merge(");
@@ -73,6 +80,7 @@ static std::string PrintContents(WriteBatch* b) {
         state.append(iter->value().ToString());
         state.append(")");
         count++;
+        merge_count++;
         break;
       default:
         assert(false);
@@ -81,6 +89,10 @@ static std::string PrintContents(WriteBatch* b) {
     state.append("@");
     state.append(NumberToString(ikey.sequence));
   }
+  EXPECT_EQ(b->HasPut(), put_count > 0);
+  EXPECT_EQ(b->HasDelete(), delete_count > 0);
+  EXPECT_EQ(b->HasSingleDelete(), single_delete_count > 0);
+  EXPECT_EQ(b->HasMerge(), merge_count > 0);
   if (!s.ok()) {
     state.append(s.ToString());
   } else if (count != WriteBatchInternal::Count(b)) {
diff --git a/src/rocksdb/db/write_controller.cc b/src/rocksdb/db/write_controller.cc
index c26f6fb..3bbb116 100644
--- a/src/rocksdb/db/write_controller.cc
+++ b/src/rocksdb/db/write_controller.cc
@@ -25,7 +25,7 @@ std::unique_ptr<WriteControllerToken> WriteController::GetDelayToken() {
 }
 
 bool WriteController::IsStopped() const { return total_stopped_ > 0; }
-// Tihs is inside DB mutex, so we can't sleep and need to minimize
+// This is inside DB mutex, so we can't sleep and need to minimize
 // frequency to get time.
 // If it turns out to be a performance issue, we can redesign the thread
 // synchronization model here.
diff --git a/src/rocksdb/db/write_thread.cc b/src/rocksdb/db/write_thread.cc
index 9b66af2..cbfd264 100644
--- a/src/rocksdb/db/write_thread.cc
+++ b/src/rocksdb/db/write_thread.cc
@@ -4,6 +4,7 @@
 //  of patent rights can be found in the PATENTS file in the same directory.
 
 #include "db/write_thread.h"
+#include "util/sync_point.h"
 
 namespace rocksdb {
 
@@ -120,12 +121,13 @@ size_t WriteThread::EnterAsBatchGroupLeader(
       break;
     }
 
-    size += WriteBatchInternal::ByteSize(w->batch);
-    if (size > max_size) {
+    auto batch_size = WriteBatchInternal::ByteSize(w->batch);
+    if (size + batch_size > max_size) {
       // Do not make batch too big
       break;
     }
 
+    size += batch_size;
     write_batch_group->push_back(w->batch);
     w->in_batch_group = true;
     *last_writer = w;
@@ -187,6 +189,7 @@ void WriteThread::EnterUnbatched(Writer* w, InstrumentedMutex* mu) {
   LinkOne(w, &wait_needed);
   if (wait_needed) {
     mu->Unlock();
+    TEST_SYNC_POINT("WriteThread::EnterUnbatched:Wait");
     Await(w);
     mu->Lock();
   }
diff --git a/src/rocksdb/doc/log_format.txt b/src/rocksdb/doc/log_format.txt
index 3a0414b..5222d81 100644
--- a/src/rocksdb/doc/log_format.txt
+++ b/src/rocksdb/doc/log_format.txt
@@ -11,7 +11,7 @@ Each block consists of a sequence of records:
 
 A record never starts within the last six bytes of a block (since it
 won't fit).  Any leftover bytes here form the trailer, which must
-consist entirely of zero bytes and must be skipped by readers.  
+consist entirely of zero bytes and must be skipped by readers.
 
 Aside: if exactly seven bytes are left in the current block, and a new
 non-zero length record is added, the writer must emit a FIRST record
diff --git a/src/rocksdb/examples/Makefile b/src/rocksdb/examples/Makefile
index fe82d11..5bf0577 100644
--- a/src/rocksdb/examples/Makefile
+++ b/src/rocksdb/examples/Makefile
@@ -28,6 +28,9 @@ optimistic_transaction_example: librocksdb optimistic_transaction_example.cc
 transaction_example: librocksdb transaction_example.cc
 	$(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++11 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
 
+options_file_example: librocksdb options_file_example.cc
+	$(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++11 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+
 clean:
 	rm -rf ./simple_example ./column_families_example ./compact_files_example ./compaction_filter_example ./c_simple_example c_simple_example.o ./optimistic_transaction_example ./transaction_example
 
diff --git a/src/rocksdb/examples/options_file_example.cc b/src/rocksdb/examples/options_file_example.cc
new file mode 100644
index 0000000..916ff02
--- /dev/null
+++ b/src/rocksdb/examples/options_file_example.cc
@@ -0,0 +1,113 @@
+// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+//
+// This file demonstrates how to use the utility functions defined in
+// rocksdb/utilities/options_util.h to open a rocksdb database without
+// remembering all the rocksdb options.
+#include <cstdio>
+#include <string>
+#include <vector>
+
+#include "rocksdb/cache.h"
+#include "rocksdb/compaction_filter.h"
+#include "rocksdb/db.h"
+#include "rocksdb/options.h"
+#include "rocksdb/slice.h"
+#include "rocksdb/table.h"
+#include "rocksdb/utilities/options_util.h"
+
+using namespace rocksdb;
+
+std::string kDBPath = "/tmp/rocksdb_options_file_example";
+
+namespace {
+// A dummy compaction filter
+class DummyCompactionFilter : public CompactionFilter {
+ public:
+  virtual ~DummyCompactionFilter() {}
+  virtual bool Filter(int level, const Slice& key, const Slice& existing_value,
+                      std::string* new_value, bool* value_changed) const {
+    return false;
+  }
+  virtual const char* Name() const { return "DummyCompactionFilter"; }
+};
+
+}  // namespace
+
+int main() {
+  DBOptions db_opt;
+  db_opt.create_if_missing = true;
+
+  std::vector<ColumnFamilyDescriptor> cf_descs;
+  cf_descs.push_back({kDefaultColumnFamilyName, ColumnFamilyOptions()});
+  cf_descs.push_back({"new_cf", ColumnFamilyOptions()});
+
+  // initialize BlockBasedTableOptions
+  auto cache = NewLRUCache(1 * 1024 * 1024 * 1024);
+  BlockBasedTableOptions bbt_opts;
+  bbt_opts.block_size = 32 * 1024;
+  bbt_opts.block_cache = cache;
+
+  // initialize column families options
+  std::unique_ptr<CompactionFilter> compaction_filter;
+  compaction_filter.reset(new DummyCompactionFilter());
+  cf_descs[0].options.table_factory.reset(NewBlockBasedTableFactory(bbt_opts));
+  cf_descs[0].options.compaction_filter = compaction_filter.get();
+  cf_descs[1].options.table_factory.reset(NewBlockBasedTableFactory(bbt_opts));
+
+  // destroy and open DB
+  DB* db;
+  Status s = DestroyDB(kDBPath, Options(db_opt, cf_descs[0].options));
+  assert(s.ok());
+  s = DB::Open(Options(db_opt, cf_descs[0].options), kDBPath, &db);
+  assert(s.ok());
+
+  // Create column family, and rocksdb will persist the options.
+  ColumnFamilyHandle* cf;
+  s = db->CreateColumnFamily(ColumnFamilyOptions(), "new_cf", &cf);
+  assert(s.ok());
+
+  // close DB
+  delete cf;
+  delete db;
+
+  // In the following code, we will reopen the rocksdb instance using
+  // the options file stored in the db directory.
+
+  // Load the options file.
+  DBOptions loaded_db_opt;
+  std::vector<ColumnFamilyDescriptor> loaded_cf_descs;
+  s = LoadLatestOptions(kDBPath, Env::Default(), &loaded_db_opt,
+                        &loaded_cf_descs);
+  assert(s.ok());
+  assert(loaded_db_opt.create_if_missing == db_opt.create_if_missing);
+
+  // Initialize pointer options for each column family
+  for (size_t i = 0; i < loaded_cf_descs.size(); ++i) {
+    auto* loaded_bbt_opt = reinterpret_cast<BlockBasedTableOptions*>(
+        loaded_cf_descs[0].options.table_factory->GetOptions());
+    // Expect the same as BlockBasedTableOptions will be loaded form file.
+    assert(loaded_bbt_opt->block_size == bbt_opts.block_size);
+    // However, block_cache needs to be manually initialized as documented
+    // in rocksdb/utilities/options_util.h.
+    loaded_bbt_opt->block_cache = cache;
+  }
+  // In addition, as pointer options are initialized with default value,
+  // we need to properly initialized all the pointer options if non-defalut
+  // values are used before calling DB::Open().
+  assert(loaded_cf_descs[0].options.compaction_filter == nullptr);
+  loaded_cf_descs[0].options.compaction_filter = compaction_filter.get();
+
+  // reopen the db using the loaded options.
+  std::vector<ColumnFamilyHandle*> handles;
+  s = DB::Open(loaded_db_opt, kDBPath, loaded_cf_descs, &handles, &db);
+  assert(s.ok());
+
+  // close DB
+  for (auto* handle : handles) {
+    delete handle;
+  }
+  delete db;
+}
diff --git a/src/rocksdb/examples/rocksdb_option_file_example.ini b/src/rocksdb/examples/rocksdb_option_file_example.ini
index ce74f77..838afe8 100644
--- a/src/rocksdb/examples/rocksdb_option_file_example.ini
+++ b/src/rocksdb/examples/rocksdb_option_file_example.ini
@@ -1,9 +1,10 @@
 # This is a RocksDB option file.
 #
-# A typical RocksDB options file has three sections, which are
-# Version, DBOptions, and more than one CFOptions.  The RocksDB
-# options file in general follows the basic INI file format
-# with the following extensions / modifications:
+# A typical RocksDB options file has four sections, which are
+# Version section, DBOptions section, at least one CFOptions
+# section, and one TableOptions section for each column family.
+# The RocksDB options file in general follows the basic INI
+# file format with the following extensions / modifications:
 #
 #  * Escaped characters
 #    We escaped the following characters:
@@ -20,7 +21,7 @@
 #    Each statement contains a '=', where extra white-spaces
 #    are supported. However, we don't support multi-lined statement.
 #    Furthermore, each line can only contain at most one statement.
-#  * Section
+#  * Sections
 #    Sections are of the form [SecitonTitle "SectionArgument"],
 #    where section argument is optional.
 #  * List
@@ -29,25 +30,114 @@
 #
 # Below is an example of a RocksDB options file:
 [Version]
-  # The Version section stores the version information about rocksdb
-  # and option file.  This is used for handling potential format
-  # change in the future.
-  rocksdb_version=4.0.0  # We support "#" style comment.
-  options_file_version=1.0
+  rocksdb_version=4.3.0
+  options_file_version=1.1
+
 [DBOptions]
-  # Followed by the Version section is the DBOptions section.
-  # The value of an options can be assigned using a statement.
-  # Note that for those options that is not set in the options file,
-  # we will use the default value.
-  max_open_files=12345
-  max_background_flushes=301
+  stats_dump_period_sec=600
+  max_manifest_file_size=18446744073709551615
+  bytes_per_sync=8388608
+  delayed_write_rate=2097152
+  WAL_ttl_seconds=0
+  WAL_size_limit_MB=0
+  max_subcompactions=1
+  wal_dir=
+  wal_bytes_per_sync=0
+  db_write_buffer_size=0
+  keep_log_file_num=1000
+  table_cache_numshardbits=4
+  max_file_opening_threads=1
+  writable_file_max_buffer_size=1048576
+  random_access_max_buffer_size=1048576
+  use_fsync=false
+  max_total_wal_size=0
+  max_open_files=-1
+  skip_stats_update_on_db_open=false
+  max_background_compactions=16
+  manifest_preallocation_size=4194304
+  max_background_flushes=7
+  is_fd_close_on_exec=true
+  max_log_file_size=0
+  advise_random_on_open=true
+  create_missing_column_families=false
+  paranoid_checks=true
+  delete_obsolete_files_period_micros=21600000000
+  disable_data_sync=false
+  log_file_time_to_roll=0
+  compaction_readahead_size=0
+  create_if_missing=false
+  use_adaptive_mutex=false
+  enable_thread_tracking=false
+  disableDataSync=false
+  allow_fallocate=true
+  error_if_exists=false
+  recycle_log_file_num=0
+  skip_log_error_on_recovery=false
+  allow_mmap_reads=false
+  allow_os_buffer=true
+  db_log_dir=
+  new_table_reader_for_compaction_inputs=true
+  allow_mmap_writes=false
+  
+
 [CFOptions "default"]
-  # ColumnFamilyOptions section must follow the format of
-  # [CFOptions "cf name"].  If a rocksdb instance
-  # has multiple column families, then its CFOptions must be
-  # specified in the same order as column family creation order.
-[CFOptions "the second column family"]
-  # Each column family must have one section in the RocksDB option
-  # file even all the options of this column family are set to
-  # default value.
-[CFOptions "the third column family"]
+  compaction_style=kCompactionStyleLevel
+  compaction_filter=nullptr
+  num_levels=6
+  table_factory=BlockBasedTable
+  comparator=leveldb.BytewiseComparator
+  max_sequential_skip_in_iterations=8
+  soft_rate_limit=0.000000
+  max_bytes_for_level_base=1073741824
+  memtable_prefix_bloom_probes=6
+  memtable_prefix_bloom_bits=0
+  memtable_prefix_bloom_huge_page_tlb_size=0
+  max_successive_merges=0
+  arena_block_size=16777216
+  min_write_buffer_number_to_merge=1
+  target_file_size_multiplier=1
+  source_compaction_factor=1
+  max_bytes_for_level_multiplier=8
+  compaction_filter_factory=nullptr
+  max_write_buffer_number=8
+  level0_stop_writes_trigger=20
+  compression=kSnappyCompression
+  level0_file_num_compaction_trigger=4
+  purge_redundant_kvs_while_flush=true
+  max_write_buffer_number_to_maintain=0
+  memtable_factory=SkipListFactory
+  max_grandparent_overlap_factor=8
+  expanded_compaction_factor=25
+  hard_pending_compaction_bytes_limit=137438953472
+  inplace_update_num_locks=10000
+  level_compaction_dynamic_level_bytes=true
+  level0_slowdown_writes_trigger=12
+  filter_deletes=false
+  verify_checksums_in_compaction=true
+  min_partial_merge_operands=2
+  paranoid_file_checks=false
+  target_file_size_base=134217728
+  optimize_filters_for_hits=false
+  merge_operator=PutOperator
+  compression_per_level=kNoCompression:kNoCompression:kNoCompression:kSnappyCompression:kSnappyCompression:kSnappyCompression
+  compaction_measure_io_stats=false
+  prefix_extractor=nullptr
+  bloom_locality=0
+  write_buffer_size=134217728
+  disable_auto_compactions=false
+  inplace_update_support=false
+  
+[TableOptions/BlockBasedTable "default"]
+  format_version=2
+  whole_key_filtering=true
+  skip_table_builder_flush=false
+  no_block_cache=false
+  checksum=kCRC32c
+  filter_policy=rocksdb.BuiltinBloomFilter
+  block_size_deviation=10
+  block_size=8192
+  block_restart_interval=16
+  cache_index_and_filter_blocks=false
+  index_type=kBinarySearch
+  hash_index_allow_collision=true
+  flush_block_policy_factory=FlushBlockBySizePolicyFactory
diff --git a/src/rocksdb/hdfs/README b/src/rocksdb/hdfs/README
index f4f1106..598315b 100644
--- a/src/rocksdb/hdfs/README
+++ b/src/rocksdb/hdfs/README
@@ -10,7 +10,7 @@ The env_hdfs.h file defines the rocksdb objects that are needed to talk to an
 underlying filesystem. 
 
 If you want to compile rocksdb with hdfs support, please set the following
-enviroment variables appropriately (also defined in setup.sh for convenience)
+environment variables appropriately (also defined in setup.sh for convenience)
    USE_HDFS=1
    JAVA_HOME=/usr/local/jdk-6u22-64
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/jdk-6u22-64/jre/lib/amd64/server:/usr/local/jdk-6u22-64/jre/lib/amd64/:./snappy/libs
diff --git a/src/rocksdb/include/rocksdb/c.h b/src/rocksdb/include/rocksdb/c.h
index 782d10b..6bb3b85 100644
--- a/src/rocksdb/include/rocksdb/c.h
+++ b/src/rocksdb/include/rocksdb/c.h
@@ -450,6 +450,9 @@ rocksdb_block_based_options_set_hash_index_allow_collision(
 extern ROCKSDB_LIBRARY_API void
 rocksdb_block_based_options_set_cache_index_and_filter_blocks(
     rocksdb_block_based_table_options_t*, unsigned char);
+extern ROCKSDB_LIBRARY_API void
+rocksdb_block_based_options_set_skip_table_builder_flush(
+    rocksdb_block_based_table_options_t* options, unsigned char);
 extern ROCKSDB_LIBRARY_API void rocksdb_options_set_block_based_table_factory(
     rocksdb_options_t* opt, rocksdb_block_based_table_options_t* table_options);
 
@@ -572,6 +575,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_log_file_time_to_roll(
     rocksdb_options_t*, size_t);
 extern ROCKSDB_LIBRARY_API void rocksdb_options_set_keep_log_file_num(
     rocksdb_options_t*, size_t);
+extern ROCKSDB_LIBRARY_API void rocksdb_options_set_recycle_log_file_num(
+    rocksdb_options_t*, size_t);
 extern ROCKSDB_LIBRARY_API void rocksdb_options_set_soft_rate_limit(
     rocksdb_options_t*, double);
 extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hard_rate_limit(
diff --git a/src/rocksdb/include/rocksdb/cache.h b/src/rocksdb/include/rocksdb/cache.h
index 4e4b0e1..47657b9 100644
--- a/src/rocksdb/include/rocksdb/cache.h
+++ b/src/rocksdb/include/rocksdb/cache.h
@@ -45,7 +45,9 @@ class Cache {
   Cache() { }
 
   // Destroys all existing entries by calling the "deleter"
-  // function that was passed to the constructor.
+  // function that was passed via the Insert() function.
+  //
+  // @See Insert
   virtual ~Cache();
 
   // Opaque handle to an entry stored in the cache.
diff --git a/src/rocksdb/include/rocksdb/compaction_filter.h b/src/rocksdb/include/rocksdb/compaction_filter.h
index 698753c..3bb250e 100644
--- a/src/rocksdb/include/rocksdb/compaction_filter.h
+++ b/src/rocksdb/include/rocksdb/compaction_filter.h
@@ -39,6 +39,8 @@ class CompactionFilter {
     // Is this compaction requested by the client (true),
     // or is it occurring as an automatic compaction process
     bool is_manual_compaction;
+    // Which column family this compaction is for.
+    uint32_t column_family_id;
   };
 
   virtual ~CompactionFilter() {}
@@ -96,6 +98,16 @@ class CompactionFilter {
     return false;
   }
 
+  // By default, compaction will only call Filter() on keys written after the
+  // most recent call to GetSnapshot(). However, if the compaction filter
+  // overrides IgnoreSnapshots to make it return false, the compaction filter
+  // will be called even if the keys were written before the last snapshot.
+  // This behavior is to be used only when we want to delete a set of keys
+  // irrespective of snapshots. In particular, care should be taken
+  // to understand that the values of thesekeys will change even if we are
+  // using a snapshot.
+  virtual bool IgnoreSnapshots() const { return false; }
+
   // Returns a name that identifies this compaction filter.
   // The name will be printed to LOG file on start up for diagnosis.
   virtual const char* Name() const = 0;
@@ -114,20 +126,6 @@ class CompactionFilterFactory {
   virtual const char* Name() const = 0;
 };
 
-// Default implementation of CompactionFilterFactory which does not
-// return any filter
-class DefaultCompactionFilterFactory : public CompactionFilterFactory {
- public:
-  virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
-      const CompactionFilter::Context& context) override {
-    return std::unique_ptr<CompactionFilter>(nullptr);
-  }
-
-  virtual const char* Name() const override {
-    return "DefaultCompactionFilterFactory";
-  }
-};
-
 }  // namespace rocksdb
 
 #endif  // STORAGE_ROCKSDB_INCLUDE_COMPACTION_FILTER_H_
diff --git a/src/rocksdb/include/rocksdb/convenience.h b/src/rocksdb/include/rocksdb/convenience.h
index db59727..7a65b13 100644
--- a/src/rocksdb/include/rocksdb/convenience.h
+++ b/src/rocksdb/include/rocksdb/convenience.h
@@ -40,7 +40,14 @@ Status GetDBOptionsFromMap(
 Status GetBlockBasedTableOptionsFromMap(
     const BlockBasedTableOptions& table_options,
     const std::unordered_map<std::string, std::string>& opts_map,
-    BlockBasedTableOptions* new_table_options);
+    BlockBasedTableOptions* new_table_options,
+    bool input_strings_escaped = false);
+
+Status GetPlainTableOptionsFromMap(
+    const PlainTableOptions& table_options,
+    const std::unordered_map<std::string, std::string>& opts_map,
+    PlainTableOptions* new_table_options,
+    bool input_strings_escaped = false);
 
 // Take a string representation of option names and  values, apply them into the
 // base_options, and return the new options as a result. The string has the
@@ -73,6 +80,15 @@ Status GetBlockBasedTableOptionsFromString(
     const std::string& opts_str,
     BlockBasedTableOptions* new_table_options);
 
+Status GetPlainTableOptionsFromString(
+    const PlainTableOptions& table_options,
+    const std::string& opts_str,
+    PlainTableOptions* new_table_options);
+
+Status GetMemTableRepFactoryFromString(
+    const std::string& opts_str,
+    std::unique_ptr<MemTableRepFactory>* new_mem_factory);
+
 Status GetOptionsFromString(const Options& base_options,
                             const std::string& opts_str, Options* new_options);
 
diff --git a/src/rocksdb/include/rocksdb/db.h b/src/rocksdb/include/rocksdb/db.h
index 5a49638..2fb1c51 100644
--- a/src/rocksdb/include/rocksdb/db.h
+++ b/src/rocksdb/include/rocksdb/db.h
@@ -15,15 +15,16 @@
 #include <vector>
 #include <string>
 #include <unordered_map>
-#include "rocksdb/metadata.h"
-#include "rocksdb/version.h"
+#include "rocksdb/immutable_options.h"
 #include "rocksdb/iterator.h"
-#include "rocksdb/options.h"
-#include "rocksdb/types.h"
-#include "rocksdb/transaction_log.h"
 #include "rocksdb/listener.h"
+#include "rocksdb/metadata.h"
+#include "rocksdb/options.h"
 #include "rocksdb/snapshot.h"
 #include "rocksdb/thread_status.h"
+#include "rocksdb/transaction_log.h"
+#include "rocksdb/types.h"
+#include "rocksdb/version.h"
 
 #ifdef _WIN32
 // Windows API macro interference
@@ -188,6 +189,18 @@ class DB {
   // Remove the database entry for "key". Requires that the key exists
   // and was not overwritten. Returns OK on success, and a non-OK status
   // on error.  It is not an error if "key" did not exist in the database.
+  //
+  // If a key is overwritten (by calling Put() multiple times), then the result
+  // of calling SingleDelete() on this key is undefined.  SingleDelete() only
+  // behaves correctly if there has been only one Put() for this key since the
+  // previous call to SingleDelete() for this key.
+  //
+  // This feature is currently an experimental performance optimization
+  // for a very specific workload.  It is up to the caller to ensure that
+  // SingleDelete is only used for a key that is not deleted using Delete() or
+  // written using Merge().  Mixing SingleDelete operations with Deletes and
+  // Merges can result in undefined behavior.
+  //
   // Note: consider setting options.sync = true.
   virtual Status SingleDelete(const WriteOptions& options,
                               ColumnFamilyHandle* column_family,
@@ -258,9 +271,10 @@ class DB {
   // This check is potentially lighter-weight than invoking DB::Get(). One way
   // to make this lighter weight is to avoid doing any IOs.
   // Default implementation here returns true and sets 'value_found' to false
-  virtual bool KeyMayExist(const ReadOptions& options,
-                           ColumnFamilyHandle* column_family, const Slice& key,
-                           std::string* value, bool* value_found = nullptr) {
+  virtual bool KeyMayExist(const ReadOptions& /*options*/,
+                           ColumnFamilyHandle* /*column_family*/,
+                           const Slice& /*key*/, std::string* /*value*/,
+                           bool* value_found = nullptr) {
     if (value_found != nullptr) {
       *value_found = false;
     }
@@ -324,34 +338,37 @@ class DB {
   //  "rocksdb.compaction-pending" - 1 if at least one compaction is pending
   //  "rocksdb.background-errors" - accumulated number of background errors
   //  "rocksdb.cur-size-active-mem-table"
-//  "rocksdb.size-all-mem-tables"
-//  "rocksdb.num-entries-active-mem-table"
-//  "rocksdb.num-entries-imm-mem-tables"
-//  "rocksdb.num-deletes-active-mem-table"
-//  "rocksdb.num-deletes-imm-mem-tables"
-//  "rocksdb.estimate-num-keys" - estimated keys in the column family
-//  "rocksdb.estimate-table-readers-mem" - estimated memory used for reding
-//      SST tables, that is not counted as a part of block cache.
-//  "rocksdb.is-file-deletions-enabled"
-//  "rocksdb.num-snapshots"
-//  "rocksdb.oldest-snapshot-time"
-//  "rocksdb.num-live-versions" - `version` is an internal data structure.
-//      See version_set.h for details. More live versions often mean more SST
-//      files are held from being deleted, by iterators or unfinished
-//      compactions.
-//  "rocksdb.estimate-live-data-size"
-//  "rocksdb.total-sst-files-size" - total size of all used sst files, this may
-//      slow down online queries if there are too many files.
-//  "rocksdb.base-level"
-//  "rocksdb.estimate-pending-compaction-bytes" - estimated total number of
-//      bytes compaction needs to rewrite the data to get all levels down
-//      to under target size. Not valid for other compactions than level-based.
-//  "rocksdb.aggregated-table-properties" - returns a string representation of
-//      the aggregated table properties of the target column family.
-//  "rocksdb.aggregated-table-properties-at-level<N>", same as the previous
-//      one but only returns the aggregated table properties of the specified
-//      level "N" at the target column family.
-//  replaced by the target level.
+  //  "rocksdb.size-all-mem-tables"
+  //  "rocksdb.num-entries-active-mem-table"
+  //  "rocksdb.num-entries-imm-mem-tables"
+  //  "rocksdb.num-deletes-active-mem-table"
+  //  "rocksdb.num-deletes-imm-mem-tables"
+  //  "rocksdb.estimate-num-keys" - estimated keys in the column family
+  //  "rocksdb.estimate-table-readers-mem" - estimated memory used for reding
+  //      SST tables, that is not counted as a part of block cache.
+  //  "rocksdb.is-file-deletions-enabled"
+  //  "rocksdb.num-snapshots"
+  //  "rocksdb.oldest-snapshot-time"
+  //  "rocksdb.num-live-versions" - `version` is an internal data structure.
+  //      See version_set.h for details. More live versions often mean more SST
+  //      files are held from being deleted, by iterators or unfinished
+  //      compactions.
+  //  "rocksdb.estimate-live-data-size"
+  //  "rocksdb.total-sst-files-size" - total size of all used sst files, this
+  //      may slow down online queries if there are too many files.
+  //  "rocksdb.base-level"
+  //  "rocksdb.estimate-pending-compaction-bytes" - estimated total number of
+  //      bytes compaction needs to rewrite the data to get all levels down
+  //      to under target size. Not valid for other compactions than
+  //      level-based.
+  //  "rocksdb.aggregated-table-properties" - returns a string representation
+  //      of the aggregated table properties of the target column family.
+  //  "rocksdb.aggregated-table-properties-at-level<N>", same as the previous
+  //      one but only returns the aggregated table properties of the specified
+  //      level "N" at the target column family.
+  //  "rocksdb.num-running-compactions" - the number of currently running
+  //      compacitons.
+  //  "rocksdb.num-running-flushes" - the number of currently running flushes.
 #ifndef ROCKSDB_LITE
   struct Properties {
     static const std::string kNumFilesAtLevelPrefix;
@@ -361,7 +378,9 @@ class DB {
     static const std::string kDBStats;
     static const std::string kNumImmutableMemTable;
     static const std::string kMemTableFlushPending;
+    static const std::string kNumRunningFlushes;
     static const std::string kCompactionPending;
+    static const std::string kNumRunningCompactions;
     static const std::string kBackgroundErrors;
     static const std::string kCurSizeActiveMemTable;
     static const std::string kCurSizeAllMemTables;
@@ -414,12 +433,19 @@ class DB {
   //  "rocksdb.total-sst-files-size"
   //  "rocksdb.base-level"
   //  "rocksdb.estimate-pending-compaction-bytes"
+  //  "rocksdb.num-running-compactions"
+  //  "rocksdb.num-running-flushes"
   virtual bool GetIntProperty(ColumnFamilyHandle* column_family,
                               const Slice& property, uint64_t* value) = 0;
   virtual bool GetIntProperty(const Slice& property, uint64_t* value) {
     return GetIntProperty(DefaultColumnFamily(), property, value);
   }
 
+  // Same as GetIntProperty(), but this one returns the aggregated int
+  // property from all column families.
+  virtual bool GetAggregatedIntProperty(const Slice& property,
+                                        uint64_t* value) = 0;
+
   // For each i in [0,n-1], store in "sizes[i]", the approximate
   // file system space used by keys in "[range[i].start .. range[i].limit)".
   //
@@ -495,8 +521,9 @@ class DB {
     return CompactRange(options, DefaultColumnFamily(), begin, end);
   }
 
-  virtual Status SetOptions(ColumnFamilyHandle* column_family,
-      const std::unordered_map<std::string, std::string>& new_options) {
+  virtual Status SetOptions(
+      ColumnFamilyHandle* /*column_family*/,
+      const std::unordered_map<std::string, std::string>& /*new_options*/) {
     return Status::NotSupported("Not implemented");
   }
   virtual Status SetOptions(
@@ -531,6 +558,12 @@ class DB {
   virtual Status PauseBackgroundWork() = 0;
   virtual Status ContinueBackgroundWork() = 0;
 
+  // This function will enable automatic compactions for the given column
+  // families if they were previously disabled via the disable_auto_compactions
+  // option.
+  virtual Status EnableAutoCompaction(
+      const std::vector<ColumnFamilyHandle*>& column_family_handles) = 0;
+
   // Number of levels used for this DB.
   virtual int NumberLevels(ColumnFamilyHandle* column_family) = 0;
   virtual int NumberLevels() { return NumberLevels(DefaultColumnFamily()); }
@@ -646,7 +679,8 @@ class DB {
 
   // Returns a list of all table files with their level, start key
   // and end key
-  virtual void GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {}
+  virtual void GetLiveFilesMetaData(
+      std::vector<LiveFileMetaData>* /*metadata*/) {}
 
   // Obtains the meta data of the specified column family of the DB.
   // Status::NotFound() will be returned if the current DB does not have
@@ -654,9 +688,8 @@ class DB {
   //
   // If cf_name is not specified, then the metadata of the default
   // column family will be returned.
-  virtual void GetColumnFamilyMetaData(
-      ColumnFamilyHandle* column_family,
-      ColumnFamilyMetaData* metadata) {}
+  virtual void GetColumnFamilyMetaData(ColumnFamilyHandle* /*column_family*/,
+                                       ColumnFamilyMetaData* /*metadata*/) {}
 
   // Get the metadata of the default column family.
   void GetColumnFamilyMetaData(
@@ -670,13 +703,11 @@ class DB {
   // move the file instead of copying it.
   //
   // Current Requirements:
-  // (1) Memtable is empty.
-  // (2) All existing files (if any) have sequence number = 0.
-  // (3) Key range in loaded table file don't overlap with existing
-  //     files key ranges.
-  // (4) No other writes happen during AddFile call, otherwise
+  // (1) Key range in loaded table file don't overlap with
+  //     existing keys or tombstones in DB.
+  // (2) No other writes happen during AddFile call, otherwise
   //     DB may get corrupted.
-  // (5) Database have at least 2 levels.
+  // (3) No snapshots are held.
   virtual Status AddFile(ColumnFamilyHandle* column_family,
                          const std::string& file_path,
                          bool move_file = false) = 0;
@@ -709,6 +740,9 @@ class DB {
   virtual Status GetPropertiesOfAllTables(TablePropertiesCollection* props) {
     return GetPropertiesOfAllTables(DefaultColumnFamily(), props);
   }
+  virtual Status GetPropertiesOfTablesInRange(
+      ColumnFamilyHandle* column_family, const Range* range, std::size_t n,
+      TablePropertiesCollection* props) = 0;
 #endif  // ROCKSDB_LITE
 
   // Needed for StackableDB
diff --git a/src/rocksdb/include/rocksdb/env.h b/src/rocksdb/include/rocksdb/env.h
index 57c60f0..ebaeee6 100644
--- a/src/rocksdb/include/rocksdb/env.h
+++ b/src/rocksdb/include/rocksdb/env.h
@@ -88,6 +88,15 @@ struct EnvOptions {
   // WAL writes
   bool fallocate_with_keep_size = true;
 
+  // See DBOPtions doc
+  size_t compaction_readahead_size;
+
+  // See DBOPtions doc
+  size_t random_access_max_buffer_size;
+
+  // See DBOptions doc
+  size_t writable_file_max_buffer_size = 1024 * 1024;
+
   // If not nullptr, write rate limiting is enabled for flush and compaction
   RateLimiter* rate_limiter = nullptr;
 };
@@ -139,6 +148,12 @@ class Env {
                                  unique_ptr<WritableFile>* result,
                                  const EnvOptions& options) = 0;
 
+  // Reuse an existing file by renaming it and opening it as writable.
+  virtual Status ReuseWritableFile(const std::string& fname,
+                                   const std::string& old_fname,
+                                   unique_ptr<WritableFile>* result,
+                                   const EnvOptions& options);
+
   // Create an object that represents a directory. Will fail if directory
   // doesn't exist. If the directory exists, it will open the directory
   // and create a new Directory object.
@@ -402,6 +417,10 @@ class RandomAccessFile {
     return false;
   }
 
+  // For cases when read-ahead is implemented in the platform dependent
+  // layer
+  virtual void EnableReadAhead() {}
+
   // Tries to get an unique ID for this file that will be the same each time
   // the file is opened (and will stay the same while the file is open).
   // Furthermore, it tries to make this ID at most "max_size" bytes. If such an
@@ -551,7 +570,7 @@ class WritableFile {
   // This asks the OS to initiate flushing the cached data to disk,
   // without waiting for completion.
   // Default implementation does nothing.
-  virtual Status RangeSync(off_t offset, off_t nbytes) { return Status::OK(); }
+  virtual Status RangeSync(uint64_t offset, uint64_t nbytes) { return Status::OK(); }
 
   // PrepareWrite performs any necessary preparation for a write
   // before the write actually occurs.  This allows for pre-allocation
@@ -571,8 +590,8 @@ class WritableFile {
     if (new_last_preallocated_block > last_preallocated_block_) {
       size_t num_spanned_blocks =
         new_last_preallocated_block - last_preallocated_block_;
-      Allocate(static_cast<off_t>(block_size * last_preallocated_block_),
-               static_cast<off_t>(block_size * num_spanned_blocks));
+      Allocate(block_size * last_preallocated_block_,
+               block_size * num_spanned_blocks);
       last_preallocated_block_ = new_last_preallocated_block;
     }
   }
@@ -581,7 +600,7 @@ class WritableFile {
   /*
    * Pre-allocate space for a file.
    */
-  virtual Status Allocate(off_t offset, off_t len) {
+  virtual Status Allocate(uint64_t offset, uint64_t len) {
     return Status::OK();
   }
 
@@ -596,6 +615,7 @@ class WritableFile {
 
  protected:
   friend class WritableFileWrapper;
+  friend class WritableFileMirror;
 
   Env::IOPriority io_priority_;
 };
@@ -749,6 +769,12 @@ class EnvWrapper : public Env {
                          const EnvOptions& options) override {
     return target_->NewWritableFile(f, r, options);
   }
+  Status ReuseWritableFile(const std::string& fname,
+                           const std::string& old_fname,
+                           unique_ptr<WritableFile>* r,
+                           const EnvOptions& options) override {
+    return target_->ReuseWritableFile(fname, old_fname, r, options);
+  }
   virtual Status NewDirectory(const std::string& name,
                               unique_ptr<Directory>* result) override {
     return target_->NewDirectory(name, result);
@@ -901,10 +927,10 @@ class WritableFileWrapper : public WritableFile {
   }
 
  protected:
-  Status Allocate(off_t offset, off_t len) override {
+  Status Allocate(uint64_t offset, uint64_t len) override {
     return target_->Allocate(offset, len);
   }
-  Status RangeSync(off_t offset, off_t nbytes) override {
+  Status RangeSync(uint64_t offset, uint64_t nbytes) override {
     return target_->RangeSync(offset, nbytes);
   }
 
diff --git a/src/rocksdb/include/rocksdb/iterator.h b/src/rocksdb/include/rocksdb/iterator.h
index 7538e9c..1e7600d 100644
--- a/src/rocksdb/include/rocksdb/iterator.h
+++ b/src/rocksdb/include/rocksdb/iterator.h
@@ -24,10 +24,32 @@
 
 namespace rocksdb {
 
-class Iterator {
+class Cleanable {
  public:
-  Iterator();
-  virtual ~Iterator();
+  Cleanable();
+  ~Cleanable();
+  // Clients are allowed to register function/arg1/arg2 triples that
+  // will be invoked when this iterator is destroyed.
+  //
+  // Note that unlike all of the preceding methods, this method is
+  // not abstract and therefore clients should not override it.
+  typedef void (*CleanupFunction)(void* arg1, void* arg2);
+  void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
+
+ protected:
+  struct Cleanup {
+    CleanupFunction function;
+    void* arg1;
+    void* arg2;
+    Cleanup* next;
+  };
+  Cleanup cleanup_;
+};
+
+class Iterator : public Cleanable {
+ public:
+  Iterator() {}
+  virtual ~Iterator() {}
 
   // An iterator is either positioned at a key/value pair, or
   // not valid.  This method returns true iff the iterator is valid.
@@ -73,23 +95,7 @@ class Iterator {
   // satisfied without doing some IO, then this returns Status::Incomplete().
   virtual Status status() const = 0;
 
-  // Clients are allowed to register function/arg1/arg2 triples that
-  // will be invoked when this iterator is destroyed.
-  //
-  // Note that unlike all of the preceding methods, this method is
-  // not abstract and therefore clients should not override it.
-  typedef void (*CleanupFunction)(void* arg1, void* arg2);
-  void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
-
  private:
-  struct Cleanup {
-    CleanupFunction function;
-    void* arg1;
-    void* arg2;
-    Cleanup* next;
-  };
-  Cleanup cleanup_;
-
   // No copying allowed
   Iterator(const Iterator&);
   void operator=(const Iterator&);
diff --git a/src/rocksdb/include/rocksdb/listener.h b/src/rocksdb/include/rocksdb/listener.h
index f693d5c..aa19307 100644
--- a/src/rocksdb/include/rocksdb/listener.h
+++ b/src/rocksdb/include/rocksdb/listener.h
@@ -4,7 +4,9 @@
 
 #pragma once
 
+#include <memory>
 #include <string>
+#include <unordered_map>
 #include <vector>
 #include "rocksdb/compaction_job_stats.h"
 #include "rocksdb/status.h"
@@ -12,6 +14,9 @@
 
 namespace rocksdb {
 
+typedef std::unordered_map<std::string, std::shared_ptr<const TableProperties>>
+    TablePropertiesCollection;
+
 class DB;
 class Status;
 struct CompactionJobStats;
@@ -45,7 +50,7 @@ struct TableFileDeletionInfo {
   std::string file_path;
   // The id of the job which deleted the file.
   int job_id;
-  // The status indicating whether the deletion was successfull or not.
+  // The status indicating whether the deletion was successful or not.
   Status status;
 };
 
@@ -72,6 +77,8 @@ struct FlushJobInfo {
   SequenceNumber smallest_seqno;
   // The largest sequence number in the newly created file
   SequenceNumber largest_seqno;
+  // Table properties of the table being flushed
+  TableProperties table_properties;
 };
 
 struct CompactionJobInfo {
@@ -93,8 +100,13 @@ struct CompactionJobInfo {
   int output_level;
   // the names of the compaction input files.
   std::vector<std::string> input_files;
+
   // the names of the compaction output files.
   std::vector<std::string> output_files;
+  // Table properties for input and output tables.
+  // The map is keyed by values from input_files and output_files.
+  TablePropertiesCollection table_properties;
+
   // If non-null, this variable stores detailed information
   // about this compaction.
   CompactionJobStats stats;
@@ -138,8 +150,8 @@ class EventListener {
   // Note that the this function must be implemented in a way such that
   // it should not run for an extended period of time before the function
   // returns.  Otherwise, RocksDB may be blocked.
-  virtual void OnFlushCompleted(
-      DB* db, const FlushJobInfo& flush_job_info) {}
+  virtual void OnFlushCompleted(DB* /*db*/,
+                                const FlushJobInfo& /*flush_job_info*/) {}
 
   // A call-back function for RocksDB which will be called whenever
   // a SST file is deleted.  Different from OnCompactionCompleted and
@@ -152,8 +164,7 @@ class EventListener {
   // Note that if applications would like to use the passed reference
   // outside this function call, they should make copies from the
   // returned value.
-  virtual void OnTableFileDeleted(
-      const TableFileDeletionInfo& info) {}
+  virtual void OnTableFileDeleted(const TableFileDeletionInfo& /*info*/) {}
 
   // A call-back function for RocksDB which will be called whenever
   // a registered RocksDB compacts a file. The default implementation
@@ -168,7 +179,8 @@ class EventListener {
   // @param ci a reference to a CompactionJobInfo struct. 'ci' is released
   //  after this function is returned, and must be copied if it is needed
   //  outside of this function.
-  virtual void OnCompactionCompleted(DB *db, const CompactionJobInfo& ci) {}
+  virtual void OnCompactionCompleted(DB* /*db*/,
+                                     const CompactionJobInfo& /*ci*/) {}
 
   // A call-back function for RocksDB which will be called whenever
   // a SST file is created.  Different from OnCompactionCompleted and
@@ -181,8 +193,7 @@ class EventListener {
   // Note that if applications would like to use the passed reference
   // outside this function call, they should make copies from these
   // returned value.
-  virtual void OnTableFileCreated(
-      const TableFileCreationInfo& info) {}
+  virtual void OnTableFileCreated(const TableFileCreationInfo& /*info*/) {}
 
   virtual ~EventListener() {}
 };
diff --git a/src/rocksdb/include/rocksdb/options.h b/src/rocksdb/include/rocksdb/options.h
index 16aa378..5ec1da7 100644
--- a/src/rocksdb/include/rocksdb/options.h
+++ b/src/rocksdb/include/rocksdb/options.h
@@ -46,6 +46,7 @@ class Slice;
 class SliceTransform;
 class Statistics;
 class InternalKeyComparator;
+class WalFilter;
 
 // DB contents are stored in a set of blocks, each of which holds a
 // sequence of key,value pairs.  Each block may be compressed before
@@ -81,9 +82,14 @@ enum CompactionStyle : char {
 
 enum CompactionPri : char {
   // Slightly Priotize larger files by size compensated by #deletes
-  kCompactionPriByCompensatedSize = 0x0,
-  // First compact files whose data is oldest.
-  kCompactionPriByLargestSeq = 0x1,
+  kByCompensatedSize = 0x0,
+  // First compact files whose data's latest update time is oldest.
+  // Try this if you only update some hot keys in small ranges.
+  kOldestLargestSeqFirst = 0x1,
+  // First compact files whose range hasn't been compacted to the next level
+  // for the longest. If your updates are random across the key space,
+  // write amplification is slightly better with this option.
+  kOldestSmallestSeqFirst = 0x2,
 };
 
 enum class WALRecoveryMode : char {
@@ -499,6 +505,7 @@ struct ColumnFamilyOptions {
   // Dynamically changeable through SetOptions() API
   int max_grandparent_overlap_factor;
 
+  // DEPRECATED -- this options is no longer used
   // Puts are delayed to options.delayed_write_rate when any level has a
   // compaction score that exceeds soft_rate_limit. This is ignored when == 0.0.
   //
@@ -507,9 +514,15 @@ struct ColumnFamilyOptions {
   // Dynamically changeable through SetOptions() API
   double soft_rate_limit;
 
-  // DEPRECATED -- this options is no longer usde
+  // DEPRECATED -- this options is no longer used
   double hard_rate_limit;
 
+  // All writes will be slowed down to at least delayed_write_rate if estimated
+  // bytes needed to be compaction exceed this threshold.
+  //
+  // Default: 0 (disabled)
+  uint64_t soft_pending_compaction_bytes_limit;
+
   // All writes are stopped if estimated bytes needed to be compaction exceed
   // this threshold.
   //
@@ -523,7 +536,7 @@ struct ColumnFamilyOptions {
   // If <= 0, a proper value is automatically calculated (usually 1/8 of
   // writer_buffer_size, rounded up to a multiple of 4KB).
   //
-  // There are two additonal restriction of the The specified size:
+  // There are two additional restriction of the The specified size:
   // (1) size should be in the range of [4096, 2 << 30] and
   // (2) be the multiple of the CPU word (which helps with the memory
   // alignment).
@@ -880,7 +893,7 @@ struct DBOptions {
   // If none of the paths has sufficient room to place a file, the file will
   // be placed to the last path anyway, despite to the target size.
   //
-  // Placing newer data to ealier paths is also best-efforts. User should
+  // Placing newer data to earlier paths is also best-efforts. User should
   // expect user files to be placed in higher levels in some extreme cases.
   //
   // If left empty, only one path will be used, which is db_name passed when
@@ -957,6 +970,16 @@ struct DBOptions {
   // Default: 1000
   size_t keep_log_file_num;
 
+  // Recycle log files.
+  // If non-zero, we will reuse previously written log files for new
+  // logs, overwriting the old data.  The value indicates how many
+  // such files we will keep around at any point in time for later
+  // use.  This is more efficient because the blocks are already
+  // allocated and fdatasync does not need to update the inode after
+  // each write.
+  // Default: 0
+  size_t recycle_log_file_num;
+
   // manifest file is rolled over on reaching this limit.
   // The older manifest file be deleted.
   // The default value is MAX_INT so that roll-over does not take place.
@@ -1064,6 +1087,28 @@ struct DBOptions {
   // Default: 0
   size_t compaction_readahead_size;
 
+  // This is a maximum buffer size that is used by WinMmapReadableFile in
+  // unbuffered disk I/O mode. We need to maintain an aligned buffer for
+  // reads. We allow the buffer to grow until the specified value and then
+  // for bigger requests allocate one shot buffers. In unbuffered mode we
+  // always bypass read-ahead buffer at ReadaheadRandomAccessFile
+  // When read-ahead is required we then make use of compaction_readahead_size
+  // value and always try to read ahead. With read-ahead we always
+  // pre-allocate buffer to the size instead of growing it up to a limit.
+  //
+  // This option is currently honored only on Windows
+  //
+  // Default: 1 Mb
+  size_t random_access_max_buffer_size;
+
+  // This is the maximum buffer size that is used by WritableFileWriter.
+  // On Windows, we need to maintain an aligned buffer for writes.
+  // We allow the buffer to grow until it's size hits the limit.
+  //
+  // Default: 1024 * 1024 (1 MB)
+  size_t writable_file_max_buffer_size;
+
+
   // Use adaptive mutex, which spins in the user space before resorting
   // to kernel. This could reduce context switch when the mutex is not
   // heavily contended. However, if the mutex is hot, we could end up
@@ -1130,6 +1175,22 @@ struct DBOptions {
   // Default: nullptr (disabled)
   // Not supported in ROCKSDB_LITE mode!
   std::shared_ptr<Cache> row_cache;
+
+#ifndef ROCKSDB_LITE
+  // A filter object supplied to be invoked while processing write-ahead-logs
+  // (WALs) during recovery. The filter provides a way to inspect log
+  // records, ignoring a particular record or skipping replay.
+  // The filter is invoked at startup and is invoked from a single-thread
+  // currently.
+  const WalFilter* wal_filter;
+#endif  // ROCKSDB_LITE
+
+  // If true, then DB::Open / CreateColumnFamily / DropColumnFamily
+  // / SetOptions will fail if options file is not detected or properly
+  // persisted.
+  //
+  // DEFAULT: false
+  bool fail_if_options_file_error;
 };
 
 // Options to control the behavior of a database (passed to DB::Open)
@@ -1248,6 +1309,14 @@ struct ReadOptions {
   // this option.
   bool total_order_seek;
 
+  // Enforce that the iterator only iterates over the same prefix as the seek.
+  // This option is effective only for prefix seeks, i.e. prefix_extractor is
+  // non-null for the column family and total_order_seek is false.  Unlike
+  // iterate_upper_bound, prefix_same_as_start only works within a prefix
+  // but in both directions.
+  // Default: false
+  bool prefix_same_as_start;
+
   ReadOptions();
   ReadOptions(bool cksum, bool cache);
 };
@@ -1312,6 +1381,11 @@ extern Options GetOptions(size_t total_write_buffer_limit,
                           int write_amplification_threshold = 32,
                           uint64_t target_db_size = 68719476736 /* 64GB */);
 
+// Create a Logger from provided DBOptions
+extern Status CreateLoggerFromOptions(const std::string& dbname,
+                                      const DBOptions& options,
+                                      std::shared_ptr<Logger>* logger);
+
 // CompactionOptions are used in CompactFiles() call.
 struct CompactionOptions {
   // Compaction output compression type
diff --git a/src/rocksdb/include/rocksdb/perf_context.h b/src/rocksdb/include/rocksdb/perf_context.h
index a7c993c..c2af729 100644
--- a/src/rocksdb/include/rocksdb/perf_context.h
+++ b/src/rocksdb/include/rocksdb/perf_context.h
@@ -27,42 +27,42 @@ struct PerfContext {
   uint64_t block_cache_hit_count;     // total number of block cache hits
   uint64_t block_read_count;          // total number of block reads (with IO)
   uint64_t block_read_byte;           // total number of bytes from block reads
-  uint64_t block_read_time;           // total time spent on block reads
-  uint64_t block_checksum_time;       // total time spent on block checksum
-  uint64_t block_decompress_time;     // total time spent on block decompression
+  uint64_t block_read_time;           // total nanos spent on block reads
+  uint64_t block_checksum_time;       // total nanos spent on block checksum
+  uint64_t block_decompress_time;  // total nanos spent on block decompression
   // total number of internal keys skipped over during iteration (overwritten or
   // deleted, to be more specific, hidden by a put or delete of the same key)
   uint64_t internal_key_skipped_count;
   // total number of deletes and single deletes skipped over during iteration
   uint64_t internal_delete_skipped_count;
 
-  uint64_t get_snapshot_time;          // total time spent on getting snapshot
-  uint64_t get_from_memtable_time;     // total time spent on querying memtables
+  uint64_t get_snapshot_time;       // total nanos spent on getting snapshot
+  uint64_t get_from_memtable_time;  // total nanos spent on querying memtables
   uint64_t get_from_memtable_count;    // number of mem tables queried
-  // total time spent after Get() finds a key
+  // total nanos spent after Get() finds a key
   uint64_t get_post_process_time;
-  uint64_t get_from_output_files_time; // total time reading from output files
-  // total time spent on seeking memtable
+  uint64_t get_from_output_files_time;  // total nanos reading from output files
+  // total nanos spent on seeking memtable
   uint64_t seek_on_memtable_time;
   // number of seeks issued on memtable
   uint64_t seek_on_memtable_count;
-  // total time spent on seeking child iters
+  // total nanos spent on seeking child iters
   uint64_t seek_child_seek_time;
   // number of seek issued in child iterators
   uint64_t seek_child_seek_count;
-  uint64_t seek_min_heap_time;         // total time spent on the merge heap
-  // total time spent on seeking the internal entries
+  uint64_t seek_min_heap_time;  // total nanos spent on the merge heap
+  // total nanos spent on seeking the internal entries
   uint64_t seek_internal_seek_time;
-  // total time spent on iterating internal entries to find the next user entry
+  // total nanos spent on iterating internal entries to find the next user entry
   uint64_t find_next_user_entry_time;
 
-  // total time spent on writing to WAL
+  // total nanos spent on writing to WAL
   uint64_t write_wal_time;
-  // total time spent on writing to mem tables
+  // total nanos spent on writing to mem tables
   uint64_t write_memtable_time;
-  // total time spent on delaying write
+  // total nanos spent on delaying write
   uint64_t write_delay_time;
-  // total time spent on writing a record, excluding the above three times
+  // total nanos spent on writing a record, excluding the above three times
   uint64_t write_pre_and_post_process_time;
 
   uint64_t db_mutex_lock_nanos;      // time spent on acquiring DB mutex.
diff --git a/src/rocksdb/include/rocksdb/slice.h b/src/rocksdb/include/rocksdb/slice.h
index ae3139c..3d39f3a 100644
--- a/src/rocksdb/include/rocksdb/slice.h
+++ b/src/rocksdb/include/rocksdb/slice.h
@@ -73,6 +73,11 @@ class Slice {
     size_ -= n;
   }
 
+  void remove_suffix(size_t n) {
+    assert(n <= size());
+    size_ -= n;
+  }
+
   // Return a string that contains the copy of the referenced data.
   std::string ToString(bool hex = false) const;
 
@@ -88,6 +93,11 @@ class Slice {
             (memcmp(data_, x.data_, x.size_) == 0));
   }
 
+  bool ends_with(const Slice& x) const {
+    return ((size_ >= x.size_) &&
+            (memcmp(data_ + size_ - x.size_, x.data_, x.size_) == 0));
+  }
+
   // Compare two slices and returns the first byte where they differ
   size_t difference_offset(const Slice& b) const;
 
diff --git a/src/rocksdb/include/rocksdb/snapshot.h b/src/rocksdb/include/rocksdb/snapshot.h
index aad675b..95822d2 100644
--- a/src/rocksdb/include/rocksdb/snapshot.h
+++ b/src/rocksdb/include/rocksdb/snapshot.h
@@ -33,6 +33,9 @@ class ManagedSnapshot {
  public:
   explicit ManagedSnapshot(DB* db);
 
+  // Instead of creating a snapshot, take ownership of the input snapshot.
+  ManagedSnapshot(DB* db, const Snapshot* _snapshot);
+
   ~ManagedSnapshot();
 
   const Snapshot* snapshot();
diff --git a/src/rocksdb/include/rocksdb/status.h b/src/rocksdb/include/rocksdb/status.h
index e8e7970..f3f652a 100644
--- a/src/rocksdb/include/rocksdb/status.h
+++ b/src/rocksdb/include/rocksdb/status.h
@@ -48,7 +48,7 @@ class Status {
     kAborted = 10,
     kBusy = 11,
     kExpired = 12,
-    kTryAgain = 13
+    kTryAgain = 13,
   };
 
   Code code() const { return code_; }
diff --git a/src/rocksdb/include/rocksdb/table.h b/src/rocksdb/include/rocksdb/table.h
index e52b580..eafcbae 100644
--- a/src/rocksdb/include/rocksdb/table.h
+++ b/src/rocksdb/include/rocksdb/table.h
@@ -128,6 +128,20 @@ struct BlockBasedTableOptions {
   // This must generally be true for gets to be efficient.
   bool whole_key_filtering = true;
 
+  // If true, block will not be explicitly flushed to disk during building
+  // a SstTable. Instead, buffer in WritableFileWriter will take
+  // care of the flushing when it is full.
+  //
+  // On Windows, this option helps a lot when unbuffered I/O
+  // (allow_os_buffer = false) is used, since it avoids small
+  // unbuffered disk write.
+  //
+  // User may also adjust writable_file_max_buffer_size to optimize disk I/O
+  // size.
+  //
+  // Default: false
+  bool skip_table_builder_flush = false;
+
   // We currently have three versions:
   // 0 -- This version is currently written out by all RocksDB's versions by
   // default.  Can be read by really old RocksDB's. Doesn't support changing
@@ -375,7 +389,7 @@ class TableFactory {
   // to use in this table.
   virtual TableBuilder* NewTableBuilder(
       const TableBuilderOptions& table_builder_options,
-      WritableFileWriter* file) const = 0;
+      uint32_t column_family_id, WritableFileWriter* file) const = 0;
 
   // Sanitizes the specified DB Options and ColumnFamilyOptions.
   //
@@ -388,6 +402,22 @@ class TableFactory {
   // Return a string that contains printable format of table configurations.
   // RocksDB prints configurations at DB Open().
   virtual std::string GetPrintableTableOptions() const = 0;
+
+  // Returns the raw pointer of the table options that is used by this
+  // TableFactory, or nullptr if this function is not supported.
+  // Since the return value is a raw pointer, the TableFactory owns the
+  // pointer and the caller should not delete the pointer.
+  //
+  // In certan case, it is desirable to alter the underlying options when the
+  // TableFactory is not used by any open DB by casting the returned pointer
+  // to the right class.   For instance, if BlockBasedTableFactory is used,
+  // then the pointer can be casted to BlockBasedTableOptions.
+  //
+  // Note that changing the underlying TableFactory options while the
+  // TableFactory is currently used by any open DB is undefined behavior.
+  // Developers should use DB::SetOption() instead to dynamically change
+  // options while the DB is open.
+  virtual void* GetOptions() { return nullptr; }
 };
 
 #ifndef ROCKSDB_LITE
diff --git a/src/rocksdb/include/rocksdb/table_properties.h b/src/rocksdb/include/rocksdb/table_properties.h
index 2850074..73a825d 100644
--- a/src/rocksdb/include/rocksdb/table_properties.h
+++ b/src/rocksdb/include/rocksdb/table_properties.h
@@ -56,6 +56,7 @@ struct TableProperties {
 
   // user collected properties
   UserCollectedProperties user_collected_properties;
+  UserCollectedProperties readable_properties;
 
   // convert this object to a human readable form
   //   @prop_delim: delimiter for each property.
@@ -106,7 +107,7 @@ class TablePropertiesCollector {
   // Add() will be called when a new key/value pair is inserted into the table.
   // @params key    the user key that is inserted into the table.
   // @params value  the value that is inserted into the table.
-  virtual Status Add(const Slice& key, const Slice& value) {
+  virtual Status Add(const Slice& /*key*/, const Slice& /*value*/) {
     return Status::InvalidArgument(
         "TablePropertiesCollector::Add() deprecated.");
   }
@@ -115,10 +116,9 @@ class TablePropertiesCollector {
   // table.
   // @params key    the user key that is inserted into the table.
   // @params value  the value that is inserted into the table.
-  // @params file_size  file size up to now
   virtual Status AddUserKey(const Slice& key, const Slice& value,
-                            EntryType type, SequenceNumber seq,
-                            uint64_t file_size) {
+                            EntryType /*type*/, SequenceNumber /*seq*/,
+                            uint64_t /*file_size*/) {
     // For backwards-compatibility.
     return Add(key, value);
   }
@@ -144,9 +144,15 @@ class TablePropertiesCollector {
 // TablePropertiesCollector for each new table
 class TablePropertiesCollectorFactory {
  public:
+  struct Context {
+    uint32_t column_family_id;
+    static const uint32_t kUnknownColumnFamily;
+  };
+
   virtual ~TablePropertiesCollectorFactory() {}
   // has to be thread-safe
-  virtual TablePropertiesCollector* CreateTablePropertiesCollector() = 0;
+  virtual TablePropertiesCollector* CreateTablePropertiesCollector(
+      TablePropertiesCollectorFactory::Context context) = 0;
 
   // The name of the properties collector can be used for debugging purpose.
   virtual const char* Name() const = 0;
diff --git a/src/rocksdb/include/rocksdb/utilities/backupable_db.h b/src/rocksdb/include/rocksdb/utilities/backupable_db.h
index 5c32750..f5f394c 100644
--- a/src/rocksdb/include/rocksdb/utilities/backupable_db.h
+++ b/src/rocksdb/include/rocksdb/utilities/backupable_db.h
@@ -88,6 +88,14 @@ struct BackupableDBOptions {
   // *turn it on only if you know what you're doing*
   bool share_files_with_checksum;
 
+  // Try to use the file size in file name instead of getting size from HDFS,
+  // if the file is generated with options.share_files_with_checksum = true.
+  // This is a temporary solution to reduce the backupable Db open latency when
+  // There are too many sst files. Will remove the option after we have a
+  // permanent solution.
+  // Default: false
+  bool use_file_size_in_file_name;
+
   // Up to this many background threads will copy files for CreateNewBackup()
   // and RestoreDBFromBackup()
   // Default: 1
@@ -117,6 +125,7 @@ struct BackupableDBOptions {
         backup_rate_limit(_backup_rate_limit),
         restore_rate_limit(_restore_rate_limit),
         share_files_with_checksum(false),
+        use_file_size_in_file_name(false),
         max_background_operations(_max_background_operations),
         callback_trigger_interval_size(_callback_trigger_interval_size) {
     assert(share_table_files || !share_files_with_checksum);
diff --git a/src/rocksdb/include/rocksdb/utilities/env_mirror.h b/src/rocksdb/include/rocksdb/utilities/env_mirror.h
new file mode 100644
index 0000000..021fbfa
--- /dev/null
+++ b/src/rocksdb/include/rocksdb/utilities/env_mirror.h
@@ -0,0 +1,166 @@
+// Copyright (c) 2015, Red Hat, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+//
+// MirrorEnv is an Env implementation that mirrors all file-related
+// operations to two backing Env's (provided at construction time).
+// Writes are mirrored.  For read operations, we do the read from both
+// backends and assert that the results match.
+//
+// This is useful when implementing a new Env and ensuring that the
+// semantics and behavior are correct (in that they match that of an
+// existing, stable Env, like the default POSIX one).
+
+#ifndef ROCKSDB_LITE
+
+#ifndef STORAGE_ROCKSDB_INCLUDE_UTILITIES_ENVMIRROR_H_
+#define STORAGE_ROCKSDB_INCLUDE_UTLIITIES_ENVMIRROR_H_
+
+#include <iostream>
+#include <algorithm>
+#include <vector>
+#include "rocksdb/env.h"
+
+namespace rocksdb {
+
+class SequentialFileMirror;
+class RandomAccessFileMirror;
+class WritableFileMirror;
+
+class EnvMirror : public EnvWrapper {
+  Env* a_, *b_;
+
+ public:
+  EnvMirror(Env* a, Env* b) : EnvWrapper(a), a_(a), b_(b) {}
+
+  Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
+                           const EnvOptions& options) override;
+  Status NewRandomAccessFile(const std::string& f,
+                             unique_ptr<RandomAccessFile>* r,
+                             const EnvOptions& options) override;
+  Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
+                         const EnvOptions& options) override;
+  Status ReuseWritableFile(const std::string& fname,
+                           const std::string& old_fname,
+                           unique_ptr<WritableFile>* r,
+                           const EnvOptions& options) override;
+  virtual Status NewDirectory(const std::string& name,
+                              unique_ptr<Directory>* result) override {
+    unique_ptr<Directory> br;
+    Status as = a_->NewDirectory(name, result);
+    Status bs = b_->NewDirectory(name, &br);
+    assert(as == bs);
+    return as;
+  }
+  Status FileExists(const std::string& f) override {
+    Status as = a_->FileExists(f);
+    Status bs = b_->FileExists(f);
+    assert(as == bs);
+    return as;
+  }
+  Status GetChildren(const std::string& dir,
+                     std::vector<std::string>* r) override {
+    std::vector<std::string> ar, br;
+    Status as = a_->GetChildren(dir, &ar);
+    Status bs = b_->GetChildren(dir, &br);
+    assert(as == bs);
+    std::sort(ar.begin(), ar.end());
+    std::sort(br.begin(), br.end());
+    if (!as.ok() || ar != br) {
+      assert(0 == "getchildren results don't match");
+    }
+    *r = ar;
+    return as;
+  }
+  Status DeleteFile(const std::string& f) override {
+    Status as = a_->DeleteFile(f);
+    Status bs = b_->DeleteFile(f);
+    assert(as == bs);
+    return as;
+  }
+  Status CreateDir(const std::string& d) override {
+    Status as = a_->CreateDir(d);
+    Status bs = b_->CreateDir(d);
+    assert(as == bs);
+    return as;
+  }
+  Status CreateDirIfMissing(const std::string& d) override {
+    Status as = a_->CreateDirIfMissing(d);
+    Status bs = b_->CreateDirIfMissing(d);
+    assert(as == bs);
+    return as;
+  }
+  Status DeleteDir(const std::string& d) override {
+    Status as = a_->DeleteDir(d);
+    Status bs = b_->DeleteDir(d);
+    assert(as == bs);
+    return as;
+  }
+  Status GetFileSize(const std::string& f, uint64_t* s) override {
+    uint64_t asize, bsize;
+    Status as = a_->GetFileSize(f, &asize);
+    Status bs = b_->GetFileSize(f, &bsize);
+    assert(as == bs);
+    assert(!as.ok() || asize == bsize);
+    *s = asize;
+    return as;
+  }
+
+  Status GetFileModificationTime(const std::string& fname,
+                                 uint64_t* file_mtime) override {
+    uint64_t amtime, bmtime;
+    Status as = a_->GetFileModificationTime(fname, &amtime);
+    Status bs = b_->GetFileModificationTime(fname, &bmtime);
+    assert(as == bs);
+    assert(!as.ok() || amtime - bmtime < 10000 || bmtime - amtime < 10000);
+    *file_mtime = amtime;
+    return as;
+  }
+
+  Status RenameFile(const std::string& s, const std::string& t) override {
+    Status as = a_->RenameFile(s, t);
+    Status bs = b_->RenameFile(s, t);
+    assert(as == bs);
+    return as;
+  }
+
+  Status LinkFile(const std::string& s, const std::string& t) override {
+    Status as = a_->LinkFile(s, t);
+    Status bs = b_->LinkFile(s, t);
+    assert(as == bs);
+    return as;
+  }
+
+  class FileLockMirror : public FileLock {
+   public:
+    FileLock* a_, *b_;
+    FileLockMirror(FileLock* a, FileLock* b) : a_(a), b_(b) {}
+  };
+
+  Status LockFile(const std::string& f, FileLock** l) override {
+    FileLock* al, *bl;
+    Status as = a_->LockFile(f, &al);
+    Status bs = b_->LockFile(f, &bl);
+    assert(as == bs);
+    if (as.ok()) *l = new FileLockMirror(al, bl);
+    return as;
+  }
+
+  Status UnlockFile(FileLock* l) override {
+    FileLockMirror* ml = static_cast<FileLockMirror*>(l);
+    Status as = a_->UnlockFile(ml->a_);
+    Status bs = b_->UnlockFile(ml->b_);
+    assert(as == bs);
+    return as;
+  }
+};
+
+}  // namespace rocksdb
+
+#endif  // STORAGE_ROCKSDB_INCLUDE_UTILITIES_ENVMIRROR_H_
+
+#endif  // ROCKSDB_LITE
diff --git a/src/rocksdb/include/rocksdb/utilities/geo_db.h b/src/rocksdb/include/rocksdb/utilities/geo_db.h
index 41c0f14..d603c57 100644
--- a/src/rocksdb/include/rocksdb/utilities/geo_db.h
+++ b/src/rocksdb/include/rocksdb/utilities/geo_db.h
@@ -59,6 +59,16 @@ class GeoObject {
   }
 };
 
+class GeoIterator {
+ public:
+  GeoIterator() = default;
+  virtual ~GeoIterator() {}
+  virtual void Next() = 0;
+  virtual bool Valid() const = 0;
+  virtual const GeoObject& geo_object() = 0;
+  virtual Status status() const = 0;
+};
+
 //
 // Stack your DB with GeoDB to be able to get geo-spatial support
 //
@@ -91,14 +101,13 @@ class GeoDB : public StackableDB {
   // Delete the specified object
   virtual Status Remove(const Slice& id) = 0;
 
-  // Returns a list of all items within a circular radius from the
+  // Returns an iterator for the items within a circular radius from the
   // specified gps location. If 'number_of_values' is specified,
-  // then this call returns at most that many number of objects.
+  // then the iterator is capped to that number of objects.
   // The radius is specified in 'meters'.
-  virtual Status SearchRadial(const GeoPosition& pos,
-                              double radius,
-                              std::vector<GeoObject>* values,
-                              int number_of_values = INT_MAX) = 0;
+  virtual GeoIterator* SearchRadial(const GeoPosition& pos,
+                                    double radius,
+                                    int number_of_values = INT_MAX) = 0;
 };
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/include/rocksdb/utilities/memory_util.h b/src/rocksdb/include/rocksdb/utilities/memory_util.h
new file mode 100644
index 0000000..323a8a1
--- /dev/null
+++ b/src/rocksdb/include/rocksdb/utilities/memory_util.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+
+#pragma once
+
+#include <map>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include "rocksdb/cache.h"
+#include "rocksdb/db.h"
+
+namespace rocksdb {
+
+// Returns the current memory usage of the specified DB instances.
+class MemoryUtil {
+ public:
+  enum UsageType : int {
+    // Memory usage of all the mem-tables.
+    kMemTableTotal = 0,
+    // Memory usage of those un-flushed mem-tables.
+    kMemTableUnFlushed = 1,
+    // Memory usage of all the table readers.
+    kTableReadersTotal = 2,
+    // Memory usage by Cache.
+    kCacheTotal = 3,
+    kNumUsageTypes = 4
+  };
+
+  // Returns the approximate memory usage of different types in the input
+  // list of DBs and Cache set.  For instance, in the output map
+  // usage_by_type, usage_by_type[kMemTableTotal] will store the memory
+  // usage of all the mem-tables from all the input rocksdb instances.
+  //
+  // Note that for memory usage inside Cache class, we will
+  // only report the usage of the input "cache_set" without
+  // including those Cache usage inside the input list "dbs"
+  // of DBs.
+  static Status GetApproximateMemoryUsageByType(
+      const std::vector<DB*>& dbs,
+      const std::unordered_set<const Cache*> cache_set,
+      std::map<MemoryUtil::UsageType, uint64_t>* usage_by_type);
+};
+}  // namespace rocksdb
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/include/rocksdb/utilities/options_util.h b/src/rocksdb/include/rocksdb/utilities/options_util.h
new file mode 100644
index 0000000..a2c09fe
--- /dev/null
+++ b/src/rocksdb/include/rocksdb/utilities/options_util.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2015, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+// This file contains utility functions for RocksDB Options.
+#pragma once
+
+#ifndef ROCKSDB_LITE
+
+#include <string>
+#include <vector>
+
+#include "rocksdb/db.h"
+#include "rocksdb/env.h"
+#include "rocksdb/options.h"
+#include "rocksdb/status.h"
+
+namespace rocksdb {
+// Constructs the DBOptions and ColumnFamilyDescriptors by loading the
+// latest RocksDB options file stored in the specified rocksdb database.
+//
+// Note that the all the pointer options (except table_factory, which will
+// be described in more details below) will be initialized with the default
+// values.  Developers can further initialize them after this function call.
+// Below is an example list of pointer options which will be initialized
+//
+// * env
+// * memtable_factory
+// * compaction_filter_factory
+// * prefix_extractor
+// * comparator
+// * merge_operator
+// * compaction_filter
+//
+// For table_factory, this function further supports deserializing
+// BlockBasedTableFactory and its BlockBasedTableOptions except the
+// pointer options of BlockBasedTableOptions (flush_block_policy_factory,
+// block_cache, and block_cache_compressed), which will be initialized with
+// default values.  Developers can further specify these three options by
+// casting the return value of TableFactoroy::GetOptions() to
+// BlockBasedTableOptions and making necessary changes.
+//
+// examples/options_file_example.cc demonstrates how to use this function
+// to open a RocksDB instance.
+//
+// @see LoadOptionsFromFile
+Status LoadLatestOptions(const std::string& dbpath, Env* env,
+                         DBOptions* db_options,
+                         std::vector<ColumnFamilyDescriptor>* cf_descs);
+
+// Similar to LoadLatestOptions, this function constructs the DBOptions
+// and ColumnFamilyDescriptors based on the specified RocksDB Options file.
+//
+// @see LoadLatestOptions
+Status LoadOptionsFromFile(const std::string& options_file_name, Env* env,
+                           DBOptions* db_options,
+                           std::vector<ColumnFamilyDescriptor>* cf_descs);
+
+// Returns the latest options file name under the specified db path.
+Status GetLatestOptionsFileName(const std::string& dbpath, Env* env,
+                                std::string* options_file_name);
+
+// Returns Status::OK if the input DBOptions and ColumnFamilyDescriptors
+// are compatible with the latest options stored in the specified DB path.
+//
+// If the return status is non-ok, it means the specified RocksDB instance
+// might not be correctly opened with the input set of options.  Currently,
+// changing one of the following options will fail the compatibility check:
+//
+// * comparator
+// * prefix_extractor
+// * table_factory
+// * merge_operator
+Status CheckOptionsCompatibility(
+    const std::string& dbpath, Env* env, const DBOptions& db_options,
+    const std::vector<ColumnFamilyDescriptor>& cf_descs);
+
+}  // namespace rocksdb
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/include/rocksdb/utilities/stackable_db.h b/src/rocksdb/include/rocksdb/utilities/stackable_db.h
index aef192b..542f6c6 100644
--- a/src/rocksdb/include/rocksdb/utilities/stackable_db.h
+++ b/src/rocksdb/include/rocksdb/utilities/stackable_db.h
@@ -144,11 +144,18 @@ class StackableDB : public DB {
     return db_->GetIntProperty(column_family, property, value);
   }
 
+  using DB::GetAggregatedIntProperty;
+  virtual bool GetAggregatedIntProperty(const Slice& property,
+                                        uint64_t* value) override {
+    return db_->GetAggregatedIntProperty(property, value);
+  }
+
   using DB::GetApproximateSizes;
   virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
                                    const Range* r, int n, uint64_t* sizes,
                                    bool include_memtable = false) override {
-      return db_->GetApproximateSizes(column_family, r, n, sizes);
+    return db_->GetApproximateSizes(column_family, r, n, sizes,
+                                    include_memtable);
   }
 
   using DB::CompactRange;
@@ -176,6 +183,11 @@ class StackableDB : public DB {
     return db_->ContinueBackgroundWork();
   }
 
+  virtual Status EnableAutoCompaction(
+      const std::vector<ColumnFamilyHandle*>& column_family_handles) override {
+    return db_->EnableAutoCompaction(column_family_handles);
+  }
+
   using DB::NumberLevels;
   virtual int NumberLevels(ColumnFamilyHandle* column_family) override {
     return db_->NumberLevels(column_family);
@@ -267,9 +279,10 @@ class StackableDB : public DB {
   }
 
   using DB::SetOptions;
-  virtual Status SetOptions(
-    const std::unordered_map<std::string, std::string>& new_options) override {
-    return db_->SetOptions(new_options);
+  virtual Status SetOptions(ColumnFamilyHandle* column_family_handle,
+                            const std::unordered_map<std::string, std::string>&
+                                new_options) override {
+    return db_->SetOptions(column_family_handle, new_options);
   }
 
   using DB::GetPropertiesOfAllTables;
@@ -279,6 +292,13 @@ class StackableDB : public DB {
     return db_->GetPropertiesOfAllTables(column_family, props);
   }
 
+  using DB::GetPropertiesOfTablesInRange;
+  virtual Status GetPropertiesOfTablesInRange(
+      ColumnFamilyHandle* column_family, const Range* range, std::size_t n,
+      TablePropertiesCollection* props) override {
+    return db_->GetPropertiesOfTablesInRange(column_family, range, n, props);
+  }
+
   virtual Status GetUpdatesSince(
       SequenceNumber seq_number, unique_ptr<TransactionLogIterator>* iter,
       const TransactionLogIterator::ReadOptions& read_options) override {
diff --git a/src/rocksdb/include/rocksdb/utilities/transaction.h b/src/rocksdb/include/rocksdb/utilities/transaction.h
index 6c2640a..099d04b 100644
--- a/src/rocksdb/include/rocksdb/utilities/transaction.h
+++ b/src/rocksdb/include/rocksdb/utilities/transaction.h
@@ -20,6 +20,17 @@ class Iterator;
 class TransactionDB;
 class WriteBatchWithIndex;
 
+// Provides notification to the caller of SetSnapshotOnNextOperation when
+// the actual snapshot gets created
+class TransactionNotifier {
+ public:
+  virtual ~TransactionNotifier() {}
+
+  // Implement this method to receive notification when a snapshot is
+  // requested via SetSnapshotOnNextOperation.
+  virtual void SnapshotCreated(const Snapshot* newSnapshot) = 0;
+};
+
 // Provides BEGIN/COMMIT/ROLLBACK transactions.
 //
 // To use transactions, you must first create either an OptimisticTransactionDB
@@ -61,12 +72,48 @@ class Transaction {
   // methods.  See Transaction::Get() for more details.
   virtual void SetSnapshot() = 0;
 
+  // Similar to SetSnapshot(), but will not change the current snapshot
+  // until Put/Merge/Delete/GetForUpdate/MultigetForUpdate is called.
+  // By calling this function, the transaction will essentially call
+  // SetSnapshot() for you right before performing the next write/GetForUpdate.
+  //
+  // Calling SetSnapshotOnNextOperation() will not affect what snapshot is
+  // returned by GetSnapshot() until the next write/GetForUpdate is executed.
+  //
+  // When the snapshot is created the notifier's SnapshotCreated method will
+  // be called so that the caller can get access to the snapshot.
+  //
+  // This is an optimization to reduce the likelihood of conflicts that
+  // could occur in between the time SetSnapshot() is called and the first
+  // write/GetForUpdate operation.  Eg, this prevents the following
+  // race-condition:
+  //
+  //   txn1->SetSnapshot();
+  //                             txn2->Put("A", ...);
+  //                             txn2->Commit();
+  //   txn1->GetForUpdate(opts, "A", ...);  // FAIL!
+  virtual void SetSnapshotOnNextOperation(
+      std::shared_ptr<TransactionNotifier> notifier = nullptr) = 0;
+
   // Returns the Snapshot created by the last call to SetSnapshot().
   //
   // REQUIRED: The returned Snapshot is only valid up until the next time
-  // SetSnapshot() is called or the Transaction is deleted.
+  // SetSnapshot()/SetSnapshotOnNextSavePoint() is called, ClearSnapshot()
+  // is called, or the Transaction is deleted.
   virtual const Snapshot* GetSnapshot() const = 0;
 
+  // Clears the current snapshot (i.e. no snapshot will be 'set')
+  //
+  // This removes any snapshot that currently exists or is set to be created
+  // on the next update operation (SetSnapshotOnNextOperation).
+  //
+  // Calling ClearSnapshot() has no effect on keys written before this function
+  // has been called.
+  //
+  // If a reference to a snapshot was retrieved via GetSnapshot(), it will no
+  // longer be valid and should be discarded after a call to ClearSnapshot().
+  virtual void ClearSnapshot() = 0;
+
   // Write all batched keys to the db atomically.
   //
   // Returns OK on success.
@@ -178,14 +225,10 @@ class Transaction {
   // in this transaction do not yet belong to any snapshot and will be fetched
   // regardless).
   //
-  // Caller is reponsible for deleting the returned Iterator.
+  // Caller is responsible for deleting the returned Iterator.
   //
   // The returned iterator is only valid until Commit(), Rollback(), or
   // RollbackToSavePoint() is called.
-  // NOTE: Transaction::Put/Merge/Delete will currently invalidate this iterator
-  // until
-  // the following issue is fixed:
-  // https://github.com/facebook/rocksdb/issues/616
   virtual Iterator* GetIterator(const ReadOptions& read_options) = 0;
 
   virtual Iterator* GetIterator(const ReadOptions& read_options,
@@ -263,6 +306,21 @@ class Transaction {
   // Similar to WriteBatch::PutLogData
   virtual void PutLogData(const Slice& blob) = 0;
 
+  // By default, all Put/Merge/Delete operations will be indexed in the
+  // transaction so that Get/GetForUpdate/GetIterator can search for these
+  // keys.
+  //
+  // If the caller does not want to fetch the keys about to be written,
+  // they may want to avoid indexing as a performance optimization.
+  // Calling DisableIndexing() will turn off indexing for all future
+  // Put/Merge/Delete operations until EnableIndexing() is called.
+  //
+  // If a key is Put/Merge/Deleted after DisableIndexing is called and then
+  // is fetched via Get/GetForUpdate/GetIterator, the result of the fetch is
+  // undefined.
+  virtual void DisableIndexing() = 0;
+  virtual void EnableIndexing() = 0;
+
   // Returns the number of distinct Keys being tracked by this transaction.
   // If this transaction was created by a TransactinDB, this is the number of
   // keys that are currently locked by this transaction.
diff --git a/src/rocksdb/include/rocksdb/version.h b/src/rocksdb/include/rocksdb/version.h
index 86a1939..408afda 100644
--- a/src/rocksdb/include/rocksdb/version.h
+++ b/src/rocksdb/include/rocksdb/version.h
@@ -5,7 +5,7 @@
 #pragma once
 
 #define ROCKSDB_MAJOR 4
-#define ROCKSDB_MINOR 1
+#define ROCKSDB_MINOR 3
 #define ROCKSDB_PATCH 0
 
 // Do not use these. We made the mistake of declaring macros starting with
diff --git a/src/rocksdb/include/rocksdb/wal_filter.h b/src/rocksdb/include/rocksdb/wal_filter.h
new file mode 100644
index 0000000..226d697
--- /dev/null
+++ b/src/rocksdb/include/rocksdb/wal_filter.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#pragma once
+
+namespace rocksdb {
+
+class WriteBatch;
+
+// WALFilter allows an application to inspect write-ahead-log (WAL)
+// records or modify their processing on recovery.
+// Please see the details below.
+class WalFilter {
+ public:
+  enum class WalProcessingOption {
+    // Continue processing as usual
+    kContinueProcessing = 0,
+    // Ignore the current record but continue processing of log(s)
+    kIgnoreCurrentRecord = 1,
+    // Stop replay of logs and discard logs
+    // Logs won't be replayed on subsequent recovery
+    kStopReplay = 2,
+    // Corrupted record detected by filter
+    kCorruptedRecord = 3,
+    // Marker for enum count
+    kWalProcessingOptionMax = 4
+  };
+
+  virtual ~WalFilter() {}
+
+  // LogRecord is invoked for each log record encountered for all the logs
+  // during replay on logs on recovery. This method can be used to:
+  //  * inspect the record (using the batch parameter)
+  //  * ignoring current record
+  //    (by returning WalProcessingOption::kIgnoreCurrentRecord)
+  //  * reporting corrupted record
+  //    (by returning WalProcessingOption::kCorruptedRecord)
+  //  * stop log replay
+  //    (by returning kStop replay) - please note that this implies
+  //    discarding the logs from current record onwards.
+  //
+  // @params batch          batch encountered in the log during recovery
+  // @params new_batch      new_batch to populate if filter wants to change
+  //                        the batch (for example to filter some records out,
+  //                        or alter some records).
+  //                        Please note that the new batch MUST NOT contain
+  //                        more records than original, else recovery would
+  //                        be failed.
+  // @params batch_changed  Whether batch was changed by the filter.
+  //                        It must be set to true if new_batch was populated,
+  //                        else new_batch has no effect.
+  // @returns               Processing option for the current record.
+  //                        Please see WalProcessingOption enum above for
+  //                        details.
+  virtual WalProcessingOption LogRecord(const WriteBatch& batch,
+                                        WriteBatch* new_batch,
+                                        bool* batch_changed) const = 0;
+
+  // Returns a name that identifies this WAL filter.
+  // The name will be printed to LOG file on start up for diagnosis.
+  virtual const char* Name() const = 0;
+};
+
+}  // namespace rocksdb
diff --git a/src/rocksdb/include/rocksdb/write_batch.h b/src/rocksdb/include/rocksdb/write_batch.h
index a097f21..f4a7ac0 100644
--- a/src/rocksdb/include/rocksdb/write_batch.h
+++ b/src/rocksdb/include/rocksdb/write_batch.h
@@ -25,6 +25,7 @@
 #ifndef STORAGE_ROCKSDB_INCLUDE_WRITE_BATCH_H_
 #define STORAGE_ROCKSDB_INCLUDE_WRITE_BATCH_H_
 
+#include <atomic>
 #include <stack>
 #include <string>
 #include <stdint.h>
@@ -71,8 +72,7 @@ class WriteBatch : public WriteBatchBase {
   void Delete(const SliceParts& key) override { Delete(nullptr, key); }
 
   using WriteBatchBase::SingleDelete;
-  // If the database contains a mapping for "key", erase it. Expects that the
-  // key was not overwritten. Else do nothing.
+  // WriteBatch implementation of DB::SingleDelete().  See db.h.
   void SingleDelete(ColumnFamilyHandle* column_family,
                     const Slice& key) override;
   void SingleDelete(const Slice& key) override { SingleDelete(nullptr, key); }
@@ -147,7 +147,7 @@ class WriteBatch : public WriteBatchBase {
       return Status::InvalidArgument(
           "non-default column family and PutCF not implemented");
     }
-    virtual void Put(const Slice& key, const Slice& value) {}
+    virtual void Put(const Slice& /*key*/, const Slice& /*value*/) {}
 
     virtual Status DeleteCF(uint32_t column_family_id, const Slice& key) {
       if (column_family_id == 0) {
@@ -157,7 +157,7 @@ class WriteBatch : public WriteBatchBase {
       return Status::InvalidArgument(
           "non-default column family and DeleteCF not implemented");
     }
-    virtual void Delete(const Slice& key) {}
+    virtual void Delete(const Slice& /*key*/) {}
 
     virtual Status SingleDeleteCF(uint32_t column_family_id, const Slice& key) {
       if (column_family_id == 0) {
@@ -167,7 +167,7 @@ class WriteBatch : public WriteBatchBase {
       return Status::InvalidArgument(
           "non-default column family and SingleDeleteCF not implemented");
     }
-    virtual void SingleDelete(const Slice& key) {}
+    virtual void SingleDelete(const Slice& /*key*/) {}
 
     // Merge and LogData are not pure virtual. Otherwise, we would break
     // existing clients of Handler on a source code level. The default
@@ -181,7 +181,7 @@ class WriteBatch : public WriteBatchBase {
       return Status::InvalidArgument(
           "non-default column family and MergeCF not implemented");
     }
-    virtual void Merge(const Slice& key, const Slice& value) {}
+    virtual void Merge(const Slice& /*key*/, const Slice& /*value*/) {}
 
     // The default implementation of LogData does nothing.
     virtual void LogData(const Slice& blob);
@@ -202,17 +202,39 @@ class WriteBatch : public WriteBatchBase {
   // Returns the number of updates in the batch
   int Count() const;
 
+  // Returns true if PutCF will be called during Iterate
+  bool HasPut() const;
+
+  // Returns true if DeleteCF will be called during Iterate
+  bool HasDelete() const;
+
+  // Returns true if SingleDeleteCF will be called during Iterate
+  bool HasSingleDelete() const;
+
+  // Returns trie if MergeCF will be called during Iterate
+  bool HasMerge() const;
+
   using WriteBatchBase::GetWriteBatch;
   WriteBatch* GetWriteBatch() override { return this; }
 
   // Constructor with a serialized string object
-  explicit WriteBatch(const std::string& rep)
-      : save_points_(nullptr), rep_(rep) {}
+  explicit WriteBatch(const std::string& rep);
+
+  WriteBatch(const WriteBatch& src);
+  WriteBatch(WriteBatch&& src);
+  WriteBatch& operator=(const WriteBatch& src);
+  WriteBatch& operator=(WriteBatch&& src);
 
  private:
   friend class WriteBatchInternal;
   SavePoints* save_points_;
 
+  // For HasXYZ.  Mutable to allow lazy computation of results
+  mutable std::atomic<uint32_t> content_flags_;
+
+  // Performs deferred computation of content_flags if necessary
+  uint32_t ComputeContentFlags() const;
+
  protected:
   std::string rep_;  // See comment in write_batch.cc for the format of rep_
 
diff --git a/src/rocksdb/java/RELEASE.md b/src/rocksdb/java/RELEASE.md
index 084460c..cb9aaf9 100644
--- a/src/rocksdb/java/RELEASE.md
+++ b/src/rocksdb/java/RELEASE.md
@@ -15,7 +15,7 @@ Once you have these items, run this make command from RocksDB's root source dire
 
 This command will build RocksDB natively on OSX, and will then spin up two Vagrant Virtualbox Ubuntu images to build RocksDB for both 32-bit and 64-bit Linux. 
 
-You can find all native binaries and JARs in the java directory upon completion:
+You can find all native binaries and JARs in the java/target directory upon completion:
 
     librocksdbjni-linux32.so
     librocksdbjni-linux64.so
diff --git a/src/rocksdb/java/crossbuild/Vagrantfile b/src/rocksdb/java/crossbuild/Vagrantfile
index 8a52b92..21cce12 100644
--- a/src/rocksdb/java/crossbuild/Vagrantfile
+++ b/src/rocksdb/java/crossbuild/Vagrantfile
@@ -20,7 +20,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   end
 
   config.vm.provision :shell, path: "build-linux-centos.sh"
-  config.vm.synced_folder "../", "/rocksdb-build"
+  config.vm.synced_folder "../target", "/rocksdb-build"
   config.vm.synced_folder "../..", "/rocksdb", type: "rsync"
   config.vm.boot_timeout = 1200
 end
diff --git a/src/rocksdb/java/crossbuild/build-linux-centos.sh b/src/rocksdb/java/crossbuild/build-linux-centos.sh
index f2b7948..2e8f81d 100755
--- a/src/rocksdb/java/crossbuild/build-linux-centos.sh
+++ b/src/rocksdb/java/crossbuild/build-linux-centos.sh
@@ -1,15 +1,15 @@
 #!/usr/bin/env bash
 # install all required packages for rocksdb that are available through yum
 ARCH=$(uname -i)
-sudo yum -y install openssl java-1.7.0-openjdk-devel.$ARCH zlib zlib-devel bzip2 bzip2-devel
+sudo yum -y install openssl java-1.7.0-openjdk-devel.$ARCH 
 
 # install gcc/g++ 4.8.2 via CERN (http://linux.web.cern.ch/linux/devtoolset/)
 sudo wget -O /etc/yum.repos.d/slc5-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc5-devtoolset.repo
 sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-cern http://ftp.mirrorservice.org/sites/ftp.scientificlinux.org/linux/scientific/51/i386/RPM-GPG-KEYs/RPM-GPG-KEY-cern
 sudo yum -y install devtoolset-2
 
-wget http://gflags.googlecode.com/files/gflags-1.6.tar.gz
-tar xvfz gflags-1.6.tar.gz; cd gflags-1.6; scl enable devtoolset-2 ./configure; scl enable devtoolset-2 make; sudo make install
+wget http://gflags.googlecode.com/files/gflags-2.0-no-svn-files.tar.gz
+tar xvfz gflags-2.0-no-svn-files.tar.gz; cd gflags-2.0; scl enable devtoolset-2 ./configure; scl enable devtoolset-2 make; sudo make install
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
 
 # set java home so we can build rocksdb jars
@@ -18,7 +18,7 @@ export JAVA_HOME=/usr/lib/jvm/java-1.7.0
 # build rocksdb
 cd /rocksdb
 scl enable devtoolset-2 'make jclean clean'
-scl enable devtoolset-2 'make rocksdbjavastatic'
+scl enable devtoolset-2 'PORTABLE=1 make rocksdbjavastatic'
 cp /rocksdb/java/target/librocksdbjni-* /rocksdb-build
 cp /rocksdb/java/target/rocksdbjni-* /rocksdb-build
 
diff --git a/src/rocksdb/java/rocksjni/options.cc b/src/rocksdb/java/rocksjni/options.cc
index 216fa5e..de3df94 100644
--- a/src/rocksdb/java/rocksjni/options.cc
+++ b/src/rocksdb/java/rocksjni/options.cc
@@ -578,6 +578,33 @@ void Java_org_rocksdb_Options_setKeepLogFileNum(
 
 /*
  * Class:     org_rocksdb_Options
+ * Method:    recycleLogFiles
+ * Signature: (J)J
+ */
+jlong Java_org_rocksdb_Options_recycleLogFileNum(JNIEnv* env, jobject jobj,
+                                                 jlong jhandle) {
+  return reinterpret_cast<rocksdb::Options*>(jhandle)->recycle_log_file_num;
+}
+
+/*
+ * Class:     org_rocksdb_Options
+ * Method:    setRecycleLogFiles
+ * Signature: (JJ)V
+ */
+void Java_org_rocksdb_Options_setRecycleLogFiles(JNIEnv* env, jobject jobj,
+                                                 jlong jhandle,
+                                                 jlong recycle_log_file_num) {
+  rocksdb::Status s = rocksdb::check_if_jlong_fits_size_t(recycle_log_file_num);
+  if (s.ok()) {
+    reinterpret_cast<rocksdb::Options*>(jhandle)->recycle_log_file_num =
+        recycle_log_file_num;
+  } else {
+    rocksdb::IllegalArgumentExceptionJni::ThrowNew(env, s);
+  }
+}
+
+/*
+ * Class:     org_rocksdb_Options
  * Method:    maxManifestFileSize
  * Signature: (J)J
  */
@@ -3535,6 +3562,32 @@ jlong Java_org_rocksdb_DBOptions_keepLogFileNum(
 
 /*
  * Class:     org_rocksdb_DBOptions
+ * Method:    setRecycleLogFiles
+ * Signature: (JJ)V
+ */
+void Java_org_rocksdb_DBOptions_setRecycleLogFileNum(
+    JNIEnv* env, jobject jobj, jlong jhandle, jlong recycle_log_file_num) {
+  rocksdb::Status s = rocksdb::check_if_jlong_fits_size_t(recycle_log_file_num);
+  if (s.ok()) {
+    reinterpret_cast<rocksdb::DBOptions*>(jhandle)->recycle_log_file_num =
+        recycle_log_file_num;
+  } else {
+    rocksdb::IllegalArgumentExceptionJni::ThrowNew(env, s);
+  }
+}
+
+/*
+ * Class:     org_rocksdb_DBOptions
+ * Method:    recycleLogFiles
+ * Signature: (J)J
+ */
+jlong Java_org_rocksdb_DBOptions_recycleLogFileNum(JNIEnv* env, jobject jobj,
+                                                   jlong jhandle) {
+  return reinterpret_cast<rocksdb::DBOptions*>(jhandle)->recycle_log_file_num;
+}
+
+/*
+ * Class:     org_rocksdb_DBOptions
  * Method:    setMaxManifestFileSize
  * Signature: (JJ)V
  */
diff --git a/src/rocksdb/java/rocksjni/write_batch.cc b/src/rocksdb/java/rocksjni/write_batch.cc
index aa0c230..dc3f6d2 100644
--- a/src/rocksdb/java/rocksjni/write_batch.cc
+++ b/src/rocksdb/java/rocksjni/write_batch.cc
@@ -20,8 +20,8 @@
 #include "db/writebuffer.h"
 #include "rocksdb/env.h"
 #include "rocksdb/memtablerep.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/logging.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/testharness.h"
 
 /*
diff --git a/src/rocksdb/java/rocksjni/write_batch_test.cc b/src/rocksdb/java/rocksjni/write_batch_test.cc
index d540291..98e53ff 100644
--- a/src/rocksdb/java/rocksjni/write_batch_test.cc
+++ b/src/rocksdb/java/rocksjni/write_batch_test.cc
@@ -21,8 +21,8 @@
 #include "rocksdb/status.h"
 #include "rocksdb/write_batch.h"
 #include "rocksjni/portal.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/logging.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/testharness.h"
 
 /*
diff --git a/src/rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java b/src/rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java
index 1c7a5a1..c4d7245 100644
--- a/src/rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java
+++ b/src/rocksdb/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java
@@ -231,7 +231,7 @@ public interface ColumnFamilyOptionsInterface {
 
 
   /**
-   * Same as fixed length prefix extractor, except that when slice is 
+   * Same as fixed length prefix extractor, except that when slice is
    * shorter than the fixed length, it will use the full key.
    *
    * @param n use the first n bytes of a key as its prefix.
@@ -753,7 +753,7 @@ public interface ColumnFamilyOptionsInterface {
    * If ≤ 0, a proper value is automatically calculated (usually 1/10 of
    * writer_buffer_size).
    *
-   * There are two additonal restriction of the The specified size:
+   * There are two additional restriction of the The specified size:
    * (1) size should be in the range of [4096, 2 << 30] and
    * (2) be the multiple of the CPU word (which helps with the memory
    * alignment).
@@ -774,7 +774,7 @@ public interface ColumnFamilyOptionsInterface {
    * If ≤ 0, a proper value is automatically calculated (usually 1/10 of
    * writer_buffer_size).
    *
-   * There are two additonal restriction of the The specified size:
+   * There are two additional restriction of the The specified size:
    * (1) size should be in the range of [4096, 2 << 30] and
    * (2) be the multiple of the CPU word (which helps with the memory
    * alignment).
diff --git a/src/rocksdb/java/src/main/java/org/rocksdb/DBOptionsInterface.java b/src/rocksdb/java/src/main/java/org/rocksdb/DBOptionsInterface.java
index f710105..0c230e4 100644
--- a/src/rocksdb/java/src/main/java/org/rocksdb/DBOptionsInterface.java
+++ b/src/rocksdb/java/src/main/java/org/rocksdb/DBOptionsInterface.java
@@ -565,7 +565,7 @@ public interface DBOptionsInterface {
    *    are older than WAL_ttl_seconds will be deleted.</li>
    * <li>If both are not 0, WAL files will be checked every 10 min and both
    *    checks will be performed with ttl being first.</li>
-   * </ol> 
+   * </ol>
    *
    * @param sizeLimitMB size limit in mega-bytes.
    * @return the instance of the current Object.
diff --git a/src/rocksdb/util/hash_cuckoo_rep.cc b/src/rocksdb/memtable/hash_cuckoo_rep.cc
similarity index 99%
rename from src/rocksdb/util/hash_cuckoo_rep.cc
rename to src/rocksdb/memtable/hash_cuckoo_rep.cc
index 6e5057a..fdf09c6 100644
--- a/src/rocksdb/util/hash_cuckoo_rep.cc
+++ b/src/rocksdb/memtable/hash_cuckoo_rep.cc
@@ -5,8 +5,7 @@
 //
 
 #ifndef ROCKSDB_LITE
-
-#include "util/hash_cuckoo_rep.h"
+#include "memtable/hash_cuckoo_rep.h"
 
 #include <algorithm>
 #include <atomic>
@@ -18,9 +17,10 @@
 
 #include "db/memtable.h"
 #include "db/skiplist.h"
+#include "memtable/stl_wrappers.h"
+#include "port/port.h"
 #include "rocksdb/memtablerep.h"
 #include "util/murmurhash.h"
-#include "util/stl_wrappers.h"
 
 namespace rocksdb {
 namespace {
@@ -318,7 +318,7 @@ void HashCuckooRep::Get(const LookupKey& key, void* callback_args,
 }
 
 void HashCuckooRep::Insert(KeyHandle handle) {
-  static const float kMaxFullness = 0.90;
+  static const float kMaxFullness = 0.90f;
 
   auto* key = static_cast<char*>(handle);
   int initial_hash_id = 0;
@@ -620,7 +620,7 @@ MemTableRep* HashCuckooRepFactory::CreateMemTableRep(
   // degrades as the fullness of the mem-table increases.  Setting kFullness
   // to a value around 0.7 can better avoid write performance degradation while
   // keeping efficient memory usage.
-  static const float kFullness = 0.7;
+  static const float kFullness = 0.7f;
   size_t pointer_size = sizeof(std::atomic<const char*>);
   assert(write_buffer_size_ >= (average_data_size_ + pointer_size));
   size_t bucket_count =
diff --git a/src/rocksdb/util/hash_cuckoo_rep.h b/src/rocksdb/memtable/hash_cuckoo_rep.h
similarity index 98%
rename from src/rocksdb/util/hash_cuckoo_rep.h
rename to src/rocksdb/memtable/hash_cuckoo_rep.h
index 9f374a9..6de4baa 100644
--- a/src/rocksdb/util/hash_cuckoo_rep.h
+++ b/src/rocksdb/memtable/hash_cuckoo_rep.h
@@ -6,8 +6,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#ifndef ROCKSDB_LITE
 #pragma once
+#ifndef ROCKSDB_LITE
+#include "port/port.h"
 #include "rocksdb/slice_transform.h"
 #include "rocksdb/memtablerep.h"
 
diff --git a/src/rocksdb/util/hash_linklist_rep.cc b/src/rocksdb/memtable/hash_linklist_rep.cc
similarity index 99%
rename from src/rocksdb/util/hash_linklist_rep.cc
rename to src/rocksdb/memtable/hash_linklist_rep.cc
index 1e6eadf..2e761ce 100644
--- a/src/rocksdb/util/hash_linklist_rep.cc
+++ b/src/rocksdb/memtable/hash_linklist_rep.cc
@@ -5,7 +5,7 @@
 //
 
 #ifndef ROCKSDB_LITE
-#include "util/hash_linklist_rep.h"
+#include "memtable/hash_linklist_rep.h"
 
 #include <algorithm>
 #include <atomic>
diff --git a/src/rocksdb/util/hash_linklist_rep.h b/src/rocksdb/memtable/hash_linklist_rep.h
similarity index 100%
rename from src/rocksdb/util/hash_linklist_rep.h
rename to src/rocksdb/memtable/hash_linklist_rep.h
index 6292723..1bab441 100644
--- a/src/rocksdb/util/hash_linklist_rep.h
+++ b/src/rocksdb/memtable/hash_linklist_rep.h
@@ -6,8 +6,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#ifndef ROCKSDB_LITE
 #pragma once
+#ifndef ROCKSDB_LITE
 #include "rocksdb/slice_transform.h"
 #include "rocksdb/memtablerep.h"
 
diff --git a/src/rocksdb/util/hash_skiplist_rep.cc b/src/rocksdb/memtable/hash_skiplist_rep.cc
similarity index 99%
rename from src/rocksdb/util/hash_skiplist_rep.cc
rename to src/rocksdb/memtable/hash_skiplist_rep.cc
index 142903d..cbdd889 100644
--- a/src/rocksdb/util/hash_skiplist_rep.cc
+++ b/src/rocksdb/memtable/hash_skiplist_rep.cc
@@ -5,7 +5,7 @@
 //
 
 #ifndef ROCKSDB_LITE
-#include "util/hash_skiplist_rep.h"
+#include "memtable/hash_skiplist_rep.h"
 
 #include <atomic>
 
diff --git a/src/rocksdb/util/hash_skiplist_rep.h b/src/rocksdb/memtable/hash_skiplist_rep.h
similarity index 100%
rename from src/rocksdb/util/hash_skiplist_rep.h
rename to src/rocksdb/memtable/hash_skiplist_rep.h
index 15d0fc7..a6544ff 100644
--- a/src/rocksdb/util/hash_skiplist_rep.h
+++ b/src/rocksdb/memtable/hash_skiplist_rep.h
@@ -6,8 +6,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#ifndef ROCKSDB_LITE
 #pragma once
+#ifndef ROCKSDB_LITE
 #include "rocksdb/slice_transform.h"
 #include "rocksdb/memtablerep.h"
 
diff --git a/src/rocksdb/util/stl_wrappers.h b/src/rocksdb/memtable/stl_wrappers.h
similarity index 73%
copy from src/rocksdb/util/stl_wrappers.h
copy to src/rocksdb/memtable/stl_wrappers.h
index 15b9bdf..cef8301 100644
--- a/src/rocksdb/util/stl_wrappers.h
+++ b/src/rocksdb/memtable/stl_wrappers.h
@@ -30,17 +30,5 @@ struct Compare : private Base {
   }
 };
 
-struct LessOfComparator {
-  explicit LessOfComparator(const Comparator* c = BytewiseComparator())
-      : cmp(c) {}
-
-  bool operator()(const std::string& a, const std::string& b) const {
-    return cmp->Compare(Slice(a), Slice(b)) < 0;
-  }
-
-  const Comparator* cmp;
-};
-
-typedef std::map<std::string, std::string, LessOfComparator> KVMap;
 }
 }
diff --git a/src/rocksdb/port/port.h b/src/rocksdb/port/port.h
index e949cd2..670006e 100644
--- a/src/rocksdb/port/port.h
+++ b/src/rocksdb/port/port.h
@@ -19,4 +19,3 @@
 #elif defined(OS_WIN)
 #include "port/win/port_win.h"
 #endif
-
diff --git a/src/rocksdb/port/port_posix.h b/src/rocksdb/port/port_posix.h
index efb72ee..8854e1c 100644
--- a/src/rocksdb/port/port_posix.h
+++ b/src/rocksdb/port/port_posix.h
@@ -32,14 +32,11 @@
   #else
     #define PLATFORM_IS_LITTLE_ENDIAN false
   #endif
-#elif defined(OS_FREEBSD)
+#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || \
+    defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID)
   #include <sys/endian.h>
   #include <sys/types.h>
   #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN)
-#elif defined(OS_OPENBSD) || defined(OS_NETBSD) ||\
-      defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID)
-  #include <sys/types.h>
-  #include <sys/endian.h>
 #else
   #include <endian.h>
 #endif
@@ -70,7 +67,7 @@
 
 #if defined(OS_ANDROID) && __ANDROID_API__ < 9
 // fdatasync() was only introduced in API level 9 on Android. Use fsync()
-// when targetting older platforms.
+// when targeting older platforms.
 #define fdatasync fsync
 #endif
 
@@ -159,4 +156,3 @@ extern int GetMaxOpenFiles();
 
 } // namespace port
 } // namespace rocksdb
-
diff --git a/src/rocksdb/port/win/env_win.cc b/src/rocksdb/port/win/env_win.cc
index 4584732..86f0e08 100644
--- a/src/rocksdb/port/win/env_win.cc
+++ b/src/rocksdb/port/win/env_win.cc
@@ -61,12 +61,6 @@ ThreadStatusUpdater* CreateThreadStatusUpdater() {
   return new ThreadStatusUpdater();
 }
 
-// A wrapper for fadvise, if the platform doesn't support fadvise,
-// it will simply return Status::NotSupport.
-int Fadvise(int fd, off_t offset, size_t len, int advice) {
-  return 0;  // simply do nothing.
-}
-
 inline Status IOErrorFromWindowsError(const std::string& context, DWORD err) {
   return Status::IOError(context, GetWindowsErrSz(err));
 }
@@ -107,6 +101,7 @@ typedef std::unique_ptr<void, decltype(CloseHandleFunc)> UniqueCloseHandlePtr;
 // rely on the current file offset.
 SSIZE_T pwrite(HANDLE hFile, const char* src, size_t numBytes,
                uint64_t offset) {
+  assert(numBytes <= std::numeric_limits<DWORD>::max());
   OVERLAPPED overlapped = {0};
   ULARGE_INTEGER offsetUnion;
   offsetUnion.QuadPart = offset;
@@ -118,7 +113,8 @@ SSIZE_T pwrite(HANDLE hFile, const char* src, size_t numBytes,
 
   unsigned long bytesWritten = 0;
 
-  if (FALSE == WriteFile(hFile, src, numBytes, &bytesWritten, &overlapped)) {
+  if (FALSE == WriteFile(hFile, src, static_cast<DWORD>(numBytes), &bytesWritten,
+    &overlapped)) {
     result = -1;
   } else {
     result = bytesWritten;
@@ -129,6 +125,7 @@ SSIZE_T pwrite(HANDLE hFile, const char* src, size_t numBytes,
 
 // See comments for pwrite above
 SSIZE_T pread(HANDLE hFile, char* src, size_t numBytes, uint64_t offset) {
+  assert(numBytes <= std::numeric_limits<DWORD>::max());
   OVERLAPPED overlapped = {0};
   ULARGE_INTEGER offsetUnion;
   offsetUnion.QuadPart = offset;
@@ -140,7 +137,8 @@ SSIZE_T pread(HANDLE hFile, char* src, size_t numBytes, uint64_t offset) {
 
   unsigned long bytesRead = 0;
 
-  if (FALSE == ReadFile(hFile, src, numBytes, &bytesRead, &overlapped)) {
+  if (FALSE == ReadFile(hFile, src, static_cast<DWORD>(numBytes), &bytesRead,
+    &overlapped)) {
     return -1;
   } else {
     result = bytesRead;
@@ -605,7 +603,7 @@ class WinMmapFile : public WritableFile {
     return Status::OK();
   }
 
-  virtual Status Allocate(off_t offset, off_t len) override {
+  virtual Status Allocate(uint64_t offset, uint64_t len) override {
     return Status::OK();
   }
 };
@@ -616,7 +614,7 @@ class WinSequentialFile : public SequentialFile {
   HANDLE file_;
 
   // There is no equivalent of advising away buffered pages as in posix.
-  // To implement this flag we would need to do unbuffered reads which 
+  // To implement this flag we would need to do unbuffered reads which
   // will need to be aligned (not sure there is a guarantee that the buffer
   // passed in is aligned).
   // Hence we currently ignore this flag. It is used only in a few cases
@@ -688,28 +686,104 @@ class WinRandomAccessFile : public RandomAccessFile {
   const std::string filename_;
   HANDLE hFile_;
   const bool use_os_buffer_;
+  bool read_ahead_;
+  const size_t compaction_readahead_size_;
+  const size_t random_access_max_buffer_size_;
   mutable std::mutex buffer_mut_;
   mutable AlignedBuffer buffer_;
   mutable uint64_t
       buffered_start_;  // file offset set that is currently buffered
 
+  /*
+   * The function reads a requested amount of bytes into the specified aligned
+   * buffer Upon success the function sets the length of the buffer to the
+   * amount of bytes actually read even though it might be less than actually
+   * requested. It then copies the amount of bytes requested by the user (left)
+   * to the user supplied buffer (dest) and reduces left by the amount of bytes
+   * copied to the user buffer
+   *
+   * @user_offset [in] - offset on disk where the read was requested by the user
+   * @first_page_start [in] - actual page aligned disk offset that we want to
+   *                          read from
+   * @bytes_to_read [in] - total amount of bytes that will be read from disk
+   *                       which is generally greater or equal to the amount
+   *                       that the user has requested due to the
+   *                       either alignment requirements or read_ahead in
+   *                       effect.
+   * @left [in/out] total amount of bytes that needs to be copied to the user
+   *                buffer. It is reduced by the amount of bytes that actually
+   *                copied
+   * @buffer - buffer to use
+   * @dest - user supplied buffer
+  */
+  SSIZE_T ReadIntoBuffer(uint64_t user_offset, uint64_t first_page_start,
+                         size_t bytes_to_read, size_t& left,
+                         AlignedBuffer& buffer, char* dest) const {
+    assert(buffer.CurrentSize() == 0);
+    assert(buffer.Capacity() >= bytes_to_read);
+
+    SSIZE_T read =
+        pread(hFile_, buffer.Destination(), bytes_to_read, first_page_start);
+
+    if (read > 0) {
+      buffer.Size(read);
+
+      // Let's figure out how much we read from the users standpoint
+      if ((first_page_start + buffer.CurrentSize()) > user_offset) {
+        assert(first_page_start <= user_offset);
+        size_t buffer_offset = user_offset - first_page_start;
+        read = buffer.Read(dest, buffer_offset, left);
+      } else {
+        read = 0;
+      }
+      left -= read;
+    }
+    return read;
+  }
+
+  SSIZE_T ReadIntoOneShotBuffer(uint64_t user_offset, uint64_t first_page_start,
+                                size_t bytes_to_read, size_t& left,
+                                char* dest) const {
+    AlignedBuffer bigBuffer;
+    bigBuffer.Alignment(buffer_.Alignment());
+    bigBuffer.AllocateNewBuffer(bytes_to_read);
+
+    return ReadIntoBuffer(user_offset, first_page_start, bytes_to_read, left,
+                          bigBuffer, dest);
+  }
+
+  SSIZE_T ReadIntoInstanceBuffer(uint64_t user_offset,
+                                 uint64_t first_page_start,
+                                 size_t bytes_to_read, size_t& left,
+                                 char* dest) const {
+    SSIZE_T read = ReadIntoBuffer(user_offset, first_page_start, bytes_to_read,
+                                  left, buffer_, dest);
+
+    if (read > 0) {
+      buffered_start_ = first_page_start;
+    }
+
+    return read;
+  }
+
  public:
   WinRandomAccessFile(const std::string& fname, HANDLE hFile, size_t alignment,
                       const EnvOptions& options)
       : filename_(fname),
         hFile_(hFile),
         use_os_buffer_(options.use_os_buffer),
+        read_ahead_(false),
+        compaction_readahead_size_(options.compaction_readahead_size),
+        random_access_max_buffer_size_(options.random_access_max_buffer_size),
         buffer_(),
         buffered_start_(0) {
     assert(!options.use_mmap_reads);
 
     // Unbuffered access, use internal buffer for reads
     if (!use_os_buffer_) {
+      // Do not allocate the buffer either until the first request or
+      // until there is a call to allocate a read-ahead buffer
       buffer_.Alignment(alignment);
-      // Random read, no need in a big buffer
-      // We read things in database blocks which are likely to be similar to
-      // the alignment we use.
-      buffer_.AllocateNewBuffer(alignment * 2);
     }
   }
 
@@ -719,6 +793,8 @@ class WinRandomAccessFile : public RandomAccessFile {
     }
   }
 
+  virtual void EnableReadAhead() override { this->Hint(SEQUENTIAL); }
+
   virtual Status Read(uint64_t offset, size_t n, Slice* result,
                       char* scratch) const override {
     Status s;
@@ -730,7 +806,7 @@ class WinRandomAccessFile : public RandomAccessFile {
     // - use our own aligned buffer
     // - always read at the offset of that is a multiple of alignment
     if (!use_os_buffer_) {
-      std::lock_guard<std::mutex> lg(buffer_mut_);
+      std::unique_lock<std::mutex> lock(buffer_mut_);
 
       // Let's see if at least some of the requested data is already
       // in the buffer
@@ -749,40 +825,40 @@ class WinRandomAccessFile : public RandomAccessFile {
       if (left > 0) {
         // Figure out the start/end offset for reading and amount to read
         const size_t alignment = buffer_.Alignment();
-        const size_t start_page_start =
+        const size_t first_page_start =
             TruncateToPageBoundary(alignment, offset);
-        const size_t end_page_start =
-            TruncateToPageBoundary(alignment, offset + left - 1);
-        const size_t actual_bytes_toread =
-            (end_page_start - start_page_start) + alignment;
 
-        if (buffer_.Capacity() < actual_bytes_toread) {
-          buffer_.AllocateNewBuffer(actual_bytes_toread);
-        } else {
-          buffer_.Clear();
+        size_t bytes_requested = left;
+        if (read_ahead_ && bytes_requested < compaction_readahead_size_) {
+          bytes_requested = compaction_readahead_size_;
         }
 
-        SSIZE_T read = 0;
-        read = pread(hFile_, buffer_.Destination(), actual_bytes_toread,
-                      start_page_start);
-
-        if (read > 0) {
-          buffer_.Size(read);
-          buffered_start_ = start_page_start;
+        const size_t last_page_start =
+            TruncateToPageBoundary(alignment, offset + bytes_requested - 1);
+        const size_t actual_bytes_toread =
+            (last_page_start - first_page_start) + alignment;
 
-          // Let's figure out how much we read from the users standpoint
-          if ((buffered_start_ + uint64_t(read)) > offset) {
-            size_t buffer_offset = offset - buffered_start_;
-            r = buffer_.Read(dest, buffer_offset, left);
+        if (buffer_.Capacity() < actual_bytes_toread) {
+          // If we are in read-ahead mode or the requested size
+          // exceeds max buffer size then use one-shot
+          // big buffer otherwise reallocate main buffer
+          if (read_ahead_ ||
+              (actual_bytes_toread > random_access_max_buffer_size_)) {
+            // Unlock the mutex since we are not using instance buffer
+            lock.unlock();
+            r = ReadIntoOneShotBuffer(offset, first_page_start,
+                                      actual_bytes_toread, left, dest);
           } else {
-            r = 0;
+            buffer_.AllocateNewBuffer(actual_bytes_toread);
+            r = ReadIntoInstanceBuffer(offset, first_page_start,
+                                       actual_bytes_toread, left, dest);
           }
-          left -= r;
         } else {
-          r = read;
+          buffer_.Clear();
+          r = ReadIntoInstanceBuffer(offset, first_page_start,
+                                     actual_bytes_toread, left, dest);
         }
       }
-
     } else {
       r = pread(hFile_, scratch, left, offset);
       if (r > 0) {
@@ -802,7 +878,21 @@ class WinRandomAccessFile : public RandomAccessFile {
     return true;
   }
 
-  virtual void Hint(AccessPattern pattern) override {}
+  virtual void Hint(AccessPattern pattern) override {
+    if (pattern == SEQUENTIAL && !use_os_buffer_ &&
+        compaction_readahead_size_ > 0) {
+      std::lock_guard<std::mutex> lg(buffer_mut_);
+      if (!read_ahead_) {
+        read_ahead_ = true;
+        // This would allocate read-ahead size + 2 alignments
+        // - one for memory alignment which added implicitly by AlignedBuffer
+        // - We add one more alignment because we will read one alignment more
+        // from disk
+        buffer_.AllocateNewBuffer(compaction_readahead_size_ +
+                                  buffer_.Alignment());
+      }
+    }
+  }
 
   virtual Status InvalidateCache(size_t offset, size_t length) override {
     return Status::OK();
@@ -862,13 +952,13 @@ class WinWritableFile : public WritableFile {
 
     // Used for buffered access ONLY
     assert(use_os_buffer_);
-    assert(data.size() < std::numeric_limits<int>::max());
+    assert(data.size() < std::numeric_limits<DWORD>::max());
 
     Status s;
 
     DWORD bytesWritten = 0;
     if (!WriteFile(hFile_, data.data(),
-        data.size(), &bytesWritten, NULL)) {
+        static_cast<DWORD>(data.size()), &bytesWritten, NULL)) {
       auto lastError = GetLastError();
       s = IOErrorFromWindowsError(
         "Failed to WriteFile: " + filename_,
@@ -884,8 +974,7 @@ class WinWritableFile : public WritableFile {
   virtual Status PositionedAppend(const Slice& data, uint64_t offset) override {
     Status s;
 
-    SSIZE_T ret = pwrite(hFile_, data.data(), 
-      data.size(), offset);
+    SSIZE_T ret = pwrite(hFile_, data.data(), data.size(), offset);
 
     // Error break
     if (ret < 0) {
@@ -961,9 +1050,9 @@ class WinWritableFile : public WritableFile {
     return filesize_;
   }
 
-  virtual Status Allocate(off_t offset, off_t len) override {
+  virtual Status Allocate(uint64_t offset, uint64_t len) override {
     Status status;
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
+    TEST_KILL_RANDOM("WinWritableFile::Allocate", rocksdb_kill_odds);
 
     // Make sure that we reserve an aligned amount of space
     // since the reservation block size is driven outside so we want
diff --git a/src/rocksdb/port/win/port_win.cc b/src/rocksdb/port/win/port_win.cc
index 2aaeada..99998b3 100644
--- a/src/rocksdb/port/win/port_win.cc
+++ b/src/rocksdb/port/win/port_win.cc
@@ -43,65 +43,50 @@ void gettimeofday(struct timeval* tv, struct timezone* /* tz */) {
   tv->tv_usec = usNow.count() - duration_cast<microseconds>(secNow).count();
 }
 
-Mutex::Mutex(bool adaptive) : lock(m_mutex, std::defer_lock) {}
-
 Mutex::~Mutex() {}
 
-void Mutex::Lock() {
-  lock.lock();
-#ifndef NDEBUG
-  locked_ = true;
-#endif
-}
-
-void Mutex::Unlock() {
-#ifndef NDEBUG
-  locked_ = false;
-#endif
-  lock.unlock();
-}
-
-void Mutex::AssertHeld() {
-#ifndef NDEBUG
-  assert(locked_);
-#endif
-}
-
-CondVar::CondVar(Mutex* mu) : mu_(mu) {}
-
 CondVar::~CondVar() {}
 
 void CondVar::Wait() {
+  // Caller must ensure that mutex is held prior to calling this method
+  std::unique_lock<std::mutex> lk(mu_->getLock(), std::adopt_lock);
 #ifndef NDEBUG
   mu_->locked_ = false;
 #endif
-  cv_.wait(mu_->getLock());
+  cv_.wait(lk);
 #ifndef NDEBUG
   mu_->locked_ = true;
 #endif
+  // Release ownership of the lock as we don't want it to be unlocked when
+  // it goes out of scope (as we adopted the lock and didn't lock it ourselves)
+  lk.release();
 }
 
 bool CondVar::TimedWait(uint64_t abs_time_us) {
-#ifndef NDEBUG
-  mu_->locked_ = false;
-#endif
 
   using namespace std::chrono;
 
   // MSVC++ library implements wait_until in terms of wait_for so
-  // there is not an absolute wait anyway.
+  // we need to convert absolute wait into relative wait.
   microseconds usAbsTime(abs_time_us);
 
   microseconds usNow(
-      duration_cast<microseconds>(system_clock::now().time_since_epoch()));
+    duration_cast<microseconds>(system_clock::now().time_since_epoch()));
   microseconds relTimeUs =
-      (usAbsTime > usNow) ? (usAbsTime - usNow) : microseconds::zero();
-
-  std::cv_status cvStatus = cv_.wait_for(mu_->getLock(), relTimeUs);
+    (usAbsTime > usNow) ? (usAbsTime - usNow) : microseconds::zero();
 
+  // Caller must ensure that mutex is held prior to calling this method
+  std::unique_lock<std::mutex> lk(mu_->getLock(), std::adopt_lock);
+#ifndef NDEBUG
+  mu_->locked_ = false;
+#endif
+  std::cv_status cvStatus = cv_.wait_for(lk, relTimeUs);
 #ifndef NDEBUG
   mu_->locked_ = true;
 #endif
+  // Release ownership of the lock as we don't want it to be unlocked when
+  // it goes out of scope (as we adopted the lock and didn't lock it ourselves)
+  lk.release();
 
   if (cvStatus == std::cv_status::timeout) {
     return true;
@@ -115,7 +100,7 @@ void CondVar::Signal() { cv_.notify_one(); }
 void CondVar::SignalAll() { cv_.notify_all(); }
 
 void InitOnce(OnceType* once, void (*initializer)()) {
-  std::call_once(*once, initializer);
+  std::call_once(once->flag_, initializer);
 }
 
 // Private structure, exposed only by pointer
diff --git a/src/rocksdb/port/win/port_win.h b/src/rocksdb/port/win/port_win.h
index 1f517fb..6b79200 100644
--- a/src/rocksdb/port/win/port_win.h
+++ b/src/rocksdb/port/win/port_win.h
@@ -25,6 +25,7 @@
 #include <string>
 #include <string.h>
 #include <mutex>
+#include <limits>
 #include <condition_variable>
 
 #include <stdint.h>
@@ -41,11 +42,6 @@
 #define strcasecmp _stricmp
 #endif
 
-// defined in stdio.h
-#ifndef snprintf
-#define snprintf _snprintf
-#endif
-
 #undef GetCurrentTime
 #undef DeleteFile
 
@@ -58,8 +54,6 @@ typedef SSIZE_T ssize_t;
 #define ROCKSDB_PRIszt "Iu"
 #endif
 
-#define ROCKSDB_NOEXCEPT
-
 #define __attribute__(A)
 
 #ifdef ZLIB
@@ -96,46 +90,91 @@ std::string GetWindowsErrSz(DWORD err);
 
 namespace port {
 
+// VS 15
+#if (defined _MSC_VER) && (_MSC_VER >= 1900)
+
+#define ROCKSDB_NOEXCEPT noexcept
+
 // For use at db/file_indexer.h kLevelMaxIndex
-const int kMaxInt32 = INT32_MAX;
-const uint64_t kMaxUint64 = UINT64_MAX;
+const int kMaxInt32 = std::numeric_limits<int>::max();
+const uint64_t kMaxUint64 = std::numeric_limits<uint64_t>::max();
+
+const size_t kMaxSizet = std::numeric_limits<size_t>::max();
+
+#else //_MSC_VER
+
+// VS 15 has snprintf
+#define snprintf _snprintf
+
+#define ROCKSDB_NOEXCEPT
 // std::numeric_limits<size_t>::max() is not constexpr just yet
 // therefore, use the same limits
+
+// For use at db/file_indexer.h kLevelMaxIndex
+const int kMaxInt32 = INT32_MAX;
+const uint64_t kMaxUint64 = UINT64_MAX;
+
 #ifdef _WIN64
 const size_t kMaxSizet = UINT64_MAX;
 #else
 const size_t kMaxSizet = UINT_MAX;
 #endif
 
+#endif //_MSC_VER
+
 const bool kLittleEndian = true;
 
 class CondVar;
 
 class Mutex {
  public:
-  /* implicit */ Mutex(bool adaptive = false);
+
+   /* implicit */ Mutex(bool adaptive = false)
+#ifndef NDEBUG
+     : locked_(false)
+#endif
+   { }
+
   ~Mutex();
 
-  void Lock();
-  void Unlock();
+  void Lock() {
+    mutex_.lock();
+#ifndef NDEBUG
+    locked_ = true;
+#endif
+  }
+
+  void Unlock() {
+#ifndef NDEBUG
+    locked_ = false;
+#endif
+    mutex_.unlock();
+  }
 
   // this will assert if the mutex is not locked
   // it does NOT verify that mutex is held by a calling thread
-  void AssertHeld();
+  void AssertHeld() {
+#ifndef NDEBUG
+    assert(locked_);
+#endif
+  }
 
-  std::unique_lock<std::mutex>& getLock() { return lock; }
+  // Mutex is move only with lock ownership transfer
+  Mutex(const Mutex&) = delete;
+  void operator=(const Mutex&) = delete;
 
  private:
+
   friend class CondVar;
-  std::mutex m_mutex;
-  std::unique_lock<std::mutex> lock;
+
+  std::mutex& getLock() {
+    return mutex_;
+  }
+
+  std::mutex mutex_;
 #ifndef NDEBUG
   bool locked_;
 #endif
-
-  // No copying
-  Mutex(const Mutex&);
-  void operator=(const Mutex&);
 };
 
 class RWMutex {
@@ -162,31 +201,48 @@ class RWMutex {
 
 class CondVar {
  public:
-  explicit CondVar(Mutex* mu);
+  explicit CondVar(Mutex* mu) : mu_(mu) {
+  }
+
   ~CondVar();
   void Wait();
   bool TimedWait(uint64_t expiration_time);
   void Signal();
   void SignalAll();
 
+  // Condition var is not copy/move constructible
+  CondVar(const CondVar&) = delete;
+  CondVar& operator=(const CondVar&) = delete;
+
+  CondVar(CondVar&&) = delete;
+  CondVar& operator=(CondVar&&) = delete;
+
  private:
   std::condition_variable cv_;
   Mutex* mu_;
 };
 
-typedef std::once_flag OnceType;
-#define LEVELDB_ONCE_INIT std::once_flag::once_flag();
+
+// OnceInit type helps emulate
+// Posix semantics with initialization
+// adopted in the project
+struct OnceType {
+
+    struct Init {};
+
+    OnceType() {}
+    OnceType(const Init&) {}
+    OnceType(const OnceType&) = delete;
+    OnceType& operator=(const OnceType&) = delete;
+
+    std::once_flag flag_;
+};
+
+#define LEVELDB_ONCE_INIT port::OnceType::Init()
 extern void InitOnce(OnceType* once, void (*initializer)());
 
 #define CACHE_LINE_SIZE 64U
 
-#ifdef min
-#undef min
-#endif
-#ifdef max
-#undef max
-#endif
-
 // For Thread Local Storage abstraction
 typedef DWORD pthread_key_t;
 
@@ -247,4 +303,4 @@ using port::truncate;
 
 }  // namespace rocksdb
 
-#endif  // STORAGE_LEVELDB_PORT_PORT_POSIX_H_
+#endif  // STORAGE_LEVELDB_PORT_PORT_WIN_H_
diff --git a/src/rocksdb/port/win/win_logger.cc b/src/rocksdb/port/win/win_logger.cc
index e91930d..e89c1af 100644
--- a/src/rocksdb/port/win/win_logger.cc
+++ b/src/rocksdb/port/win/win_logger.cc
@@ -10,7 +10,8 @@
 // Logger implementation that can be shared by all environments
 // where enough posix functionality is available.
 
-#include <stdint.h>
+#include "port/win/win_logger.h"
+
 #include <algorithm>
 #include <stdio.h>
 #include <time.h>
@@ -19,9 +20,6 @@
 
 #include "rocksdb/env.h"
 
-#include <Windows.h>
-
-#include "port/win/win_logger.h"
 #include "port/sys_time.h"
 #include "util/iostats_context_imp.h"
 
@@ -53,8 +51,9 @@ void WinLogger::close() { CloseHandle(file_); }
 void WinLogger::Flush() {
   if (flush_pending_) {
     flush_pending_ = false;
-    // With Windows API writes go to OS buffers directly so no fflush needed unlike 
-    // with C runtime API. We don't flush all the way to disk for perf reasons.
+    // With Windows API writes go to OS buffers directly so no fflush needed
+    // unlike with C runtime API. We don't flush all the way to disk
+    // for perf reasons.
   }
 
   last_flush_micros_ = env_->NowMicros();
@@ -124,8 +123,9 @@ void WinLogger::Logv(const char* format, va_list ap) {
     assert(p <= limit);
     const size_t write_size = p - base;
 
-    DWORD bytesWritten = 0;    
-    BOOL ret = WriteFile(file_, base, write_size, &bytesWritten, NULL);
+    DWORD bytesWritten = 0;
+    BOOL ret = WriteFile(file_, base, static_cast<DWORD>(write_size),
+      &bytesWritten, NULL);
     if (ret == FALSE) {
       std::string errSz = GetWindowsErrSz(GetLastError());
       fprintf(stderr, errSz.c_str());
@@ -141,8 +141,9 @@ void WinLogger::Logv(const char* format, va_list ap) {
         static_cast<uint64_t>(now_tv.tv_sec) * 1000000 + now_tv.tv_usec;
     if (now_micros - last_flush_micros_ >= flush_every_seconds_ * 1000000) {
       flush_pending_ = false;
-      // With Windows API writes go to OS buffers directly so no fflush needed unlike 
-      // with C runtime API. We don't flush all the way to disk for perf reasons.
+      // With Windows API writes go to OS buffers directly so no fflush needed
+      // unlike with C runtime API. We don't flush all the way to disk
+      // for perf reasons.
       last_flush_micros_ = now_micros;
     }
     break;
diff --git a/src/rocksdb/port/win/win_logger.h b/src/rocksdb/port/win/win_logger.h
index 67e4590..1460ba8 100644
--- a/src/rocksdb/port/win/win_logger.h
+++ b/src/rocksdb/port/win/win_logger.h
@@ -16,6 +16,9 @@
 
 #include "rocksdb/env.h"
 
+#include <stdint.h>
+#include <Windows.h>
+
 namespace rocksdb {
 
 class Env;
diff --git a/src/rocksdb/src.mk b/src/rocksdb/src.mk
index 5e9ed16..40f7f0d 100644
--- a/src/rocksdb/src.mk
+++ b/src/rocksdb/src.mk
@@ -46,6 +46,9 @@ LIB_SOURCES =                                                   \
   db/write_batch_base.cc                                        \
   db/write_controller.cc                                        \
   db/write_thread.cc                                            \
+  memtable/hash_cuckoo_rep.cc                                   \
+  memtable/hash_linklist_rep.cc                                 \
+  memtable/hash_skiplist_rep.cc                                 \
   port/stack_trace.cc                                           \
   port/port_posix.cc                                            \
   table/adaptive_table_factory.cc                               \
@@ -92,13 +95,12 @@ LIB_SOURCES =                                                   \
   util/env.cc                                                   \
   util/env_hdfs.cc                                              \
   util/env_posix.cc                                             \
+  util/io_posix.cc                                              \
+  util/thread_posix.cc                                          \
   util/file_util.cc                                             \
   util/file_reader_writer.cc                                    \
   util/filter_policy.cc                                         \
   util/hash.cc                                                  \
-  util/hash_cuckoo_rep.cc                                       \
-  util/hash_linklist_rep.cc                                     \
-  util/hash_skiplist_rep.cc                                     \
   util/histogram.cc                                             \
   util/instrumented_mutex.cc                                    \
   util/iostats_context.cc                                       \
@@ -109,13 +111,16 @@ LIB_SOURCES =                                                   \
   utilities/document/document_db.cc                             \
   utilities/document/json_document_builder.cc                   \
   utilities/document/json_document.cc                           \
+  utilities/env_mirror.cc                                       \
   utilities/flashcache/flashcache.cc                            \
   utilities/geodb/geodb_impl.cc                                 \
   utilities/leveldb_options/leveldb_options.cc                  \
+  utilities/memory/memory_util.cc                               \
   utilities/merge_operators/put.cc                              \
   utilities/merge_operators/string_append/stringappend2.cc      \
   utilities/merge_operators/string_append/stringappend.cc       \
   utilities/merge_operators/uint64add.cc                        \
+  utilities/options/options_util.cc                             \
   utilities/redis/redis_lists.cc                                \
   utilities/spatialdb/spatial_db.cc                             \
   utilities/table_properties_collectors/compact_on_deletion_collector.cc \
@@ -136,12 +141,14 @@ LIB_SOURCES =                                                   \
   util/memenv.cc                                                \
   util/murmurhash.cc                                            \
   util/mutable_cf_options.cc                                    \
-  util/options_builder.cc                                       \
   util/options.cc                                               \
+  util/options_builder.cc                                       \
   util/options_helper.cc                                        \
   util/options_parser.cc                                        \
+  util/options_sanity_check.cc                                  \
   util/perf_context.cc                                          \
   util/perf_level.cc                                            \
+  util/random.cc                                                \
   util/rate_limiter.cc                                          \
   util/skiplistrep.cc                                           \
   util/slice.cc                                                 \
@@ -161,9 +168,9 @@ LIB_SOURCES =                                                   \
   util/xxhash.cc                                                \
 
 TOOL_SOURCES = \
-  util/ldb_cmd.cc                                               \
-  util/ldb_tool.cc                                              \
-  util/sst_dump_tool.cc                                         \
+  tools/ldb_cmd.cc                                               \
+  tools/ldb_tool.cc                                              \
+  tools/sst_dump_tool.cc                                         \
 
 MOCK_SOURCES = \
   table/mock_table.cc \
@@ -190,21 +197,26 @@ TEST_BENCH_SOURCES =                                                    \
   db/db_universal_compaction_test.cc                                    \
   db/db_tailing_iter_test.cc                                            \
   db/db_wal_test.cc                                                     \
+  db/db_table_properties_test.cc                                        \
   db/deletefile_test.cc                                                 \
   db/fault_injection_test.cc                                            \
   db/file_indexer_test.cc                                               \
   db/filename_test.cc                                                   \
   db/flush_job_test.cc                                                  \
+  db/inlineskiplist_test.cc                                             \
   db/listener_test.cc                                                   \
   db/log_and_apply_bench.cc                                             \
   db/log_test.cc                                                        \
+  db/manual_compaction_test.cc                                          \
   db/memtablerep_bench.cc                                               \
   db/merge_test.cc                                                      \
+  db/options_file_test.cc                                               \
   db/perf_context_test.cc                                               \
   db/plain_table_db_test.cc                                             \
   db/prefix_test.cc                                                     \
   db/skiplist_test.cc                                                   \
   db/table_properties_collector_test.cc                                 \
+  db/db_test_util.cc                                                    \
   db/version_builder_test.cc                                            \
   db/version_edit_test.cc                                               \
   db/version_set_test.cc                                                \
@@ -222,7 +234,9 @@ TEST_BENCH_SOURCES =                                                    \
   table/table_reader_bench.cc                                           \
   table/table_test.cc                                                   \
   tools/db_sanity_test.cc                                               \
+  tools/ldb_cmd_test.cc                                                 \
   tools/reduce_levels_test.cc                                           \
+  tools/sst_dump_test.cc                                                \
   util/arena_test.cc                                                    \
   util/auto_roll_logger_test.cc                                         \
   util/autovector_test.cc                                               \
@@ -233,7 +247,6 @@ TEST_BENCH_SOURCES =                                                    \
   util/cache_test.cc                                                    \
   util/coding_test.cc                                                   \
   util/crc32c_test.cc                                                   \
-  util/db_test_util.cc                                                  \
   util/dynamic_bloom_test.cc                                            \
   util/env_test.cc                                                      \
   util/filelock_test.cc                                                 \
@@ -243,7 +256,9 @@ TEST_BENCH_SOURCES =                                                    \
   utilities/document/document_db_test.cc                                \
   utilities/document/json_document_test.cc                              \
   utilities/geodb/geodb_test.cc                                         \
+  utilities/memory/memory_test.cc                                       \
   utilities/merge_operators/string_append/stringappend_test.cc          \
+  utilities/options_util_test.cc                                        \
   utilities/redis/redis_lists_test.cc                                   \
   utilities/spatialdb/spatial_db_test.cc                                \
   utilities/table_properties_collectors/compact_on_deletion_collector_test.cc  \
@@ -252,19 +267,16 @@ TEST_BENCH_SOURCES =                                                    \
   utilities/ttl/ttl_test.cc                                             \
   utilities/write_batch_with_index/write_batch_with_index_test.cc       \
   util/log_write_bench.cc                                               \
-  util/manual_compaction_test.cc                                        \
   util/memenv_test.cc                                                   \
   util/mock_env_test.cc                                                 \
   util/options_test.cc                                                  \
   util/event_logger_test.cc                                             \
   util/rate_limiter_test.cc                                             \
   util/slice_transform_test.cc                                          \
-  util/sst_dump_test.cc                                                 \
   util/testharness.cc                                                   \
   util/testutil.cc                                                      \
   util/thread_list_test.cc                                              \
-  util/thread_local_test.cc                                             \
-  util/ldb_cmd_test.cc
+  util/thread_local_test.cc
 
 JNI_NATIVE_SOURCES =                                          \
   java/rocksjni/backupenginejni.cc                            \
diff --git a/src/rocksdb/table/adaptive_table_factory.cc b/src/rocksdb/table/adaptive_table_factory.cc
index c589c07..3e2cfa3 100644
--- a/src/rocksdb/table/adaptive_table_factory.cc
+++ b/src/rocksdb/table/adaptive_table_factory.cc
@@ -66,9 +66,10 @@ Status AdaptiveTableFactory::NewTableReader(
 }
 
 TableBuilder* AdaptiveTableFactory::NewTableBuilder(
-    const TableBuilderOptions& table_builder_options,
+    const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
     WritableFileWriter* file) const {
-  return table_factory_to_write_->NewTableBuilder(table_builder_options, file);
+  return table_factory_to_write_->NewTableBuilder(table_builder_options,
+                                                  column_family_id, file);
 }
 
 std::string AdaptiveTableFactory::GetPrintableTableOptions() const {
diff --git a/src/rocksdb/table/adaptive_table_factory.h b/src/rocksdb/table/adaptive_table_factory.h
index dfcae14..955ded4 100644
--- a/src/rocksdb/table/adaptive_table_factory.h
+++ b/src/rocksdb/table/adaptive_table_factory.h
@@ -40,7 +40,7 @@ class AdaptiveTableFactory : public TableFactory {
 
   TableBuilder* NewTableBuilder(
       const TableBuilderOptions& table_builder_options,
-      WritableFileWriter* file) const override;
+      uint32_t column_family_id, WritableFileWriter* file) const override;
 
   // Sanitizes the specified DB Options.
   Status SanitizeOptions(const DBOptions& db_opts,
diff --git a/src/rocksdb/table/block.cc b/src/rocksdb/table/block.cc
index 99c76f6..9e72a0b 100644
--- a/src/rocksdb/table/block.cc
+++ b/src/rocksdb/table/block.cc
@@ -316,14 +316,14 @@ Block::Block(BlockContents&& contents)
   }
 }
 
-Iterator* Block::NewIterator(
-    const Comparator* cmp, BlockIter* iter, bool total_order_seek) {
+InternalIterator* Block::NewIterator(const Comparator* cmp, BlockIter* iter,
+                                     bool total_order_seek) {
   if (size_ < 2*sizeof(uint32_t)) {
     if (iter != nullptr) {
       iter->SetStatus(Status::Corruption("bad block contents"));
       return iter;
     } else {
-      return NewErrorIterator(Status::Corruption("bad block contents"));
+      return NewErrorInternalIterator(Status::Corruption("bad block contents"));
     }
   }
   const uint32_t num_restarts = NumRestarts();
@@ -332,7 +332,7 @@ Iterator* Block::NewIterator(
       iter->SetStatus(Status::OK());
       return iter;
     } else {
-      return NewEmptyIterator();
+      return NewEmptyInternalIterator();
     }
   } else {
     BlockHashIndex* hash_index_ptr =
diff --git a/src/rocksdb/table/block.h b/src/rocksdb/table/block.h
index 2ce48d3..0a37b90 100644
--- a/src/rocksdb/table/block.h
+++ b/src/rocksdb/table/block.h
@@ -19,6 +19,7 @@
 #include "db/dbformat.h"
 #include "table/block_prefix_index.h"
 #include "table/block_hash_index.h"
+#include "table/internal_iterator.h"
 
 #include "format.h"
 
@@ -66,8 +67,9 @@ class Block {
   // If total_order_seek is true, hash_index_ and prefix_index_ are ignored.
   // This option only applies for index block. For data block, hash_index_
   // and prefix_index_ are null, so this option does not matter.
-  Iterator* NewIterator(const Comparator* comparator,
-      BlockIter* iter = nullptr, bool total_order_seek = true);
+  InternalIterator* NewIterator(const Comparator* comparator,
+                                BlockIter* iter = nullptr,
+                                bool total_order_seek = true);
   void SetBlockHashIndex(BlockHashIndex* hash_index);
   void SetBlockPrefixIndex(BlockPrefixIndex* prefix_index);
 
@@ -87,7 +89,7 @@ class Block {
   void operator=(const Block&);
 };
 
-class BlockIter : public Iterator {
+class BlockIter : public InternalIterator {
  public:
   BlockIter()
       : comparator_(nullptr),
diff --git a/src/rocksdb/table/block_based_table_builder.cc b/src/rocksdb/table/block_based_table_builder.cc
index e135315..319235f 100644
--- a/src/rocksdb/table/block_based_table_builder.cc
+++ b/src/rocksdb/table/block_based_table_builder.cc
@@ -474,7 +474,8 @@ struct BlockBasedTableBuilder::Rep {
       const InternalKeyComparator& icomparator,
       const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
           int_tbl_prop_collector_factories,
-      WritableFileWriter* f, const CompressionType _compression_type,
+      uint32_t column_family_id, WritableFileWriter* f,
+      const CompressionType _compression_type,
       const CompressionOptions& _compression_opts, const bool skip_filters)
       : ioptions(_ioptions),
         table_options(table_opt),
@@ -494,7 +495,7 @@ struct BlockBasedTableBuilder::Rep {
                 table_options, data_block)) {
     for (auto& collector_factories : *int_tbl_prop_collector_factories) {
       table_properties_collectors.emplace_back(
-          collector_factories->CreateIntTblPropCollector());
+          collector_factories->CreateIntTblPropCollector(column_family_id));
     }
     table_properties_collectors.emplace_back(
         new BlockBasedTablePropertiesCollector(
@@ -509,7 +510,8 @@ BlockBasedTableBuilder::BlockBasedTableBuilder(
     const InternalKeyComparator& internal_comparator,
     const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
         int_tbl_prop_collector_factories,
-    WritableFileWriter* file, const CompressionType compression_type,
+    uint32_t column_family_id, WritableFileWriter* file,
+    const CompressionType compression_type,
     const CompressionOptions& compression_opts, const bool skip_filters) {
   BlockBasedTableOptions sanitized_table_options(table_options);
   if (sanitized_table_options.format_version == 0 &&
@@ -523,8 +525,8 @@ BlockBasedTableBuilder::BlockBasedTableBuilder(
   }
 
   rep_ = new Rep(ioptions, sanitized_table_options, internal_comparator,
-                 int_tbl_prop_collector_factories, file, compression_type,
-                 compression_opts, skip_filters);
+                 int_tbl_prop_collector_factories, column_family_id, file,
+                 compression_type, compression_opts, skip_filters);
 
   if (rep_->filter_block != nullptr) {
     rep_->filter_block->StartBlock(0);
@@ -590,7 +592,7 @@ void BlockBasedTableBuilder::Flush() {
   if (!ok()) return;
   if (r->data_block.empty()) return;
   WriteBlock(&r->data_block, &r->pending_handle);
-  if (ok()) {
+  if (ok() && !r->table_options.skip_table_builder_flush) {
     r->status = r->file->Flush();
   }
   if (r->filter_block != nullptr) {
@@ -871,8 +873,9 @@ TableProperties BlockBasedTableBuilder::GetTableProperties() const {
   TableProperties ret = rep_->props;
   for (const auto& collector : rep_->table_properties_collectors) {
     for (const auto& prop : collector->GetReadableProperties()) {
-      ret.user_collected_properties.insert(prop);
+      ret.readable_properties.insert(prop);
     }
+    collector->Finish(&ret.user_collected_properties);
   }
   return ret;
 }
diff --git a/src/rocksdb/table/block_based_table_builder.h b/src/rocksdb/table/block_based_table_builder.h
index ce86820..7dc93b7 100644
--- a/src/rocksdb/table/block_based_table_builder.h
+++ b/src/rocksdb/table/block_based_table_builder.h
@@ -40,7 +40,8 @@ class BlockBasedTableBuilder : public TableBuilder {
       const InternalKeyComparator& internal_comparator,
       const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
           int_tbl_prop_collector_factories,
-      WritableFileWriter* file, const CompressionType compression_type,
+      uint32_t column_family_id, WritableFileWriter* file,
+      const CompressionType compression_type,
       const CompressionOptions& compression_opts, const bool skip_filters);
 
   // REQUIRES: Either Finish() or Abandon() has been called.
diff --git a/src/rocksdb/table/block_based_table_factory.cc b/src/rocksdb/table/block_based_table_factory.cc
index ea910c6..3ddb46b 100644
--- a/src/rocksdb/table/block_based_table_factory.cc
+++ b/src/rocksdb/table/block_based_table_factory.cc
@@ -24,8 +24,8 @@
 namespace rocksdb {
 
 BlockBasedTableFactory::BlockBasedTableFactory(
-    const BlockBasedTableOptions& table_options)
-    : table_options_(table_options) {
+    const BlockBasedTableOptions& _table_options)
+    : table_options_(_table_options) {
   if (table_options_.flush_block_policy_factory == nullptr) {
     table_options_.flush_block_policy_factory.reset(
         new FlushBlockBySizePolicyFactory());
@@ -61,13 +61,13 @@ Status BlockBasedTableFactory::NewTableReader(
 }
 
 TableBuilder* BlockBasedTableFactory::NewTableBuilder(
-    const TableBuilderOptions& table_builder_options,
+    const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
     WritableFileWriter* file) const {
   auto table_builder = new BlockBasedTableBuilder(
       table_builder_options.ioptions, table_options_,
       table_builder_options.internal_comparator,
-      table_builder_options.int_tbl_prop_collector_factories, file,
-      table_builder_options.compression_type,
+      table_builder_options.int_tbl_prop_collector_factories, column_family_id,
+      file, table_builder_options.compression_type,
       table_builder_options.compression_opts,
       table_builder_options.skip_filters);
 
@@ -152,19 +152,23 @@ std::string BlockBasedTableFactory::GetPrintableTableOptions() const {
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  whole_key_filtering: %d\n",
            table_options_.whole_key_filtering);
+  ret.append(buffer);
+  snprintf(buffer, kBufferSize, "  skip_table_builder_flush: %d\n",
+           table_options_.skip_table_builder_flush);
+  ret.append(buffer);
   snprintf(buffer, kBufferSize, "  format_version: %d\n",
            table_options_.format_version);
   ret.append(buffer);
   return ret;
 }
 
-const BlockBasedTableOptions& BlockBasedTableFactory::GetTableOptions() const {
+const BlockBasedTableOptions& BlockBasedTableFactory::table_options() const {
   return table_options_;
 }
 
 TableFactory* NewBlockBasedTableFactory(
-    const BlockBasedTableOptions& table_options) {
-  return new BlockBasedTableFactory(table_options);
+    const BlockBasedTableOptions& _table_options) {
+  return new BlockBasedTableFactory(_table_options);
 }
 
 const std::string BlockBasedTablePropertyNames::kIndexType =
diff --git a/src/rocksdb/table/block_based_table_factory.h b/src/rocksdb/table/block_based_table_factory.h
index 8bdd4cd..714a4f8 100644
--- a/src/rocksdb/table/block_based_table_factory.h
+++ b/src/rocksdb/table/block_based_table_factory.h
@@ -48,7 +48,7 @@ class BlockBasedTableFactory : public TableFactory {
 
   TableBuilder* NewTableBuilder(
       const TableBuilderOptions& table_builder_options,
-      WritableFileWriter* file) const override;
+      uint32_t column_family_id, WritableFileWriter* file) const override;
 
   // Sanitizes the specified DB Options.
   Status SanitizeOptions(const DBOptions& db_opts,
@@ -56,7 +56,9 @@ class BlockBasedTableFactory : public TableFactory {
 
   std::string GetPrintableTableOptions() const override;
 
-  const BlockBasedTableOptions& GetTableOptions() const;
+  const BlockBasedTableOptions& table_options() const;
+
+  void* GetOptions() override { return &table_options_; }
 
  private:
   BlockBasedTableOptions table_options_;
diff --git a/src/rocksdb/table/block_based_table_reader.cc b/src/rocksdb/table/block_based_table_reader.cc
index b113272..ad38372 100644
--- a/src/rocksdb/table/block_based_table_reader.cc
+++ b/src/rocksdb/table/block_based_table_reader.cc
@@ -32,6 +32,7 @@
 #include "table/block_hash_index.h"
 #include "table/block_prefix_index.h"
 #include "table/format.h"
+#include "table/internal_iterator.h"
 #include "table/meta_blocks.h"
 #include "table/two_level_iterator.h"
 #include "table/get_context.h"
@@ -146,8 +147,8 @@ class BlockBasedTable::IndexReader {
   // Create an iterator for index access.
   // An iter is passed in, if it is not null, update this one and return it
   // If it is null, create a new Iterator
-  virtual Iterator* NewIterator(
-      BlockIter* iter = nullptr, bool total_order_seek = true) = 0;
+  virtual InternalIterator* NewIterator(BlockIter* iter = nullptr,
+                                        bool total_order_seek = true) = 0;
 
   // The size of the index.
   virtual size_t size() const = 0;
@@ -187,8 +188,8 @@ class BinarySearchIndexReader : public IndexReader {
     return s;
   }
 
-  virtual Iterator* NewIterator(
-      BlockIter* iter = nullptr, bool dont_care = true) override {
+  virtual InternalIterator* NewIterator(BlockIter* iter = nullptr,
+                                        bool dont_care = true) override {
     return index_block_->NewIterator(comparator_, iter, true);
   }
 
@@ -219,7 +220,8 @@ class HashIndexReader : public IndexReader {
                        const Footer& footer, RandomAccessFileReader* file,
                        Env* env, const Comparator* comparator,
                        const BlockHandle& index_handle,
-                       Iterator* meta_index_iter, IndexReader** index_reader,
+                       InternalIterator* meta_index_iter,
+                       IndexReader** index_reader,
                        bool hash_index_allow_collision) {
     std::unique_ptr<Block> index_block;
     auto s = ReadBlockFromFile(file, footer, ReadOptions(), index_handle,
@@ -298,8 +300,8 @@ class HashIndexReader : public IndexReader {
     return Status::OK();
   }
 
-  virtual Iterator* NewIterator(
-      BlockIter* iter = nullptr, bool total_order_seek = true) override {
+  virtual InternalIterator* NewIterator(BlockIter* iter = nullptr,
+                                        bool total_order_seek = true) override {
     return index_block_->NewIterator(comparator_, iter, total_order_seek);
   }
 
@@ -512,7 +514,7 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions,
 
   // Read meta index
   std::unique_ptr<Block> meta;
-  std::unique_ptr<Iterator> meta_iter;
+  std::unique_ptr<InternalIterator> meta_iter;
   s = ReadMetaBlock(rep, &meta, &meta_iter);
   if (!s.ok()) {
     return s;
@@ -580,7 +582,8 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions,
       assert(table_options.block_cache != nullptr);
       // Hack: Call NewIndexIterator() to implicitly add index to the
       // block_cache
-      unique_ptr<Iterator> iter(new_table->NewIndexIterator(ReadOptions()));
+      unique_ptr<InternalIterator> iter(
+          new_table->NewIndexIterator(ReadOptions()));
       s = iter->status();
 
       if (s.ok()) {
@@ -652,10 +655,9 @@ size_t BlockBasedTable::ApproximateMemoryUsage() const {
 
 // Load the meta-block from the file. On success, return the loaded meta block
 // and its iterator.
-Status BlockBasedTable::ReadMetaBlock(
-    Rep* rep,
-    std::unique_ptr<Block>* meta_block,
-    std::unique_ptr<Iterator>* iter) {
+Status BlockBasedTable::ReadMetaBlock(Rep* rep,
+                                      std::unique_ptr<Block>* meta_block,
+                                      std::unique_ptr<InternalIterator>* iter) {
   // TODO(sanjay): Skip this if footer.metaindex_handle() size indicates
   // it is an empty block.
   //  TODO: we never really verify check sum for meta index block
@@ -898,8 +900,8 @@ BlockBasedTable::CachableEntry<FilterBlockReader> BlockBasedTable::GetFilter(
   return { filter, cache_handle };
 }
 
-Iterator* BlockBasedTable::NewIndexIterator(const ReadOptions& read_options,
-        BlockIter* input_iter) {
+InternalIterator* BlockBasedTable::NewIndexIterator(
+    const ReadOptions& read_options, BlockIter* input_iter) {
   // index reader has already been pre-populated.
   if (rep_->index_reader) {
     return rep_->index_reader->NewIterator(
@@ -922,7 +924,7 @@ Iterator* BlockBasedTable::NewIndexIterator(const ReadOptions& read_options,
       input_iter->SetStatus(Status::Incomplete("no blocking io"));
       return input_iter;
     } else {
-      return NewErrorIterator(Status::Incomplete("no blocking io"));
+      return NewErrorInternalIterator(Status::Incomplete("no blocking io"));
     }
   }
 
@@ -942,7 +944,7 @@ Iterator* BlockBasedTable::NewIndexIterator(const ReadOptions& read_options,
         input_iter->SetStatus(s);
         return input_iter;
       } else {
-        return NewErrorIterator(s);
+        return NewErrorInternalIterator(s);
       }
     }
 
@@ -965,8 +967,8 @@ Iterator* BlockBasedTable::NewIndexIterator(const ReadOptions& read_options,
 // into an iterator over the contents of the corresponding block.
 // If input_iter is null, new a iterator
 // If input_iter is not null, update this iter and return it
-Iterator* BlockBasedTable::NewDataBlockIterator(Rep* rep,
-    const ReadOptions& ro, const Slice& index_value,
+InternalIterator* BlockBasedTable::NewDataBlockIterator(
+    Rep* rep, const ReadOptions& ro, const Slice& index_value,
     BlockIter* input_iter) {
   PERF_TIMER_GUARD(new_table_block_iter_nanos);
 
@@ -987,7 +989,7 @@ Iterator* BlockBasedTable::NewDataBlockIterator(Rep* rep,
       input_iter->SetStatus(s);
       return input_iter;
     } else {
-      return NewErrorIterator(s);
+      return NewErrorInternalIterator(s);
     }
   }
 
@@ -1040,7 +1042,7 @@ Iterator* BlockBasedTable::NewDataBlockIterator(Rep* rep,
         input_iter->SetStatus(Status::Incomplete("no blocking io"));
         return input_iter;
       } else {
-        return NewErrorIterator(Status::Incomplete("no blocking io"));
+        return NewErrorInternalIterator(Status::Incomplete("no blocking io"));
       }
     }
     std::unique_ptr<Block> block_value;
@@ -1051,7 +1053,7 @@ Iterator* BlockBasedTable::NewDataBlockIterator(Rep* rep,
     }
   }
 
-  Iterator* iter;
+  InternalIterator* iter;
   if (block.value != nullptr) {
     iter = block.value->NewIterator(&rep->internal_comparator, input_iter);
     if (block.cache_handle != nullptr) {
@@ -1065,7 +1067,7 @@ Iterator* BlockBasedTable::NewDataBlockIterator(Rep* rep,
       input_iter->SetStatus(s);
       iter = input_iter;
     } else {
-      iter = NewErrorIterator(s);
+      iter = NewErrorInternalIterator(s);
     }
   }
   return iter;
@@ -1080,7 +1082,7 @@ class BlockBasedTable::BlockEntryIteratorState : public TwoLevelIteratorState {
         table_(table),
         read_options_(read_options) {}
 
-  Iterator* NewSecondaryIterator(const Slice& index_value) override {
+  InternalIterator* NewSecondaryIterator(const Slice& index_value) override {
     return NewDataBlockIterator(table_->rep_, read_options_, index_value);
   }
 
@@ -1138,7 +1140,7 @@ bool BlockBasedTable::PrefixMayMatch(const Slice& internal_key) {
 
   // Then, try find it within each block
   if (may_match) {
-    unique_ptr<Iterator> iiter(NewIndexIterator(no_io_read_options));
+    unique_ptr<InternalIterator> iiter(NewIndexIterator(no_io_read_options));
     iiter->Seek(internal_prefix);
 
     if (!iiter->Valid()) {
@@ -1184,8 +1186,8 @@ bool BlockBasedTable::PrefixMayMatch(const Slice& internal_key) {
   return may_match;
 }
 
-Iterator* BlockBasedTable::NewIterator(const ReadOptions& read_options,
-                                       Arena* arena) {
+InternalIterator* BlockBasedTable::NewIterator(const ReadOptions& read_options,
+                                               Arena* arena) {
   return NewTwoLevelIterator(new BlockEntryIteratorState(this, read_options),
                              NewIndexIterator(read_options), arena);
 }
@@ -1326,7 +1328,7 @@ Status BlockBasedTable::Prefetch(const Slice* const begin,
 
 bool BlockBasedTable::TEST_KeyInCache(const ReadOptions& options,
                                       const Slice& key) {
-  std::unique_ptr<Iterator> iiter(NewIndexIterator(options));
+  std::unique_ptr<InternalIterator> iiter(NewIndexIterator(options));
   iiter->Seek(key);
   assert(iiter->Valid());
   CachableEntry<Block> block;
@@ -1361,8 +1363,8 @@ bool BlockBasedTable::TEST_KeyInCache(const ReadOptions& options,
 //  3. options
 //  4. internal_comparator
 //  5. index_type
-Status BlockBasedTable::CreateIndexReader(IndexReader** index_reader,
-                                          Iterator* preloaded_meta_index_iter) {
+Status BlockBasedTable::CreateIndexReader(
+    IndexReader** index_reader, InternalIterator* preloaded_meta_index_iter) {
   // Some old version of block-based tables don't have index type present in
   // table properties. If that's the case we can safely use the kBinarySearch.
   auto index_type_on_file = BlockBasedTableOptions::kBinarySearch;
@@ -1396,7 +1398,7 @@ Status BlockBasedTable::CreateIndexReader(IndexReader** index_reader,
     }
     case BlockBasedTableOptions::kHashSearch: {
       std::unique_ptr<Block> meta_guard;
-      std::unique_ptr<Iterator> meta_iter_guard;
+      std::unique_ptr<InternalIterator> meta_iter_guard;
       auto meta_index_iter = preloaded_meta_index_iter;
       if (meta_index_iter == nullptr) {
         auto s = ReadMetaBlock(rep_, &meta_guard, &meta_iter_guard);
@@ -1430,7 +1432,7 @@ Status BlockBasedTable::CreateIndexReader(IndexReader** index_reader,
 }
 
 uint64_t BlockBasedTable::ApproximateOffsetOf(const Slice& key) {
-  unique_ptr<Iterator> index_iter(NewIndexIterator(ReadOptions()));
+  unique_ptr<InternalIterator> index_iter(NewIndexIterator(ReadOptions()));
 
   index_iter->Seek(key);
   uint64_t result;
@@ -1484,7 +1486,7 @@ Status BlockBasedTable::DumpTable(WritableFile* out_file) {
       "Metaindex Details:\n"
       "--------------------------------------\n");
   std::unique_ptr<Block> meta;
-  std::unique_ptr<Iterator> meta_iter;
+  std::unique_ptr<InternalIterator> meta_iter;
   Status s = ReadMetaBlock(rep_, &meta, &meta_iter);
   if (s.ok()) {
     for (meta_iter->SeekToFirst(); meta_iter->Valid(); meta_iter->Next()) {
@@ -1567,7 +1569,8 @@ Status BlockBasedTable::DumpIndexBlock(WritableFile* out_file) {
       "Index Details:\n"
       "--------------------------------------\n");
 
-  std::unique_ptr<Iterator> blockhandles_iter(NewIndexIterator(ReadOptions()));
+  std::unique_ptr<InternalIterator> blockhandles_iter(
+      NewIndexIterator(ReadOptions()));
   Status s = blockhandles_iter->status();
   if (!s.ok()) {
     out_file->Append("Can not read Index Block \n\n");
@@ -1608,7 +1611,8 @@ Status BlockBasedTable::DumpIndexBlock(WritableFile* out_file) {
 }
 
 Status BlockBasedTable::DumpDataBlocks(WritableFile* out_file) {
-  std::unique_ptr<Iterator> blockhandles_iter(NewIndexIterator(ReadOptions()));
+  std::unique_ptr<InternalIterator> blockhandles_iter(
+      NewIndexIterator(ReadOptions()));
   Status s = blockhandles_iter->status();
   if (!s.ok()) {
     out_file->Append("Can not read Index Block \n\n");
@@ -1630,7 +1634,7 @@ Status BlockBasedTable::DumpDataBlocks(WritableFile* out_file) {
     out_file->Append("\n");
     out_file->Append("--------------------------------------\n");
 
-    std::unique_ptr<Iterator> datablock_iter;
+    std::unique_ptr<InternalIterator> datablock_iter;
     datablock_iter.reset(
         NewDataBlockIterator(rep_, ReadOptions(), blockhandles_iter->value()));
     s = datablock_iter->status();
diff --git a/src/rocksdb/table/block_based_table_reader.h b/src/rocksdb/table/block_based_table_reader.h
index d81f610..4e095cb 100644
--- a/src/rocksdb/table/block_based_table_reader.h
+++ b/src/rocksdb/table/block_based_table_reader.h
@@ -43,6 +43,7 @@ struct BlockBasedTableOptions;
 struct EnvOptions;
 struct ReadOptions;
 class GetContext;
+class InternalIterator;
 
 using std::unique_ptr;
 
@@ -79,7 +80,8 @@ class BlockBasedTable : public TableReader {
   // Returns a new iterator over the table contents.
   // The result of NewIterator() is initially invalid (caller must
   // call one of the Seek methods on the iterator before using it).
-  Iterator* NewIterator(const ReadOptions&, Arena* arena = nullptr) override;
+  InternalIterator* NewIterator(const ReadOptions&,
+                                Arena* arena = nullptr) override;
 
   Status Get(const ReadOptions& readOptions, const Slice& key,
              GetContext* get_context) override;
@@ -129,9 +131,9 @@ class BlockBasedTable : public TableReader {
 
   class BlockEntryIteratorState;
   // input_iter: if it is not null, update this one and return it as Iterator
-  static Iterator* NewDataBlockIterator(Rep* rep, const ReadOptions& ro,
-                                        const Slice& index_value,
-                                        BlockIter* input_iter = nullptr);
+  static InternalIterator* NewDataBlockIterator(
+      Rep* rep, const ReadOptions& ro, const Slice& index_value,
+      BlockIter* input_iter = nullptr);
 
   // For the following two functions:
   // if `no_io == true`, we will not try to read filter/index from sst file
@@ -148,8 +150,8 @@ class BlockBasedTable : public TableReader {
   //  2. index is not present in block cache.
   //  3. We disallowed any io to be performed, that is, read_options ==
   //     kBlockCacheTier
-  Iterator* NewIndexIterator(const ReadOptions& read_options,
-                             BlockIter* input_iter = nullptr);
+  InternalIterator* NewIndexIterator(const ReadOptions& read_options,
+                                     BlockIter* input_iter = nullptr);
 
   // Read block cache from block caches (if set): block_cache and
   // block_cache_compressed.
@@ -186,17 +188,16 @@ class BlockBasedTable : public TableReader {
   // Optionally, user can pass a preloaded meta_index_iter for the index that
   // need to access extra meta blocks for index construction. This parameter
   // helps avoid re-reading meta index block if caller already created one.
-  Status CreateIndexReader(IndexReader** index_reader,
-                           Iterator* preloaded_meta_index_iter = nullptr);
+  Status CreateIndexReader(
+      IndexReader** index_reader,
+      InternalIterator* preloaded_meta_index_iter = nullptr);
 
   bool FullFilterKeyMayMatch(FilterBlockReader* filter,
                              const Slice& user_key) const;
 
   // Read the meta block from sst.
-  static Status ReadMetaBlock(
-      Rep* rep,
-      std::unique_ptr<Block>* meta_block,
-      std::unique_ptr<Iterator>* iter);
+  static Status ReadMetaBlock(Rep* rep, std::unique_ptr<Block>* meta_block,
+                              std::unique_ptr<InternalIterator>* iter);
 
   // Create the filter from the filter block.
   static FilterBlockReader* ReadFilter(Rep* rep, size_t* filter_size = nullptr);
diff --git a/src/rocksdb/table/block_hash_index.cc b/src/rocksdb/table/block_hash_index.cc
index fd13296..b38cc8a 100644
--- a/src/rocksdb/table/block_hash_index.cc
+++ b/src/rocksdb/table/block_hash_index.cc
@@ -10,6 +10,7 @@
 #include "rocksdb/comparator.h"
 #include "rocksdb/iterator.h"
 #include "rocksdb/slice_transform.h"
+#include "table/internal_iterator.h"
 #include "util/coding.h"
 
 namespace rocksdb {
@@ -53,8 +54,9 @@ Status CreateBlockHashIndex(const SliceTransform* hash_key_extractor,
 }
 
 BlockHashIndex* CreateBlockHashIndexOnTheFly(
-    Iterator* index_iter, Iterator* data_iter, const uint32_t num_restarts,
-    const Comparator* comparator, const SliceTransform* hash_key_extractor) {
+    InternalIterator* index_iter, InternalIterator* data_iter,
+    const uint32_t num_restarts, const Comparator* comparator,
+    const SliceTransform* hash_key_extractor) {
   assert(hash_key_extractor);
   auto hash_index = new BlockHashIndex(
       hash_key_extractor,
diff --git a/src/rocksdb/table/block_hash_index.h b/src/rocksdb/table/block_hash_index.h
index 5829107..fc110d5 100644
--- a/src/rocksdb/table/block_hash_index.h
+++ b/src/rocksdb/table/block_hash_index.h
@@ -14,7 +14,7 @@
 namespace rocksdb {
 
 class Comparator;
-class Iterator;
+class InternalIterator;
 class Slice;
 class SliceTransform;
 
@@ -79,7 +79,8 @@ Status CreateBlockHashIndex(const SliceTransform* hash_key_extractor,
 // @params hash_key_extractor: extract the hashable part of a given key.
 // On error, nullptr will be returned.
 BlockHashIndex* CreateBlockHashIndexOnTheFly(
-    Iterator* index_iter, Iterator* data_iter, const uint32_t num_restarts,
-    const Comparator* comparator, const SliceTransform* hash_key_extractor);
+    InternalIterator* index_iter, InternalIterator* data_iter,
+    const uint32_t num_restarts, const Comparator* comparator,
+    const SliceTransform* hash_key_extractor);
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/table/block_hash_index_test.cc b/src/rocksdb/table/block_hash_index_test.cc
index b001c20..ffca663 100644
--- a/src/rocksdb/table/block_hash_index_test.cc
+++ b/src/rocksdb/table/block_hash_index_test.cc
@@ -11,6 +11,7 @@
 #include "rocksdb/iterator.h"
 #include "rocksdb/slice_transform.h"
 #include "table/block_hash_index.h"
+#include "table/internal_iterator.h"
 #include "util/testharness.h"
 #include "util/testutil.h"
 
@@ -18,7 +19,7 @@ namespace rocksdb {
 
 typedef std::map<std::string, std::string> Data;
 
-class MapIterator : public Iterator {
+class MapIterator : public InternalIterator {
  public:
   explicit MapIterator(const Data& data) : data_(data), pos_(data_.end()) {}
 
diff --git a/src/rocksdb/table/block_test.cc b/src/rocksdb/table/block_test.cc
index c86f38d..e9c0179 100644
--- a/src/rocksdb/table/block_test.cc
+++ b/src/rocksdb/table/block_test.cc
@@ -96,7 +96,7 @@ TEST_F(BlockTest, SimpleTest) {
 
   // read contents of block sequentially
   int count = 0;
-  Iterator* iter = reader.NewIterator(options.comparator);
+  InternalIterator *iter = reader.NewIterator(options.comparator);
   for (iter->SeekToFirst();iter->Valid(); count++, iter->Next()) {
 
     // read kv from block
@@ -170,10 +170,10 @@ void CheckBlockContents(BlockContents contents, const int max_key,
     delete iter2;
   }
 
-  std::unique_ptr<Iterator> hash_iter(
+  std::unique_ptr<InternalIterator> hash_iter(
       reader1.NewIterator(BytewiseComparator(), nullptr, false));
 
-  std::unique_ptr<Iterator> regular_iter(
+  std::unique_ptr<InternalIterator> regular_iter(
       reader2.NewIterator(BytewiseComparator()));
 
   // Seek existent keys
diff --git a/src/rocksdb/table/cuckoo_table_factory.cc b/src/rocksdb/table/cuckoo_table_factory.cc
index 16bf3fb..2b9407f 100644
--- a/src/rocksdb/table/cuckoo_table_factory.cc
+++ b/src/rocksdb/table/cuckoo_table_factory.cc
@@ -27,7 +27,7 @@ Status CuckooTableFactory::NewTableReader(
 }
 
 TableBuilder* CuckooTableFactory::NewTableBuilder(
-    const TableBuilderOptions& table_builder_options,
+    const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
     WritableFileWriter* file) const {
   // Ignore the skipFIlters flag. Does not apply to this file format
   //
diff --git a/src/rocksdb/table/cuckoo_table_factory.h b/src/rocksdb/table/cuckoo_table_factory.h
index 394e834..3f89ca8 100644
--- a/src/rocksdb/table/cuckoo_table_factory.h
+++ b/src/rocksdb/table/cuckoo_table_factory.h
@@ -62,7 +62,7 @@ class CuckooTableFactory : public TableFactory {
 
   TableBuilder* NewTableBuilder(
       const TableBuilderOptions& table_builder_options,
-      WritableFileWriter* file) const override;
+      uint32_t column_family_id, WritableFileWriter* file) const override;
 
   // Sanitizes the specified DB Options.
   Status SanitizeOptions(const DBOptions& db_opts,
@@ -72,8 +72,10 @@ class CuckooTableFactory : public TableFactory {
 
   std::string GetPrintableTableOptions() const override;
 
+  void* GetOptions() override { return &table_options_; }
+
  private:
-  const CuckooTableOptions table_options_;
+  CuckooTableOptions table_options_;
 };
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/table/cuckoo_table_reader.cc b/src/rocksdb/table/cuckoo_table_reader.cc
index 8c0329c..2d413f0 100644
--- a/src/rocksdb/table/cuckoo_table_reader.cc
+++ b/src/rocksdb/table/cuckoo_table_reader.cc
@@ -17,6 +17,7 @@
 #include <vector>
 #include "rocksdb/iterator.h"
 #include "rocksdb/table.h"
+#include "table/internal_iterator.h"
 #include "table/meta_blocks.h"
 #include "table/cuckoo_table_factory.h"
 #include "table/get_context.h"
@@ -173,7 +174,7 @@ void CuckooTableReader::Prepare(const Slice& key) {
   }
 }
 
-class CuckooTableIterator : public Iterator {
+class CuckooTableIterator : public InternalIterator {
  public:
   explicit CuckooTableIterator(CuckooTableReader* reader);
   ~CuckooTableIterator() {}
@@ -348,16 +349,17 @@ Slice CuckooTableIterator::value() const {
   return curr_value_;
 }
 
-extern Iterator* NewErrorIterator(const Status& status, Arena* arena);
+extern InternalIterator* NewErrorInternalIterator(const Status& status,
+                                                  Arena* arena);
 
-Iterator* CuckooTableReader::NewIterator(
+InternalIterator* CuckooTableReader::NewIterator(
     const ReadOptions& read_options, Arena* arena) {
   if (!status().ok()) {
-    return NewErrorIterator(
+    return NewErrorInternalIterator(
         Status::Corruption("CuckooTableReader status is not okay."), arena);
   }
   if (read_options.total_order_seek) {
-    return NewErrorIterator(
+    return NewErrorInternalIterator(
         Status::InvalidArgument("total_order_seek is not supported."), arena);
   }
   CuckooTableIterator* iter;
diff --git a/src/rocksdb/table/cuckoo_table_reader.h b/src/rocksdb/table/cuckoo_table_reader.h
index 6643be0..ee17dc4 100644
--- a/src/rocksdb/table/cuckoo_table_reader.h
+++ b/src/rocksdb/table/cuckoo_table_reader.h
@@ -24,6 +24,7 @@ namespace rocksdb {
 
 class Arena;
 class TableReader;
+class InternalIterator;
 
 class CuckooTableReader: public TableReader {
  public:
@@ -43,7 +44,8 @@ class CuckooTableReader: public TableReader {
   Status Get(const ReadOptions& read_options, const Slice& key,
              GetContext* get_context) override;
 
-  Iterator* NewIterator(const ReadOptions&, Arena* arena = nullptr) override;
+  InternalIterator* NewIterator(const ReadOptions&,
+                                Arena* arena = nullptr) override;
   void Prepare(const Slice& target) override;
 
   // Report an approximation of how much memory has been used.
diff --git a/src/rocksdb/table/cuckoo_table_reader_test.cc b/src/rocksdb/table/cuckoo_table_reader_test.cc
index f10fcc5..9758af3 100644
--- a/src/rocksdb/table/cuckoo_table_reader_test.cc
+++ b/src/rocksdb/table/cuckoo_table_reader_test.cc
@@ -148,7 +148,7 @@ class CuckooReaderTest : public testing::Test {
     CuckooTableReader reader(ioptions, std::move(file_reader), file_size, ucomp,
                              GetSliceHash);
     ASSERT_OK(reader.status());
-    Iterator* it = reader.NewIterator(ReadOptions(), nullptr);
+    InternalIterator* it = reader.NewIterator(ReadOptions(), nullptr);
     ASSERT_OK(it->status());
     ASSERT_TRUE(!it->Valid());
     it->SeekToFirst();
@@ -196,7 +196,7 @@ class CuckooReaderTest : public testing::Test {
     ASSERT_TRUE(keys[num_items/2] == it->key());
     ASSERT_TRUE(values[num_items/2] == it->value());
     ASSERT_OK(it->status());
-    it->~Iterator();
+    it->~InternalIterator();
   }
 
   std::vector<std::string> keys;
diff --git a/src/rocksdb/include/rocksdb/iterator.h b/src/rocksdb/table/internal_iterator.h
similarity index 59%
copy from src/rocksdb/include/rocksdb/iterator.h
copy to src/rocksdb/table/internal_iterator.h
index 7538e9c..51a1632 100644
--- a/src/rocksdb/include/rocksdb/iterator.h
+++ b/src/rocksdb/table/internal_iterator.h
@@ -2,32 +2,19 @@
 // This source code is licensed under the BSD-style license found in the
 // LICENSE file in the root directory of this source tree. An additional grant
 // of patent rights can be found in the PATENTS file in the same directory.
-// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file. See the AUTHORS file for names of contributors.
 //
-// An iterator yields a sequence of key/value pairs from a source.
-// The following class defines the interface.  Multiple implementations
-// are provided by this library.  In particular, iterators are provided
-// to access the contents of a Table or a DB.
-//
-// Multiple threads can invoke const methods on an Iterator without
-// external synchronization, but if any of the threads may call a
-// non-const method, all threads accessing the same Iterator must use
-// external synchronization.
 
-#ifndef STORAGE_ROCKSDB_INCLUDE_ITERATOR_H_
-#define STORAGE_ROCKSDB_INCLUDE_ITERATOR_H_
+#pragma once
 
-#include "rocksdb/slice.h"
+#include "rocksdb/iterator.h"
 #include "rocksdb/status.h"
 
 namespace rocksdb {
 
-class Iterator {
+class InternalIterator : public Cleanable {
  public:
-  Iterator();
-  virtual ~Iterator();
+  InternalIterator() {}
+  virtual ~InternalIterator() {}
 
   // An iterator is either positioned at a key/value pair, or
   // not valid.  This method returns true iff the iterator is valid.
@@ -73,34 +60,16 @@ class Iterator {
   // satisfied without doing some IO, then this returns Status::Incomplete().
   virtual Status status() const = 0;
 
-  // Clients are allowed to register function/arg1/arg2 triples that
-  // will be invoked when this iterator is destroyed.
-  //
-  // Note that unlike all of the preceding methods, this method is
-  // not abstract and therefore clients should not override it.
-  typedef void (*CleanupFunction)(void* arg1, void* arg2);
-  void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
-
  private:
-  struct Cleanup {
-    CleanupFunction function;
-    void* arg1;
-    void* arg2;
-    Cleanup* next;
-  };
-  Cleanup cleanup_;
-
   // No copying allowed
-  Iterator(const Iterator&);
-  void operator=(const Iterator&);
+  InternalIterator(const InternalIterator&) = delete;
+  InternalIterator& operator=(const InternalIterator&) = delete;
 };
 
 // Return an empty iterator (yields nothing).
-extern Iterator* NewEmptyIterator();
+extern InternalIterator* NewEmptyInternalIterator();
 
 // Return an empty iterator with the specified status.
-extern Iterator* NewErrorIterator(const Status& status);
+extern InternalIterator* NewErrorInternalIterator(const Status& status);
 
 }  // namespace rocksdb
-
-#endif  // STORAGE_ROCKSDB_INCLUDE_ITERATOR_H_
diff --git a/src/rocksdb/table/iterator.cc b/src/rocksdb/table/iterator.cc
index f97879a..2db321e 100644
--- a/src/rocksdb/table/iterator.cc
+++ b/src/rocksdb/table/iterator.cc
@@ -8,17 +8,18 @@
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
 #include "rocksdb/iterator.h"
+#include "table/internal_iterator.h"
 #include "table/iterator_wrapper.h"
 #include "util/arena.h"
 
 namespace rocksdb {
 
-Iterator::Iterator() {
+Cleanable::Cleanable() {
   cleanup_.function = nullptr;
   cleanup_.next = nullptr;
 }
 
-Iterator::~Iterator() {
+Cleanable::~Cleanable() {
   if (cleanup_.function != nullptr) {
     (*cleanup_.function)(cleanup_.arg1, cleanup_.arg2);
     for (Cleanup* c = cleanup_.next; c != nullptr; ) {
@@ -30,7 +31,7 @@ Iterator::~Iterator() {
   }
 }
 
-void Iterator::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) {
+void Cleanable::RegisterCleanup(CleanupFunction func, void* arg1, void* arg2) {
   assert(func != nullptr);
   Cleanup* c;
   if (cleanup_.function == nullptr) {
@@ -68,31 +69,62 @@ class EmptyIterator : public Iterator {
  private:
   Status status_;
 };
+
+class EmptyInternalIterator : public InternalIterator {
+ public:
+  explicit EmptyInternalIterator(const Status& s) : status_(s) {}
+  virtual bool Valid() const override { return false; }
+  virtual void Seek(const Slice& target) override {}
+  virtual void SeekToFirst() override {}
+  virtual void SeekToLast() override {}
+  virtual void Next() override { assert(false); }
+  virtual void Prev() override { assert(false); }
+  Slice key() const override {
+    assert(false);
+    return Slice();
+  }
+  Slice value() const override {
+    assert(false);
+    return Slice();
+  }
+  virtual Status status() const override { return status_; }
+
+ private:
+  Status status_;
+};
 }  // namespace
 
 Iterator* NewEmptyIterator() {
   return new EmptyIterator(Status::OK());
 }
 
-Iterator* NewEmptyIterator(Arena* arena) {
+Iterator* NewErrorIterator(const Status& status) {
+  return new EmptyIterator(status);
+}
+
+InternalIterator* NewEmptyInternalIterator() {
+  return new EmptyInternalIterator(Status::OK());
+}
+
+InternalIterator* NewEmptyInternalIterator(Arena* arena) {
   if (arena == nullptr) {
-    return NewEmptyIterator();
+    return NewEmptyInternalIterator();
   } else {
     auto mem = arena->AllocateAligned(sizeof(EmptyIterator));
-    return new (mem) EmptyIterator(Status::OK());
+    return new (mem) EmptyInternalIterator(Status::OK());
   }
 }
 
-Iterator* NewErrorIterator(const Status& status) {
-  return new EmptyIterator(status);
+InternalIterator* NewErrorInternalIterator(const Status& status) {
+  return new EmptyInternalIterator(status);
 }
 
-Iterator* NewErrorIterator(const Status& status, Arena* arena) {
+InternalIterator* NewErrorInternalIterator(const Status& status, Arena* arena) {
   if (arena == nullptr) {
-    return NewErrorIterator(status);
+    return NewErrorInternalIterator(status);
   } else {
     auto mem = arena->AllocateAligned(sizeof(EmptyIterator));
-    return new (mem) EmptyIterator(status);
+    return new (mem) EmptyInternalIterator(status);
   }
 }
 
diff --git a/src/rocksdb/table/iterator_wrapper.h b/src/rocksdb/table/iterator_wrapper.h
index d64047b..2eb33b5 100644
--- a/src/rocksdb/table/iterator_wrapper.h
+++ b/src/rocksdb/table/iterator_wrapper.h
@@ -9,7 +9,7 @@
 
 #pragma once
 
-#include "rocksdb/iterator.h"
+#include "table/internal_iterator.h"
 
 namespace rocksdb {
 
@@ -20,13 +20,15 @@ namespace rocksdb {
 class IteratorWrapper {
  public:
   IteratorWrapper(): iter_(nullptr), valid_(false) { }
-  explicit IteratorWrapper(Iterator* _iter) : iter_(nullptr) { Set(_iter); }
+  explicit IteratorWrapper(InternalIterator* _iter) : iter_(nullptr) {
+    Set(_iter);
+  }
   ~IteratorWrapper() {}
-  Iterator* iter() const { return iter_; }
+  InternalIterator* iter() const { return iter_; }
 
   // Takes ownership of "iter" and will delete it when destroyed, or
   // when Set() is invoked again.
-  void Set(Iterator* _iter) {
+  void Set(InternalIterator* _iter) {
     delete iter_;
     iter_ = _iter;
     if (iter_ == nullptr) {
@@ -40,7 +42,7 @@ class IteratorWrapper {
     if (!is_arena_mode) {
       delete iter_;
     } else {
-      iter_->~Iterator();
+      iter_->~InternalIterator();
     }
   }
 
@@ -64,16 +66,17 @@ class IteratorWrapper {
     }
   }
 
-  Iterator* iter_;
+  InternalIterator* iter_;
   bool valid_;
   Slice key_;
 };
 
 class Arena;
 // Return an empty iterator (yields nothing) allocated from arena.
-extern Iterator* NewEmptyIterator(Arena* arena);
+extern InternalIterator* NewEmptyInternalIterator(Arena* arena);
 
 // Return an empty iterator with the specified status, allocated arena.
-extern Iterator* NewErrorIterator(const Status& status, Arena* arena);
+extern InternalIterator* NewErrorInternalIterator(const Status& status,
+                                                  Arena* arena);
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/table/merger.cc b/src/rocksdb/table/merger.cc
index 242587e..49e5125 100644
--- a/src/rocksdb/table/merger.cc
+++ b/src/rocksdb/table/merger.cc
@@ -14,6 +14,7 @@
 #include "rocksdb/comparator.h"
 #include "rocksdb/iterator.h"
 #include "rocksdb/options.h"
+#include "table/internal_iterator.h"
 #include "table/iter_heap.h"
 #include "table/iterator_wrapper.h"
 #include "util/arena.h"
@@ -32,10 +33,10 @@ typedef BinaryHeap<IteratorWrapper*, MinIteratorComparator> MergerMinIterHeap;
 
 const size_t kNumIterReserve = 4;
 
-class MergingIterator : public Iterator {
+class MergingIterator : public InternalIterator {
  public:
-  MergingIterator(const Comparator* comparator, Iterator** children, int n,
-                  bool is_arena_mode)
+  MergingIterator(const Comparator* comparator, InternalIterator** children,
+                  int n, bool is_arena_mode)
       : is_arena_mode_(is_arena_mode),
         comparator_(comparator),
         current_(nullptr),
@@ -53,7 +54,7 @@ class MergingIterator : public Iterator {
     current_ = CurrentForward();
   }
 
-  virtual void AddIterator(Iterator* iter) {
+  virtual void AddIterator(InternalIterator* iter) {
     assert(direction_ == kForward);
     children_.emplace_back(iter);
     auto new_wrapper = children_.back();
@@ -288,11 +289,12 @@ void MergingIterator::InitMaxHeap() {
   }
 }
 
-Iterator* NewMergingIterator(const Comparator* cmp, Iterator** list, int n,
-                             Arena* arena) {
+InternalIterator* NewMergingIterator(const Comparator* cmp,
+                                     InternalIterator** list, int n,
+                                     Arena* arena) {
   assert(n >= 0);
   if (n == 0) {
-    return NewEmptyIterator(arena);
+    return NewEmptyInternalIterator(arena);
   } else if (n == 1) {
     return list[0];
   } else {
@@ -313,7 +315,7 @@ MergeIteratorBuilder::MergeIteratorBuilder(const Comparator* comparator,
   merge_iter = new (mem) MergingIterator(comparator, nullptr, 0, true);
 }
 
-void MergeIteratorBuilder::AddIterator(Iterator* iter) {
+void MergeIteratorBuilder::AddIterator(InternalIterator* iter) {
   if (!use_merging_iter && first_iter != nullptr) {
     merge_iter->AddIterator(first_iter);
     use_merging_iter = true;
@@ -325,7 +327,7 @@ void MergeIteratorBuilder::AddIterator(Iterator* iter) {
   }
 }
 
-Iterator* MergeIteratorBuilder::Finish() {
+InternalIterator* MergeIteratorBuilder::Finish() {
   if (!use_merging_iter) {
     return first_iter;
   } else {
diff --git a/src/rocksdb/table/merger.h b/src/rocksdb/table/merger.h
index 7dcf2af..5ea6246 100644
--- a/src/rocksdb/table/merger.h
+++ b/src/rocksdb/table/merger.h
@@ -14,7 +14,7 @@
 namespace rocksdb {
 
 class Comparator;
-class Iterator;
+class InternalIterator;
 class Env;
 class Arena;
 
@@ -26,9 +26,9 @@ class Arena;
 // key is present in K child iterators, it will be yielded K times.
 //
 // REQUIRES: n >= 0
-extern Iterator* NewMergingIterator(const Comparator* comparator,
-                                    Iterator** children, int n,
-                                    Arena* arena = nullptr);
+extern InternalIterator* NewMergingIterator(const Comparator* comparator,
+                                            InternalIterator** children, int n,
+                                            Arena* arena = nullptr);
 
 class MergingIterator;
 
@@ -41,18 +41,18 @@ class MergeIteratorBuilder {
   ~MergeIteratorBuilder() {}
 
   // Add iter to the merging iterator.
-  void AddIterator(Iterator* iter);
+  void AddIterator(InternalIterator* iter);
 
   // Get arena used to build the merging iterator. It is called one a child
   // iterator needs to be allocated.
   Arena* GetArena() { return arena; }
 
   // Return the result merging iterator.
-  Iterator* Finish();
+  InternalIterator* Finish();
 
  private:
   MergingIterator* merge_iter;
-  Iterator* first_iter;
+  InternalIterator* first_iter;
   bool use_merging_iter;
   Arena* arena;
 };
diff --git a/src/rocksdb/table/merger_test.cc b/src/rocksdb/table/merger_test.cc
index 562c0ae..e9397dc 100644
--- a/src/rocksdb/table/merger_test.cc
+++ b/src/rocksdb/table/merger_test.cc
@@ -88,7 +88,7 @@ class MergerTest : public testing::Test {
 
   void Generate(size_t num_iterators, size_t strings_per_iterator,
                 int letters_per_string) {
-    std::vector<Iterator*> small_iterators;
+    std::vector<InternalIterator*> small_iterators;
     for (size_t i = 0; i < num_iterators; ++i) {
       auto strings = GenerateStrings(strings_per_iterator, letters_per_string);
       small_iterators.push_back(new test::VectorIterator(strings));
@@ -102,8 +102,8 @@ class MergerTest : public testing::Test {
   }
 
   Random rnd_;
-  std::unique_ptr<Iterator> merging_iterator_;
-  std::unique_ptr<Iterator> single_iterator_;
+  std::unique_ptr<InternalIterator> merging_iterator_;
+  std::unique_ptr<InternalIterator> single_iterator_;
   std::vector<std::string> all_keys_;
 };
 
diff --git a/src/rocksdb/table/meta_blocks.cc b/src/rocksdb/table/meta_blocks.cc
index 7bcdf75..505dbac 100644
--- a/src/rocksdb/table/meta_blocks.cc
+++ b/src/rocksdb/table/meta_blocks.cc
@@ -12,6 +12,7 @@
 #include "rocksdb/table_properties.h"
 #include "table/block.h"
 #include "table/format.h"
+#include "table/internal_iterator.h"
 #include "table/table_properties_internal.h"
 #include "util/coding.h"
 
@@ -152,7 +153,7 @@ Status ReadProperties(const Slice& handle_value, RandomAccessFileReader* file,
   }
 
   Block properties_block(std::move(block_contents));
-  std::unique_ptr<Iterator> iter(
+  std::unique_ptr<InternalIterator> iter(
       properties_block.NewIterator(BytewiseComparator()));
 
   auto new_table_properties = new TableProperties();
@@ -237,7 +238,7 @@ Status ReadTableProperties(RandomAccessFileReader* file, uint64_t file_size,
     return s;
   }
   Block metaindex_block(std::move(metaindex_contents));
-  std::unique_ptr<Iterator> meta_iter(
+  std::unique_ptr<InternalIterator> meta_iter(
       metaindex_block.NewIterator(BytewiseComparator()));
 
   // -- Read property block
@@ -258,7 +259,7 @@ Status ReadTableProperties(RandomAccessFileReader* file, uint64_t file_size,
   return s;
 }
 
-Status FindMetaBlock(Iterator* meta_index_iter,
+Status FindMetaBlock(InternalIterator* meta_index_iter,
                      const std::string& meta_block_name,
                      BlockHandle* block_handle) {
   meta_index_iter->Seek(meta_block_name);
@@ -292,7 +293,7 @@ Status FindMetaBlock(RandomAccessFileReader* file, uint64_t file_size,
   }
   Block metaindex_block(std::move(metaindex_contents));
 
-  std::unique_ptr<Iterator> meta_iter;
+  std::unique_ptr<InternalIterator> meta_iter;
   meta_iter.reset(metaindex_block.NewIterator(BytewiseComparator()));
 
   return FindMetaBlock(meta_iter.get(), meta_block_name, block_handle);
@@ -323,7 +324,7 @@ Status ReadMetaBlock(RandomAccessFileReader* file, uint64_t file_size,
   // Finding metablock
   Block metaindex_block(std::move(metaindex_contents));
 
-  std::unique_ptr<Iterator> meta_iter;
+  std::unique_ptr<InternalIterator> meta_iter;
   meta_iter.reset(metaindex_block.NewIterator(BytewiseComparator()));
 
   BlockHandle block_handle;
diff --git a/src/rocksdb/table/meta_blocks.h b/src/rocksdb/table/meta_blocks.h
index 005bcaa..085ae30 100644
--- a/src/rocksdb/table/meta_blocks.h
+++ b/src/rocksdb/table/meta_blocks.h
@@ -11,12 +11,12 @@
 
 #include "db/builder.h"
 #include "db/table_properties_collector.h"
+#include "util/kv_map.h"
 #include "rocksdb/comparator.h"
 #include "rocksdb/options.h"
 #include "rocksdb/slice.h"
 #include "table/block_builder.h"
 #include "table/format.h"
-#include "util/stl_wrappers.h"
 
 namespace rocksdb {
 
@@ -27,6 +27,7 @@ class Footer;
 class Logger;
 class RandomAccessFile;
 struct TableProperties;
+class InternalIterator;
 
 class MetaIndexBuilder {
  public:
@@ -105,7 +106,7 @@ Status ReadTableProperties(RandomAccessFileReader* file, uint64_t file_size,
                            Logger* info_log, TableProperties** properties);
 
 // Find the meta block from the meta index block.
-Status FindMetaBlock(Iterator* meta_index_iter,
+Status FindMetaBlock(InternalIterator* meta_index_iter,
                      const std::string& meta_block_name,
                      BlockHandle* block_handle);
 
diff --git a/src/rocksdb/table/mock_table.cc b/src/rocksdb/table/mock_table.cc
index ff56d63..027e6d1 100644
--- a/src/rocksdb/table/mock_table.cc
+++ b/src/rocksdb/table/mock_table.cc
@@ -28,7 +28,8 @@ stl_wrappers::KVMap MakeMockFile(
   return stl_wrappers::KVMap(l, stl_wrappers::LessOfComparator(&icmp_));
 }
 
-Iterator* MockTableReader::NewIterator(const ReadOptions&, Arena* arena) {
+InternalIterator* MockTableReader::NewIterator(const ReadOptions&,
+                                               Arena* arena) {
   return new MockTableIterator(table_);
 }
 
@@ -74,9 +75,9 @@ Status MockTableFactory::NewTableReader(
 }
 
 TableBuilder* MockTableFactory::NewTableBuilder(
-    const TableBuilderOptions& table_builder_options,
+    const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
     WritableFileWriter* file) const {
-  uint32_t id = GetAndWriteNextID(file->writable_file());
+  uint32_t id = GetAndWriteNextID(file);
 
   return new MockTableBuilder(id, &file_system_);
 }
@@ -89,12 +90,14 @@ Status MockTableFactory::CreateMockTable(Env* env, const std::string& fname,
     return s;
   }
 
-  uint32_t id = GetAndWriteNextID(file.get());
+  WritableFileWriter file_writer(std::move(file), EnvOptions());
+
+  uint32_t id = GetAndWriteNextID(&file_writer);
   file_system_.files.insert({id, std::move(file_contents)});
   return Status::OK();
 }
 
-uint32_t MockTableFactory::GetAndWriteNextID(WritableFile* file) const {
+uint32_t MockTableFactory::GetAndWriteNextID(WritableFileWriter* file) const {
   uint32_t next_id = next_id_.fetch_add(1);
   char buf[4];
   EncodeFixed32(buf, next_id);
diff --git a/src/rocksdb/table/mock_table.h b/src/rocksdb/table/mock_table.h
index 322a51d..15ecad8 100644
--- a/src/rocksdb/table/mock_table.h
+++ b/src/rocksdb/table/mock_table.h
@@ -14,13 +14,14 @@
 #include <string>
 #include <utility>
 
+#include "util/kv_map.h"
 #include "port/port.h"
 #include "rocksdb/comparator.h"
 #include "rocksdb/table.h"
+#include "table/internal_iterator.h"
 #include "table/table_builder.h"
 #include "table/table_reader.h"
 #include "util/mutexlock.h"
-#include "util/stl_wrappers.h"
 #include "util/testharness.h"
 #include "util/testutil.h"
 
@@ -39,7 +40,7 @@ class MockTableReader : public TableReader {
  public:
   explicit MockTableReader(const stl_wrappers::KVMap& table) : table_(table) {}
 
-  Iterator* NewIterator(const ReadOptions&, Arena* arena) override;
+  InternalIterator* NewIterator(const ReadOptions&, Arena* arena) override;
 
   Status Get(const ReadOptions&, const Slice& key,
              GetContext* get_context) override;
@@ -58,7 +59,7 @@ class MockTableReader : public TableReader {
   const stl_wrappers::KVMap& table_;
 };
 
-class MockTableIterator : public Iterator {
+class MockTableIterator : public InternalIterator {
  public:
   explicit MockTableIterator(const stl_wrappers::KVMap& table) : table_(table) {
     itr_ = table_.end();
@@ -151,7 +152,7 @@ class MockTableFactory : public TableFactory {
                         unique_ptr<TableReader>* table_reader) const override;
   TableBuilder* NewTableBuilder(
       const TableBuilderOptions& table_builder_options,
-      WritableFileWriter* file) const override;
+      uint32_t column_familly_id, WritableFileWriter* file) const override;
 
   // This function will directly create mock table instead of going through
   // MockTableBuilder. file_contents has to have a format of <internal_key,
@@ -175,7 +176,7 @@ class MockTableFactory : public TableFactory {
   void AssertLatestFile(const stl_wrappers::KVMap& file_contents);
 
  private:
-  uint32_t GetAndWriteNextID(WritableFile* file) const;
+  uint32_t GetAndWriteNextID(WritableFileWriter* file) const;
   uint32_t GetIDFromFile(RandomAccessFileReader* file) const;
 
   mutable MockTableFileSystem file_system_;
diff --git a/src/rocksdb/table/plain_table_builder.cc b/src/rocksdb/table/plain_table_builder.cc
index e16224a..2306a7e 100644
--- a/src/rocksdb/table/plain_table_builder.cc
+++ b/src/rocksdb/table/plain_table_builder.cc
@@ -60,10 +60,10 @@ PlainTableBuilder::PlainTableBuilder(
     const ImmutableCFOptions& ioptions,
     const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
         int_tbl_prop_collector_factories,
-    WritableFileWriter* file, uint32_t user_key_len, EncodingType encoding_type,
-    size_t index_sparseness, uint32_t bloom_bits_per_key, uint32_t num_probes,
-    size_t huge_page_tlb_size, double hash_table_ratio,
-    bool store_index_in_file)
+    uint32_t column_family_id, WritableFileWriter* file, uint32_t user_key_len,
+    EncodingType encoding_type, size_t index_sparseness,
+    uint32_t bloom_bits_per_key, uint32_t num_probes, size_t huge_page_tlb_size,
+    double hash_table_ratio, bool store_index_in_file)
     : ioptions_(ioptions),
       bloom_block_(num_probes),
       file_(file),
@@ -108,7 +108,7 @@ PlainTableBuilder::PlainTableBuilder(
 
   for (auto& collector_factories : *int_tbl_prop_collector_factories) {
     table_properties_collectors_.emplace_back(
-        collector_factories->CreateIntTblPropCollector());
+        collector_factories->CreateIntTblPropCollector(column_family_id));
   }
 }
 
diff --git a/src/rocksdb/table/plain_table_builder.h b/src/rocksdb/table/plain_table_builder.h
index 75ec3fa..5c0cad9 100644
--- a/src/rocksdb/table/plain_table_builder.h
+++ b/src/rocksdb/table/plain_table_builder.h
@@ -34,11 +34,11 @@ class PlainTableBuilder: public TableBuilder {
       const ImmutableCFOptions& ioptions,
       const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
           int_tbl_prop_collector_factories,
-      WritableFileWriter* file, uint32_t user_key_size,
-      EncodingType encoding_type, size_t index_sparseness,
-      uint32_t bloom_bits_per_key, uint32_t num_probes = 6,
-      size_t huge_page_tlb_size = 0, double hash_table_ratio = 0,
-      bool store_index_in_file = false);
+      uint32_t column_family_id, WritableFileWriter* file,
+      uint32_t user_key_size, EncodingType encoding_type,
+      size_t index_sparseness, uint32_t bloom_bits_per_key,
+      uint32_t num_probes = 6, size_t huge_page_tlb_size = 0,
+      double hash_table_ratio = 0, bool store_index_in_file = false);
 
   // REQUIRES: Either Finish() or Abandon() has been called.
   ~PlainTableBuilder();
diff --git a/src/rocksdb/table/plain_table_factory.cc b/src/rocksdb/table/plain_table_factory.cc
index 6e86ff5..a2f55b6 100644
--- a/src/rocksdb/table/plain_table_factory.cc
+++ b/src/rocksdb/table/plain_table_factory.cc
@@ -21,12 +21,13 @@ Status PlainTableFactory::NewTableReader(
   return PlainTableReader::Open(
       table_reader_options.ioptions, table_reader_options.env_options,
       table_reader_options.internal_comparator, std::move(file), file_size,
-      table, bloom_bits_per_key_, hash_table_ratio_, index_sparseness_,
-      huge_page_tlb_size_, full_scan_mode_);
+      table, table_options_.bloom_bits_per_key, table_options_.hash_table_ratio,
+      table_options_.index_sparseness, table_options_.huge_page_tlb_size,
+      table_options_.full_scan_mode);
 }
 
 TableBuilder* PlainTableFactory::NewTableBuilder(
-    const TableBuilderOptions& table_builder_options,
+    const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
     WritableFileWriter* file) const {
   // Ignore the skip_filters flag. PlainTable format is optimized for small
   // in-memory dbs. The skip_filters optimization is not useful for plain
@@ -34,9 +35,11 @@ TableBuilder* PlainTableFactory::NewTableBuilder(
   //
   return new PlainTableBuilder(
       table_builder_options.ioptions,
-      table_builder_options.int_tbl_prop_collector_factories, file,
-      user_key_len_, encoding_type_, index_sparseness_, bloom_bits_per_key_, 6,
-      huge_page_tlb_size_, hash_table_ratio_, store_index_in_file_);
+      table_builder_options.int_tbl_prop_collector_factories, column_family_id,
+      file, table_options_.user_key_len, table_options_.encoding_type,
+      table_options_.index_sparseness, table_options_.bloom_bits_per_key, 6,
+      table_options_.huge_page_tlb_size, table_options_.hash_table_ratio,
+      table_options_.store_index_in_file);
 }
 
 std::string PlainTableFactory::GetPrintableTableOptions() const {
@@ -46,32 +49,36 @@ std::string PlainTableFactory::GetPrintableTableOptions() const {
   char buffer[kBufferSize];
 
   snprintf(buffer, kBufferSize, "  user_key_len: %u\n",
-           user_key_len_);
+           table_options_.user_key_len);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  bloom_bits_per_key: %d\n",
-           bloom_bits_per_key_);
+           table_options_.bloom_bits_per_key);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  hash_table_ratio: %lf\n",
-           hash_table_ratio_);
+           table_options_.hash_table_ratio);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  index_sparseness: %" ROCKSDB_PRIszt "\n",
-           index_sparseness_);
+           table_options_.index_sparseness);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  huge_page_tlb_size: %" ROCKSDB_PRIszt "\n",
-           huge_page_tlb_size_);
+           table_options_.huge_page_tlb_size);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  encoding_type: %d\n",
-           encoding_type_);
+           table_options_.encoding_type);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  full_scan_mode: %d\n",
-           full_scan_mode_);
+           table_options_.full_scan_mode);
   ret.append(buffer);
   snprintf(buffer, kBufferSize, "  store_index_in_file: %d\n",
-           store_index_in_file_);
+           table_options_.store_index_in_file);
   ret.append(buffer);
   return ret;
 }
 
+const PlainTableOptions& PlainTableFactory::table_options() const {
+  return table_options_;
+}
+
 extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options) {
   return new PlainTableFactory(options);
 }
diff --git a/src/rocksdb/table/plain_table_factory.h b/src/rocksdb/table/plain_table_factory.h
index 539e753..154cbff 100644
--- a/src/rocksdb/table/plain_table_factory.h
+++ b/src/rocksdb/table/plain_table_factory.h
@@ -142,28 +142,25 @@ class PlainTableFactory : public TableFactory {
   // huge_page_tlb_size determines whether to allocate hash indexes from huge
   // page TLB and the page size if allocating from there. See comments of
   // Arena::AllocateAligned() for details.
-  explicit PlainTableFactory(const PlainTableOptions& options =
-                                 PlainTableOptions())
-      : user_key_len_(options.user_key_len),
-        bloom_bits_per_key_(options.bloom_bits_per_key),
-        hash_table_ratio_(options.hash_table_ratio),
-        index_sparseness_(options.index_sparseness),
-        huge_page_tlb_size_(options.huge_page_tlb_size),
-        encoding_type_(options.encoding_type),
-        full_scan_mode_(options.full_scan_mode),
-        store_index_in_file_(options.store_index_in_file) {}
+  explicit PlainTableFactory(
+      const PlainTableOptions& _table_options = PlainTableOptions())
+      : table_options_(_table_options) {}
+
   const char* Name() const override { return "PlainTable"; }
   Status NewTableReader(const TableReaderOptions& table_reader_options,
                         unique_ptr<RandomAccessFileReader>&& file,
                         uint64_t file_size,
                         unique_ptr<TableReader>* table) const override;
+
   TableBuilder* NewTableBuilder(
       const TableBuilderOptions& table_builder_options,
-      WritableFileWriter* file) const override;
+      uint32_t column_family_id, WritableFileWriter* file) const override;
 
   std::string GetPrintableTableOptions() const override;
 
-  static const char kValueTypeSeqId0 = 0xFF;
+  const PlainTableOptions& table_options() const;
+
+  static const char kValueTypeSeqId0 = char(0xFF);
 
   // Sanitizes the specified DB Options.
   Status SanitizeOptions(const DBOptions& db_opts,
@@ -171,15 +168,10 @@ class PlainTableFactory : public TableFactory {
     return Status::OK();
   }
 
+  void* GetOptions() override { return &table_options_; }
+
  private:
-  uint32_t user_key_len_;
-  int bloom_bits_per_key_;
-  double hash_table_ratio_;
-  size_t index_sparseness_;
-  size_t huge_page_tlb_size_;
-  EncodingType encoding_type_;
-  bool full_scan_mode_;
-  bool store_index_in_file_;
+  PlainTableOptions table_options_;
 };
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/table/plain_table_reader.cc b/src/rocksdb/table/plain_table_reader.cc
index 1aabbb9..603d60d 100644
--- a/src/rocksdb/table/plain_table_reader.cc
+++ b/src/rocksdb/table/plain_table_reader.cc
@@ -22,6 +22,7 @@
 #include "table/bloom_block.h"
 #include "table/filter_block.h"
 #include "table/format.h"
+#include "table/internal_iterator.h"
 #include "table/meta_blocks.h"
 #include "table/two_level_iterator.h"
 #include "table/plain_table_factory.h"
@@ -51,7 +52,7 @@ inline uint32_t GetFixed32Element(const char* base, size_t offset) {
 }  // namespace
 
 // Iterator to iterate IndexedTable
-class PlainTableIterator : public Iterator {
+class PlainTableIterator : public InternalIterator {
  public:
   explicit PlainTableIterator(PlainTableReader* table, bool use_prefix_seek);
   ~PlainTableIterator();
@@ -186,10 +187,10 @@ Status PlainTableReader::Open(const ImmutableCFOptions& ioptions,
 void PlainTableReader::SetupForCompaction() {
 }
 
-Iterator* PlainTableReader::NewIterator(const ReadOptions& options,
-                                        Arena* arena) {
+InternalIterator* PlainTableReader::NewIterator(const ReadOptions& options,
+                                                Arena* arena) {
   if (options.total_order_seek && !IsTotalOrderMode()) {
-    return NewErrorIterator(
+    return NewErrorInternalIterator(
         Status::InvalidArgument("total_order_seek not supported"), arena);
   }
   if (arena == nullptr) {
@@ -408,7 +409,8 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
   return Status::OK();
 }
 
-Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
+Status PlainTableReader::GetOffset(PlainTableKeyDecoder* decoder,
+                                   const Slice& target, const Slice& prefix,
                                    uint32_t prefix_hash, bool& prefix_matched,
                                    uint32_t* offset) const {
   prefix_matched = false;
@@ -434,15 +436,12 @@ Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
     return Status::Corruption(Slice());
   }
 
-  PlainTableKeyDecoder decoder(&file_info_, encoding_type_, user_key_len_,
-                               ioptions_.prefix_extractor);
-
   // The key is between [low, high). Do a binary search between it.
   while (high - low > 1) {
     uint32_t mid = (high + low) / 2;
     uint32_t file_offset = GetFixed32Element(base_ptr, mid);
     uint32_t tmp;
-    Status s = decoder.NextKeyNoValue(file_offset, &mid_key, nullptr, &tmp);
+    Status s = decoder->NextKeyNoValue(file_offset, &mid_key, nullptr, &tmp);
     if (!s.ok()) {
       return s;
     }
@@ -467,7 +466,7 @@ Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
   ParsedInternalKey low_key;
   uint32_t tmp;
   uint32_t low_key_offset = GetFixed32Element(base_ptr, low);
-  Status s = decoder.NextKeyNoValue(low_key_offset, &low_key, nullptr, &tmp);
+  Status s = decoder->NextKeyNoValue(low_key_offset, &low_key, nullptr, &tmp);
   if (!s.ok()) {
     return s;
   }
@@ -558,8 +557,10 @@ Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
   }
   uint32_t offset;
   bool prefix_match;
-  Status s =
-      GetOffset(target, prefix_slice, prefix_hash, prefix_match, &offset);
+  PlainTableKeyDecoder decoder(&file_info_, encoding_type_, user_key_len_,
+                               ioptions_.prefix_extractor);
+  Status s = GetOffset(&decoder, target, prefix_slice, prefix_hash,
+                       prefix_match, &offset);
 
   if (!s.ok()) {
     return s;
@@ -570,8 +571,6 @@ Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
     return Status::Corruption(Slice());
   }
   Slice found_value;
-  PlainTableKeyDecoder decoder(&file_info_, encoding_type_, user_key_len_,
-                               ioptions_.prefix_extractor);
   while (offset < file_info_.data_end_offset) {
     s = Next(&decoder, &offset, &found_key, nullptr, &found_value);
     if (!s.ok()) {
@@ -661,8 +660,8 @@ void PlainTableIterator::Seek(const Slice& target) {
     }
   }
   bool prefix_match;
-  status_ = table_->GetOffset(target, prefix_slice, prefix_hash, prefix_match,
-                              &next_offset_);
+  status_ = table_->GetOffset(&decoder_, target, prefix_slice, prefix_hash,
+                              prefix_match, &next_offset_);
   if (!status_.ok()) {
     offset_ = next_offset_ = table_->file_info_.data_end_offset;
     return;
diff --git a/src/rocksdb/table/plain_table_reader.h b/src/rocksdb/table/plain_table_reader.h
index b9d8ceb..e7d38e6 100644
--- a/src/rocksdb/table/plain_table_reader.h
+++ b/src/rocksdb/table/plain_table_reader.h
@@ -38,6 +38,7 @@ class TableReader;
 class InternalKeyComparator;
 class PlainTableKeyDecoder;
 class GetContext;
+class InternalIterator;
 
 using std::unique_ptr;
 using std::unordered_map;
@@ -77,7 +78,8 @@ class PlainTableReader: public TableReader {
                      size_t index_sparseness, size_t huge_page_tlb_size,
                      bool full_scan_mode);
 
-  Iterator* NewIterator(const ReadOptions&, Arena* arena = nullptr) override;
+  InternalIterator* NewIterator(const ReadOptions&,
+                                Arena* arena = nullptr) override;
 
   void Prepare(const Slice& target) override;
 
@@ -217,9 +219,9 @@ class PlainTableReader: public TableReader {
   // Get file offset for key target.
   // return value prefix_matched is set to true if the offset is confirmed
   // for a key with the same prefix as target.
-  Status GetOffset(const Slice& target, const Slice& prefix,
-                   uint32_t prefix_hash, bool& prefix_matched,
-                   uint32_t* offset) const;
+  Status GetOffset(PlainTableKeyDecoder* decoder, const Slice& target,
+                   const Slice& prefix, uint32_t prefix_hash,
+                   bool& prefix_matched, uint32_t* offset) const;
 
   bool IsTotalOrderMode() const { return (prefix_extractor_ == nullptr); }
 
diff --git a/src/rocksdb/util/scoped_arena_iterator.h b/src/rocksdb/table/scoped_arena_iterator.h
similarity index 63%
rename from src/rocksdb/util/scoped_arena_iterator.h
rename to src/rocksdb/table/scoped_arena_iterator.h
index 2021d2d..0372b56 100644
--- a/src/rocksdb/util/scoped_arena_iterator.h
+++ b/src/rocksdb/table/scoped_arena_iterator.h
@@ -7,22 +7,23 @@
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 #pragma once
 
-#include "rocksdb/iterator.h"
+#include "table/internal_iterator.h"
 
 namespace rocksdb {
 class ScopedArenaIterator {
  public:
-  explicit ScopedArenaIterator(Iterator* iter = nullptr) : iter_(iter) {}
+  explicit ScopedArenaIterator(InternalIterator* iter = nullptr)
+      : iter_(iter) {}
 
-  Iterator* operator->() { return iter_; }
+  InternalIterator* operator->() { return iter_; }
 
-  void set(Iterator* iter) { iter_ = iter; }
+  void set(InternalIterator* iter) { iter_ = iter; }
 
-  Iterator* get() { return iter_; }
+  InternalIterator* get() { return iter_; }
 
-  ~ScopedArenaIterator() { iter_->~Iterator(); }
+  ~ScopedArenaIterator() { iter_->~InternalIterator(); }
 
  private:
-  Iterator* iter_;
+  InternalIterator* iter_;
 };
 }  // namespace rocksdb
diff --git a/src/rocksdb/table/sst_file_writer.cc b/src/rocksdb/table/sst_file_writer.cc
index d780f0a..1c21a25 100644
--- a/src/rocksdb/table/sst_file_writer.cc
+++ b/src/rocksdb/table/sst_file_writer.cc
@@ -57,7 +57,8 @@ class SstFileWriter::SstFileWriterPropertiesCollectorFactory
   explicit SstFileWriterPropertiesCollectorFactory(int32_t version)
       : version_(version) {}
 
-  virtual IntTblPropCollector* CreateIntTblPropCollector() override {
+  virtual IntTblPropCollector* CreateIntTblPropCollector(
+      uint32_t column_family_id) override {
     return new SstFileWriterPropertiesCollector(version_);
   }
 
@@ -117,7 +118,9 @@ Status SstFileWriter::Open(const std::string& file_path) {
   r->file_writer.reset(
       new WritableFileWriter(std::move(sst_file), r->env_options));
   r->builder.reset(r->ioptions.table_factory->NewTableBuilder(
-      table_builder_options, r->file_writer.get()));
+      table_builder_options,
+      TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
+      r->file_writer.get()));
 
   r->file_info.file_path = file_path;
   r->file_info.file_size = 0;
diff --git a/src/rocksdb/table/table_properties.cc b/src/rocksdb/table/table_properties.cc
index 86c0843..7a51779 100644
--- a/src/rocksdb/table/table_properties.cc
+++ b/src/rocksdb/table/table_properties.cc
@@ -8,10 +8,14 @@
 #include "rocksdb/iterator.h"
 #include "rocksdb/env.h"
 #include "port/port.h"
+#include "table/internal_iterator.h"
 #include "util/string_util.h"
 
 namespace rocksdb {
 
+const uint32_t TablePropertiesCollectorFactory::Context::kUnknownColumnFamily =
+    port::kMaxInt32;
+
 namespace {
   void AppendProperty(
       std::string& props,
@@ -111,7 +115,7 @@ extern const std::string kPropertiesBlockOldName = "rocksdb.stats";
 
 // Seek to the properties block.
 // Return true if it successfully seeks to the properties block.
-Status SeekToPropertiesBlock(Iterator* meta_iter, bool* is_found) {
+Status SeekToPropertiesBlock(InternalIterator* meta_iter, bool* is_found) {
   *is_found = true;
   meta_iter->Seek(kPropertiesBlock);
   if (meta_iter->status().ok() &&
diff --git a/src/rocksdb/table/table_properties_internal.h b/src/rocksdb/table/table_properties_internal.h
index 9ef8ad4..10f38cd 100644
--- a/src/rocksdb/table/table_properties_internal.h
+++ b/src/rocksdb/table/table_properties_internal.h
@@ -10,9 +10,11 @@
 
 namespace rocksdb {
 
+class InternalIterator;
+
 // Seek to the properties block.
 // If it successfully seeks to the properties block, "is_found" will be
 // set to true.
-Status SeekToPropertiesBlock(Iterator* meta_iter, bool* is_found);
+Status SeekToPropertiesBlock(InternalIterator* meta_iter, bool* is_found);
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/table/table_reader.h b/src/rocksdb/table/table_reader.h
index 2058b86..60a593b 100644
--- a/src/rocksdb/table/table_reader.h
+++ b/src/rocksdb/table/table_reader.h
@@ -19,6 +19,7 @@ class Arena;
 struct ReadOptions;
 struct TableProperties;
 class GetContext;
+class InternalIterator;
 
 // A Table is a sorted map from strings to strings.  Tables are
 // immutable and persistent.  A Table may be safely accessed from
@@ -34,7 +35,8 @@ class TableReader {
   //        When destroying the iterator, the caller will not call "delete"
   //        but Iterator::~Iterator() directly. The destructor needs to destroy
   //        all the states but those allocated in arena.
-  virtual Iterator* NewIterator(const ReadOptions&, Arena* arena = nullptr) = 0;
+  virtual InternalIterator* NewIterator(const ReadOptions&,
+                                        Arena* arena = nullptr) = 0;
 
   // Given a key, return an approximate byte offset in the file where
   // the data for that key begins (or would begin if the key were
diff --git a/src/rocksdb/table/table_reader_bench.cc b/src/rocksdb/table/table_reader_bench.cc
index e3baa29..c93e2c5 100644
--- a/src/rocksdb/table/table_reader_bench.cc
+++ b/src/rocksdb/table/table_reader_bench.cc
@@ -19,6 +19,7 @@ int main() {
 #include "db/db_impl.h"
 #include "db/dbformat.h"
 #include "table/block_based_table_factory.h"
+#include "table/internal_iterator.h"
 #include "table/plain_table_factory.h"
 #include "table/table_builder.h"
 #include "table/get_context.h"
@@ -98,7 +99,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
         TableBuilderOptions(ioptions, ikc, &int_tbl_prop_collector_factories,
                             CompressionType::kNoCompression,
                             CompressionOptions(), false),
-        file_writer.get());
+        0, file_writer.get());
   } else {
     s = DB::Open(opts, dbname, &db);
     ASSERT_OK(s);
@@ -187,14 +188,17 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
           std::string end_key = MakeKey(r1, r2 + r2_len, through_db);
           uint64_t total_time = 0;
           uint64_t start_time = Now(env, measured_by_nanosecond);
-          Iterator* iter;
+          Iterator* iter = nullptr;
+          InternalIterator* iiter = nullptr;
           if (!through_db) {
-            iter = table_reader->NewIterator(read_options);
+            iiter = table_reader->NewIterator(read_options);
           } else {
             iter = db->NewIterator(read_options);
           }
           int count = 0;
-          for(iter->Seek(start_key); iter->Valid(); iter->Next()) {
+          for (through_db ? iter->Seek(start_key) : iiter->Seek(start_key);
+               through_db ? iter->Valid() : iiter->Valid();
+               through_db ? iter->Next() : iiter->Next()) {
             if (if_query_empty_keys) {
               break;
             }
@@ -254,6 +258,7 @@ DEFINE_bool(iterator, false, "For test iterator");
 DEFINE_bool(through_db, false, "If enable, a DB instance will be created and "
             "the query will be against DB. Otherwise, will be directly against "
             "a table reader.");
+DEFINE_bool(mmap_read, true, "Whether use mmap read");
 DEFINE_string(table_factory, "block_based",
               "Table factory to use: `block_based` (default), `plain_table` or "
               "`cuckoo_hash`.");
@@ -279,8 +284,8 @@ int main(int argc, char** argv) {
 
   if (FLAGS_table_factory == "cuckoo_hash") {
 #ifndef ROCKSDB_LITE
-    options.allow_mmap_reads = true;
-    env_options.use_mmap_reads = true;
+    options.allow_mmap_reads = FLAGS_mmap_read;
+    env_options.use_mmap_reads = FLAGS_mmap_read;
     rocksdb::CuckooTableOptions table_options;
     table_options.hash_table_ratio = 0.75;
     tf.reset(rocksdb::NewCuckooTableFactory(table_options));
@@ -290,8 +295,8 @@ int main(int argc, char** argv) {
 #endif  // ROCKSDB_LITE
   } else if (FLAGS_table_factory == "plain_table") {
 #ifndef ROCKSDB_LITE
-    options.allow_mmap_reads = true;
-    env_options.use_mmap_reads = true;
+    options.allow_mmap_reads = FLAGS_mmap_read;
+    env_options.use_mmap_reads = FLAGS_mmap_read;
 
     rocksdb::PlainTableOptions plain_table_options;
     plain_table_options.user_key_len = 16;
diff --git a/src/rocksdb/table/table_test.cc b/src/rocksdb/table/table_test.cc
index e21503b..58607bb 100644
--- a/src/rocksdb/table/table_test.cc
+++ b/src/rocksdb/table/table_test.cc
@@ -21,6 +21,7 @@
 #include "db/memtable.h"
 #include "db/write_batch_internal.h"
 #include "db/writebuffer.h"
+#include "memtable/stl_wrappers.h"
 #include "rocksdb/cache.h"
 #include "rocksdb/db.h"
 #include "rocksdb/env.h"
@@ -36,13 +37,13 @@
 #include "table/block_builder.h"
 #include "table/format.h"
 #include "table/get_context.h"
+#include "table/internal_iterator.h"
 #include "table/meta_blocks.h"
 #include "table/plain_table_factory.h"
+#include "table/scoped_arena_iterator.h"
 #include "util/compression.h"
 #include "util/random.h"
-#include "util/scoped_arena_iterator.h"
 #include "util/statistics.h"
-#include "util/stl_wrappers.h"
 #include "util/string_util.h"
 #include "util/testharness.h"
 #include "util/testutil.h"
@@ -142,7 +143,7 @@ class Constructor {
                             const InternalKeyComparator& internal_comparator,
                             const stl_wrappers::KVMap& data) = 0;
 
-  virtual Iterator* NewIterator() const = 0;
+  virtual InternalIterator* NewIterator() const = 0;
 
   virtual const stl_wrappers::KVMap& data() { return data_; }
 
@@ -188,7 +189,7 @@ class BlockConstructor: public Constructor {
     block_ = new Block(std::move(contents));
     return Status::OK();
   }
-  virtual Iterator* NewIterator() const override {
+  virtual InternalIterator* NewIterator() const override {
     return block_->NewIterator(comparator_);
   }
 
@@ -201,13 +202,14 @@ class BlockConstructor: public Constructor {
 };
 
 // A helper class that converts internal format keys into user keys
-class KeyConvertingIterator: public Iterator {
+class KeyConvertingIterator : public InternalIterator {
  public:
-  explicit KeyConvertingIterator(Iterator* iter, bool arena_mode = false)
+  explicit KeyConvertingIterator(InternalIterator* iter,
+                                 bool arena_mode = false)
       : iter_(iter), arena_mode_(arena_mode) {}
   virtual ~KeyConvertingIterator() {
     if (arena_mode_) {
-      iter_->~Iterator();
+      iter_->~InternalIterator();
     } else {
       delete iter_;
     }
@@ -241,7 +243,7 @@ class KeyConvertingIterator: public Iterator {
 
  private:
   mutable Status status_;
-  Iterator* iter_;
+  InternalIterator* iter_;
   bool arena_mode_;
 
   // No copying allowed
@@ -272,6 +274,7 @@ class TableConstructor: public Constructor {
         TableBuilderOptions(ioptions, internal_comparator,
                             &int_tbl_prop_collector_factories,
                             options.compression, CompressionOptions(), false),
+        TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
         file_writer_.get()));
 
     for (const auto kv : kv_map) {
@@ -300,9 +303,9 @@ class TableConstructor: public Constructor {
         std::move(file_reader_), GetSink()->contents().size(), &table_reader_);
   }
 
-  virtual Iterator* NewIterator() const override {
+  virtual InternalIterator* NewIterator() const override {
     ReadOptions ro;
-    Iterator* iter = table_reader_->NewIterator(ro);
+    InternalIterator* iter = table_reader_->NewIterator(ro);
     if (convert_to_internal_key_) {
       return new KeyConvertingIterator(iter);
     } else {
@@ -389,7 +392,7 @@ class MemTableConstructor: public Constructor {
     }
     return Status::OK();
   }
-  virtual Iterator* NewIterator() const override {
+  virtual InternalIterator* NewIterator() const override {
     return new KeyConvertingIterator(
         memtable_->NewIterator(ReadOptions(), &arena_), true);
   }
@@ -407,6 +410,23 @@ class MemTableConstructor: public Constructor {
   std::shared_ptr<SkipListFactory> table_factory_;
 };
 
+class InternalIteratorFromIterator : public InternalIterator {
+ public:
+  explicit InternalIteratorFromIterator(Iterator* it) : it_(it) {}
+  virtual bool Valid() const override { return it_->Valid(); }
+  virtual void Seek(const Slice& target) override { it_->Seek(target); }
+  virtual void SeekToFirst() override { it_->SeekToFirst(); }
+  virtual void SeekToLast() override { it_->SeekToLast(); }
+  virtual void Next() override { it_->Next(); }
+  virtual void Prev() override { it_->Prev(); }
+  Slice key() const override { return it_->key(); }
+  Slice value() const override { return it_->value(); }
+  virtual Status status() const override { return it_->status(); }
+
+ private:
+  unique_ptr<Iterator> it_;
+};
+
 class DBConstructor: public Constructor {
  public:
   explicit DBConstructor(const Comparator* cmp)
@@ -433,8 +453,9 @@ class DBConstructor: public Constructor {
     }
     return Status::OK();
   }
-  virtual Iterator* NewIterator() const override {
-    return db_->NewIterator(ReadOptions());
+
+  virtual InternalIterator* NewIterator() const override {
+    return new InternalIteratorFromIterator(db_->NewIterator(ReadOptions()));
   }
 
   virtual DB* db() const override { return db_; }
@@ -704,7 +725,7 @@ class HarnessTest : public testing::Test {
 
   void TestForwardScan(const std::vector<std::string>& keys,
                        const stl_wrappers::KVMap& data) {
-    Iterator* iter = constructor_->NewIterator();
+    InternalIterator* iter = constructor_->NewIterator();
     ASSERT_TRUE(!iter->Valid());
     iter->SeekToFirst();
     for (stl_wrappers::KVMap::const_iterator model_iter = data.begin();
@@ -714,7 +735,7 @@ class HarnessTest : public testing::Test {
     }
     ASSERT_TRUE(!iter->Valid());
     if (constructor_->IsArenaMode() && !constructor_->AnywayDeleteIterator()) {
-      iter->~Iterator();
+      iter->~InternalIterator();
     } else {
       delete iter;
     }
@@ -722,7 +743,7 @@ class HarnessTest : public testing::Test {
 
   void TestBackwardScan(const std::vector<std::string>& keys,
                         const stl_wrappers::KVMap& data) {
-    Iterator* iter = constructor_->NewIterator();
+    InternalIterator* iter = constructor_->NewIterator();
     ASSERT_TRUE(!iter->Valid());
     iter->SeekToLast();
     for (stl_wrappers::KVMap::const_reverse_iterator model_iter = data.rbegin();
@@ -732,7 +753,7 @@ class HarnessTest : public testing::Test {
     }
     ASSERT_TRUE(!iter->Valid());
     if (constructor_->IsArenaMode() && !constructor_->AnywayDeleteIterator()) {
-      iter->~Iterator();
+      iter->~InternalIterator();
     } else {
       delete iter;
     }
@@ -741,7 +762,7 @@ class HarnessTest : public testing::Test {
   void TestRandomAccess(Random* rnd, const std::vector<std::string>& keys,
                         const stl_wrappers::KVMap& data) {
     static const bool kVerbose = false;
-    Iterator* iter = constructor_->NewIterator();
+    InternalIterator* iter = constructor_->NewIterator();
     ASSERT_TRUE(!iter->Valid());
     stl_wrappers::KVMap::const_iterator model_iter = data.begin();
     if (kVerbose) fprintf(stderr, "---\n");
@@ -805,7 +826,7 @@ class HarnessTest : public testing::Test {
       }
     }
     if (constructor_->IsArenaMode() && !constructor_->AnywayDeleteIterator()) {
-      iter->~Iterator();
+      iter->~InternalIterator();
     } else {
       delete iter;
     }
@@ -829,7 +850,7 @@ class HarnessTest : public testing::Test {
     }
   }
 
-  std::string ToString(const Iterator* it) {
+  std::string ToString(const InternalIterator* it) {
     if (!it->Valid()) {
       return "END";
     } else {
@@ -1190,7 +1211,7 @@ TEST_F(BlockBasedTableTest, TotalOrderSeekOnHashIndex) {
     auto* reader = c.GetTableReader();
     ReadOptions ro;
     ro.total_order_seek = true;
-    std::unique_ptr<Iterator> iter(reader->NewIterator(ro));
+    std::unique_ptr<InternalIterator> iter(reader->NewIterator(ro));
 
     iter->Seek(InternalKey("b", 0, kTypeValue).Encode());
     ASSERT_OK(iter->status());
@@ -1274,7 +1295,8 @@ TEST_F(TableTest, HashIndexTest) {
   auto props = reader->GetTableProperties();
   ASSERT_EQ(5u, props->num_data_blocks);
 
-  std::unique_ptr<Iterator> hash_iter(reader->NewIterator(ReadOptions()));
+  std::unique_ptr<InternalIterator> hash_iter(
+      reader->NewIterator(ReadOptions()));
 
   // -- Find keys do not exist, but have common prefix.
   std::vector<std::string> prefixes = {"001", "003", "005", "007", "009"};
@@ -1544,7 +1566,7 @@ TEST_F(BlockBasedTableTest, FilterBlockInBlockCache) {
 
   // -- PART 1: Open with regular block cache.
   // Since block_cache is disabled, no cache activities will be involved.
-  unique_ptr<Iterator> iter;
+  unique_ptr<InternalIterator> iter;
 
   int64_t last_cache_bytes_read = 0;
   // At first, no block will be accessed.
@@ -1777,7 +1799,7 @@ TEST_F(BlockBasedTableTest, BlockCacheLeak) {
   const ImmutableCFOptions ioptions(opt);
   c.Finish(opt, ioptions, table_options, *ikc, &keys, &kvmap);
 
-  unique_ptr<Iterator> iter(c.NewIterator());
+  unique_ptr<InternalIterator> iter(c.NewIterator());
   iter->SeekToFirst();
   while (iter->Valid()) {
     iter->key();
@@ -1824,6 +1846,7 @@ TEST_F(PlainTableTest, BasicPlainTableProperties) {
   std::unique_ptr<TableBuilder> builder(factory.NewTableBuilder(
       TableBuilderOptions(ioptions, ikc, &int_tbl_prop_collector_factories,
                           kNoCompression, CompressionOptions(), false),
+      TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
       file_writer.get()));
 
   for (char c = 'a'; c <= 'z'; ++c) {
@@ -1972,6 +1995,7 @@ TEST_F(HarnessTest, Randomized) {
   }
 }
 
+#ifndef ROCKSDB_LITE
 TEST_F(HarnessTest, RandomizedLongDB) {
   Random rnd(test::RandomSeed());
   TestArgs args = { DB_TEST, false, 16, kNoCompression, 0 };
@@ -1995,6 +2019,7 @@ TEST_F(HarnessTest, RandomizedLongDB) {
   }
   ASSERT_GT(files, 0);
 }
+#endif  // ROCKSDB_LITE
 
 class MemTableTest : public testing::Test {};
 
diff --git a/src/rocksdb/table/two_level_iterator.cc b/src/rocksdb/table/two_level_iterator.cc
index f540d3b..dbc3785 100644
--- a/src/rocksdb/table/two_level_iterator.cc
+++ b/src/rocksdb/table/two_level_iterator.cc
@@ -19,10 +19,10 @@ namespace rocksdb {
 
 namespace {
 
-class TwoLevelIterator: public Iterator {
+class TwoLevelIterator : public InternalIterator {
  public:
   explicit TwoLevelIterator(TwoLevelIteratorState* state,
-                            Iterator* first_level_iter,
+                            InternalIterator* first_level_iter,
                             bool need_free_iter_and_state);
 
   virtual ~TwoLevelIterator() {
@@ -68,7 +68,7 @@ class TwoLevelIterator: public Iterator {
   }
   void SkipEmptyDataBlocksForward();
   void SkipEmptyDataBlocksBackward();
-  void SetSecondLevelIterator(Iterator* iter);
+  void SetSecondLevelIterator(InternalIterator* iter);
   void InitDataBlock();
 
   TwoLevelIteratorState* state_;
@@ -82,7 +82,7 @@ class TwoLevelIterator: public Iterator {
 };
 
 TwoLevelIterator::TwoLevelIterator(TwoLevelIteratorState* state,
-                                   Iterator* first_level_iter,
+                                   InternalIterator* first_level_iter,
                                    bool need_free_iter_and_state)
     : state_(state),
       first_level_iter_(first_level_iter),
@@ -168,7 +168,7 @@ void TwoLevelIterator::SkipEmptyDataBlocksBackward() {
   }
 }
 
-void TwoLevelIterator::SetSecondLevelIterator(Iterator* iter) {
+void TwoLevelIterator::SetSecondLevelIterator(InternalIterator* iter) {
   if (second_level_iter_.iter() != nullptr) {
     SaveError(second_level_iter_.status());
   }
@@ -186,7 +186,7 @@ void TwoLevelIterator::InitDataBlock() {
       // second_level_iter is already constructed with this iterator, so
       // no need to change anything
     } else {
-      Iterator* iter = state_->NewSecondaryIterator(handle);
+      InternalIterator* iter = state_->NewSecondaryIterator(handle);
       data_block_handle_.assign(handle.data(), handle.size());
       SetSecondLevelIterator(iter);
     }
@@ -195,9 +195,10 @@ void TwoLevelIterator::InitDataBlock() {
 
 }  // namespace
 
-Iterator* NewTwoLevelIterator(TwoLevelIteratorState* state,
-                              Iterator* first_level_iter, Arena* arena,
-                              bool need_free_iter_and_state) {
+InternalIterator* NewTwoLevelIterator(TwoLevelIteratorState* state,
+                                      InternalIterator* first_level_iter,
+                                      Arena* arena,
+                                      bool need_free_iter_and_state) {
   if (arena == nullptr) {
     return new TwoLevelIterator(state, first_level_iter,
                                 need_free_iter_and_state);
diff --git a/src/rocksdb/table/two_level_iterator.h b/src/rocksdb/table/two_level_iterator.h
index 4c6b48c..ed5380b 100644
--- a/src/rocksdb/table/two_level_iterator.h
+++ b/src/rocksdb/table/two_level_iterator.h
@@ -23,7 +23,7 @@ struct TwoLevelIteratorState {
       : check_prefix_may_match(_check_prefix_may_match) {}
 
   virtual ~TwoLevelIteratorState() {}
-  virtual Iterator* NewSecondaryIterator(const Slice& handle) = 0;
+  virtual InternalIterator* NewSecondaryIterator(const Slice& handle) = 0;
   virtual bool PrefixMayMatch(const Slice& internal_key) = 0;
 
   // If call PrefixMayMatch()
@@ -45,9 +45,8 @@ struct TwoLevelIteratorState {
 //        all the states but those allocated in arena.
 // need_free_iter_and_state: free `state` and `first_level_iter` if
 //                           true. Otherwise, just call destructor.
-extern Iterator* NewTwoLevelIterator(TwoLevelIteratorState* state,
-                                     Iterator* first_level_iter,
-                                     Arena* arena = nullptr,
-                                     bool need_free_iter_and_state = true);
+extern InternalIterator* NewTwoLevelIterator(
+    TwoLevelIteratorState* state, InternalIterator* first_level_iter,
+    Arena* arena = nullptr, bool need_free_iter_and_state = true);
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc b/src/rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc
index 92c3a43..bdb83d5 100644
--- a/src/rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc
+++ b/src/rocksdb/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc
@@ -2592,7 +2592,7 @@ class Hunk {
   // Print a unified diff header for one hunk.
   // The format is
   //   "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
-  // where the left/right parts are ommitted if unnecessary.
+  // where the left/right parts are omitted if unnecessary.
   void PrintHeader(std::ostream* ss) const {
     *ss << "@@ ";
     if (removes_) {
diff --git a/src/rocksdb/thirdparty.inc b/src/rocksdb/thirdparty.inc
index 448c49a..46da30c 100644
--- a/src/rocksdb/thirdparty.inc
+++ b/src/rocksdb/thirdparty.inc
@@ -36,6 +36,19 @@ endif ()
 
 if (${USE_GFLAGS} EQUAL 1)
   message(STATUS "GFLAGS library is enabled")
+  
+  if(DEFINED ENV{GFLAGS_INCLUDE})
+    set(GFLAGS_INCLUDE $ENV{GFLAGS_INCLUDE})
+  endif()
+  
+  if(DEFINED ENV{GFLAGS_LIB_DEBUG})
+    set(GFLAGS_LIB_DEBUG $ENV{GFLAGS_LIB_DEBUG})
+  endif()
+
+  if(DEFINED ENV{GFLAGS_LIB_RELEASE})
+    set(GFLAGS_LIB_RELEASE $ENV{GFLAGS_LIB_RELEASE})
+  endif()
+  
   set(GFLAGS_CXX_FLAGS -DGFLAGS=gflags)
   set(GFLAGS_LIBS debug ${GFLAGS_LIB_DEBUG} optimized ${GFLAGS_LIB_RELEASE})
 
@@ -66,6 +79,19 @@ endif ()
 
 if (${USE_SNAPPY} EQUAL 1)
   message(STATUS "SNAPPY library is enabled")
+  
+  if(DEFINED ENV{SNAPPY_INCLUDE})
+    set(SNAPPY_INCLUDE $ENV{SNAPPY_INCLUDE})
+  endif()
+  
+  if(DEFINED ENV{SNAPPY_LIB_DEBUG})
+    set(SNAPPY_LIB_DEBUG $ENV{SNAPPY_LIB_DEBUG})
+  endif()
+
+  if(DEFINED ENV{SNAPPY_LIB_RELEASE})
+    set(SNAPPY_LIB_RELEASE $ENV{SNAPPY_LIB_RELEASE})
+  endif()
+  
   set(SNAPPY_CXX_FLAGS -DSNAPPY)
   set(SNAPPY_LIBS debug ${SNAPPY_LIB_DEBUG} optimized ${SNAPPY_LIB_RELEASE})
 
@@ -96,6 +122,19 @@ endif ()
 
 if (${USE_LZ4} EQUAL 1)
   message(STATUS "LZ4 library is enabled")
+  
+  if(DEFINED ENV{LZ4_INCLUDE})
+    set(LZ4_INCLUDE $ENV{LZ4_INCLUDE})
+  endif()
+  
+  if(DEFINED ENV{LZ4_LIB_DEBUG})
+    set(LZ4_LIB_DEBUG $ENV{LZ4_LIB_DEBUG})
+  endif()
+
+  if(DEFINED ENV{LZ4_LIB_RELEASE})
+    set(LZ4_LIB_RELEASE $ENV{LZ4_LIB_RELEASE})
+  endif()
+  
   set(LZ4_CXX_FLAGS -DLZ4)
   set(LZ4_LIBS debug ${LZ4_LIB_DEBUG} optimized ${LZ4_LIB_RELEASE})
 
@@ -126,6 +165,19 @@ endif ()
 
 if (${USE_ZLIB} EQUAL 1)
   message(STATUS "ZLIB library is enabled")
+
+  if(DEFINED ENV{ZLIB_INCLUDE})
+    set(ZLIB_INCLUDE $ENV{ZLIB_INCLUDE})
+  endif()
+  
+  if(DEFINED ENV{ZLIB_LIB_DEBUG})
+    set(ZLIB_LIB_DEBUG $ENV{ZLIB_LIB_DEBUG})
+  endif()
+
+  if(DEFINED ENV{ZLIB_LIB_RELEASE})
+    set(ZLIB_LIB_RELEASE $ENV{ZLIB_LIB_RELEASE})
+  endif()
+  
   set(ZLIB_CXX_FLAGS -DZLIB)
   set(ZLIB_LIBS debug ${ZLIB_LIB_DEBUG} optimized ${ZLIB_LIB_RELEASE})
 
@@ -157,6 +209,19 @@ endif ()
 if (${USE_JEMALLOC} EQUAL 1)
   message(STATUS "JEMALLOC library is enabled")
   set(JEMALLOC_CXX_FLAGS -DJEMALLOC)
+  
+  if(DEFINED ENV{JEMALLOC_INCLUDE})
+    set(JEMALLOC_INCLUDE $ENV{JEMALLOC_INCLUDE})
+  endif()
+  
+  if(DEFINED ENV{JEMALLOC_LIB_DEBUG})
+    set(JEMALLOC_LIB_DEBUG $ENV{JEMALLOC_LIB_DEBUG})
+  endif()
+
+  if(DEFINED ENV{JEMALLOC_LIB_RELEASE})
+    set(JEMALLOC_LIB_RELEASE $ENV{JEMALLOC_LIB_RELEASE})
+  endif()
+
   set(JEMALLOC_LIBS debug ${JEMALLOC_LIB_DEBUG} optimized ${JEMALLOC_LIB_RELEASE})
 
   add_definitions(${JEMALLOC_CXX_FLAGS})
diff --git a/src/rocksdb/tools/auto_sanity_test.sh b/src/rocksdb/tools/auto_sanity_test.sh
index bece681..07d444e 100755
--- a/src/rocksdb/tools/auto_sanity_test.sh
+++ b/src/rocksdb/tools/auto_sanity_test.sh
@@ -64,11 +64,11 @@ echo "Creating db based on the old commit --- $commit_old"
 ./old_db_sanity_test $dir_old create
 
 echo "============================================================="
-echo "[Backward Compability Check]"
+echo "[Backward Compatibility Check]"
 echo "Verifying old db $dir_old using the new commit --- $commit_new"
 ./new_db_sanity_test $dir_old verify
 if [ $? -ne 0 ]; then
-  echo "[ERROR] Backward Compability Check fails:"
+  echo "[ERROR] Backward Compatibility Check fails:"
   echo "    Verification of $dir_old using commit $commit_new failed."
   exit 2
 fi
@@ -78,7 +78,7 @@ echo "[Forward Compatibility Check]"
 echo "Verifying new db $dir_new using the old commit --- $commit_old"
 ./old_db_sanity_test $dir_new verify
 if [ $? -ne 0 ]; then
-  echo "[ERROR] Forward Compability Check fails:"
+  echo "[ERROR] Forward Compatibility Check fails:"
   echo "    $dir_new using commit $commit_old failed."
   exit 2
 fi
diff --git a/src/rocksdb/tools/db_crashtest.py b/src/rocksdb/tools/db_crashtest.py
index 6ef20ff..348ed12 100644
--- a/src/rocksdb/tools/db_crashtest.py
+++ b/src/rocksdb/tools/db_crashtest.py
@@ -4,161 +4,179 @@ import re
 import sys
 import time
 import random
-import getopt
 import logging
 import tempfile
 import subprocess
 import shutil
+import argparse
 
-# This script runs and kills db_stress multiple times. It checks consistency
-# in case of unsafe crashes in RocksDB.
+# params overwrite priority:
+#   for default:
+#       default_params < blackbox|whitebox_default_params < args
+#   for simple:
+#       simple_default_params < blackbox|whitebox_simple_default_params < args
 
-def main(argv):
-    try:
-        opts, args = getopt.getopt(argv, "hsd:t:i:o:b:")
-    except getopt.GetoptError:
-        print("db_crashtest.py -d <duration_test> -t <#threads> "
-              "-i <interval for one run> -o <ops_per_thread> "
-              "-b <write_buffer_size> [-s (simple mode)]\n")
-        sys.exit(2)
-
-    # default values, will be overridden by cmdline args
-    interval = 120  # time for one db_stress instance to run
-    duration = 6000  # total time for this script to test db_stress
-    threads = 32
-    # since we will be killing anyway, use large value for ops_per_thread
-    ops_per_thread = 100000000
-    write_buf_size = 4 * 1024 * 1024
-    simple_mode = False
-    write_buf_size_set = False
-    for opt, arg in opts:
-        if opt == '-h':
-            print("db_crashtest.py -d <duration_test>"
-                  " -t <#threads> -i <interval for one run>"
-                  " -o <ops_per_thread> -b <write_buffer_size>"
-                  " [-s (simple mode)]\n")
-            sys.exit()
-        elif opt == '-s':
-            simple_mode = True
-            if not write_buf_size_set:
-                write_buf_size = 32 * 1024 * 1024
-        elif opt == "-d":
-            duration = int(arg)
-        elif opt == "-t":
-            threads = int(arg)
-        elif opt == "-i":
-            interval = int(arg)
-        elif opt == "-o":
-            ops_per_thread = int(arg)
-        elif opt == "-b":
-            write_buf_size = int(arg)
-            write_buf_size_set = True
-        else:
-            print("db_crashtest.py -d <duration_test>"
-                  " -t <#threads> -i <interval for one run>"
-                  " -o <ops_per_thread> -b <write_buffer_size>\n")
-            sys.exit(2)
-
-    exit_time = time.time() + duration
+default_params = {
+    "block_size": 16384,
+    "cache_size": 1048576,
+    "delpercent": 5,
+    "destroy_db_initially": 0,
+    "disable_data_sync": 0,
+    "disable_wal": 0,
+    "filter_deletes": lambda: random.randint(0, 1),
+    "iterpercent": 10,
+    "max_background_compactions": 20,
+    "max_bytes_for_level_base": 10485760,
+    "max_key": 100000000,
+    "max_write_buffer_number": 3,
+    "memtablerep": "prefix_hash",
+    "mmap_read": lambda: random.randint(0, 1),
+    "open_files": 500000,
+    "prefix_size": 7,
+    "prefixpercent": 5,
+    "progress_reports": 0,
+    "readpercent": 45,
+    "reopen": 20,
+    "sync": 0,
+    "target_file_size_base": 2097152,
+    "target_file_size_multiplier": 2,
+    "threads": 32,
+    "verify_checksum": 1,
+    "write_buffer_size": 4 * 1024 * 1024,
+    "writepercent": 35,
+}
 
-    print("Running blackbox-crash-test with \ninterval_between_crash="
-          + str(interval) + "\ntotal-duration=" + str(duration)
-          + "\nthreads=" + str(threads) + "\nops_per_thread="
-          + str(ops_per_thread) + "\nwrite_buffer_size="
-          + str(write_buf_size) + "\n")
 
+def get_dbname(test_name):
     test_tmpdir = os.environ.get("TEST_TMPDIR")
     if test_tmpdir is None or test_tmpdir == "":
-        dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_')
+        dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_' + test_name)
     else:
-        dbname = test_tmpdir + "/rocksdb_crashtest"
+        dbname = test_tmpdir + "/rocksdb_crashtest_" + test_name
         shutil.rmtree(dbname, True)
+    return dbname
+
+blackbox_default_params = {
+    # total time for this script to test db_stress
+    "duration": 6000,
+    # time for one db_stress instance to run
+    "interval": 120,
+    # since we will be killing anyway, use large value for ops_per_thread
+    "ops_per_thread": 100000000,
+    "set_options_one_in": 10000,
+    "test_batches_snapshots": 1,
+}
+
+whitebox_default_params = {
+    "duration": 10000,
+    "log2_keys_per_lock": 10,
+    "nooverwritepercent": 1,
+    "ops_per_thread": 200000,
+    "test_batches_snapshots": lambda: random.randint(0, 1),
+    "write_buffer_size": 4 * 1024 * 1024,
+}
+
+simple_default_params = {
+    "block_size": 16384,
+    "cache_size": 1048576,
+    "column_families": 1,
+    "delpercent": 5,
+    "destroy_db_initially": 0,
+    "disable_data_sync": 0,
+    "disable_wal": 0,
+    "filter_deletes": lambda: random.randint(0, 1),
+    "iterpercent": 10,
+    "max_background_compactions": 1,
+    "max_bytes_for_level_base": 67108864,
+    "max_key": 100000000,
+    "max_write_buffer_number": 3,
+    "memtablerep": "skip_list",
+    "mmap_read": lambda: random.randint(0, 1),
+    "prefix_size": 0,
+    "prefixpercent": 0,
+    "progress_reports": 0,
+    "readpercent": 50,
+    "reopen": 20,
+    "sync": 0,
+    "target_file_size_base": 16777216,
+    "target_file_size_multiplier": 1,
+    "test_batches_snapshots": 0,
+    "threads": 32,
+    "verify_checksum": 1,
+    "write_buffer_size": 32 * 1024 * 1024,
+    "writepercent": 35,
+}
+
+blackbox_simple_default_params = {
+    "duration": 6000,
+    "interval": 120,
+    "open_files": -1,
+    "ops_per_thread": 100000000,
+    "set_options_one_in": 0,
+    "test_batches_snapshots": 0,
+}
+
+whitebox_simple_default_params = {
+    "duration": 10000,
+    "log2_keys_per_lock": 10,
+    "nooverwritepercent": 1,
+    "open_files": 500000,
+    "ops_per_thread": 200000,
+    "write_buffer_size": 32 * 1024 * 1024,
+}
+
+
+def gen_cmd_params(args):
+    params = {}
+
+    if args.simple:
+        params.update(simple_default_params)
+        if args.test_type == 'blackbox':
+            params.update(blackbox_simple_default_params)
+        if args.test_type == 'whitebox':
+            params.update(whitebox_simple_default_params)
+
+    if not args.simple:
+        params.update(default_params)
+        if args.test_type == 'blackbox':
+            params.update(blackbox_default_params)
+        if args.test_type == 'whitebox':
+            params.update(whitebox_default_params)
+
+    for k, v in vars(args).items():
+        if v is not None:
+            params[k] = v
+    return params
+
+
+def gen_cmd(params):
+    cmd = './db_stress ' + ' '.join(
+        '--{0}={1}'.format(k, v() if callable(v) else v)
+        for k, v in params.items()
+        if k not in set(['test_type', 'simple', 'duration', 'interval'])
+        and v is not None)
+    return cmd
+
+
+# This script runs and kills db_stress multiple times. It checks consistency
+# in case of unsafe crashes in RocksDB.
+def blackbox_crash_main(args):
+    cmd_params = gen_cmd_params(args)
+    dbname = get_dbname('blackbox')
+    exit_time = time.time() + cmd_params['duration']
+
+    print("Running blackbox-crash-test with \n"
+          + "interval_between_crash=" + str(cmd_params['interval']) + "\n"
+          + "total-duration=" + str(cmd_params['duration']) + "\n"
+          + "threads=" + str(cmd_params['threads']) + "\n"
+          + "ops_per_thread=" + str(cmd_params['ops_per_thread']) + "\n"
+          + "write_buffer_size=" + str(cmd_params['write_buffer_size']) + "\n")
 
     while time.time() < exit_time:
         run_had_errors = False
-        killtime = time.time() + interval
-
-        if simple_mode:
-            cmd = re.sub('\s+', ' ', """
-                ./db_stress
-                --column_families=1
-                --test_batches_snapshots=0
-                --ops_per_thread=%s
-                --threads=%s
-                --write_buffer_size=%s
-                --destroy_db_initially=0
-                --reopen=20
-                --readpercent=50
-                --prefixpercent=0
-                --writepercent=35
-                --delpercent=5
-                --iterpercent=10
-                --db=%s
-                --max_key=100000000
-                --mmap_read=%s
-                --block_size=16384
-                --cache_size=1048576
-                --open_files=-1
-                --verify_checksum=1
-                --sync=0
-                --progress_reports=0
-                --disable_wal=0
-                --disable_data_sync=1
-                --target_file_size_base=16777216
-                --target_file_size_multiplier=1
-                --max_write_buffer_number=3
-                --max_background_compactions=1
-                --max_bytes_for_level_base=67108864
-                --filter_deletes=%s
-                --memtablerep=skip_list
-                --prefix_size=0
-                --set_options_one_in=0
-                """ % (ops_per_thread,
-                       threads,
-                       write_buf_size,
-                       dbname,
-                       random.randint(0, 1),
-                       random.randint(0, 1)))
-        else:
-            cmd = re.sub('\s+', ' ', """
-                ./db_stress
-                --test_batches_snapshots=1
-                --ops_per_thread=%s
-                --threads=%s
-                --write_buffer_size=%s
-                --destroy_db_initially=0
-                --reopen=20
-                --readpercent=45
-                --prefixpercent=5
-                --writepercent=35
-                --delpercent=5
-                --iterpercent=10
-                --db=%s
-                --max_key=100000000
-                --mmap_read=%s
-                --block_size=16384
-                --cache_size=1048576
-                --open_files=500000
-                --verify_checksum=1
-                --sync=0
-                --progress_reports=0
-                --disable_wal=0
-                --disable_data_sync=1
-                --target_file_size_base=2097152
-                --target_file_size_multiplier=2
-                --max_write_buffer_number=3
-                --max_background_compactions=20
-                --max_bytes_for_level_base=10485760
-                --filter_deletes=%s
-                --memtablerep=prefix_hash
-                --prefix_size=7
-                --set_options_one_in=10000
-                """ % (ops_per_thread,
-                       threads,
-                       write_buf_size,
-                       dbname,
-                       random.randint(0, 1),
-                       random.randint(0, 1)))
+        killtime = time.time() + cmd_params['interval']
+
+        cmd = gen_cmd(dict(cmd_params.items() + {'db': dbname}.items()))
 
         child = subprocess.Popen([cmd],
                                  stderr=subprocess.PIPE, shell=True)
@@ -199,5 +217,151 @@ def main(argv):
     # we need to clean up after ourselves -- only do this on test success
     shutil.rmtree(dbname, True)
 
-if __name__ == "__main__":
-    sys.exit(main(sys.argv[1:]))
+
+# This python script runs db_stress multiple times. Some runs with
+# kill_random_test that causes rocksdb to crash at various points in code.
+def whitebox_crash_main(args):
+    cmd_params = gen_cmd_params(args)
+    dbname = get_dbname('whitebox')
+
+    cur_time = time.time()
+    exit_time = cur_time + cmd_params['duration']
+    half_time = cur_time + cmd_params['duration'] / 2
+
+    print("Running whitebox-crash-test with \n"
+          + "total-duration=" + str(cmd_params['duration']) + "\n"
+          + "threads=" + str(cmd_params['threads']) + "\n"
+          + "ops_per_thread=" + str(cmd_params['ops_per_thread']) + "\n"
+          + "write_buffer_size=" + str(cmd_params['write_buffer_size']) + "\n")
+
+    total_check_mode = 4
+    check_mode = 0
+    kill_random_test = 97
+    kill_mode = 0
+
+    while time.time() < exit_time:
+        if check_mode == 0:
+            additional_opts = {
+                # use large ops per thread since we will kill it anyway
+                "ops_per_thread": 100 * cmd_params['ops_per_thread'],
+            }
+            # run with kill_random_test, with three modes.
+            # Mode 0 covers all kill points. Mode 1 covers less kill points but
+            # increases change of triggering them. Mode 2 covers even less
+            # frequent kill points and further increases triggering change.
+            if kill_mode == 0:
+                additional_opts.update({
+                    "kill_random_test": kill_random_test,
+                })
+            elif kill_mode == 1:
+                additional_opts.update({
+                    "kill_random_test": (kill_random_test / 2 + 1),
+                    "kill_prefix_blacklist": "WritableFileWriter::Append,"
+                    + "WritableFileWriter::WriteBuffered",
+                })
+            elif kill_mode == 2:
+                additional_opts.update({
+                    "kill_random_test": (kill_random_test / 4 + 1),
+                    "kill_prefix_blacklist": "WritableFileWriter::Append,"
+                    "WritableFileWriter::WriteBuffered,"
+                    "PosixMmapFile::Allocate,WritableFileWriter::Flush",
+                })
+            # Run kill mode 0, 1 and 2 by turn.
+            kill_mode = (kill_mode + 1) % 3
+        elif check_mode == 1:
+            # normal run with universal compaction mode
+            additional_opts = {
+                "kill_random_test": None,
+                "ops_per_thread": cmd_params['ops_per_thread'],
+                "compaction_style": 1,
+            }
+        elif check_mode == 2:
+            # normal run with FIFO compaction mode
+            # ops_per_thread is divided by 5 because FIFO compaction
+            # style is quite a bit slower on reads with lot of files
+            additional_opts = {
+                "kill_random_test": None,
+                "ops_per_thread": cmd_params['ops_per_thread'] / 5,
+                "compaction_style": 2,
+            }
+        else:
+            # normal run
+            additional_opts = additional_opts = {
+                "kill_random_test": None,
+                "ops_per_thread": cmd_params['ops_per_thread'],
+            }
+
+        cmd = gen_cmd(dict(cmd_params.items() + additional_opts.items()
+                           + {'db': dbname}.items()))
+
+        print "Running:" + cmd + "\n"
+
+        popen = subprocess.Popen([cmd], stdout=subprocess.PIPE,
+                                 stderr=subprocess.STDOUT,
+                                 shell=True)
+        stdoutdata, stderrdata = popen.communicate()
+        retncode = popen.returncode
+        msg = ("check_mode={0}, kill option={1}, exitcode={2}\n".format(
+               check_mode, additional_opts['kill_random_test'], retncode))
+        print msg
+        print stdoutdata
+
+        expected = False
+        if additional_opts['kill_random_test'] is None and (retncode == 0):
+            # we expect zero retncode if no kill option
+            expected = True
+        elif additional_opts['kill_random_test'] is not None and retncode < 0:
+            # we expect negative retncode if kill option was given
+            expected = True
+
+        if not expected:
+            print "TEST FAILED. See kill option and exit code above!!!\n"
+            sys.exit(1)
+
+        stdoutdata = stdoutdata.lower()
+        errorcount = (stdoutdata.count('error') -
+                      stdoutdata.count('got errors 0 times'))
+        print "#times error occurred in output is " + str(errorcount) + "\n"
+
+        if (errorcount > 0):
+            print "TEST FAILED. Output has 'error'!!!\n"
+            sys.exit(2)
+        if (stdoutdata.find('fail') >= 0):
+            print "TEST FAILED. Output has 'fail'!!!\n"
+            sys.exit(2)
+
+        # First half of the duration, keep doing kill test. For the next half,
+        # try different modes.
+        if time.time() > half_time:
+            # we need to clean up after ourselves -- only do this on test
+            # success
+            shutil.rmtree(dbname, True)
+            check_mode = (check_mode + 1) % total_check_mode
+
+        time.sleep(1)  # time to stabilize after a kill
+
+
+def main():
+    parser = argparse.ArgumentParser(description="This script runs and kills \
+        db_stress multiple times")
+    parser.add_argument("test_type", choices=["blackbox", "whitebox"])
+    parser.add_argument("--simple", action="store_true")
+
+    all_params = dict(default_params.items()
+                      + blackbox_default_params.items()
+                      + whitebox_default_params.items()
+                      + simple_default_params.items()
+                      + blackbox_simple_default_params.items()
+                      + whitebox_simple_default_params.items())
+
+    for k, v in all_params.items():
+        parser.add_argument("--" + k, type=type(v() if callable(v) else v))
+    args = parser.parse_args()
+
+    if args.test_type == 'blackbox':
+        blackbox_crash_main(args)
+    if args.test_type == 'whitebox':
+        whitebox_crash_main(args)
+
+if __name__ == '__main__':
+    main()
diff --git a/src/rocksdb/tools/db_crashtest2.py b/src/rocksdb/tools/db_crashtest2.py
deleted file mode 100644
index a74053e..0000000
--- a/src/rocksdb/tools/db_crashtest2.py
+++ /dev/null
@@ -1,231 +0,0 @@
-#! /usr/bin/env python
-import os
-import re
-import sys
-import time
-import random
-import getopt
-import logging
-import tempfile
-import subprocess
-import shutil
-
-# This python script runs db_stress multiple times. Some runs with
-# kill_random_test that causes rocksdb to crash at various points in code.
-
-def main(argv):
-    try:
-        opts, args = getopt.getopt(argv, "hsd:t:k:o:b:")
-    except getopt.GetoptError:
-        print str(getopt.GetoptError)
-        print "db_crashtest2.py -d <duration_test> -t <#threads> " \
-              "-k <kills with prob 1/k> -o <ops_per_thread> "\
-              "-b <write_buffer_size> [-s (simple mode)]\n"
-        sys.exit(2)
-
-    # default values, will be overridden by cmdline args
-    kill_random_test = 97  # kill with probability 1/97 by default
-    duration = 10000  # total time for this script to test db_stress
-    threads = 32
-    ops_per_thread = 200000
-    write_buf_size = 4 * 1024 * 1024
-    simple_mode = False
-    write_buf_size_set = False
-
-    for opt, arg in opts:
-        if opt == '-h':
-            print "db_crashtest2.py -d <duration_test> -t <#threads> " \
-                  "-k <kills with prob 1/k> -o <ops_per_thread> " \
-                  "-b <write_buffer_size> [-s (simple mode)]\n"
-            sys.exit()
-        elif opt == '-s':
-            simple_mode = True
-            if not write_buf_size_set:
-                write_buf_size = 32 * 1024 * 1024
-        elif opt == "-d":
-            duration = int(arg)
-        elif opt == "-t":
-            threads = int(arg)
-        elif opt == "-k":
-            kill_random_test = int(arg)
-        elif opt == "-o":
-            ops_per_thread = int(arg)
-        elif opt == "-b":
-            write_buf_size = int(arg)
-            write_buf_size_set = True
-        else:
-            print "unrecognized option " + str(opt) + "\n"
-            print "db_crashtest2.py -d <duration_test> -t <#threads> " \
-                  "-k <kills with prob 1/k> -o <ops_per_thread> " \
-                  "-b <write_buffer_size>\n"
-            sys.exit(2)
-
-    cur_time = time.time()
-    exit_time = cur_time + duration
-    half_time = cur_time + duration / 2
-
-    print "Running whitebox-crash-test with \ntotal-duration=" + str(duration) \
-          + "\nthreads=" + str(threads) + "\nops_per_thread=" \
-          + str(ops_per_thread) + "\nwrite_buffer_size=" \
-          + str(write_buf_size) + "\n"
-
-    total_check_mode = 4
-    check_mode = 0
-
-    test_tmpdir = os.environ.get("TEST_TMPDIR")
-    if test_tmpdir is None or test_tmpdir == "":
-        dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest2_')
-    else:
-        dbname = test_tmpdir + "/rocksdb_crashtest2"
-        shutil.rmtree(dbname, True)
-
-    while time.time() < exit_time:
-        killoption = ""
-        if check_mode == 0:
-            # run with kill_random_test
-            killoption = " --kill_random_test=" + str(kill_random_test)
-            # use large ops per thread since we will kill it anyway
-            additional_opts = "--ops_per_thread=" + \
-                              str(100 * ops_per_thread) + killoption
-        elif check_mode == 1:
-            # normal run with universal compaction mode
-            additional_opts = "--ops_per_thread=" + str(ops_per_thread) + \
-                              " --compaction_style=1"
-        elif check_mode == 2:
-            # normal run with FIFO compaction mode
-            # ops_per_thread is divided by 5 because FIFO compaction
-            # style is quite a bit slower on reads with lot of files
-            additional_opts = "--ops_per_thread=" + str(ops_per_thread / 5) + \
-                              " --compaction_style=2"
-        else:
-            # normal run
-            additional_opts = "--ops_per_thread=" + str(ops_per_thread)
-
-        if simple_mode:
-            cmd = re.sub('\s+', ' ', """
-                ./db_stress
-                --column_families=1
-                --threads=%s
-                --write_buffer_size=%s
-                --destroy_db_initially=0
-                --reopen=20
-                --prefixpercent=0
-                --readpercent=50
-                --writepercent=35
-                --delpercent=5
-                --iterpercent=10
-                --db=%s
-                --max_key=100000000
-                --mmap_read=%s
-                --block_size=16384
-                --cache_size=1048576
-                --open_files=500000
-                --verify_checksum=1
-                --sync=0
-                --progress_reports=0
-                --disable_wal=0
-                --disable_data_sync=1
-                --target_file_size_base=16777216
-                --target_file_size_multiplier=1
-                --max_write_buffer_number=3
-                --max_background_compactions=1
-                --max_bytes_for_level_base=67108864
-                --filter_deletes=%s
-                --memtablerep=skip_list
-                --prefix_size=0
-                 %s
-                """ % (threads,
-                       write_buf_size,
-                       dbname,
-                       random.randint(0, 1),
-                       random.randint(0, 1),
-                       additional_opts))
-        else:
-            cmd = re.sub('\s+', ' ', """
-                ./db_stress
-                --test_batches_snapshots=%s
-                --threads=%s
-                --write_buffer_size=%s
-                --destroy_db_initially=0
-                --reopen=20
-                --readpercent=45
-                --prefixpercent=5
-                --writepercent=35
-                --delpercent=5
-                --iterpercent=10
-                --db=%s
-                --max_key=100000000
-                --mmap_read=%s
-                --block_size=16384
-                --cache_size=1048576
-                --open_files=500000
-                --verify_checksum=1
-                --sync=0
-                --progress_reports=0
-                --disable_wal=0
-                --disable_data_sync=1
-                --target_file_size_base=2097152
-                --target_file_size_multiplier=2
-                --max_write_buffer_number=3
-                --max_background_compactions=20
-                --max_bytes_for_level_base=10485760
-                --filter_deletes=%s
-                --memtablerep=prefix_hash
-                --prefix_size=7
-                %s
-                """ % (random.randint(0, 1),
-                       threads,
-                       write_buf_size,
-                       dbname,
-                       random.randint(0, 1),
-                       random.randint(0, 1),
-                       additional_opts))
-
-        print "Running:" + cmd + "\n"
-
-        popen = subprocess.Popen([cmd], stdout=subprocess.PIPE,
-                                 stderr=subprocess.STDOUT,
-                                 shell=True)
-        stdoutdata, stderrdata = popen.communicate()
-        retncode = popen.returncode
-        msg = ("check_mode={0}, kill option={1}, exitcode={2}\n".format(
-               check_mode, killoption, retncode))
-        print msg
-        print stdoutdata
-
-        expected = False
-        if (killoption == '') and (retncode == 0):
-            # we expect zero retncode if no kill option
-            expected = True
-        elif killoption != '' and retncode < 0:
-            # we expect negative retncode if kill option was given
-            expected = True
-
-        if not expected:
-            print "TEST FAILED. See kill option and exit code above!!!\n"
-            sys.exit(1)
-
-        stdoutdata = stdoutdata.lower()
-        errorcount = (stdoutdata.count('error') -
-                      stdoutdata.count('got errors 0 times'))
-        print "#times error occurred in output is " + str(errorcount) + "\n"
-
-        if (errorcount > 0):
-            print "TEST FAILED. Output has 'error'!!!\n"
-            sys.exit(2)
-        if (stdoutdata.find('fail') >= 0):
-            print "TEST FAILED. Output has 'fail'!!!\n"
-            sys.exit(2)
-
-        # First half of the duration, keep doing kill test. For the next half,
-        # try different modes.
-        if time.time() > half_time:
-            # we need to clean up after ourselves -- only do this on test
-            # success
-            shutil.rmtree(dbname, True)
-            check_mode = (check_mode + 1) % total_check_mode
-
-        time.sleep(1)  # time to stabilize after a kill
-
-if __name__ == "__main__":
-    sys.exit(main(sys.argv[1:]))
diff --git a/src/rocksdb/tools/db_stress.cc b/src/rocksdb/tools/db_stress.cc
index 634045d..669ca6c 100644
--- a/src/rocksdb/tools/db_stress.cc
+++ b/src/rocksdb/tools/db_stress.cc
@@ -277,6 +277,11 @@ static const bool FLAGS_kill_random_test_dummy __attribute__((unused)) =
     RegisterFlagValidator(&FLAGS_kill_random_test, &ValidateInt32Positive);
 extern int rocksdb_kill_odds;
 
+DEFINE_string(kill_prefix_blacklist, "",
+              "If non-empty, kill points with prefix in the list given will be"
+              " skipped. Items are comma-separated.");
+extern std::vector<std::string> rocksdb_kill_prefix_blacklist;
+
 DEFINE_bool(disable_wal, false, "If true, do not write WAL for write.");
 
 DEFINE_int32(target_file_size_base, 64 * KB,
@@ -356,6 +361,21 @@ enum rocksdb::CompressionType StringToCompressionType(const char* ctype) {
   fprintf(stdout, "Cannot parse compression type '%s'\n", ctype);
   return rocksdb::kSnappyCompression; //default value
 }
+
+std::vector<std::string> SplitString(std::string src) {
+  std::vector<std::string> ret;
+  if (src.empty()) {
+    return ret;
+  }
+  size_t pos = 0;
+  size_t pos_comma;
+  while ((pos_comma = src.find(',', pos)) != std::string::npos) {
+    ret.push_back(src.substr(pos, pos_comma - pos));
+    pos = pos_comma + 1;
+  }
+  ret.push_back(src.substr(pos, src.length()));
+  return ret;
+}
 }  // namespace
 
 DEFINE_string(compression_type, "snappy",
@@ -590,7 +610,8 @@ class Stats {
             "", bytes_mb, rate, (100*writes_)/done_, done_);
     fprintf(stdout, "%-12s: Wrote %ld times\n", "", writes_);
     fprintf(stdout, "%-12s: Deleted %ld times\n", "", deletes_);
-    fprintf(stdout, "%-12s: Single deleted %ld times\n", "", single_deletes_);
+    fprintf(stdout, "%-12s: Single deleted %" ROCKSDB_PRIszt " times\n", "",
+           single_deletes_);
     fprintf(stdout, "%-12s: %ld read and %ld found the key\n", "",
             gets_, founds_);
     fprintf(stdout, "%-12s: Prefix scanned %ld times\n", "", prefixes_);
@@ -1921,6 +1942,14 @@ class StressTest {
 
     fprintf(stdout, "Memtablerep               : %s\n", memtablerep);
 
+    fprintf(stdout, "Test kill odd             : %d\n", rocksdb_kill_odds);
+    if (!rocksdb_kill_prefix_blacklist.empty()) {
+      fprintf(stdout, "Skipping kill points prefixes:\n");
+      for (auto& p : rocksdb_kill_prefix_blacklist) {
+        fprintf(stdout, "  %s\n", p.c_str());
+      }
+    }
+
     fprintf(stdout, "------------------------------------------------\n");
   }
 
@@ -1952,7 +1981,6 @@ class StressTest {
     options_.disableDataSync = FLAGS_disable_data_sync;
     options_.use_fsync = FLAGS_use_fsync;
     options_.allow_mmap_reads = FLAGS_mmap_read;
-    rocksdb_kill_odds = FLAGS_kill_random_test;
     options_.target_file_size_base = FLAGS_target_file_size_base;
     options_.target_file_size_multiplier = FLAGS_target_file_size_multiplier;
     options_.max_bytes_for_level_base = FLAGS_max_bytes_for_level_base;
@@ -2186,6 +2214,9 @@ int main(int argc, char** argv) {
       FLAGS_db = default_db_path;
   }
 
+  rocksdb_kill_odds = FLAGS_kill_random_test;
+  rocksdb_kill_prefix_blacklist = SplitString(FLAGS_kill_prefix_blacklist);
+
   rocksdb::StressTest stress;
   if (stress.Run()) {
     return 0;
diff --git a/src/rocksdb/util/ldb_cmd.cc b/src/rocksdb/tools/ldb_cmd.cc
similarity index 97%
rename from src/rocksdb/util/ldb_cmd.cc
rename to src/rocksdb/tools/ldb_cmd.cc
index a441d71..b9adef0 100644
--- a/src/rocksdb/util/ldb_cmd.cc
+++ b/src/rocksdb/tools/ldb_cmd.cc
@@ -4,7 +4,7 @@
 //  of patent rights can be found in the PATENTS file in the same directory.
 //
 #ifndef ROCKSDB_LITE
-#include "util/ldb_cmd.h"
+#include "tools/ldb_cmd.h"
 
 #ifndef __STDC_FORMAT_MACROS
 #define __STDC_FORMAT_MACROS
@@ -21,11 +21,11 @@
 #include "rocksdb/write_batch.h"
 #include "rocksdb/cache.h"
 #include "rocksdb/table_properties.h"
+#include "table/scoped_arena_iterator.h"
 #include "port/dirent.h"
+#include "tools/sst_dump_tool_imp.h"
 #include "util/coding.h"
-#include "util/sst_dump_tool_imp.h"
 #include "util/string_util.h"
-#include "util/scoped_arena_iterator.h"
 #include "utilities/ttl/db_ttl_impl.h"
 
 #include <cstdlib>
@@ -449,7 +449,10 @@ void CompactorCommand::DoCommand() {
     end = new Slice(to_);
   }
 
-  db_->CompactRange(CompactRangeOptions(), begin, end);
+  CompactRangeOptions cro;
+  cro.bottommost_level_compaction = BottommostLevelCompaction::kForce;
+
+  db_->CompactRange(cro, begin, end);
   exec_state_ = LDBCommandExecuteResult::Succeed("");
 
   delete begin;
@@ -809,7 +812,7 @@ void InternalDumpCommand::DoCommand() {
   uint64_t s1=0,s2=0;
   // Setup internal key iterator
   Arena arena;
-  ScopedArenaIterator iter(idb->TEST_NewInternalIterator(&arena));
+  ScopedArenaIterator iter(idb->NewInternalIterator(&arena));
   Status st = iter->status();
   if (!st.ok()) {
     exec_state_ =
@@ -1438,7 +1441,21 @@ void DumpWalFile(std::string wal_file, bool print_header, bool print_values,
     }
   } else {
     StdErrReporter reporter;
-    log::Reader reader(move(wal_file_reader), &reporter, true, 0);
+    uint64_t log_number;
+    FileType type;
+
+    // we need the log number, but ParseFilename expects dbname/NNN.log.
+    string sanitized = wal_file;
+    size_t lastslash = sanitized.rfind('/');
+    if (lastslash != std::string::npos)
+      sanitized = sanitized.substr(lastslash + 1);
+    if (!ParseFileName(sanitized, &log_number, &type)) {
+      // bogus input, carry on as best we can
+      log_number = 0;
+    }
+    DBOptions db_options;
+    log::Reader reader(db_options.info_log, move(wal_file_reader), &reporter,
+                       true, 0, log_number);
     string scratch;
     WriteBatch batch;
     Slice record;
@@ -1745,7 +1762,6 @@ void ScanCommand::DoCommand() {
   for ( ;
         it->Valid() && (!end_key_specified_ || it->key().ToString() < end_key_);
         it->Next()) {
-    string key = ldb_options_.key_formatter->Format(it->key());
     if (is_db_ttl_) {
       TtlIterator* it_ttl = dynamic_cast<TtlIterator*>(it);
       assert(it_ttl);
@@ -1757,11 +1773,29 @@ void ScanCommand::DoCommand() {
         fprintf(stdout, "%s ", ReadableTime(rawtime).c_str());
       }
     }
-    string value = it->value().ToString();
-    fprintf(stdout, "%s : %s\n",
-            (is_key_hex_ ? "0x" + it->key().ToString(true) : key).c_str(),
-            (is_value_hex_ ? StringToHex(value) : value).c_str()
-        );
+
+    Slice key_slice = it->key();
+    Slice val_slice = it->value();
+
+    std::string formatted_key;
+    if (is_key_hex_) {
+      formatted_key = "0x" + key_slice.ToString(true /* hex */);
+      key_slice = formatted_key;
+    } else if (ldb_options_.key_formatter) {
+      formatted_key = ldb_options_.key_formatter->Format(key_slice);
+      key_slice = formatted_key;
+    }
+
+    std::string formatted_value;
+    if (is_value_hex_) {
+      formatted_value = "0x" + val_slice.ToString(true /* hex */);
+      val_slice = formatted_value;
+    }
+
+    fprintf(stdout, "%.*s : %.*s\n",
+        static_cast<int>(key_slice.size()), key_slice.data(),
+        static_cast<int>(val_slice.size()), val_slice.data());
+
     num_keys_scanned++;
     if (max_keys_scanned_ >= 0 && num_keys_scanned >= max_keys_scanned_) {
       break;
diff --git a/src/rocksdb/util/ldb_cmd.h b/src/rocksdb/tools/ldb_cmd.h
similarity index 99%
rename from src/rocksdb/util/ldb_cmd.h
rename to src/rocksdb/tools/ldb_cmd.h
index d48fcf6..71d5f64 100644
--- a/src/rocksdb/util/ldb_cmd.h
+++ b/src/rocksdb/tools/ldb_cmd.h
@@ -23,8 +23,8 @@
 #include "rocksdb/options.h"
 #include "rocksdb/slice.h"
 #include "rocksdb/utilities/db_ttl.h"
+#include "tools/ldb_cmd_execute_result.h"
 #include "util/logging.h"
-#include "util/ldb_cmd_execute_result.h"
 #include "util/string_util.h"
 #include "utilities/ttl/db_ttl_impl.h"
 
diff --git a/src/rocksdb/util/ldb_cmd_execute_result.h b/src/rocksdb/tools/ldb_cmd_execute_result.h
similarity index 100%
rename from src/rocksdb/util/ldb_cmd_execute_result.h
rename to src/rocksdb/tools/ldb_cmd_execute_result.h
diff --git a/src/rocksdb/util/ldb_cmd_test.cc b/src/rocksdb/tools/ldb_cmd_test.cc
similarity index 85%
rename from src/rocksdb/util/ldb_cmd_test.cc
rename to src/rocksdb/tools/ldb_cmd_test.cc
index c918cf5..edb6a21 100644
--- a/src/rocksdb/util/ldb_cmd_test.cc
+++ b/src/rocksdb/tools/ldb_cmd_test.cc
@@ -3,7 +3,9 @@
 //  LICENSE file in the root directory of this source tree. An additional grant
 //  of patent rights can be found in the PATENTS file in the same directory.
 //
-#include "util/ldb_cmd.h"
+#ifndef ROCKSDB_LITE
+
+#include "tools/ldb_cmd.h"
 #include "util/testharness.h"
 
 class LdbCmdTest : public testing::Test {};
@@ -42,3 +44,12 @@ int main(int argc, char** argv) {
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }
+#else
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+  fprintf(stderr, "SKIPPED as LDBCommand is not supported in ROCKSDB_LITE\n");
+  return 0;
+}
+
+#endif  // ROCKSDB_LITE
diff --git a/src/rocksdb/util/ldb_tool.cc b/src/rocksdb/tools/ldb_tool.cc
similarity index 93%
rename from src/rocksdb/util/ldb_tool.cc
rename to src/rocksdb/tools/ldb_tool.cc
index fe84fa9..c1b23eb 100644
--- a/src/rocksdb/util/ldb_tool.cc
+++ b/src/rocksdb/tools/ldb_tool.cc
@@ -5,20 +5,11 @@
 //
 #ifndef ROCKSDB_LITE
 #include "rocksdb/ldb_tool.h"
-#include "util/ldb_cmd.h"
+#include "tools/ldb_cmd.h"
 
 namespace rocksdb {
 
-class DefaultSliceFormatter : public SliceFormatter {
- public:
-  virtual std::string Format(const Slice& s) const override {
-    return s.ToString();
-  }
-};
-
-LDBOptions::LDBOptions()
-    : key_formatter(new DefaultSliceFormatter()) {
-}
+LDBOptions::LDBOptions() {}
 
 class LDBCommandRunner {
 public:
diff --git a/src/rocksdb/tools/reduce_levels_test.cc b/src/rocksdb/tools/reduce_levels_test.cc
index f3091ed..863d860 100644
--- a/src/rocksdb/tools/reduce_levels_test.cc
+++ b/src/rocksdb/tools/reduce_levels_test.cc
@@ -9,10 +9,10 @@
 #include "rocksdb/db.h"
 #include "db/db_impl.h"
 #include "db/version_set.h"
+#include "tools/ldb_cmd.h"
 #include "util/logging.h"
 #include "util/testutil.h"
 #include "util/testharness.h"
-#include "util/ldb_cmd.h"
 
 namespace rocksdb {
 
diff --git a/src/rocksdb/util/sst_dump_test.cc b/src/rocksdb/tools/sst_dump_test.cc
similarity index 98%
rename from src/rocksdb/util/sst_dump_test.cc
rename to src/rocksdb/tools/sst_dump_test.cc
index 50e9f10..b40a334 100644
--- a/src/rocksdb/util/sst_dump_test.cc
+++ b/src/rocksdb/tools/sst_dump_test.cc
@@ -62,6 +62,7 @@ void createSST(const std::string& file_name,
       TableBuilderOptions(imoptions, ikc, &int_tbl_prop_collector_factories,
                           CompressionType::kNoCompression, CompressionOptions(),
                           false),
+      TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
       file_writer.get()));
 
   // Populate slightly more than 1K keys
diff --git a/src/rocksdb/util/sst_dump_tool.cc b/src/rocksdb/tools/sst_dump_tool.cc
similarity index 98%
rename from src/rocksdb/util/sst_dump_tool.cc
rename to src/rocksdb/tools/sst_dump_tool.cc
index 2e31901..ae22da3 100644
--- a/src/rocksdb/util/sst_dump_tool.cc
+++ b/src/rocksdb/tools/sst_dump_tool.cc
@@ -5,7 +5,7 @@
 //
 #ifndef ROCKSDB_LITE
 
-#include "util/sst_dump_tool_imp.h"
+#include "tools/sst_dump_tool_imp.h"
 
 #ifndef __STDC_FORMAT_MACROS
 #define __STDC_FORMAT_MACROS
@@ -124,8 +124,10 @@ uint64_t SstFileReader::CalculateCompressedTableSize(
   BlockBasedTableFactory block_based_tf(table_options);
   unique_ptr<TableBuilder> table_builder;
   table_builder.reset(block_based_tf.NewTableBuilder(
-                         tb_options, dest_writer.get()));
-  unique_ptr<Iterator> iter(table_reader_->NewIterator(ReadOptions()));
+      tb_options,
+      TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
+      dest_writer.get()));
+  unique_ptr<InternalIterator> iter(table_reader_->NewIterator(ReadOptions()));
   for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
     if (!iter->status().ok()) {
       fputs(iter->status().ToString().c_str(), stderr);
@@ -259,8 +261,8 @@ Status SstFileReader::ReadSequential(bool print_kv,
     return init_result_;
   }
 
-  Iterator* iter = table_reader_->NewIterator(ReadOptions(verify_checksum_,
-                                                         false));
+  InternalIterator* iter =
+      table_reader_->NewIterator(ReadOptions(verify_checksum_, false));
   uint64_t i = 0;
   if (has_from) {
     InternalKey ikey;
diff --git a/src/rocksdb/util/sst_dump_tool_imp.h b/src/rocksdb/tools/sst_dump_tool_imp.h
similarity index 99%
rename from src/rocksdb/util/sst_dump_tool_imp.h
rename to src/rocksdb/tools/sst_dump_tool_imp.h
index b7d9e4d..dd65d3b 100644
--- a/src/rocksdb/util/sst_dump_tool_imp.h
+++ b/src/rocksdb/tools/sst_dump_tool_imp.h
@@ -2,8 +2,8 @@
 // This source code is licensed under the BSD-style license found in the
 // LICENSE file in the root directory of this source tree. An additional grant
 // of patent rights can be found in the PATENTS file in the same directory.
-#ifndef ROCKSDB_LITE
 #pragma once
+#ifndef ROCKSDB_LITE
 
 #include "rocksdb/sst_dump_tool.h"
 
@@ -29,8 +29,8 @@
 #include "table/format.h"
 #include "table/meta_blocks.h"
 #include "table/plain_table_factory.h"
+#include "tools/ldb_cmd.h"
 #include "util/file_reader_writer.h"
-#include "util/ldb_cmd.h"
 #include "util/random.h"
 #include "util/testharness.h"
 #include "util/testutil.h"
diff --git a/src/rocksdb/tools/write_stress.cc b/src/rocksdb/tools/write_stress.cc
new file mode 100644
index 0000000..c0501fa
--- /dev/null
+++ b/src/rocksdb/tools/write_stress.cc
@@ -0,0 +1,306 @@
+// Copyright (c) 2015, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+//
+//
+// The goal of this tool is to be a simple stress test with focus on catching:
+// * bugs in compaction/flush processes, especially the ones that cause
+// assertion errors
+// * bugs in the code that deletes obsolete files
+//
+// There are two parts of the test:
+// * write_stress, a binary that writes to the database
+// * write_stress_runner.py, a script that invokes and kills write_stress
+//
+// Here are some interesting parts of write_stress:
+// * Runs with very high concurrency of compactions and flushes (32 threads
+// total) and tries to create a huge amount of small files
+// * The keys written to the database are not uniformly distributed -- there is
+// a 3-character prefix that mutates occasionally (in prefix mutator thread), in
+// such a way that the first character mutates slower than second, which mutates
+// slower than third character. That way, the compaction stress tests some
+// interesting compaction features like trivial moves and bottommost level
+// calculation
+// * There is a thread that creates an iterator, holds it for couple of seconds
+// and then iterates over all keys. This is supposed to test RocksDB's abilities
+// to keep the files alive when there are references to them.
+// * Some writes trigger WAL sync. This is stress testing our WAL sync code.
+// * At the end of the run, we make sure that we didn't leak any of the sst
+// files
+//
+// write_stress_runner.py changes the mode in which we run write_stress and also
+// kills and restarts it. There are some interesting characteristics:
+// * At the beginning we divide the full test runtime into smaller parts --
+// shorter runtimes (couple of seconds) and longer runtimes (100, 1000) seconds
+// * The first time we run write_stress, we destroy the old DB. Every next time
+// during the test, we use the same DB.
+// * We can run in kill mode or clean-restart mode. Kill mode kills the
+// write_stress violently.
+// * We can run in mode where delete_obsolete_files_with_fullscan is true or
+// false
+// * We can run with low_open_files mode turned on or off. When it's turned on,
+// we configure table cache to only hold a couple of files -- that way we need
+// to reopen files every time we access them.
+//
+// Another goal was to create a stress test without a lot of parameters. So
+// tools/write_stress_runner.py should only take one parameter -- runtime_sec
+// and it should figure out everything else on its own.
+
+#include <cstdio>
+
+#ifndef GFLAGS
+int main() {
+  fprintf(stderr, "Please install gflags to run rocksdb tools\n");
+  return 1;
+}
+#else
+
+#include <gflags/gflags.h>
+
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+#include <atomic>
+#include <random>
+#include <set>
+#include <string>
+#include <thread>
+
+#include "rocksdb/db.h"
+#include "rocksdb/env.h"
+#include "rocksdb/options.h"
+#include "rocksdb/slice.h"
+
+#include "db/filename.h"
+
+using GFLAGS::ParseCommandLineFlags;
+using GFLAGS::RegisterFlagValidator;
+using GFLAGS::SetUsageMessage;
+
+DEFINE_int32(key_size, 10, "Key size");
+DEFINE_int32(value_size, 100, "Value size");
+DEFINE_string(db, "", "Use the db with the following name.");
+DEFINE_bool(destroy_db, true,
+            "Destory the existing DB before running the test");
+
+DEFINE_int32(runtime_sec, 10 * 60, "How long are we running for, in seconds");
+DEFINE_int32(seed, 139, "Random seed");
+
+DEFINE_double(prefix_mutate_period_sec, 1.0,
+              "How often are we going to mutate the prefix");
+DEFINE_double(first_char_mutate_probability, 0.1,
+              "How likely are we to mutate the first char every period");
+DEFINE_double(second_char_mutate_probability, 0.2,
+              "How likely are we to mutate the second char every period");
+DEFINE_double(third_char_mutate_probability, 0.5,
+              "How likely are we to mutate the third char every period");
+
+DEFINE_int32(iterator_hold_sec, 5,
+             "How long will the iterator hold files before it gets destroyed");
+
+DEFINE_double(sync_probability, 0.01, "How often are we syncing writes");
+DEFINE_bool(delete_obsolete_files_with_fullscan, false,
+            "If true, we delete obsolete files after each compaction/flush "
+            "using GetChildren() API");
+DEFINE_bool(low_open_files_mode, false,
+            "If true, we set max_open_files to 20, so that every file access "
+            "needs to reopen it");
+
+namespace rocksdb {
+
+static const int kPrefixSize = 3;
+
+class WriteStress {
+ public:
+  WriteStress() : stop_(false) {
+    // initialize key_prefix
+    for (int i = 0; i < kPrefixSize; ++i) {
+      key_prefix_[i].store('a');
+    }
+
+    // Choose a location for the test database if none given with --db=<path>
+    if (FLAGS_db.empty()) {
+      std::string default_db_path;
+      Env::Default()->GetTestDirectory(&default_db_path);
+      default_db_path += "/write_stress";
+      FLAGS_db = default_db_path;
+    }
+
+    Options options;
+    if (FLAGS_destroy_db) {
+      DestroyDB(FLAGS_db, options);  // ignore
+    }
+
+    // make the LSM tree deep, so that we have many concurrent flushes and
+    // compactions
+    options.create_if_missing = true;
+    options.write_buffer_size = 256 * 1024;              // 256k
+    options.max_bytes_for_level_base = 1 * 1024 * 1204;  // 1MB
+    options.target_file_size_base = 100 * 1204;          // 100k
+    options.max_write_buffer_number = 16;
+    options.max_background_compactions = 16;
+    options.max_background_flushes = 16;
+    options.max_open_files = FLAGS_low_open_files_mode ? 20 : -1;
+    if (FLAGS_delete_obsolete_files_with_fullscan) {
+      options.delete_obsolete_files_period_micros = 0;
+    }
+
+    // open DB
+    DB* db;
+    Status s = DB::Open(options, FLAGS_db, &db);
+    if (!s.ok()) {
+      fprintf(stderr, "Can't open database: %s\n", s.ToString().c_str());
+      std::abort();
+    }
+    db_.reset(db);
+  }
+
+  void WriteThread() {
+    std::mt19937 rng(static_cast<unsigned int>(FLAGS_seed));
+    std::uniform_real_distribution<double> dist(0, 1);
+
+    auto random_string = [](std::mt19937& r, int len) {
+      std::uniform_int_distribution<int> char_dist('a', 'z');
+      std::string ret;
+      for (int i = 0; i < len; ++i) {
+        ret += char_dist(r);
+      }
+      return ret;
+    };
+
+    while (!stop_.load(std::memory_order_relaxed)) {
+      std::string prefix;
+      prefix.resize(kPrefixSize);
+      for (int i = 0; i < kPrefixSize; ++i) {
+        prefix[i] = key_prefix_[i].load(std::memory_order_relaxed);
+      }
+      auto key = prefix + random_string(rng, FLAGS_key_size - kPrefixSize);
+      auto value = random_string(rng, FLAGS_value_size);
+      WriteOptions woptions;
+      woptions.sync = dist(rng) < FLAGS_sync_probability;
+      auto s = db_->Put(woptions, key, value);
+      if (!s.ok()) {
+        fprintf(stderr, "Write to DB failed: %s\n", s.ToString().c_str());
+        std::abort();
+      }
+    }
+  }
+
+  void IteratorHoldThread() {
+    while (!stop_.load(std::memory_order_relaxed)) {
+      std::unique_ptr<Iterator> iterator(db_->NewIterator(ReadOptions()));
+      Env::Default()->SleepForMicroseconds(FLAGS_iterator_hold_sec * 1000 *
+                                           1000LL);
+      for (iterator->SeekToFirst(); iterator->Valid(); iterator->Next()) {
+      }
+      if (!iterator->status().ok()) {
+        fprintf(stderr, "Iterator statuts not OK: %s\n",
+                iterator->status().ToString().c_str());
+        std::abort();
+      }
+    }
+  }
+
+  void PrefixMutatorThread() {
+    std::mt19937 rng(static_cast<unsigned int>(FLAGS_seed));
+    std::uniform_real_distribution<double> dist(0, 1);
+    std::uniform_int_distribution<int> char_dist('a', 'z');
+    while (!stop_.load(std::memory_order_relaxed)) {
+      Env::Default()->SleepForMicroseconds(FLAGS_prefix_mutate_period_sec *
+                                           1000 * 1000LL);
+      if (dist(rng) < FLAGS_first_char_mutate_probability) {
+        key_prefix_[0].store(char_dist(rng), std::memory_order_relaxed);
+      }
+      if (dist(rng) < FLAGS_second_char_mutate_probability) {
+        key_prefix_[1].store(char_dist(rng), std::memory_order_relaxed);
+      }
+      if (dist(rng) < FLAGS_third_char_mutate_probability) {
+        key_prefix_[2].store(char_dist(rng), std::memory_order_relaxed);
+      }
+    }
+  }
+
+  int Run() {
+    threads_.emplace_back([&]() { WriteThread(); });
+    threads_.emplace_back([&]() { PrefixMutatorThread(); });
+    threads_.emplace_back([&]() { IteratorHoldThread(); });
+
+    if (FLAGS_runtime_sec == -1) {
+      // infinite runtime, until we get killed
+      while (true) {
+        Env::Default()->SleepForMicroseconds(1000 * 1000);
+      }
+    }
+
+    Env::Default()->SleepForMicroseconds(FLAGS_runtime_sec * 1000 * 1000);
+
+    stop_.store(true, std::memory_order_relaxed);
+    for (auto& t : threads_) {
+      t.join();
+    }
+    threads_.clear();
+
+// Skip checking for leaked files in ROCKSDB_LITE since we don't have access to
+// function GetLiveFilesMetaData
+#ifndef ROCKSDB_LITE
+    // let's see if we leaked some files
+    db_->PauseBackgroundWork();
+    std::vector<LiveFileMetaData> metadata;
+    db_->GetLiveFilesMetaData(&metadata);
+    std::set<uint64_t> sst_file_numbers;
+    for (const auto& file : metadata) {
+      uint64_t number;
+      FileType type;
+      if (!ParseFileName(file.name, &number, "LOG", &type)) {
+        continue;
+      }
+      if (type == kTableFile) {
+        sst_file_numbers.insert(number);
+      }
+    }
+
+    std::vector<std::string> children;
+    Env::Default()->GetChildren(FLAGS_db, &children);
+    for (const auto& child : children) {
+      uint64_t number;
+      FileType type;
+      if (!ParseFileName(child, &number, "LOG", &type)) {
+        continue;
+      }
+      if (type == kTableFile) {
+        if (sst_file_numbers.find(number) == sst_file_numbers.end()) {
+          fprintf(stderr,
+                  "Found a table file in DB path that should have been "
+                  "deleted: %s\n",
+                  child.c_str());
+          std::abort();
+        }
+      }
+    }
+    db_->ContinueBackgroundWork();
+#endif  // !ROCKSDB_LITE
+
+    return 0;
+  }
+
+ private:
+  // each key is prepended with this prefix. we occasionally change it. third
+  // letter is changed more frequently than second, which is changed more
+  // frequently than the first one.
+  std::atomic<char> key_prefix_[kPrefixSize];
+  std::atomic<bool> stop_;
+  std::vector<std::thread> threads_;
+  std::unique_ptr<DB> db_;
+};
+
+}  // namespace rocksdb
+
+int main(int argc, char** argv) {
+  SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) +
+                  " [OPTIONS]...");
+  ParseCommandLineFlags(&argc, &argv, true);
+  rocksdb::WriteStress write_stress;
+  return write_stress.Run();
+}
+
+#endif  // GFLAGS
diff --git a/src/rocksdb/tools/write_stress_runner.py b/src/rocksdb/tools/write_stress_runner.py
new file mode 100644
index 0000000..f696578
--- /dev/null
+++ b/src/rocksdb/tools/write_stress_runner.py
@@ -0,0 +1,73 @@
+#! /usr/bin/env python
+import subprocess
+import argparse
+import random
+import time
+import sys
+
+
+def generate_runtimes(total_runtime):
+    # combination of short runtimes and long runtimes, with heavier
+    # weight on short runtimes
+    possible_runtimes_sec = range(1, 10) + range(1, 20) + [100, 1000]
+    runtimes = []
+    while total_runtime > 0:
+        chosen = random.choice(possible_runtimes_sec)
+        chosen = min(chosen, total_runtime)
+        runtimes.append(chosen)
+        total_runtime -= chosen
+    return runtimes
+
+
+def main(args):
+    runtimes = generate_runtimes(int(args.runtime_sec))
+    print "Going to execute write stress for " + str(runtimes)
+    first_time = True
+
+    for runtime in runtimes:
+        kill = random.choice([False, True])
+
+        cmd = './write_stress --runtime_sec=' + \
+            ("-1" if kill else str(runtime))
+
+        if len(args.db) > 0:
+            cmd = cmd + ' --db=' + args.db
+
+        if first_time:
+            first_time = False
+        else:
+            # use current db
+            cmd = cmd + ' --destroy_db=false'
+        if random.choice([False, True]):
+            cmd = cmd + ' --delete_obsolete_files_with_fullscan=true'
+        if random.choice([False, True]):
+            cmd = cmd + ' --low_open_files_mode=true'
+
+        print("Running write_stress for %d seconds (%s): %s" %
+              (runtime, ("kill-mode" if kill else "clean-shutdown-mode"),
+              cmd))
+
+        child = subprocess.Popen([cmd], shell=True)
+        killtime = time.time() + runtime
+        while not kill or time.time() < killtime:
+            time.sleep(1)
+            if child.poll() is not None:
+                if child.returncode == 0:
+                    break
+                else:
+                    print("ERROR: write_stress died with exitcode=%d\n"
+                          % child.returncode)
+                    sys.exit(1)
+        if kill:
+            child.kill()
+        # breathe
+        time.sleep(3)
+
+if __name__ == '__main__':
+    random.seed(time.time())
+    parser = argparse.ArgumentParser(description="This script runs and kills \
+        write_stress multiple times")
+    parser.add_argument("--runtime_sec", default='1000')
+    parser.add_argument("--db", default='')
+    args = parser.parse_args()
+    main(args)
diff --git a/src/rocksdb/util/auto_roll_logger.cc b/src/rocksdb/util/auto_roll_logger.cc
index 4ea0356..e9b13d1 100644
--- a/src/rocksdb/util/auto_roll_logger.cc
+++ b/src/rocksdb/util/auto_roll_logger.cc
@@ -122,22 +122,25 @@ bool AutoRollLogger::LogExpired() {
   return cached_now >= ctime_ + kLogFileTimeToRoll;
 }
 
-Status CreateLoggerFromOptions(
-    const std::string& dbname,
-    const std::string& db_log_dir,
-    Env* env,
-    const DBOptions& options,
-    std::shared_ptr<Logger>* logger) {
+Status CreateLoggerFromOptions(const std::string& dbname,
+                               const DBOptions& options,
+                               std::shared_ptr<Logger>* logger) {
+  if (options.info_log) {
+    *logger = options.info_log;
+    return Status::OK();
+  }
+
+  Env* env = options.env;
   std::string db_absolute_path;
   env->GetAbsolutePath(dbname, &db_absolute_path);
-  std::string fname = InfoLogFileName(dbname, db_absolute_path, db_log_dir);
+  std::string fname =
+      InfoLogFileName(dbname, db_absolute_path, options.db_log_dir);
 
   env->CreateDirIfMissing(dbname);  // In case it does not exist
   // Currently we only support roll by time-to-roll and log size
   if (options.log_file_time_to_roll > 0 || options.max_log_file_size > 0) {
     AutoRollLogger* result = new AutoRollLogger(
-        env, dbname, db_log_dir,
-        options.max_log_file_size,
+        env, dbname, options.db_log_dir, options.max_log_file_size,
         options.log_file_time_to_roll, options.info_log_level);
     Status s = result->GetStatus();
     if (!s.ok()) {
@@ -148,8 +151,9 @@ Status CreateLoggerFromOptions(
     return s;
   } else {
     // Open a log file in the same directory as the db
-    env->RenameFile(fname, OldInfoLogFileName(dbname, env->NowMicros(),
-                                              db_absolute_path, db_log_dir));
+    env->RenameFile(
+        fname, OldInfoLogFileName(dbname, env->NowMicros(), db_absolute_path,
+                                  options.db_log_dir));
     auto s = env->NewLogger(fname, logger);
     if (logger->get() != nullptr) {
       (*logger)->SetInfoLogLevel(options.info_log_level);
diff --git a/src/rocksdb/util/auto_roll_logger.h b/src/rocksdb/util/auto_roll_logger.h
index 5b6dff6..1288cdf 100644
--- a/src/rocksdb/util/auto_roll_logger.h
+++ b/src/rocksdb/util/auto_roll_logger.h
@@ -8,6 +8,7 @@
 
 #pragma once
 #include <list>
+#include <string>
 
 #include "db/filename.h"
 #include "port/port.h"
@@ -104,11 +105,8 @@ class AutoRollLogger : public Logger {
 };
 
 // Facade to craete logger automatically
-Status CreateLoggerFromOptions(
-    const std::string& dbname,
-    const std::string& db_log_dir,
-    Env* env,
-    const DBOptions& options,
-    std::shared_ptr<Logger>* logger);
+Status CreateLoggerFromOptions(const std::string& dbname,
+                               const DBOptions& options,
+                               std::shared_ptr<Logger>* logger);
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/util/auto_roll_logger_test.cc b/src/rocksdb/util/auto_roll_logger_test.cc
index 138eb6e..c26be2b 100644
--- a/src/rocksdb/util/auto_roll_logger_test.cc
+++ b/src/rocksdb/util/auto_roll_logger_test.cc
@@ -221,13 +221,13 @@ TEST_F(AutoRollLoggerTest, CreateLoggerFromOptions) {
   shared_ptr<Logger> logger;
 
   // Normal logger
-  ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger));
+  ASSERT_OK(CreateLoggerFromOptions(kTestDir, options, &logger));
   ASSERT_TRUE(dynamic_cast<PosixLogger*>(logger.get()));
 
   // Only roll by size
   InitTestDb();
   options.max_log_file_size = 1024;
-  ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger));
+  ASSERT_OK(CreateLoggerFromOptions(kTestDir, options, &logger));
   AutoRollLogger* auto_roll_logger =
     dynamic_cast<AutoRollLogger*>(logger.get());
   ASSERT_TRUE(auto_roll_logger);
@@ -239,7 +239,7 @@ TEST_F(AutoRollLoggerTest, CreateLoggerFromOptions) {
   InitTestDb();
   options.max_log_file_size = 0;
   options.log_file_time_to_roll = 2;
-  ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger));
+  ASSERT_OK(CreateLoggerFromOptions(kTestDir, options, &logger));
   auto_roll_logger =
     dynamic_cast<AutoRollLogger*>(logger.get());
   RollLogFileByTimeTest(
@@ -250,7 +250,7 @@ TEST_F(AutoRollLoggerTest, CreateLoggerFromOptions) {
   InitTestDb();
   options.max_log_file_size = 1024 * 5;
   options.log_file_time_to_roll = 2;
-  ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger));
+  ASSERT_OK(CreateLoggerFromOptions(kTestDir, options, &logger));
   auto_roll_logger =
     dynamic_cast<AutoRollLogger*>(logger.get());
   RollLogFileBySizeTest(
diff --git a/src/rocksdb/util/cache.cc b/src/rocksdb/util/cache.cc
index e64c01e..9c47edd 100644
--- a/src/rocksdb/util/cache.cc
+++ b/src/rocksdb/util/cache.cc
@@ -74,7 +74,7 @@ struct LRUHandle {
   void Free() {
     assert((refs == 1 && in_cache) || (refs == 0 && !in_cache));
     (*deleter)(key(), value);
-    free(this);
+    delete[] reinterpret_cast<char*>(this);
   }
 };
 
@@ -390,8 +390,8 @@ Cache::Handle* LRUCache::Insert(
   // Allocate the memory here outside of the mutex
   // If the cache is full, we'll have to release it
   // It shouldn't happen very often though.
-  LRUHandle* e =
-      reinterpret_cast<LRUHandle*>(malloc(sizeof(LRUHandle) - 1 + key.size()));
+  LRUHandle* e = reinterpret_cast<LRUHandle*>(
+                    new char[sizeof(LRUHandle) - 1 + key.size()]);
   autovector<LRUHandle*> last_reference_list;
 
   e->value = value;
diff --git a/src/rocksdb/util/coding.h b/src/rocksdb/util/coding.h
index a72f7db..5ea9aad 100644
--- a/src/rocksdb/util/coding.h
+++ b/src/rocksdb/util/coding.h
@@ -184,11 +184,11 @@ inline void PutLengthPrefixedSlice(std::string* dst, const Slice& value) {
 
 inline void PutLengthPrefixedSliceParts(std::string* dst,
                                         const SliceParts& slice_parts) {
-  uint32_t total_bytes = 0;
+  size_t total_bytes = 0;
   for (int i = 0; i < slice_parts.num_parts; ++i) {
     total_bytes += slice_parts.parts[i].size();
   }
-  PutVarint32(dst, total_bytes);
+  PutVarint32(dst, static_cast<uint32_t>(total_bytes));
   for (int i = 0; i < slice_parts.num_parts; ++i) {
     dst->append(slice_parts.parts[i].data(), slice_parts.parts[i].size());
   }
diff --git a/src/rocksdb/util/compression.h b/src/rocksdb/util/compression.h
index dd4d013..691bf1e 100644
--- a/src/rocksdb/util/compression.h
+++ b/src/rocksdb/util/compression.h
@@ -304,7 +304,7 @@ inline char* Zlib_Uncompress(const char* input_data, size_t input_length,
         // compress_format_version == 2
         assert(compress_format_version != 2);
         size_t old_sz = output_len;
-        size_t output_len_delta = static_cast<size_t>(output_len * 0.2);
+        uint32_t output_len_delta = output_len/5;
         output_len += output_len_delta < 10 ? 10 : output_len_delta;
         char* tmp = new char[output_len];
         memcpy(tmp, output, old_sz);
@@ -620,7 +620,7 @@ inline bool ZSTD_Compress(const CompressionOptions& opts, const char* input,
   size_t compressBound = ZSTD_compressBound(length);
   output->resize(static_cast<size_t>(output_header_len + compressBound));
   size_t outlen = ZSTD_compress(&(*output)[output_header_len], compressBound,
-                                input, length);
+                                input, length, 1 /* level */);
   if (outlen == 0) {
     return false;
   }
diff --git a/src/rocksdb/util/env.cc b/src/rocksdb/util/env.cc
index effa7f5..968d300 100644
--- a/src/rocksdb/util/env.cc
+++ b/src/rocksdb/util/env.cc
@@ -27,6 +27,17 @@ uint64_t Env::GetThreadID() const {
   return hasher(std::this_thread::get_id());
 }
 
+Status Env::ReuseWritableFile(const std::string& fname,
+                              const std::string& old_fname,
+                              unique_ptr<WritableFile>* result,
+                              const EnvOptions& options) {
+  Status s = RenameFile(old_fname, fname);
+  if (!s.ok()) {
+    return s;
+  }
+  return NewWritableFile(fname, result, options);
+}
+
 SequentialFile::~SequentialFile() {
 }
 
@@ -281,7 +292,12 @@ void AssignEnvOptions(EnvOptions* env_options, const DBOptions& options) {
   env_options->use_mmap_writes = options.allow_mmap_writes;
   env_options->set_fd_cloexec = options.is_fd_close_on_exec;
   env_options->bytes_per_sync = options.bytes_per_sync;
+  env_options->compaction_readahead_size = options.compaction_readahead_size;
+  env_options->random_access_max_buffer_size =
+      options.random_access_max_buffer_size;
   env_options->rate_limiter = options.rate_limiter.get();
+  env_options->writable_file_max_buffer_size =
+      options.writable_file_max_buffer_size;
   env_options->allow_fallocate = options.allow_fallocate;
 }
 
diff --git a/src/rocksdb/util/env_posix.cc b/src/rocksdb/util/env_posix.cc
index 5c031a7..8b44a5b 100644
--- a/src/rocksdb/util/env_posix.cc
+++ b/src/rocksdb/util/env_posix.cc
@@ -6,13 +6,14 @@
 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
-
-#include <deque>
-#include <set>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
+#if defined(OS_LINUX)
+#include <linux/fs.h>
+#endif
 #include <pthread.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -26,25 +27,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <time.h>
-#include <unistd.h>
-#if defined(OS_LINUX)
-#include <linux/fs.h>
-#endif
-#include <signal.h>
 #include <algorithm>
-#include "rocksdb/env.h"
-#include "rocksdb/slice.h"
-#include "port/port.h"
-#include "util/coding.h"
-#include "util/logging.h"
-#include "util/posix_logger.h"
-#include "util/random.h"
-#include "util/iostats_context_imp.h"
-#include "util/string_util.h"
-#include "util/sync_point.h"
-#include "util/thread_status_updater.h"
-#include "util/thread_status_util.h"
-
 // Get nano time includes
 #if defined(OS_LINUX) || defined(OS_FREEBSD)
 #elif defined(__MACH__)
@@ -53,6 +36,20 @@
 #else
 #include <chrono>
 #endif
+#include <deque>
+#include <set>
+#include "port/port.h"
+#include "rocksdb/slice.h"
+#include "util/coding.h"
+#include "util/io_posix.h"
+#include "util/thread_posix.h"
+#include "util/iostats_context_imp.h"
+#include "util/logging.h"
+#include "util/posix_logger.h"
+#include "util/string_util.h"
+#include "util/sync_point.h"
+#include "util/thread_local.h"
+#include "util/thread_status_updater.h"
 
 #if !defined(TMPFS_MAGIC)
 #define TMPFS_MAGIC 0x01021994
@@ -64,31 +61,10 @@
 #define EXT4_SUPER_MAGIC 0xEF53
 #endif
 
-// For non linux platform, the following macros are used only as place
-// holder.
-#if !(defined OS_LINUX) && !(defined CYGWIN)
-#define POSIX_FADV_NORMAL 0 /* [MC1] no further special treatment */
-#define POSIX_FADV_RANDOM 1 /* [MC1] expect random page refs */
-#define POSIX_FADV_SEQUENTIAL 2 /* [MC1] expect sequential page refs */
-#define POSIX_FADV_WILLNEED 3 /* [MC1] will need these pages */
-#define POSIX_FADV_DONTNEED 4 /* [MC1] dont need these pages */
-#endif
-
-
 namespace rocksdb {
 
 namespace {
 
-// A wrapper for fadvise, if the platform doesn't support fadvise,
-// it will simply return Status::NotSupport.
-int Fadvise(int fd, off_t offset, size_t len, int advice) {
-#ifdef OS_LINUX
-  return posix_fadvise(fd, offset, len, advice);
-#else
-  return 0;  // simply do nothing.
-#endif
-}
-
 ThreadStatusUpdater* CreateThreadStatusUpdater() {
   return new ThreadStatusUpdater();
 }
@@ -97,677 +73,6 @@ ThreadStatusUpdater* CreateThreadStatusUpdater() {
 static std::set<std::string> lockedFiles;
 static port::Mutex mutex_lockedFiles;
 
-static Status IOError(const std::string& context, int err_number) {
-  return Status::IOError(context, strerror(err_number));
-}
-
-#if defined(OS_LINUX)
-namespace {
-  static size_t GetUniqueIdFromFile(int fd, char* id, size_t max_size) {
-    if (max_size < kMaxVarint64Length*3) {
-      return 0;
-    }
-
-    struct stat buf;
-    int result = fstat(fd, &buf);
-    if (result == -1) {
-      return 0;
-    }
-
-    long version = 0;
-    result = ioctl(fd, FS_IOC_GETVERSION, &version);
-    if (result == -1) {
-      return 0;
-    }
-    uint64_t uversion = (uint64_t)version;
-
-    char* rid = id;
-    rid = EncodeVarint64(rid, buf.st_dev);
-    rid = EncodeVarint64(rid, buf.st_ino);
-    rid = EncodeVarint64(rid, uversion);
-    assert(rid >= id);
-    return static_cast<size_t>(rid-id);
-  }
-}
-#endif
-
-class PosixSequentialFile: public SequentialFile {
- private:
-  std::string filename_;
-  FILE* file_;
-  int fd_;
-  bool use_os_buffer_;
-
- public:
-  PosixSequentialFile(const std::string& fname, FILE* f,
-      const EnvOptions& options)
-      : filename_(fname), file_(f), fd_(fileno(f)),
-        use_os_buffer_(options.use_os_buffer) {
-  }
-  virtual ~PosixSequentialFile() { fclose(file_); }
-
-  virtual Status Read(size_t n, Slice* result, char* scratch) override {
-    Status s;
-    size_t r = 0;
-    do {
-      r = fread_unlocked(scratch, 1, n, file_);
-    } while (r == 0 && ferror(file_) && errno == EINTR);
-    *result = Slice(scratch, r);
-    if (r < n) {
-      if (feof(file_)) {
-        // We leave status as ok if we hit the end of the file
-        // We also clear the error so that the reads can continue
-        // if a new data is written to the file
-        clearerr(file_);
-      } else {
-        // A partial read with an error: return a non-ok status
-        s = IOError(filename_, errno);
-      }
-    }
-    if (!use_os_buffer_) {
-      // we need to fadvise away the entire range of pages because
-      // we do not want readahead pages to be cached.
-      Fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages
-    }
-    return s;
-  }
-
-  virtual Status Skip(uint64_t n) override {
-    if (fseek(file_, static_cast<long int>(n), SEEK_CUR)) {
-      return IOError(filename_, errno);
-    }
-    return Status::OK();
-  }
-
-  virtual Status InvalidateCache(size_t offset, size_t length) override {
-#ifndef OS_LINUX
-    return Status::OK();
-#else
-    // free OS pages
-    int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
-    if (ret == 0) {
-      return Status::OK();
-    }
-    return IOError(filename_, errno);
-#endif
-  }
-};
-
-// pread() based random-access
-class PosixRandomAccessFile: public RandomAccessFile {
- private:
-  std::string filename_;
-  int fd_;
-  bool use_os_buffer_;
-
- public:
-  PosixRandomAccessFile(const std::string& fname, int fd,
-                        const EnvOptions& options)
-      : filename_(fname), fd_(fd), use_os_buffer_(options.use_os_buffer) {
-    assert(!options.use_mmap_reads || sizeof(void*) < 8);
-  }
-  virtual ~PosixRandomAccessFile() { close(fd_); }
-
-  virtual Status Read(uint64_t offset, size_t n, Slice* result,
-                      char* scratch) const override {
-    Status s;
-    ssize_t r = -1;
-    size_t left = n;
-    char* ptr = scratch;
-    while (left > 0) {
-      r = pread(fd_, ptr, left, static_cast<off_t>(offset));
-
-      if (r <= 0) {
-        if (errno == EINTR) {
-          continue;
-        }
-        break;
-      }
-      ptr += r;
-      offset += r;
-      left -= r;
-    }
-
-    *result = Slice(scratch, (r < 0) ? 0 : n - left);
-    if (r < 0) {
-      // An error: return a non-ok status
-      s = IOError(filename_, errno);
-    }
-    if (!use_os_buffer_) {
-      // we need to fadvise away the entire range of pages because
-      // we do not want readahead pages to be cached.
-      Fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages
-    }
-    return s;
-  }
-
-#ifdef OS_LINUX
-  virtual size_t GetUniqueId(char* id, size_t max_size) const override {
-    return GetUniqueIdFromFile(fd_, id, max_size);
-  }
-#endif
-
-  virtual void Hint(AccessPattern pattern) override {
-    switch(pattern) {
-      case NORMAL:
-        Fadvise(fd_, 0, 0, POSIX_FADV_NORMAL);
-        break;
-      case RANDOM:
-        Fadvise(fd_, 0, 0, POSIX_FADV_RANDOM);
-        break;
-      case SEQUENTIAL:
-        Fadvise(fd_, 0, 0, POSIX_FADV_SEQUENTIAL);
-        break;
-      case WILLNEED:
-        Fadvise(fd_, 0, 0, POSIX_FADV_WILLNEED);
-        break;
-      case DONTNEED:
-        Fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED);
-        break;
-      default:
-        assert(false);
-        break;
-    }
-  }
-
-  virtual Status InvalidateCache(size_t offset, size_t length) override {
-#ifndef OS_LINUX
-    return Status::OK();
-#else
-    // free OS pages
-    int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
-    if (ret == 0) {
-      return Status::OK();
-    }
-    return IOError(filename_, errno);
-#endif
-  }
-};
-
-// mmap() based random-access
-class PosixMmapReadableFile: public RandomAccessFile {
- private:
-  int fd_;
-  std::string filename_;
-  void* mmapped_region_;
-  size_t length_;
-
- public:
-  // base[0,length-1] contains the mmapped contents of the file.
-  PosixMmapReadableFile(const int fd, const std::string& fname,
-                        void* base, size_t length,
-                        const EnvOptions& options)
-      : fd_(fd), filename_(fname), mmapped_region_(base), length_(length) {
-    fd_ = fd_ + 0;  // suppress the warning for used variables
-    assert(options.use_mmap_reads);
-    assert(options.use_os_buffer);
-  }
-  virtual ~PosixMmapReadableFile() {
-    int ret = munmap(mmapped_region_, length_);
-    if (ret != 0) {
-      fprintf(stdout, "failed to munmap %p length %" ROCKSDB_PRIszt " \n",
-              mmapped_region_, length_);
-    }
-  }
-
-  virtual Status Read(uint64_t offset, size_t n, Slice* result,
-                      char* scratch) const override {
-    Status s;
-    if (offset > length_) {
-      *result = Slice();
-      return IOError(filename_, EINVAL);
-    } else if (offset + n > length_) {
-      n = length_ - offset;
-    }
-    *result = Slice(reinterpret_cast<char*>(mmapped_region_) + offset, n);
-    return s;
-  }
-  virtual Status InvalidateCache(size_t offset, size_t length) override {
-#ifndef OS_LINUX
-    return Status::OK();
-#else
-    // free OS pages
-    int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
-    if (ret == 0) {
-      return Status::OK();
-    }
-    return IOError(filename_, errno);
-#endif
-  }
-};
-
-// We preallocate up to an extra megabyte and use memcpy to append new
-// data to the file.  This is safe since we either properly close the
-// file before reading from it, or for log files, the reading code
-// knows enough to skip zero suffixes.
-class PosixMmapFile : public WritableFile {
- private:
-  std::string filename_;
-  int fd_;
-  size_t page_size_;
-  size_t map_size_;       // How much extra memory to map at a time
-  char* base_;            // The mapped region
-  char* limit_;           // Limit of the mapped region
-  char* dst_;             // Where to write next  (in range [base_,limit_])
-  char* last_sync_;       // Where have we synced up to
-  uint64_t file_offset_;  // Offset of base_ in file
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-  bool allow_fallocate_;  // If false, fallocate calls are bypassed
-  bool fallocate_with_keep_size_;
-#endif
-
-  // Roundup x to a multiple of y
-  static size_t Roundup(size_t x, size_t y) {
-    return ((x + y - 1) / y) * y;
-  }
-
-  size_t TruncateToPageBoundary(size_t s) {
-    s -= (s & (page_size_ - 1));
-    assert((s % page_size_) == 0);
-    return s;
-  }
-
-  Status UnmapCurrentRegion() {
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-    if (base_ != nullptr) {
-      int munmap_status = munmap(base_, limit_ - base_);
-      if (munmap_status != 0) {
-        return IOError(filename_, munmap_status);
-      }
-      file_offset_ += limit_ - base_;
-      base_ = nullptr;
-      limit_ = nullptr;
-      last_sync_ = nullptr;
-      dst_ = nullptr;
-
-      // Increase the amount we map the next time, but capped at 1MB
-      if (map_size_ < (1<<20)) {
-        map_size_ *= 2;
-      }
-    }
-    return Status::OK();
-  }
-
-  Status MapNewRegion() {
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-    assert(base_ == nullptr);
-
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-    // we can't fallocate with FALLOC_FL_KEEP_SIZE here
-    if (allow_fallocate_) {
-      IOSTATS_TIMER_GUARD(allocate_nanos);
-      int alloc_status = fallocate(fd_, 0, file_offset_, map_size_);
-      if (alloc_status != 0) {
-        // fallback to posix_fallocate
-        alloc_status = posix_fallocate(fd_, file_offset_, map_size_);
-      }
-      if (alloc_status != 0) {
-        return Status::IOError("Error allocating space to file : " + filename_ +
-          "Error : " + strerror(alloc_status));
-      }
-    }
-
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-    void* ptr = mmap(nullptr, map_size_, PROT_READ | PROT_WRITE, MAP_SHARED,
-                     fd_, file_offset_);
-    if (ptr == MAP_FAILED) {
-      return Status::IOError("MMap failed on " + filename_);
-    }
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-
-    base_ = reinterpret_cast<char*>(ptr);
-    limit_ = base_ + map_size_;
-    dst_ = base_;
-    last_sync_ = base_;
-    return Status::OK();
-#else
-    return Status::NotSupported("This platform doesn't support fallocate()");
-#endif
-  }
-
-  Status Msync() {
-    if (dst_ == last_sync_) {
-      return Status::OK();
-    }
-    // Find the beginnings of the pages that contain the first and last
-    // bytes to be synced.
-    size_t p1 = TruncateToPageBoundary(last_sync_ - base_);
-    size_t p2 = TruncateToPageBoundary(dst_ - base_ - 1);
-    last_sync_ = dst_;
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-    if (msync(base_ + p1, p2 - p1 + page_size_, MS_SYNC) < 0) {
-      return IOError(filename_, errno);
-    }
-    return Status::OK();
-  }
-
- public:
-  PosixMmapFile(const std::string& fname, int fd, size_t page_size,
-                const EnvOptions& options)
-      : filename_(fname),
-        fd_(fd),
-        page_size_(page_size),
-        map_size_(Roundup(65536, page_size)),
-        base_(nullptr),
-        limit_(nullptr),
-        dst_(nullptr),
-        last_sync_(nullptr),
-        file_offset_(0) {
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-    allow_fallocate_ = options.allow_fallocate;
-    fallocate_with_keep_size_ = options.fallocate_with_keep_size;
-#endif
-    assert((page_size & (page_size - 1)) == 0);
-    assert(options.use_mmap_writes);
-  }
-
-
-  ~PosixMmapFile() {
-    if (fd_ >= 0) {
-      PosixMmapFile::Close();
-    }
-  }
-
-  virtual Status Append(const Slice& data) override {
-    const char* src = data.data();
-    size_t left = data.size();
-    while (left > 0) {
-      assert(base_ <= dst_);
-      assert(dst_ <= limit_);
-      size_t avail = limit_ - dst_;
-      if (avail == 0) {
-        Status s = UnmapCurrentRegion();
-        if (!s.ok()) {
-          return s;
-        }
-        s = MapNewRegion();
-        if (!s.ok()) {
-          return s;
-        }
-        TEST_KILL_RANDOM(rocksdb_kill_odds);
-      }
-
-      size_t n = (left <= avail) ? left : avail;
-      memcpy(dst_, src, n);
-      dst_ += n;
-      src += n;
-      left -= n;
-    }
-    return Status::OK();
-  }
-
-  // Means Close() will properly take care of truncate
-  // and it does not need any additional information
-  virtual Status Truncate(uint64_t size) override {
-    return Status::OK();
-  }
-
-  virtual Status Close() override {
-    Status s;
-    size_t unused = limit_ - dst_;
-
-    s = UnmapCurrentRegion();
-    if (!s.ok()) {
-      s = IOError(filename_, errno);
-    } else if (unused > 0) {
-      // Trim the extra space at the end of the file
-      if (ftruncate(fd_, file_offset_ - unused) < 0) {
-        s = IOError(filename_, errno);
-      }
-    }
-
-    if (close(fd_) < 0) {
-      if (s.ok()) {
-        s = IOError(filename_, errno);
-      }
-    }
-
-    fd_ = -1;
-    base_ = nullptr;
-    limit_ = nullptr;
-    return s;
-  }
-
-  virtual Status Flush() override {
-    return Status::OK();
-  }
-
-  virtual Status Sync() override {
-    if (fdatasync(fd_) < 0) {
-      return IOError(filename_, errno);
-    }
-
-    return Msync();
-  }
-
-  /**
-   * Flush data as well as metadata to stable storage.
-   */
-  virtual Status Fsync() override {
-    if (fsync(fd_) < 0) {
-      return IOError(filename_, errno);
-    }
-
-    return Msync();
-  }
-
-  /**
-   * Get the size of valid data in the file. This will not match the
-   * size that is returned from the filesystem because we use mmap
-   * to extend file by map_size every time.
-   */
-  virtual uint64_t GetFileSize() override {
-    size_t used = dst_ - base_;
-    return file_offset_ + used;
-  }
-
-  virtual Status InvalidateCache(size_t offset, size_t length) override {
-#ifndef OS_LINUX
-    return Status::OK();
-#else
-    // free OS pages
-    int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
-    if (ret == 0) {
-      return Status::OK();
-    }
-    return IOError(filename_, errno);
-#endif
-  }
-
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-  virtual Status Allocate(off_t offset, off_t len) override {
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-    int alloc_status = 0;
-    if (allow_fallocate_) {
-      alloc_status =
-          fallocate(fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0,
-                    offset, len);
-    }
-    if (alloc_status == 0) {
-      return Status::OK();
-    } else {
-      return IOError(filename_, errno);
-    }
-  }
-#endif
-};
-
-// Use posix write to write data to a file.
-class PosixWritableFile : public WritableFile {
- private:
-  const std::string filename_;
-  int fd_;
-  uint64_t filesize_;
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-  bool allow_fallocate_;
-  bool fallocate_with_keep_size_;
-#endif
-
- public:
-  PosixWritableFile(const std::string& fname, int fd, const EnvOptions& options)
-      : filename_(fname), fd_(fd), filesize_(0) {
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-    allow_fallocate_ = options.allow_fallocate;
-    fallocate_with_keep_size_ = options.fallocate_with_keep_size;
-#endif
-    assert(!options.use_mmap_writes);
-  }
-
-  ~PosixWritableFile() {
-    if (fd_ >= 0) {
-      PosixWritableFile::Close();
-    }
-  }
-
-  virtual Status Append(const Slice& data) override {
-    const char* src = data.data();
-    size_t left = data.size();
-    while (left != 0) {
-      ssize_t done = write(fd_, src, left);
-      if (done < 0) {
-        if (errno == EINTR) {
-          continue;
-        }
-        return IOError(filename_, errno);
-      }
-      left -= done;
-      src += done;
-    }
-    filesize_ += data.size();
-    return Status::OK();
-  }
-
-  // Means Close() will properly take care of truncate
-  // and it does not need any additional information
-  virtual Status Truncate(uint64_t size) override {
-    return Status::OK();
-  }
-
-  virtual Status Close() override {
-    Status s;
-
-    size_t block_size;
-    size_t last_allocated_block;
-    GetPreallocationStatus(&block_size, &last_allocated_block);
-    if (last_allocated_block > 0) {
-      // trim the extra space preallocated at the end of the file
-      // NOTE(ljin): we probably don't want to surface failure as an IOError,
-      // but it will be nice to log these errors.
-      int dummy __attribute__((unused));
-      dummy = ftruncate(fd_, filesize_);
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-      // in some file systems, ftruncate only trims trailing space if the
-      // new file size is smaller than the current size. Calling fallocate
-      // with FALLOC_FL_PUNCH_HOLE flag to explicitly release these unused
-      // blocks. FALLOC_FL_PUNCH_HOLE is supported on at least the following
-      // filesystems:
-      //   XFS (since Linux 2.6.38)
-      //   ext4 (since Linux 3.0)
-      //   Btrfs (since Linux 3.7)
-      //   tmpfs (since Linux 3.5)
-      // We ignore error since failure of this operation does not affect
-      // correctness.
-      IOSTATS_TIMER_GUARD(allocate_nanos);
-      if (allow_fallocate_) {
-        fallocate(fd_, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, filesize_,
-                  block_size * last_allocated_block - filesize_);
-      }
-#endif
-    }
-
-    if (close(fd_) < 0) {
-      s = IOError(filename_, errno);
-    }
-    fd_ = -1;
-    return s;
-  }
-
-  // write out the cached data to the OS cache
-  virtual Status Flush() override {
-    return Status::OK();
-  }
-
-  virtual Status Sync() override {
-    if (fdatasync(fd_) < 0) {
-      return IOError(filename_, errno);
-    }
-    return Status::OK();
-  }
-
-  virtual Status Fsync() override {
-    if (fsync(fd_) < 0) {
-      return IOError(filename_, errno);
-    }
-    return Status::OK();
-  }
-
-  virtual bool IsSyncThreadSafe() const override {
-    return true;
-  }
-
-  virtual uint64_t GetFileSize() override { return filesize_; }
-
-  virtual Status InvalidateCache(size_t offset, size_t length) override {
-#ifndef OS_LINUX
-    return Status::OK();
-#else
-    // free OS pages
-    int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
-    if (ret == 0) {
-      return Status::OK();
-    }
-    return IOError(filename_, errno);
-#endif
-  }
-
-#ifdef ROCKSDB_FALLOCATE_PRESENT
-  virtual Status Allocate(off_t offset, off_t len) override {
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
-    IOSTATS_TIMER_GUARD(allocate_nanos);
-    int alloc_status = 0;
-    if (allow_fallocate_) {
-      alloc_status =
-          fallocate(fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0,
-                    offset, len);
-    }
-    if (alloc_status == 0) {
-      return Status::OK();
-    } else {
-      return IOError(filename_, errno);
-    }
-  }
-
-  virtual Status RangeSync(off_t offset, off_t nbytes) override {
-    if (sync_file_range(fd_, offset, nbytes, SYNC_FILE_RANGE_WRITE) == 0) {
-      return Status::OK();
-    } else {
-      return IOError(filename_, errno);
-    }
-  }
-  virtual size_t GetUniqueId(char* id, size_t max_size) const override {
-    return GetUniqueIdFromFile(fd_, id, max_size);
-  }
-#endif
-};
-
-class PosixDirectory : public Directory {
- public:
-  explicit PosixDirectory(int fd) : fd_(fd) {}
-  ~PosixDirectory() {
-    close(fd_);
-  }
-
-  virtual Status Fsync() override {
-    if (fsync(fd_) == -1) {
-      return IOError("directory", errno);
-    }
-    return Status::OK();
-  }
-
- private:
-  int fd_;
-};
-
 static int LockOrUnlock(const std::string& fname, int fd, bool lock) {
   mutex_lockedFiles.Lock();
   if (lock) {
@@ -812,13 +117,6 @@ class PosixFileLock : public FileLock {
   std::string filename;
 };
 
-void PthreadCall(const char* label, int result) {
-  if (result != 0) {
-    fprintf(stderr, "pthread %s: %s\n", label, strerror(result));
-    abort();
-  }
-}
-
 class PosixEnv : public Env {
  public:
   PosixEnv();
@@ -933,6 +231,50 @@ class PosixEnv : public Env {
     return s;
   }
 
+  virtual Status ReuseWritableFile(const std::string& fname,
+                                   const std::string& old_fname,
+                                   unique_ptr<WritableFile>* result,
+                                   const EnvOptions& options) override {
+    result->reset();
+    Status s;
+    int fd = -1;
+    do {
+      IOSTATS_TIMER_GUARD(open_nanos);
+      fd = open(old_fname.c_str(), O_RDWR, 0644);
+    } while (fd < 0 && errno == EINTR);
+    if (fd < 0) {
+      s = IOError(fname, errno);
+    } else {
+      SetFD_CLOEXEC(fd, &options);
+      // rename into place
+      if (rename(old_fname.c_str(), fname.c_str()) != 0) {
+        Status r = IOError(old_fname, errno);
+        close(fd);
+        return r;
+      }
+      if (options.use_mmap_writes) {
+        if (!checkedDiskForMmap_) {
+          // this will be executed once in the program's lifetime.
+          // do not use mmapWrite on non ext-3/xfs/tmpfs systems.
+          if (!SupportsFastAllocate(fname)) {
+            forceMmapOff = true;
+          }
+          checkedDiskForMmap_ = true;
+        }
+      }
+      if (options.use_mmap_writes && !forceMmapOff) {
+        result->reset(new PosixMmapFile(fname, fd, page_size_, options));
+      } else {
+        // disable mmap writes
+        EnvOptions no_mmap_writes_options = options;
+        no_mmap_writes_options.use_mmap_writes = false;
+
+        result->reset(new PosixWritableFile(fname, fd, no_mmap_writes_options));
+      }
+    }
+    return s;
+  }
+
   virtual Status NewDirectory(const std::string& name,
                               unique_ptr<Directory>* result) override {
     result->reset();
@@ -1326,300 +668,9 @@ class PosixEnv : public Env {
 
   size_t page_size_;
 
-
-  class ThreadPool {
-   public:
-    ThreadPool()
-        : total_threads_limit_(1),
-          bgthreads_(0),
-          queue_(),
-          queue_len_(0),
-          exit_all_threads_(false),
-          low_io_priority_(false),
-          env_(nullptr) {
-      PthreadCall("mutex_init", pthread_mutex_init(&mu_, nullptr));
-      PthreadCall("cvar_init", pthread_cond_init(&bgsignal_, nullptr));
-    }
-
-    ~ThreadPool() {
-      assert(bgthreads_.size() == 0U);
-    }
-
-    void JoinAllThreads() {
-      PthreadCall("lock", pthread_mutex_lock(&mu_));
-      assert(!exit_all_threads_);
-      exit_all_threads_ = true;
-      PthreadCall("signalall", pthread_cond_broadcast(&bgsignal_));
-      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-      for (const auto tid : bgthreads_) {
-        pthread_join(tid, nullptr);
-      }
-      bgthreads_.clear();
-    }
-
-    void SetHostEnv(Env* env) {
-      env_ = env;
-    }
-
-    void LowerIOPriority() {
-#ifdef OS_LINUX
-      PthreadCall("lock", pthread_mutex_lock(&mu_));
-      low_io_priority_ = true;
-      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-#endif
-    }
-
-    // Return true if there is at least one thread needs to terminate.
-    bool HasExcessiveThread() {
-      return static_cast<int>(bgthreads_.size()) > total_threads_limit_;
-    }
-
-    // Return true iff the current thread is the excessive thread to terminate.
-    // Always terminate the running thread that is added last, even if there are
-    // more than one thread to terminate.
-    bool IsLastExcessiveThread(size_t thread_id) {
-      return HasExcessiveThread() && thread_id == bgthreads_.size() - 1;
-    }
-
-    // Is one of the threads to terminate.
-    bool IsExcessiveThread(size_t thread_id) {
-      return static_cast<int>(thread_id) >= total_threads_limit_;
-    }
-
-    // Return the thread priority.
-    // This would allow its member-thread to know its priority.
-    Env::Priority GetThreadPriority() {
-      return priority_;
-    }
-
-    // Set the thread priority.
-    void SetThreadPriority(Env::Priority priority) {
-      priority_ = priority;
-    }
-
-    void BGThread(size_t thread_id) {
-      bool low_io_priority = false;
-      while (true) {
-        // Wait until there is an item that is ready to run
-        PthreadCall("lock", pthread_mutex_lock(&mu_));
-        // Stop waiting if the thread needs to do work or needs to terminate.
-        while (!exit_all_threads_ && !IsLastExcessiveThread(thread_id) &&
-               (queue_.empty() || IsExcessiveThread(thread_id))) {
-          PthreadCall("wait", pthread_cond_wait(&bgsignal_, &mu_));
-        }
-        if (exit_all_threads_) { // mechanism to let BG threads exit safely
-          PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-          break;
-        }
-        if (IsLastExcessiveThread(thread_id)) {
-          // Current thread is the last generated one and is excessive.
-          // We always terminate excessive thread in the reverse order of
-          // generation time.
-          auto terminating_thread = bgthreads_.back();
-          pthread_detach(terminating_thread);
-          bgthreads_.pop_back();
-          if (HasExcessiveThread()) {
-            // There is still at least more excessive thread to terminate.
-            WakeUpAllThreads();
-          }
-          PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-          break;
-        }
-        void (*function)(void*) = queue_.front().function;
-        void* arg = queue_.front().arg;
-        queue_.pop_front();
-        queue_len_.store(static_cast<unsigned int>(queue_.size()),
-                         std::memory_order_relaxed);
-
-        bool decrease_io_priority = (low_io_priority != low_io_priority_);
-        PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-
-#ifdef OS_LINUX
-        if (decrease_io_priority) {
-          #define IOPRIO_CLASS_SHIFT               (13)
-          #define IOPRIO_PRIO_VALUE(class, data)   \
-              (((class) << IOPRIO_CLASS_SHIFT) | data)
-          // Put schedule into IOPRIO_CLASS_IDLE class (lowest)
-          // These system calls only have an effect when used in conjunction
-          // with an I/O scheduler that supports I/O priorities. As at
-          // kernel 2.6.17 the only such scheduler is the Completely
-          // Fair Queuing (CFQ) I/O scheduler.
-          // To change scheduler:
-          //  echo cfq > /sys/block/<device_name>/queue/schedule
-          // Tunables to consider:
-          //  /sys/block/<device_name>/queue/slice_idle
-          //  /sys/block/<device_name>/queue/slice_sync
-          syscall(SYS_ioprio_set,
-                  1,  // IOPRIO_WHO_PROCESS
-                  0,  // current thread
-                  IOPRIO_PRIO_VALUE(3, 0));
-          low_io_priority = true;
-        }
-#else
-        (void)decrease_io_priority; // avoid 'unused variable' error
-#endif
-        (*function)(arg);
-      }
-    }
-
-    // Helper struct for passing arguments when creating threads.
-    struct BGThreadMetadata {
-      ThreadPool* thread_pool_;
-      size_t thread_id_;  // Thread count in the thread.
-      explicit BGThreadMetadata(ThreadPool* thread_pool, size_t thread_id)
-          : thread_pool_(thread_pool), thread_id_(thread_id) {}
-    };
-
-    static void* BGThreadWrapper(void* arg) {
-      BGThreadMetadata* meta = reinterpret_cast<BGThreadMetadata*>(arg);
-      size_t thread_id = meta->thread_id_;
-      ThreadPool* tp = meta->thread_pool_;
-#if ROCKSDB_USING_THREAD_STATUS
-      // for thread-status
-      ThreadStatusUtil::RegisterThread(tp->env_,
-          (tp->GetThreadPriority() == Env::Priority::HIGH ?
-              ThreadStatus::HIGH_PRIORITY :
-              ThreadStatus::LOW_PRIORITY));
-#endif
-      delete meta;
-      tp->BGThread(thread_id);
-#if ROCKSDB_USING_THREAD_STATUS
-      ThreadStatusUtil::UnregisterThread();
-#endif
-      return nullptr;
-    }
-
-    void WakeUpAllThreads() {
-      PthreadCall("signalall", pthread_cond_broadcast(&bgsignal_));
-    }
-
-    void SetBackgroundThreadsInternal(int num, bool allow_reduce) {
-      PthreadCall("lock", pthread_mutex_lock(&mu_));
-      if (exit_all_threads_) {
-        PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-        return;
-      }
-      if (num > total_threads_limit_ ||
-          (num < total_threads_limit_ && allow_reduce)) {
-        total_threads_limit_ = std::max(1, num);
-        WakeUpAllThreads();
-        StartBGThreads();
-      }
-      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-    }
-
-    void IncBackgroundThreadsIfNeeded(int num) {
-      SetBackgroundThreadsInternal(num, false);
-    }
-
-    void SetBackgroundThreads(int num) {
-      SetBackgroundThreadsInternal(num, true);
-    }
-
-    void StartBGThreads() {
-      // Start background thread if necessary
-      while ((int)bgthreads_.size() < total_threads_limit_) {
-        pthread_t t;
-        PthreadCall(
-            "create thread",
-            pthread_create(&t, nullptr, &ThreadPool::BGThreadWrapper,
-                           new BGThreadMetadata(this, bgthreads_.size())));
-
-        // Set the thread name to aid debugging
-#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ)
-#if __GLIBC_PREREQ(2, 12)
-        char name_buf[16];
-        snprintf(name_buf, sizeof name_buf, "rocksdb:bg%" ROCKSDB_PRIszt,
-                 bgthreads_.size());
-        name_buf[sizeof name_buf - 1] = '\0';
-        pthread_setname_np(t, name_buf);
-#endif
-#endif
-
-        bgthreads_.push_back(t);
-      }
-    }
-
-    void Schedule(void (*function)(void* arg1), void* arg, void* tag) {
-      PthreadCall("lock", pthread_mutex_lock(&mu_));
-
-      if (exit_all_threads_) {
-        PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-        return;
-      }
-
-      StartBGThreads();
-
-      // Add to priority queue
-      queue_.push_back(BGItem());
-      queue_.back().function = function;
-      queue_.back().arg = arg;
-      queue_.back().tag = tag;
-      queue_len_.store(static_cast<unsigned int>(queue_.size()),
-                       std::memory_order_relaxed);
-
-      if (!HasExcessiveThread()) {
-        // Wake up at least one waiting thread.
-        PthreadCall("signal", pthread_cond_signal(&bgsignal_));
-      } else {
-        // Need to wake up all threads to make sure the one woken
-        // up is not the one to terminate.
-        WakeUpAllThreads();
-      }
-
-      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-    }
-
-    int UnSchedule(void* arg) {
-      int count = 0;
-      PthreadCall("lock", pthread_mutex_lock(&mu_));
-
-      // Remove from priority queue
-      BGQueue::iterator it = queue_.begin();
-      while (it != queue_.end()) {
-        if (arg == (*it).tag) {
-          it = queue_.erase(it);
-          count++;
-        } else {
-          it++;
-        }
-      }
-      queue_len_.store(static_cast<unsigned int>(queue_.size()),
-                       std::memory_order_relaxed);
-      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
-      return count;
-    }
-
-    unsigned int GetQueueLen() const {
-      return queue_len_.load(std::memory_order_relaxed);
-    }
-
-   private:
-    // Entry per Schedule() call
-    struct BGItem {
-      void* arg;
-      void (*function)(void*);
-      void* tag;
-    };
-    typedef std::deque<BGItem> BGQueue;
-
-    pthread_mutex_t mu_;
-    pthread_cond_t bgsignal_;
-    int total_threads_limit_;
-    std::vector<pthread_t> bgthreads_;
-    BGQueue queue_;
-    std::atomic_uint queue_len_;  // Queue length. Used for stats reporting
-    bool exit_all_threads_;
-    bool low_io_priority_;
-    Env::Priority priority_;
-    Env* env_;
-  };
-
   std::vector<ThreadPool> thread_pools_;
-
   pthread_mutex_t mu_;
   std::vector<pthread_t> threads_to_join_;
-
 };
 
 PosixEnv::PosixEnv()
@@ -1627,7 +678,7 @@ PosixEnv::PosixEnv()
       forceMmapOff(false),
       page_size_(getpagesize()),
       thread_pools_(Priority::TOTAL) {
-  PthreadCall("mutex_init", pthread_mutex_init(&mu_, nullptr));
+  ThreadPool::PthreadCall("mutex_init", pthread_mutex_init(&mu_, nullptr));
   for (int pool_id = 0; pool_id < Env::Priority::TOTAL; ++pool_id) {
     thread_pools_[pool_id].SetThreadPriority(
         static_cast<Env::Priority>(pool_id));
@@ -1669,11 +720,11 @@ void PosixEnv::StartThread(void (*function)(void* arg), void* arg) {
   StartThreadState* state = new StartThreadState;
   state->user_function = function;
   state->arg = arg;
-  PthreadCall("start thread",
-              pthread_create(&t, nullptr,  &StartThreadWrapper, state));
-  PthreadCall("lock", pthread_mutex_lock(&mu_));
+  ThreadPool::PthreadCall(
+      "start thread", pthread_create(&t, nullptr, &StartThreadWrapper, state));
+  ThreadPool::PthreadCall("lock", pthread_mutex_lock(&mu_));
   threads_to_join_.push_back(t);
-  PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+  ThreadPool::PthreadCall("unlock", pthread_mutex_unlock(&mu_));
 }
 
 void PosixEnv::WaitForJoin() {
@@ -1711,6 +762,17 @@ std::string Env::GenerateUniqueId() {
 }
 
 Env* Env::Default() {
+  // The following function call initializes the singletons of ThreadLocalPtr
+  // right before the static default_env.  This guarantees default_env will
+  // always being destructed before the ThreadLocalPtr singletons get
+  // destructed as C++ guarantees that the destructions of static variables
+  // is in the reverse order of their constructions.
+  //
+  // Since static members are destructed in the reverse order
+  // of their construction, having this call here guarantees that
+  // the destructor of static PosixEnv will go first, then the
+  // the singletons of ThreadLocalPtr.
+  ThreadLocalPtr::InitSingletons();
   static PosixEnv default_env;
   return &default_env;
 }
diff --git a/src/rocksdb/util/env_test.cc b/src/rocksdb/util/env_test.cc
index 7f5e4b9..e5fa370 100644
--- a/src/rocksdb/util/env_test.cc
+++ b/src/rocksdb/util/env_test.cc
@@ -971,11 +971,11 @@ TEST_F(EnvPosixTest, WritableFileWrapper) {
     }
 
    protected:
-    Status Allocate(off_t offset, off_t len) override {
+    Status Allocate(uint64_t offset, uint64_t len) override {
       inc(11);
       return Status::OK();
     }
-    Status RangeSync(off_t offset, off_t nbytes) override {
+    Status RangeSync(uint64_t offset, uint64_t nbytes) override {
       inc(12);
       return Status::OK();
     }
diff --git a/src/rocksdb/util/file_reader_writer.cc b/src/rocksdb/util/file_reader_writer.cc
index 86d70b6..6d548c4 100644
--- a/src/rocksdb/util/file_reader_writer.cc
+++ b/src/rocksdb/util/file_reader_writer.cc
@@ -21,10 +21,6 @@
 
 namespace rocksdb {
 
-namespace {
-  const size_t c_OneMb = (1 << 20);
-}
-
 Status SequentialFileReader::Read(size_t n, Slice* result, char* scratch) {
   Status s = file_->Read(n, result, scratch);
   IOSTATS_ADD(bytes_read, result->size());
@@ -57,7 +53,8 @@ Status WritableFileWriter::Append(const Slice& data) {
   pending_sync_ = true;
   pending_fsync_ = true;
 
-  TEST_KILL_RANDOM(rocksdb_kill_odds * REDUCE_ODDS2);
+  TEST_KILL_RANDOM("WritableFileWriter::Append:0",
+                   rocksdb_kill_odds * REDUCE_ODDS2);
 
   {
     IOSTATS_TIMER_GUARD(prepare_write_nanos);
@@ -75,9 +72,9 @@ Status WritableFileWriter::Append(const Slice& data) {
       }
     }
 
-    if (buf_.Capacity() < c_OneMb) {
+    if (buf_.Capacity() < max_buffer_size_) {
       size_t desiredCapacity = buf_.Capacity() * 2;
-      desiredCapacity = std::min(desiredCapacity, c_OneMb);
+      desiredCapacity = std::min(desiredCapacity, max_buffer_size_);
       buf_.AllocateNewBuffer(desiredCapacity);
     }
     assert(buf_.CurrentSize() == 0);
@@ -101,9 +98,9 @@ Status WritableFileWriter::Append(const Slice& data) {
         // We double the buffer here because
         // Flush calls do not keep up with the incoming bytes
         // This is the only place when buffer is changed with unbuffered I/O
-        if (buf_.Capacity() < (1 << 20)) {
+        if (buf_.Capacity() < max_buffer_size_) {
           size_t desiredCapacity = buf_.Capacity() * 2;
-          desiredCapacity = std::min(desiredCapacity, c_OneMb);
+          desiredCapacity = std::min(desiredCapacity, max_buffer_size_);
           buf_.AllocateNewBuffer(desiredCapacity);
         }
       }
@@ -114,9 +111,11 @@ Status WritableFileWriter::Append(const Slice& data) {
     s = WriteBuffered(src, left);
   }
 
-  TEST_KILL_RANDOM(rocksdb_kill_odds);
-  filesize_ += data.size();
-  return Status::OK();
+  TEST_KILL_RANDOM("WritableFileWriter::Append:1", rocksdb_kill_odds);
+  if (s.ok()) {
+    filesize_ += data.size();
+  }
+  return s;
 }
 
 Status WritableFileWriter::Close() {
@@ -141,22 +140,23 @@ Status WritableFileWriter::Close() {
     s = interim;
   }
 
-  TEST_KILL_RANDOM(rocksdb_kill_odds);
+  TEST_KILL_RANDOM("WritableFileWriter::Close:0", rocksdb_kill_odds);
   interim = writable_file_->Close();
   if (!interim.ok() && s.ok()) {
     s = interim;
   }
 
   writable_file_.reset();
+  TEST_KILL_RANDOM("WritableFileWriter::Close:1", rocksdb_kill_odds);
 
   return s;
 }
 
-
 // write out the cached data to the OS cache
 Status WritableFileWriter::Flush() {
   Status s;
-  TEST_KILL_RANDOM(rocksdb_kill_odds * REDUCE_ODDS2);
+  TEST_KILL_RANDOM("WritableFileWriter::Flush:0",
+                   rocksdb_kill_odds * REDUCE_ODDS2);
 
   if (buf_.CurrentSize() > 0) {
     if (use_os_buffer_) {
@@ -209,14 +209,14 @@ Status WritableFileWriter::Sync(bool use_fsync) {
   if (!s.ok()) {
     return s;
   }
-  TEST_KILL_RANDOM(rocksdb_kill_odds);
+  TEST_KILL_RANDOM("WritableFileWriter::Sync:0", rocksdb_kill_odds);
   if (!direct_io_ && pending_sync_) {
     s = SyncInternal(use_fsync);
     if (!s.ok()) {
       return s;
     }
   }
-  TEST_KILL_RANDOM(rocksdb_kill_odds);
+  TEST_KILL_RANDOM("WritableFileWriter::Sync:1", rocksdb_kill_odds);
   pending_sync_ = false;
   if (use_fsync) {
     pending_fsync_ = false;
@@ -248,7 +248,7 @@ Status WritableFileWriter::SyncInternal(bool use_fsync) {
   return s;
 }
 
-Status WritableFileWriter::RangeSync(off_t offset, off_t nbytes) {
+Status WritableFileWriter::RangeSync(uint64_t offset, uint64_t nbytes) {
   IOSTATS_TIMER_GUARD(range_sync_nanos);
   TEST_SYNC_POINT("WritableFileWriter::RangeSync:0");
   return writable_file_->RangeSync(offset, nbytes);
@@ -294,7 +294,7 @@ Status WritableFileWriter::WriteBuffered(const char* data, size_t size) {
     }
 
     IOSTATS_ADD(bytes_written, allowed);
-    TEST_KILL_RANDOM(rocksdb_kill_odds);
+    TEST_KILL_RANDOM("WritableFileWriter::WriteBuffered:0", rocksdb_kill_odds);
 
     left -= allowed;
     src += allowed;
@@ -376,14 +376,20 @@ Status WritableFileWriter::WriteUnbuffered() {
 namespace {
 class ReadaheadRandomAccessFile : public RandomAccessFile {
  public:
-   ReadaheadRandomAccessFile(std::unique_ptr<RandomAccessFile>&& file,
-     size_t readahead_size)
-     : file_(std::move(file)),
-       readahead_size_(readahead_size),
-       forward_calls_(file_->ShouldForwardRawRequest()),
-       buffer_(new char[readahead_size_]),
-       buffer_offset_(0),
-       buffer_len_(0) {}
+  ReadaheadRandomAccessFile(std::unique_ptr<RandomAccessFile>&& file,
+                            size_t readahead_size)
+      : file_(std::move(file)),
+        readahead_size_(readahead_size),
+        forward_calls_(file_->ShouldForwardRawRequest()),
+        buffer_(),
+        buffer_offset_(0),
+        buffer_len_(0) {
+    if (!forward_calls_) {
+      buffer_.reset(new char[readahead_size_]);
+    } else if (readahead_size_ > 0) {
+      file_->EnableReadAhead();
+    }
+  }
 
  ReadaheadRandomAccessFile(const ReadaheadRandomAccessFile&) = delete;
 
@@ -409,8 +415,7 @@ class ReadaheadRandomAccessFile : public RandomAccessFile {
     // if offset between [buffer_offset_, buffer_offset_ + buffer_len>
     if (offset >= buffer_offset_ && offset < buffer_len_ + buffer_offset_) {
       uint64_t offset_in_buffer = offset - buffer_offset_;
-      copied = std::min(static_cast<uint64_t>(buffer_len_) - offset_in_buffer,
-        static_cast<uint64_t>(n));
+      copied = std::min(buffer_len_ - static_cast<size_t>(offset_in_buffer), n);
       memcpy(scratch, buffer_.get() + offset_in_buffer, copied);
       if (copied == n) {
         // fully cached
@@ -468,4 +473,12 @@ std::unique_ptr<RandomAccessFile> NewReadaheadRandomAccessFile(
   return result;
 }
 
+Status NewWritableFile(Env* env, const std::string& fname,
+                       unique_ptr<WritableFile>* result,
+                       const EnvOptions& options) {
+  Status s = env->NewWritableFile(fname, result, options);
+  TEST_KILL_RANDOM("NewWritableFile:0", rocksdb_kill_odds * REDUCE_ODDS2);
+  return s;
+}
+
 }  // namespace rocksdb
diff --git a/src/rocksdb/util/file_reader_writer.h b/src/rocksdb/util/file_reader_writer.h
index 4134a0e..c10cde2 100644
--- a/src/rocksdb/util/file_reader_writer.h
+++ b/src/rocksdb/util/file_reader_writer.h
@@ -7,6 +7,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 #pragma once
+#include <string>
 #include "rocksdb/env.h"
 #include "util/aligned_buffer.h"
 #include "port/port.h"
@@ -36,8 +37,8 @@ class SequentialFileReader {
     return *this;
   }
 
-  SequentialFileReader(SequentialFileReader&) = delete;
-  SequentialFileReader& operator=(SequentialFileReader&) = delete;
+  SequentialFileReader(const SequentialFileReader&) = delete;
+  SequentialFileReader& operator=(const SequentialFileReader&) = delete;
 
   Status Read(size_t n, Slice* result, char* scratch);
 
@@ -92,6 +93,7 @@ class WritableFileWriter {
  private:
   std::unique_ptr<WritableFile> writable_file_;
   AlignedBuffer           buf_;
+  size_t                  max_buffer_size_;
   // Actually written data size can be used for truncate
   // not counting padding data
   uint64_t                filesize_;
@@ -112,6 +114,7 @@ class WritableFileWriter {
                      const EnvOptions& options)
       : writable_file_(std::move(file)),
         buf_(),
+        max_buffer_size_(options.writable_file_max_buffer_size),
         filesize_(0),
         next_write_offset_(0),
         pending_sync_(false),
@@ -159,8 +162,12 @@ class WritableFileWriter {
   Status WriteUnbuffered();
   // Normal write
   Status WriteBuffered(const char* data, size_t size);
-  Status RangeSync(off_t offset, off_t nbytes);
+  Status RangeSync(uint64_t offset, uint64_t nbytes);
   size_t RequestToken(size_t bytes, bool align);
   Status SyncInternal(bool use_fsync);
 };
+
+extern Status NewWritableFile(Env* env, const std::string& fname,
+                              unique_ptr<WritableFile>* result,
+                              const EnvOptions& options);
 }  // namespace rocksdb
diff --git a/src/rocksdb/util/file_reader_writer_test.cc b/src/rocksdb/util/file_reader_writer_test.cc
index d1f0dcb..69b8cfe 100644
--- a/src/rocksdb/util/file_reader_writer_test.cc
+++ b/src/rocksdb/util/file_reader_writer_test.cc
@@ -47,8 +47,8 @@ TEST_F(WritableFileWriterTest, RangeSync) {
     }
 
    protected:
-    Status Allocate(off_t offset, off_t len) override { return Status::OK(); }
-    Status RangeSync(off_t offset, off_t nbytes) override {
+    Status Allocate(uint64_t offset, uint64_t len) override { return Status::OK(); }
+    Status RangeSync(uint64_t offset, uint64_t nbytes) override {
       EXPECT_EQ(offset % 4096, 0u);
       EXPECT_EQ(nbytes % 4096, 0u);
 
@@ -84,6 +84,47 @@ TEST_F(WritableFileWriterTest, RangeSync) {
   }
   writer->Close();
 }
+
+TEST_F(WritableFileWriterTest, AppendStatusReturn) {
+  class FakeWF : public WritableFile {
+   public:
+    explicit FakeWF() : use_os_buffer_(true), io_error_(false) {}
+
+    virtual bool UseOSBuffer() const override { return use_os_buffer_; }
+    Status Append(const Slice& data) override {
+      if (io_error_) {
+        return Status::IOError("Fake IO error");
+      }
+      return Status::OK();
+    }
+    Status PositionedAppend(const Slice& data, uint64_t) override {
+      if (io_error_) {
+        return Status::IOError("Fake IO error");
+      }
+      return Status::OK();
+    }
+    Status Close() override { return Status::OK(); }
+    Status Flush() override { return Status::OK(); }
+    Status Sync() override { return Status::OK(); }
+    void SetUseOSBuffer(bool val) { use_os_buffer_ = val; }
+    void SetIOError(bool val) { io_error_ = val; }
+
+   protected:
+    bool use_os_buffer_;
+    bool io_error_;
+  };
+  unique_ptr<FakeWF> wf(new FakeWF());
+  wf->SetUseOSBuffer(false);
+  unique_ptr<WritableFileWriter> writer(
+      new WritableFileWriter(std::move(wf), EnvOptions()));
+
+  ASSERT_OK(writer->Append(std::string(2 * kMb, 'a')));
+
+  // Next call to WritableFile::Append() should fail
+  dynamic_cast<FakeWF*>(writer->writable_file())->SetIOError(true);
+  ASSERT_NOK(writer->Append(std::string(2 * kMb, 'b')));
+}
+
 }  // namespace rocksdb
 
 int main(int argc, char** argv) {
diff --git a/src/rocksdb/util/file_util.cc b/src/rocksdb/util/file_util.cc
index 1bcf3ed..d4f7b40 100644
--- a/src/rocksdb/util/file_util.cc
+++ b/src/rocksdb/util/file_util.cc
@@ -49,8 +49,7 @@ Status CopyFile(Env* env, const std::string& source,
   char buffer[4096];
   Slice slice;
   while (size > 0) {
-    uint64_t bytes_to_read =
-        std::min(static_cast<uint64_t>(sizeof(buffer)), size);
+    size_t bytes_to_read = std::min(sizeof(buffer), static_cast<size_t>(size));
     if (s.ok()) {
       s = src_reader->Read(bytes_to_read, &slice, buffer);
     }
diff --git a/src/rocksdb/util/histogram.cc b/src/rocksdb/util/histogram.cc
index 5a875e5..4165121 100644
--- a/src/rocksdb/util/histogram.cc
+++ b/src/rocksdb/util/histogram.cc
@@ -82,7 +82,7 @@ void HistogramImpl::Clear() {
   memset(buckets_, 0, sizeof buckets_);
 }
 
-bool HistogramImpl::Empty() { return sum_squares_ == 0; }
+bool HistogramImpl::Empty() { return num_ == 0; }
 
 void HistogramImpl::Add(uint64_t value) {
   const size_t index = bucketMapper.IndexForValue(value);
diff --git a/src/rocksdb/util/instrumented_mutex.cc b/src/rocksdb/util/instrumented_mutex.cc
index 2e240cc..bfb989a 100644
--- a/src/rocksdb/util/instrumented_mutex.cc
+++ b/src/rocksdb/util/instrumented_mutex.cc
@@ -3,13 +3,14 @@
 //  LICENSE file in the root directory of this source tree. An additional grant
 //  of patent rights can be found in the PATENTS file in the same directory.
 
-#include "util/perf_context_imp.h"
 #include "util/instrumented_mutex.h"
+#include "util/perf_context_imp.h"
 #include "util/thread_status_util.h"
 
 namespace rocksdb {
 void InstrumentedMutex::Lock() {
-  PERF_TIMER_GUARD(db_mutex_lock_nanos);
+  PERF_CONDITIONAL_TIMER_GUARD(db_mutex_lock_nanos,
+                               stats_code_ == DB_MUTEX_WAIT_MICROS);
   uint64_t wait_time_micros = 0;
   if (env_ != nullptr && stats_ != nullptr) {
     {
@@ -30,7 +31,8 @@ void InstrumentedMutex::LockInternal() {
 }
 
 void InstrumentedCondVar::Wait() {
-  PERF_TIMER_GUARD(db_condition_wait_nanos);
+  PERF_CONDITIONAL_TIMER_GUARD(db_condition_wait_nanos,
+                               stats_code_ == DB_MUTEX_WAIT_MICROS);
   uint64_t wait_time_micros = 0;
   if (env_ != nullptr && stats_ != nullptr) {
     {
@@ -51,7 +53,8 @@ void InstrumentedCondVar::WaitInternal() {
 }
 
 bool InstrumentedCondVar::TimedWait(uint64_t abs_time_us) {
-  PERF_TIMER_GUARD(db_condition_wait_nanos);
+  PERF_CONDITIONAL_TIMER_GUARD(db_condition_wait_nanos,
+                               stats_code_ == DB_MUTEX_WAIT_MICROS);
   uint64_t wait_time_micros = 0;
   bool result = false;
   if (env_ != nullptr && stats_ != nullptr) {
diff --git a/src/rocksdb/util/io_posix.cc b/src/rocksdb/util/io_posix.cc
new file mode 100644
index 0000000..dd41e2a
--- /dev/null
+++ b/src/rocksdb/util/io_posix.cc
@@ -0,0 +1,655 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+
+#ifdef ROCKSDB_LIB_IO_POSIX
+
+#include "util/io_posix.h"
+#include <errno.h>
+#include <fcntl.h>
+#if defined(OS_LINUX)
+#include <linux/fs.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#ifdef OS_LINUX
+#include <sys/statfs.h>
+#include <sys/syscall.h>
+#endif
+#include "port/port.h"
+#include "rocksdb/slice.h"
+#include "util/coding.h"
+#include "util/iostats_context_imp.h"
+#include "util/posix_logger.h"
+#include "util/string_util.h"
+#include "util/sync_point.h"
+
+namespace rocksdb {
+
+// A wrapper for fadvise, if the platform doesn't support fadvise,
+// it will simply return Status::NotSupport.
+int Fadvise(int fd, off_t offset, size_t len, int advice) {
+#ifdef OS_LINUX
+  return posix_fadvise(fd, offset, len, advice);
+#else
+  return 0;  // simply do nothing.
+#endif
+}
+
+/*
+ * PosixSequentialFile
+ */
+PosixSequentialFile::PosixSequentialFile(const std::string& fname, FILE* f,
+                                         const EnvOptions& options)
+    : filename_(fname),
+      file_(f),
+      fd_(fileno(f)),
+      use_os_buffer_(options.use_os_buffer) {}
+
+PosixSequentialFile::~PosixSequentialFile() { fclose(file_); }
+
+Status PosixSequentialFile::Read(size_t n, Slice* result, char* scratch) {
+  Status s;
+  size_t r = 0;
+  do {
+    r = fread_unlocked(scratch, 1, n, file_);
+  } while (r == 0 && ferror(file_) && errno == EINTR);
+  *result = Slice(scratch, r);
+  if (r < n) {
+    if (feof(file_)) {
+      // We leave status as ok if we hit the end of the file
+      // We also clear the error so that the reads can continue
+      // if a new data is written to the file
+      clearerr(file_);
+    } else {
+      // A partial read with an error: return a non-ok status
+      s = IOError(filename_, errno);
+    }
+  }
+  if (!use_os_buffer_) {
+    // we need to fadvise away the entire range of pages because
+    // we do not want readahead pages to be cached.
+    Fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED);  // free OS pages
+  }
+  return s;
+}
+
+Status PosixSequentialFile::Skip(uint64_t n) {
+  if (fseek(file_, static_cast<long int>(n), SEEK_CUR)) {
+    return IOError(filename_, errno);
+  }
+  return Status::OK();
+}
+
+Status PosixSequentialFile::InvalidateCache(size_t offset, size_t length) {
+#ifndef OS_LINUX
+  return Status::OK();
+#else
+  // free OS pages
+  int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
+  if (ret == 0) {
+    return Status::OK();
+  }
+  return IOError(filename_, errno);
+#endif
+}
+
+#if defined(OS_LINUX)
+namespace {
+static size_t GetUniqueIdFromFile(int fd, char* id, size_t max_size) {
+  if (max_size < kMaxVarint64Length * 3) {
+    return 0;
+  }
+
+  struct stat buf;
+  int result = fstat(fd, &buf);
+  if (result == -1) {
+    return 0;
+  }
+
+  long version = 0;
+  result = ioctl(fd, FS_IOC_GETVERSION, &version);
+  if (result == -1) {
+    return 0;
+  }
+  uint64_t uversion = (uint64_t)version;
+
+  char* rid = id;
+  rid = EncodeVarint64(rid, buf.st_dev);
+  rid = EncodeVarint64(rid, buf.st_ino);
+  rid = EncodeVarint64(rid, uversion);
+  assert(rid >= id);
+  return static_cast<size_t>(rid - id);
+}
+}
+#endif
+
+/*
+ * PosixRandomAccessFile
+ *
+ * pread() based random-access
+ */
+PosixRandomAccessFile::PosixRandomAccessFile(const std::string& fname, int fd,
+                                             const EnvOptions& options)
+    : filename_(fname), fd_(fd), use_os_buffer_(options.use_os_buffer) {
+  assert(!options.use_mmap_reads || sizeof(void*) < 8);
+}
+
+PosixRandomAccessFile::~PosixRandomAccessFile() { close(fd_); }
+
+Status PosixRandomAccessFile::Read(uint64_t offset, size_t n, Slice* result,
+                                   char* scratch) const {
+  Status s;
+  ssize_t r = -1;
+  size_t left = n;
+  char* ptr = scratch;
+  while (left > 0) {
+    r = pread(fd_, ptr, left, static_cast<off_t>(offset));
+
+    if (r <= 0) {
+      if (errno == EINTR) {
+        continue;
+      }
+      break;
+    }
+    ptr += r;
+    offset += r;
+    left -= r;
+  }
+
+  *result = Slice(scratch, (r < 0) ? 0 : n - left);
+  if (r < 0) {
+    // An error: return a non-ok status
+    s = IOError(filename_, errno);
+  }
+  if (!use_os_buffer_) {
+    // we need to fadvise away the entire range of pages because
+    // we do not want readahead pages to be cached.
+    Fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED);  // free OS pages
+  }
+  return s;
+}
+
+#ifdef OS_LINUX
+size_t PosixRandomAccessFile::GetUniqueId(char* id, size_t max_size) const {
+  return GetUniqueIdFromFile(fd_, id, max_size);
+}
+#endif
+
+void PosixRandomAccessFile::Hint(AccessPattern pattern) {
+  switch (pattern) {
+    case NORMAL:
+      Fadvise(fd_, 0, 0, POSIX_FADV_NORMAL);
+      break;
+    case RANDOM:
+      Fadvise(fd_, 0, 0, POSIX_FADV_RANDOM);
+      break;
+    case SEQUENTIAL:
+      Fadvise(fd_, 0, 0, POSIX_FADV_SEQUENTIAL);
+      break;
+    case WILLNEED:
+      Fadvise(fd_, 0, 0, POSIX_FADV_WILLNEED);
+      break;
+    case DONTNEED:
+      Fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED);
+      break;
+    default:
+      assert(false);
+      break;
+  }
+}
+
+Status PosixRandomAccessFile::InvalidateCache(size_t offset, size_t length) {
+#ifndef OS_LINUX
+  return Status::OK();
+#else
+  // free OS pages
+  int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
+  if (ret == 0) {
+    return Status::OK();
+  }
+  return IOError(filename_, errno);
+#endif
+}
+
+/*
+ * PosixMmapReadableFile
+ *
+ * mmap() based random-access
+ */
+// base[0,length-1] contains the mmapped contents of the file.
+PosixMmapReadableFile::PosixMmapReadableFile(const int fd,
+                                             const std::string& fname,
+                                             void* base, size_t length,
+                                             const EnvOptions& options)
+    : fd_(fd), filename_(fname), mmapped_region_(base), length_(length) {
+  fd_ = fd_ + 0;  // suppress the warning for used variables
+  assert(options.use_mmap_reads);
+  assert(options.use_os_buffer);
+}
+
+PosixMmapReadableFile::~PosixMmapReadableFile() {
+  int ret = munmap(mmapped_region_, length_);
+  if (ret != 0) {
+    fprintf(stdout, "failed to munmap %p length %" ROCKSDB_PRIszt " \n",
+            mmapped_region_, length_);
+  }
+}
+
+Status PosixMmapReadableFile::Read(uint64_t offset, size_t n, Slice* result,
+                                   char* scratch) const {
+  Status s;
+  if (offset > length_) {
+    *result = Slice();
+    return IOError(filename_, EINVAL);
+  } else if (offset + n > length_) {
+    n = static_cast<size_t>(length_ - offset);
+  }
+  *result = Slice(reinterpret_cast<char*>(mmapped_region_) + offset, n);
+  return s;
+}
+
+Status PosixMmapReadableFile::InvalidateCache(size_t offset, size_t length) {
+#ifndef OS_LINUX
+  return Status::OK();
+#else
+  // free OS pages
+  int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
+  if (ret == 0) {
+    return Status::OK();
+  }
+  return IOError(filename_, errno);
+#endif
+}
+
+/*
+ * PosixMmapFile
+ *
+ * We preallocate up to an extra megabyte and use memcpy to append new
+ * data to the file.  This is safe since we either properly close the
+ * file before reading from it, or for log files, the reading code
+ * knows enough to skip zero suffixes.
+ */
+Status PosixMmapFile::UnmapCurrentRegion() {
+  TEST_KILL_RANDOM("PosixMmapFile::UnmapCurrentRegion:0", rocksdb_kill_odds);
+  if (base_ != nullptr) {
+    int munmap_status = munmap(base_, limit_ - base_);
+    if (munmap_status != 0) {
+      return IOError(filename_, munmap_status);
+    }
+    file_offset_ += limit_ - base_;
+    base_ = nullptr;
+    limit_ = nullptr;
+    last_sync_ = nullptr;
+    dst_ = nullptr;
+
+    // Increase the amount we map the next time, but capped at 1MB
+    if (map_size_ < (1 << 20)) {
+      map_size_ *= 2;
+    }
+  }
+  return Status::OK();
+}
+
+Status PosixMmapFile::MapNewRegion() {
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  assert(base_ == nullptr);
+
+  TEST_KILL_RANDOM("PosixMmapFile::UnmapCurrentRegion:0", rocksdb_kill_odds);
+  // we can't fallocate with FALLOC_FL_KEEP_SIZE here
+  if (allow_fallocate_) {
+    IOSTATS_TIMER_GUARD(allocate_nanos);
+    int alloc_status = fallocate(fd_, 0, file_offset_, map_size_);
+    if (alloc_status != 0) {
+      // fallback to posix_fallocate
+      alloc_status = posix_fallocate(fd_, file_offset_, map_size_);
+    }
+    if (alloc_status != 0) {
+      return Status::IOError("Error allocating space to file : " + filename_ +
+                             "Error : " + strerror(alloc_status));
+    }
+  }
+
+  TEST_KILL_RANDOM("PosixMmapFile::Append:1", rocksdb_kill_odds);
+  void* ptr = mmap(nullptr, map_size_, PROT_READ | PROT_WRITE, MAP_SHARED, fd_,
+                   file_offset_);
+  if (ptr == MAP_FAILED) {
+    return Status::IOError("MMap failed on " + filename_);
+  }
+  TEST_KILL_RANDOM("PosixMmapFile::Append:2", rocksdb_kill_odds);
+
+  base_ = reinterpret_cast<char*>(ptr);
+  limit_ = base_ + map_size_;
+  dst_ = base_;
+  last_sync_ = base_;
+  return Status::OK();
+#else
+  return Status::NotSupported("This platform doesn't support fallocate()");
+#endif
+}
+
+Status PosixMmapFile::Msync() {
+  if (dst_ == last_sync_) {
+    return Status::OK();
+  }
+  // Find the beginnings of the pages that contain the first and last
+  // bytes to be synced.
+  size_t p1 = TruncateToPageBoundary(last_sync_ - base_);
+  size_t p2 = TruncateToPageBoundary(dst_ - base_ - 1);
+  last_sync_ = dst_;
+  TEST_KILL_RANDOM("PosixMmapFile::Msync:0", rocksdb_kill_odds);
+  if (msync(base_ + p1, p2 - p1 + page_size_, MS_SYNC) < 0) {
+    return IOError(filename_, errno);
+  }
+  return Status::OK();
+}
+
+PosixMmapFile::PosixMmapFile(const std::string& fname, int fd, size_t page_size,
+                             const EnvOptions& options)
+    : filename_(fname),
+      fd_(fd),
+      page_size_(page_size),
+      map_size_(Roundup(65536, page_size)),
+      base_(nullptr),
+      limit_(nullptr),
+      dst_(nullptr),
+      last_sync_(nullptr),
+      file_offset_(0) {
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  allow_fallocate_ = options.allow_fallocate;
+  fallocate_with_keep_size_ = options.fallocate_with_keep_size;
+#endif
+  assert((page_size & (page_size - 1)) == 0);
+  assert(options.use_mmap_writes);
+}
+
+PosixMmapFile::~PosixMmapFile() {
+  if (fd_ >= 0) {
+    PosixMmapFile::Close();
+  }
+}
+
+Status PosixMmapFile::Append(const Slice& data) {
+  const char* src = data.data();
+  size_t left = data.size();
+  while (left > 0) {
+    assert(base_ <= dst_);
+    assert(dst_ <= limit_);
+    size_t avail = limit_ - dst_;
+    if (avail == 0) {
+      Status s = UnmapCurrentRegion();
+      if (!s.ok()) {
+        return s;
+      }
+      s = MapNewRegion();
+      if (!s.ok()) {
+        return s;
+      }
+      TEST_KILL_RANDOM("PosixMmapFile::Append:0", rocksdb_kill_odds);
+    }
+
+    size_t n = (left <= avail) ? left : avail;
+    memcpy(dst_, src, n);
+    dst_ += n;
+    src += n;
+    left -= n;
+  }
+  return Status::OK();
+}
+
+Status PosixMmapFile::Close() {
+  Status s;
+  size_t unused = limit_ - dst_;
+
+  s = UnmapCurrentRegion();
+  if (!s.ok()) {
+    s = IOError(filename_, errno);
+  } else if (unused > 0) {
+    // Trim the extra space at the end of the file
+    if (ftruncate(fd_, file_offset_ - unused) < 0) {
+      s = IOError(filename_, errno);
+    }
+  }
+
+  if (close(fd_) < 0) {
+    if (s.ok()) {
+      s = IOError(filename_, errno);
+    }
+  }
+
+  fd_ = -1;
+  base_ = nullptr;
+  limit_ = nullptr;
+  return s;
+}
+
+Status PosixMmapFile::Flush() { return Status::OK(); }
+
+Status PosixMmapFile::Sync() {
+  if (fdatasync(fd_) < 0) {
+    return IOError(filename_, errno);
+  }
+
+  return Msync();
+}
+
+/**
+ * Flush data as well as metadata to stable storage.
+ */
+Status PosixMmapFile::Fsync() {
+  if (fsync(fd_) < 0) {
+    return IOError(filename_, errno);
+  }
+
+  return Msync();
+}
+
+/**
+ * Get the size of valid data in the file. This will not match the
+ * size that is returned from the filesystem because we use mmap
+ * to extend file by map_size every time.
+ */
+uint64_t PosixMmapFile::GetFileSize() {
+  size_t used = dst_ - base_;
+  return file_offset_ + used;
+}
+
+Status PosixMmapFile::InvalidateCache(size_t offset, size_t length) {
+#ifndef OS_LINUX
+  return Status::OK();
+#else
+  // free OS pages
+  int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
+  if (ret == 0) {
+    return Status::OK();
+  }
+  return IOError(filename_, errno);
+#endif
+}
+
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+Status PosixMmapFile::Allocate(uint64_t offset, uint64_t len) {
+  assert(offset <= std::numeric_limits<off_t>::max());
+  assert(len <= std::numeric_limits<off_t>::max());
+  TEST_KILL_RANDOM("PosixMmapFile::Allocate:0", rocksdb_kill_odds);
+  int alloc_status = 0;
+  if (allow_fallocate_) {
+    alloc_status = fallocate(
+        fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0,
+          static_cast<off_t>(offset), static_cast<off_t>(len));
+  }
+  if (alloc_status == 0) {
+    return Status::OK();
+  } else {
+    return IOError(filename_, errno);
+  }
+}
+#endif
+
+/*
+ * PosixWritableFile
+ *
+ * Use posix write to write data to a file.
+ */
+PosixWritableFile::PosixWritableFile(const std::string& fname, int fd,
+                                     const EnvOptions& options)
+    : filename_(fname), fd_(fd), filesize_(0) {
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  allow_fallocate_ = options.allow_fallocate;
+  fallocate_with_keep_size_ = options.fallocate_with_keep_size;
+#endif
+  assert(!options.use_mmap_writes);
+}
+
+PosixWritableFile::~PosixWritableFile() {
+  if (fd_ >= 0) {
+    PosixWritableFile::Close();
+  }
+}
+
+Status PosixWritableFile::Append(const Slice& data) {
+  const char* src = data.data();
+  size_t left = data.size();
+  while (left != 0) {
+    ssize_t done = write(fd_, src, left);
+    if (done < 0) {
+      if (errno == EINTR) {
+        continue;
+      }
+      return IOError(filename_, errno);
+    }
+    left -= done;
+    src += done;
+  }
+  filesize_ += data.size();
+  return Status::OK();
+}
+
+Status PosixWritableFile::Close() {
+  Status s;
+
+  size_t block_size;
+  size_t last_allocated_block;
+  GetPreallocationStatus(&block_size, &last_allocated_block);
+  if (last_allocated_block > 0) {
+    // trim the extra space preallocated at the end of the file
+    // NOTE(ljin): we probably don't want to surface failure as an IOError,
+    // but it will be nice to log these errors.
+    int dummy __attribute__((unused));
+    dummy = ftruncate(fd_, filesize_);
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+    // in some file systems, ftruncate only trims trailing space if the
+    // new file size is smaller than the current size. Calling fallocate
+    // with FALLOC_FL_PUNCH_HOLE flag to explicitly release these unused
+    // blocks. FALLOC_FL_PUNCH_HOLE is supported on at least the following
+    // filesystems:
+    //   XFS (since Linux 2.6.38)
+    //   ext4 (since Linux 3.0)
+    //   Btrfs (since Linux 3.7)
+    //   tmpfs (since Linux 3.5)
+    // We ignore error since failure of this operation does not affect
+    // correctness.
+    IOSTATS_TIMER_GUARD(allocate_nanos);
+    if (allow_fallocate_) {
+      fallocate(fd_, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, filesize_,
+                block_size * last_allocated_block - filesize_);
+    }
+#endif
+  }
+
+  if (close(fd_) < 0) {
+    s = IOError(filename_, errno);
+  }
+  fd_ = -1;
+  return s;
+}
+
+// write out the cached data to the OS cache
+Status PosixWritableFile::Flush() { return Status::OK(); }
+
+Status PosixWritableFile::Sync() {
+  if (fdatasync(fd_) < 0) {
+    return IOError(filename_, errno);
+  }
+  return Status::OK();
+}
+
+Status PosixWritableFile::Fsync() {
+  if (fsync(fd_) < 0) {
+    return IOError(filename_, errno);
+  }
+  return Status::OK();
+}
+
+bool PosixWritableFile::IsSyncThreadSafe() const { return true; }
+
+uint64_t PosixWritableFile::GetFileSize() { return filesize_; }
+
+Status PosixWritableFile::InvalidateCache(size_t offset, size_t length) {
+#ifndef OS_LINUX
+  return Status::OK();
+#else
+  // free OS pages
+  int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
+  if (ret == 0) {
+    return Status::OK();
+  }
+  return IOError(filename_, errno);
+#endif
+}
+
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+Status PosixWritableFile::Allocate(uint64_t offset, uint64_t len) {
+  assert(offset <= std::numeric_limits<off_t>::max());
+  assert(len <= std::numeric_limits<off_t>::max());
+  TEST_KILL_RANDOM("PosixWritableFile::Allocate:0", rocksdb_kill_odds);
+  IOSTATS_TIMER_GUARD(allocate_nanos);
+  int alloc_status = 0;
+  if (allow_fallocate_) {
+    alloc_status = fallocate(
+        fd_, fallocate_with_keep_size_ ? FALLOC_FL_KEEP_SIZE : 0,
+        static_cast<off_t>(offset), static_cast<off_t>(len));
+  }
+  if (alloc_status == 0) {
+    return Status::OK();
+  } else {
+    return IOError(filename_, errno);
+  }
+}
+
+Status PosixWritableFile::RangeSync(uint64_t offset, uint64_t nbytes) {
+  assert(offset <= std::numeric_limits<off_t>::max());
+  assert(nbytes <= std::numeric_limits<off_t>::max());
+  if (sync_file_range(fd_, static_cast<off_t>(offset),
+      static_cast<off_t>(nbytes), SYNC_FILE_RANGE_WRITE) == 0) {
+    return Status::OK();
+  } else {
+    return IOError(filename_, errno);
+  }
+}
+
+size_t PosixWritableFile::GetUniqueId(char* id, size_t max_size) const {
+  return GetUniqueIdFromFile(fd_, id, max_size);
+}
+#endif
+
+PosixDirectory::~PosixDirectory() { close(fd_); }
+
+Status PosixDirectory::Fsync() {
+  if (fsync(fd_) == -1) {
+    return IOError("directory", errno);
+  }
+  return Status::OK();
+}
+}  // namespace rocksdb
+#endif
diff --git a/src/rocksdb/util/io_posix.h b/src/rocksdb/util/io_posix.h
new file mode 100644
index 0000000..2a45d10
--- /dev/null
+++ b/src/rocksdb/util/io_posix.h
@@ -0,0 +1,174 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+#pragma once
+#include <unistd.h>
+#include "rocksdb/env.h"
+
+// For non linux platform, the following macros are used only as place
+// holder.
+#if !(defined OS_LINUX) && !(defined CYGWIN)
+#define POSIX_FADV_NORMAL 0     /* [MC1] no further special treatment */
+#define POSIX_FADV_RANDOM 1     /* [MC1] expect random page refs */
+#define POSIX_FADV_SEQUENTIAL 2 /* [MC1] expect sequential page refs */
+#define POSIX_FADV_WILLNEED 3   /* [MC1] will need these pages */
+#define POSIX_FADV_DONTNEED 4   /* [MC1] dont need these pages */
+#endif
+
+namespace rocksdb {
+
+static Status IOError(const std::string& context, int err_number) {
+  return Status::IOError(context, strerror(err_number));
+}
+
+class PosixSequentialFile : public SequentialFile {
+ private:
+  std::string filename_;
+  FILE* file_;
+  int fd_;
+  bool use_os_buffer_;
+
+ public:
+  PosixSequentialFile(const std::string& fname, FILE* f,
+                      const EnvOptions& options);
+  virtual ~PosixSequentialFile();
+
+  virtual Status Read(size_t n, Slice* result, char* scratch) override;
+  virtual Status Skip(uint64_t n) override;
+  virtual Status InvalidateCache(size_t offset, size_t length) override;
+};
+
+class PosixRandomAccessFile : public RandomAccessFile {
+ private:
+  std::string filename_;
+  int fd_;
+  bool use_os_buffer_;
+
+ public:
+  PosixRandomAccessFile(const std::string& fname, int fd,
+                        const EnvOptions& options);
+  virtual ~PosixRandomAccessFile();
+
+  virtual Status Read(uint64_t offset, size_t n, Slice* result,
+                      char* scratch) const override;
+#ifdef OS_LINUX
+  virtual size_t GetUniqueId(char* id, size_t max_size) const override;
+#endif
+  virtual void Hint(AccessPattern pattern) override;
+  virtual Status InvalidateCache(size_t offset, size_t length) override;
+};
+
+class PosixWritableFile : public WritableFile {
+ private:
+  const std::string filename_;
+  int fd_;
+  uint64_t filesize_;
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  bool allow_fallocate_;
+  bool fallocate_with_keep_size_;
+#endif
+
+ public:
+  PosixWritableFile(const std::string& fname, int fd,
+                    const EnvOptions& options);
+  ~PosixWritableFile();
+
+  // Means Close() will properly take care of truncate
+  // and it does not need any additional information
+  virtual Status Truncate(uint64_t size) override { return Status::OK(); }
+  virtual Status Close() override;
+  virtual Status Append(const Slice& data) override;
+  virtual Status Flush() override;
+  virtual Status Sync() override;
+  virtual Status Fsync() override;
+  virtual bool IsSyncThreadSafe() const override;
+  virtual uint64_t GetFileSize() override;
+  virtual Status InvalidateCache(size_t offset, size_t length) override;
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  virtual Status Allocate(uint64_t offset, uint64_t len) override;
+  virtual Status RangeSync(uint64_t offset, uint64_t nbytes) override;
+  virtual size_t GetUniqueId(char* id, size_t max_size) const override;
+#endif
+};
+
+class PosixMmapReadableFile : public RandomAccessFile {
+ private:
+  int fd_;
+  std::string filename_;
+  void* mmapped_region_;
+  size_t length_;
+
+ public:
+  PosixMmapReadableFile(const int fd, const std::string& fname, void* base,
+                        size_t length, const EnvOptions& options);
+  virtual ~PosixMmapReadableFile();
+  virtual Status Read(uint64_t offset, size_t n, Slice* result,
+                      char* scratch) const override;
+  virtual Status InvalidateCache(size_t offset, size_t length) override;
+};
+
+class PosixMmapFile : public WritableFile {
+ private:
+  std::string filename_;
+  int fd_;
+  size_t page_size_;
+  size_t map_size_;       // How much extra memory to map at a time
+  char* base_;            // The mapped region
+  char* limit_;           // Limit of the mapped region
+  char* dst_;             // Where to write next  (in range [base_,limit_])
+  char* last_sync_;       // Where have we synced up to
+  uint64_t file_offset_;  // Offset of base_ in file
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  bool allow_fallocate_;  // If false, fallocate calls are bypassed
+  bool fallocate_with_keep_size_;
+#endif
+
+  // Roundup x to a multiple of y
+  static size_t Roundup(size_t x, size_t y) { return ((x + y - 1) / y) * y; }
+
+  size_t TruncateToPageBoundary(size_t s) {
+    s -= (s & (page_size_ - 1));
+    assert((s % page_size_) == 0);
+    return s;
+  }
+
+  Status MapNewRegion();
+  Status UnmapCurrentRegion();
+  Status Msync();
+
+ public:
+  PosixMmapFile(const std::string& fname, int fd, size_t page_size,
+                const EnvOptions& options);
+  ~PosixMmapFile();
+
+  // Means Close() will properly take care of truncate
+  // and it does not need any additional information
+  virtual Status Truncate(uint64_t size) override { return Status::OK(); }
+  virtual Status Close() override;
+  virtual Status Append(const Slice& data) override;
+  virtual Status Flush() override;
+  virtual Status Sync() override;
+  virtual Status Fsync() override;
+  virtual uint64_t GetFileSize() override;
+  virtual Status InvalidateCache(size_t offset, size_t length) override;
+#ifdef ROCKSDB_FALLOCATE_PRESENT
+  virtual Status Allocate(uint64_t offset, uint64_t len) override;
+#endif
+};
+
+class PosixDirectory : public Directory {
+ public:
+  explicit PosixDirectory(int fd) : fd_(fd) {}
+  ~PosixDirectory();
+  virtual Status Fsync() override;
+
+ private:
+  int fd_;
+};
+
+}  // namespace rocksdb
diff --git a/src/rocksdb/util/stl_wrappers.h b/src/rocksdb/util/kv_map.h
similarity index 67%
rename from src/rocksdb/util/stl_wrappers.h
rename to src/rocksdb/util/kv_map.h
index 15b9bdf..486db19 100644
--- a/src/rocksdb/util/stl_wrappers.h
+++ b/src/rocksdb/util/kv_map.h
@@ -8,7 +8,6 @@
 #include <string>
 
 #include "rocksdb/comparator.h"
-#include "rocksdb/memtablerep.h"
 #include "rocksdb/slice.h"
 #include "util/coding.h"
 #include "util/murmurhash.h"
@@ -16,20 +15,6 @@
 namespace rocksdb {
 namespace stl_wrappers {
 
-class Base {
- protected:
-  const MemTableRep::KeyComparator& compare_;
-  explicit Base(const MemTableRep::KeyComparator& compare)
-      : compare_(compare) {}
-};
-
-struct Compare : private Base {
-  explicit Compare(const MemTableRep::KeyComparator& compare) : Base(compare) {}
-  inline bool operator()(const char* a, const char* b) const {
-    return compare_(a, b) < 0;
-  }
-};
-
 struct LessOfComparator {
   explicit LessOfComparator(const Comparator* c = BytewiseComparator())
       : cmp(c) {}
diff --git a/src/rocksdb/util/mutable_cf_options.cc b/src/rocksdb/util/mutable_cf_options.cc
index fafd154..582c0ea 100644
--- a/src/rocksdb/util/mutable_cf_options.cc
+++ b/src/rocksdb/util/mutable_cf_options.cc
@@ -82,8 +82,8 @@ void MutableCFOptions::Dump(Logger* log) const {
       filter_deletes);
   Log(log, "                 disable_auto_compactions: %d",
       disable_auto_compactions);
-  Log(log, "                          soft_rate_limit: %lf",
-      soft_rate_limit);
+  Log(log, "      soft_pending_compaction_bytes_limit: %" PRIu64,
+      soft_pending_compaction_bytes_limit);
   Log(log, "      hard_pending_compaction_bytes_limit: %" PRIu64,
       hard_pending_compaction_bytes_limit);
   Log(log, "       level0_file_num_compaction_trigger: %d",
diff --git a/src/rocksdb/util/mutable_cf_options.h b/src/rocksdb/util/mutable_cf_options.h
index 94c4019..209aa3d 100644
--- a/src/rocksdb/util/mutable_cf_options.h
+++ b/src/rocksdb/util/mutable_cf_options.h
@@ -24,7 +24,8 @@ struct MutableCFOptions {
         filter_deletes(options.filter_deletes),
         inplace_update_num_locks(options.inplace_update_num_locks),
         disable_auto_compactions(options.disable_auto_compactions),
-        soft_rate_limit(options.soft_rate_limit),
+        soft_pending_compaction_bytes_limit(
+            options.soft_pending_compaction_bytes_limit),
         hard_pending_compaction_bytes_limit(
             options.hard_pending_compaction_bytes_limit),
         level0_file_num_compaction_trigger(
@@ -62,12 +63,12 @@ struct MutableCFOptions {
         filter_deletes(false),
         inplace_update_num_locks(0),
         disable_auto_compactions(false),
-        soft_rate_limit(0),
+        soft_pending_compaction_bytes_limit(0),
         hard_pending_compaction_bytes_limit(0),
         level0_file_num_compaction_trigger(0),
         level0_slowdown_writes_trigger(0),
         level0_stop_writes_trigger(0),
-        compaction_pri(kCompactionPriByCompensatedSize),
+        compaction_pri(kByCompensatedSize),
         max_grandparent_overlap_factor(0),
         expanded_compaction_factor(0),
         source_compaction_factor(0),
@@ -114,7 +115,7 @@ struct MutableCFOptions {
 
   // Compaction related options
   bool disable_auto_compactions;
-  double soft_rate_limit;
+  uint64_t soft_pending_compaction_bytes_limit;
   uint64_t hard_pending_compaction_bytes_limit;
   int level0_file_num_compaction_trigger;
   int level0_slowdown_writes_trigger;
diff --git a/src/rocksdb/util/options.cc b/src/rocksdb/util/options.cc
index 14b69e6..2230b77 100644
--- a/src/rocksdb/util/options.cc
+++ b/src/rocksdb/util/options.cc
@@ -29,6 +29,7 @@
 #include "rocksdb/slice_transform.h"
 #include "rocksdb/table.h"
 #include "rocksdb/table_properties.h"
+#include "rocksdb/wal_filter.h"
 #include "table/block_based_table_factory.h"
 #include "util/compression.h"
 #include "util/statistics.h"
@@ -103,13 +104,14 @@ ColumnFamilyOptions::ColumnFamilyOptions()
       max_grandparent_overlap_factor(10),
       soft_rate_limit(0.0),
       hard_rate_limit(0.0),
+      soft_pending_compaction_bytes_limit(0),
       hard_pending_compaction_bytes_limit(0),
       rate_limit_delay_max_milliseconds(1000),
       arena_block_size(0),
       disable_auto_compactions(false),
       purge_redundant_kvs_while_flush(true),
       compaction_style(kCompactionStyleLevel),
-      compaction_pri(kCompactionPriByCompensatedSize),
+      compaction_pri(kByCompensatedSize),
       verify_checksums_in_compaction(true),
       filter_deletes(false),
       max_sequential_skip_in_iterations(8),
@@ -163,6 +165,8 @@ ColumnFamilyOptions::ColumnFamilyOptions(const Options& options)
       source_compaction_factor(options.source_compaction_factor),
       max_grandparent_overlap_factor(options.max_grandparent_overlap_factor),
       soft_rate_limit(options.soft_rate_limit),
+      soft_pending_compaction_bytes_limit(
+          options.soft_pending_compaction_bytes_limit),
       hard_pending_compaction_bytes_limit(
           options.hard_pending_compaction_bytes_limit),
       rate_limit_delay_max_milliseconds(
@@ -224,13 +228,14 @@ DBOptions::DBOptions()
       use_fsync(false),
       db_log_dir(""),
       wal_dir(""),
-      delete_obsolete_files_period_micros(6 * 60 * 60 * 1000000UL),
+      delete_obsolete_files_period_micros(6ULL * 60 * 60 * 1000000),
       max_background_compactions(1),
       max_subcompactions(1),
       max_background_flushes(1),
       max_log_file_size(0),
       log_file_time_to_roll(0),
       keep_log_file_num(1000),
+      recycle_log_file_num(0),
       max_manifest_file_size(std::numeric_limits<uint64_t>::max()),
       table_cache_numshardbits(4),
       WAL_ttl_seconds(0),
@@ -248,6 +253,8 @@ DBOptions::DBOptions()
       access_hint_on_compaction_start(NORMAL),
       new_table_reader_for_compaction_inputs(false),
       compaction_readahead_size(0),
+      random_access_max_buffer_size(1024 * 1024),
+      writable_file_max_buffer_size(1024 * 1024),
       use_adaptive_mutex(false),
       bytes_per_sync(0),
       wal_bytes_per_sync(0),
@@ -255,7 +262,12 @@ DBOptions::DBOptions()
       enable_thread_tracking(false),
       delayed_write_rate(1024U * 1024U),
       skip_stats_update_on_db_open(false),
-      wal_recovery_mode(WALRecoveryMode::kTolerateCorruptedTailRecords) {
+      wal_recovery_mode(WALRecoveryMode::kTolerateCorruptedTailRecords),
+      row_cache(nullptr),
+#ifndef ROCKSDB_LITE
+      wal_filter(nullptr),
+#endif  // ROCKSDB_LITE
+      fail_if_options_file_error(false) {
 }
 
 DBOptions::DBOptions(const Options& options)
@@ -285,6 +297,7 @@ DBOptions::DBOptions(const Options& options)
       max_log_file_size(options.max_log_file_size),
       log_file_time_to_roll(options.log_file_time_to_roll),
       keep_log_file_num(options.keep_log_file_num),
+      recycle_log_file_num(options.recycle_log_file_num),
       max_manifest_file_size(options.max_manifest_file_size),
       table_cache_numshardbits(options.table_cache_numshardbits),
       WAL_ttl_seconds(options.WAL_ttl_seconds),
@@ -303,6 +316,8 @@ DBOptions::DBOptions(const Options& options)
       new_table_reader_for_compaction_inputs(
           options.new_table_reader_for_compaction_inputs),
       compaction_readahead_size(options.compaction_readahead_size),
+      random_access_max_buffer_size(options.random_access_max_buffer_size),
+      writable_file_max_buffer_size(options.writable_file_max_buffer_size),
       use_adaptive_mutex(options.use_adaptive_mutex),
       bytes_per_sync(options.bytes_per_sync),
       wal_bytes_per_sync(options.wal_bytes_per_sync),
@@ -311,7 +326,12 @@ DBOptions::DBOptions(const Options& options)
       delayed_write_rate(options.delayed_write_rate),
       skip_stats_update_on_db_open(options.skip_stats_update_on_db_open),
       wal_recovery_mode(options.wal_recovery_mode),
-      row_cache(options.row_cache) {}
+      row_cache(options.row_cache),
+#ifndef ROCKSDB_LITE
+      wal_filter(options.wal_filter),
+#endif  // ROCKSDB_LITE
+      fail_if_options_file_error(options.fail_if_options_file_error) {
+}
 
 static const char* const access_hints[] = {
   "NONE", "NORMAL", "SEQUENTIAL", "WILLNEED"
@@ -338,6 +358,8 @@ void DBOptions::Dump(Logger* log) const {
          log_file_time_to_roll);
     Header(log, "     Options.keep_log_file_num: %" ROCKSDB_PRIszt,
          keep_log_file_num);
+    Header(log, "  Options.recycle_log_file_num: %" ROCKSDB_PRIszt,
+           recycle_log_file_num);
     Header(log, "       Options.allow_os_buffer: %d", allow_os_buffer);
     Header(log, "      Options.allow_mmap_reads: %d", allow_mmap_reads);
     Header(log, "      Options.allow_fallocate: %d", allow_fallocate);
@@ -389,6 +411,15 @@ void DBOptions::Dump(Logger* log) const {
          "               Options.compaction_readahead_size: %" ROCKSDB_PRIszt
          "d",
          compaction_readahead_size);
+    Header(
+        log,
+        "               Options.random_access_max_buffer_size: %" ROCKSDB_PRIszt
+        "d",
+        random_access_max_buffer_size);
+    Header(log,
+         "              Options.writable_file_max_buffer_size: %" ROCKSDB_PRIszt
+         "d",
+         writable_file_max_buffer_size);
     Header(log, "                      Options.use_adaptive_mutex: %d",
         use_adaptive_mutex);
     Header(log, "                            Options.rate_limiter: %p",
@@ -409,6 +440,10 @@ void DBOptions::Dump(Logger* log) const {
     } else {
       Header(log, "                               Options.row_cache: None");
     }
+#ifndef ROCKSDB_LITE
+    Header(log, "       Options.wal_filter: %s",
+           wal_filter ? wal_filter->Name() : "None");
+#endif  // ROCKDB_LITE
 }  // DBOptions::Dump
 
 void ColumnFamilyOptions::Dump(Logger* log) const {
@@ -483,8 +518,8 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
     Header(log,
          "                       Options.arena_block_size: %" ROCKSDB_PRIszt,
          arena_block_size);
-    Header(log, "                      Options.soft_rate_limit: %.2f",
-        soft_rate_limit);
+    Header(log, "  Options.soft_pending_compaction_bytes_limit: %" PRIu64,
+           soft_pending_compaction_bytes_limit);
     Header(log, "  Options.hard_pending_compaction_bytes_limit: %" PRIu64,
          hard_pending_compaction_bytes_limit);
     Header(log, "      Options.rate_limit_delay_max_milliseconds: %u",
@@ -684,7 +719,8 @@ ReadOptions::ReadOptions()
       read_tier(kReadAllTier),
       tailing(false),
       managed(false),
-      total_order_seek(false) {
+      total_order_seek(false),
+      prefix_same_as_start(false) {
   XFUNC_TEST("", "managed_options", managed_options, xf_manage_options,
              reinterpret_cast<ReadOptions*>(this));
 }
@@ -697,7 +733,8 @@ ReadOptions::ReadOptions(bool cksum, bool cache)
       read_tier(kReadAllTier),
       tailing(false),
       managed(false),
-      total_order_seek(false) {
+      total_order_seek(false),
+      prefix_same_as_start(false) {
   XFUNC_TEST("", "managed_options", managed_options, xf_manage_options,
              reinterpret_cast<ReadOptions*>(this));
 }
diff --git a/src/rocksdb/util/options_builder.cc b/src/rocksdb/util/options_builder.cc
index 3ac3deb..67fd268 100644
--- a/src/rocksdb/util/options_builder.cc
+++ b/src/rocksdb/util/options_builder.cc
@@ -127,8 +127,8 @@ void OptimizeForLevel(int read_amplification_threshold,
   const int kMaxFileNumCompactionTrigger = 4;
   const int kMinLevel0StopTrigger = 3;
 
-  int file_num_buffer =
-      kInitialLevel0TotalSize / options->write_buffer_size + 1;
+  int file_num_buffer = static_cast<int>(
+      kInitialLevel0TotalSize / options->write_buffer_size + 1);
 
   if (level0_stop_writes_trigger > file_num_buffer) {
     // Have sufficient room for multiple level 0 files
diff --git a/src/rocksdb/util/options_helper.cc b/src/rocksdb/util/options_helper.cc
index 78ae599..c397c2f 100644
--- a/src/rocksdb/util/options_helper.cc
+++ b/src/rocksdb/util/options_helper.cc
@@ -20,6 +20,7 @@
 #include "rocksdb/slice_transform.h"
 #include "rocksdb/table.h"
 #include "table/block_based_table_factory.h"
+#include "table/plain_table_factory.h"
 #include "util/logging.h"
 #include "util/string_util.h"
 
@@ -105,32 +106,27 @@ std::string trim(const std::string& str) {
   return std::string();
 }
 
-bool SerializeCompressionType(const CompressionType& type, std::string* value) {
-  switch (type) {
-    case kNoCompression:
-      *value = "kNoCompression";
-      return true;
-    case kSnappyCompression:
-      *value = "kSnappyCompression";
-      return true;
-    case kZlibCompression:
-      *value = "kZlibCompression";
-      return true;
-    case kBZip2Compression:
-      *value = "kBZip2Compression";
-      return true;
-    case kLZ4Compression:
-      *value = "kLZ4Compression";
-      return true;
-    case kLZ4HCCompression:
-      *value = "kLZ4HCCompression";
-      return true;
-    case kZSTDNotFinalCompression:
-      *value = "kZSTDNotFinalCompression";
+template <typename T>
+bool ParseEnum(const std::unordered_map<std::string, T>& type_map,
+               const std::string& type, T* value) {
+  auto iter = type_map.find(type);
+  if (iter != type_map.end()) {
+    *value = iter->second;
+    return true;
+  }
+  return false;
+}
+
+template <typename T>
+bool SerializeEnum(const std::unordered_map<std::string, T>& type_map,
+                   const T& type, std::string* value) {
+  for (const auto& pair : type_map) {
+    if (pair.second == type) {
+      *value = pair.first;
       return true;
-    default:
-      return false;
+    }
   }
+  return false;
 }
 
 bool SerializeVectorCompressionType(const std::vector<CompressionType>& types,
@@ -142,7 +138,8 @@ bool SerializeVectorCompressionType(const std::vector<CompressionType>& types,
       ss << ':';
     }
     std::string string_type;
-    result = SerializeCompressionType(types[i], &string_type);
+    result = SerializeEnum<CompressionType>(compression_type_string_map,
+                                            types[i], &string_type);
     if (result == false) {
       return result;
     }
@@ -152,50 +149,6 @@ bool SerializeVectorCompressionType(const std::vector<CompressionType>& types,
   return true;
 }
 
-bool ParseCompressionType(const std::string& string_value,
-                          CompressionType* type) {
-  if (string_value == "kNoCompression") {
-    *type = kNoCompression;
-  } else if (string_value == "kSnappyCompression") {
-    *type = kSnappyCompression;
-  } else if (string_value == "kZlibCompression") {
-    *type = kZlibCompression;
-  } else if (string_value == "kBZip2Compression") {
-    *type = kBZip2Compression;
-  } else if (string_value == "kLZ4Compression") {
-    *type = kLZ4Compression;
-  } else if (string_value == "kLZ4HCCompression") {
-    *type = kLZ4HCCompression;
-  } else if (string_value == "kZSTDNotFinalCompression") {
-    *type = kZSTDNotFinalCompression;
-  } else {
-    return false;
-  }
-  return true;
-}
-
-BlockBasedTableOptions::IndexType ParseBlockBasedTableIndexType(
-    const std::string& type) {
-  if (type == "kBinarySearch") {
-    return BlockBasedTableOptions::kBinarySearch;
-  } else if (type == "kHashSearch") {
-    return BlockBasedTableOptions::kHashSearch;
-  }
-  throw std::invalid_argument("Unknown index type: " + type);
-}
-
-ChecksumType ParseBlockBasedTableChecksumType(
-    const std::string& type) {
-  if (type == "kNoChecksum") {
-    return kNoChecksum;
-  } else if (type == "kCRC32c") {
-    return kCRC32c;
-  } else if (type == "kxxHash") {
-    return kxxHash;
-  }
-  throw std::invalid_argument("Unknown checksum type: " + type);
-}
-
 bool ParseBoolean(const std::string& type, const std::string& value) {
   if (value == "true" || value == "1") {
     return true;
@@ -273,28 +226,6 @@ double ParseDouble(const std::string& value) {
   return std::strtod(value.c_str(), 0);
 #endif
 }
-static const std::unordered_map<char, std::string>
-    compaction_style_to_string_map = {
-        {kCompactionStyleLevel, "kCompactionStyleLevel"},
-        {kCompactionStyleUniversal, "kCompactionStyleUniversal"},
-        {kCompactionStyleFIFO, "kCompactionStyleFIFO"},
-        {kCompactionStyleNone, "kCompactionStyleNone"}};
-
-CompactionStyle ParseCompactionStyle(const std::string& type) {
-  for (auto const& entry : compaction_style_to_string_map) {
-    if (entry.second == type) {
-      return static_cast<CompactionStyle>(entry.first);
-    }
-  }
-  throw std::invalid_argument("unknown compaction style: " + type);
-  return kCompactionStyleLevel;
-}
-
-std::string CompactionStyleToString(const CompactionStyle style) {
-  auto iter = compaction_style_to_string_map.find(style);
-  assert(iter != compaction_style_to_string_map.end());
-  return iter->second;
-}
 
 bool ParseVectorCompressionType(
     const std::string& value,
@@ -306,14 +237,16 @@ bool ParseVectorCompressionType(
     bool is_ok;
     CompressionType type;
     if (end == std::string::npos) {
-      is_ok = ParseCompressionType(value.substr(start), &type);
+      is_ok = ParseEnum<CompressionType>(compression_type_string_map,
+                                         value.substr(start), &type);
       if (!is_ok) {
         return false;
       }
       compression_per_level->emplace_back(type);
       break;
     } else {
-      is_ok = ParseCompressionType(value.substr(start, end - start), &type);
+      is_ok = ParseEnum<CompressionType>(
+          compression_type_string_map, value.substr(start, end - start), &type);
       if (!is_ok) {
         return false;
       }
@@ -328,6 +261,7 @@ bool ParseSliceTransformHelper(
     const std::string& kFixedPrefixName, const std::string& kCappedPrefixName,
     const std::string& value,
     std::shared_ptr<const SliceTransform>* slice_transform) {
+  static const std::string kNullptrString = "nullptr";
   auto& pe_value = value;
   if (pe_value.size() > kFixedPrefixName.size() &&
       pe_value.compare(0, kFixedPrefixName.size(), kFixedPrefixName) == 0) {
@@ -339,7 +273,7 @@ bool ParseSliceTransformHelper(
     int prefix_length =
         ParseInt(trim(pe_value.substr(kCappedPrefixName.size())));
     slice_transform->reset(NewCappedPrefixTransform(prefix_length));
-  } else if (value == "nullptr") {
+  } else if (value == kNullptrString) {
     slice_transform->reset();
   } else {
     return false;
@@ -401,12 +335,13 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
       *reinterpret_cast<double*>(opt_address) = ParseDouble(value);
       break;
     case OptionType::kCompactionStyle:
-      *reinterpret_cast<CompactionStyle*>(opt_address) =
-          ParseCompactionStyle(value);
-      break;
+      return ParseEnum<CompactionStyle>(
+          compaction_style_string_map, value,
+          reinterpret_cast<CompactionStyle*>(opt_address));
     case OptionType::kCompressionType:
-      return ParseCompressionType(
-          value, reinterpret_cast<CompressionType*>(opt_address));
+      return ParseEnum<CompressionType>(
+          compression_type_string_map, value,
+          reinterpret_cast<CompressionType*>(opt_address));
     case OptionType::kVectorCompressionType:
       return ParseVectorCompressionType(
           value, reinterpret_cast<std::vector<CompressionType>*>(opt_address));
@@ -414,6 +349,18 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
       return ParseSliceTransform(
           value, reinterpret_cast<std::shared_ptr<const SliceTransform>*>(
                      opt_address));
+    case OptionType::kChecksumType:
+      return ParseEnum<ChecksumType>(
+          checksum_type_string_map, value,
+          reinterpret_cast<ChecksumType*>(opt_address));
+    case OptionType::kBlockBasedTableIndexType:
+      return ParseEnum<BlockBasedTableOptions::IndexType>(
+          block_base_table_index_type_string_map, value,
+          reinterpret_cast<BlockBasedTableOptions::IndexType*>(opt_address));
+    case OptionType::kEncodingType:
+      return ParseEnum<EncodingType>(
+          encoding_type_string_map, value,
+          reinterpret_cast<EncodingType*>(opt_address));
     default:
       return false;
   }
@@ -425,6 +372,7 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
 bool SerializeSingleOptionHelper(const char* opt_address,
                                  const OptionType opt_type,
                                  std::string* value) {
+  static const std::string kNullptrString = "nullptr";
   assert(value);
   switch (opt_type) {
     case OptionType::kBoolean:
@@ -453,11 +401,12 @@ bool SerializeSingleOptionHelper(const char* opt_address,
           *(reinterpret_cast<const std::string*>(opt_address)));
       break;
     case OptionType::kCompactionStyle:
-      *value = CompactionStyleToString(
-          *(reinterpret_cast<const CompactionStyle*>(opt_address)));
-      break;
+      return SerializeEnum<CompactionStyle>(
+          compaction_style_string_map,
+          *(reinterpret_cast<const CompactionStyle*>(opt_address)), value);
     case OptionType::kCompressionType:
-      return SerializeCompressionType(
+      return SerializeEnum<CompressionType>(
+          compression_type_string_map,
           *(reinterpret_cast<const CompressionType*>(opt_address)), value);
     case OptionType::kVectorCompressionType:
       return SerializeVectorCompressionType(
@@ -469,7 +418,7 @@ bool SerializeSingleOptionHelper(const char* opt_address,
           reinterpret_cast<const std::shared_ptr<const SliceTransform>*>(
               opt_address);
       *value = slice_transform_ptr->get() ? slice_transform_ptr->get()->Name()
-                                          : "nullptr";
+                                          : kNullptrString;
       break;
     }
     case OptionType::kTableFactory: {
@@ -477,42 +426,78 @@ bool SerializeSingleOptionHelper(const char* opt_address,
           reinterpret_cast<const std::shared_ptr<const TableFactory>*>(
               opt_address);
       *value = table_factory_ptr->get() ? table_factory_ptr->get()->Name()
-                                        : "nullptr";
+                                        : kNullptrString;
       break;
     }
     case OptionType::kComparator: {
       // it's a const pointer of const Comparator*
       const auto* ptr = reinterpret_cast<const Comparator* const*>(opt_address);
-      *value = *ptr ? (*ptr)->Name() : "nullptr";
+      // Since the user-specified comparator will be wrapped by
+      // InternalKeyComparator, we should persist the user-specified one
+      // instead of InternalKeyComparator.
+      const auto* internal_comparator =
+          dynamic_cast<const InternalKeyComparator*>(*ptr);
+      if (internal_comparator != nullptr) {
+        *value = internal_comparator->user_comparator()->Name();
+      } else {
+        *value = *ptr ? (*ptr)->Name() : kNullptrString;
+      }
       break;
     }
     case OptionType::kCompactionFilter: {
       // it's a const pointer of const CompactionFilter*
       const auto* ptr =
           reinterpret_cast<const CompactionFilter* const*>(opt_address);
-      *value = *ptr ? (*ptr)->Name() : "nullptr";
+      *value = *ptr ? (*ptr)->Name() : kNullptrString;
       break;
     }
     case OptionType::kCompactionFilterFactory: {
       const auto* ptr =
           reinterpret_cast<const std::shared_ptr<CompactionFilterFactory>*>(
               opt_address);
-      *value = ptr->get() ? ptr->get()->Name() : "nullptr";
+      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
       break;
     }
     case OptionType::kMemTableRepFactory: {
       const auto* ptr =
           reinterpret_cast<const std::shared_ptr<MemTableRepFactory>*>(
               opt_address);
-      *value = ptr->get() ? ptr->get()->Name() : "nullptr";
+      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
       break;
     }
     case OptionType::kMergeOperator: {
       const auto* ptr =
           reinterpret_cast<const std::shared_ptr<MergeOperator>*>(opt_address);
-      *value = ptr->get() ? ptr->get()->Name() : "nullptr";
+      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
+      break;
+    }
+    case OptionType::kFilterPolicy: {
+      const auto* ptr =
+          reinterpret_cast<const std::shared_ptr<FilterPolicy>*>(opt_address);
+      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
       break;
     }
+    case OptionType::kChecksumType:
+      return SerializeEnum<ChecksumType>(
+          checksum_type_string_map,
+          *reinterpret_cast<const ChecksumType*>(opt_address), value);
+    case OptionType::kBlockBasedTableIndexType:
+      return SerializeEnum<BlockBasedTableOptions::IndexType>(
+          block_base_table_index_type_string_map,
+          *reinterpret_cast<const BlockBasedTableOptions::IndexType*>(
+              opt_address),
+          value);
+    case OptionType::kFlushBlockPolicyFactory: {
+      const auto* ptr =
+          reinterpret_cast<const std::shared_ptr<FlushBlockPolicyFactory>*>(
+              opt_address);
+      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
+      break;
+    }
+    case OptionType::kEncodingType:
+      return SerializeEnum<EncodingType>(
+          encoding_type_string_map,
+          *reinterpret_cast<const EncodingType*>(opt_address), value);
     default:
       return false;
   }
@@ -554,7 +539,10 @@ bool ParseCompactionOptions(const std::string& name, const std::string& value,
   if (name == "disable_auto_compactions") {
     new_options->disable_auto_compactions = ParseBoolean(name, value);
   } else if (name == "soft_rate_limit") {
-    new_options->soft_rate_limit = ParseDouble(value);
+    // Deprecated options but still leave it here to avoid older options
+    // strings can be consumed.
+  } else if (name == "soft_pending_compaction_bytes_limit") {
+    new_options->soft_pending_compaction_bytes_limit = ParseUint64(value);
   } else if (name == "hard_pending_compaction_bytes_limit") {
     new_options->hard_pending_compaction_bytes_limit = ParseUint64(value);
   } else if (name == "hard_rate_limit") {
@@ -715,12 +703,12 @@ Status StringToMap(const std::string& opts_str,
   return Status::OK();
 }
 
-bool ParseColumnFamilyOption(const std::string& name,
-                             const std::string& org_value,
-                             ColumnFamilyOptions* new_options,
-                             bool input_string_escaped = false) {
+Status ParseColumnFamilyOption(const std::string& name,
+                               const std::string& org_value,
+                               ColumnFamilyOptions* new_options,
+                               bool input_strings_escaped = false) {
   const std::string& value =
-      input_string_escaped ? UnescapeOptionString(org_value) : org_value;
+      input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
   try {
     if (name == "max_bytes_for_level_multiplier_additional") {
       new_options->max_bytes_for_level_multiplier_additional.clear();
@@ -743,55 +731,95 @@ bool ParseColumnFamilyOption(const std::string& name,
       auto block_based_table_factory = dynamic_cast<BlockBasedTableFactory*>(
           new_options->table_factory.get());
       if (block_based_table_factory != nullptr) {
-        base_table_options = block_based_table_factory->GetTableOptions();
+        base_table_options = block_based_table_factory->table_options();
       }
       Status table_opt_s = GetBlockBasedTableOptionsFromString(
           base_table_options, value, &table_opt);
       if (!table_opt_s.ok()) {
-        return false;
+        return Status::InvalidArgument(
+            "unable to parse the specified CF option " + name);
       }
       new_options->table_factory.reset(NewBlockBasedTableFactory(table_opt));
+    } else if (name == "plain_table_factory") {
+      // Nested options
+      PlainTableOptions table_opt, base_table_options;
+      auto plain_table_factory = dynamic_cast<PlainTableFactory*>(
+          new_options->table_factory.get());
+      if (plain_table_factory != nullptr) {
+        base_table_options = plain_table_factory->table_options();
+      }
+      Status table_opt_s = GetPlainTableOptionsFromString(
+          base_table_options, value, &table_opt);
+      if (!table_opt_s.ok()) {
+        return Status::InvalidArgument(
+            "unable to parse the specified CF option " + name);
+      }
+      new_options->table_factory.reset(NewPlainTableFactory(table_opt));
+    } else if (name == "memtable") {
+      std::unique_ptr<MemTableRepFactory> new_mem_factory;
+      Status mem_factory_s =
+          GetMemTableRepFactoryFromString(value, &new_mem_factory);
+      if (!mem_factory_s.ok()) {
+        return Status::InvalidArgument(
+            "unable to parse the specified CF option " + name);
+      }
+      new_options->memtable_factory.reset(new_mem_factory.release());
     } else if (name == "compression_opts") {
       size_t start = 0;
       size_t end = value.find(':');
       if (end == std::string::npos) {
-        return false;
+        return Status::InvalidArgument(
+            "unable to parse the specified CF option " + name);
       }
       new_options->compression_opts.window_bits =
           ParseInt(value.substr(start, end - start));
       start = end + 1;
       end = value.find(':', start);
       if (end == std::string::npos) {
-        return false;
+        return Status::InvalidArgument(
+            "unable to parse the specified CF option " + name);
       }
       new_options->compression_opts.level =
           ParseInt(value.substr(start, end - start));
       start = end + 1;
       if (start >= value.size()) {
-        return false;
+        return Status::InvalidArgument(
+            "unable to parse the specified CF option " + name);
       }
       new_options->compression_opts.strategy =
           ParseInt(value.substr(start, value.size() - start));
-    } else if (name == "compaction_options_universal") {
-      // TODO(ljin): add support
-      return false;
     } else if (name == "compaction_options_fifo") {
       new_options->compaction_options_fifo.max_table_files_size =
           ParseUint64(value);
     } else {
       auto iter = cf_options_type_info.find(name);
       if (iter == cf_options_type_info.end()) {
-        return false;
+        return Status::InvalidArgument(
+            "Unable to parse the specified CF option " + name);
       }
       const auto& opt_info = iter->second;
-      return ParseOptionHelper(
-          reinterpret_cast<char*>(new_options) + opt_info.offset, opt_info.type,
-          value);
+      if (ParseOptionHelper(
+              reinterpret_cast<char*>(new_options) + opt_info.offset,
+              opt_info.type, value)) {
+        return Status::OK();
+      }
+      switch (opt_info.verification) {
+        case OptionVerificationType::kByName:
+          return Status::NotSupported(
+              "Deserializing the specified CF option " + name +
+                  " is not supported");
+        case OptionVerificationType::kDeprecated:
+          return Status::OK();
+        default:
+          return Status::InvalidArgument(
+              "Unable to parse the specified CF option " + name);
+      }
     }
-  } catch (std::exception& e) {
-    return false;
+  } catch (const std::exception&) {
+    return Status::InvalidArgument(
+        "unable to parse the specified option " + name);
   }
-  return true;
+  return Status::OK();
 }
 
 bool SerializeSingleDBOption(std::string* opt_string,
@@ -881,10 +909,65 @@ Status GetStringFromColumnFamilyOptions(std::string* opt_string,
   return Status::OK();
 }
 
-bool ParseDBOption(const std::string& name, const std::string& org_value,
-                   DBOptions* new_options, bool input_string_escaped = false) {
+bool SerializeSingleBlockBasedTableOption(
+    std::string* opt_string, const BlockBasedTableOptions& bbt_options,
+    const std::string& name, const std::string& delimiter) {
+  auto iter = block_based_table_type_info.find(name);
+  if (iter == block_based_table_type_info.end()) {
+    return false;
+  }
+  auto& opt_info = iter->second;
+  const char* opt_address =
+      reinterpret_cast<const char*>(&bbt_options) + opt_info.offset;
+  std::string value;
+  bool result = SerializeSingleOptionHelper(opt_address, opt_info.type, &value);
+  if (result) {
+    *opt_string = name + "=" + value + delimiter;
+  }
+  return result;
+}
+
+Status GetStringFromBlockBasedTableOptions(
+    std::string* opt_string, const BlockBasedTableOptions& bbt_options,
+    const std::string& delimiter) {
+  assert(opt_string);
+  opt_string->clear();
+  for (auto iter = block_based_table_type_info.begin();
+       iter != block_based_table_type_info.end(); ++iter) {
+    if (iter->second.verification == OptionVerificationType::kDeprecated) {
+      // If the option is no longer used in rocksdb and marked as deprecated,
+      // we skip it in the serialization.
+      continue;
+    }
+    std::string single_output;
+    bool result = SerializeSingleBlockBasedTableOption(
+        &single_output, bbt_options, iter->first, delimiter);
+    assert(result);
+    if (result) {
+      opt_string->append(single_output);
+    }
+  }
+  return Status::OK();
+}
+
+Status GetStringFromTableFactory(std::string* opts_str, const TableFactory* tf,
+                                 const std::string& delimiter) {
+  const auto* bbtf = dynamic_cast<const BlockBasedTableFactory*>(tf);
+  opts_str->clear();
+  if (bbtf != nullptr) {
+    return GetStringFromBlockBasedTableOptions(opts_str, bbtf->table_options(),
+                                               delimiter);
+  }
+
+  return Status::OK();
+}
+
+Status ParseDBOption(const std::string& name,
+                     const std::string& org_value,
+                     DBOptions* new_options,
+                     bool input_strings_escaped = false) {
   const std::string& value =
-      input_string_escaped ? UnescapeOptionString(org_value) : org_value;
+      input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
   try {
     if (name == "rate_limiter_bytes_per_sec") {
       new_options->rate_limiter.reset(
@@ -892,83 +975,117 @@ bool ParseDBOption(const std::string& name, const std::string& org_value,
     } else {
       auto iter = db_options_type_info.find(name);
       if (iter == db_options_type_info.end()) {
-        return false;
+        return Status::InvalidArgument("Unrecognized option DBOptions:", name);
       }
       const auto& opt_info = iter->second;
-      if (opt_info.verification != OptionVerificationType::kByName &&
-          opt_info.verification != OptionVerificationType::kDeprecated) {
-        return ParseOptionHelper(
-            reinterpret_cast<char*>(new_options) + opt_info.offset,
-            opt_info.type, value);
+      if (ParseOptionHelper(
+              reinterpret_cast<char*>(new_options) + opt_info.offset,
+              opt_info.type, value)) {
+        return Status::OK();
+      }
+      switch (opt_info.verification) {
+        case OptionVerificationType::kByName:
+          return Status::NotSupported(
+              "Deserializing the specified DB option " + name +
+                  " is not supported");
+        case OptionVerificationType::kDeprecated:
+          return Status::OK();
+        default:
+          return Status::InvalidArgument(
+              "Unable to parse the specified DB option " + name);
       }
     }
-  } catch (const std::exception& e) {
-    return false;
+  } catch (const std::exception&) {
+    return Status::InvalidArgument("Unable to parse DBOptions:", name);
   }
-  return true;
+  return Status::OK();
+}
+
+std::string ParseBlockBasedTableOption(const std::string& name,
+                                       const std::string& org_value,
+                                       BlockBasedTableOptions* new_options,
+                                       bool input_strings_escaped = false) {
+  const std::string& value =
+      input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
+  if (!input_strings_escaped) {
+    // if the input string is not escaped, it means this function is
+    // invoked from SetOptions, which takes the old format.
+    if (name == "block_cache") {
+      new_options->block_cache = NewLRUCache(ParseSizeT(value));
+      return "";
+    } else if (name == "block_cache_compressed") {
+      new_options->block_cache_compressed = NewLRUCache(ParseSizeT(value));
+      return "";
+    } else if (name == "filter_policy") {
+      // Expect the following format
+      // bloomfilter:int:bool
+      const std::string kName = "bloomfilter:";
+      if (value.compare(0, kName.size(), kName) != 0) {
+        return "Invalid filter policy name";
+      }
+      size_t pos = value.find(':', kName.size());
+      if (pos == std::string::npos) {
+        return "Invalid filter policy config, missing bits_per_key";
+      }
+      int bits_per_key =
+          ParseInt(trim(value.substr(kName.size(), pos - kName.size())));
+      bool use_block_based_builder =
+          ParseBoolean("use_block_based_builder", trim(value.substr(pos + 1)));
+      new_options->filter_policy.reset(
+          NewBloomFilterPolicy(bits_per_key, use_block_based_builder));
+      return "";
+    }
+  }
+  const auto iter = block_based_table_type_info.find(name);
+  if (iter == block_based_table_type_info.end()) {
+    return "Unrecognized option";
+  }
+  const auto& opt_info = iter->second;
+  if (!ParseOptionHelper(reinterpret_cast<char*>(new_options) + opt_info.offset,
+                         opt_info.type, value)) {
+    return "Invalid value";
+  }
+  return "";
+}
+
+std::string ParsePlainTableOptions(const std::string& name,
+                                   const std::string& org_value,
+                                   PlainTableOptions* new_option,
+                                   bool input_strings_escaped = false) {
+  const std::string& value =
+      input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
+  const auto iter = plain_table_type_info.find(name);
+  if (iter == plain_table_type_info.end()) {
+    return "Unrecognized option";
+  }
+  const auto& opt_info = iter->second;
+  if (!ParseOptionHelper(reinterpret_cast<char*>(new_option) + opt_info.offset,
+                         opt_info.type, value)) {
+    return "Invalid value";
+  }
+  return "";
 }
 
 Status GetBlockBasedTableOptionsFromMap(
     const BlockBasedTableOptions& table_options,
     const std::unordered_map<std::string, std::string>& opts_map,
-    BlockBasedTableOptions* new_table_options) {
-
+    BlockBasedTableOptions* new_table_options, bool input_strings_escaped) {
   assert(new_table_options);
   *new_table_options = table_options;
   for (const auto& o : opts_map) {
-    try {
-      if (o.first == "cache_index_and_filter_blocks") {
-        new_table_options->cache_index_and_filter_blocks =
-          ParseBoolean(o.first, o.second);
-      } else if (o.first == "index_type") {
-        new_table_options->index_type = ParseBlockBasedTableIndexType(o.second);
-      } else if (o.first == "hash_index_allow_collision") {
-        new_table_options->hash_index_allow_collision =
-          ParseBoolean(o.first, o.second);
-      } else if (o.first == "checksum") {
-        new_table_options->checksum =
-          ParseBlockBasedTableChecksumType(o.second);
-      } else if (o.first == "no_block_cache") {
-        new_table_options->no_block_cache = ParseBoolean(o.first, o.second);
-      } else if (o.first == "block_cache") {
-        new_table_options->block_cache = NewLRUCache(ParseSizeT(o.second));
-      } else if (o.first == "block_cache_compressed") {
-        new_table_options->block_cache_compressed =
-          NewLRUCache(ParseSizeT(o.second));
-      } else if (o.first == "block_size") {
-        new_table_options->block_size = ParseSizeT(o.second);
-      } else if (o.first == "block_size_deviation") {
-        new_table_options->block_size_deviation = ParseInt(o.second);
-      } else if (o.first == "block_restart_interval") {
-        new_table_options->block_restart_interval = ParseInt(o.second);
-      } else if (o.first == "filter_policy") {
-        // Expect the following format
-        // bloomfilter:int:bool
-        const std::string kName = "bloomfilter:";
-        if (o.second.compare(0, kName.size(), kName) != 0) {
-          return Status::InvalidArgument("Invalid filter policy name");
-        }
-        size_t pos = o.second.find(':', kName.size());
-        if (pos == std::string::npos) {
-          return Status::InvalidArgument("Invalid filter policy config, "
-                                         "missing bits_per_key");
-        }
-        int bits_per_key = ParseInt(
-            trim(o.second.substr(kName.size(), pos - kName.size())));
-        bool use_block_based_builder =
-          ParseBoolean("use_block_based_builder",
-                       trim(o.second.substr(pos + 1)));
-        new_table_options->filter_policy.reset(
-            NewBloomFilterPolicy(bits_per_key, use_block_based_builder));
-      } else if (o.first == "whole_key_filtering") {
-        new_table_options->whole_key_filtering =
-          ParseBoolean(o.first, o.second);
-      } else {
-        return Status::InvalidArgument("Unrecognized option: " + o.first);
+    auto error_message = ParseBlockBasedTableOption(
+        o.first, o.second, new_table_options, input_strings_escaped);
+    if (error_message != "") {
+      const auto iter = block_based_table_type_info.find(o.first);
+      if (iter == block_based_table_type_info.end() ||
+          !input_strings_escaped ||  // !input_strings_escaped indicates
+                                     // the old API, where everything is
+                                     // parsable.
+          (iter->second.verification != OptionVerificationType::kByName &&
+           iter->second.verification != OptionVerificationType::kDeprecated)) {
+        return Status::InvalidArgument("Can't parse BlockBasedTableOptions:",
+                                       o.first + " " + error_message);
       }
-    } catch (std::exception& e) {
-      return Status::InvalidArgument("error parsing " + o.first + ":" +
-                                     std::string(e.what()));
     }
   }
   return Status::OK();
@@ -990,60 +1107,145 @@ Status GetBlockBasedTableOptionsFromString(
 Status GetPlainTableOptionsFromMap(
     const PlainTableOptions& table_options,
     const std::unordered_map<std::string, std::string>& opts_map,
-    PlainTableOptions* new_table_options) {
+    PlainTableOptions* new_table_options, bool input_strings_escaped) {
   assert(new_table_options);
   *new_table_options = table_options;
-
   for (const auto& o : opts_map) {
-    try {
-      if (o.first == "user_key_len") {
-        new_table_options->user_key_len = ParseUint32(o.second);
-      } else if (o.first == "bloom_bits_per_key") {
-        new_table_options->bloom_bits_per_key = ParseInt(o.second);
-      } else if (o.first == "hash_table_ratio") {
-        new_table_options->hash_table_ratio = ParseDouble(o.second);
-      } else if (o.first == "index_sparseness") {
-        new_table_options->index_sparseness = ParseSizeT(o.second);
-      } else if (o.first == "huge_page_tlb_size") {
-        new_table_options->huge_page_tlb_size = ParseSizeT(o.second);
-      } else if (o.first == "encoding_type") {
-        if (o.second == "kPlain") {
-          new_table_options->encoding_type = kPlain;
-        } else if (o.second == "kPrefix") {
-          new_table_options->encoding_type = kPrefix;
-        } else {
-          throw std::invalid_argument("Unknown encoding_type: " + o.second);
-        }
-      } else if (o.first == "full_scan_mode") {
-        new_table_options->full_scan_mode = ParseBoolean(o.first, o.second);
-      } else if (o.first == "store_index_in_file") {
-        new_table_options->store_index_in_file =
-            ParseBoolean(o.first, o.second);
-      } else {
-        return Status::InvalidArgument("Unrecognized option: " + o.first);
+    auto error_message = ParsePlainTableOptions(
+        o.first, o.second, new_table_options, input_strings_escaped);
+    if (error_message != "") {
+      const auto iter = plain_table_type_info.find(o.first);
+      if (iter == plain_table_type_info.end() ||
+          !input_strings_escaped ||// !input_strings_escaped indicates
+                                   // the old API, where everything is
+                                   // parsable.
+          (iter->second.verification != OptionVerificationType::kByName &&
+           iter->second.verification != OptionVerificationType::kDeprecated)) {
+        return Status::InvalidArgument("Can't parse PlainTableOptions:",
+                                        o.first + " " + error_message);
       }
-    } catch (std::exception& e) {
-      return Status::InvalidArgument("error parsing " + o.first + ":" +
-                                     std::string(e.what()));
     }
   }
   return Status::OK();
 }
 
+Status GetPlainTableOptionsFromString(
+    const PlainTableOptions& table_options,
+    const std::string& opts_str,
+    PlainTableOptions* new_table_options) {
+  std::unordered_map<std::string, std::string> opts_map;
+  Status s = StringToMap(opts_str, &opts_map);
+  if (!s.ok()) {
+    return s;
+  }
+  return GetPlainTableOptionsFromMap(table_options, opts_map,
+                                     new_table_options);
+}
+
+Status GetMemTableRepFactoryFromString(const std::string& opts_str,
+    std::unique_ptr<MemTableRepFactory>* new_mem_factory) {
+  std::vector<std::string> opts_list = StringSplit(opts_str, ':');
+  size_t len = opts_list.size();
+
+  if (opts_list.size() <= 0 || opts_list.size() > 2) {
+    return Status::InvalidArgument("Can't parse memtable_factory option ",
+                                     opts_str);
+  }
+
+  MemTableRepFactory* mem_factory = nullptr;
+
+  if (opts_list[0] == "skip_list") {
+    // Expecting format
+    // skip_list:<lookahead>
+    if (2 == len) {
+      size_t lookahead = ParseSizeT(opts_list[1]);
+      mem_factory = new SkipListFactory(lookahead);
+    } else if (1 == len) {
+      mem_factory = new SkipListFactory();
+    }
+  } else if (opts_list[0] == "prefix_hash") {
+    // Expecting format
+    // prfix_hash:<hash_bucket_count>
+    if (2 == len) {
+      size_t hash_bucket_count = ParseSizeT(opts_list[1]);
+      mem_factory = NewHashSkipListRepFactory(hash_bucket_count);
+    } else if (1 == len) {
+      mem_factory = NewHashSkipListRepFactory();
+    }
+  } else if (opts_list[0] == "hash_linkedlist") {
+    // Expecting format
+    // hash_linkedlist:<hash_bucket_count>
+    if (2 == len) {
+      size_t hash_bucket_count = ParseSizeT(opts_list[1]);
+      mem_factory = NewHashLinkListRepFactory(hash_bucket_count);
+    } else if (1 == len) {
+      mem_factory = NewHashLinkListRepFactory();
+    }
+  } else if (opts_list[0] == "vector") {
+    // Expecting format
+    // vector:<count>
+    if (2 == len) {
+      size_t count = ParseSizeT(opts_list[1]);
+      mem_factory = new VectorRepFactory(count);
+    } else if (1 == len) {
+      mem_factory = new VectorRepFactory();
+    }
+  } else if (opts_list[0] == "cuckoo") {
+    // Expecting format
+    // cuckoo:<write_buffer_size>
+    if (2 == len) {
+      size_t write_buffer_size = ParseSizeT(opts_list[1]);
+      mem_factory= NewHashCuckooRepFactory(write_buffer_size);
+    } else if (1 == len) {
+      return Status::InvalidArgument("Can't parse memtable_factory option ",
+                                     opts_str);
+    }
+  } else {
+    return Status::InvalidArgument("Unrecognized memtable_factory option ",
+                                   opts_str);
+  }
+
+  if (mem_factory != nullptr){
+    new_mem_factory->reset(mem_factory);
+  }
+
+  return Status::OK();
+}
+
 Status GetColumnFamilyOptionsFromMap(
     const ColumnFamilyOptions& base_options,
     const std::unordered_map<std::string, std::string>& opts_map,
     ColumnFamilyOptions* new_options, bool input_strings_escaped) {
+  return GetColumnFamilyOptionsFromMapInternal(
+      base_options, opts_map, new_options, input_strings_escaped);
+}
+
+Status GetColumnFamilyOptionsFromMapInternal(
+    const ColumnFamilyOptions& base_options,
+    const std::unordered_map<std::string, std::string>& opts_map,
+    ColumnFamilyOptions* new_options, bool input_strings_escaped,
+    std::vector<std::string>* unsupported_options_names) {
   assert(new_options);
   *new_options = base_options;
+  if (unsupported_options_names) {
+    unsupported_options_names->clear();
+  }
   for (const auto& o : opts_map) {
-    if (!ParseColumnFamilyOption(o.first, o.second, new_options,
-                                 input_strings_escaped)) {
-      auto iter = cf_options_type_info.find(o.first);
-      if (iter == cf_options_type_info.end() ||
-          (iter->second.verification != OptionVerificationType::kByName &&
-           iter->second.verification != OptionVerificationType::kDeprecated)) {
-        return Status::InvalidArgument("Can't parse option " + o.first);
+    auto s = ParseColumnFamilyOption(o.first, o.second, new_options,
+                                 input_strings_escaped);
+    if (!s.ok()) {
+      if (s.IsNotSupported()) {
+        // If the deserialization of the specified option is not supported
+        // and an output vector of unsupported_options is provided, then
+        // we log the name of the unsupported option and proceed.
+        if (unsupported_options_names != nullptr) {
+          unsupported_options_names->push_back(o.first);
+        }
+        // Note that we still return Status::OK in such case to maintain
+        // the backward compatibility in the old public API defined in
+        // rocksdb/convenience.h
+      } else {
+        return s;
       }
     }
   }
@@ -1066,13 +1268,37 @@ Status GetDBOptionsFromMap(
     const DBOptions& base_options,
     const std::unordered_map<std::string, std::string>& opts_map,
     DBOptions* new_options, bool input_strings_escaped) {
+  return GetDBOptionsFromMapInternal(
+      base_options, opts_map, new_options, input_strings_escaped);
+}
+
+Status GetDBOptionsFromMapInternal(
+    const DBOptions& base_options,
+    const std::unordered_map<std::string, std::string>& opts_map,
+    DBOptions* new_options, bool input_strings_escaped,
+    std::vector<std::string>* unsupported_options_names) {
   assert(new_options);
   *new_options = base_options;
+  if (unsupported_options_names) {
+    unsupported_options_names->clear();
+  }
   for (const auto& o : opts_map) {
-    if (!ParseDBOption(o.first, o.second, new_options, input_strings_escaped)) {
-      // Note that options with kDeprecated validation will pass ParseDBOption
-      // and will not hit the below statement.
-      return Status::InvalidArgument("Can't parse option " + o.first);
+    auto s = ParseDBOption(o.first, o.second,
+                           new_options, input_strings_escaped);
+    if (!s.ok()) {
+      if (s.IsNotSupported()) {
+        // If the deserialization of the specified option is not supported
+        // and an output vector of unsupported_options is provided, then
+        // we log the name of the unsupported option and proceed.
+        if (unsupported_options_names != nullptr) {
+          unsupported_options_names->push_back(o.first);
+        }
+        // Note that we still return Status::OK in such case to maintain
+        // the backward compatibility in the old public API defined in
+        // rocksdb/convenience.h
+      } else {
+        return s;
+      }
     }
   }
   return Status::OK();
@@ -1100,8 +1326,9 @@ Status GetOptionsFromString(const Options& base_options,
   DBOptions new_db_options(base_options);
   ColumnFamilyOptions new_cf_options(base_options);
   for (const auto& o : opts_map) {
-    if (ParseDBOption(o.first, o.second, &new_db_options)) {
-    } else if (ParseColumnFamilyOption(o.first, o.second, &new_cf_options)) {
+    if (ParseDBOption(o.first, o.second, &new_db_options).ok()) {
+    } else if (ParseColumnFamilyOption(
+        o.first, o.second, &new_cf_options).ok()) {
     } else {
       return Status::InvalidArgument("Can't parse option " + o.first);
     }
@@ -1110,5 +1337,100 @@ Status GetOptionsFromString(const Options& base_options,
   return Status::OK();
 }
 
+Status GetTableFactoryFromMap(
+    const std::string& factory_name,
+    const std::unordered_map<std::string, std::string>& opt_map,
+    std::shared_ptr<TableFactory>* table_factory) {
+  Status s;
+  if (factory_name == BlockBasedTableFactory().Name()) {
+    BlockBasedTableOptions bbt_opt;
+    s = GetBlockBasedTableOptionsFromMap(BlockBasedTableOptions(), opt_map,
+                                         &bbt_opt, true);
+    if (!s.ok()) {
+      return s;
+    }
+    table_factory->reset(new BlockBasedTableFactory(bbt_opt));
+    return Status::OK();
+  } else if (factory_name == PlainTableFactory().Name()) {
+    PlainTableOptions pt_opt;
+    s = GetPlainTableOptionsFromMap(PlainTableOptions(), opt_map, &pt_opt,
+                                    true);
+    if (!s.ok()) {
+      return s;
+    }
+    table_factory->reset(new PlainTableFactory(pt_opt));
+    return Status::OK();
+  }
+  // Return OK for not supported table factories as TableFactory
+  // Deserialization is optional.
+  table_factory->reset();
+  return Status::OK();
+}
+
+ColumnFamilyOptions BuildColumnFamilyOptions(
+    const Options& options, const MutableCFOptions& mutable_cf_options) {
+  ColumnFamilyOptions cf_opts(options);
+
+  // Memtable related options
+  cf_opts.write_buffer_size = mutable_cf_options.write_buffer_size;
+  cf_opts.max_write_buffer_number = mutable_cf_options.max_write_buffer_number;
+  cf_opts.arena_block_size = mutable_cf_options.arena_block_size;
+  cf_opts.memtable_prefix_bloom_bits =
+      mutable_cf_options.memtable_prefix_bloom_bits;
+  cf_opts.memtable_prefix_bloom_probes =
+      mutable_cf_options.memtable_prefix_bloom_probes;
+  cf_opts.memtable_prefix_bloom_huge_page_tlb_size =
+      mutable_cf_options.memtable_prefix_bloom_huge_page_tlb_size;
+  cf_opts.max_successive_merges = mutable_cf_options.max_successive_merges;
+  cf_opts.filter_deletes = mutable_cf_options.filter_deletes;
+  cf_opts.inplace_update_num_locks =
+      mutable_cf_options.inplace_update_num_locks;
+
+  // Compaction related options
+  cf_opts.disable_auto_compactions =
+      mutable_cf_options.disable_auto_compactions;
+  cf_opts.level0_file_num_compaction_trigger =
+      mutable_cf_options.level0_file_num_compaction_trigger;
+  cf_opts.level0_slowdown_writes_trigger =
+      mutable_cf_options.level0_slowdown_writes_trigger;
+  cf_opts.level0_stop_writes_trigger =
+      mutable_cf_options.level0_stop_writes_trigger;
+  cf_opts.max_grandparent_overlap_factor =
+      mutable_cf_options.max_grandparent_overlap_factor;
+  cf_opts.expanded_compaction_factor =
+      mutable_cf_options.expanded_compaction_factor;
+  cf_opts.source_compaction_factor =
+      mutable_cf_options.source_compaction_factor;
+  cf_opts.target_file_size_base = mutable_cf_options.target_file_size_base;
+  cf_opts.target_file_size_multiplier =
+      mutable_cf_options.target_file_size_multiplier;
+  cf_opts.max_bytes_for_level_base =
+      mutable_cf_options.max_bytes_for_level_base;
+  cf_opts.max_bytes_for_level_multiplier =
+      mutable_cf_options.max_bytes_for_level_multiplier;
+
+  cf_opts.max_bytes_for_level_multiplier_additional.clear();
+  for (auto value :
+       mutable_cf_options.max_bytes_for_level_multiplier_additional) {
+    cf_opts.max_bytes_for_level_multiplier_additional.emplace_back(value);
+  }
+
+  cf_opts.verify_checksums_in_compaction =
+      mutable_cf_options.verify_checksums_in_compaction;
+
+  // Misc options
+  cf_opts.max_sequential_skip_in_iterations =
+      mutable_cf_options.max_sequential_skip_in_iterations;
+  cf_opts.paranoid_file_checks = mutable_cf_options.paranoid_file_checks;
+  cf_opts.compaction_measure_io_stats =
+      mutable_cf_options.compaction_measure_io_stats;
+
+  cf_opts.table_factory = options.table_factory;
+  // TODO(yhchiang): find some way to handle the following derived options
+  // * max_file_size
+
+  return cf_opts;
+}
+
 #endif  // !ROCKSDB_LITE
 }  // namespace rocksdb
diff --git a/src/rocksdb/util/options_helper.h b/src/rocksdb/util/options_helper.h
index d72a375..84d547c 100644
--- a/src/rocksdb/util/options_helper.h
+++ b/src/rocksdb/util/options_helper.h
@@ -7,8 +7,11 @@
 
 #include <string>
 #include <stdexcept>
+#include <vector>
+
 #include "rocksdb/options.h"
 #include "rocksdb/status.h"
+#include "rocksdb/table.h"
 #include "util/mutable_cf_options.h"
 
 #ifndef ROCKSDB_LITE
@@ -55,6 +58,17 @@ Status GetMutableOptionsFromStrings(
     const std::unordered_map<std::string, std::string>& options_map,
     MutableCFOptions* new_options);
 
+Status GetTableFactoryFromMap(
+    const std::string& factory_name,
+    const std::unordered_map<std::string, std::string>& opt_map,
+    std::shared_ptr<TableFactory>* table_factory);
+
+Status GetStringFromTableFactory(std::string* opts_str, const TableFactory* tf,
+                                 const std::string& delimiter = ";  ");
+
+ColumnFamilyOptions BuildColumnFamilyOptions(
+    const Options& options, const MutableCFOptions& mutable_cf_options);
+
 enum class OptionType {
   kBoolean,
   kInt,
@@ -74,6 +88,11 @@ enum class OptionType {
   kCompactionFilterFactory,
   kMergeOperator,
   kMemTableRepFactory,
+  kBlockBasedTableIndexType,
+  kFilterPolicy,
+  kFlushBlockPolicyFactory,
+  kChecksumType,
+  kEncodingType,
   kUnknown
 };
 
@@ -101,6 +120,24 @@ struct OptionTypeInfo {
 bool SerializeSingleOptionHelper(const char* opt_address,
                                  const OptionType opt_type, std::string* value);
 
+// In addition to its public version defined in rocksdb/convenience.h,
+// this further takes an optional output vector "unsupported_options_names",
+// which stores the name of all the unsupported options specified in "opts_map".
+Status GetDBOptionsFromMapInternal(
+    const DBOptions& base_options,
+    const std::unordered_map<std::string, std::string>& opts_map,
+    DBOptions* new_options, bool input_strings_escaped,
+    std::vector<std::string>* unsupported_options_names = nullptr);
+
+// In addition to its public version defined in rocksdb/convenience.h,
+// this further takes an optional output vector "unsupported_options_names",
+// which stores the name of all the unsupported options specified in "opts_map".
+Status GetColumnFamilyOptionsFromMapInternal(
+    const ColumnFamilyOptions& base_options,
+    const std::unordered_map<std::string, std::string>& opts_map,
+    ColumnFamilyOptions* new_options, bool input_strings_escaped,
+    std::vector<std::string>* unsupported_options_names = nullptr);
+
 static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
     /*
      // not yet supported
@@ -167,6 +204,12 @@ static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
     {"compaction_readahead_size",
      {offsetof(struct DBOptions, compaction_readahead_size), OptionType::kSizeT,
       OptionVerificationType::kNormal}},
+    {"random_access_max_buffer_size",
+     {offsetof(struct DBOptions, random_access_max_buffer_size),
+      OptionType::kSizeT, OptionVerificationType::kNormal}},
+    {"writable_file_max_buffer_size",
+     {offsetof(struct DBOptions, writable_file_max_buffer_size),  
+      OptionType::kSizeT, OptionVerificationType::kNormal}},
     {"use_adaptive_mutex",
      {offsetof(struct DBOptions, use_adaptive_mutex), OptionType::kBoolean,
       OptionVerificationType::kNormal}},
@@ -194,6 +237,9 @@ static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
     {"keep_log_file_num",
      {offsetof(struct DBOptions, keep_log_file_num), OptionType::kSizeT,
       OptionVerificationType::kNormal}},
+    {"recycle_log_file_num",
+     {offsetof(struct DBOptions, recycle_log_file_num), OptionType::kSizeT,
+      OptionVerificationType::kNormal}},
     {"log_file_time_to_roll",
      {offsetof(struct DBOptions, log_file_time_to_roll), OptionType::kSizeT,
       OptionVerificationType::kNormal}},
@@ -282,6 +328,9 @@ static std::unordered_map<std::string, OptionTypeInfo> cf_options_type_info = {
     {"verify_checksums_in_compaction",
      {offsetof(struct ColumnFamilyOptions, verify_checksums_in_compaction),
       OptionType::kBoolean, OptionVerificationType::kNormal}},
+    {"soft_pending_compaction_bytes_limit",
+     {offsetof(struct ColumnFamilyOptions, soft_pending_compaction_bytes_limit),
+      OptionType::kUInt64T, OptionVerificationType::kNormal}},
     {"hard_pending_compaction_bytes_limit",
      {offsetof(struct ColumnFamilyOptions, hard_pending_compaction_bytes_limit),
       OptionType::kUInt64T, OptionVerificationType::kNormal}},
@@ -401,6 +450,106 @@ static std::unordered_map<std::string, OptionTypeInfo> cf_options_type_info = {
      {offsetof(struct ColumnFamilyOptions, compaction_style),
       OptionType::kCompactionStyle, OptionVerificationType::kNormal}}};
 
+static std::unordered_map<std::string,
+                          OptionTypeInfo> block_based_table_type_info = {
+    /* currently not supported
+      std::shared_ptr<Cache> block_cache = nullptr;
+      std::shared_ptr<Cache> block_cache_compressed = nullptr;
+     */
+    {"flush_block_policy_factory",
+     {offsetof(struct BlockBasedTableOptions, flush_block_policy_factory),
+      OptionType::kFlushBlockPolicyFactory, OptionVerificationType::kByName}},
+    {"cache_index_and_filter_blocks",
+     {offsetof(struct BlockBasedTableOptions, cache_index_and_filter_blocks),
+      OptionType::kBoolean, OptionVerificationType::kNormal}},
+    {"index_type",
+     {offsetof(struct BlockBasedTableOptions, index_type),
+      OptionType::kBlockBasedTableIndexType, OptionVerificationType::kNormal}},
+    {"hash_index_allow_collision",
+     {offsetof(struct BlockBasedTableOptions, hash_index_allow_collision),
+      OptionType::kBoolean, OptionVerificationType::kNormal}},
+    {"checksum",
+     {offsetof(struct BlockBasedTableOptions, checksum),
+      OptionType::kChecksumType, OptionVerificationType::kNormal}},
+    {"no_block_cache",
+     {offsetof(struct BlockBasedTableOptions, no_block_cache),
+      OptionType::kBoolean, OptionVerificationType::kNormal}},
+    {"block_size",
+     {offsetof(struct BlockBasedTableOptions, block_size), OptionType::kSizeT,
+      OptionVerificationType::kNormal}},
+    {"block_size_deviation",
+     {offsetof(struct BlockBasedTableOptions, block_size_deviation),
+      OptionType::kInt, OptionVerificationType::kNormal}},
+    {"block_restart_interval",
+     {offsetof(struct BlockBasedTableOptions, block_restart_interval),
+      OptionType::kInt, OptionVerificationType::kNormal}},
+    {"filter_policy",
+     {offsetof(struct BlockBasedTableOptions, filter_policy),
+      OptionType::kFilterPolicy, OptionVerificationType::kByName}},
+    {"whole_key_filtering",
+     {offsetof(struct BlockBasedTableOptions, whole_key_filtering),
+      OptionType::kBoolean, OptionVerificationType::kNormal}},
+    {"skip_table_builder_flush",
+     {offsetof(struct BlockBasedTableOptions, skip_table_builder_flush),  
+      OptionType::kBoolean, OptionVerificationType::kNormal}},
+    {"format_version",
+     {offsetof(struct BlockBasedTableOptions, format_version),
+      OptionType::kUInt32T, OptionVerificationType::kNormal}}};
+
+static std::unordered_map<std::string, OptionTypeInfo> plain_table_type_info = {
+    {"user_key_len",
+     {offsetof(struct PlainTableOptions, user_key_len), OptionType::kUInt32T,
+      OptionVerificationType::kNormal}},
+    {"bloom_bits_per_key",
+     {offsetof(struct PlainTableOptions, bloom_bits_per_key), OptionType::kInt,
+      OptionVerificationType::kNormal}},
+    {"hash_table_ratio",
+     {offsetof(struct PlainTableOptions, hash_table_ratio), OptionType::kDouble,
+      OptionVerificationType::kNormal}},
+    {"index_sparseness",
+     {offsetof(struct PlainTableOptions, index_sparseness), OptionType::kSizeT,
+      OptionVerificationType::kNormal}},
+    {"huge_page_tlb_size",
+     {offsetof(struct PlainTableOptions, huge_page_tlb_size),
+      OptionType::kSizeT, OptionVerificationType::kNormal}},
+    {"encoding_type",
+     {offsetof(struct PlainTableOptions, encoding_type),
+      OptionType::kEncodingType, OptionVerificationType::kByName}},
+    {"full_scan_mode",
+     {offsetof(struct PlainTableOptions, full_scan_mode), OptionType::kBoolean,
+      OptionVerificationType::kNormal}},
+    {"store_index_in_file",
+     {offsetof(struct PlainTableOptions, store_index_in_file),
+      OptionType::kBoolean, OptionVerificationType::kNormal}}};
+
+static std::unordered_map<std::string, CompressionType>
+    compression_type_string_map = {
+        {"kNoCompression", kNoCompression},
+        {"kSnappyCompression", kSnappyCompression},
+        {"kZlibCompression", kZlibCompression},
+        {"kBZip2Compression", kBZip2Compression},
+        {"kLZ4Compression", kLZ4Compression},
+        {"kLZ4HCCompression", kLZ4HCCompression},
+        {"kZSTDNotFinalCompression", kZSTDNotFinalCompression}};
+
+static std::unordered_map<std::string, BlockBasedTableOptions::IndexType>
+    block_base_table_index_type_string_map = {
+        {"kBinarySearch", BlockBasedTableOptions::IndexType::kBinarySearch},
+        {"kHashSearch", BlockBasedTableOptions::IndexType::kHashSearch}};
+
+static std::unordered_map<std::string, EncodingType> encoding_type_string_map =
+    {{"kPlain", kPlain}, {"kPrefix", kPrefix}};
+
+static std::unordered_map<std::string, ChecksumType> checksum_type_string_map =
+    {{"kNoChecksum", kNoChecksum}, {"kCRC32c", kCRC32c}, {"kxxHash", kxxHash}};
+
+static std::unordered_map<std::string, CompactionStyle>
+    compaction_style_string_map = {
+        {"kCompactionStyleLevel", kCompactionStyleLevel},
+        {"kCompactionStyleUniversal", kCompactionStyleUniversal},
+        {"kCompactionStyleFIFO", kCompactionStyleFIFO},
+        {"kCompactionStyleNone", kCompactionStyleNone}};
+
 }  // namespace rocksdb
 
 #endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/util/options_parser.cc b/src/rocksdb/util/options_parser.cc
index d792554..20ae51e 100644
--- a/src/rocksdb/util/options_parser.cc
+++ b/src/rocksdb/util/options_parser.cc
@@ -17,6 +17,7 @@
 #include "rocksdb/db.h"
 #include "util/options_helper.h"
 #include "util/string_util.h"
+#include "util/sync_point.h"
 
 #include "port/port.h"
 
@@ -34,6 +35,7 @@ Status PersistRocksDBOptions(const DBOptions& db_opt,
                              const std::vector<std::string>& cf_names,
                              const std::vector<ColumnFamilyOptions>& cf_opts,
                              const std::string& file_name, Env* env) {
+  TEST_SYNC_POINT("PersistRocksDBOptions:start");
   if (cf_names.size() != cf_opts.size()) {
     return Status::InvalidArgument(
         "cf_names.size() and cf_opts.size() must be the same");
@@ -66,6 +68,7 @@ Status PersistRocksDBOptions(const DBOptions& db_opt,
   writable->Append(options_file_content + "\n");
 
   for (size_t i = 0; i < cf_opts.size(); ++i) {
+    // CFOptions section
     writable->Append("\n[" + opt_section_titles[kOptionSectionCFOptions] +
                      " \"" + EscapeOptionString(cf_names[i]) + "\"]\n  ");
     s = GetStringFromColumnFamilyOptions(&options_file_content, cf_opts[i],
@@ -75,6 +78,18 @@ Status PersistRocksDBOptions(const DBOptions& db_opt,
       return s;
     }
     writable->Append(options_file_content + "\n");
+    // TableOptions section
+    auto* tf = cf_opts[i].table_factory.get();
+    if (tf != nullptr) {
+      writable->Append("[" + opt_section_titles[kOptionSectionTableOptions] +
+                       tf->Name() + " \"" + EscapeOptionString(cf_names[i]) +
+                       "\"]\n  ");
+      s = GetStringFromTableFactory(&options_file_content, tf, "\n  ");
+      if (!s.ok()) {
+        return s;
+      }
+      writable->Append(options_file_content + "\n");
+    }
   }
   writable->Flush();
   writable->Fsync();
@@ -112,11 +127,11 @@ bool RocksDBOptionsParser::IsSection(const std::string& line) {
 }
 
 Status RocksDBOptionsParser::ParseSection(OptionSection* section,
+                                          std::string* title,
                                           std::string* argument,
                                           const std::string& line,
                                           const int line_num) {
   *section = kOptionSectionUnknown;
-  std::string sec_string;
   // A section is of the form [<SectionName> "<SectionArg>"], where
   // "<SectionArg>" is optional.
   size_t arg_start_pos = line.find("\"");
@@ -124,17 +139,30 @@ Status RocksDBOptionsParser::ParseSection(OptionSection* section,
   // The following if-then check tries to identify whether the input
   // section has the optional section argument.
   if (arg_start_pos != std::string::npos && arg_start_pos != arg_end_pos) {
-    sec_string = TrimAndRemoveComment(line.substr(1, arg_start_pos - 1), true);
+    *title = TrimAndRemoveComment(line.substr(1, arg_start_pos - 1), true);
     *argument = UnescapeOptionString(
         line.substr(arg_start_pos + 1, arg_end_pos - arg_start_pos - 1));
   } else {
-    sec_string = TrimAndRemoveComment(line.substr(1, line.size() - 2), true);
+    *title = TrimAndRemoveComment(line.substr(1, line.size() - 2), true);
     *argument = "";
   }
   for (int i = 0; i < kOptionSectionUnknown; ++i) {
-    if (opt_section_titles[i] == sec_string) {
-      *section = static_cast<OptionSection>(i);
-      return CheckSection(*section, *argument, line_num);
+    if (title->find(opt_section_titles[i]) == 0) {
+      if (i == kOptionSectionVersion || i == kOptionSectionDBOptions ||
+          i == kOptionSectionCFOptions) {
+        if (title->size() == opt_section_titles[i].size()) {
+          // if true, then it indicats equal
+          *section = static_cast<OptionSection>(i);
+          return CheckSection(*section, *argument, line_num);
+        }
+      } else if (i == kOptionSectionTableOptions) {
+        // This type of sections has a sufffix at the end of the
+        // section title
+        if (title->size() > opt_section_titles[i].size()) {
+          *section = static_cast<OptionSection>(i);
+          return CheckSection(*section, *argument, line_num);
+        }
+      }
     }
   }
   return Status::InvalidArgument(std::string("Unknown section ") + line);
@@ -215,6 +243,7 @@ Status RocksDBOptionsParser::Parse(const std::string& file_name, Env* env) {
   }
 
   OptionSection section = kOptionSectionUnknown;
+  std::string title;
   std::string argument;
   std::unordered_map<std::string, std::string> opt_map;
   std::istringstream iss;
@@ -231,12 +260,12 @@ Status RocksDBOptionsParser::Parse(const std::string& file_name, Env* env) {
       continue;
     }
     if (IsSection(line)) {
-      s = EndSection(section, argument, opt_map);
+      s = EndSection(section, title, argument, opt_map);
       opt_map.clear();
       if (!s.ok()) {
         return s;
       }
-      s = ParseSection(&section, &argument, line, line_num);
+      s = ParseSection(&section, &title, &argument, line, line_num);
       if (!s.ok()) {
         return s;
       }
@@ -251,7 +280,7 @@ Status RocksDBOptionsParser::Parse(const std::string& file_name, Env* env) {
     }
   }
 
-  s = EndSection(section, argument, opt_map);
+  s = EndSection(section, title, argument, opt_map);
   opt_map.clear();
   if (!s.ok()) {
     return s;
@@ -280,13 +309,21 @@ Status RocksDBOptionsParser::CheckSection(const OptionSection section,
       return InvalidArgument(
           line_num,
           "Default column family must be the first CFOptions section "
-          "in the option config file");
+          "in the optio/n config file");
     } else if (GetCFOptions(section_arg) != nullptr) {
       return InvalidArgument(
           line_num,
           "Two identical column families found in option config file");
     }
     has_default_cf_options_ |= is_default_cf;
+  } else if (section == kOptionSectionTableOptions) {
+    if (GetCFOptions(section_arg) == nullptr) {
+      return InvalidArgument(
+          line_num, std::string(
+                        "Does not find a matched column family name in "
+                        "TableOptions section.  Column Family Name:") +
+                        section_arg);
+    }
   } else if (section == kOptionSectionVersion) {
     if (has_version_section_) {
       return InvalidArgument(
@@ -350,7 +387,8 @@ Status RocksDBOptionsParser::ParseVersionNumber(const std::string& ver_name,
 }
 
 Status RocksDBOptionsParser::EndSection(
-    const OptionSection section, const std::string& section_arg,
+    const OptionSection section, const std::string& section_title,
+    const std::string& section_arg,
     const std::unordered_map<std::string, std::string>& opt_map) {
   Status s;
   if (section == kOptionSectionDBOptions) {
@@ -372,6 +410,23 @@ Status RocksDBOptionsParser::EndSection(
     }
     // keep the parsed string.
     cf_opt_maps_.emplace_back(opt_map);
+  } else if (section == kOptionSectionTableOptions) {
+    assert(GetCFOptions(section_arg) != nullptr);
+    auto* cf_opt = GetCFOptionsImpl(section_arg);
+    if (cf_opt == nullptr) {
+      return Status::InvalidArgument(
+          "The specified column family must be defined before the "
+          "TableOptions section:",
+          section_arg);
+    }
+    // Ignore error as table factory deserialization is optional
+    s = GetTableFactoryFromMap(
+        section_title.substr(
+            opt_section_titles[kOptionSectionTableOptions].size()),
+        opt_map, &(cf_opt->table_factory));
+    if (!s.ok()) {
+      return s;
+    }
   } else if (section == kOptionSectionVersion) {
     for (const auto pair : opt_map) {
       if (pair.first == "rocksdb_version") {
@@ -493,6 +548,14 @@ bool AreEqualOptions(
           reinterpret_cast<const std::vector<CompressionType>*>(offset2);
       return (*vec1 == *vec2);
     }
+    case OptionType::kChecksumType:
+      return (*reinterpret_cast<const ChecksumType*>(offset1) ==
+              *reinterpret_cast<const ChecksumType*>(offset2));
+    case OptionType::kBlockBasedTableIndexType:
+      return (
+          *reinterpret_cast<const BlockBasedTableOptions::IndexType*>(
+              offset1) ==
+          *reinterpret_cast<const BlockBasedTableOptions::IndexType*>(offset2));
     default:
       if (type_info.verification == OptionVerificationType::kByName) {
         std::string value1;
@@ -520,7 +583,8 @@ bool AreEqualOptions(
 Status RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
     const DBOptions& db_opt, const std::vector<std::string>& cf_names,
     const std::vector<ColumnFamilyOptions>& cf_opts,
-    const std::string& file_name, Env* env) {
+    const std::string& file_name, Env* env,
+    OptionsSanityCheckLevel sanity_check_level) {
   RocksDBOptionsParser parser;
   std::unique_ptr<SequentialFile> seq_file;
   Status s = parser.Parse(file_name, env);
@@ -529,20 +593,28 @@ Status RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
   }
 
   // Verify DBOptions
-  s = VerifyDBOptions(db_opt, *parser.db_opt(), parser.db_opt_map());
+  s = VerifyDBOptions(db_opt, *parser.db_opt(), parser.db_opt_map(),
+                      sanity_check_level);
   if (!s.ok()) {
     return s;
   }
 
   // Verify ColumnFamily Name
   if (cf_names.size() != parser.cf_names()->size()) {
-    return Status::Corruption(
-        "[RocksDBOptionParser Error] The persisted options does not have"
-        "the same number of column family names as the db instance.");
+    if (sanity_check_level >= kSanityLevelLooselyCompatible) {
+      return Status::InvalidArgument(
+          "[RocksDBOptionParser Error] The persisted options does not have "
+          "the same number of column family names as the db instance.");
+    } else if (cf_opts.size() > parser.cf_opts()->size()) {
+      return Status::InvalidArgument(
+          "[RocksDBOptionsParser Error]",
+          "The persisted options file has less number of column family "
+          "names than that of the specified one.");
+    }
   }
   for (size_t i = 0; i < cf_names.size(); ++i) {
     if (cf_names[i] != parser.cf_names()->at(i)) {
-      return Status::Corruption(
+      return Status::InvalidArgument(
           "[RocksDBOptionParser Error] The persisted options and the db"
           "instance does not have the same name for column family ",
           ToString(i));
@@ -551,13 +623,27 @@ Status RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
 
   // Verify Column Family Options
   if (cf_opts.size() != parser.cf_opts()->size()) {
-    return Status::Corruption(
-        "[RocksDBOptionParser Error] The persisted options does not have"
-        "the same number of column families as the db instance.");
+    if (sanity_check_level >= kSanityLevelLooselyCompatible) {
+      return Status::InvalidArgument(
+          "[RocksDBOptionsParser Error]",
+          "The persisted options does not have the same number of "
+          "column families as the db instance.");
+    } else if (cf_opts.size() > parser.cf_opts()->size()) {
+      return Status::InvalidArgument(
+          "[RocksDBOptionsParser Error]",
+          "The persisted options file has less number of column families "
+          "than that of the specified number.");
+    }
   }
   for (size_t i = 0; i < cf_opts.size(); ++i) {
     s = VerifyCFOptions(cf_opts[i], parser.cf_opts()->at(i),
-                        &(parser.cf_opt_maps()->at(i)));
+                        &(parser.cf_opt_maps()->at(i)), sanity_check_level);
+    if (!s.ok()) {
+      return s;
+    }
+    s = VerifyTableFactory(cf_opts[i].table_factory.get(),
+                           parser.cf_opts()->at(i).table_factory.get(),
+                           sanity_check_level);
     if (!s.ok()) {
       return s;
     }
@@ -567,43 +653,136 @@ Status RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
 }
 
 Status RocksDBOptionsParser::VerifyDBOptions(
-    const DBOptions& base_opt, const DBOptions& new_opt,
-    const std::unordered_map<std::string, std::string>* opt_map) {
+    const DBOptions& base_opt, const DBOptions& persisted_opt,
+    const std::unordered_map<std::string, std::string>* opt_map,
+    OptionsSanityCheckLevel sanity_check_level) {
   for (auto pair : db_options_type_info) {
     if (pair.second.verification == OptionVerificationType::kDeprecated) {
       // We skip checking deprecated variables as they might
       // contain random values since they might not be initialized
       continue;
     }
-    if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
-                         reinterpret_cast<const char*>(&new_opt), pair.second,
-                         pair.first, nullptr)) {
-      return Status::Corruption(
-          "[RocksDBOptionsParser]: "
-          "failed the verification on DBOptions::",
-          pair.first);
+    if (DBOptionSanityCheckLevel(pair.first) <= sanity_check_level) {
+      if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
+                           reinterpret_cast<const char*>(&persisted_opt),
+                           pair.second, pair.first, nullptr)) {
+        const size_t kBufferSize = 2048;
+        char buffer[kBufferSize];
+        std::string base_value;
+        std::string persisted_value;
+        SerializeSingleOptionHelper(
+            reinterpret_cast<const char*>(&base_opt) + pair.second.offset,
+            pair.second.type, &base_value);
+        SerializeSingleOptionHelper(
+            reinterpret_cast<const char*>(&persisted_opt) + pair.second.offset,
+            pair.second.type, &persisted_value);
+        snprintf(buffer, sizeof(buffer),
+                 "[RocksDBOptionsParser]: "
+                 "failed the verification on DBOptions::%s --- "
+                 "The specified one is %s while the persisted one is %s.\n",
+                 pair.first.c_str(), base_value.c_str(),
+                 persisted_value.c_str());
+        return Status::InvalidArgument(Slice(buffer, strlen(buffer)));
+      }
     }
   }
   return Status::OK();
 }
 
 Status RocksDBOptionsParser::VerifyCFOptions(
-    const ColumnFamilyOptions& base_opt, const ColumnFamilyOptions& new_opt,
-    const std::unordered_map<std::string, std::string>* new_opt_map) {
+    const ColumnFamilyOptions& base_opt,
+    const ColumnFamilyOptions& persisted_opt,
+    const std::unordered_map<std::string, std::string>* persisted_opt_map,
+    OptionsSanityCheckLevel sanity_check_level) {
   for (auto& pair : cf_options_type_info) {
     if (pair.second.verification == OptionVerificationType::kDeprecated) {
       // We skip checking deprecated variables as they might
       // contain random values since they might not be initialized
       continue;
     }
-    if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
-                         reinterpret_cast<const char*>(&new_opt), pair.second,
-                         pair.first, new_opt_map)) {
+    if (CFOptionSanityCheckLevel(pair.first) <= sanity_check_level) {
+      if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
+                           reinterpret_cast<const char*>(&persisted_opt),
+                           pair.second, pair.first, persisted_opt_map)) {
+        const size_t kBufferSize = 2048;
+        char buffer[kBufferSize];
+        std::string base_value;
+        std::string persisted_value;
+        SerializeSingleOptionHelper(
+            reinterpret_cast<const char*>(&base_opt) + pair.second.offset,
+            pair.second.type, &base_value);
+        SerializeSingleOptionHelper(
+            reinterpret_cast<const char*>(&persisted_opt) + pair.second.offset,
+            pair.second.type, &persisted_value);
+        snprintf(buffer, sizeof(buffer),
+                 "[RocksDBOptionsParser]: "
+                 "failed the verification on ColumnFamilyOptions::%s --- "
+                 "The specified one is %s while the persisted one is %s.\n",
+                 pair.first.c_str(), base_value.c_str(),
+                 persisted_value.c_str());
+        return Status::InvalidArgument(Slice(buffer, sizeof(buffer)));
+      }
+    }
+  }
+  return Status::OK();
+}
+
+Status RocksDBOptionsParser::VerifyBlockBasedTableFactory(
+    const BlockBasedTableFactory* base_tf,
+    const BlockBasedTableFactory* file_tf,
+    OptionsSanityCheckLevel sanity_check_level) {
+  if ((base_tf != nullptr) != (file_tf != nullptr) &&
+      sanity_check_level > kSanityLevelNone) {
+    return Status::Corruption(
+        "[RocksDBOptionsParser]: Inconsistent TableFactory class type");
+  }
+  if (base_tf == nullptr) {
+    return Status::OK();
+  }
+
+  const auto& base_opt = base_tf->table_options();
+  const auto& file_opt = file_tf->table_options();
+
+  for (auto& pair : block_based_table_type_info) {
+    if (pair.second.verification == OptionVerificationType::kDeprecated) {
+      // We skip checking deprecated variables as they might
+      // contain random values since they might not be initialized
+      continue;
+    }
+    if (BBTOptionSanityCheckLevel(pair.first) <= sanity_check_level) {
+      if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
+                           reinterpret_cast<const char*>(&file_opt),
+                           pair.second, pair.first, nullptr)) {
+        return Status::Corruption(
+            "[RocksDBOptionsParser]: "
+            "failed the verification on BlockBasedTableOptions::",
+            pair.first);
+      }
+    }
+  }
+  return Status::OK();
+}
+
+Status RocksDBOptionsParser::VerifyTableFactory(
+    const TableFactory* base_tf, const TableFactory* file_tf,
+    OptionsSanityCheckLevel sanity_check_level) {
+  if (base_tf && file_tf) {
+    if (sanity_check_level > kSanityLevelNone &&
+        base_tf->Name() != file_tf->Name()) {
       return Status::Corruption(
           "[RocksDBOptionsParser]: "
-          "failed the verification on ColumnFamilyOptions::",
-          pair.first);
+          "failed the verification on TableFactory->Name()");
+    }
+    auto s = VerifyBlockBasedTableFactory(
+        dynamic_cast<const BlockBasedTableFactory*>(base_tf),
+        dynamic_cast<const BlockBasedTableFactory*>(file_tf),
+        sanity_check_level);
+    if (!s.ok()) {
+      return s;
     }
+    // TODO(yhchiang): add checks for other table factory types
+  } else {
+    // TODO(yhchiang): further support sanity check here
   }
   return Status::OK();
 }
diff --git a/src/rocksdb/util/options_parser.h b/src/rocksdb/util/options_parser.h
index f308fcb..94e69cc 100644
--- a/src/rocksdb/util/options_parser.h
+++ b/src/rocksdb/util/options_parser.h
@@ -11,23 +11,27 @@
 
 #include "rocksdb/env.h"
 #include "rocksdb/options.h"
+#include "util/options_helper.h"
+#include "util/options_sanity_check.h"
+#include "table/block_based_table_factory.h"
 
 namespace rocksdb {
 
 #ifndef ROCKSDB_LITE
 
 #define ROCKSDB_OPTION_FILE_MAJOR 1
-#define ROCKSDB_OPTION_FILE_MINOR 0
+#define ROCKSDB_OPTION_FILE_MINOR 1
 
 enum OptionSection : char {
   kOptionSectionVersion = 0,
   kOptionSectionDBOptions,
   kOptionSectionCFOptions,
+  kOptionSectionTableOptions,
   kOptionSectionUnknown
 };
 
-static const std::string opt_section_titles[] = {"Version", "DBOptions",
-                                                 "CFOptions", "Unknown"};
+static const std::string opt_section_titles[] = {
+    "Version", "DBOptions", "CFOptions", "TableOptions/", "Unknown"};
 
 Status PersistRocksDBOptions(const DBOptions& db_opt,
                              const std::vector<std::string>& cf_names,
@@ -55,38 +59,43 @@ class RocksDBOptionsParser {
     return &cf_opt_maps_;
   }
 
-  const ColumnFamilyOptions* GetCFOptions(const std::string& name) const {
-    assert(cf_names_.size() == cf_opts_.size());
-    for (size_t i = 0; i < cf_names_.size(); ++i) {
-      if (cf_names_[i] == name) {
-        return &cf_opts_[i];
-      }
-    }
-    return nullptr;
+  const ColumnFamilyOptions* GetCFOptions(const std::string& name) {
+    return GetCFOptionsImpl(name);
   }
   size_t NumColumnFamilies() { return cf_opts_.size(); }
 
   static Status VerifyRocksDBOptionsFromFile(
       const DBOptions& db_opt, const std::vector<std::string>& cf_names,
       const std::vector<ColumnFamilyOptions>& cf_opts,
-      const std::string& file_name, Env* env);
+      const std::string& file_name, Env* env,
+      OptionsSanityCheckLevel sanity_check_level = kSanityLevelExactMatch);
 
   static Status VerifyDBOptions(
       const DBOptions& base_opt, const DBOptions& new_opt,
-      const std::unordered_map<std::string, std::string>* new_opt_map =
-          nullptr);
+      const std::unordered_map<std::string, std::string>* new_opt_map = nullptr,
+      OptionsSanityCheckLevel sanity_check_level = kSanityLevelExactMatch);
 
   static Status VerifyCFOptions(
       const ColumnFamilyOptions& base_opt, const ColumnFamilyOptions& new_opt,
-      const std::unordered_map<std::string, std::string>* new_opt_map =
-          nullptr);
+      const std::unordered_map<std::string, std::string>* new_opt_map = nullptr,
+      OptionsSanityCheckLevel sanity_check_level = kSanityLevelExactMatch);
+
+  static Status VerifyTableFactory(
+      const TableFactory* base_tf, const TableFactory* file_tf,
+      OptionsSanityCheckLevel sanity_check_level = kSanityLevelExactMatch);
+
+  static Status VerifyBlockBasedTableFactory(
+      const BlockBasedTableFactory* base_tf,
+      const BlockBasedTableFactory* file_tf,
+      OptionsSanityCheckLevel sanity_check_level);
 
   static Status ExtraParserCheck(const RocksDBOptionsParser& input_parser);
 
  protected:
   bool IsSection(const std::string& line);
-  Status ParseSection(OptionSection* section, std::string* argument,
-                      const std::string& line, const int line_num);
+  Status ParseSection(OptionSection* section, std::string* title,
+                      std::string* argument, const std::string& line,
+                      const int line_num);
 
   Status CheckSection(const OptionSection section,
                       const std::string& section_arg, const int line_num);
@@ -95,7 +104,8 @@ class RocksDBOptionsParser {
                         const std::string& line, const int line_num);
 
   Status EndSection(
-      const OptionSection section, const std::string& section_arg,
+      const OptionSection section, const std::string& title,
+      const std::string& section_arg,
       const std::unordered_map<std::string, std::string>& opt_map);
 
   Status ValidityCheck();
@@ -106,6 +116,16 @@ class RocksDBOptionsParser {
                             const std::string& ver_string, const int max_count,
                             int* version);
 
+  ColumnFamilyOptions* GetCFOptionsImpl(const std::string& name) {
+    assert(cf_names_.size() == cf_opts_.size());
+    for (size_t i = 0; i < cf_names_.size(); ++i) {
+      if (cf_names_[i] == name) {
+        return &cf_opts_[i];
+      }
+    }
+    return nullptr;
+  }
+
  private:
   DBOptions db_opt_;
   std::unordered_map<std::string, std::string> db_opt_map_;
diff --git a/src/rocksdb/util/options_sanity_check.cc b/src/rocksdb/util/options_sanity_check.cc
new file mode 100644
index 0000000..a84031b
--- /dev/null
+++ b/src/rocksdb/util/options_sanity_check.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2014, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+
+#include "util/options_sanity_check.h"
+
+namespace rocksdb {
+
+namespace {
+OptionsSanityCheckLevel SanityCheckLevelHelper(
+    const std::unordered_map<std::string, OptionsSanityCheckLevel>& smap,
+    const std::string& name) {
+  auto iter = smap.find(name);
+  return iter != smap.end() ? iter->second : kSanityLevelExactMatch;
+}
+}
+
+OptionsSanityCheckLevel DBOptionSanityCheckLevel(
+    const std::string& option_name) {
+  return SanityCheckLevelHelper(sanity_level_db_options, option_name);
+}
+
+OptionsSanityCheckLevel CFOptionSanityCheckLevel(
+    const std::string& option_name) {
+  return SanityCheckLevelHelper(sanity_level_cf_options, option_name);
+}
+
+OptionsSanityCheckLevel BBTOptionSanityCheckLevel(
+    const std::string& option_name) {
+  return SanityCheckLevelHelper(sanity_level_bbt_options, option_name);
+}
+
+}  // namespace rocksdb
+
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/util/options_sanity_check.h b/src/rocksdb/util/options_sanity_check.h
new file mode 100644
index 0000000..83f7e38
--- /dev/null
+++ b/src/rocksdb/util/options_sanity_check.h
@@ -0,0 +1,49 @@
+// Copyright (c) 2014, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+
+#ifndef ROCKSDB_LITE
+namespace rocksdb {
+// This enum defines the RocksDB options sanity level.
+enum OptionsSanityCheckLevel : unsigned char {
+  // Performs no sanity check at all.
+  kSanityLevelNone = 0x00,
+  // Performs minimum check to ensure the RocksDB instance can be
+  // opened without corrupting / mis-interpreting the data.
+  kSanityLevelLooselyCompatible = 0x01,
+  // Perform exact match sanity check.
+  kSanityLevelExactMatch = 0xFF,
+};
+
+// The sanity check level for DB options
+static const std::unordered_map<std::string, OptionsSanityCheckLevel>
+    sanity_level_db_options;
+
+// The sanity check level for column-family options
+static const std::unordered_map<std::string, OptionsSanityCheckLevel>
+    sanity_level_cf_options = {
+        {"comparator", kSanityLevelLooselyCompatible},
+        {"prefix_extractor", kSanityLevelLooselyCompatible},
+        {"table_factory", kSanityLevelLooselyCompatible},
+        {"merge_operator", kSanityLevelLooselyCompatible}};
+
+// The sanity check level for block-based table options
+static const std::unordered_map<std::string, OptionsSanityCheckLevel>
+    sanity_level_bbt_options;
+
+OptionsSanityCheckLevel DBOptionSanityCheckLevel(
+    const std::string& options_name);
+OptionsSanityCheckLevel CFOptionSanityCheckLevel(
+    const std::string& options_name);
+OptionsSanityCheckLevel BBTOptionSanityCheckLevel(
+    const std::string& options_name);
+
+}  // namespace rocksdb
+
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/util/options_test.cc b/src/rocksdb/util/options_test.cc
index ee13540..e4b5725 100644
--- a/src/rocksdb/util/options_test.cc
+++ b/src/rocksdb/util/options_test.cc
@@ -16,15 +16,12 @@
 #include <inttypes.h>
 
 #include "rocksdb/cache.h"
-#include "rocksdb/compaction_filter.h"
 #include "rocksdb/convenience.h"
-#include "rocksdb/merge_operator.h"
-#include "rocksdb/options.h"
-#include "rocksdb/table.h"
+#include "rocksdb/memtablerep.h"
 #include "rocksdb/utilities/leveldb_options.h"
-#include "table/block_based_table_factory.h"
 #include "util/options_helper.h"
 #include "util/options_parser.h"
+#include "util/options_sanity_check.h"
 #include "util/random.h"
 #include "util/testharness.h"
 #include "util/testutil.h"
@@ -73,163 +70,6 @@ Options PrintAndGetOptions(size_t total_write_buffer_limit,
   return options;
 }
 
-class StringEnv : public EnvWrapper {
- public:
-  class SeqStringSource : public SequentialFile {
-   public:
-    explicit SeqStringSource(const std::string& data)
-        : data_(data), offset_(0) {}
-    ~SeqStringSource() {}
-    Status Read(size_t n, Slice* result, char* scratch) override {
-      std::string output;
-      if (offset_ < data_.size()) {
-        n = std::min(data_.size() - offset_, n);
-        memcpy(scratch, data_.data() + offset_, n);
-        offset_ += n;
-        *result = Slice(scratch, n);
-      } else {
-        return Status::InvalidArgument(
-            "Attemp to read when it already reached eof.");
-      }
-      return Status::OK();
-    }
-    Status Skip(uint64_t n) override {
-      if (offset_ >= data_.size()) {
-        return Status::InvalidArgument(
-            "Attemp to read when it already reached eof.");
-      }
-      // TODO(yhchiang): Currently doesn't handle the overflow case.
-      offset_ += n;
-      return Status::OK();
-    }
-
-   private:
-    std::string data_;
-    size_t offset_;
-  };
-
-  class StringSink : public WritableFile {
-   public:
-    explicit StringSink(std::string* contents)
-        : WritableFile(), contents_(contents) {}
-    virtual Status Truncate(uint64_t size) override {
-      contents_->resize(size);
-      return Status::OK();
-    }
-    virtual Status Close() override { return Status::OK(); }
-    virtual Status Flush() override { return Status::OK(); }
-    virtual Status Sync() override { return Status::OK(); }
-    virtual Status Append(const Slice& slice) override {
-      contents_->append(slice.data(), slice.size());
-      return Status::OK();
-    }
-
-   private:
-    std::string* contents_;
-  };
-
-  explicit StringEnv(Env* t) : EnvWrapper(t) {}
-  virtual ~StringEnv() {}
-
-  const std::string& GetContent(const std::string& f) { return files_[f]; }
-
-  const Status WriteToNewFile(const std::string& file_name,
-                              const std::string& content) {
-    unique_ptr<WritableFile> r;
-    auto s = NewWritableFile(file_name, &r, EnvOptions());
-    if (!s.ok()) {
-      return s;
-    }
-    r->Append(content);
-    r->Flush();
-    r->Close();
-    assert(files_[file_name] == content);
-    return Status::OK();
-  }
-
-  // The following text is boilerplate that forwards all methods to target()
-  Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
-                           const EnvOptions& options) override {
-    auto iter = files_.find(f);
-    if (iter == files_.end()) {
-      return Status::NotFound("The specified file does not exist", f);
-    }
-    r->reset(new SeqStringSource(iter->second));
-    return Status::OK();
-  }
-  Status NewRandomAccessFile(const std::string& f,
-                             unique_ptr<RandomAccessFile>* r,
-                             const EnvOptions& options) override {
-    return Status::NotSupported();
-  }
-  Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
-                         const EnvOptions& options) override {
-    auto iter = files_.find(f);
-    if (iter != files_.end()) {
-      return Status::IOError("The specified file already exists", f);
-    }
-    r->reset(new StringSink(&files_[f]));
-    return Status::OK();
-  }
-  virtual Status NewDirectory(const std::string& name,
-                              unique_ptr<Directory>* result) override {
-    return Status::NotSupported();
-  }
-  Status FileExists(const std::string& f) override {
-    if (files_.find(f) == files_.end()) {
-      return Status::NotFound();
-    }
-    return Status::OK();
-  }
-  Status GetChildren(const std::string& dir,
-                     std::vector<std::string>* r) override {
-    return Status::NotSupported();
-  }
-  Status DeleteFile(const std::string& f) override {
-    files_.erase(f);
-    return Status::OK();
-  }
-  Status CreateDir(const std::string& d) override {
-    return Status::NotSupported();
-  }
-  Status CreateDirIfMissing(const std::string& d) override {
-    return Status::NotSupported();
-  }
-  Status DeleteDir(const std::string& d) override {
-    return Status::NotSupported();
-  }
-  Status GetFileSize(const std::string& f, uint64_t* s) override {
-    auto iter = files_.find(f);
-    if (iter == files_.end()) {
-      return Status::NotFound("The specified file does not exist:", f);
-    }
-    *s = iter->second.size();
-    return Status::OK();
-  }
-
-  Status GetFileModificationTime(const std::string& fname,
-                                 uint64_t* file_mtime) override {
-    return Status::NotSupported();
-  }
-
-  Status RenameFile(const std::string& s, const std::string& t) override {
-    return Status::NotSupported();
-  }
-
-  Status LinkFile(const std::string& s, const std::string& t) override {
-    return Status::NotSupported();
-  }
-
-  Status LockFile(const std::string& f, FileLock** l) override {
-    return Status::NotSupported();
-  }
-
-  Status UnlockFile(FileLock* l) override { return Status::NotSupported(); }
-
- protected:
-  std::unordered_map<std::string, std::string> files_;
-};
-
 class OptionsTest : public testing::Test {};
 
 TEST_F(OptionsTest, LooseCondition) {
@@ -323,6 +163,7 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
       {"max_log_file_size", "37"},
       {"log_file_time_to_roll", "38"},
       {"keep_log_file_num", "39"},
+      {"recycle_log_file_num", "5"},
       {"max_manifest_file_size", "40"},
       {"table_cache_numshardbits", "41"},
       {"WAL_ttl_seconds", "43"},
@@ -338,8 +179,11 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
       {"use_adaptive_mutex", "false"},
       {"new_table_reader_for_compaction_inputs", "true"},
       {"compaction_readahead_size", "100"},
+      {"random_access_max_buffer_size", "3145728"},
+      {"writable_file_max_buffer_size", "314159"},
       {"bytes_per_sync", "47"},
-      {"wal_bytes_per_sync", "48"}, };
+      {"wal_bytes_per_sync", "48"},
+  };
 
   ColumnFamilyOptions base_cf_opt;
   ColumnFamilyOptions new_cf_opt;
@@ -431,6 +275,7 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
   ASSERT_EQ(new_db_opt.max_log_file_size, 37U);
   ASSERT_EQ(new_db_opt.log_file_time_to_roll, 38U);
   ASSERT_EQ(new_db_opt.keep_log_file_num, 39U);
+  ASSERT_EQ(new_db_opt.recycle_log_file_num, 5U);
   ASSERT_EQ(new_db_opt.max_manifest_file_size, static_cast<uint64_t>(40));
   ASSERT_EQ(new_db_opt.table_cache_numshardbits, 41);
   ASSERT_EQ(new_db_opt.WAL_ttl_seconds, static_cast<uint64_t>(43));
@@ -446,6 +291,8 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
   ASSERT_EQ(new_db_opt.use_adaptive_mutex, false);
   ASSERT_EQ(new_db_opt.new_table_reader_for_compaction_inputs, true);
   ASSERT_EQ(new_db_opt.compaction_readahead_size, 100);
+  ASSERT_EQ(new_db_opt.random_access_max_buffer_size, 3145728);
+  ASSERT_EQ(new_db_opt.writable_file_max_buffer_size, 314159);
   ASSERT_EQ(new_db_opt.bytes_per_sync, static_cast<uint64_t>(47));
   ASSERT_EQ(new_db_opt.wal_bytes_per_sync, static_cast<uint64_t>(48));
 }
@@ -585,6 +432,31 @@ TEST_F(OptionsTest, GetColumnFamilyOptionsFromStringTest) {
   ASSERT_NOK(GetColumnFamilyOptionsFromString(base_cf_opt,
               "optimize_filters_for_hits=junk",
               &new_cf_opt));
+
+  // Nested plain table options
+  // Emtpy
+  ASSERT_OK(GetColumnFamilyOptionsFromString(base_cf_opt,
+            "write_buffer_size=10;max_write_buffer_number=16;"
+            "plain_table_factory={};arena_block_size=1024",
+            &new_cf_opt));
+  ASSERT_TRUE(new_cf_opt.table_factory != nullptr);
+  ASSERT_EQ(std::string(new_cf_opt.table_factory->Name()), "PlainTable");
+  // Non-empty
+  ASSERT_OK(GetColumnFamilyOptionsFromString(base_cf_opt,
+            "write_buffer_size=10;max_write_buffer_number=16;"
+            "plain_table_factory={user_key_len=66;bloom_bits_per_key=20;};"
+            "arena_block_size=1024",
+            &new_cf_opt));
+  ASSERT_TRUE(new_cf_opt.table_factory != nullptr);
+  ASSERT_EQ(std::string(new_cf_opt.table_factory->Name()), "PlainTable");
+
+  // memtable factory
+  ASSERT_OK(GetColumnFamilyOptionsFromString(base_cf_opt,
+            "write_buffer_size=10;max_write_buffer_number=16;"
+            "memtable=skip_list:10;arena_block_size=1024",
+            &new_cf_opt));
+  ASSERT_TRUE(new_cf_opt.memtable_factory != nullptr);
+  ASSERT_EQ(std::string(new_cf_opt.memtable_factory->Name()), "SkipListFactory");
 }
 #endif  // !ROCKSDB_LITE
 
@@ -598,7 +470,8 @@ TEST_F(OptionsTest, GetBlockBasedTableOptionsFromString) {
             "checksum=kxxHash;hash_index_allow_collision=1;no_block_cache=1;"
             "block_cache=1M;block_cache_compressed=1k;block_size=1024;"
             "block_size_deviation=8;block_restart_interval=4;"
-            "filter_policy=bloomfilter:4:true;whole_key_filtering=1",
+            "filter_policy=bloomfilter:4:true;whole_key_filtering=1;"
+            "skip_table_builder_flush=1",
             &new_opt));
   ASSERT_TRUE(new_opt.cache_index_and_filter_blocks);
   ASSERT_EQ(new_opt.index_type, BlockBasedTableOptions::kHashSearch);
@@ -613,6 +486,7 @@ TEST_F(OptionsTest, GetBlockBasedTableOptionsFromString) {
   ASSERT_EQ(new_opt.block_size_deviation, 8);
   ASSERT_EQ(new_opt.block_restart_interval, 4);
   ASSERT_TRUE(new_opt.filter_policy != nullptr);
+  ASSERT_TRUE(new_opt.skip_table_builder_flush);
 
   // unknown option
   ASSERT_NOK(GetBlockBasedTableOptionsFromString(table_opt,
@@ -643,6 +517,79 @@ TEST_F(OptionsTest, GetBlockBasedTableOptionsFromString) {
 }
 #endif  // !ROCKSDB_LITE
 
+
+#ifndef ROCKSDB_LITE  // GetPlainTableOptionsFromString is not supported
+TEST_F(OptionsTest, GetPlainTableOptionsFromString) {
+  PlainTableOptions table_opt;
+  PlainTableOptions new_opt;
+  // make sure default values are overwritten by something else
+  ASSERT_OK(GetPlainTableOptionsFromString(table_opt,
+            "user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;"
+            "index_sparseness=8;huge_page_tlb_size=4;encoding_type=kPrefix;"
+            "full_scan_mode=true;store_index_in_file=true",
+            &new_opt));
+  ASSERT_EQ(new_opt.user_key_len, 66);
+  ASSERT_EQ(new_opt.bloom_bits_per_key, 20);
+  ASSERT_EQ(new_opt.hash_table_ratio, 0.5);
+  ASSERT_EQ(new_opt.index_sparseness, 8);
+  ASSERT_EQ(new_opt.huge_page_tlb_size, 4);
+  ASSERT_EQ(new_opt.encoding_type, EncodingType::kPrefix);
+  ASSERT_TRUE(new_opt.full_scan_mode);
+  ASSERT_TRUE(new_opt.store_index_in_file);
+
+  // unknown option
+  ASSERT_NOK(GetPlainTableOptionsFromString(table_opt,
+             "user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;"
+             "bad_option=1",
+             &new_opt));
+
+  // unrecognized EncodingType
+  ASSERT_NOK(GetPlainTableOptionsFromString(table_opt,
+             "user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;"
+             "encoding_type=kPrefixXX",
+             &new_opt));
+}
+#endif  // !ROCKSDB_LITE
+
+#ifndef ROCKSDB_LITE  // GetMemTableRepFactoryFromString is not supported
+TEST_F(OptionsTest, GetMemTableRepFactoryFromString) {
+  std::unique_ptr<MemTableRepFactory> new_mem_factory = nullptr;
+
+  ASSERT_OK(GetMemTableRepFactoryFromString("skip_list", &new_mem_factory));
+  ASSERT_OK(GetMemTableRepFactoryFromString("skip_list:16", &new_mem_factory));
+  ASSERT_EQ(std::string(new_mem_factory->Name()), "SkipListFactory");
+  ASSERT_NOK(GetMemTableRepFactoryFromString("skip_list:16:invalid_opt",
+                                             &new_mem_factory));
+
+  ASSERT_OK(GetMemTableRepFactoryFromString("prefix_hash", &new_mem_factory));
+  ASSERT_OK(GetMemTableRepFactoryFromString("prefix_hash:1000",
+                                            &new_mem_factory));
+  ASSERT_EQ(std::string(new_mem_factory->Name()), "HashSkipListRepFactory");
+  ASSERT_NOK(GetMemTableRepFactoryFromString("prefix_hash:1000:invalid_opt",
+                                             &new_mem_factory));
+
+  ASSERT_OK(GetMemTableRepFactoryFromString("hash_linkedlist",
+                                            &new_mem_factory));
+  ASSERT_OK(GetMemTableRepFactoryFromString("hash_linkedlist:1000",
+                                            &new_mem_factory));
+  ASSERT_EQ(std::string(new_mem_factory->Name()), "HashLinkListRepFactory");
+  ASSERT_NOK(GetMemTableRepFactoryFromString("hash_linkedlist:1000:invalid_opt",
+                                             &new_mem_factory));
+
+  ASSERT_OK(GetMemTableRepFactoryFromString("vector", &new_mem_factory));
+  ASSERT_OK(GetMemTableRepFactoryFromString("vector:1024", &new_mem_factory));
+  ASSERT_EQ(std::string(new_mem_factory->Name()), "VectorRepFactory");
+  ASSERT_NOK(GetMemTableRepFactoryFromString("vector:1024:invalid_opt",
+                                             &new_mem_factory));
+
+  ASSERT_NOK(GetMemTableRepFactoryFromString("cuckoo", &new_mem_factory));
+  ASSERT_OK(GetMemTableRepFactoryFromString("cuckoo:1024", &new_mem_factory));
+  ASSERT_EQ(std::string(new_mem_factory->Name()), "HashCuckooRepFactory");
+
+  ASSERT_NOK(GetMemTableRepFactoryFromString("bad_factory", &new_mem_factory));
+}
+#endif  // !ROCKSDB_LITE
+
 #ifndef ROCKSDB_LITE  // GetOptionsFromString is not supported in RocksDB Lite
 TEST_F(OptionsTest, GetOptionsFromStringTest) {
   Options base_options, new_options;
@@ -663,7 +610,7 @@ TEST_F(OptionsTest, GetOptionsFromStringTest) {
   ASSERT_EQ(new_options.max_write_buffer_number, 16);
   BlockBasedTableOptions new_block_based_table_options =
       dynamic_cast<BlockBasedTableFactory*>(new_options.table_factory.get())
-          ->GetTableOptions();
+          ->table_options();
   ASSERT_EQ(new_block_based_table_options.block_cache->GetCapacity(), 1U << 20);
   ASSERT_EQ(new_block_based_table_options.block_size, 4U);
   // don't overwrite block based table options
@@ -674,69 +621,12 @@ TEST_F(OptionsTest, GetOptionsFromStringTest) {
   ASSERT_TRUE(new_options.rate_limiter.get() != nullptr);
 }
 
-namespace {
-void RandomInitDBOptions(DBOptions* db_opt, Random* rnd) {
-  // boolean options
-  db_opt->advise_random_on_open = rnd->Uniform(2);
-  db_opt->allow_mmap_reads = rnd->Uniform(2);
-  db_opt->allow_mmap_writes = rnd->Uniform(2);
-  db_opt->allow_os_buffer = rnd->Uniform(2);
-  db_opt->create_if_missing = rnd->Uniform(2);
-  db_opt->create_missing_column_families = rnd->Uniform(2);
-  db_opt->disableDataSync = rnd->Uniform(2);
-  db_opt->enable_thread_tracking = rnd->Uniform(2);
-  db_opt->error_if_exists = rnd->Uniform(2);
-  db_opt->is_fd_close_on_exec = rnd->Uniform(2);
-  db_opt->paranoid_checks = rnd->Uniform(2);
-  db_opt->skip_log_error_on_recovery = rnd->Uniform(2);
-  db_opt->skip_stats_update_on_db_open = rnd->Uniform(2);
-  db_opt->use_adaptive_mutex = rnd->Uniform(2);
-  db_opt->use_fsync = rnd->Uniform(2);
-
-  // int options
-  db_opt->max_background_compactions = rnd->Uniform(100);
-  db_opt->max_background_flushes = rnd->Uniform(100);
-  db_opt->max_file_opening_threads = rnd->Uniform(100);
-  db_opt->max_open_files = rnd->Uniform(100);
-  db_opt->table_cache_numshardbits = rnd->Uniform(100);
-
-  // size_t options
-  db_opt->db_write_buffer_size = rnd->Uniform(10000);
-  db_opt->keep_log_file_num = rnd->Uniform(10000);
-  db_opt->log_file_time_to_roll = rnd->Uniform(10000);
-  db_opt->manifest_preallocation_size = rnd->Uniform(10000);
-  db_opt->max_log_file_size = rnd->Uniform(10000);
-
-  // std::string options
-  db_opt->db_log_dir = "path/to/db_log_dir";
-  db_opt->wal_dir = "path/to/wal_dir";
-
-  // uint32_t options
-  db_opt->max_subcompactions = rnd->Uniform(100000);
-
-  // uint64_t options
-  static const uint64_t uint_max = static_cast<uint64_t>(UINT_MAX);
-  db_opt->WAL_size_limit_MB = uint_max + rnd->Uniform(100000);
-  db_opt->WAL_ttl_seconds = uint_max + rnd->Uniform(100000);
-  db_opt->bytes_per_sync = uint_max + rnd->Uniform(100000);
-  db_opt->delayed_write_rate = uint_max + rnd->Uniform(100000);
-  db_opt->delete_obsolete_files_period_micros = uint_max + rnd->Uniform(100000);
-  db_opt->max_manifest_file_size = uint_max + rnd->Uniform(100000);
-  db_opt->max_total_wal_size = uint_max + rnd->Uniform(100000);
-  db_opt->wal_bytes_per_sync = uint_max + rnd->Uniform(100000);
-
-  // unsigned int options
-  db_opt->stats_dump_period_sec = rnd->Uniform(100000);
-}
-
-}  // namespace
-
 TEST_F(OptionsTest, DBOptionsSerialization) {
   Options base_options, new_options;
   Random rnd(301);
 
   // Phase 1: Make big change in base_options
-  RandomInitDBOptions(&base_options, &rnd);
+  test::RandomInitDBOptions(&base_options, &rnd);
 
   // Phase 2: obtain a string from base_option
   std::string base_options_file_content;
@@ -749,212 +639,12 @@ TEST_F(OptionsTest, DBOptionsSerialization) {
   ASSERT_OK(RocksDBOptionsParser::VerifyDBOptions(base_options, new_options));
 }
 
-namespace {
-CompressionType RandomCompressionType(Random* rnd) {
-  return static_cast<CompressionType>(rnd->Uniform(6));
-}
-
-void RandomCompressionTypeVector(const size_t count,
-                                 std::vector<CompressionType>* types,
-                                 Random* rnd) {
-  types->clear();
-  for (size_t i = 0; i < count; ++i) {
-    types->emplace_back(RandomCompressionType(rnd));
-  }
-}
-
-const SliceTransform* RandomSliceTransform(Random* rnd, int pre_defined = -1) {
-  int random_num = pre_defined >= 0 ? pre_defined : rnd->Uniform(4);
-  switch (random_num) {
-    case 0:
-      return NewFixedPrefixTransform(rnd->Uniform(20) + 1);
-    case 1:
-      return NewCappedPrefixTransform(rnd->Uniform(20) + 1);
-    case 2:
-      return NewNoopTransform();
-    default:
-      return nullptr;
-  }
-}
-
-TableFactory* RandomTableFactory(Random* rnd, int pre_defined = -1) {
-  int random_num = pre_defined >= 0 ? pre_defined : rnd->Uniform(3);
-  switch (random_num) {
-    case 0:
-      return NewPlainTableFactory();
-    case 1:
-      return NewCuckooTableFactory();
-    default:
-      return NewBlockBasedTableFactory();
-  }
-}
-
-std::string RandomString(Random* rnd, const size_t len) {
-  std::stringstream ss;
-  for (size_t i = 0; i < len; ++i) {
-    ss << static_cast<char>(rnd->Uniform(26) + 'a');
-  }
-  return ss.str();
-}
-
-class ChanglingMergeOperator : public MergeOperator {
- public:
-  explicit ChanglingMergeOperator(const std::string& name)
-      : name_(name + "MergeOperator") {}
-  ~ChanglingMergeOperator() {}
-
-  void SetName(const std::string& name) { name_ = name; }
-
-  virtual bool FullMerge(const Slice& key, const Slice* existing_value,
-                         const std::deque<std::string>& operand_list,
-                         std::string* new_value,
-                         Logger* logger) const override {
-    return false;
-  }
-  virtual bool PartialMergeMulti(const Slice& key,
-                                 const std::deque<Slice>& operand_list,
-                                 std::string* new_value,
-                                 Logger* logger) const override {
-    return false;
-  }
-  virtual const char* Name() const override { return name_.c_str(); }
-
- protected:
-  std::string name_;
-};
-
-MergeOperator* RandomMergeOperator(Random* rnd) {
-  return new ChanglingMergeOperator(RandomString(rnd, 10));
-}
-
-class ChanglingCompactionFilter : public CompactionFilter {
- public:
-  explicit ChanglingCompactionFilter(const std::string& name)
-      : name_(name + "CompactionFilter") {}
-  ~ChanglingCompactionFilter() {}
-
-  void SetName(const std::string& name) { name_ = name; }
-
-  bool Filter(int level, const Slice& key, const Slice& existing_value,
-              std::string* new_value, bool* value_changed) const override {
-    return false;
-  }
-
-  const char* Name() const override { return name_.c_str(); }
-
- private:
-  std::string name_;
-};
-
-CompactionFilter* RandomCompactionFilter(Random* rnd) {
-  return new ChanglingCompactionFilter(RandomString(rnd, 10));
-}
-
-class ChanglingCompactionFilterFactory : public CompactionFilterFactory {
- public:
-  explicit ChanglingCompactionFilterFactory(const std::string& name)
-      : name_(name + "CompactionFilterFactory") {}
-  ~ChanglingCompactionFilterFactory() {}
-
-  void SetName(const std::string& name) { name_ = name; }
-
-  std::unique_ptr<CompactionFilter> CreateCompactionFilter(
-      const CompactionFilter::Context& context) override {
-    return std::unique_ptr<CompactionFilter>();
-  }
-
-  // Returns a name that identifies this compaction filter factory.
-  const char* Name() const override { return name_.c_str(); }
-
- protected:
-  std::string name_;
-};
-
-CompactionFilterFactory* RandomCompactionFilterFactory(Random* rnd) {
-  return new ChanglingCompactionFilterFactory(RandomString(rnd, 10));
-}
-
-// Note that the caller is responsible for releasing non-null
-// cf_opt->compaction_filter.
-void RandomInitCFOptions(ColumnFamilyOptions* cf_opt, Random* rnd) {
-  cf_opt->compaction_style = (CompactionStyle)(rnd->Uniform(4));
-
-  // boolean options
-  cf_opt->compaction_measure_io_stats = rnd->Uniform(2);
-  cf_opt->disable_auto_compactions = rnd->Uniform(2);
-  cf_opt->filter_deletes = rnd->Uniform(2);
-  cf_opt->inplace_update_support = rnd->Uniform(2);
-  cf_opt->level_compaction_dynamic_level_bytes = rnd->Uniform(2);
-  cf_opt->optimize_filters_for_hits = rnd->Uniform(2);
-  cf_opt->paranoid_file_checks = rnd->Uniform(2);
-  cf_opt->purge_redundant_kvs_while_flush = rnd->Uniform(2);
-  cf_opt->verify_checksums_in_compaction = rnd->Uniform(2);
-
-  // double options
-  cf_opt->hard_rate_limit = static_cast<double>(rnd->Uniform(10000)) / 13;
-  cf_opt->soft_rate_limit = static_cast<double>(rnd->Uniform(10000)) / 13;
-
-  // int options
-  cf_opt->expanded_compaction_factor = rnd->Uniform(100);
-  cf_opt->level0_file_num_compaction_trigger = rnd->Uniform(100);
-  cf_opt->level0_slowdown_writes_trigger = rnd->Uniform(100);
-  cf_opt->level0_stop_writes_trigger = rnd->Uniform(100);
-  cf_opt->max_bytes_for_level_multiplier = rnd->Uniform(100);
-  cf_opt->max_grandparent_overlap_factor = rnd->Uniform(100);
-  cf_opt->max_mem_compaction_level = rnd->Uniform(100);
-  cf_opt->max_write_buffer_number = rnd->Uniform(100);
-  cf_opt->max_write_buffer_number_to_maintain = rnd->Uniform(100);
-  cf_opt->min_write_buffer_number_to_merge = rnd->Uniform(100);
-  cf_opt->num_levels = rnd->Uniform(100);
-  cf_opt->source_compaction_factor = rnd->Uniform(100);
-  cf_opt->target_file_size_multiplier = rnd->Uniform(100);
-
-  // size_t options
-  cf_opt->arena_block_size = rnd->Uniform(10000);
-  cf_opt->inplace_update_num_locks = rnd->Uniform(10000);
-  cf_opt->max_successive_merges = rnd->Uniform(10000);
-  cf_opt->memtable_prefix_bloom_huge_page_tlb_size = rnd->Uniform(10000);
-  cf_opt->write_buffer_size = rnd->Uniform(10000);
-
-  // uint32_t options
-  cf_opt->bloom_locality = rnd->Uniform(10000);
-  cf_opt->memtable_prefix_bloom_bits = rnd->Uniform(10000);
-  cf_opt->memtable_prefix_bloom_probes = rnd->Uniform(10000);
-  cf_opt->min_partial_merge_operands = rnd->Uniform(10000);
-  cf_opt->max_bytes_for_level_base = rnd->Uniform(10000);
-
-  // uint64_t options
-  static const uint64_t uint_max = static_cast<uint64_t>(UINT_MAX);
-  cf_opt->max_sequential_skip_in_iterations = uint_max + rnd->Uniform(10000);
-  cf_opt->target_file_size_base = uint_max + rnd->Uniform(10000);
-
-  // unsigned int options
-  cf_opt->rate_limit_delay_max_milliseconds = rnd->Uniform(10000);
-
-  // pointer typed options
-  cf_opt->prefix_extractor.reset(RandomSliceTransform(rnd));
-  cf_opt->table_factory.reset(RandomTableFactory(rnd));
-  cf_opt->merge_operator.reset(RandomMergeOperator(rnd));
-  if (cf_opt->compaction_filter) {
-    delete cf_opt->compaction_filter;
-  }
-  cf_opt->compaction_filter = RandomCompactionFilter(rnd);
-  cf_opt->compaction_filter_factory.reset(RandomCompactionFilterFactory(rnd));
-
-  // custom typed options
-  cf_opt->compression = RandomCompressionType(rnd);
-  RandomCompressionTypeVector(cf_opt->num_levels,
-                              &cf_opt->compression_per_level, rnd);
-}
-
-}  // namespace
-
 TEST_F(OptionsTest, ColumnFamilyOptionsSerialization) {
   ColumnFamilyOptions base_opt, new_opt;
   Random rnd(302);
   // Phase 1: randomly assign base_opt
   // custom type options
-  RandomInitCFOptions(&base_opt, &rnd);
+  test::RandomInitCFOptions(&base_opt, &rnd);
 
   // Phase 2: obtain a string from base_opt
   std::string base_options_file_content;
@@ -973,7 +663,6 @@ TEST_F(OptionsTest, ColumnFamilyOptionsSerialization) {
 
 #endif  // !ROCKSDB_LITE
 
-
 Status StringToMap(
     const std::string& opts_str,
     std::unordered_map<std::string, std::string>* opts_map);
@@ -1163,7 +852,7 @@ TEST_F(OptionsTest, ConvertOptionsTest) {
 
   ASSERT_TRUE(table_factory.get() != nullptr);
 
-  const BlockBasedTableOptions table_opt = table_factory->GetTableOptions();
+  const BlockBasedTableOptions table_opt = table_factory->table_options();
 
   ASSERT_EQ(table_opt.block_cache->GetCapacity(), 8UL << 20);
   ASSERT_EQ(table_opt.block_size, leveldb_opt.block_size);
@@ -1175,10 +864,10 @@ TEST_F(OptionsTest, ConvertOptionsTest) {
 #ifndef ROCKSDB_LITE
 class OptionsParserTest : public testing::Test {
  public:
-  OptionsParserTest() { env_.reset(new StringEnv(Env::Default())); }
+  OptionsParserTest() { env_.reset(new test::StringEnv(Env::Default())); }
 
  protected:
-  std::unique_ptr<StringEnv> env_;
+  std::unique_ptr<test::StringEnv> env_;
 };
 
 TEST_F(OptionsParserTest, Comment) {
@@ -1422,7 +1111,7 @@ void VerifyCFPointerTypedOptions(
 
   // change the name of merge operator back-and-forth
   {
-    auto* merge_operator = dynamic_cast<ChanglingMergeOperator*>(
+    auto* merge_operator = dynamic_cast<test::ChanglingMergeOperator*>(
         base_cf_opt->merge_operator.get());
     if (merge_operator != nullptr) {
       name_buffer = merge_operator->Name();
@@ -1440,7 +1129,7 @@ void VerifyCFPointerTypedOptions(
   // change the name of the compaction filter factory back-and-forth
   {
     auto* compaction_filter_factory =
-        dynamic_cast<ChanglingCompactionFilterFactory*>(
+        dynamic_cast<test::ChanglingCompactionFilterFactory*>(
             base_cf_opt->compaction_filter_factory.get());
     if (compaction_filter_factory != nullptr) {
       name_buffer = compaction_filter_factory->Name();
@@ -1510,17 +1199,17 @@ TEST_F(OptionsParserTest, DumpAndParse) {
                                        "###rocksdb#1-testcf#2###"};
   const int num_cf = static_cast<int>(cf_names.size());
   Random rnd(302);
-  RandomInitDBOptions(&base_db_opt, &rnd);
+  test::RandomInitDBOptions(&base_db_opt, &rnd);
   base_db_opt.db_log_dir += "/#odd #but #could #happen #path #/\\\\#OMG";
   for (int c = 0; c < num_cf; ++c) {
     ColumnFamilyOptions cf_opt;
     Random cf_rnd(0xFB + c);
-    RandomInitCFOptions(&cf_opt, &cf_rnd);
+    test::RandomInitCFOptions(&cf_opt, &cf_rnd);
     if (c < 4) {
-      cf_opt.prefix_extractor.reset(RandomSliceTransform(&rnd, c));
+      cf_opt.prefix_extractor.reset(test::RandomSliceTransform(&rnd, c));
     }
     if (c < 3) {
-      cf_opt.table_factory.reset(RandomTableFactory(&rnd, c));
+      cf_opt.table_factory.reset(test::RandomTableFactory(&rnd, c));
     }
     base_cf_opts.emplace_back(cf_opt);
   }
@@ -1565,6 +1254,151 @@ TEST_F(OptionsParserTest, DumpAndParse) {
   }
 }
 
+TEST_F(OptionsParserTest, DifferentDefault) {
+  const std::string kOptionsFileName = "test-persisted-options.ini";
+
+  ColumnFamilyOptions cf_level_opts;
+  cf_level_opts.OptimizeLevelStyleCompaction();
+
+  ColumnFamilyOptions cf_univ_opts;
+  cf_univ_opts.OptimizeUniversalStyleCompaction();
+
+  ASSERT_OK(PersistRocksDBOptions(DBOptions(), {"default", "universal"},
+                                  {cf_level_opts, cf_univ_opts},
+                                  kOptionsFileName, env_.get()));
+
+  RocksDBOptionsParser parser;
+  ASSERT_OK(parser.Parse(kOptionsFileName, env_.get()));
+}
+
+class OptionsSanityCheckTest : public OptionsParserTest {
+ public:
+  OptionsSanityCheckTest() {}
+
+ protected:
+  Status SanityCheckCFOptions(const ColumnFamilyOptions& cf_opts,
+                              OptionsSanityCheckLevel level) {
+    return RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
+        DBOptions(), {"default"}, {cf_opts}, kOptionsFileName, env_.get(),
+        level);
+  }
+
+  Status PersistCFOptions(const ColumnFamilyOptions& cf_opts) {
+    Status s = env_->DeleteFile(kOptionsFileName);
+    if (!s.ok()) {
+      return s;
+    }
+    return PersistRocksDBOptions(DBOptions(), {"default"}, {cf_opts},
+                                 kOptionsFileName, env_.get());
+  }
+
+  const std::string kOptionsFileName = "OPTIONS";
+};
+
+TEST_F(OptionsSanityCheckTest, SanityCheck) {
+  ColumnFamilyOptions opts;
+  Random rnd(301);
+
+  // default ColumnFamilyOptions
+  {
+    ASSERT_OK(PersistCFOptions(opts));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+  }
+
+  // prefix_extractor
+  {
+    // change the prefix extractor and expect only pass when
+    // sanity-level == kSanityLevelNone
+    opts.prefix_extractor.reset(NewCappedPrefixTransform(10));
+    ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelNone));
+
+    // persist the change
+    ASSERT_OK(PersistCFOptions(opts));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+
+    // use same prefix extractor but with different parameter
+    opts.prefix_extractor.reset(NewCappedPrefixTransform(15));
+    // expect pass only in kSanityLevelNone
+    ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelNone));
+
+    // repeat the test with FixedPrefixTransform
+    opts.prefix_extractor.reset(NewFixedPrefixTransform(10));
+    ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelNone));
+
+    // persist the change of prefix_extractor
+    ASSERT_OK(PersistCFOptions(opts));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+
+    // use same prefix extractor but with different parameter
+    opts.prefix_extractor.reset(NewFixedPrefixTransform(15));
+    // expect pass only in kSanityLevelNone
+    ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+    ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelNone));
+  }
+
+  // table_factory
+  {
+    for (int tb = 2; tb >= 0; --tb) {
+      // change the table factory
+      opts.table_factory.reset(test::RandomTableFactory(&rnd, tb));
+      ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelNone));
+
+      // persist the change
+      ASSERT_OK(PersistCFOptions(opts));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+    }
+  }
+
+  // merge_operator
+  {
+    for (int test = 0; test < 5; ++test) {
+      // change the merge operator
+      opts.merge_operator.reset(test::RandomMergeOperator(&rnd));
+      ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelNone));
+
+      // persist the change
+      ASSERT_OK(PersistCFOptions(opts));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+    }
+  }
+
+  // compaction_filter
+  {
+    for (int test = 0; test < 5; ++test) {
+      // change the compaction filter
+      opts.compaction_filter = test::RandomCompactionFilter(&rnd);
+      ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+
+      // persist the change
+      ASSERT_OK(PersistCFOptions(opts));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+      delete opts.compaction_filter;
+      opts.compaction_filter = nullptr;
+    }
+  }
+
+  // compaction_filter_factory
+  {
+    for (int test = 0; test < 5; ++test) {
+      // change the compaction filter factory
+      opts.compaction_filter_factory.reset(
+          test::RandomCompactionFilterFactory(&rnd));
+      ASSERT_NOK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelLooselyCompatible));
+
+      // persist the change
+      ASSERT_OK(PersistCFOptions(opts));
+      ASSERT_OK(SanityCheckCFOptions(opts, kSanityLevelExactMatch));
+    }
+  }
+}
+
 namespace {
 bool IsEscapedString(const std::string& str) {
   for (size_t i = 0; i < str.size(); ++i) {
diff --git a/src/rocksdb/util/perf_context_imp.h b/src/rocksdb/util/perf_context_imp.h
index cde7ee3..a5c4c39 100644
--- a/src/rocksdb/util/perf_context_imp.h
+++ b/src/rocksdb/util/perf_context_imp.h
@@ -13,6 +13,7 @@ namespace rocksdb {
 #if defined(NPERF_CONTEXT) || defined(IOS_CROSS_COMPILE)
 
 #define PERF_TIMER_GUARD(metric)
+#define PERF_CONDITIONAL_TIMER_GUARD(metric, condition)
 #define PERF_TIMER_MEASURE(metric)
 #define PERF_TIMER_STOP(metric)
 #define PERF_TIMER_START(metric)
@@ -32,6 +33,12 @@ namespace rocksdb {
   PerfStepTimer perf_step_timer_ ## metric(&(perf_context.metric));   \
   perf_step_timer_ ## metric.Start();
 
+#define PERF_CONDITIONAL_TIMER_GUARD(metric, condition)           \
+  PerfStepTimer perf_step_timer_##metric(&(perf_context.metric)); \
+  if ((condition)) {                                              \
+    perf_step_timer_##metric.Start();                             \
+  }
+
 // Update metric with time elapsed since last START. start time is reset
 // to current timestamp.
 #define PERF_TIMER_MEASURE(metric)        \
diff --git a/src/rocksdb/util/random.cc b/src/rocksdb/util/random.cc
new file mode 100644
index 0000000..5694477
--- /dev/null
+++ b/src/rocksdb/util/random.cc
@@ -0,0 +1,38 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+
+#include "util/random.h"
+
+#include <stdint.h>
+#include <string.h>
+#include <thread>
+#include <utility>
+
+#include "port/likely.h"
+#include "util/thread_local.h"
+
+#if ROCKSDB_SUPPORT_THREAD_LOCAL
+#define STORAGE_DECL static __thread
+#else
+#define STORAGE_DECL static
+#endif
+
+namespace rocksdb {
+
+Random* Random::GetTLSInstance() {
+  STORAGE_DECL Random* tls_instance;
+  STORAGE_DECL std::aligned_storage<sizeof(Random)>::type tls_instance_bytes;
+
+  auto rv = tls_instance;
+  if (UNLIKELY(rv == nullptr)) {
+    size_t seed = std::hash<std::thread::id>()(std::this_thread::get_id());
+    rv = new (&tls_instance_bytes) Random((uint32_t)seed);
+    tls_instance = rv;
+  }
+  return rv;
+}
+
+}  // namespace rocksdb
diff --git a/src/rocksdb/util/random.h b/src/rocksdb/util/random.h
index e5b3315..8f90c76 100644
--- a/src/rocksdb/util/random.h
+++ b/src/rocksdb/util/random.h
@@ -18,12 +18,26 @@ namespace rocksdb {
 // package.
 class Random {
  private:
+  enum : uint32_t {
+    M = 2147483647L  // 2^31-1
+  };
+  enum : uint64_t {
+    A = 16807  // bits 14, 8, 7, 5, 2, 1, 0
+  };
+
   uint32_t seed_;
+
+  static uint32_t GoodSeed(uint32_t s) { return (s & M) != 0 ? (s & M) : 1; }
+
  public:
-  explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { }
+  // This is the largest value that can be returned from Next()
+  enum : uint32_t { kMaxNext = M };
+
+  explicit Random(uint32_t s) : seed_(GoodSeed(s)) {}
+
+  void Reset(uint32_t s) { seed_ = GoodSeed(s); }
+
   uint32_t Next() {
-    static const uint32_t M = 2147483647L;   // 2^31-1
-    static const uint64_t A = 16807;  // bits 14, 8, 7, 5, 2, 1, 0
     // We are computing
     //       seed_ = (seed_ * A) % M,    where M = 2^31-1
     //
@@ -42,6 +56,7 @@ class Random {
     }
     return seed_;
   }
+
   // Returns a uniformly distributed value in the range [0..n-1]
   // REQUIRES: n > 0
   uint32_t Uniform(int n) { return Next() % n; }
@@ -56,6 +71,10 @@ class Random {
   uint32_t Skewed(int max_log) {
     return Uniform(1 << Uniform(max_log + 1));
   }
+
+  // Returns a Random instance for use by the current thread without
+  // additional locking
+  static Random* GetTLSInstance();
 };
 
 // A simple 64bit random number generator based on std::mt19937_64
diff --git a/src/rocksdb/util/skiplistrep.cc b/src/rocksdb/util/skiplistrep.cc
index 112a7ab..83472c6 100644
--- a/src/rocksdb/util/skiplistrep.cc
+++ b/src/rocksdb/util/skiplistrep.cc
@@ -3,15 +3,15 @@
 //  LICENSE file in the root directory of this source tree. An additional grant
 //  of patent rights can be found in the PATENTS file in the same directory.
 //
-#include "rocksdb/memtablerep.h"
+#include "db/inlineskiplist.h"
 #include "db/memtable.h"
-#include "db/skiplist.h"
+#include "rocksdb/memtablerep.h"
 #include "util/arena.h"
 
 namespace rocksdb {
 namespace {
 class SkipListRep : public MemTableRep {
-  SkipList<const char*, const MemTableRep::KeyComparator&> skip_list_;
+  InlineSkipList<const MemTableRep::KeyComparator&> skip_list_;
   const MemTableRep::KeyComparator& cmp_;
   const SliceTransform* transform_;
   const size_t lookahead_;
@@ -25,6 +25,11 @@ public:
       transform_(transform), lookahead_(lookahead) {
   }
 
+  virtual KeyHandle Allocate(const size_t len, char** buf) override {
+    *buf = skip_list_.AllocateKey(len);
+    return static_cast<KeyHandle>(*buf);
+  }
+
   // Insert key into the list.
   // REQUIRES: nothing that compares equal to key is currently in the list.
   virtual void Insert(KeyHandle handle) override {
@@ -65,13 +70,14 @@ public:
 
   // Iteration over the contents of a skip list
   class Iterator : public MemTableRep::Iterator {
-    SkipList<const char*, const MemTableRep::KeyComparator&>::Iterator iter_;
+    InlineSkipList<const MemTableRep::KeyComparator&>::Iterator iter_;
+
    public:
     // Initialize an iterator over the specified list.
     // The returned iterator is not valid.
     explicit Iterator(
-      const SkipList<const char*, const MemTableRep::KeyComparator&>* list
-    ) : iter_(list) { }
+        const InlineSkipList<const MemTableRep::KeyComparator&>* list)
+        : iter_(list) {}
 
     virtual ~Iterator() override { }
 
@@ -213,8 +219,8 @@ public:
 
    private:
     const SkipListRep& rep_;
-    SkipList<const char*, const MemTableRep::KeyComparator&>::Iterator iter_;
-    SkipList<const char*, const MemTableRep::KeyComparator&>::Iterator prev_;
+    InlineSkipList<const MemTableRep::KeyComparator&>::Iterator iter_;
+    InlineSkipList<const MemTableRep::KeyComparator&>::Iterator prev_;
   };
 
   virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override {
diff --git a/src/rocksdb/util/sync_point.cc b/src/rocksdb/util/sync_point.cc
index 7051b51..11c42f1 100644
--- a/src/rocksdb/util/sync_point.cc
+++ b/src/rocksdb/util/sync_point.cc
@@ -8,15 +8,28 @@
 #include "util/random.h"
 
 int rocksdb_kill_odds = 0;
+std::vector<std::string> rocksdb_kill_prefix_blacklist;
 
 #ifndef NDEBUG
 namespace rocksdb {
 
-void TestKillRandom(int odds, const std::string& srcfile, int srcline) {
+void TestKillRandom(std::string kill_point, int odds,
+                    const std::string& srcfile, int srcline) {
+  for (auto& p : rocksdb_kill_prefix_blacklist) {
+    if (kill_point.substr(0, p.length()) == p) {
+      return;
+    }
+  }
+
   time_t curtime = time(nullptr);
   Random r((uint32_t)curtime);
 
   assert(odds > 0);
+  if (odds % 7 == 0) {
+    // class Rarndom uses multiplier 16807, which is 7^5. If odds are
+    // multiplier of 7, the first random value might have limited values.
+    odds++;
+  }
   bool crash = r.OneIn(odds);
   if (crash) {
     port::Crash(srcfile, srcline);
diff --git a/src/rocksdb/util/sync_point.h b/src/rocksdb/util/sync_point.h
index 6a4629c..f169636 100644
--- a/src/rocksdb/util/sync_point.h
+++ b/src/rocksdb/util/sync_point.h
@@ -15,26 +15,29 @@
 // This is only set from db_stress.cc and for testing only.
 // If non-zero, kill at various points in source code with probability 1/this
 extern int rocksdb_kill_odds;
+// If kill point has a prefix on this list, will skip killing.
+extern std::vector<std::string> rocksdb_kill_prefix_blacklist;
 
 #ifdef NDEBUG
 // empty in release build
-#define TEST_KILL_RANDOM(rocksdb_kill_odds)
+#define TEST_KILL_RANDOM(kill_point, rocksdb_kill_odds)
 #else
 
 namespace rocksdb {
 // Kill the process with probablity 1/odds for testing.
-extern void TestKillRandom(int odds, const std::string& srcfile, int srcline);
+extern void TestKillRandom(std::string kill_point, int odds,
+                           const std::string& srcfile, int srcline);
 
 // To avoid crashing always at some frequently executed codepaths (during
 // kill random test), use this factor to reduce odds
 #define REDUCE_ODDS 2
 #define REDUCE_ODDS2 4
 
-#define TEST_KILL_RANDOM(rocksdb_kill_odds)                  \
-  {                                                          \
-    if (rocksdb_kill_odds > 0) {                             \
-      TestKillRandom(rocksdb_kill_odds, __FILE__, __LINE__); \
-    }                                                        \
+#define TEST_KILL_RANDOM(kill_point, rocksdb_kill_odds)                  \
+  {                                                                      \
+    if (rocksdb_kill_odds > 0) {                                         \
+      TestKillRandom(kill_point, rocksdb_kill_odds, __FILE__, __LINE__); \
+    }                                                                    \
   }
 }  // namespace rocksdb
 #endif
@@ -53,7 +56,7 @@ namespace rocksdb {
 // In the unit test, 'Happens After' relationship among sync points could be
 // setup via SyncPoint::LoadDependency, to reproduce a desired interleave of
 // threads execution.
-// Refer to (DBTest,TransactionLogIteratorRace), for an exmaple use case.
+// Refer to (DBTest,TransactionLogIteratorRace), for an example use case.
 
 class SyncPoint {
  public:
diff --git a/src/rocksdb/util/testutil.cc b/src/rocksdb/util/testutil.cc
index 5f74221..8db8dac 100644
--- a/src/rocksdb/util/testutil.cc
+++ b/src/rocksdb/util/testutil.cc
@@ -9,9 +9,11 @@
 
 #include "util/testutil.h"
 
+#include <cctype>
+#include <sstream>
+
 #include "port/port.h"
 #include "util/file_reader_writer.h"
-#include "util/random.h"
 
 namespace rocksdb {
 namespace test {
@@ -33,7 +35,7 @@ extern std::string RandomHumanReadableString(Random* rnd, int len) {
   return ret;
 }
 
-std::string RandomKey(Random* rnd, int len) {
+std::string RandomKey(Random* rnd, int len, RandomKeyType type) {
   // Make sure to generate a wide variety of characters so we
   // test the boundary conditions for short-key optimizations.
   static const char kTestChars[] = {
@@ -41,7 +43,22 @@ std::string RandomKey(Random* rnd, int len) {
   };
   std::string result;
   for (int i = 0; i < len; i++) {
-    result += kTestChars[rnd->Uniform(sizeof(kTestChars))];
+    std::size_t indx = 0;
+    switch (type) {
+      case RandomKeyType::RANDOM:
+        indx = rnd->Uniform(sizeof(kTestChars));
+        break;
+      case RandomKeyType::LARGEST:
+        indx = sizeof(kTestChars) - 1;
+        break;
+      case RandomKeyType::MIDDLE:
+        indx = sizeof(kTestChars) / 2;
+        break;
+      case RandomKeyType::SMALLEST:
+        indx = 0;
+        break;
+    }
+    result += kTestChars[indx];
   }
   return result;
 }
@@ -138,5 +155,209 @@ std::string KeyStr(const std::string& user_key, const SequenceNumber& seq,
   return k.Encode().ToString();
 }
 
+std::string RandomName(Random* rnd, const size_t len) {
+  std::stringstream ss;
+  for (size_t i = 0; i < len; ++i) {
+    ss << static_cast<char>(rnd->Uniform(26) + 'a');
+  }
+  return ss.str();
+}
+
+CompressionType RandomCompressionType(Random* rnd) {
+  return static_cast<CompressionType>(rnd->Uniform(6));
+}
+
+void RandomCompressionTypeVector(const size_t count,
+                                 std::vector<CompressionType>* types,
+                                 Random* rnd) {
+  types->clear();
+  for (size_t i = 0; i < count; ++i) {
+    types->emplace_back(RandomCompressionType(rnd));
+  }
+}
+
+const SliceTransform* RandomSliceTransform(Random* rnd, int pre_defined) {
+  int random_num = pre_defined >= 0 ? pre_defined : rnd->Uniform(4);
+  switch (random_num) {
+    case 0:
+      return NewFixedPrefixTransform(rnd->Uniform(20) + 1);
+    case 1:
+      return NewCappedPrefixTransform(rnd->Uniform(20) + 1);
+    case 2:
+      return NewNoopTransform();
+    default:
+      return nullptr;
+  }
+}
+
+BlockBasedTableOptions RandomBlockBasedTableOptions(Random* rnd) {
+  BlockBasedTableOptions opt;
+  opt.cache_index_and_filter_blocks = rnd->Uniform(2);
+  opt.index_type = rnd->Uniform(2) ? BlockBasedTableOptions::kBinarySearch
+                                   : BlockBasedTableOptions::kHashSearch;
+  opt.hash_index_allow_collision = rnd->Uniform(2);
+  opt.checksum = static_cast<ChecksumType>(rnd->Uniform(3));
+  opt.block_size = rnd->Uniform(10000000);
+  opt.block_size_deviation = rnd->Uniform(100);
+  opt.block_restart_interval = rnd->Uniform(100);
+  opt.whole_key_filtering = rnd->Uniform(2);
+
+  return opt;
+}
+
+TableFactory* RandomTableFactory(Random* rnd, int pre_defined) {
+#ifndef ROCKSDB_LITE
+  int random_num = pre_defined >= 0 ? pre_defined : rnd->Uniform(4);
+  switch (random_num) {
+    case 0:
+      return NewPlainTableFactory();
+    case 1:
+      return NewCuckooTableFactory();
+    default:
+      return NewBlockBasedTableFactory();
+  }
+#else
+  return NewBlockBasedTableFactory();
+#endif  // !ROCKSDB_LITE
+}
+
+MergeOperator* RandomMergeOperator(Random* rnd) {
+  return new ChanglingMergeOperator(RandomName(rnd, 10));
+}
+
+CompactionFilter* RandomCompactionFilter(Random* rnd) {
+  return new ChanglingCompactionFilter(RandomName(rnd, 10));
+}
+
+CompactionFilterFactory* RandomCompactionFilterFactory(Random* rnd) {
+  return new ChanglingCompactionFilterFactory(RandomName(rnd, 10));
+}
+
+void RandomInitDBOptions(DBOptions* db_opt, Random* rnd) {
+  // boolean options
+  db_opt->advise_random_on_open = rnd->Uniform(2);
+  db_opt->allow_mmap_reads = rnd->Uniform(2);
+  db_opt->allow_mmap_writes = rnd->Uniform(2);
+  db_opt->allow_os_buffer = rnd->Uniform(2);
+  db_opt->create_if_missing = rnd->Uniform(2);
+  db_opt->create_missing_column_families = rnd->Uniform(2);
+  db_opt->disableDataSync = rnd->Uniform(2);
+  db_opt->enable_thread_tracking = rnd->Uniform(2);
+  db_opt->error_if_exists = rnd->Uniform(2);
+  db_opt->is_fd_close_on_exec = rnd->Uniform(2);
+  db_opt->paranoid_checks = rnd->Uniform(2);
+  db_opt->skip_log_error_on_recovery = rnd->Uniform(2);
+  db_opt->skip_stats_update_on_db_open = rnd->Uniform(2);
+  db_opt->use_adaptive_mutex = rnd->Uniform(2);
+  db_opt->use_fsync = rnd->Uniform(2);
+  db_opt->recycle_log_file_num = rnd->Uniform(2);
+
+  // int options
+  db_opt->max_background_compactions = rnd->Uniform(100);
+  db_opt->max_background_flushes = rnd->Uniform(100);
+  db_opt->max_file_opening_threads = rnd->Uniform(100);
+  db_opt->max_open_files = rnd->Uniform(100);
+  db_opt->table_cache_numshardbits = rnd->Uniform(100);
+
+  // size_t options
+  db_opt->db_write_buffer_size = rnd->Uniform(10000);
+  db_opt->keep_log_file_num = rnd->Uniform(10000);
+  db_opt->log_file_time_to_roll = rnd->Uniform(10000);
+  db_opt->manifest_preallocation_size = rnd->Uniform(10000);
+  db_opt->max_log_file_size = rnd->Uniform(10000);
+
+  // std::string options
+  db_opt->db_log_dir = "path/to/db_log_dir";
+  db_opt->wal_dir = "path/to/wal_dir";
+
+  // uint32_t options
+  db_opt->max_subcompactions = rnd->Uniform(100000);
+
+  // uint64_t options
+  static const uint64_t uint_max = static_cast<uint64_t>(UINT_MAX);
+  db_opt->WAL_size_limit_MB = uint_max + rnd->Uniform(100000);
+  db_opt->WAL_ttl_seconds = uint_max + rnd->Uniform(100000);
+  db_opt->bytes_per_sync = uint_max + rnd->Uniform(100000);
+  db_opt->delayed_write_rate = uint_max + rnd->Uniform(100000);
+  db_opt->delete_obsolete_files_period_micros = uint_max + rnd->Uniform(100000);
+  db_opt->max_manifest_file_size = uint_max + rnd->Uniform(100000);
+  db_opt->max_total_wal_size = uint_max + rnd->Uniform(100000);
+  db_opt->wal_bytes_per_sync = uint_max + rnd->Uniform(100000);
+
+  // unsigned int options
+  db_opt->stats_dump_period_sec = rnd->Uniform(100000);
+}
+
+void RandomInitCFOptions(ColumnFamilyOptions* cf_opt, Random* rnd) {
+  cf_opt->compaction_style = (CompactionStyle)(rnd->Uniform(4));
+
+  // boolean options
+  cf_opt->compaction_measure_io_stats = rnd->Uniform(2);
+  cf_opt->disable_auto_compactions = rnd->Uniform(2);
+  cf_opt->filter_deletes = rnd->Uniform(2);
+  cf_opt->inplace_update_support = rnd->Uniform(2);
+  cf_opt->level_compaction_dynamic_level_bytes = rnd->Uniform(2);
+  cf_opt->optimize_filters_for_hits = rnd->Uniform(2);
+  cf_opt->paranoid_file_checks = rnd->Uniform(2);
+  cf_opt->purge_redundant_kvs_while_flush = rnd->Uniform(2);
+  cf_opt->verify_checksums_in_compaction = rnd->Uniform(2);
+
+  // double options
+  cf_opt->hard_rate_limit = static_cast<double>(rnd->Uniform(10000)) / 13;
+  cf_opt->soft_rate_limit = static_cast<double>(rnd->Uniform(10000)) / 13;
+
+  // int options
+  cf_opt->expanded_compaction_factor = rnd->Uniform(100);
+  cf_opt->level0_file_num_compaction_trigger = rnd->Uniform(100);
+  cf_opt->level0_slowdown_writes_trigger = rnd->Uniform(100);
+  cf_opt->level0_stop_writes_trigger = rnd->Uniform(100);
+  cf_opt->max_bytes_for_level_multiplier = rnd->Uniform(100);
+  cf_opt->max_grandparent_overlap_factor = rnd->Uniform(100);
+  cf_opt->max_mem_compaction_level = rnd->Uniform(100);
+  cf_opt->max_write_buffer_number = rnd->Uniform(100);
+  cf_opt->max_write_buffer_number_to_maintain = rnd->Uniform(100);
+  cf_opt->min_write_buffer_number_to_merge = rnd->Uniform(100);
+  cf_opt->num_levels = rnd->Uniform(100);
+  cf_opt->source_compaction_factor = rnd->Uniform(100);
+  cf_opt->target_file_size_multiplier = rnd->Uniform(100);
+
+  // size_t options
+  cf_opt->arena_block_size = rnd->Uniform(10000);
+  cf_opt->inplace_update_num_locks = rnd->Uniform(10000);
+  cf_opt->max_successive_merges = rnd->Uniform(10000);
+  cf_opt->memtable_prefix_bloom_huge_page_tlb_size = rnd->Uniform(10000);
+  cf_opt->write_buffer_size = rnd->Uniform(10000);
+
+  // uint32_t options
+  cf_opt->bloom_locality = rnd->Uniform(10000);
+  cf_opt->memtable_prefix_bloom_bits = rnd->Uniform(10000);
+  cf_opt->memtable_prefix_bloom_probes = rnd->Uniform(10000);
+  cf_opt->min_partial_merge_operands = rnd->Uniform(10000);
+  cf_opt->max_bytes_for_level_base = rnd->Uniform(10000);
+
+  // uint64_t options
+  static const uint64_t uint_max = static_cast<uint64_t>(UINT_MAX);
+  cf_opt->max_sequential_skip_in_iterations = uint_max + rnd->Uniform(10000);
+  cf_opt->target_file_size_base = uint_max + rnd->Uniform(10000);
+
+  // unsigned int options
+  cf_opt->rate_limit_delay_max_milliseconds = rnd->Uniform(10000);
+
+  // pointer typed options
+  cf_opt->prefix_extractor.reset(RandomSliceTransform(rnd));
+  cf_opt->table_factory.reset(RandomTableFactory(rnd));
+  cf_opt->merge_operator.reset(RandomMergeOperator(rnd));
+  if (cf_opt->compaction_filter) {
+    delete cf_opt->compaction_filter;
+  }
+  cf_opt->compaction_filter = RandomCompactionFilter(rnd);
+  cf_opt->compaction_filter_factory.reset(RandomCompactionFilterFactory(rnd));
+
+  // custom typed options
+  cf_opt->compression = RandomCompressionType(rnd);
+  RandomCompressionTypeVector(cf_opt->num_levels,
+                              &cf_opt->compression_per_level, rnd);
+}
+
 }  // namespace test
 }  // namespace rocksdb
diff --git a/src/rocksdb/util/testutil.h b/src/rocksdb/util/testutil.h
index 2980628..e50b50f 100644
--- a/src/rocksdb/util/testutil.h
+++ b/src/rocksdb/util/testutil.h
@@ -9,6 +9,7 @@
 
 #pragma once
 #include <algorithm>
+#include <deque>
 #include <string>
 #include <vector>
 
@@ -16,7 +17,13 @@
 #include "rocksdb/compaction_filter.h"
 #include "rocksdb/env.h"
 #include "rocksdb/iterator.h"
+#include "rocksdb/merge_operator.h"
+#include "rocksdb/options.h"
 #include "rocksdb/slice.h"
+#include "rocksdb/table.h"
+#include "table/block_based_table_factory.h"
+#include "table/internal_iterator.h"
+#include "table/plain_table_factory.h"
 #include "util/mutexlock.h"
 #include "util/random.h"
 
@@ -34,7 +41,9 @@ extern std::string RandomHumanReadableString(Random* rnd, int len);
 
 // Return a random key with the specified length that may contain interesting
 // characters (e.g. \x00, \xff, etc.).
-extern std::string RandomKey(Random* rnd, int len);
+enum RandomKeyType : char { RANDOM, LARGEST, SMALLEST, MIDDLE };
+extern std::string RandomKey(Random* rnd, int len,
+                             RandomKeyType type = RandomKeyType::RANDOM);
 
 // Store in *dst a string of length "len" that will compress to
 // "N*compressed_fraction" bytes and return a Slice that references
@@ -127,7 +136,7 @@ class SimpleSuffixReverseComparator : public Comparator {
 extern const Comparator* Uint64Comparator();
 
 // Iterator over a vector of keys/values
-class VectorIterator : public Iterator {
+class VectorIterator : public InternalIterator {
  public:
   explicit VectorIterator(const std::vector<std::string>& keys)
       : keys_(keys), current_(keys.size()) {
@@ -187,7 +196,7 @@ class StringSink: public WritableFile {
   const std::string& contents() const { return contents_; }
 
   virtual Status Truncate(uint64_t size) override {
-    contents_.resize(size);
+    contents_.resize(static_cast<size_t>(size));
     return Status::OK();
   }
   virtual Status Close() override { return Status::OK(); }
@@ -222,6 +231,47 @@ class StringSink: public WritableFile {
   size_t last_flush_;
 };
 
+class OverwritingStringSink : public WritableFile {
+ public:
+  std::string contents_;
+
+  explicit OverwritingStringSink(Slice* reader_contents)
+      : WritableFile(),
+        contents_(""),
+        reader_contents_(reader_contents),
+        last_flush_(0) {}
+
+  const std::string& contents() const { return contents_; }
+
+  virtual Status Truncate(uint64_t size) override {
+    contents_.resize(static_cast<size_t>(size));
+    return Status::OK();
+  }
+  virtual Status Close() override { return Status::OK(); }
+  virtual Status Flush() override {
+    if (last_flush_ < contents_.size()) {
+      assert(reader_contents_->size() >= contents_.size());
+      memcpy((char*)reader_contents_->data() + last_flush_,
+             contents_.data() + last_flush_, contents_.size() - last_flush_);
+      last_flush_ = contents_.size();
+    }
+    return Status::OK();
+  }
+  virtual Status Sync() override { return Status::OK(); }
+  virtual Status Append(const Slice& slice) override {
+    contents_.append(slice.data(), slice.size());
+    return Status::OK();
+  }
+  void Drop(size_t bytes) {
+    contents_.resize(contents_.size() - bytes);
+    if (last_flush_ > contents_.size()) last_flush_ = contents_.size();
+  }
+
+ private:
+  Slice* reader_contents_;
+  size_t last_flush_;
+};
+
 class StringSource: public RandomAccessFile {
  public:
   explicit StringSource(const Slice& contents, uint64_t uniq_id = 0,
@@ -240,13 +290,13 @@ class StringSource: public RandomAccessFile {
       return Status::InvalidArgument("invalid Read offset");
     }
     if (offset + n > contents_.size()) {
-      n = contents_.size() - offset;
+      n = contents_.size() - static_cast<size_t>(offset);
     }
     if (!mmap_) {
-      memcpy(scratch, &contents_[offset], n);
+      memcpy(scratch, &contents_[static_cast<size_t>(offset)], n);
       *result = Slice(scratch, n);
     } else {
-      *result = Slice(&contents_[offset], n);
+      *result = Slice(&contents_[static_cast<size_t>(offset)], n);
     }
     return Status::OK();
   }
@@ -297,6 +347,7 @@ class SleepingBackgroundTask {
   void DoSleep() {
     MutexLock l(&mutex_);
     sleeping_ = true;
+    bg_cv_.SignalAll();
     while (should_sleep_) {
       bg_cv_.Wait();
     }
@@ -304,6 +355,12 @@ class SleepingBackgroundTask {
     done_with_sleep_ = true;
     bg_cv_.SignalAll();
   }
+  void WaitUntilSleeping() {
+    MutexLock l(&mutex_);
+    while (!sleeping_ || !should_sleep_) {
+      bg_cv_.Wait();
+    }
+  }
   void WakeUp() {
     MutexLock l(&mutex_);
     should_sleep_ = false;
@@ -375,5 +432,258 @@ inline std::string EncodeInt(uint64_t x) {
   return result;
 }
 
+class StringEnv : public EnvWrapper {
+ public:
+  class SeqStringSource : public SequentialFile {
+   public:
+    explicit SeqStringSource(const std::string& data)
+        : data_(data), offset_(0) {}
+    ~SeqStringSource() {}
+    Status Read(size_t n, Slice* result, char* scratch) override {
+      std::string output;
+      if (offset_ < data_.size()) {
+        n = std::min(data_.size() - offset_, n);
+        memcpy(scratch, data_.data() + offset_, n);
+        offset_ += n;
+        *result = Slice(scratch, n);
+      } else {
+        return Status::InvalidArgument(
+            "Attemp to read when it already reached eof.");
+      }
+      return Status::OK();
+    }
+    Status Skip(uint64_t n) override {
+      if (offset_ >= data_.size()) {
+        return Status::InvalidArgument(
+            "Attemp to read when it already reached eof.");
+      }
+      // TODO(yhchiang): Currently doesn't handle the overflow case.
+      offset_ += n;
+      return Status::OK();
+    }
+
+   private:
+    std::string data_;
+    size_t offset_;
+  };
+
+  class StringSink : public WritableFile {
+   public:
+    explicit StringSink(std::string* contents)
+        : WritableFile(), contents_(contents) {}
+    virtual Status Truncate(uint64_t size) override {
+      contents_->resize(size);
+      return Status::OK();
+    }
+    virtual Status Close() override { return Status::OK(); }
+    virtual Status Flush() override { return Status::OK(); }
+    virtual Status Sync() override { return Status::OK(); }
+    virtual Status Append(const Slice& slice) override {
+      contents_->append(slice.data(), slice.size());
+      return Status::OK();
+    }
+
+   private:
+    std::string* contents_;
+  };
+
+  explicit StringEnv(Env* t) : EnvWrapper(t) {}
+  virtual ~StringEnv() {}
+
+  const std::string& GetContent(const std::string& f) { return files_[f]; }
+
+  const Status WriteToNewFile(const std::string& file_name,
+                              const std::string& content) {
+    unique_ptr<WritableFile> r;
+    auto s = NewWritableFile(file_name, &r, EnvOptions());
+    if (!s.ok()) {
+      return s;
+    }
+    r->Append(content);
+    r->Flush();
+    r->Close();
+    assert(files_[file_name] == content);
+    return Status::OK();
+  }
+
+  // The following text is boilerplate that forwards all methods to target()
+  Status NewSequentialFile(const std::string& f, unique_ptr<SequentialFile>* r,
+                           const EnvOptions& options) override {
+    auto iter = files_.find(f);
+    if (iter == files_.end()) {
+      return Status::NotFound("The specified file does not exist", f);
+    }
+    r->reset(new SeqStringSource(iter->second));
+    return Status::OK();
+  }
+  Status NewRandomAccessFile(const std::string& f,
+                             unique_ptr<RandomAccessFile>* r,
+                             const EnvOptions& options) override {
+    return Status::NotSupported();
+  }
+  Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
+                         const EnvOptions& options) override {
+    auto iter = files_.find(f);
+    if (iter != files_.end()) {
+      return Status::IOError("The specified file already exists", f);
+    }
+    r->reset(new StringSink(&files_[f]));
+    return Status::OK();
+  }
+  virtual Status NewDirectory(const std::string& name,
+                              unique_ptr<Directory>* result) override {
+    return Status::NotSupported();
+  }
+  Status FileExists(const std::string& f) override {
+    if (files_.find(f) == files_.end()) {
+      return Status::NotFound();
+    }
+    return Status::OK();
+  }
+  Status GetChildren(const std::string& dir,
+                     std::vector<std::string>* r) override {
+    return Status::NotSupported();
+  }
+  Status DeleteFile(const std::string& f) override {
+    files_.erase(f);
+    return Status::OK();
+  }
+  Status CreateDir(const std::string& d) override {
+    return Status::NotSupported();
+  }
+  Status CreateDirIfMissing(const std::string& d) override {
+    return Status::NotSupported();
+  }
+  Status DeleteDir(const std::string& d) override {
+    return Status::NotSupported();
+  }
+  Status GetFileSize(const std::string& f, uint64_t* s) override {
+    auto iter = files_.find(f);
+    if (iter == files_.end()) {
+      return Status::NotFound("The specified file does not exist:", f);
+    }
+    *s = iter->second.size();
+    return Status::OK();
+  }
+
+  Status GetFileModificationTime(const std::string& fname,
+                                 uint64_t* file_mtime) override {
+    return Status::NotSupported();
+  }
+
+  Status RenameFile(const std::string& s, const std::string& t) override {
+    return Status::NotSupported();
+  }
+
+  Status LinkFile(const std::string& s, const std::string& t) override {
+    return Status::NotSupported();
+  }
+
+  Status LockFile(const std::string& f, FileLock** l) override {
+    return Status::NotSupported();
+  }
+
+  Status UnlockFile(FileLock* l) override { return Status::NotSupported(); }
+
+ protected:
+  std::unordered_map<std::string, std::string> files_;
+};
+
+// Randomly initialize the given DBOptions
+void RandomInitDBOptions(DBOptions* db_opt, Random* rnd);
+
+// Randomly initialize the given ColumnFamilyOptions
+// Note that the caller is responsible for releasing non-null
+// cf_opt->compaction_filter.
+void RandomInitCFOptions(ColumnFamilyOptions* cf_opt, Random* rnd);
+
+// A dummy merge operator which can change its name
+class ChanglingMergeOperator : public MergeOperator {
+ public:
+  explicit ChanglingMergeOperator(const std::string& name)
+      : name_(name + "MergeOperator") {}
+  ~ChanglingMergeOperator() {}
+
+  void SetName(const std::string& name) { name_ = name; }
+
+  virtual bool FullMerge(const Slice& key, const Slice* existing_value,
+                         const std::deque<std::string>& operand_list,
+                         std::string* new_value,
+                         Logger* logger) const override {
+    return false;
+  }
+  virtual bool PartialMergeMulti(const Slice& key,
+                                 const std::deque<Slice>& operand_list,
+                                 std::string* new_value,
+                                 Logger* logger) const override {
+    return false;
+  }
+  virtual const char* Name() const override { return name_.c_str(); }
+
+ protected:
+  std::string name_;
+};
+
+// Returns a dummy merge operator with random name.
+MergeOperator* RandomMergeOperator(Random* rnd);
+
+// A dummy compaction filter which can change its name
+class ChanglingCompactionFilter : public CompactionFilter {
+ public:
+  explicit ChanglingCompactionFilter(const std::string& name)
+      : name_(name + "CompactionFilter") {}
+  ~ChanglingCompactionFilter() {}
+
+  void SetName(const std::string& name) { name_ = name; }
+
+  bool Filter(int level, const Slice& key, const Slice& existing_value,
+              std::string* new_value, bool* value_changed) const override {
+    return false;
+  }
+
+  const char* Name() const override { return name_.c_str(); }
+
+ private:
+  std::string name_;
+};
+
+// Returns a dummy compaction filter with a random name.
+CompactionFilter* RandomCompactionFilter(Random* rnd);
+
+// A dummy compaction filter factory which can change its name
+class ChanglingCompactionFilterFactory : public CompactionFilterFactory {
+ public:
+  explicit ChanglingCompactionFilterFactory(const std::string& name)
+      : name_(name + "CompactionFilterFactory") {}
+  ~ChanglingCompactionFilterFactory() {}
+
+  void SetName(const std::string& name) { name_ = name; }
+
+  std::unique_ptr<CompactionFilter> CreateCompactionFilter(
+      const CompactionFilter::Context& context) override {
+    return std::unique_ptr<CompactionFilter>();
+  }
+
+  // Returns a name that identifies this compaction filter factory.
+  const char* Name() const override { return name_.c_str(); }
+
+ protected:
+  std::string name_;
+};
+
+CompressionType RandomCompressionType(Random* rnd);
+
+void RandomCompressionTypeVector(const size_t count,
+                                 std::vector<CompressionType>* types,
+                                 Random* rnd);
+
+CompactionFilterFactory* RandomCompactionFilterFactory(Random* rnd);
+
+const SliceTransform* RandomSliceTransform(Random* rnd, int pre_defined = -1);
+
+TableFactory* RandomTableFactory(Random* rnd, int pre_defined = -1);
+
+std::string RandomName(Random* rnd, const size_t len);
+
 }  // namespace test
 }  // namespace rocksdb
diff --git a/src/rocksdb/util/thread_local.cc b/src/rocksdb/util/thread_local.cc
index 21adf4f..7fb7a27 100644
--- a/src/rocksdb/util/thread_local.cc
+++ b/src/rocksdb/util/thread_local.cc
@@ -14,7 +14,6 @@
 
 namespace rocksdb {
 
-port::Mutex ThreadLocalPtr::StaticMeta::mutex_;
 #if ROCKSDB_SUPPORT_THREAD_LOCAL
 __thread ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::tls_ = nullptr;
 #endif
@@ -103,11 +102,33 @@ PIMAGE_TLS_CALLBACK p_thread_callback_on_exit = wintlscleanup::WinOnThreadExit;
 
 #endif  // OS_WIN
 
+void ThreadLocalPtr::InitSingletons() {
+  ThreadLocalPtr::StaticMeta::InitSingletons();
+  ThreadLocalPtr::Instance();
+}
+
 ThreadLocalPtr::StaticMeta* ThreadLocalPtr::Instance() {
+  // Here we prefer function static variable instead of global
+  // static variable as function static variable is initialized
+  // when the function is first call.  As a result, we can properly
+  // control their construction order by properly preparing their
+  // first function call.
   static ThreadLocalPtr::StaticMeta inst;
   return &inst;
 }
 
+void ThreadLocalPtr::StaticMeta::InitSingletons() { Mutex(); }
+
+port::Mutex* ThreadLocalPtr::StaticMeta::Mutex() {
+  // Here we prefer function static variable instead of global
+  // static variable as function static variable is initialized
+  // when the function is first call.  As a result, we can properly
+  // control their construction order by properly preparing their
+  // first function call.
+  static port::Mutex mutex;
+  return &mutex;
+}
+
 void ThreadLocalPtr::StaticMeta::OnThreadExit(void* ptr) {
   auto* tls = static_cast<ThreadData*>(ptr);
   assert(tls != nullptr);
@@ -115,7 +136,7 @@ void ThreadLocalPtr::StaticMeta::OnThreadExit(void* ptr) {
   auto* inst = Instance();
   pthread_setspecific(inst->pthread_key_, nullptr);
 
-  MutexLock l(&mutex_);
+  MutexLock l(Mutex());
   inst->RemoveThreadData(tls);
   // Unref stored pointers of current thread from all instances
   uint32_t id = 0;
@@ -175,7 +196,7 @@ ThreadLocalPtr::StaticMeta::StaticMeta() : next_instance_id_(0) {
 }
 
 void ThreadLocalPtr::StaticMeta::AddThreadData(ThreadLocalPtr::ThreadData* d) {
-  mutex_.AssertHeld();
+  Mutex()->AssertHeld();
   d->next = &head_;
   d->prev = head_.prev;
   head_.prev->next = d;
@@ -184,7 +205,7 @@ void ThreadLocalPtr::StaticMeta::AddThreadData(ThreadLocalPtr::ThreadData* d) {
 
 void ThreadLocalPtr::StaticMeta::RemoveThreadData(
     ThreadLocalPtr::ThreadData* d) {
-  mutex_.AssertHeld();
+  Mutex()->AssertHeld();
   d->next->prev = d->prev;
   d->prev->next = d->next;
   d->next = d->prev = d;
@@ -204,14 +225,14 @@ ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::GetThreadLocal() {
     {
       // Register it in the global chain, needs to be done before thread exit
       // handler registration
-      MutexLock l(&mutex_);
+      MutexLock l(Mutex());
       inst->AddThreadData(tls_);
     }
     // Even it is not OS_MACOSX, need to register value for pthread_key_ so that
     // its exit handler will be triggered.
     if (pthread_setspecific(inst->pthread_key_, tls_) != 0) {
       {
-        MutexLock l(&mutex_);
+        MutexLock l(Mutex());
         inst->RemoveThreadData(tls_);
       }
       delete tls_;
@@ -233,7 +254,7 @@ void ThreadLocalPtr::StaticMeta::Reset(uint32_t id, void* ptr) {
   auto* tls = GetThreadLocal();
   if (UNLIKELY(id >= tls->entries.size())) {
     // Need mutex to protect entries access within ReclaimId
-    MutexLock l(&mutex_);
+    MutexLock l(Mutex());
     tls->entries.resize(id + 1);
   }
   tls->entries[id].ptr.store(ptr, std::memory_order_release);
@@ -243,7 +264,7 @@ void* ThreadLocalPtr::StaticMeta::Swap(uint32_t id, void* ptr) {
   auto* tls = GetThreadLocal();
   if (UNLIKELY(id >= tls->entries.size())) {
     // Need mutex to protect entries access within ReclaimId
-    MutexLock l(&mutex_);
+    MutexLock l(Mutex());
     tls->entries.resize(id + 1);
   }
   return tls->entries[id].ptr.exchange(ptr, std::memory_order_acquire);
@@ -254,7 +275,7 @@ bool ThreadLocalPtr::StaticMeta::CompareAndSwap(uint32_t id, void* ptr,
   auto* tls = GetThreadLocal();
   if (UNLIKELY(id >= tls->entries.size())) {
     // Need mutex to protect entries access within ReclaimId
-    MutexLock l(&mutex_);
+    MutexLock l(Mutex());
     tls->entries.resize(id + 1);
   }
   return tls->entries[id].ptr.compare_exchange_strong(
@@ -263,7 +284,7 @@ bool ThreadLocalPtr::StaticMeta::CompareAndSwap(uint32_t id, void* ptr,
 
 void ThreadLocalPtr::StaticMeta::Scrape(uint32_t id, autovector<void*>* ptrs,
     void* const replacement) {
-  MutexLock l(&mutex_);
+  MutexLock l(Mutex());
   for (ThreadData* t = head_.next; t != &head_; t = t->next) {
     if (id < t->entries.size()) {
       void* ptr =
@@ -276,12 +297,12 @@ void ThreadLocalPtr::StaticMeta::Scrape(uint32_t id, autovector<void*>* ptrs,
 }
 
 void ThreadLocalPtr::StaticMeta::SetHandler(uint32_t id, UnrefHandler handler) {
-  MutexLock l(&mutex_);
+  MutexLock l(Mutex());
   handler_map_[id] = handler;
 }
 
 UnrefHandler ThreadLocalPtr::StaticMeta::GetHandler(uint32_t id) {
-  mutex_.AssertHeld();
+  Mutex()->AssertHeld();
   auto iter = handler_map_.find(id);
   if (iter == handler_map_.end()) {
     return nullptr;
@@ -290,7 +311,7 @@ UnrefHandler ThreadLocalPtr::StaticMeta::GetHandler(uint32_t id) {
 }
 
 uint32_t ThreadLocalPtr::StaticMeta::GetId() {
-  MutexLock l(&mutex_);
+  MutexLock l(Mutex());
   if (free_instance_ids_.empty()) {
     return next_instance_id_++;
   }
@@ -301,7 +322,7 @@ uint32_t ThreadLocalPtr::StaticMeta::GetId() {
 }
 
 uint32_t ThreadLocalPtr::StaticMeta::PeekId() const {
-  MutexLock l(&mutex_);
+  MutexLock l(Mutex());
   if (!free_instance_ids_.empty()) {
     return free_instance_ids_.back();
   }
@@ -311,7 +332,7 @@ uint32_t ThreadLocalPtr::StaticMeta::PeekId() const {
 void ThreadLocalPtr::StaticMeta::ReclaimId(uint32_t id) {
   // This id is not used, go through all thread local data and release
   // corresponding value
-  MutexLock l(&mutex_);
+  MutexLock l(Mutex());
   auto unref = GetHandler(id);
   for (ThreadData* t = head_.next; t != &head_; t = t->next) {
     if (id < t->entries.size()) {
diff --git a/src/rocksdb/util/thread_local.h b/src/rocksdb/util/thread_local.h
index 828a737..7299172 100644
--- a/src/rocksdb/util/thread_local.h
+++ b/src/rocksdb/util/thread_local.h
@@ -54,7 +54,7 @@ class ThreadLocalPtr {
   void* Swap(void* ptr);
 
   // Atomically compare the stored value with expected. Set the new
-  // pointer value to thread local only if the comparision is true.
+  // pointer value to thread local only if the comparison is true.
   // Otherwise, expected returns the stored value.
   // Return true on success, false on failure
   bool CompareAndSwap(void* ptr, void*& expected);
@@ -63,6 +63,15 @@ class ThreadLocalPtr {
   // data for all existing threads
   void Scrape(autovector<void*>* ptrs, void* const replacement);
 
+  // Initialize the static singletons of the ThreadLocalPtr.
+  //
+  // If this function is not called, then the singletons will be
+  // automatically initialized when they are used.
+  //
+  // Calling this function twice or after the singletons have been
+  // initialized will be no-op.
+  static void InitSingletons();
+
  protected:
   struct Entry {
     Entry() : ptr(nullptr) {}
@@ -98,7 +107,7 @@ class ThreadLocalPtr {
 
     // Return the next available Id
     uint32_t GetId();
-    // Return the next availabe Id without claiming it
+    // Return the next available Id without claiming it
     uint32_t PeekId() const;
     // Return the given Id back to the free pool. This also triggers
     // UnrefHandler for associated pointer value (if not NULL) for all threads.
@@ -121,6 +130,15 @@ class ThreadLocalPtr {
     // Register the UnrefHandler for id
     void SetHandler(uint32_t id, UnrefHandler handler);
 
+    // Initialize all the singletons associated with StaticMeta.
+    //
+    // If this function is not called, then the singletons will be
+    // automatically initialized when they are used.
+    //
+    // Calling this function twice or after the singletons have been
+    // initialized will be no-op.
+    static void InitSingletons();
+
    private:
     // Get UnrefHandler for id with acquiring mutex
     // REQUIRES: mutex locked
@@ -153,7 +171,22 @@ class ThreadLocalPtr {
 
     // protect inst, next_instance_id_, free_instance_ids_, head_,
     // ThreadData.entries
-    static port::Mutex mutex_;
+    //
+    // Note that here we prefer function static variable instead of the usual
+    // global static variable.  The reason is that c++ destruction order of
+    // static variables in the reverse order of their construction order.
+    // However, C++ does not guarantee any construction order when global
+    // static variables are defined in different files, while the function
+    // static variables are initialized when their function are first called.
+    // As a result, the construction order of the function static variables
+    // can be controlled by properly invoke their first function calls in
+    // the right order.
+    //
+    // For instance, the following function contains a function static
+    // variable.  We place a dummy function call of this inside
+    // Env::Default() to ensure the construction order of the construction
+    // order.
+    static port::Mutex* Mutex();
 #if ROCKSDB_SUPPORT_THREAD_LOCAL
     // Thread local storage
     static __thread ThreadData* tls_;
diff --git a/src/rocksdb/util/thread_local_test.cc b/src/rocksdb/util/thread_local_test.cc
index a78a849..3688186 100644
--- a/src/rocksdb/util/thread_local_test.cc
+++ b/src/rocksdb/util/thread_local_test.cc
@@ -165,7 +165,9 @@ TEST_F(ThreadLocalTest, ConcurrentReadWriteTest) {
     auto& p = *static_cast<Params*>(ptr);
 
     p.mu->Lock();
-    int own = ++(p.started);
+    // Size_T switches size along with the ptr size
+    // we want to cast to.
+    size_t own = ++(p.started);
     p.cv->SignalAll();
     while (p.started != p.total) {
       p.cv->Wait();
@@ -183,16 +185,16 @@ TEST_F(ThreadLocalTest, ConcurrentReadWriteTest) {
     auto* env = Env::Default();
     auto start = env->NowMicros();
 
-    p.tls1.Reset(reinterpret_cast<int*>(own));
-    p.tls2->Reset(reinterpret_cast<int*>(own + 1));
+    p.tls1.Reset(reinterpret_cast<size_t*>(own));
+    p.tls2->Reset(reinterpret_cast<size_t*>(own + 1));
     // Loop for 1 second
     while (env->NowMicros() - start < 1000 * 1000) {
       for (int iter = 0; iter < 100000; ++iter) {
-        ASSERT_TRUE(p.tls1.Get() == reinterpret_cast<int*>(own));
-        ASSERT_TRUE(p.tls2->Get() == reinterpret_cast<int*>(own + 1));
+        ASSERT_TRUE(p.tls1.Get() == reinterpret_cast<size_t*>(own));
+        ASSERT_TRUE(p.tls2->Get() == reinterpret_cast<size_t*>(own + 1));
         if (p.doWrite) {
-          p.tls1.Reset(reinterpret_cast<int*>(own));
-          p.tls2->Reset(reinterpret_cast<int*>(own + 1));
+          p.tls1.Reset(reinterpret_cast<size_t*>(own));
+          p.tls2->Reset(reinterpret_cast<size_t*>(own + 1));
         }
       }
     }
diff --git a/src/rocksdb/util/thread_posix.cc b/src/rocksdb/util/thread_posix.cc
new file mode 100644
index 0000000..c8c07e2
--- /dev/null
+++ b/src/rocksdb/util/thread_posix.cc
@@ -0,0 +1,250 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+
+#include <atomic>
+#include "util/thread_posix.h"
+#include <unistd.h>
+#ifdef OS_LINUX
+#include <sys/syscall.h>
+#endif
+
+namespace rocksdb {
+
+void ThreadPool::PthreadCall(const char* label, int result) {
+  if (result != 0) {
+    fprintf(stderr, "pthread %s: %s\n", label, strerror(result));
+    abort();
+  }
+}
+
+ThreadPool::ThreadPool()
+    : total_threads_limit_(1),
+      bgthreads_(0),
+      queue_(),
+      queue_len_(0),
+      exit_all_threads_(false),
+      low_io_priority_(false),
+      env_(nullptr) {
+  PthreadCall("mutex_init", pthread_mutex_init(&mu_, nullptr));
+  PthreadCall("cvar_init", pthread_cond_init(&bgsignal_, nullptr));
+}
+
+ThreadPool::~ThreadPool() { assert(bgthreads_.size() == 0U); }
+
+void ThreadPool::JoinAllThreads() {
+  PthreadCall("lock", pthread_mutex_lock(&mu_));
+  assert(!exit_all_threads_);
+  exit_all_threads_ = true;
+  PthreadCall("signalall", pthread_cond_broadcast(&bgsignal_));
+  PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+  for (const auto tid : bgthreads_) {
+    pthread_join(tid, nullptr);
+  }
+  bgthreads_.clear();
+}
+
+void ThreadPool::LowerIOPriority() {
+#ifdef OS_LINUX
+  PthreadCall("lock", pthread_mutex_lock(&mu_));
+  low_io_priority_ = true;
+  PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+#endif
+}
+
+void ThreadPool::BGThread(size_t thread_id) {
+  bool low_io_priority = false;
+  while (true) {
+    // Wait until there is an item that is ready to run
+    PthreadCall("lock", pthread_mutex_lock(&mu_));
+    // Stop waiting if the thread needs to do work or needs to terminate.
+    while (!exit_all_threads_ && !IsLastExcessiveThread(thread_id) &&
+           (queue_.empty() || IsExcessiveThread(thread_id))) {
+      PthreadCall("wait", pthread_cond_wait(&bgsignal_, &mu_));
+    }
+    if (exit_all_threads_) {  // mechanism to let BG threads exit safely
+      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+      break;
+    }
+    if (IsLastExcessiveThread(thread_id)) {
+      // Current thread is the last generated one and is excessive.
+      // We always terminate excessive thread in the reverse order of
+      // generation time.
+      auto terminating_thread = bgthreads_.back();
+      pthread_detach(terminating_thread);
+      bgthreads_.pop_back();
+      if (HasExcessiveThread()) {
+        // There is still at least more excessive thread to terminate.
+        WakeUpAllThreads();
+      }
+      PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+      break;
+    }
+    void (*function)(void*) = queue_.front().function;
+    void* arg = queue_.front().arg;
+    queue_.pop_front();
+    queue_len_.store(static_cast<unsigned int>(queue_.size()),
+                     std::memory_order_relaxed);
+
+    bool decrease_io_priority = (low_io_priority != low_io_priority_);
+    PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+
+#ifdef OS_LINUX
+    if (decrease_io_priority) {
+#define IOPRIO_CLASS_SHIFT (13)
+#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
+      // Put schedule into IOPRIO_CLASS_IDLE class (lowest)
+      // These system calls only have an effect when used in conjunction
+      // with an I/O scheduler that supports I/O priorities. As at
+      // kernel 2.6.17 the only such scheduler is the Completely
+      // Fair Queuing (CFQ) I/O scheduler.
+      // To change scheduler:
+      //  echo cfq > /sys/block/<device_name>/queue/schedule
+      // Tunables to consider:
+      //  /sys/block/<device_name>/queue/slice_idle
+      //  /sys/block/<device_name>/queue/slice_sync
+      syscall(SYS_ioprio_set, 1,  // IOPRIO_WHO_PROCESS
+              0,                  // current thread
+              IOPRIO_PRIO_VALUE(3, 0));
+      low_io_priority = true;
+    }
+#else
+    (void)decrease_io_priority;  // avoid 'unused variable' error
+#endif
+    (*function)(arg);
+  }
+}
+
+// Helper struct for passing arguments when creating threads.
+struct BGThreadMetadata {
+  ThreadPool* thread_pool_;
+  size_t thread_id_;  // Thread count in the thread.
+  explicit BGThreadMetadata(ThreadPool* thread_pool, size_t thread_id)
+      : thread_pool_(thread_pool), thread_id_(thread_id) {}
+};
+
+static void* BGThreadWrapper(void* arg) {
+  BGThreadMetadata* meta = reinterpret_cast<BGThreadMetadata*>(arg);
+  size_t thread_id = meta->thread_id_;
+  ThreadPool* tp = meta->thread_pool_;
+#if ROCKSDB_USING_THREAD_STATUS
+  // for thread-status
+  ThreadStatusUtil::RegisterThread(
+      tp->GetHostEnv(), (tp->GetThreadPriority() == Env::Priority::HIGH
+                             ? ThreadStatus::HIGH_PRIORITY
+                             : ThreadStatus::LOW_PRIORITY));
+#endif
+  delete meta;
+  tp->BGThread(thread_id);
+#if ROCKSDB_USING_THREAD_STATUS
+  ThreadStatusUtil::UnregisterThread();
+#endif
+  return nullptr;
+}
+
+void ThreadPool::WakeUpAllThreads() {
+  PthreadCall("signalall", pthread_cond_broadcast(&bgsignal_));
+}
+
+void ThreadPool::SetBackgroundThreadsInternal(int num, bool allow_reduce) {
+  PthreadCall("lock", pthread_mutex_lock(&mu_));
+  if (exit_all_threads_) {
+    PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+    return;
+  }
+  if (num > total_threads_limit_ ||
+      (num < total_threads_limit_ && allow_reduce)) {
+    total_threads_limit_ = std::max(1, num);
+    WakeUpAllThreads();
+    StartBGThreads();
+  }
+  PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+}
+
+void ThreadPool::IncBackgroundThreadsIfNeeded(int num) {
+  SetBackgroundThreadsInternal(num, false);
+}
+
+void ThreadPool::SetBackgroundThreads(int num) {
+  SetBackgroundThreadsInternal(num, true);
+}
+
+void ThreadPool::StartBGThreads() {
+  // Start background thread if necessary
+  while ((int)bgthreads_.size() < total_threads_limit_) {
+    pthread_t t;
+    PthreadCall("create thread",
+                pthread_create(&t, nullptr, &BGThreadWrapper,
+                               new BGThreadMetadata(this, bgthreads_.size())));
+
+// Set the thread name to aid debugging
+#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+    char name_buf[16];
+    snprintf(name_buf, sizeof name_buf, "rocksdb:bg%" ROCKSDB_PRIszt,
+             bgthreads_.size());
+    name_buf[sizeof name_buf - 1] = '\0';
+    pthread_setname_np(t, name_buf);
+#endif
+#endif
+
+    bgthreads_.push_back(t);
+  }
+}
+
+void ThreadPool::Schedule(void (*function)(void* arg1), void* arg, void* tag) {
+  PthreadCall("lock", pthread_mutex_lock(&mu_));
+
+  if (exit_all_threads_) {
+    PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+    return;
+  }
+
+  StartBGThreads();
+
+  // Add to priority queue
+  queue_.push_back(BGItem());
+  queue_.back().function = function;
+  queue_.back().arg = arg;
+  queue_.back().tag = tag;
+  queue_len_.store(static_cast<unsigned int>(queue_.size()),
+                   std::memory_order_relaxed);
+
+  if (!HasExcessiveThread()) {
+    // Wake up at least one waiting thread.
+    PthreadCall("signal", pthread_cond_signal(&bgsignal_));
+  } else {
+    // Need to wake up all threads to make sure the one woken
+    // up is not the one to terminate.
+    WakeUpAllThreads();
+  }
+
+  PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+}
+
+int ThreadPool::UnSchedule(void* arg) {
+  int count = 0;
+  PthreadCall("lock", pthread_mutex_lock(&mu_));
+
+  // Remove from priority queue
+  BGQueue::iterator it = queue_.begin();
+  while (it != queue_.end()) {
+    if (arg == (*it).tag) {
+      it = queue_.erase(it);
+      count++;
+    } else {
+      it++;
+    }
+  }
+  queue_len_.store(static_cast<unsigned int>(queue_.size()),
+                   std::memory_order_relaxed);
+  PthreadCall("unlock", pthread_mutex_unlock(&mu_));
+  return count;
+}
+
+}  // namespace rocksdb
diff --git a/src/rocksdb/util/thread_posix.h b/src/rocksdb/util/thread_posix.h
new file mode 100644
index 0000000..28db0d7
--- /dev/null
+++ b/src/rocksdb/util/thread_posix.h
@@ -0,0 +1,86 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+//
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+#pragma once
+#include "rocksdb/env.h"
+#include "util/thread_status_util.h"
+
+namespace rocksdb {
+
+class ThreadPool {
+ public:
+  ThreadPool();
+  ~ThreadPool();
+
+  void JoinAllThreads();
+  void LowerIOPriority();
+  void BGThread(size_t thread_id);
+  void WakeUpAllThreads();
+  void IncBackgroundThreadsIfNeeded(int num);
+  void SetBackgroundThreads(int num);
+  void StartBGThreads();
+  void Schedule(void (*function)(void* arg1), void* arg, void* tag);
+  int UnSchedule(void* arg);
+
+  unsigned int GetQueueLen() const {
+    return queue_len_.load(std::memory_order_relaxed);
+  }
+
+  void SetHostEnv(Env* env) { env_ = env; }
+  Env* GetHostEnv() { return env_; }
+
+  // Return true if there is at least one thread needs to terminate.
+  bool HasExcessiveThread() {
+    return static_cast<int>(bgthreads_.size()) > total_threads_limit_;
+  }
+
+  // Return true iff the current thread is the excessive thread to terminate.
+  // Always terminate the running thread that is added last, even if there are
+  // more than one thread to terminate.
+  bool IsLastExcessiveThread(size_t thread_id) {
+    return HasExcessiveThread() && thread_id == bgthreads_.size() - 1;
+  }
+
+  // Is one of the threads to terminate.
+  bool IsExcessiveThread(size_t thread_id) {
+    return static_cast<int>(thread_id) >= total_threads_limit_;
+  }
+
+  // Return the thread priority.
+  // This would allow its member-thread to know its priority.
+  Env::Priority GetThreadPriority() { return priority_; }
+
+  // Set the thread priority.
+  void SetThreadPriority(Env::Priority priority) { priority_ = priority; }
+
+  static void PthreadCall(const char* label, int result);
+
+ private:
+  // Entry per Schedule() call
+  struct BGItem {
+    void* arg;
+    void (*function)(void*);
+    void* tag;
+  };
+  typedef std::deque<BGItem> BGQueue;
+
+  pthread_mutex_t mu_;
+  pthread_cond_t bgsignal_;
+  int total_threads_limit_;
+  std::vector<pthread_t> bgthreads_;
+  BGQueue queue_;
+  std::atomic_uint queue_len_;  // Queue length. Used for stats reporting
+  bool exit_all_threads_;
+  bool low_io_priority_;
+  Env::Priority priority_;
+  Env* env_;
+
+  void SetBackgroundThreadsInternal(int num, bool allow_reduce);
+};
+
+}  // namespace rocksdb
diff --git a/src/rocksdb/util/vectorrep.cc b/src/rocksdb/util/vectorrep.cc
index 017f89f..324439a 100644
--- a/src/rocksdb/util/vectorrep.cc
+++ b/src/rocksdb/util/vectorrep.cc
@@ -14,9 +14,9 @@
 
 #include "util/arena.h"
 #include "db/memtable.h"
+#include "memtable/stl_wrappers.h"
 #include "port/port.h"
 #include "util/mutexlock.h"
-#include "util/stl_wrappers.h"
 
 namespace rocksdb {
 namespace {
diff --git a/src/rocksdb/util/xxhash.cc b/src/rocksdb/util/xxhash.cc
index 3204cbb..7bd8002 100644
--- a/src/rocksdb/util/xxhash.cc
+++ b/src/rocksdb/util/xxhash.cc
@@ -65,6 +65,7 @@ You can contact the author at :
 // Disable some Visual warning messages
 #ifdef _MSC_VER  // Visual Studio
 #  pragma warning(disable : 4127)      // disable: C4127: conditional expression is constant
+#  pragma warning(disable : 4804)      // disable: C4804: 'operation' : unsafe use of type 'bool' in operation (static assert line 313)
 #endif
 
 #ifdef _MSC_VER    // Visual Studio
diff --git a/src/rocksdb/utilities/backupable/backupable_db.cc b/src/rocksdb/utilities/backupable/backupable_db.cc
index 16f6d52..3a3d152 100644
--- a/src/rocksdb/utilities/backupable/backupable_db.cc
+++ b/src/rocksdb/utilities/backupable/backupable_db.cc
@@ -180,7 +180,8 @@ class BackupEngineImpl : public BackupEngine {
       return files_;
     }
 
-    Status LoadFromFile(const std::string& backup_dir);
+    Status LoadFromFile(const std::string& backup_dir,
+                        bool use_size_in_file_name);
     Status StoreToFile(bool sync);
 
     std::string GetInfoString() {
@@ -542,7 +543,8 @@ Status BackupEngineImpl::Initialize() {
   } else {  // Load data from storage
     // load the backups if any
     for (auto& backup : backups_) {
-      Status s = backup.second->LoadFromFile(options_.backup_dir);
+      Status s = backup.second->LoadFromFile(
+          options_.backup_dir, options_.use_file_size_in_file_name);
       if (!s.ok()) {
         Log(options_.info_log, "Backup %u corrupted -- %s", backup.first,
             s.ToString().c_str());
@@ -1451,6 +1453,55 @@ Status BackupEngineImpl::BackupMeta::Delete(bool delete_meta) {
   return s;
 }
 
+namespace {
+bool ParseStrToUint64(const std::string& str, uint64_t* out) {
+  try {
+    unsigned long ul = std::stoul(str);
+    *out = static_cast<uint64_t>(ul);
+    return true;
+  } catch (const std::invalid_argument&) {
+    return false;
+  } catch (const std::out_of_range&) {
+    return false;
+  }
+}
+
+// Parse file name in the format of
+// "shared_checksum/<file_number>_<checksum>_<size>.sst, and fill `size` with
+// the parsed <size> part.
+// Will also accept only name part, or a file path in URL format.
+// if file name doesn't have the extension of "sst", or doesn't have '_' as a
+// part of the file name, or we can't parse a number from the sub string
+// between the last '_' and '.', return false.
+bool GetFileSizeFromBackupFileName(const std::string full_name,
+                                   uint64_t* size) {
+  auto dot_pos = full_name.find_last_of('.');
+  if (dot_pos == std::string::npos) {
+    return false;
+  }
+  if (full_name.substr(dot_pos + 1) != "sst") {
+    return false;
+  }
+  auto last_underscore_pos = full_name.find_last_of('_');
+  if (last_underscore_pos == std::string::npos) {
+    return false;
+  }
+  if (dot_pos <= last_underscore_pos + 2) {
+    return false;
+  }
+  return ParseStrToUint64(full_name.substr(last_underscore_pos + 1,
+                                           dot_pos - last_underscore_pos - 1),
+                          size);
+}
+}  // namespace
+
+namespace test {
+bool TEST_GetFileSizeFromBackupFileName(const std::string full_name,
+                                        uint64_t* size) {
+  return GetFileSizeFromBackupFileName(full_name, size);
+}
+}  // namespace test
+
 // each backup meta file is of the format:
 // <timestamp>
 // <seq number>
@@ -1458,8 +1509,8 @@ Status BackupEngineImpl::BackupMeta::Delete(bool delete_meta) {
 // <file1> <crc32(literal string)> <crc32_value>
 // <file2> <crc32(literal string)> <crc32_value>
 // ...
-Status BackupEngineImpl::BackupMeta::LoadFromFile(
-    const std::string& backup_dir) {
+Status BackupEngineImpl::BackupMeta::LoadFromFile(const std::string& backup_dir,
+                                                  bool use_size_in_file_name) {
   assert(Empty());
   Status s;
   unique_ptr<SequentialFile> backup_meta_file;
@@ -1501,9 +1552,12 @@ Status BackupEngineImpl::BackupMeta::LoadFromFile(
     if (file_info) {
       size = file_info->size;
     } else {
-      s = env_->GetFileSize(backup_dir + "/" + filename, &size);
-      if (!s.ok()) {
-        return s;
+      if (!use_size_in_file_name ||
+          !GetFileSizeFromBackupFileName(filename, &size)) {
+        s = env_->GetFileSize(backup_dir + "/" + filename, &size);
+        if (!s.ok()) {
+          return s;
+        }
       }
     }
 
diff --git a/src/rocksdb/utilities/backupable/backupable_db_test.cc b/src/rocksdb/utilities/backupable/backupable_db_test.cc
index 5e4d690..b4f56bf 100644
--- a/src/rocksdb/utilities/backupable/backupable_db_test.cc
+++ b/src/rocksdb/utilities/backupable/backupable_db_test.cc
@@ -26,6 +26,7 @@
 #include "util/testutil.h"
 #include "util/auto_roll_logger.h"
 #include "util/mock_env.h"
+#include "utilities/backupable/backupable_db_testutil.h"
 
 namespace rocksdb {
 
@@ -424,9 +425,14 @@ class BackupableDBTest : public testing::Test {
     options_.write_buffer_size = 1 << 17; // 128KB
     options_.env = test_db_env_.get();
     options_.wal_dir = dbname_;
+
+    // Create logger
+    DBOptions logger_options;
+    logger_options.env = env_;
+    logger_options.db_log_dir = backupdir_;
+    CreateLoggerFromOptions(dbname_, logger_options, &logger_);
+
     // set up backup db options
-    CreateLoggerFromOptions(dbname_, backupdir_, env_,
-                            DBOptions(), &logger_);
     backupable_options_.reset(new BackupableDBOptions(
         backupdir_, test_backup_env_.get(), true, logger_.get(), true));
 
@@ -443,9 +449,15 @@ class BackupableDBTest : public testing::Test {
     return db;
   }
 
+  void OpenDBAndBackupEngineShareWithChecksum(
+      bool destroy_old_data = false, bool dummy = false,
+      bool share_table_files = true, bool share_with_checksums = false) {
+    backupable_options_->share_files_with_checksum = share_with_checksums;
+    OpenDBAndBackupEngine(destroy_old_data, dummy, share_with_checksums);
+  }
+
   void OpenDBAndBackupEngine(bool destroy_old_data = false, bool dummy = false,
-                             bool share_table_files = true,
-                             bool share_with_checksums = false) {
+                             bool share_table_files = true) {
     // reset all the defaults
     test_backup_env_->SetLimitWrittenFiles(1000000);
     test_db_env_->SetLimitWrittenFiles(1000000);
@@ -461,7 +473,6 @@ class BackupableDBTest : public testing::Test {
     db_.reset(db);
     backupable_options_->destroy_old_data = destroy_old_data;
     backupable_options_->share_table_files = share_table_files;
-    backupable_options_->share_files_with_checksum = share_with_checksums;
     BackupEngine* backup_engine;
     ASSERT_OK(BackupEngine::Open(test_db_env_.get(), *backupable_options_,
                                  &backup_engine));
@@ -547,8 +558,10 @@ class BackupableDBTest : public testing::Test {
 
   // options
   Options options_;
-  unique_ptr<BackupableDBOptions> backupable_options_;
   std::shared_ptr<Logger> logger_;
+
+ protected:
+  unique_ptr<BackupableDBOptions> backupable_options_;
 }; // BackupableDBTest
 
 void AppendPath(const std::string& path, std::vector<std::string>& v) {
@@ -557,6 +570,201 @@ void AppendPath(const std::string& path, std::vector<std::string>& v) {
   }
 }
 
+class BackupableDBTestWithParam : public BackupableDBTest,
+                                  public testing::WithParamInterface<bool> {
+ public:
+  BackupableDBTestWithParam() {
+    backupable_options_->share_files_with_checksum =
+        backupable_options_->use_file_size_in_file_name = GetParam();
+  }
+};
+
+// This test verifies that the verifyBackup method correctly identifies
+// invalid backups
+TEST_P(BackupableDBTestWithParam, VerifyBackup) {
+  const int keys_iteration = 5000;
+  Random rnd(6);
+  Status s;
+  OpenDBAndBackupEngine(true);
+  // create five backups
+  for (int i = 0; i < 5; ++i) {
+    FillDB(db_.get(), keys_iteration * i, keys_iteration * (i + 1));
+    ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true));
+  }
+  CloseDBAndBackupEngine();
+
+  OpenDBAndBackupEngine();
+  // ---------- case 1. - valid backup -----------
+  ASSERT_TRUE(backup_engine_->VerifyBackup(1).ok());
+
+  // ---------- case 2. - delete a file -----------i
+  file_manager_->DeleteRandomFileInDir(backupdir_ + "/private/1");
+  ASSERT_TRUE(backup_engine_->VerifyBackup(1).IsNotFound());
+
+  // ---------- case 3. - corrupt a file -----------
+  std::string append_data = "Corrupting a random file";
+  file_manager_->AppendToRandomFileInDir(backupdir_ + "/private/2",
+                                         append_data);
+  ASSERT_TRUE(backup_engine_->VerifyBackup(2).IsCorruption());
+
+  // ---------- case 4. - invalid backup -----------
+  ASSERT_TRUE(backup_engine_->VerifyBackup(6).IsNotFound());
+  CloseDBAndBackupEngine();
+}
+
+// open DB, write, close DB, backup, restore, repeat
+TEST_P(BackupableDBTestWithParam, OfflineIntegrationTest) {
+  // has to be a big number, so that it triggers the memtable flush
+  const int keys_iteration = 5000;
+  const int max_key = keys_iteration * 4 + 10;
+  // first iter -- flush before backup
+  // second iter -- don't flush before backup
+  for (int iter = 0; iter < 2; ++iter) {
+    // delete old data
+    DestroyDB(dbname_, Options());
+    bool destroy_data = true;
+
+    // every iteration --
+    // 1. insert new data in the DB
+    // 2. backup the DB
+    // 3. destroy the db
+    // 4. restore the db, check everything is still there
+    for (int i = 0; i < 5; ++i) {
+      // in last iteration, put smaller amount of data,
+      int fill_up_to = std::min(keys_iteration * (i + 1), max_key);
+      // ---- insert new data and back up ----
+      OpenDBAndBackupEngine(destroy_data);
+      destroy_data = false;
+      FillDB(db_.get(), keys_iteration * i, fill_up_to);
+      ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), iter == 0));
+      CloseDBAndBackupEngine();
+      DestroyDB(dbname_, Options());
+
+      // ---- make sure it's empty ----
+      DB* db = OpenDB();
+      AssertEmpty(db, 0, fill_up_to);
+      delete db;
+
+      // ---- restore the DB ----
+      OpenBackupEngine();
+      if (i >= 3) {  // test purge old backups
+        // when i == 4, purge to only 1 backup
+        // when i == 3, purge to 2 backups
+        ASSERT_OK(backup_engine_->PurgeOldBackups(5 - i));
+      }
+      // ---- make sure the data is there ---
+      AssertBackupConsistency(0, 0, fill_up_to, max_key);
+      CloseBackupEngine();
+    }
+  }
+}
+
+// open DB, write, backup, write, backup, close, restore
+TEST_P(BackupableDBTestWithParam, OnlineIntegrationTest) {
+  // has to be a big number, so that it triggers the memtable flush
+  const int keys_iteration = 5000;
+  const int max_key = keys_iteration * 4 + 10;
+  Random rnd(7);
+  // delete old data
+  DestroyDB(dbname_, Options());
+
+  OpenDBAndBackupEngine(true);
+  // write some data, backup, repeat
+  for (int i = 0; i < 5; ++i) {
+    if (i == 4) {
+      // delete backup number 2, online delete!
+      ASSERT_OK(backup_engine_->DeleteBackup(2));
+    }
+    // in last iteration, put smaller amount of data,
+    // so that backups can share sst files
+    int fill_up_to = std::min(keys_iteration * (i + 1), max_key);
+    FillDB(db_.get(), keys_iteration * i, fill_up_to);
+    // we should get consistent results with flush_before_backup
+    // set to both true and false
+    ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), !!(rnd.Next() % 2)));
+  }
+  // close and destroy
+  CloseDBAndBackupEngine();
+  DestroyDB(dbname_, Options());
+
+  // ---- make sure it's empty ----
+  DB* db = OpenDB();
+  AssertEmpty(db, 0, max_key);
+  delete db;
+
+  // ---- restore every backup and verify all the data is there ----
+  OpenBackupEngine();
+  for (int i = 1; i <= 5; ++i) {
+    if (i == 2) {
+      // we deleted backup 2
+      Status s = backup_engine_->RestoreDBFromBackup(2, dbname_, dbname_);
+      ASSERT_TRUE(!s.ok());
+    } else {
+      int fill_up_to = std::min(keys_iteration * i, max_key);
+      AssertBackupConsistency(i, 0, fill_up_to, max_key);
+    }
+  }
+
+  // delete some backups -- this should leave only backups 3 and 5 alive
+  ASSERT_OK(backup_engine_->DeleteBackup(4));
+  ASSERT_OK(backup_engine_->PurgeOldBackups(2));
+
+  std::vector<BackupInfo> backup_info;
+  backup_engine_->GetBackupInfo(&backup_info);
+  ASSERT_EQ(2UL, backup_info.size());
+
+  // check backup 3
+  AssertBackupConsistency(3, 0, 3 * keys_iteration, max_key);
+  // check backup 5
+  AssertBackupConsistency(5, 0, max_key);
+
+  CloseBackupEngine();
+}
+
+INSTANTIATE_TEST_CASE_P(BackupableDBTestWithParam, BackupableDBTestWithParam,
+                        ::testing::Bool());
+
+TEST_F(BackupableDBTest, GetFileSizeFromBackupFileName) {
+  uint64_t size = 0;
+
+  ASSERT_TRUE(test::TEST_GetFileSizeFromBackupFileName(
+      "shared_checksum/6580354_1874793674_65806675.sst", &size));
+  ASSERT_EQ(65806675u, size);
+
+  ASSERT_TRUE(test::TEST_GetFileSizeFromBackupFileName(
+      "hdfs://a.b:80/a/b/shared_checksum/6580354_1874793674_85806675.sst",
+      &size));
+  ASSERT_EQ(85806675u, size);
+
+  ASSERT_TRUE(test::TEST_GetFileSizeFromBackupFileName(
+      "6580354_1874793674_65806665.sst", &size));
+  ASSERT_EQ(65806665u, size);
+
+  ASSERT_TRUE(test::TEST_GetFileSizeFromBackupFileName(
+      "private/66/6580354_1874793674_65806666.sst", &size));
+  ASSERT_EQ(65806666u, size);
+
+  ASSERT_TRUE(!test::TEST_GetFileSizeFromBackupFileName(
+                  "shared_checksum/6580354.sst", &size));
+
+  ASSERT_TRUE(!test::TEST_GetFileSizeFromBackupFileName(
+                  "private/368/6592388.log", &size));
+
+  ASSERT_TRUE(!test::TEST_GetFileSizeFromBackupFileName(
+                  "private/68/MANIFEST-6586581", &size));
+
+  ASSERT_TRUE(
+      !test::TEST_GetFileSizeFromBackupFileName("private/68/CURRENT", &size));
+
+  ASSERT_TRUE(!test::TEST_GetFileSizeFromBackupFileName(
+                  "shared_checksum/6580354_1874793674_65806675.log", &size));
+
+  ASSERT_TRUE(!test::TEST_GetFileSizeFromBackupFileName(
+                  "shared_checksum/6580354_1874793674_65806675", &size));
+
+  ASSERT_TRUE(!test::TEST_GetFileSizeFromBackupFileName("meta/368", &size));
+}
+
 // this will make sure that backup does not copy the same file twice
 TEST_F(BackupableDBTest, NoDoubleCopy) {
   OpenDBAndBackupEngine(true, true);
@@ -783,39 +991,6 @@ TEST_F(BackupableDBTest, CorruptionsTest) {
   AssertBackupConsistency(2, 0, keys_iteration * 2, keys_iteration * 5);
 }
 
-// This test verifies that the verifyBackup method correctly identifies
-// invalid backups
-TEST_F(BackupableDBTest, VerifyBackup) {
-  const int keys_iteration = 5000;
-  Random rnd(6);
-  Status s;
-  OpenDBAndBackupEngine(true);
-  // create five backups
-  for (int i = 0; i < 5; ++i) {
-    FillDB(db_.get(), keys_iteration * i, keys_iteration * (i + 1));
-    ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true));
-  }
-  CloseDBAndBackupEngine();
-
-  OpenDBAndBackupEngine();
-  // ---------- case 1. - valid backup -----------
-  ASSERT_TRUE(backup_engine_->VerifyBackup(1).ok());
-
-  // ---------- case 2. - delete a file -----------i
-  file_manager_->DeleteRandomFileInDir(backupdir_ + "/private/1");
-  ASSERT_TRUE(backup_engine_->VerifyBackup(1).IsNotFound());
-
-  // ---------- case 3. - corrupt a file -----------
-  std::string append_data = "Corrupting a random file";
-  file_manager_->AppendToRandomFileInDir(backupdir_ + "/private/2",
-                                         append_data);
-  ASSERT_TRUE(backup_engine_->VerifyBackup(2).IsCorruption());
-
-  // ---------- case 4. - invalid backup -----------
-  ASSERT_TRUE(backup_engine_->VerifyBackup(6).IsNotFound());
-  CloseDBAndBackupEngine();
-}
-
 // This test verifies we don't delete the latest backup when read-only option is
 // set
 TEST_F(BackupableDBTest, NoDeleteWithReadOnly) {
@@ -850,115 +1025,6 @@ TEST_F(BackupableDBTest, NoDeleteWithReadOnly) {
   delete read_only_backup_engine;
 }
 
-// open DB, write, close DB, backup, restore, repeat
-TEST_F(BackupableDBTest, OfflineIntegrationTest) {
-  // has to be a big number, so that it triggers the memtable flush
-  const int keys_iteration = 5000;
-  const int max_key = keys_iteration * 4 + 10;
-  // first iter -- flush before backup
-  // second iter -- don't flush before backup
-  for (int iter = 0; iter < 2; ++iter) {
-    // delete old data
-    DestroyDB(dbname_, Options());
-    bool destroy_data = true;
-
-    // every iteration --
-    // 1. insert new data in the DB
-    // 2. backup the DB
-    // 3. destroy the db
-    // 4. restore the db, check everything is still there
-    for (int i = 0; i < 5; ++i) {
-      // in last iteration, put smaller amount of data,
-      int fill_up_to = std::min(keys_iteration * (i + 1), max_key);
-      // ---- insert new data and back up ----
-      OpenDBAndBackupEngine(destroy_data);
-      destroy_data = false;
-      FillDB(db_.get(), keys_iteration * i, fill_up_to);
-      ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), iter == 0));
-      CloseDBAndBackupEngine();
-      DestroyDB(dbname_, Options());
-
-      // ---- make sure it's empty ----
-      DB* db = OpenDB();
-      AssertEmpty(db, 0, fill_up_to);
-      delete db;
-
-      // ---- restore the DB ----
-      OpenBackupEngine();
-      if (i >= 3) {  // test purge old backups
-        // when i == 4, purge to only 1 backup
-        // when i == 3, purge to 2 backups
-        ASSERT_OK(backup_engine_->PurgeOldBackups(5 - i));
-      }
-      // ---- make sure the data is there ---
-      AssertBackupConsistency(0, 0, fill_up_to, max_key);
-      CloseBackupEngine();
-    }
-  }
-}
-
-// open DB, write, backup, write, backup, close, restore
-TEST_F(BackupableDBTest, OnlineIntegrationTest) {
-  // has to be a big number, so that it triggers the memtable flush
-  const int keys_iteration = 5000;
-  const int max_key = keys_iteration * 4 + 10;
-  Random rnd(7);
-  // delete old data
-  DestroyDB(dbname_, Options());
-
-  OpenDBAndBackupEngine(true);
-  // write some data, backup, repeat
-  for (int i = 0; i < 5; ++i) {
-    if (i == 4) {
-      // delete backup number 2, online delete!
-      ASSERT_OK(backup_engine_->DeleteBackup(2));
-    }
-    // in last iteration, put smaller amount of data,
-    // so that backups can share sst files
-    int fill_up_to = std::min(keys_iteration * (i + 1), max_key);
-    FillDB(db_.get(), keys_iteration * i, fill_up_to);
-    // we should get consistent results with flush_before_backup
-    // set to both true and false
-    ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), !!(rnd.Next() % 2)));
-  }
-  // close and destroy
-  CloseDBAndBackupEngine();
-  DestroyDB(dbname_, Options());
-
-  // ---- make sure it's empty ----
-  DB* db = OpenDB();
-  AssertEmpty(db, 0, max_key);
-  delete db;
-
-  // ---- restore every backup and verify all the data is there ----
-  OpenBackupEngine();
-  for (int i = 1; i <= 5; ++i) {
-    if (i == 2) {
-      // we deleted backup 2
-      Status s = backup_engine_->RestoreDBFromBackup(2, dbname_, dbname_);
-      ASSERT_TRUE(!s.ok());
-    } else {
-      int fill_up_to = std::min(keys_iteration * i, max_key);
-      AssertBackupConsistency(i, 0, fill_up_to, max_key);
-    }
-  }
-
-  // delete some backups -- this should leave only backups 3 and 5 alive
-  ASSERT_OK(backup_engine_->DeleteBackup(4));
-  ASSERT_OK(backup_engine_->PurgeOldBackups(2));
-
-  std::vector<BackupInfo> backup_info;
-  backup_engine_->GetBackupInfo(&backup_info);
-  ASSERT_EQ(2UL, backup_info.size());
-
-  // check backup 3
-  AssertBackupConsistency(3, 0, 3 * keys_iteration, max_key);
-  // check backup 5
-  AssertBackupConsistency(5, 0, max_key);
-
-  CloseBackupEngine();
-}
-
 TEST_F(BackupableDBTest, FailOverwritingBackups) {
   options_.write_buffer_size = 1024 * 1024 * 1024;  // 1GB
   options_.disable_auto_compactions = true;
@@ -1014,7 +1080,7 @@ TEST_F(BackupableDBTest, NoShareTableFiles) {
 // Verify that you can backup and restore with share_files_with_checksum on
 TEST_F(BackupableDBTest, ShareTableFilesWithChecksums) {
   const int keys_iteration = 5000;
-  OpenDBAndBackupEngine(true, false, true, true);
+  OpenDBAndBackupEngineShareWithChecksum(true, false, true, true);
   for (int i = 0; i < 5; ++i) {
     FillDB(db_.get(), keys_iteration * i, keys_iteration * (i + 1));
     ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), !!(i % 2)));
@@ -1032,7 +1098,7 @@ TEST_F(BackupableDBTest, ShareTableFilesWithChecksums) {
 TEST_F(BackupableDBTest, ShareTableFilesWithChecksumsTransition) {
   const int keys_iteration = 5000;
   // set share_files_with_checksum to false
-  OpenDBAndBackupEngine(true, false, true, false);
+  OpenDBAndBackupEngineShareWithChecksum(true, false, true, false);
   for (int i = 0; i < 5; ++i) {
     FillDB(db_.get(), keys_iteration * i, keys_iteration * (i + 1));
     ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true));
@@ -1045,7 +1111,7 @@ TEST_F(BackupableDBTest, ShareTableFilesWithChecksumsTransition) {
   }
 
   // set share_files_with_checksum to true and do some more backups
-  OpenDBAndBackupEngine(true, false, true, true);
+  OpenDBAndBackupEngineShareWithChecksum(true, false, true, true);
   for (int i = 5; i < 10; ++i) {
     FillDB(db_.get(), keys_iteration * i, keys_iteration * (i + 1));
     ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), true));
@@ -1193,18 +1259,18 @@ TEST_F(BackupableDBTest, GarbageCollectionBeforeBackup) {
   OpenDBAndBackupEngine(true);
 
   env_->CreateDirIfMissing(backupdir_ + "/shared");
-  std::string file_five = backupdir_ + "/shared/000005.sst";
+  std::string file_five = backupdir_ + "/shared/000007.sst";
   std::string file_five_contents = "I'm not really a sst file";
-  // this depends on the fact that 00005.sst is the first file created by the DB
+  // this depends on the fact that 00007.sst is the first file created by the DB
   ASSERT_OK(file_manager_->WriteToFile(file_five, file_five_contents));
 
   FillDB(db_.get(), 0, 100);
-  // backup overwrites file 000005.sst
+  // backup overwrites file 000007.sst
   ASSERT_TRUE(backup_engine_->CreateNewBackup(db_.get(), true).ok());
 
   std::string new_file_five_contents;
   ASSERT_OK(ReadFileToString(env_, file_five, &new_file_five_contents));
-  // file 000005.sst was overwritten
+  // file 000007.sst was overwritten
   ASSERT_TRUE(new_file_five_contents != file_five_contents);
 
   CloseDBAndBackupEngine();
@@ -1247,7 +1313,6 @@ TEST_F(BackupableDBTest, EnvFailures) {
     delete backup_engine;
   }
 }
-
 }  // anon namespace
 
 } //  namespace rocksdb
diff --git a/src/rocksdb/table/table_properties_internal.h b/src/rocksdb/utilities/backupable/backupable_db_testutil.h
similarity index 58%
copy from src/rocksdb/table/table_properties_internal.h
copy to src/rocksdb/utilities/backupable/backupable_db_testutil.h
index 9ef8ad4..6c45f33 100644
--- a/src/rocksdb/table/table_properties_internal.h
+++ b/src/rocksdb/utilities/backupable/backupable_db_testutil.h
@@ -2,17 +2,14 @@
 //  This source code is licensed under the BSD-style license found in the
 //  LICENSE file in the root directory of this source tree. An additional grant
 //  of patent rights can be found in the PATENTS file in the same directory.
-
 #pragma once
-
-#include "rocksdb/status.h"
-#include "rocksdb/iterator.h"
+#ifndef ROCKSDB_LITE
+#include <string>
 
 namespace rocksdb {
-
-// Seek to the properties block.
-// If it successfully seeks to the properties block, "is_found" will be
-// set to true.
-Status SeekToPropertiesBlock(Iterator* meta_iter, bool* is_found);
-
+namespace test {
+extern bool TEST_GetFileSizeFromBackupFileName(const std::string full_name,
+                                               uint64_t* size);
+}  // namespace test
 }  // namespace rocksdb
+#endif  // ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/checkpoint/checkpoint_test.cc b/src/rocksdb/utilities/checkpoint/checkpoint_test.cc
index 5cd72ea..27c1beb 100644
--- a/src/rocksdb/utilities/checkpoint/checkpoint_test.cc
+++ b/src/rocksdb/utilities/checkpoint/checkpoint_test.cc
@@ -10,8 +10,6 @@
 // Syncpoint prevents us building and running tests in release
 #ifndef ROCKSDB_LITE
 
-#if !defined(NDEBUG) || !defined(OS_WIN)
-
 #ifndef OS_WIN
 #include <unistd.h>
 #endif
@@ -350,16 +348,10 @@ TEST_F(DBTest, CheckpointCF) {
 
 }  // namespace rocksdb
 
-#endif
-
 int main(int argc, char** argv) {
-#if !defined(NDEBUG) || !defined(OS_WIN)
   rocksdb::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
 }
 
 #else
diff --git a/src/rocksdb/utilities/document/json_document.cc b/src/rocksdb/utilities/document/json_document.cc
index 99376d2..b8d178b 100644
--- a/src/rocksdb/utilities/document/json_document.cc
+++ b/src/rocksdb/utilities/document/json_document.cc
@@ -588,8 +588,8 @@ JSONDocument::const_item_iterator::~const_item_iterator() {
 
 JSONDocument::const_item_iterator::value_type
   JSONDocument::const_item_iterator::operator*() {
-  return {std::string(it_->getKeyStr(), it_->klen()),
-    JSONDocument(it_->value(), false)};
+  return JSONDocument::const_item_iterator::value_type(std::string(it_->getKeyStr(), it_->klen()),
+    JSONDocument(it_->value(), false));
 }
 
 JSONDocument::ItemsIteratorGenerator::ItemsIteratorGenerator(
diff --git a/src/rocksdb/utilities/document/json_document_builder.cc b/src/rocksdb/utilities/document/json_document_builder.cc
index 0dd4ce4..8cbccc8 100644
--- a/src/rocksdb/utilities/document/json_document_builder.cc
+++ b/src/rocksdb/utilities/document/json_document_builder.cc
@@ -4,6 +4,9 @@
 //  of patent rights can be found in the PATENTS file in the same directory.
 
 #ifndef ROCKSDB_LITE
+#include <assert.h>
+#include <limits>
+#include <stdint.h>
 #include "rocksdb/utilities/json_document.h"
 #include "third-party/fbson/FbsonWriter.h"
 
@@ -38,7 +41,9 @@ bool JSONDocumentBuilder::WriteEndObject() {
 
 bool JSONDocumentBuilder::WriteKeyValue(const std::string& key,
                                         const JSONDocument& value) {
-  size_t bytesWritten = writer_->writeKey(key.c_str(), key.size());
+  assert(key.size() <= std::numeric_limits<uint8_t>::max());
+  size_t bytesWritten = writer_->writeKey(key.c_str(),
+    static_cast<uint8_t>(key.size()));
   if (bytesWritten == 0) {
     return false;
   }
diff --git a/src/rocksdb/utilities/env_mirror.cc b/src/rocksdb/utilities/env_mirror.cc
new file mode 100644
index 0000000..8067113
--- /dev/null
+++ b/src/rocksdb/utilities/env_mirror.cc
@@ -0,0 +1,266 @@
+// Copyright (c) 2015, Red Hat, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file. See the AUTHORS file for names of contributors.
+
+#ifndef ROCKSDB_LITE
+
+#include "rocksdb/utilities/env_mirror.h"
+
+namespace rocksdb {
+
+// An implementaiton of Env that mirrors all work over two backend
+// Env's.  This is useful for debugging purposes.
+class SequentialFileMirror : public SequentialFile {
+ public:
+  unique_ptr<SequentialFile> a_, b_;
+  std::string fname;
+  SequentialFileMirror(std::string f) : fname(f) {}
+
+  Status Read(size_t n, Slice* result, char* scratch) {
+    Slice aslice;
+    Status as = a_->Read(n, &aslice, scratch);
+    if (as == Status::OK()) {
+      char* bscratch = new char[n];
+      Slice bslice;
+      size_t off = 0;
+      size_t left = aslice.size();
+      while (left) {
+        Status bs = b_->Read(left, &bslice, bscratch);
+        assert(as == bs);
+        assert(memcmp(bscratch, scratch + off, bslice.size()) == 0);
+        off += bslice.size();
+        left -= bslice.size();
+      }
+      delete[] bscratch;
+      *result = aslice;
+    } else {
+      Status bs = b_->Read(n, result, scratch);
+      assert(as == bs);
+    }
+    return as;
+  }
+
+  Status Skip(uint64_t n) {
+    Status as = a_->Skip(n);
+    Status bs = b_->Skip(n);
+    assert(as == bs);
+    return as;
+  }
+  Status InvalidateCache(size_t offset, size_t length) {
+    Status as = a_->InvalidateCache(offset, length);
+    Status bs = b_->InvalidateCache(offset, length);
+    assert(as == bs);
+    return as;
+  };
+};
+
+class RandomAccessFileMirror : public RandomAccessFile {
+ public:
+  unique_ptr<RandomAccessFile> a_, b_;
+  std::string fname;
+  RandomAccessFileMirror(std::string f) : fname(f) {}
+
+  Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const {
+    Status as = a_->Read(offset, n, result, scratch);
+    if (as == Status::OK()) {
+      char* bscratch = new char[n];
+      Slice bslice;
+      size_t off = 0;
+      size_t left = result->size();
+      while (left) {
+        Status bs = b_->Read(offset + off, left, &bslice, bscratch);
+        assert(as == bs);
+        assert(memcmp(bscratch, scratch + off, bslice.size()) == 0);
+        off += bslice.size();
+        left -= bslice.size();
+      }
+      delete[] bscratch;
+    } else {
+      Status bs = b_->Read(offset, n, result, scratch);
+      assert(as == bs);
+    }
+    return as;
+  }
+
+  bool ShouldForwardRawRequest() const {
+    // NOTE: not verified
+    return a_->ShouldForwardRawRequest();
+  }
+
+  size_t GetUniqueId(char* id, size_t max_size) const {
+    // NOTE: not verified
+    return a_->GetUniqueId(id, max_size);
+  }
+};
+
+class WritableFileMirror : public WritableFile {
+ public:
+  unique_ptr<WritableFile> a_, b_;
+  std::string fname;
+  WritableFileMirror(std::string f) : fname(f) {}
+
+  Status Append(const Slice& data) override {
+    Status as = a_->Append(data);
+    Status bs = b_->Append(data);
+    assert(as == bs);
+    return as;
+  }
+  Status PositionedAppend(const Slice& data, uint64_t offset) override {
+    Status as = a_->PositionedAppend(data, offset);
+    Status bs = b_->PositionedAppend(data, offset);
+    assert(as == bs);
+    return as;
+  }
+  Status Truncate(uint64_t size) override {
+    Status as = a_->Truncate(size);
+    Status bs = b_->Truncate(size);
+    assert(as == bs);
+    return as;
+  }
+  Status Close() override {
+    Status as = a_->Close();
+    Status bs = b_->Close();
+    assert(as == bs);
+    return as;
+  }
+  Status Flush() override {
+    Status as = a_->Flush();
+    Status bs = b_->Flush();
+    assert(as == bs);
+    return as;
+  }
+  Status Sync() override {
+    Status as = a_->Sync();
+    Status bs = b_->Sync();
+    assert(as == bs);
+    return as;
+  }
+  Status Fsync() override {
+    Status as = a_->Fsync();
+    Status bs = b_->Fsync();
+    assert(as == bs);
+    return as;
+  }
+  bool IsSyncThreadSafe() const override {
+    bool as = a_->IsSyncThreadSafe();
+    bool bs = b_->IsSyncThreadSafe();
+    assert(as == bs);
+    return as;
+  }
+  void SetIOPriority(Env::IOPriority pri) override {
+    a_->SetIOPriority(pri);
+    b_->SetIOPriority(pri);
+  }
+  Env::IOPriority GetIOPriority() override {
+    // NOTE: we don't verify this one
+    return a_->GetIOPriority();
+  }
+  uint64_t GetFileSize() override {
+    uint64_t as = a_->GetFileSize();
+    uint64_t bs = b_->GetFileSize();
+    assert(as == bs);
+    return as;
+  }
+  void GetPreallocationStatus(size_t* block_size,
+                              size_t* last_allocated_block) override {
+    // NOTE: we don't verify this one
+    return a_->GetPreallocationStatus(block_size, last_allocated_block);
+  }
+  size_t GetUniqueId(char* id, size_t max_size) const override {
+    // NOTE: we don't verify this one
+    return a_->GetUniqueId(id, max_size);
+  }
+  Status InvalidateCache(size_t offset, size_t length) override {
+    Status as = a_->InvalidateCache(offset, length);
+    Status bs = b_->InvalidateCache(offset, length);
+    assert(as == bs);
+    return as;
+  }
+
+ protected:
+  Status Allocate(uint64_t offset, uint64_t length) override {
+    Status as = a_->Allocate(offset, length);
+    Status bs = b_->Allocate(offset, length);
+    assert(as == bs);
+    return as;
+  }
+  Status RangeSync(uint64_t offset, uint64_t nbytes) override {
+    Status as = a_->RangeSync(offset, nbytes);
+    Status bs = b_->RangeSync(offset, nbytes);
+    assert(as == bs);
+    return as;
+  }
+};
+
+Status EnvMirror::NewSequentialFile(const std::string& f,
+                                    unique_ptr<SequentialFile>* r,
+                                    const EnvOptions& options) {
+  if (f.find("/proc/") == 0) {
+    return a_->NewSequentialFile(f, r, options);
+  }
+  SequentialFileMirror* mf = new SequentialFileMirror(f);
+  Status as = a_->NewSequentialFile(f, &mf->a_, options);
+  Status bs = b_->NewSequentialFile(f, &mf->b_, options);
+  assert(as == bs);
+  if (as.ok())
+    r->reset(mf);
+  else
+    delete mf;
+  return as;
+}
+
+Status EnvMirror::NewRandomAccessFile(const std::string& f,
+                                      unique_ptr<RandomAccessFile>* r,
+                                      const EnvOptions& options) {
+  if (f.find("/proc/") == 0) {
+    return a_->NewRandomAccessFile(f, r, options);
+  }
+  RandomAccessFileMirror* mf = new RandomAccessFileMirror(f);
+  Status as = a_->NewRandomAccessFile(f, &mf->a_, options);
+  Status bs = b_->NewRandomAccessFile(f, &mf->b_, options);
+  assert(as == bs);
+  if (as.ok())
+    r->reset(mf);
+  else
+    delete mf;
+  return as;
+}
+
+Status EnvMirror::NewWritableFile(const std::string& f,
+                                  unique_ptr<WritableFile>* r,
+                                  const EnvOptions& options) {
+  if (f.find("/proc/") == 0) return a_->NewWritableFile(f, r, options);
+  WritableFileMirror* mf = new WritableFileMirror(f);
+  Status as = a_->NewWritableFile(f, &mf->a_, options);
+  Status bs = b_->NewWritableFile(f, &mf->b_, options);
+  assert(as == bs);
+  if (as.ok())
+    r->reset(mf);
+  else
+    delete mf;
+  return as;
+}
+
+Status EnvMirror::ReuseWritableFile(const std::string& fname,
+                                    const std::string& old_fname,
+                                    unique_ptr<WritableFile>* r,
+                                    const EnvOptions& options) {
+  if (fname.find("/proc/") == 0)
+    return a_->ReuseWritableFile(fname, old_fname, r, options);
+  WritableFileMirror* mf = new WritableFileMirror(fname);
+  Status as = a_->ReuseWritableFile(fname, old_fname, &mf->a_, options);
+  Status bs = b_->ReuseWritableFile(fname, old_fname, &mf->b_, options);
+  assert(as == bs);
+  if (as.ok())
+    r->reset(mf);
+  else
+    delete mf;
+  return as;
+}
+
+}  // namespace rocksdb
+#endif
diff --git a/src/rocksdb/utilities/env_mirror_test.cc b/src/rocksdb/utilities/env_mirror_test.cc
new file mode 100644
index 0000000..845356b
--- /dev/null
+++ b/src/rocksdb/utilities/env_mirror_test.cc
@@ -0,0 +1,222 @@
+//  Copyright (c) 2015, Red Hat, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+
+#include "rocksdb/utilities/env_mirror.h"
+#include "util/mock_env.h"
+#include "util/testharness.h"
+
+namespace rocksdb {
+
+class EnvMirrorTest : public testing::Test {
+ public:
+  Env* default_;
+  MockEnv* a_, *b_;
+  EnvMirror* env_;
+  const EnvOptions soptions_;
+
+  EnvMirrorTest()
+      : default_(Env::Default()),
+        a_(new MockEnv(default_)),
+        b_(new MockEnv(default_)),
+        env_(new EnvMirror(a_, b_)) {}
+  ~EnvMirrorTest() {
+    delete env_;
+    delete a_;
+    delete b_;
+  }
+};
+
+TEST_F(EnvMirrorTest, Basics) {
+  uint64_t file_size;
+  unique_ptr<WritableFile> writable_file;
+  std::vector<std::string> children;
+
+  ASSERT_OK(env_->CreateDir("/dir"));
+
+  // Check that the directory is empty.
+  ASSERT_EQ(Status::NotFound(), env_->FileExists("/dir/non_existent"));
+  ASSERT_TRUE(!env_->GetFileSize("/dir/non_existent", &file_size).ok());
+  ASSERT_OK(env_->GetChildren("/dir", &children));
+  ASSERT_EQ(0U, children.size());
+
+  // Create a file.
+  ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file, soptions_));
+  writable_file.reset();
+
+  // Check that the file exists.
+  ASSERT_OK(env_->FileExists("/dir/f"));
+  ASSERT_OK(a_->FileExists("/dir/f"));
+  ASSERT_OK(b_->FileExists("/dir/f"));
+  ASSERT_OK(env_->GetFileSize("/dir/f", &file_size));
+  ASSERT_EQ(0U, file_size);
+  ASSERT_OK(env_->GetChildren("/dir", &children));
+  ASSERT_EQ(1U, children.size());
+  ASSERT_EQ("f", children[0]);
+  ASSERT_OK(a_->GetChildren("/dir", &children));
+  ASSERT_EQ(1U, children.size());
+  ASSERT_EQ("f", children[0]);
+  ASSERT_OK(b_->GetChildren("/dir", &children));
+  ASSERT_EQ(1U, children.size());
+  ASSERT_EQ("f", children[0]);
+
+  // Write to the file.
+  ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file, soptions_));
+  ASSERT_OK(writable_file->Append("abc"));
+  writable_file.reset();
+
+  // Check for expected size.
+  ASSERT_OK(env_->GetFileSize("/dir/f", &file_size));
+  ASSERT_EQ(3U, file_size);
+  ASSERT_OK(a_->GetFileSize("/dir/f", &file_size));
+  ASSERT_EQ(3U, file_size);
+  ASSERT_OK(b_->GetFileSize("/dir/f", &file_size));
+  ASSERT_EQ(3U, file_size);
+
+  // Check that renaming works.
+  ASSERT_TRUE(!env_->RenameFile("/dir/non_existent", "/dir/g").ok());
+  ASSERT_OK(env_->RenameFile("/dir/f", "/dir/g"));
+  ASSERT_EQ(Status::NotFound(), env_->FileExists("/dir/f"));
+  ASSERT_OK(env_->FileExists("/dir/g"));
+  ASSERT_OK(env_->GetFileSize("/dir/g", &file_size));
+  ASSERT_EQ(3U, file_size);
+  ASSERT_OK(a_->FileExists("/dir/g"));
+  ASSERT_OK(a_->GetFileSize("/dir/g", &file_size));
+  ASSERT_EQ(3U, file_size);
+  ASSERT_OK(b_->FileExists("/dir/g"));
+  ASSERT_OK(b_->GetFileSize("/dir/g", &file_size));
+  ASSERT_EQ(3U, file_size);
+
+  // Check that opening non-existent file fails.
+  unique_ptr<SequentialFile> seq_file;
+  unique_ptr<RandomAccessFile> rand_file;
+  ASSERT_TRUE(
+      !env_->NewSequentialFile("/dir/non_existent", &seq_file, soptions_).ok());
+  ASSERT_TRUE(!seq_file);
+  ASSERT_TRUE(!env_->NewRandomAccessFile("/dir/non_existent", &rand_file,
+                                         soptions_).ok());
+  ASSERT_TRUE(!rand_file);
+
+  // Check that deleting works.
+  ASSERT_TRUE(!env_->DeleteFile("/dir/non_existent").ok());
+  ASSERT_OK(env_->DeleteFile("/dir/g"));
+  ASSERT_EQ(Status::NotFound(), env_->FileExists("/dir/g"));
+  ASSERT_OK(env_->GetChildren("/dir", &children));
+  ASSERT_EQ(0U, children.size());
+  ASSERT_OK(env_->DeleteDir("/dir"));
+}
+
+TEST_F(EnvMirrorTest, ReadWrite) {
+  unique_ptr<WritableFile> writable_file;
+  unique_ptr<SequentialFile> seq_file;
+  unique_ptr<RandomAccessFile> rand_file;
+  Slice result;
+  char scratch[100];
+
+  ASSERT_OK(env_->CreateDir("/dir"));
+
+  ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file, soptions_));
+  ASSERT_OK(writable_file->Append("hello "));
+  ASSERT_OK(writable_file->Append("world"));
+  writable_file.reset();
+
+  // Read sequentially.
+  ASSERT_OK(env_->NewSequentialFile("/dir/f", &seq_file, soptions_));
+  ASSERT_OK(seq_file->Read(5, &result, scratch));  // Read "hello".
+  ASSERT_EQ(0, result.compare("hello"));
+  ASSERT_OK(seq_file->Skip(1));
+  ASSERT_OK(seq_file->Read(1000, &result, scratch));  // Read "world".
+  ASSERT_EQ(0, result.compare("world"));
+  ASSERT_OK(seq_file->Read(1000, &result, scratch));  // Try reading past EOF.
+  ASSERT_EQ(0U, result.size());
+  ASSERT_OK(seq_file->Skip(100));  // Try to skip past end of file.
+  ASSERT_OK(seq_file->Read(1000, &result, scratch));
+  ASSERT_EQ(0U, result.size());
+
+  // Random reads.
+  ASSERT_OK(env_->NewRandomAccessFile("/dir/f", &rand_file, soptions_));
+  ASSERT_OK(rand_file->Read(6, 5, &result, scratch));  // Read "world".
+  ASSERT_EQ(0, result.compare("world"));
+  ASSERT_OK(rand_file->Read(0, 5, &result, scratch));  // Read "hello".
+  ASSERT_EQ(0, result.compare("hello"));
+  ASSERT_OK(rand_file->Read(10, 100, &result, scratch));  // Read "d".
+  ASSERT_EQ(0, result.compare("d"));
+
+  // Too high offset.
+  ASSERT_TRUE(!rand_file->Read(1000, 5, &result, scratch).ok());
+}
+
+TEST_F(EnvMirrorTest, Locks) {
+  FileLock* lock;
+
+  // These are no-ops, but we test they return success.
+  ASSERT_OK(env_->LockFile("some file", &lock));
+  ASSERT_OK(env_->UnlockFile(lock));
+}
+
+TEST_F(EnvMirrorTest, Misc) {
+  std::string test_dir;
+  ASSERT_OK(env_->GetTestDirectory(&test_dir));
+  ASSERT_TRUE(!test_dir.empty());
+
+  unique_ptr<WritableFile> writable_file;
+  ASSERT_OK(env_->NewWritableFile("/a/b", &writable_file, soptions_));
+
+  // These are no-ops, but we test they return success.
+  ASSERT_OK(writable_file->Sync());
+  ASSERT_OK(writable_file->Flush());
+  ASSERT_OK(writable_file->Close());
+  writable_file.reset();
+}
+
+TEST_F(EnvMirrorTest, LargeWrite) {
+  const size_t kWriteSize = 300 * 1024;
+  char* scratch = new char[kWriteSize * 2];
+
+  std::string write_data;
+  for (size_t i = 0; i < kWriteSize; ++i) {
+    write_data.append(1, static_cast<char>(i));
+  }
+
+  unique_ptr<WritableFile> writable_file;
+  ASSERT_OK(env_->NewWritableFile("/dir/f", &writable_file, soptions_));
+  ASSERT_OK(writable_file->Append("foo"));
+  ASSERT_OK(writable_file->Append(write_data));
+  writable_file.reset();
+
+  unique_ptr<SequentialFile> seq_file;
+  Slice result;
+  ASSERT_OK(env_->NewSequentialFile("/dir/f", &seq_file, soptions_));
+  ASSERT_OK(seq_file->Read(3, &result, scratch));  // Read "foo".
+  ASSERT_EQ(0, result.compare("foo"));
+
+  size_t read = 0;
+  std::string read_data;
+  while (read < kWriteSize) {
+    ASSERT_OK(seq_file->Read(kWriteSize - read, &result, scratch));
+    read_data.append(result.data(), result.size());
+    read += result.size();
+  }
+  ASSERT_TRUE(write_data == read_data);
+  delete[] scratch;
+}
+
+}  // namespace rocksdb
+
+int main(int argc, char** argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
+#else
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+  fprintf(stderr, "SKIPPED as EnvMirror is not supported in ROCKSDB_LITE\n");
+  return 0;
+}
+
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/geodb/geodb_impl.cc b/src/rocksdb/utilities/geodb/geodb_impl.cc
index afa2f4c..f509e27 100644
--- a/src/rocksdb/utilities/geodb/geodb_impl.cc
+++ b/src/rocksdb/utilities/geodb/geodb_impl.cc
@@ -159,15 +159,63 @@ Status GeoDBImpl::Remove(const Slice& id) {
   return db_->Write(woptions_, &batch);
 }
 
-Status GeoDBImpl::SearchRadial(const GeoPosition& pos,
+class GeoIteratorImpl : public GeoIterator {
+ private:
+  std::vector<GeoObject> values_;
+  std::vector<GeoObject>::iterator iter_;
+ public:
+  explicit GeoIteratorImpl(std::vector<GeoObject> values)
+    : values_(std::move(values)) {
+    iter_ = values_.begin();
+  }
+  virtual void Next() override;
+  virtual bool Valid() const override;
+  virtual const GeoObject& geo_object() override;
+  virtual Status status() const override;
+};
+
+class GeoErrorIterator : public GeoIterator {
+ private:
+  Status status_;
+ public:
+  explicit GeoErrorIterator(Status s) : status_(s) {}
+  virtual void Next() override {};
+  virtual bool Valid() const override { return false; }
+  virtual const GeoObject& geo_object() override {
+    GeoObject* g = new GeoObject();
+    return *g;
+  }
+  virtual Status status() const override { return status_; }
+};
+
+void GeoIteratorImpl::Next() {
+  assert(Valid());
+  iter_++;
+}
+
+bool GeoIteratorImpl::Valid() const {
+  return iter_ != values_.end();
+}
+
+const GeoObject& GeoIteratorImpl::geo_object() {
+  assert(Valid());
+  return *iter_;
+}
+
+Status GeoIteratorImpl::status() const {
+  return Status::OK();
+}
+
+GeoIterator* GeoDBImpl::SearchRadial(const GeoPosition& pos,
   double radius,
-  std::vector<GeoObject>* values,
   int number_of_values) {
+  std::vector<GeoObject> values;
+
   // Gather all bounding quadkeys
   std::vector<std::string> qids;
   Status s = searchQuadIds(pos, radius, &qids);
   if (!s.ok()) {
-    return s;
+    return new GeoErrorIterator(s);
   }
 
   // create an iterator
@@ -200,7 +248,7 @@ Status GeoDBImpl::SearchRadial(const GeoPosition& pos,
       if (res.first == qid.end()) {
         GeoPosition obj_pos(atof(parts[3].c_str()), atof(parts[4].c_str()));
         GeoObject obj(obj_pos, parts[4], iter->value().ToString());
-        values->push_back(obj);
+        values.push_back(obj);
         number_of_values--;
       } else {
         break;
@@ -208,7 +256,7 @@ Status GeoDBImpl::SearchRadial(const GeoPosition& pos,
     }
   }
   delete iter;
-  return Status::OK();
+  return new GeoIteratorImpl(std::move(values));
 }
 
 std::string GeoDBImpl::MakeKey1(const GeoPosition& pos, Slice id,
diff --git a/src/rocksdb/utilities/geodb/geodb_impl.h b/src/rocksdb/utilities/geodb/geodb_impl.h
index aaf3a25..d631028 100644
--- a/src/rocksdb/utilities/geodb/geodb_impl.h
+++ b/src/rocksdb/utilities/geodb/geodb_impl.h
@@ -46,9 +46,8 @@ class GeoDBImpl : public GeoDB {
 
   // Returns a list of all items within a circular radius from the
   // specified gps location
-  virtual Status SearchRadial(const GeoPosition& pos, double radius,
-                              std::vector<GeoObject>* values,
-                              int number_of_values) override;
+  virtual GeoIterator* SearchRadial(const GeoPosition& pos, double radius,
+                                    int number_of_values) override;
 
  private:
   DB* db_;
diff --git a/src/rocksdb/utilities/geodb/geodb_test.cc b/src/rocksdb/utilities/geodb/geodb_test.cc
index 503e533..503332e 100644
--- a/src/rocksdb/utilities/geodb/geodb_test.cc
+++ b/src/rocksdb/utilities/geodb/geodb_test.cc
@@ -103,17 +103,23 @@ TEST_F(GeoDBTest, Search) {
   // search all objects centered at 46 degree latitude with
   // a radius of 200 kilometers. We should find the one object that
   // we inserted earlier.
-  std::vector<GeoObject> values;
-  status = getdb()->SearchRadial(GeoPosition(46, 46), 200000, &values);
+  GeoIterator* iter1 = getdb()->SearchRadial(GeoPosition(46, 46), 200000);
   ASSERT_TRUE(status.ok());
-  ASSERT_EQ(values.size(), 1U);
+  ASSERT_EQ(iter1->geo_object().value, "midvalue1");
+  uint32_t size = 0;
+  while (iter1->Valid()) {
+    size++;
+    iter1->Next();
+  }
+  ASSERT_EQ(size, 1U);
+  delete iter1;
 
   // search all objects centered at 46 degree latitude with
   // a radius of 2 kilometers. There should be none.
-  values.clear();
-  status = getdb()->SearchRadial(GeoPosition(46, 46), 2, &values);
+  GeoIterator* iter2 = getdb()->SearchRadial(GeoPosition(46, 46), 2);
   ASSERT_TRUE(status.ok());
-  ASSERT_EQ(values.size(), 0U);
+  ASSERT_FALSE(iter2->Valid());
+  delete iter2;
 }
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/utilities/memory/memory_test.cc b/src/rocksdb/utilities/memory/memory_test.cc
new file mode 100644
index 0000000..0795147
--- /dev/null
+++ b/src/rocksdb/utilities/memory/memory_test.cc
@@ -0,0 +1,274 @@
+// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+
+#include "db/db_impl.h"
+#include "rocksdb/cache.h"
+#include "rocksdb/table.h"
+#include "rocksdb/utilities/memory_util.h"
+#include "rocksdb/utilities/stackable_db.h"
+#include "table/block_based_table_factory.h"
+#include "util/string_util.h"
+#include "util/testharness.h"
+#include "util/testutil.h"
+
+namespace rocksdb {
+
+class MemoryTest : public testing::Test {
+ public:
+  MemoryTest() : kDbDir(test::TmpDir() + "/memory_test"), rnd_(301) {
+    assert(Env::Default()->CreateDirIfMissing(kDbDir).ok());
+  }
+
+  std::string GetDBName(int id) { return kDbDir + "db_" + ToString(id); }
+
+  std::string RandomString(int len) {
+    std::string r;
+    test::RandomString(&rnd_, len, &r);
+    return r;
+  }
+
+  void UpdateUsagesHistory(const std::vector<DB*>& dbs) {
+    std::map<MemoryUtil::UsageType, uint64_t> usage_by_type;
+    ASSERT_OK(GetApproximateMemoryUsageByType(dbs, &usage_by_type));
+    for (int i = 0; i < MemoryUtil::kNumUsageTypes; ++i) {
+      usage_history_[i].push_back(
+          usage_by_type[static_cast<MemoryUtil::UsageType>(i)]);
+    }
+  }
+
+  void GetCachePointersFromTableFactory(
+      const TableFactory* factory,
+      std::unordered_set<const Cache*>* cache_set) {
+    const BlockBasedTableFactory* bbtf =
+        dynamic_cast<const BlockBasedTableFactory*>(factory);
+    if (bbtf != nullptr) {
+      const auto bbt_opts = bbtf->table_options();
+      cache_set->insert(bbt_opts.block_cache.get());
+      cache_set->insert(bbt_opts.block_cache_compressed.get());
+    }
+  }
+
+  void GetCachePointers(const std::vector<DB*>& dbs,
+                        std::unordered_set<const Cache*>* cache_set) {
+    cache_set->clear();
+
+    for (auto* db : dbs) {
+      // Cache from DBImpl
+      StackableDB* sdb = dynamic_cast<StackableDB*>(db);
+      DBImpl* db_impl = dynamic_cast<DBImpl*>(sdb ? sdb->GetBaseDB() : db);
+      if (db_impl != nullptr) {
+        cache_set->insert(db_impl->TEST_table_cache());
+      }
+
+      // Cache from DBOptions
+      cache_set->insert(db->GetDBOptions().row_cache.get());
+
+      // Cache from table factories
+      std::unordered_map<std::string, const ImmutableCFOptions*> iopts_map;
+      if (db_impl != nullptr) {
+        ASSERT_OK(db_impl->TEST_GetAllImmutableCFOptions(&iopts_map));
+      }
+      for (auto pair : iopts_map) {
+        GetCachePointersFromTableFactory(pair.second->table_factory, cache_set);
+      }
+    }
+  }
+
+  Status GetApproximateMemoryUsageByType(
+      const std::vector<DB*>& dbs,
+      std::map<MemoryUtil::UsageType, uint64_t>* usage_by_type) {
+    std::unordered_set<const Cache*> cache_set;
+    GetCachePointers(dbs, &cache_set);
+
+    return MemoryUtil::GetApproximateMemoryUsageByType(dbs, cache_set,
+                                                       usage_by_type);
+  }
+
+  const std::string kDbDir;
+  Random rnd_;
+  std::vector<uint64_t> usage_history_[MemoryUtil::kNumUsageTypes];
+};
+
+TEST_F(MemoryTest, SharedBlockCacheTotal) {
+  std::vector<DB*> dbs;
+  std::vector<uint64_t> usage_by_type;
+  const int kNumDBs = 10;
+  const int kKeySize = 100;
+  const int kValueSize = 500;
+  Options opt;
+  opt.create_if_missing = true;
+  opt.write_buffer_size = kKeySize + kValueSize;
+  opt.max_write_buffer_number = 10;
+  opt.min_write_buffer_number_to_merge = 10;
+  BlockBasedTableOptions bbt_opts;
+  bbt_opts.block_cache = NewLRUCache(4096 * 1000 * 10);
+  for (int i = 0; i < kNumDBs; ++i) {
+    DestroyDB(GetDBName(i), opt);
+    DB* db = nullptr;
+    ASSERT_OK(DB::Open(opt, GetDBName(i), &db));
+    dbs.push_back(db);
+  }
+
+  std::vector<std::string> keys_by_db[kNumDBs];
+
+  // Fill one memtable per Put to make memtable use more memory.
+  for (int p = 0; p < opt.min_write_buffer_number_to_merge / 2; ++p) {
+    for (int i = 0; i < kNumDBs; ++i) {
+      for (int j = 0; j < 100; ++j) {
+        keys_by_db[i].emplace_back(RandomString(kKeySize));
+        dbs[i]->Put(WriteOptions(), keys_by_db[i].back(),
+                    RandomString(kValueSize));
+      }
+      dbs[i]->Flush(FlushOptions());
+    }
+  }
+  for (int i = 0; i < kNumDBs; ++i) {
+    for (auto& key : keys_by_db[i]) {
+      std::string value;
+      dbs[i]->Get(ReadOptions(), key, &value);
+    }
+    UpdateUsagesHistory(dbs);
+  }
+  for (size_t i = 1; i < usage_history_[MemoryUtil::kMemTableTotal].size();
+       ++i) {
+    // Expect EQ as we didn't flush more memtables.
+    ASSERT_EQ(usage_history_[MemoryUtil::kTableReadersTotal][i],
+              usage_history_[MemoryUtil::kTableReadersTotal][i - 1]);
+  }
+  for (int i = 0; i < kNumDBs; ++i) {
+    delete dbs[i];
+  }
+}
+
+TEST_F(MemoryTest, MemTableAndTableReadersTotal) {
+  std::vector<DB*> dbs;
+  std::vector<uint64_t> usage_by_type;
+  std::vector<std::vector<ColumnFamilyHandle*>> vec_handles;
+  const int kNumDBs = 10;
+  const int kKeySize = 100;
+  const int kValueSize = 500;
+  Options opt;
+  opt.create_if_missing = true;
+  opt.create_missing_column_families = true;
+  opt.write_buffer_size = kKeySize + kValueSize;
+  opt.max_write_buffer_number = 10;
+  opt.min_write_buffer_number_to_merge = 10;
+
+  std::vector<ColumnFamilyDescriptor> cf_descs = {
+      {kDefaultColumnFamilyName, ColumnFamilyOptions(opt)},
+      {"one", ColumnFamilyOptions(opt)},
+      {"two", ColumnFamilyOptions(opt)},
+  };
+
+  for (int i = 0; i < kNumDBs; ++i) {
+    DestroyDB(GetDBName(i), opt);
+    std::vector<ColumnFamilyHandle*> handles;
+    dbs.emplace_back();
+    vec_handles.emplace_back();
+    ASSERT_OK(DB::Open(DBOptions(opt), GetDBName(i), cf_descs,
+                       &vec_handles.back(), &dbs.back()));
+  }
+
+  // Fill one memtable per Put to make memtable use more memory.
+  for (int p = 0; p < opt.min_write_buffer_number_to_merge / 2; ++p) {
+    for (int i = 0; i < kNumDBs; ++i) {
+      for (auto* handle : vec_handles[i]) {
+        dbs[i]->Put(WriteOptions(), handle, RandomString(kKeySize),
+                    RandomString(kValueSize));
+        UpdateUsagesHistory(dbs);
+      }
+    }
+  }
+  // Expect the usage history is monotonically increasing
+  for (size_t i = 1; i < usage_history_[MemoryUtil::kMemTableTotal].size();
+       ++i) {
+    ASSERT_GT(usage_history_[MemoryUtil::kMemTableTotal][i],
+              usage_history_[MemoryUtil::kMemTableTotal][i - 1]);
+    ASSERT_GT(usage_history_[MemoryUtil::kMemTableUnFlushed][i],
+              usage_history_[MemoryUtil::kMemTableUnFlushed][i - 1]);
+    ASSERT_EQ(usage_history_[MemoryUtil::kTableReadersTotal][i],
+              usage_history_[MemoryUtil::kTableReadersTotal][i - 1]);
+  }
+
+  size_t usage_check_point = usage_history_[MemoryUtil::kMemTableTotal].size();
+  std::vector<Iterator*> iters;
+
+  // Create an iterator and flush all memtables for each db
+  for (int i = 0; i < kNumDBs; ++i) {
+    iters.push_back(dbs[i]->NewIterator(ReadOptions()));
+    dbs[i]->Flush(FlushOptions());
+
+    for (int j = 0; j < 100; ++j) {
+      std::string value;
+      dbs[i]->Get(ReadOptions(), RandomString(kKeySize), &value);
+    }
+
+    UpdateUsagesHistory(dbs);
+  }
+  for (size_t i = usage_check_point;
+       i < usage_history_[MemoryUtil::kMemTableTotal].size(); ++i) {
+    // Since memtables are pinned by iterators, we don't expect the
+    // memory usage of all the memtables decreases as they are pinned
+    // by iterators.
+    ASSERT_GE(usage_history_[MemoryUtil::kMemTableTotal][i],
+              usage_history_[MemoryUtil::kMemTableTotal][i - 1]);
+    // Expect the usage history from the "usage_decay_point" is
+    // monotonically decreasing.
+    ASSERT_LT(usage_history_[MemoryUtil::kMemTableUnFlushed][i],
+              usage_history_[MemoryUtil::kMemTableUnFlushed][i - 1]);
+    // Expect the usage history of the table readers increases
+    // as we flush tables.
+    ASSERT_GT(usage_history_[MemoryUtil::kTableReadersTotal][i],
+              usage_history_[MemoryUtil::kTableReadersTotal][i - 1]);
+    ASSERT_GT(usage_history_[MemoryUtil::kCacheTotal][i],
+              usage_history_[MemoryUtil::kCacheTotal][i - 1]);
+  }
+  usage_check_point = usage_history_[MemoryUtil::kMemTableTotal].size();
+  for (int i = 0; i < kNumDBs; ++i) {
+    delete iters[i];
+    UpdateUsagesHistory(dbs);
+  }
+  for (size_t i = usage_check_point;
+       i < usage_history_[MemoryUtil::kMemTableTotal].size(); ++i) {
+    // Expect the usage of all memtables decreasing as we delete iterators.
+    ASSERT_LT(usage_history_[MemoryUtil::kMemTableTotal][i],
+              usage_history_[MemoryUtil::kMemTableTotal][i - 1]);
+    // Since the memory usage of un-flushed memtables is only affected
+    // by Put and flush, we expect EQ here as we only delete iterators.
+    ASSERT_EQ(usage_history_[MemoryUtil::kMemTableUnFlushed][i],
+              usage_history_[MemoryUtil::kMemTableUnFlushed][i - 1]);
+    // Expect EQ as we didn't flush more memtables.
+    ASSERT_EQ(usage_history_[MemoryUtil::kTableReadersTotal][i],
+              usage_history_[MemoryUtil::kTableReadersTotal][i - 1]);
+  }
+
+  for (int i = 0; i < kNumDBs; ++i) {
+    for (auto* handle : vec_handles[i]) {
+      delete handle;
+    }
+    delete dbs[i];
+  }
+}
+}  // namespace rocksdb
+
+int main(int argc, char** argv) {
+#if !(defined NDEBUG) || !defined(OS_WIN)
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+#else
+  return 0;
+#endif
+}
+
+#else
+#include <cstdio>
+
+int main(int argc, char** argv) {
+  printf("Skipped in RocksDBLite as utilities are not supported.\n");
+  return 0;
+}
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/memory/memory_util.cc b/src/rocksdb/utilities/memory/memory_util.cc
new file mode 100644
index 0000000..f558017
--- /dev/null
+++ b/src/rocksdb/utilities/memory/memory_util.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+
+#include "rocksdb/utilities/memory_util.h"
+
+#include "db/db_impl.h"
+
+namespace rocksdb {
+
+Status MemoryUtil::GetApproximateMemoryUsageByType(
+    const std::vector<DB*>& dbs,
+    const std::unordered_set<const Cache*> cache_set,
+    std::map<MemoryUtil::UsageType, uint64_t>* usage_by_type) {
+  usage_by_type->clear();
+
+  // MemTable
+  for (auto* db : dbs) {
+    uint64_t usage = 0;
+    if (db->GetAggregatedIntProperty(DB::Properties::kSizeAllMemTables,
+                                     &usage)) {
+      (*usage_by_type)[MemoryUtil::kMemTableTotal] += usage;
+    }
+    if (db->GetAggregatedIntProperty(DB::Properties::kCurSizeAllMemTables,
+                                     &usage)) {
+      (*usage_by_type)[MemoryUtil::kMemTableUnFlushed] += usage;
+    }
+  }
+
+  // Table Readers
+  for (auto* db : dbs) {
+    uint64_t usage = 0;
+    if (db->GetAggregatedIntProperty(DB::Properties::kEstimateTableReadersMem,
+                                     &usage)) {
+      (*usage_by_type)[MemoryUtil::kTableReadersTotal] += usage;
+    }
+  }
+
+  // Cache
+  for (const auto* cache : cache_set) {
+    if (cache != nullptr) {
+      (*usage_by_type)[MemoryUtil::kCacheTotal] += cache->GetUsage();
+    }
+  }
+
+  return Status::OK();
+}
+}  // namespace rocksdb
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/merge_operators/string_append/stringappend.cc b/src/rocksdb/utilities/merge_operators/string_append/stringappend.cc
index 38cd22e..ff19348 100644
--- a/src/rocksdb/utilities/merge_operators/string_append/stringappend.cc
+++ b/src/rocksdb/utilities/merge_operators/string_append/stringappend.cc
@@ -55,6 +55,3 @@ std::shared_ptr<MergeOperator> MergeOperators::CreateStringAppendOperator() {
 }
 
 } // namespace rocksdb
-
-
-
diff --git a/src/rocksdb/utilities/merge_operators/string_append/stringappend.h b/src/rocksdb/utilities/merge_operators/string_append/stringappend.h
index ca5b97e..621d151 100644
--- a/src/rocksdb/utilities/merge_operators/string_append/stringappend.h
+++ b/src/rocksdb/utilities/merge_operators/string_append/stringappend.h
@@ -12,7 +12,8 @@ namespace rocksdb {
 
 class StringAppendOperator : public AssociativeMergeOperator {
  public:
-  StringAppendOperator(char delim_char);    /// Constructor: specify delimiter
+  // Constructor: specify delimiter
+  explicit StringAppendOperator(char delim_char);
 
   virtual bool Merge(const Slice& key,
                      const Slice* existing_value,
@@ -28,4 +29,3 @@ class StringAppendOperator : public AssociativeMergeOperator {
 };
 
 } // namespace rocksdb
-
diff --git a/src/rocksdb/utilities/merge_operators/string_append/stringappend2.cc b/src/rocksdb/utilities/merge_operators/string_append/stringappend2.cc
index 1dd8262..cceb8d5 100644
--- a/src/rocksdb/utilities/merge_operators/string_append/stringappend2.cc
+++ b/src/rocksdb/utilities/merge_operators/string_append/stringappend2.cc
@@ -110,4 +110,3 @@ MergeOperators::CreateStringAppendTESTOperator() {
 }
 
 } // namespace rocksdb
-
diff --git a/src/rocksdb/utilities/options/options_util.cc b/src/rocksdb/utilities/options/options_util.cc
new file mode 100644
index 0000000..1c6a068
--- /dev/null
+++ b/src/rocksdb/utilities/options/options_util.cc
@@ -0,0 +1,99 @@
+// Copyright (c) 2014, Facebook, Inc.  All rights reserved.
+// This source code is licensed under the BSD-style license found in the
+// LICENSE file in the root directory of this source tree. An additional grant
+// of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+
+#include "rocksdb/utilities/options_util.h"
+
+#include "db/filename.h"
+#include "rocksdb/options.h"
+#include "util/options_parser.h"
+
+namespace rocksdb {
+Status LoadOptionsFromFile(const std::string& file_name, Env* env,
+                           DBOptions* db_options,
+                           std::vector<ColumnFamilyDescriptor>* cf_descs) {
+  RocksDBOptionsParser parser;
+  Status s = parser.Parse(file_name, env);
+  if (!s.ok()) {
+    return s;
+  }
+
+  *db_options = *parser.db_opt();
+
+  const std::vector<std::string>& cf_names = *parser.cf_names();
+  const std::vector<ColumnFamilyOptions>& cf_opts = *parser.cf_opts();
+  cf_descs->clear();
+  for (size_t i = 0; i < cf_opts.size(); ++i) {
+    cf_descs->push_back({cf_names[i], cf_opts[i]});
+  }
+  return Status::OK();
+}
+
+Status GetLatestOptionsFileName(const std::string& dbpath,
+                                Env* env, std::string* options_file_name) {
+  Status s;
+  std::string latest_file_name;
+  uint64_t latest_time_stamp = 0;
+  std::vector<std::string> file_names;
+  s = env->GetChildren(dbpath, &file_names);
+  if (!s.ok()) {
+    return s;
+  }
+  for (auto& file_name : file_names) {
+    uint64_t time_stamp;
+    FileType type;
+    if (ParseFileName(file_name, &time_stamp, &type) && type == kOptionsFile) {
+      if (time_stamp > latest_time_stamp) {
+        latest_time_stamp = time_stamp;
+        latest_file_name = file_name;
+      }
+    }
+  }
+  if (latest_file_name.size() == 0) {
+    return Status::NotFound("No options files found in the DB directory.");
+  }
+  *options_file_name = latest_file_name;
+  return Status::OK();
+}
+
+Status LoadLatestOptions(const std::string& dbpath, Env* env,
+                         DBOptions* db_options,
+                         std::vector<ColumnFamilyDescriptor>* cf_descs) {
+  std::string options_file_name;
+  Status s = GetLatestOptionsFileName(dbpath, env, &options_file_name);
+  if (!s.ok()) {
+    return s;
+  }
+
+  return LoadOptionsFromFile(dbpath + "/" + options_file_name, env,
+                             db_options, cf_descs);
+}
+
+Status CheckOptionsCompatibility(
+    const std::string& dbpath, Env* env, const DBOptions& db_options,
+    const std::vector<ColumnFamilyDescriptor>& cf_descs) {
+  std::string options_file_name;
+  Status s = GetLatestOptionsFileName(dbpath, env, &options_file_name);
+  if (!s.ok()) {
+    return s;
+  }
+
+  std::vector<std::string> cf_names;
+  std::vector<ColumnFamilyOptions> cf_opts;
+  for (const auto& cf_desc : cf_descs) {
+    cf_names.push_back(cf_desc.name);
+    cf_opts.push_back(cf_desc.options);
+  }
+
+  const OptionsSanityCheckLevel kDefaultLevel = kSanityLevelLooselyCompatible;
+
+  return RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
+      db_options, cf_names, cf_opts, dbpath + "/" + options_file_name, env,
+      kDefaultLevel);
+}
+
+}  // namespace rocksdb
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/options/options_util_test.cc b/src/rocksdb/utilities/options/options_util_test.cc
new file mode 100644
index 0000000..c6d8cdb
--- /dev/null
+++ b/src/rocksdb/utilities/options/options_util_test.cc
@@ -0,0 +1,287 @@
+//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
+//  This source code is licensed under the BSD-style license found in the
+//  LICENSE file in the root directory of this source tree. An additional grant
+//  of patent rights can be found in the PATENTS file in the same directory.
+
+#ifndef ROCKSDB_LITE
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
+#include <inttypes.h>
+
+#include <cctype>
+#include <unordered_map>
+
+#include "rocksdb/db.h"
+#include "rocksdb/table.h"
+#include "rocksdb/utilities/options_util.h"
+#include "util/options_parser.h"
+#include "util/random.h"
+#include "util/testharness.h"
+#include "util/testutil.h"
+
+#ifndef GFLAGS
+bool FLAGS_enable_print = false;
+#else
+#include <gflags/gflags.h>
+using GFLAGS::ParseCommandLineFlags;
+DEFINE_bool(enable_print, false, "Print options generated to console.");
+#endif  // GFLAGS
+
+namespace rocksdb {
+class OptionsUtilTest : public testing::Test {
+ public:
+  OptionsUtilTest() : rnd_(0xFB) {
+    env_.reset(new test::StringEnv(Env::Default()));
+    dbname_ = test::TmpDir() + "/options_util_test";
+  }
+
+ protected:
+  std::unique_ptr<test::StringEnv> env_;
+  std::string dbname_;
+  Random rnd_;
+};
+
+bool IsBlockBasedTableFactory(TableFactory* tf) {
+  return tf->Name() == BlockBasedTableFactory().Name();
+}
+
+TEST_F(OptionsUtilTest, SaveAndLoad) {
+  const size_t kCFCount = 5;
+
+  DBOptions db_opt;
+  std::vector<std::string> cf_names;
+  std::vector<ColumnFamilyOptions> cf_opts;
+  test::RandomInitDBOptions(&db_opt, &rnd_);
+  for (size_t i = 0; i < kCFCount; ++i) {
+    cf_names.push_back(i == 0 ? kDefaultColumnFamilyName
+                              : test::RandomName(&rnd_, 10));
+    cf_opts.emplace_back();
+    test::RandomInitCFOptions(&cf_opts.back(), &rnd_);
+  }
+
+  const std::string kFileName = "OPTIONS-123456";
+  PersistRocksDBOptions(db_opt, cf_names, cf_opts, kFileName, env_.get());
+
+  DBOptions loaded_db_opt;
+  std::vector<ColumnFamilyDescriptor> loaded_cf_descs;
+  ASSERT_OK(LoadOptionsFromFile(kFileName, env_.get(), &loaded_db_opt,
+                                &loaded_cf_descs));
+
+  ASSERT_OK(RocksDBOptionsParser::VerifyDBOptions(db_opt, loaded_db_opt));
+  test::RandomInitDBOptions(&db_opt, &rnd_);
+  ASSERT_NOK(RocksDBOptionsParser::VerifyDBOptions(db_opt, loaded_db_opt));
+
+  for (size_t i = 0; i < kCFCount; ++i) {
+    ASSERT_EQ(cf_names[i], loaded_cf_descs[i].name);
+    ASSERT_OK(RocksDBOptionsParser::VerifyCFOptions(
+        cf_opts[i], loaded_cf_descs[i].options));
+    if (IsBlockBasedTableFactory(cf_opts[i].table_factory.get())) {
+      ASSERT_OK(RocksDBOptionsParser::VerifyTableFactory(
+          cf_opts[i].table_factory.get(),
+          loaded_cf_descs[i].options.table_factory.get()));
+    }
+    test::RandomInitCFOptions(&cf_opts[i], &rnd_);
+    ASSERT_NOK(RocksDBOptionsParser::VerifyCFOptions(
+        cf_opts[i], loaded_cf_descs[i].options));
+  }
+
+  for (size_t i = 0; i < kCFCount; ++i) {
+    if (cf_opts[i].compaction_filter) {
+      delete cf_opts[i].compaction_filter;
+    }
+  }
+}
+
+namespace {
+class DummyTableFactory : public TableFactory {
+ public:
+  DummyTableFactory() {}
+  virtual ~DummyTableFactory() {}
+
+  virtual const char* Name() const { return "DummyTableFactory"; }
+
+  virtual Status NewTableReader(const TableReaderOptions& table_reader_options,
+                                unique_ptr<RandomAccessFileReader>&& file,
+                                uint64_t file_size,
+                                unique_ptr<TableReader>* table_reader) const {
+    return Status::NotSupported();
+  }
+
+  virtual TableBuilder* NewTableBuilder(
+      const TableBuilderOptions& table_builder_options,
+      uint32_t column_family_id, WritableFileWriter* file) const {
+    return nullptr;
+  }
+
+  virtual Status SanitizeOptions(const DBOptions& db_opts,
+                                 const ColumnFamilyOptions& cf_opts) const {
+    return Status::NotSupported();
+  }
+
+  virtual std::string GetPrintableTableOptions() const { return ""; }
+};
+
+class DummyMergeOperator : public MergeOperator {
+ public:
+  DummyMergeOperator() {}
+  virtual ~DummyMergeOperator() {}
+
+  virtual bool FullMerge(const Slice& key, const Slice* existing_value,
+                         const std::deque<std::string>& operand_list,
+                         std::string* new_value, Logger* logger) const {
+    return false;
+  }
+
+  virtual bool PartialMergeMulti(const Slice& key,
+                                 const std::deque<Slice>& operand_list,
+                                 std::string* new_value, Logger* logger) const {
+    return false;
+  }
+
+  virtual const char* Name() const { return "DummyMergeOperator"; }
+};
+
+class DummySliceTransform : public SliceTransform {
+ public:
+  DummySliceTransform() {}
+  virtual ~DummySliceTransform() {}
+
+  // Return the name of this transformation.
+  virtual const char* Name() const { return "DummySliceTransform"; }
+
+  // transform a src in domain to a dst in the range
+  virtual Slice Transform(const Slice& src) const { return src; }
+
+  // determine whether this is a valid src upon the function applies
+  virtual bool InDomain(const Slice& src) const { return false; }
+
+  // determine whether dst=Transform(src) for some src
+  virtual bool InRange(const Slice& dst) const { return false; }
+};
+
+}  // namespace
+
+TEST_F(OptionsUtilTest, SanityCheck) {
+  DBOptions db_opt;
+  std::vector<ColumnFamilyDescriptor> cf_descs;
+  const size_t kCFCount = 5;
+  for (size_t i = 0; i < kCFCount; ++i) {
+    cf_descs.emplace_back();
+    cf_descs.back().name =
+        (i == 0) ? kDefaultColumnFamilyName : test::RandomName(&rnd_, 10);
+
+    cf_descs.back().options.table_factory.reset(NewBlockBasedTableFactory());
+    cf_descs.back().options.prefix_extractor.reset(
+        test::RandomSliceTransform(&rnd_));
+    cf_descs.back().options.merge_operator.reset(
+        test::RandomMergeOperator(&rnd_));
+  }
+
+  db_opt.create_missing_column_families = true;
+  db_opt.create_if_missing = true;
+
+  DestroyDB(dbname_, Options(db_opt, cf_descs[0].options));
+  DB* db;
+  std::vector<ColumnFamilyHandle*> handles;
+  // open and persist the options
+  ASSERT_OK(DB::Open(db_opt, dbname_, cf_descs, &handles, &db));
+
+  // close the db
+  for (auto* handle : handles) {
+    delete handle;
+  }
+  delete db;
+
+  // perform sanity check
+  ASSERT_OK(
+      CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+  ASSERT_GE(kCFCount, 5);
+  // merge operator
+  {
+    std::shared_ptr<MergeOperator> merge_op =
+        cf_descs[0].options.merge_operator;
+
+    ASSERT_NE(merge_op.get(), nullptr);
+    cf_descs[0].options.merge_operator.reset();
+    ASSERT_NOK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+    cf_descs[0].options.merge_operator.reset(new DummyMergeOperator());
+    ASSERT_NOK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+    cf_descs[0].options.merge_operator = merge_op;
+    ASSERT_OK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+  }
+
+  // prefix extractor
+  {
+    std::shared_ptr<const SliceTransform> prefix_extractor =
+        cf_descs[1].options.prefix_extractor;
+
+    ASSERT_NE(prefix_extractor, nullptr);
+    cf_descs[1].options.prefix_extractor.reset();
+    ASSERT_NOK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+    cf_descs[1].options.prefix_extractor.reset(new DummySliceTransform());
+    ASSERT_NOK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+    cf_descs[1].options.prefix_extractor = prefix_extractor;
+    ASSERT_OK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+  }
+
+  // comparator
+  {
+    test::SimpleSuffixReverseComparator comparator;
+
+    auto* prev_comparator = cf_descs[2].options.comparator;
+    cf_descs[2].options.comparator = &comparator;
+    ASSERT_NOK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+    cf_descs[2].options.comparator = prev_comparator;
+    ASSERT_OK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+  }
+
+  // table factory
+  {
+    std::shared_ptr<TableFactory> table_factory =
+        cf_descs[3].options.table_factory;
+
+    ASSERT_NE(table_factory, nullptr);
+    cf_descs[3].options.table_factory.reset(new DummyTableFactory());
+    ASSERT_NOK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+
+    cf_descs[3].options.table_factory = table_factory;
+    ASSERT_OK(
+        CheckOptionsCompatibility(dbname_, Env::Default(), db_opt, cf_descs));
+  }
+}
+
+}  // namespace rocksdb
+
+int main(int argc, char** argv) {
+  ::testing::InitGoogleTest(&argc, argv);
+#ifdef GFLAGS
+  ParseCommandLineFlags(&argc, &argv, true);
+#endif  // GFLAGS
+  return RUN_ALL_TESTS();
+}
+
+#else
+#include <cstdio>
+
+int main(int argc, char** argv) {
+  printf("Skipped in RocksDBLite as utilities are not supported.\n");
+  return 0;
+}
+#endif  // !ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/redis/redis_list_iterator.h b/src/rocksdb/utilities/redis/redis_list_iterator.h
index 6d0b1a6..73907dd 100644
--- a/src/rocksdb/utilities/redis/redis_list_iterator.h
+++ b/src/rocksdb/utilities/redis/redis_list_iterator.h
@@ -37,8 +37,8 @@
  * @author Deon Nicholas (dnicholas at fb.com)
  */
 
-#ifndef ROCKSDB_LITE
 #pragma once
+#ifndef ROCKSDB_LITE
 
 #include <string>
 
@@ -65,7 +65,7 @@ class RedisListIterator {
   ///  e) result_ will always contain data_[0..cur_byte_) and a header
   ///  f) Whenever corrupt data is encountered or an invalid operation is
   ///      attempted, a RedisListException will immediately be thrown.
-  RedisListIterator(const std::string& list_data)
+  explicit RedisListIterator(const std::string& list_data)
       : data_(list_data.data()),
         num_bytes_(static_cast<uint32_t>(list_data.size())),
         cur_byte_(0),
@@ -73,7 +73,6 @@ class RedisListIterator {
         cur_elem_length_(0),
         length_(0),
         result_() {
-
     // Initialize the result_ (reserve enough space for header)
     InitializeResult();
 
@@ -269,7 +268,7 @@ class RedisListIterator {
                    data_+cur_byte_+ sizeof(uint32_t) + cur_elem_length_);
   }
 
-  /// Will ThrowError() if neccessary.
+  /// Will ThrowError() if necessary.
   /// Checks for common/ubiquitous errors that can arise after most operations.
   /// This method should be called before any reading operation.
   /// If this function succeeds, then we are guaranteed to be in a valid state.
diff --git a/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc b/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc
index be0e53a..2079ccb 100644
--- a/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc
+++ b/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc
@@ -4,10 +4,10 @@
 //  of patent rights can be found in the PATENTS file in the same directory.
 
 #ifndef ROCKSDB_LITE
-#include <memory>
+#include "utilities/table_properties_collectors/compact_on_deletion_collector.h"
 
+#include <memory>
 #include "rocksdb/utilities/table_properties_collectors.h"
-#include "utilities/table_properties_collectors/compact_on_deletion_collector.h"
 
 namespace rocksdb {
 
@@ -75,8 +75,9 @@ Status CompactOnDeletionCollector::AddUserKey(
   return Status::OK();
 }
 
-TablePropertiesCollector* CompactOnDeletionCollectorFactory::
-    CreateTablePropertiesCollector() {
+TablePropertiesCollector*
+CompactOnDeletionCollectorFactory::CreateTablePropertiesCollector(
+    TablePropertiesCollectorFactory::Context context) {
   return new CompactOnDeletionCollector(
       sliding_window_size_, deletion_trigger_);
 }
diff --git a/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h b/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h
index eb01e43..3001ce9 100644
--- a/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h
+++ b/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h
@@ -6,6 +6,7 @@
 #pragma once
 
 #ifndef ROCKSDB_LITE
+#include "rocksdb/utilities/table_properties_collectors.h"
 namespace rocksdb {
 
 // A factory of a table property collector that marks a SST
@@ -28,7 +29,8 @@ class CompactOnDeletionCollectorFactory
 
   virtual ~CompactOnDeletionCollectorFactory() {}
 
-  virtual TablePropertiesCollector* CreateTablePropertiesCollector() override;
+  virtual TablePropertiesCollector* CreateTablePropertiesCollector(
+      TablePropertiesCollectorFactory::Context context) override;
 
   virtual const char* Name() const override {
     return "CompactOnDeletionCollector";
diff --git a/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc b/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc
index 12f4e2e..89e6bbc 100644
--- a/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc
+++ b/src/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc
@@ -15,6 +15,7 @@
 #include <vector>
 
 #include "rocksdb/table.h"
+#include "rocksdb/table_properties.h"
 #include "rocksdb/utilities/table_properties_collectors.h"
 #include "util/random.h"
 #include "utilities/table_properties_collectors/compact_on_deletion_collector.h"
@@ -24,6 +25,9 @@ int main(int argc, char** argv) {
       {1000, 10000, 10000, 127, 128, 129, 255, 256, 257, 2, 10000};
   const int kDeletionTriggers[] =
       {500, 9500, 4323, 47, 61, 128, 250, 250, 250, 2, 2};
+  rocksdb::TablePropertiesCollectorFactory::Context context;
+  context.column_family_id =
+      rocksdb::TablePropertiesCollectorFactory::Context::kUnknownColumnFamily;
 
   std::vector<int> window_sizes;
   std::vector<int> deletion_triggers;
@@ -57,8 +61,7 @@ int main(int argc, char** argv) {
       std::unique_ptr<rocksdb::TablePropertiesCollector> collector;
       auto factory = rocksdb::NewCompactOnDeletionCollectorFactory(
           kWindowSize, kNumDeletionTrigger);
-      collector.reset(
-          factory->CreateTablePropertiesCollector());
+      collector.reset(factory->CreateTablePropertiesCollector(context));
       const int kSample = 10;
       for (int delete_rate = 0; delete_rate <= kSample; ++delete_rate) {
         int deletions = 0;
@@ -90,8 +93,7 @@ int main(int argc, char** argv) {
       std::unique_ptr<rocksdb::TablePropertiesCollector> collector;
       auto factory = rocksdb::NewCompactOnDeletionCollectorFactory(
           kWindowSize, kNumDeletionTrigger);
-      collector.reset(
-          factory->CreateTablePropertiesCollector());
+      collector.reset(factory->CreateTablePropertiesCollector(context));
       const int kSample = 10;
       for (int delete_rate = 0; delete_rate <= kSample; ++delete_rate) {
         int deletions = 0;
@@ -138,8 +140,7 @@ int main(int argc, char** argv) {
       std::unique_ptr<rocksdb::TablePropertiesCollector> collector;
       auto factory = rocksdb::NewCompactOnDeletionCollectorFactory(
           kWindowSize, kNumDeletionTrigger);
-      collector.reset(
-          factory->CreateTablePropertiesCollector());
+      collector.reset(factory->CreateTablePropertiesCollector(context));
       assert(collector->NeedCompact() == false);
       // Insert "kNumDeletionTrigger * 0.95" deletions for every
       // "kWindowSize" and verify compaction is not needed.
diff --git a/src/rocksdb/utilities/transactions/optimistic_transaction_impl.cc b/src/rocksdb/utilities/transactions/optimistic_transaction_impl.cc
index 4bd262e..028bed4 100644
--- a/src/rocksdb/utilities/transactions/optimistic_transaction_impl.cc
+++ b/src/rocksdb/utilities/transactions/optimistic_transaction_impl.cc
@@ -73,6 +73,8 @@ Status OptimisticTransactionImpl::TryLock(ColumnFamilyHandle* column_family,
   }
   uint32_t cfh_id = GetColumnFamilyID(column_family);
 
+  SetSnapshotIfNeeded();
+
   SequenceNumber seq;
   if (snapshot_) {
     seq = snapshot_->snapshot()->GetSequenceNumber();
diff --git a/src/rocksdb/utilities/transactions/transaction_base.cc b/src/rocksdb/utilities/transactions/transaction_base.cc
index dc91677..5f3e97e 100644
--- a/src/rocksdb/utilities/transactions/transaction_base.cc
+++ b/src/rocksdb/utilities/transactions/transaction_base.cc
@@ -7,6 +7,7 @@
 
 #include "utilities/transactions/transaction_base.h"
 
+#include "db/db_impl.h"
 #include "db/column_family.h"
 #include "rocksdb/comparator.h"
 #include "rocksdb/db.h"
@@ -35,7 +36,29 @@ void TransactionBaseImpl::Clear() {
 }
 
 void TransactionBaseImpl::SetSnapshot() {
-  snapshot_.reset(new ManagedSnapshot(db_));
+  assert(dynamic_cast<DBImpl*>(db_) != nullptr);
+  auto db_impl = reinterpret_cast<DBImpl*>(db_);
+
+  const Snapshot* snapshot = db_impl->GetSnapshotForWriteConflictBoundary();
+  snapshot_.reset(new ManagedSnapshot(db_, snapshot));
+  snapshot_needed_ = false;
+  snapshot_notifier_ = nullptr;
+}
+
+void TransactionBaseImpl::SetSnapshotOnNextOperation(
+    std::shared_ptr<TransactionNotifier> notifier) {
+  snapshot_needed_ = true;
+  snapshot_notifier_ = notifier;
+}
+
+void TransactionBaseImpl::SetSnapshotIfNeeded() {
+  if (snapshot_needed_) {
+    std::shared_ptr<TransactionNotifier> notifier = snapshot_notifier_;
+    SetSnapshot();
+    if (notifier != nullptr) {
+      notifier->SnapshotCreated(GetSnapshot());
+    }
+  }
 }
 
 Status TransactionBaseImpl::TryLock(ColumnFamilyHandle* column_family,
@@ -59,7 +82,8 @@ void TransactionBaseImpl::SetSavePoint() {
   if (save_points_ == nullptr) {
     save_points_.reset(new std::stack<TransactionBaseImpl::SavePoint>());
   }
-  save_points_->emplace(snapshot_, num_puts_, num_deletes_, num_merges_);
+  save_points_->emplace(snapshot_, snapshot_needed_, snapshot_notifier_,
+                        num_puts_, num_deletes_, num_merges_);
   write_batch_->SetSavePoint();
 }
 
@@ -68,6 +92,8 @@ Status TransactionBaseImpl::RollbackToSavePoint() {
     // Restore saved SavePoint
     TransactionBaseImpl::SavePoint& save_point = save_points_->top();
     snapshot_ = save_point.snapshot_;
+    snapshot_needed_ = save_point.snapshot_needed_;
+    snapshot_notifier_ = save_point.snapshot_notifier_;
     num_puts_ = save_point.num_puts_;
     num_deletes_ = save_point.num_deletes_;
     num_merges_ = save_point.num_merges_;
@@ -179,7 +205,7 @@ Status TransactionBaseImpl::Put(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->Put(column_family, key, value);
+    GetBatchForWrite()->Put(column_family, key, value);
     num_puts_++;
   }
 
@@ -192,7 +218,7 @@ Status TransactionBaseImpl::Put(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->Put(column_family, key, value);
+    GetBatchForWrite()->Put(column_family, key, value);
     num_puts_++;
   }
 
@@ -204,7 +230,7 @@ Status TransactionBaseImpl::Merge(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->Merge(column_family, key, value);
+    GetBatchForWrite()->Merge(column_family, key, value);
     num_merges_++;
   }
 
@@ -216,7 +242,7 @@ Status TransactionBaseImpl::Delete(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->Delete(column_family, key);
+    GetBatchForWrite()->Delete(column_family, key);
     num_deletes_++;
   }
 
@@ -228,7 +254,7 @@ Status TransactionBaseImpl::Delete(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->Delete(column_family, key);
+    GetBatchForWrite()->Delete(column_family, key);
     num_deletes_++;
   }
 
@@ -240,7 +266,7 @@ Status TransactionBaseImpl::SingleDelete(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->SingleDelete(column_family, key);
+    GetBatchForWrite()->SingleDelete(column_family, key);
     num_deletes_++;
   }
 
@@ -252,7 +278,7 @@ Status TransactionBaseImpl::SingleDelete(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key);
 
   if (s.ok()) {
-    write_batch_->SingleDelete(column_family, key);
+    GetBatchForWrite()->SingleDelete(column_family, key);
     num_deletes_++;
   }
 
@@ -265,7 +291,7 @@ Status TransactionBaseImpl::PutUntracked(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key, untracked);
 
   if (s.ok()) {
-    write_batch_->Put(column_family, key, value);
+    GetBatchForWrite()->Put(column_family, key, value);
     num_puts_++;
   }
 
@@ -279,7 +305,7 @@ Status TransactionBaseImpl::PutUntracked(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key, untracked);
 
   if (s.ok()) {
-    write_batch_->Put(column_family, key, value);
+    GetBatchForWrite()->Put(column_family, key, value);
     num_puts_++;
   }
 
@@ -293,7 +319,7 @@ Status TransactionBaseImpl::MergeUntracked(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key, untracked);
 
   if (s.ok()) {
-    write_batch_->Merge(column_family, key, value);
+    GetBatchForWrite()->Merge(column_family, key, value);
     num_merges_++;
   }
 
@@ -306,7 +332,7 @@ Status TransactionBaseImpl::DeleteUntracked(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key, untracked);
 
   if (s.ok()) {
-    write_batch_->Delete(column_family, key);
+    GetBatchForWrite()->Delete(column_family, key);
     num_deletes_++;
   }
 
@@ -319,7 +345,7 @@ Status TransactionBaseImpl::DeleteUntracked(ColumnFamilyHandle* column_family,
   Status s = TryLock(column_family, key, untracked);
 
   if (s.ok()) {
-    write_batch_->Delete(column_family, key);
+    GetBatchForWrite()->Delete(column_family, key);
     num_deletes_++;
   }
 
@@ -380,6 +406,20 @@ const TransactionKeyMap* TransactionBaseImpl::GetTrackedKeysSinceSavePoint() {
   return nullptr;
 }
 
+// Gets the write batch that should be used for Put/Merge/Deletes.
+//
+// Returns either a WriteBatch or WriteBatchWithIndex depending on whether
+// DisableIndexing() has been called.
+WriteBatchBase* TransactionBaseImpl::GetBatchForWrite() {
+  if (indexing_enabled_) {
+    // Use WriteBatchWithIndex
+    return write_batch_.get();
+  } else {
+    // Don't use WriteBatchWithIndex. Return base WriteBatch.
+    return write_batch_->GetWriteBatch();
+  }
+}
+
 }  // namespace rocksdb
 
 #endif  // ROCKSDB_LITE
diff --git a/src/rocksdb/utilities/transactions/transaction_base.h b/src/rocksdb/utilities/transactions/transaction_base.h
index 54ea567..90a3b59 100644
--- a/src/rocksdb/utilities/transactions/transaction_base.h
+++ b/src/rocksdb/utilities/transactions/transaction_base.h
@@ -169,6 +169,18 @@ class TransactionBaseImpl : public Transaction {
   }
 
   void SetSnapshot() override;
+  void SetSnapshotOnNextOperation(
+      std::shared_ptr<TransactionNotifier> notifier = nullptr) override;
+
+  void ClearSnapshot() override {
+    snapshot_.reset();
+    snapshot_needed_ = false;
+    snapshot_notifier_ = nullptr;
+  }
+
+  void DisableIndexing() override { indexing_enabled_ = false; }
+
+  void EnableIndexing() override { indexing_enabled_ = true; }
 
   uint64_t GetElapsedTime() const override;
 
@@ -191,6 +203,9 @@ class TransactionBaseImpl : public Transaction {
 
   const TransactionKeyMap* GetTrackedKeysSinceSavePoint();
 
+  // Sets a snapshot if SetSnapshotOnNextOperation() has been called.
+  void SetSnapshotIfNeeded();
+
   DB* const db_;
 
   const WriteOptions write_options_;
@@ -214,6 +229,8 @@ class TransactionBaseImpl : public Transaction {
 
   struct SavePoint {
     std::shared_ptr<ManagedSnapshot> snapshot_;
+    bool snapshot_needed_;
+    std::shared_ptr<TransactionNotifier> snapshot_notifier_;
     uint64_t num_puts_;
     uint64_t num_deletes_;
     uint64_t num_merges_;
@@ -221,9 +238,12 @@ class TransactionBaseImpl : public Transaction {
     // Record all keys tracked since the last savepoint
     TransactionKeyMap new_keys_;
 
-    SavePoint(std::shared_ptr<ManagedSnapshot> snapshot, uint64_t num_puts,
-              uint64_t num_deletes, uint64_t num_merges)
+    SavePoint(std::shared_ptr<ManagedSnapshot> snapshot, bool snapshot_needed,
+              std::shared_ptr<TransactionNotifier> snapshot_notifier,
+              uint64_t num_puts, uint64_t num_deletes, uint64_t num_merges)
         : snapshot_(snapshot),
+          snapshot_needed_(snapshot_needed),
+          snapshot_notifier_(snapshot_notifier),
           num_puts_(num_puts),
           num_deletes_(num_deletes),
           num_merges_(num_merges) {}
@@ -241,8 +261,24 @@ class TransactionBaseImpl : public Transaction {
   // Optimistic Transactions will wait till commit time to do conflict checking.
   TransactionKeyMap tracked_keys_;
 
+  // If true, future Put/Merge/Deletes will be indexed in the
+  // WriteBatchWithIndex.
+  // If false, future Put/Merge/Deletes will be inserted directly into the
+  // underlying WriteBatch and not indexed in the WriteBatchWithIndex.
+  bool indexing_enabled_ = true;
+
+  // SetSnapshotOnNextOperation() has been called and the snapshot has not yet
+  // been reset.
+  bool snapshot_needed_ = false;
+
+  // SetSnapshotOnNextOperation() has been called and the caller would like
+  // a notification through the TransactionNotifier interface
+  std::shared_ptr<TransactionNotifier> snapshot_notifier_ = nullptr;
+
   Status TryLock(ColumnFamilyHandle* column_family, const SliceParts& key,
                  bool untracked = false);
+
+  WriteBatchBase* GetBatchForWrite();
 };
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/utilities/transactions/transaction_db_impl.cc b/src/rocksdb/utilities/transactions/transaction_db_impl.cc
index edf15e3..f8a47b9 100644
--- a/src/rocksdb/utilities/transactions/transaction_db_impl.cc
+++ b/src/rocksdb/utilities/transactions/transaction_db_impl.cc
@@ -8,6 +8,7 @@
 #include "utilities/transactions/transaction_db_impl.h"
 
 #include <string>
+#include <unordered_set>
 #include <vector>
 
 #include "db/db_impl.h"
@@ -77,28 +78,45 @@ Status TransactionDB::Open(
   DB* db;
 
   std::vector<ColumnFamilyDescriptor> column_families_copy = column_families;
+  std::vector<size_t> compaction_enabled_cf_indices;
 
   // Enable MemTable History if not already enabled
-  for (auto& column_family : column_families_copy) {
-    ColumnFamilyOptions* options = &column_family.options;
+  for (size_t i = 0; i < column_families_copy.size(); i++) {
+    ColumnFamilyOptions* options = &column_families_copy[i].options;
 
     if (options->max_write_buffer_number_to_maintain == 0) {
       // Setting to -1 will set the History size to max_write_buffer_number.
       options->max_write_buffer_number_to_maintain = -1;
     }
+
+    if (!options->disable_auto_compactions) {
+      // Disable compactions momentarily to prevent race with DB::Open
+      options->disable_auto_compactions = true;
+      compaction_enabled_cf_indices.push_back(i);
+    }
   }
 
-  s = DB::Open(db_options, dbname, column_families, handles, &db);
+  s = DB::Open(db_options, dbname, column_families_copy, handles, &db);
 
   if (s.ok()) {
     TransactionDBImpl* txn_db = new TransactionDBImpl(
         db, TransactionDBImpl::ValidateTxnDBOptions(txn_db_options));
+    *dbptr = txn_db;
 
     for (auto cf_ptr : *handles) {
       txn_db->AddColumnFamily(cf_ptr);
     }
 
-    *dbptr = txn_db;
+    // Re-enable compaction for the column families that initially had
+    // compaction enabled.
+    assert(column_families_copy.size() == (*handles).size());
+    std::vector<ColumnFamilyHandle*> compaction_enabled_cf_handles;
+    compaction_enabled_cf_handles.reserve(compaction_enabled_cf_indices.size());
+    for (auto index : compaction_enabled_cf_indices) {
+      compaction_enabled_cf_handles.push_back((*handles)[index]);
+    }
+
+    s = txn_db->EnableAutoCompaction(compaction_enabled_cf_handles);
   }
 
   return s;
@@ -181,6 +199,7 @@ Status TransactionDBImpl::Put(const WriteOptions& options,
   Status s;
 
   Transaction* txn = BeginInternalTransaction(options);
+  txn->DisableIndexing();
 
   // Since the client didn't create a transaction, they don't care about
   // conflict checking for this write.  So we just need to do PutUntracked().
@@ -201,6 +220,7 @@ Status TransactionDBImpl::Delete(const WriteOptions& wopts,
   Status s;
 
   Transaction* txn = BeginInternalTransaction(wopts);
+  txn->DisableIndexing();
 
   // Since the client didn't create a transaction, they don't care about
   // conflict checking for this write.  So we just need to do
@@ -222,6 +242,7 @@ Status TransactionDBImpl::Merge(const WriteOptions& options,
   Status s;
 
   Transaction* txn = BeginInternalTransaction(options);
+  txn->DisableIndexing();
 
   // Since the client didn't create a transaction, they don't care about
   // conflict checking for this write.  So we just need to do
@@ -241,6 +262,7 @@ Status TransactionDBImpl::Write(const WriteOptions& opts, WriteBatch* updates) {
   // Need to lock all keys in this batch to prevent write conflicts with
   // concurrent transactions.
   Transaction* txn = BeginInternalTransaction(opts);
+  txn->DisableIndexing();
 
   assert(dynamic_cast<TransactionImpl*>(txn) != nullptr);
   auto txn_impl = reinterpret_cast<TransactionImpl*>(txn);
diff --git a/src/rocksdb/utilities/transactions/transaction_impl.cc b/src/rocksdb/utilities/transactions/transaction_impl.cc
index c2a93cf..33eb650 100644
--- a/src/rocksdb/utilities/transactions/transaction_impl.cc
+++ b/src/rocksdb/utilities/transactions/transaction_impl.cc
@@ -220,16 +220,10 @@ Status TransactionImpl::TryLock(ColumnFamilyHandle* column_family,
   bool previously_locked;
   Status s;
 
-  // Even though we do not care about doing conflict checking for this write,
-  // we still need to take a lock to make sure we do not cause a conflict with
-  // some other write.  However, we do not need to check if there have been
-  // any writes since this transaction's snapshot.
-  // TODO(agiardullo): could optimize by supporting shared txn locks in the
-  // future
-  bool check_snapshot = !untracked;
-  SequenceNumber tracked_seqno = kMaxSequenceNumber;
+  // lock this key if this transactions hasn't already locked it
+  SequenceNumber current_seqno = kMaxSequenceNumber;
+  SequenceNumber new_seqno = kMaxSequenceNumber;
 
-  // Lookup whether this key has already been locked by this transaction
   const auto& tracked_keys = GetTrackedKeys();
   const auto tracked_keys_cf = tracked_keys.find(cfh_id);
   if (tracked_keys_cf == tracked_keys.end()) {
@@ -240,7 +234,7 @@ Status TransactionImpl::TryLock(ColumnFamilyHandle* column_family,
       previously_locked = false;
     } else {
       previously_locked = true;
-      tracked_seqno = iter->second;
+      current_seqno = iter->second;
     }
   }
 
@@ -249,39 +243,37 @@ Status TransactionImpl::TryLock(ColumnFamilyHandle* column_family,
     s = txn_db_impl_->TryLock(this, cfh_id, key_str);
   }
 
-  if (s.ok()) {
+  SetSnapshotIfNeeded();
+
+  // Even though we do not care about doing conflict checking for this write,
+  // we still need to take a lock to make sure we do not cause a conflict with
+  // some other write.  However, we do not need to check if there have been
+  // any writes since this transaction's snapshot.
+  // TODO(agiardullo): could optimize by supporting shared txn locks in the
+  // future
+  if (untracked || snapshot_ == nullptr) {
+    // Need to remember the earliest sequence number that we know that this
+    // key has not been modified after.  This is useful if this same
+    // transaction
+    // later tries to lock this key again.
+    if (current_seqno == kMaxSequenceNumber) {
+      // Since we haven't checked a snapshot, we only know this key has not
+      // been modified since after we locked it.
+      new_seqno = db_->GetLatestSequenceNumber();
+    } else {
+      new_seqno = current_seqno;
+    }
+  } else {
     // If a snapshot is set, we need to make sure the key hasn't been modified
     // since the snapshot.  This must be done after we locked the key.
-    if (!check_snapshot || snapshot_ == nullptr) {
-      // Need to remember the earliest sequence number that we know that this
-      // key has not been modified after.  This is useful if this same
-      // transaction
-      // later tries to lock this key again.
-      if (tracked_seqno == kMaxSequenceNumber) {
-        // Since we haven't checked a snapshot, we only know this key has not
-        // been modified since after we locked it.
-        tracked_seqno = db_->GetLatestSequenceNumber();
-      }
-    } else {
-      // If the key has been previous validated at a sequence number earlier
-      // than the curent snapshot's sequence number, we already know it has not
-      // been modified.
-      SequenceNumber seq = snapshot_->snapshot()->GetSequenceNumber();
-      bool already_validated = tracked_seqno <= seq;
-
-      if (!already_validated) {
-        s = CheckKeySequence(column_family, key);
-
-        if (s.ok()) {
-          // Record that there have been no writes to this key after this
-          // sequence.
-          tracked_seqno = seq;
-        } else {
-          // Failed to validate key
-          if (!previously_locked) {
-            // Unlock key we just locked
-            txn_db_impl_->UnLock(this, cfh_id, key.ToString());
-          }
+    if (s.ok()) {
+      s = ValidateSnapshot(column_family, key, current_seqno, &new_seqno);
+
+      if (!s.ok()) {
+        // Failed to validate key
+        if (!previously_locked) {
+          // Unlock key we just locked
+          txn_db_impl_->UnLock(this, cfh_id, key.ToString());
         }
       }
     }
@@ -289,7 +281,7 @@ Status TransactionImpl::TryLock(ColumnFamilyHandle* column_family,
 
   if (s.ok()) {
     // Let base class know we've conflict checked this key.
-    TrackKey(cfh_id, key_str, tracked_seqno);
+    TrackKey(cfh_id, key_str, new_seqno);
   }
 
   return s;
@@ -297,22 +289,30 @@ Status TransactionImpl::TryLock(ColumnFamilyHandle* column_family,
 
 // Return OK() if this key has not been modified more recently than the
 // transaction snapshot_.
-Status TransactionImpl::CheckKeySequence(ColumnFamilyHandle* column_family,
-                                         const Slice& key) {
-  Status result;
-  if (snapshot_ != nullptr) {
-    assert(dynamic_cast<DBImpl*>(db_) != nullptr);
-    auto db_impl = reinterpret_cast<DBImpl*>(db_);
+Status TransactionImpl::ValidateSnapshot(ColumnFamilyHandle* column_family,
+                                         const Slice& key,
+                                         SequenceNumber prev_seqno,
+                                         SequenceNumber* new_seqno) {
+  assert(snapshot_);
+
+  SequenceNumber seq = snapshot_->snapshot()->GetSequenceNumber();
+  if (prev_seqno <= seq) {
+    // If the key has been previous validated at a sequence number earlier
+    // than the curent snapshot's sequence number, we already know it has not
+    // been modified.
+    return Status::OK();
+  }
 
-    ColumnFamilyHandle* cfh = column_family ? column_family :
-      db_impl->DefaultColumnFamily();
+  *new_seqno = seq;
 
-    result = TransactionUtil::CheckKeyForConflicts(
-        db_impl, cfh, key.ToString(),
-        snapshot_->snapshot()->GetSequenceNumber());
-  }
+  assert(dynamic_cast<DBImpl*>(db_) != nullptr);
+  auto db_impl = reinterpret_cast<DBImpl*>(db_);
+
+  ColumnFamilyHandle* cfh =
+      column_family ? column_family : db_impl->DefaultColumnFamily();
 
-  return result;
+  return TransactionUtil::CheckKeyForConflicts(
+      db_impl, cfh, key.ToString(), snapshot_->snapshot()->GetSequenceNumber());
 }
 
 }  // namespace rocksdb
diff --git a/src/rocksdb/utilities/transactions/transaction_impl.h b/src/rocksdb/utilities/transactions/transaction_impl.h
index 57ceacb..0fa087d 100644
--- a/src/rocksdb/utilities/transactions/transaction_impl.h
+++ b/src/rocksdb/utilities/transactions/transaction_impl.h
@@ -88,7 +88,8 @@ class TransactionImpl : public TransactionBaseImpl {
 
   void Clear() override;
 
-  Status CheckKeySequence(ColumnFamilyHandle* column_family, const Slice& key);
+  Status ValidateSnapshot(ColumnFamilyHandle* column_family, const Slice& key,
+                          SequenceNumber prev_seqno, SequenceNumber* new_seqno);
 
   Status LockBatch(WriteBatch* batch, TransactionKeyMap* keys_to_unlock);
 
diff --git a/src/rocksdb/utilities/transactions/transaction_test.cc b/src/rocksdb/utilities/transactions/transaction_test.cc
index dedc94c..73f227f 100644
--- a/src/rocksdb/utilities/transactions/transaction_test.cc
+++ b/src/rocksdb/utilities/transactions/transaction_test.cc
@@ -7,7 +7,9 @@
 
 #include <string>
 
+#include "db/db_impl.h"
 #include "rocksdb/db.h"
+#include "rocksdb/options.h"
 #include "rocksdb/utilities/transaction.h"
 #include "rocksdb/utilities/transaction_db.h"
 #include "util/logging.h"
@@ -1301,6 +1303,68 @@ TEST_F(TransactionTest, IteratorTest) {
   delete txn;
 }
 
+TEST_F(TransactionTest, DisableIndexingTest) {
+  WriteOptions write_options;
+  ReadOptions read_options;
+  string value;
+  Status s;
+
+  Transaction* txn = db->BeginTransaction(write_options);
+  ASSERT_TRUE(txn);
+
+  s = txn->Put("A", "a");
+  ASSERT_OK(s);
+
+  s = txn->Get(read_options, "A", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("a", value);
+
+  txn->DisableIndexing();
+
+  s = txn->Put("B", "b");
+  ASSERT_OK(s);
+
+  s = txn->Get(read_options, "B", &value);
+  ASSERT_TRUE(s.IsNotFound());
+
+  Iterator* iter = txn->GetIterator(read_options);
+  ASSERT_OK(iter->status());
+
+  iter->Seek("B");
+  ASSERT_OK(iter->status());
+  ASSERT_FALSE(iter->Valid());
+
+  s = txn->Delete("A");
+
+  s = txn->Get(read_options, "A", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("a", value);
+
+  txn->EnableIndexing();
+
+  s = txn->Put("B", "bb");
+  ASSERT_OK(s);
+
+  iter->Seek("B");
+  ASSERT_OK(iter->status());
+  ASSERT_TRUE(iter->Valid());
+  ASSERT_EQ("bb", iter->value().ToString());
+
+  s = txn->Get(read_options, "B", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("bb", value);
+
+  s = txn->Put("A", "aa");
+  ASSERT_OK(s);
+
+  s = txn->Get(read_options, "A", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("aa", value);
+
+  delete iter;
+  delete txn;
+}
+
 TEST_F(TransactionTest, SavepointTest) {
   WriteOptions write_options;
   ReadOptions read_options, snapshot_read_options;
@@ -1883,6 +1947,387 @@ TEST_F(TransactionTest, MergeTest) {
   ASSERT_EQ("a,3", value);
 }
 
+TEST_F(TransactionTest, DeferSnapshotTest) {
+  WriteOptions write_options;
+  ReadOptions read_options;
+  string value;
+  Status s;
+
+  s = db->Put(write_options, "A", "a0");
+  ASSERT_OK(s);
+
+  Transaction* txn1 = db->BeginTransaction(write_options);
+  Transaction* txn2 = db->BeginTransaction(write_options);
+
+  txn1->SetSnapshotOnNextOperation();
+  auto snapshot = txn1->GetSnapshot();
+  ASSERT_FALSE(snapshot);
+
+  s = txn2->Put("A", "a2");
+  ASSERT_OK(s);
+  s = txn2->Commit();
+  ASSERT_OK(s);
+  delete txn2;
+
+  s = txn1->GetForUpdate(read_options, "A", &value);
+  // Should not conflict with txn2 since snapshot wasn't set until
+  // GetForUpdate was called.
+  ASSERT_OK(s);
+  ASSERT_EQ("a2", value);
+
+  s = txn1->Put("A", "a1");
+  ASSERT_OK(s);
+
+  s = db->Put(write_options, "B", "b0");
+  ASSERT_OK(s);
+
+  // Cannot lock B since it was written after the snapshot was set
+  s = txn1->Put("B", "b1");
+  ASSERT_TRUE(s.IsBusy());
+
+  s = txn1->Commit();
+  ASSERT_OK(s);
+  delete txn1;
+
+  s = db->Get(read_options, "A", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("a1", value);
+
+  s = db->Get(read_options, "B", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("b0", value);
+}
+
+TEST_F(TransactionTest, DeferSnapshotTest2) {
+  WriteOptions write_options;
+  ReadOptions read_options, snapshot_read_options;
+  string value;
+  Status s;
+
+  Transaction* txn1 = db->BeginTransaction(write_options);
+
+  txn1->SetSnapshot();
+
+  s = txn1->Put("A", "a1");
+  ASSERT_OK(s);
+
+  s = db->Put(write_options, "C", "c0");
+  ASSERT_OK(s);
+  s = db->Put(write_options, "D", "d0");
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+
+  txn1->SetSnapshotOnNextOperation();
+
+  s = txn1->Get(snapshot_read_options, "C", &value);
+  // Snapshot was set before C was written
+  ASSERT_TRUE(s.IsNotFound());
+  s = txn1->Get(snapshot_read_options, "D", &value);
+  // Snapshot was set before D was written
+  ASSERT_TRUE(s.IsNotFound());
+
+  // Snapshot should not have changed yet.
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+
+  s = txn1->Get(snapshot_read_options, "C", &value);
+  // Snapshot was set before C was written
+  ASSERT_TRUE(s.IsNotFound());
+  s = txn1->Get(snapshot_read_options, "D", &value);
+  // Snapshot was set before D was written
+  ASSERT_TRUE(s.IsNotFound());
+
+  s = txn1->GetForUpdate(read_options, "C", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("c0", value);
+
+  s = db->Put(write_options, "D", "d00");
+  ASSERT_OK(s);
+
+  // Snapshot is now set
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  s = txn1->Get(snapshot_read_options, "D", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("d0", value);
+
+  s = txn1->Commit();
+  ASSERT_OK(s);
+  delete txn1;
+}
+
+TEST_F(TransactionTest, DeferSnapshotSavePointTest) {
+  WriteOptions write_options;
+  ReadOptions read_options, snapshot_read_options;
+  string value;
+  Status s;
+
+  Transaction* txn1 = db->BeginTransaction(write_options);
+
+  txn1->SetSavePoint();  // 1
+
+  s = db->Put(write_options, "T", "1");
+  ASSERT_OK(s);
+
+  txn1->SetSnapshotOnNextOperation();
+
+  s = db->Put(write_options, "T", "2");
+  ASSERT_OK(s);
+
+  txn1->SetSavePoint();  // 2
+
+  s = db->Put(write_options, "T", "3");
+  ASSERT_OK(s);
+
+  s = txn1->Put("A", "a");
+  ASSERT_OK(s);
+
+  txn1->SetSavePoint();  // 3
+
+  s = db->Put(write_options, "T", "4");
+  ASSERT_OK(s);
+
+  txn1->SetSnapshot();
+  txn1->SetSnapshotOnNextOperation();
+
+  txn1->SetSavePoint();  // 4
+
+  s = db->Put(write_options, "T", "5");
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("4", value);
+
+  s = txn1->Put("A", "a1");
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("5", value);
+
+  s = txn1->RollbackToSavePoint();  // Rollback to 4
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("4", value);
+
+  s = txn1->RollbackToSavePoint();  // Rollback to 3
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("3", value);
+
+  s = txn1->Get(read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("5", value);
+
+  s = txn1->RollbackToSavePoint();  // Rollback to 2
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  ASSERT_FALSE(snapshot_read_options.snapshot);
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("5", value);
+
+  s = txn1->Delete("A");
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  ASSERT_TRUE(snapshot_read_options.snapshot);
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("5", value);
+
+  s = txn1->RollbackToSavePoint();  // Rollback to 1
+  ASSERT_OK(s);
+
+  s = txn1->Delete("A");
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn1->GetSnapshot();
+  ASSERT_FALSE(snapshot_read_options.snapshot);
+  s = txn1->Get(snapshot_read_options, "T", &value);
+  ASSERT_OK(s);
+  ASSERT_EQ("5", value);
+
+  s = txn1->Commit();
+  ASSERT_OK(s);
+
+  delete txn1;
+}
+
+TEST_F(TransactionTest, SetSnapshotOnNextOperationWithNotification) {
+  WriteOptions write_options;
+  ReadOptions read_options;
+  string value;
+
+  class Notifier : public TransactionNotifier {
+   private:
+    const Snapshot** snapshot_ptr_;
+
+   public:
+    explicit Notifier(const Snapshot** snapshot_ptr)
+        : snapshot_ptr_(snapshot_ptr) {}
+
+    void SnapshotCreated(const Snapshot* newSnapshot) {
+      *snapshot_ptr_ = newSnapshot;
+    }
+  };
+
+  std::shared_ptr<Notifier> notifier =
+      std::make_shared<Notifier>(&read_options.snapshot);
+  Status s;
+
+  s = db->Put(write_options, "B", "0");
+  ASSERT_OK(s);
+
+  Transaction* txn1 = db->BeginTransaction(write_options);
+
+  txn1->SetSnapshotOnNextOperation(notifier);
+  ASSERT_FALSE(read_options.snapshot);
+
+  s = db->Put(write_options, "B", "1");
+  ASSERT_OK(s);
+
+  // A Get does not generate the snapshot
+  s = txn1->Get(read_options, "B", &value);
+  ASSERT_OK(s);
+  ASSERT_FALSE(read_options.snapshot);
+  ASSERT_EQ(value, "1");
+
+  // Any other operation does
+  s = txn1->Put("A", "0");
+  ASSERT_OK(s);
+
+  // Now change "B".
+  s = db->Put(write_options, "B", "2");
+  ASSERT_OK(s);
+
+  // The original value should still be read
+  s = txn1->Get(read_options, "B", &value);
+  ASSERT_OK(s);
+  ASSERT_TRUE(read_options.snapshot);
+  ASSERT_EQ(value, "1");
+
+  s = txn1->Commit();
+  ASSERT_OK(s);
+
+  delete txn1;
+}
+
+TEST_F(TransactionTest, ClearSnapshotTest) {
+  WriteOptions write_options;
+  ReadOptions read_options, snapshot_read_options;
+  string value;
+  Status s;
+
+  s = db->Put(write_options, "foo", "0");
+  ASSERT_OK(s);
+
+  Transaction* txn = db->BeginTransaction(write_options);
+  ASSERT_TRUE(txn);
+
+  s = db->Put(write_options, "foo", "1");
+  ASSERT_OK(s);
+
+  snapshot_read_options.snapshot = txn->GetSnapshot();
+  ASSERT_FALSE(snapshot_read_options.snapshot);
+
+  // No snapshot created yet
+  s = txn->Get(snapshot_read_options, "foo", &value);
+  ASSERT_EQ(value, "1");
+
+  txn->SetSnapshot();
+  snapshot_read_options.snapshot = txn->GetSnapshot();
+  ASSERT_TRUE(snapshot_read_options.snapshot);
+
+  s = db->Put(write_options, "foo", "2");
+  ASSERT_OK(s);
+
+  // Snapshot was created before change to '2'
+  s = txn->Get(snapshot_read_options, "foo", &value);
+  ASSERT_EQ(value, "1");
+
+  txn->ClearSnapshot();
+  snapshot_read_options.snapshot = txn->GetSnapshot();
+  ASSERT_FALSE(snapshot_read_options.snapshot);
+
+  // Snapshot has now been cleared
+  s = txn->Get(snapshot_read_options, "foo", &value);
+  ASSERT_EQ(value, "2");
+
+  s = txn->Commit();
+  ASSERT_OK(s);
+
+  delete txn;
+}
+
+TEST_F(TransactionTest, ToggleAutoCompactionTest) {
+  Status s;
+
+  TransactionOptions txn_options;
+  ColumnFamilyHandle *cfa, *cfb;
+  ColumnFamilyOptions cf_options;
+
+  // Create 2 new column families
+  s = db->CreateColumnFamily(cf_options, "CFA", &cfa);
+  ASSERT_OK(s);
+  s = db->CreateColumnFamily(cf_options, "CFB", &cfb);
+  ASSERT_OK(s);
+
+  delete cfa;
+  delete cfb;
+  delete db;
+
+  // open DB with three column families
+  std::vector<ColumnFamilyDescriptor> column_families;
+  // have to open default column family
+  column_families.push_back(
+      ColumnFamilyDescriptor(kDefaultColumnFamilyName, ColumnFamilyOptions()));
+  // open the new column families
+  column_families.push_back(
+      ColumnFamilyDescriptor("CFA", ColumnFamilyOptions()));
+  column_families.push_back(
+      ColumnFamilyDescriptor("CFB", ColumnFamilyOptions()));
+
+  ColumnFamilyOptions* cf_opt_default = &column_families[0].options;
+  ColumnFamilyOptions* cf_opt_cfa = &column_families[1].options;
+  ColumnFamilyOptions* cf_opt_cfb = &column_families[2].options;
+  cf_opt_default->disable_auto_compactions = false;
+  cf_opt_cfa->disable_auto_compactions = true;
+  cf_opt_cfb->disable_auto_compactions = false;
+
+  std::vector<ColumnFamilyHandle*> handles;
+
+  s = TransactionDB::Open(options, txn_db_options, dbname, column_families,
+                          &handles, &db);
+  ASSERT_OK(s);
+
+  auto cfh_default = reinterpret_cast<ColumnFamilyHandleImpl*>(handles[0]);
+  auto opt_default = *cfh_default->cfd()->GetLatestMutableCFOptions();
+
+  auto cfh_a = reinterpret_cast<ColumnFamilyHandleImpl*>(handles[1]);
+  auto opt_a = *cfh_a->cfd()->GetLatestMutableCFOptions();
+
+  auto cfh_b = reinterpret_cast<ColumnFamilyHandleImpl*>(handles[2]);
+  auto opt_b = *cfh_b->cfd()->GetLatestMutableCFOptions();
+
+  ASSERT_EQ(opt_default.disable_auto_compactions, false);
+  ASSERT_EQ(opt_a.disable_auto_compactions, true);
+  ASSERT_EQ(opt_b.disable_auto_compactions, false);
+
+  for (auto handle : handles) {
+    delete handle;
+  }
+}
+
 }  // namespace rocksdb
 
 int main(int argc, char** argv) {
diff --git a/src/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc b/src/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc
index ba90ec1..bae4535 100644
--- a/src/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc
+++ b/src/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc
@@ -706,7 +706,7 @@ Status WriteBatchWithIndex::GetFromBatchAndDB(DB* db,
   // Did not find key in batch OR could not resolve Merges.  Try DB.
   s = db->Get(read_options, column_family, key, value);
 
-  if (s.ok() || s.IsNotFound()) {  // DB Get Suceeded
+  if (s.ok() || s.IsNotFound()) {  // DB Get Succeeded
     if (result == WriteBatchWithIndexInternal::Result::kMergeInProgress) {
       // Merge result from DB with merges in Batch
       auto cfh = reinterpret_cast<ColumnFamilyHandleImpl*>(column_family);
diff --git a/src/test/Makefile-client.am b/src/test/Makefile-client.am
index d44a977..967dde4 100644
--- a/src/test/Makefile-client.am
+++ b/src/test/Makefile-client.am
@@ -19,6 +19,14 @@ ceph_dencoder_CFLAGS += -fno-var-tracking-assignments
 ceph_dencoder_CXXFLAGS += -fno-var-tracking-assignments
 endif
 
+if WITH_RBD
+ceph_dencoder_CXXFLAGS += -DWITH_RBD
+endif
+if WITH_RADOSGW
+ceph_dencoder_CXXFLAGS += -DWITH_RADOSGW
+endif
+
+
 bin_PROGRAMS += ceph-dencoder
 
 
@@ -29,7 +37,7 @@ libradostest_la_SOURCES = \
 	test/librados/TestCase.cc
 noinst_LTLIBRARIES += libradostest.la
 libradostest_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
-RADOS_TEST_LDADD = libradostest.la
+RADOS_TEST_LDADD = libradostest.la $(LIBCOMMON) $(CRYPTO_LIBS)
 
 ceph_test_rados_SOURCES = \
 	test/osd/TestRados.cc \
@@ -316,7 +324,7 @@ unittest_journal_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_journal_LDADD = \
 	libjournal.la libcls_journal_client.la \
 	librados_test_stub.la librados_internal.la \
-	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
+	$(UNITTEST_LDADD) $(CEPH_GLOBAL) $(RADOS_TEST_LDADD) $(LIBRADOS)
 check_TESTPROGRAMS += unittest_journal
 
 if WITH_RBD
@@ -344,9 +352,9 @@ librbd_test_la_SOURCES = \
 	test/librbd/test_librbd.cc \
 	test/librbd/test_ImageWatcher.cc \
 	test/librbd/test_internal.cc \
-	test/librbd/test_JournalEntries.cc \
-	test/librbd/test_JournalReplay.cc \
-	test/librbd/test_ObjectMap.cc
+	test/librbd/test_ObjectMap.cc \
+	test/librbd/journal/test_Entries.cc \
+	test/librbd/journal/test_Replay.cc
 librbd_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 noinst_LTLIBRARIES += librbd_test.la
 
@@ -354,8 +362,10 @@ unittest_librbd_SOURCES = \
         test/librbd/test_main.cc \
 	test/librbd/test_mock_fixture.cc \
 	test/librbd/test_mock_ExclusiveLock.cc \
+	test/librbd/test_mock_Journal.cc \
 	test/librbd/exclusive_lock/test_mock_AcquireRequest.cc \
 	test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc \
+	test/librbd/journal/test_mock_Replay.cc \
 	test/librbd/object_map/test_mock_InvalidateRequest.cc \
 	test/librbd/object_map/test_mock_LockRequest.cc \
 	test/librbd/object_map/test_mock_RefreshRequest.cc \
@@ -365,9 +375,11 @@ unittest_librbd_SOURCES = \
 	test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc \
 	test/librbd/object_map/test_mock_UnlockRequest.cc \
 	test/librbd/object_map/test_mock_UpdateRequest.cc \
+	test/librbd/operation/test_mock_ResizeRequest.cc \
 	test/librbd/operation/test_mock_SnapshotCreateRequest.cc \
 	test/librbd/operation/test_mock_SnapshotProtectRequest.cc \
 	test/librbd/operation/test_mock_SnapshotRemoveRequest.cc \
+	test/librbd/operation/test_mock_SnapshotRollbackRequest.cc \
 	test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
 unittest_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
 unittest_librbd_LDADD = \
@@ -375,7 +387,7 @@ unittest_librbd_LDADD = \
 	libcls_rbd_client.la libcls_lock_client.la \
 	libjournal.la libcls_journal_client.la \
 	librados_test_stub.la librados_internal.la \
-	$(LIBOSDC) $(UNITTEST_LDADD) \
+	$(LIBRADOS) $(LIBOSDC) $(UNITTEST_LDADD) \
 	$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
 check_PROGRAMS += unittest_librbd
 check_SCRIPTS += test/run-rbd-unit-tests.sh
@@ -411,6 +423,7 @@ noinst_HEADERS += \
 	test/librbd/mock/MockImageWatcher.h \
 	test/librbd/mock/MockJournal.h \
 	test/librbd/mock/MockObjectMap.h \
+	test/librbd/mock/MockOperations.h \
 	test/librbd/mock/MockReadahead.h \
 	test/librbd/object_map/mock/MockInvalidateRequest.h
 
@@ -497,7 +510,9 @@ ceph_test_libcephfs_SOURCES = \
 	test/libcephfs/readdir_r_cb.cc \
 	test/libcephfs/caps.cc \
 	test/libcephfs/multiclient.cc \
-	test/libcephfs/access.cc
+	test/libcephfs/access.cc \
+	test/libcephfs/acl.cc
+
 if LINUX
 ceph_test_libcephfs_SOURCES += test/libcephfs/flock.cc
 endif # LINUX
diff --git a/src/test/Makefile-server.am b/src/test/Makefile-server.am
index 4e4d70f..fc4d53d 100644
--- a/src/test/Makefile-server.am
+++ b/src/test/Makefile-server.am
@@ -8,10 +8,6 @@ ceph_test_msgr_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 ceph_test_msgr_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 bin_DEBUGPROGRAMS += ceph_test_msgr
 
-ceph_streamtest_SOURCES = test/streamtest.cc
-ceph_streamtest_LDADD = $(LIBOS) $(CEPH_GLOBAL)
-bin_DEBUGPROGRAMS += ceph_streamtest
-
 ceph_test_trans_SOURCES = test/test_trans.cc
 ceph_test_trans_LDADD = $(LIBOS) $(CEPH_GLOBAL)
 bin_DEBUGPROGRAMS += ceph_test_trans
@@ -64,6 +60,17 @@ ceph_test_filestore_SOURCES = test/filestore/TestFileStore.cc
 ceph_test_filestore_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 ceph_test_filestore_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 bin_DEBUGPROGRAMS += ceph_test_filestore
+
+unittest_bluefs_SOURCES = test/objectstore/test_bluefs.cc
+unittest_bluefs_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+unittest_bluefs_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+check_TESTPROGRAMS += unittest_bluefs
+
+unittest_bluestore_types_SOURCES = test/objectstore/test_bluestore_types.cc
+unittest_bluestore_types_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+unittest_bluestore_types_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+check_TESTPROGRAMS += unittest_bluestore_types
+
 endif
 
 ceph_test_objectstore_workloadgen_SOURCES = \
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index ab66504..a9d3dbd 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -1,5 +1,6 @@
 include test/erasure-code/Makefile.am
 include test/messenger/Makefile.am
+include test/compressor/Makefile.am
 
 if ENABLE_CLIENT
 include test/Makefile-client.am
@@ -81,9 +82,11 @@ check_SCRIPTS += \
 	test/osd/osd-scrub-repair.sh \
 	test/osd/osd-scrub-snaps.sh \
 	test/osd/osd-config.sh \
+	test/osd/osd-reuse-id.sh \
 	test/osd/osd-bench.sh \
 	test/osd/osd-reactivate.sh \
 	test/osd/osd-copy-from.sh \
+	test/osd/osd-markdown.sh \
 	test/mon/mon-handle-forward.sh \
 	test/libradosstriper/rados-striper.sh \
 	test/test_objectstore_memstore.sh
@@ -189,6 +192,11 @@ unittest_sloppy_crc_map_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_sloppy_crc_map_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL)
 check_TESTPROGRAMS += unittest_sloppy_crc_map
 
+unittest_time_SOURCES = test/common/test_time.cc
+unittest_time_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+unittest_time_LDADD = $(LIBCOMMON) -lm $(UNITTEST_LDADD) $(CRYPTO_LIBS) $(EXTRALIBS)
+check_TESTPROGRAMS += unittest_time
+
 unittest_util_SOURCES = test/common/test_util.cc
 unittest_util_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 unittest_util_LDADD = $(LIBCOMMON) -lm $(UNITTEST_LDADD) $(CRYPTO_LIBS) $(EXTRALIBS)
@@ -418,7 +426,7 @@ check_PROGRAMS += unittest_subprocess
 
 unittest_async_compressor_SOURCES = test/common/test_async_compressor.cc
 unittest_async_compressor_CXXFLAGS = $(UNITTEST_CXXFLAGS)
-unittest_async_compressor_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(LIBCOMPRESSOR)
+unittest_async_compressor_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(LIBCOMPRESSOR) $(LIBCOMMON)
 check_PROGRAMS += unittest_async_compressor
 
 check_SCRIPTS += test/pybind/test_ceph_argparse.py
diff --git a/src/test/ObjectMap/test_object_map.cc b/src/test/ObjectMap/test_object_map.cc
index 6af60cf..0d504df 100644
--- a/src/test/ObjectMap/test_object_map.cc
+++ b/src/test/ObjectMap/test_object_map.cc
@@ -7,8 +7,8 @@
 #include "include/buffer.h"
 #include "test/ObjectMap/KeyValueDBMemory.h"
 #include "kv/KeyValueDB.h"
-#include "os/DBObjectMap.h"
-#include "os/HashIndex.h"
+#include "os/filestore/DBObjectMap.h"
+#include "os/filestore/HashIndex.h"
 #include <sys/types.h>
 #include "global/global_init.h"
 #include "common/ceph_argparse.h"
diff --git a/src/test/bench/dumb_backend.h b/src/test/bench/dumb_backend.h
index b3a19a7..38e160d 100644
--- a/src/test/bench/dumb_backend.h
+++ b/src/test/bench/dumb_backend.h
@@ -123,13 +123,13 @@ public:
       do_fadvise(do_fadvise),
       sync_interval(sync_interval),
       sync_fd(sync_fd),
-      tp(cct, "DumbBackend::tp", worker_threads),
+      tp(cct, "DumbBackend::tp", "tp_dumb_backend", worker_threads),
       thread(this),
       sync_loop_mutex("DumbBackend::sync_loop_mutex"),
       sync_loop_stop(0),
       pending_commit_mutex("DumbBackend::pending_commit_mutex"),
       queue(this, 20, &tp) {
-    thread.create();
+    thread.create("thread");
     tp.start();
     for (unsigned i = 0; i < 10*worker_threads; ++i) {
       sem.Put();
diff --git a/src/test/bench/small_io_bench_dumb.cc b/src/test/bench/small_io_bench_dumb.cc
index c9d9f51..f118880 100644
--- a/src/test/bench/small_io_bench_dumb.cc
+++ b/src/test/bench/small_io_bench_dumb.cc
@@ -22,7 +22,7 @@
 #include "detailed_stat_collector.h"
 #include "distribution.h"
 #include "global/global_init.h"
-#include "os/FileStore.h"
+#include "os/ObjectStore.h"
 #include "dumb_backend.h"
 
 namespace po = boost::program_options;
diff --git a/src/test/bench/small_io_bench_fs.cc b/src/test/bench/small_io_bench_fs.cc
index 4b273e4..75ec051 100644
--- a/src/test/bench/small_io_bench_fs.cc
+++ b/src/test/bench/small_io_bench_fs.cc
@@ -20,7 +20,7 @@
 #include "detailed_stat_collector.h"
 #include "distribution.h"
 #include "global/global_init.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "testfilestore_backend.h"
 #include "common/perf_counters.h"
 
@@ -236,7 +236,7 @@ int main(int argc, char **argv)
   for (vector<ceph::shared_ptr<Bencher> >::iterator i = benchers.begin();
        i != benchers.end();
        ++i) {
-    (*i)->create();
+    (*i)->create("bencher");
   }
   for (vector<ceph::shared_ptr<Bencher> >::iterator i = benchers.begin();
        i != benchers.end();
diff --git a/src/test/bench/tp_bench.cc b/src/test/bench/tp_bench.cc
index 23185a7..6bc6be1 100644
--- a/src/test/bench/tp_bench.cc
+++ b/src/test/bench/tp_bench.cc
@@ -173,7 +173,7 @@ int main(int argc, char **argv)
     if (*i == 'q') {
       ThreadPool *tp =
 	new ThreadPool(
-	  g_ceph_context, ss.str(), vm["num-threads"].as<unsigned>(), 0);
+	  g_ceph_context, ss.str(), "tp_test",  vm["num-threads"].as<unsigned>(), 0);
       wqs.push_back(
 	new WQWrapper(
 	  new PassAlong(tp, wqs.back()),
diff --git a/src/test/bench_log.cc b/src/test/bench_log.cc
index 774cf55..a80e14a 100644
--- a/src/test/bench_log.cc
+++ b/src/test/bench_log.cc
@@ -46,22 +46,15 @@ int main(int argc, const char **argv)
   list<T*> ls;
   for (int i=0; i<threads; i++) {
     T *t = new T(num);
-    t->create();
+    t->create("t");
     ls.push_back(t);
   }
 
   for (int i=0; i<threads; i++) {
     T *t = ls.front();
     ls.pop_front();
-    try {
-      t->join();
-    }
-    catch (ceph::FailedAssertion &a) {
-      cout << "Failed assert in join(), exit." << std::endl;
-      delete t;
-      return -1;
-    }
-    delete t;    
+    t->join();
+    delete t;
   }
 
   utime_t t = ceph_clock_now(NULL);
diff --git a/src/test/bufferlist.cc b/src/test/bufferlist.cc
index d2df058..77ca3ec 100644
--- a/src/test/bufferlist.cc
+++ b/src/test/bufferlist.cc
@@ -445,8 +445,8 @@ TEST(BufferPtr, constructors) {
     EXPECT_EQ(original.get_raw(), ptr.get_raw());
     EXPECT_EQ(2, ptr.raw_nref());
     EXPECT_EQ(0, ::memcmp(original.c_str(), ptr.c_str(), len));
-    EXPECT_THROW(bufferptr(original, 0, original.length() + 1), FailedAssertion);
-    EXPECT_THROW(bufferptr(bufferptr(), 0, 0), FailedAssertion);
+    EXPECT_DEATH(bufferptr(original, 0, original.length() + 1), "");
+    EXPECT_DEATH(bufferptr(bufferptr(), 0, 0), "");
   }
 }
 
@@ -592,14 +592,14 @@ TEST(BufferPtr, accessors) {
   EXPECT_EQ('X', ptr.c_str()[0]);
   {
     bufferptr ptr;
-    EXPECT_THROW(ptr.c_str(), FailedAssertion);
-    EXPECT_THROW(ptr[0], FailedAssertion);
+    EXPECT_DEATH(ptr.c_str(), "");
+    EXPECT_DEATH(ptr[0], "");
   }
   EXPECT_EQ('X', const_ptr.c_str()[0]);
   {
     const bufferptr const_ptr;
-    EXPECT_THROW(const_ptr.c_str(), FailedAssertion);
-    EXPECT_THROW(const_ptr[0], FailedAssertion);
+    EXPECT_DEATH(const_ptr.c_str(), "");
+    EXPECT_DEATH(const_ptr[0], "");
   }
   EXPECT_EQ(len, const_ptr.length());
   EXPECT_EQ((unsigned)0, const_ptr.offset());
@@ -616,13 +616,13 @@ TEST(BufferPtr, accessors) {
     bufferptr ptr;
     EXPECT_EQ((unsigned)0, ptr.unused_tail_length());
   }
-  EXPECT_THROW(ptr[len], FailedAssertion);
-  EXPECT_THROW(const_ptr[len], FailedAssertion);
+  EXPECT_DEATH(ptr[len], "");
+  EXPECT_DEATH(const_ptr[len], "");
   {
     const bufferptr const_ptr;
-    EXPECT_THROW(const_ptr.raw_c_str(), FailedAssertion);
-    EXPECT_THROW(const_ptr.raw_length(), FailedAssertion);
-    EXPECT_THROW(const_ptr.raw_nref(), FailedAssertion);
+    EXPECT_DEATH(const_ptr.raw_c_str(), "");
+    EXPECT_DEATH(const_ptr.raw_length(), "");
+    EXPECT_DEATH(const_ptr.raw_nref(), "");
   }
   EXPECT_NE((const char *)NULL, const_ptr.raw_c_str());
   EXPECT_EQ(len, const_ptr.raw_length());
@@ -668,7 +668,7 @@ TEST(BufferPtr, is_zero) {
 TEST(BufferPtr, copy_out) {
   {
     const bufferptr ptr;
-    EXPECT_THROW(ptr.copy_out((unsigned)0, (unsigned)0, NULL), FailedAssertion);
+    EXPECT_DEATH(ptr.copy_out((unsigned)0, (unsigned)0, NULL), "");
   }
   {
     char in[] = "ABC";
@@ -703,13 +703,13 @@ TEST(BufferPtr, copy_out_bench) {
 TEST(BufferPtr, copy_in) {
   {
     bufferptr ptr;
-    EXPECT_THROW(ptr.copy_in((unsigned)0, (unsigned)0, NULL), FailedAssertion);
+    EXPECT_DEATH(ptr.copy_in((unsigned)0, (unsigned)0, NULL), "");
   }
   {
     char in[] = "ABCD";
     bufferptr ptr(2);
-    EXPECT_THROW(ptr.copy_in((unsigned)0, strlen(in) + 1, NULL), FailedAssertion);
-    EXPECT_THROW(ptr.copy_in(strlen(in) + 1, (unsigned)0, NULL), FailedAssertion);
+    EXPECT_DEATH(ptr.copy_in((unsigned)0, strlen(in) + 1, NULL), "");
+    EXPECT_DEATH(ptr.copy_in(strlen(in) + 1, (unsigned)0, NULL), "");
     ptr.copy_in((unsigned)0, (unsigned)2, in);
     EXPECT_EQ(in[0], ptr[0]);
     EXPECT_EQ(in[1], ptr[1]);
@@ -737,13 +737,13 @@ TEST(BufferPtr, copy_in_bench) {
 TEST(BufferPtr, append) {
   {
     bufferptr ptr;
-    EXPECT_THROW(ptr.append('A'), FailedAssertion);
-    EXPECT_THROW(ptr.append("B", (unsigned)1), FailedAssertion);
+    EXPECT_DEATH(ptr.append('A'), "");
+    EXPECT_DEATH(ptr.append("B", (unsigned)1), "");
   }
   {
     bufferptr ptr(2);
-    EXPECT_THROW(ptr.append('A'), FailedAssertion);
-    EXPECT_THROW(ptr.append("B", (unsigned)1), FailedAssertion);
+    EXPECT_DEATH(ptr.append('A'), "");
+    EXPECT_DEATH(ptr.append("B", (unsigned)1), "");
     ptr.set_length(0);
     ptr.append('A');
     EXPECT_EQ((unsigned)1, ptr.length());
@@ -776,7 +776,7 @@ TEST(BufferPtr, append_bench) {
 TEST(BufferPtr, zero) {
   char str[] = "XXXX";
   bufferptr ptr(buffer::create_static(strlen(str), str));
-  EXPECT_THROW(ptr.zero(ptr.length() + 1, 0), FailedAssertion);
+  EXPECT_DEATH(ptr.zero(ptr.length() + 1, 0), "");
   ptr.zero(1, 1);
   EXPECT_EQ('X', ptr[0]);
   EXPECT_EQ('\0', ptr[1]);
@@ -876,6 +876,17 @@ TEST(BufferListIterator, constructors) {
   }
 }
 
+TEST(BufferListIterator, empty_create_append_copy) {
+  bufferlist bl, bl2, bl3, out;
+  bl2.append("bar");
+  bl.swap(bl2);
+  bl2.append("xxx");
+  bl.append(bl2);
+  bl.rebuild();
+  bl.copy(0, 6, out);
+  ASSERT_TRUE(out.contents_equal(bl));
+}
+
 TEST(BufferListIterator, operator_equal) {
   bufferlist bl;
   bl.append("ABC", 3);
@@ -1882,7 +1893,7 @@ TEST(BufferList, append) {
     bufferptr in(back);
     EXPECT_EQ((unsigned)1, bl.buffers().size());
     EXPECT_EQ((unsigned)1, bl.length());
-    EXPECT_THROW(bl.append(in, (unsigned)100, (unsigned)100), FailedAssertion);
+    EXPECT_DEATH(bl.append(in, (unsigned)100, (unsigned)100), "");
     EXPECT_LT((unsigned)0, in.unused_tail_length());
     in.append('B');
     bl.append(in, back.end(), 1);
@@ -2061,8 +2072,9 @@ TEST(BufferList, hexdump) {
   std::ostringstream stream;
   bl.append("013245678901234\0006789012345678901234", 32);
   bl.hexdump(stream);
-  EXPECT_EQ("0000 : 30 31 33 32 34 35 36 37 38 39 30 31 32 33 34 00 : 013245678901234.\n"
-	    "0010 : 36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 : 6789012345678901\n",
+  EXPECT_EQ("00000000  30 31 33 32 34 35 36 37  38 39 30 31 32 33 34 00  |013245678901234.|\n"
+	    "00000010  36 37 38 39 30 31 32 33  34 35 36 37 38 39 30 31  |6789012345678901|\n"
+	    "00000020\n",
 	    stream.str());
 }
 
@@ -2398,7 +2410,7 @@ TEST(BufferList, zero) {
       bufferptr ptr(s[i], strlen(s[i]));
       bl.push_back(ptr);
     }
-    EXPECT_THROW(bl.zero((unsigned)0, (unsigned)2000), FailedAssertion);
+    EXPECT_DEATH(bl.zero((unsigned)0, (unsigned)2000), "");
     bl.zero((unsigned)2, (unsigned)5);
     EXPECT_EQ(0, ::memcmp("AB\0\0\0\0\0HIKLM", bl.c_str(), 9));
   }
diff --git a/src/test/centos-6/ceph.spec.in b/src/test/centos-6/ceph.spec.in
index 52c5c1d..487232c 100644
--- a/src/test/centos-6/ceph.spec.in
+++ b/src/test/centos-6/ceph.spec.in
@@ -1,4 +1,19 @@
 # vim: set noexpandtab ts=8 sw=8 :
+#
+# spec file for package ceph
+#
+# Copyright (C) 2004-2016 The Ceph Project Developers. See COPYING file
+# at the top-level directory of this distribution and at
+# https://github.com/ceph/ceph/blob/master/COPYING
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon.
+#
+# This file is under the GNU Lesser General Public License, version 2.1
+#
+# Please submit bugfixes or comments via http://tracker.ceph.com/
+# 
 %bcond_with ocf
 %bcond_without cephfs_java
 %bcond_with tests
@@ -133,6 +148,7 @@ BuildRequires:	python-requests
 BuildRequires:	python-virtualenv
 BuildRequires:	snappy-devel
 BuildRequires:	util-linux
+BuildRequires:	valgrind-devel
 BuildRequires:	xfsprogs
 BuildRequires:	xfsprogs-devel
 BuildRequires:	xmlstarlet
@@ -168,7 +184,6 @@ BuildRequires:	libatomic-ops-devel
 %if 0%{?_with_systemd}
 Requires:	systemd
 %endif
-BuildRequires:  bzip2-devel
 BuildRequires:	nss-devel
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	libatomic_ops-devel
@@ -790,6 +805,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ceph-mon
 %{_bindir}/ceph-mds
 %{_bindir}/ceph-objectstore-tool
+%{_bindir}/ceph-bluefs-tool
 %{_bindir}/ceph-osd
 %{_bindir}/ceph-detect-init
 %{_bindir}/librados-config
@@ -844,6 +860,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/rados-classes/libcls_journal.so*
 %dir %{_libdir}/ceph/erasure-code
 %{_libdir}/ceph/erasure-code/libec_*.so*
+%dir %{_libdir}/ceph/compressor
+%{_libdir}/ceph/compressor/libceph_*.so*
 %if 0%{?_with_lttng}
 %{_libdir}/libos_tp.so*
 %{_libdir}/libosd_tp.so*
@@ -1179,6 +1197,7 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %files -n python-cephfs
 %defattr(-,root,root,-)
 %{python_sitelib}/cephfs.py*
+%{python_sitelib}/ceph_volume_client.py*
 
 #################################################################################
 %files -n ceph-test
@@ -1204,7 +1223,6 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %{_bindir}/ceph_smalliobenchdumb
 %{_bindir}/ceph_smalliobenchfs
 %{_bindir}/ceph_smalliobenchrbd
-%{_bindir}/ceph_streamtest
 %{_bindir}/ceph_test_*
 %{_bindir}/ceph_tpbench
 %{_bindir}/ceph_xattr_bench
diff --git a/src/test/centos-7/ceph.spec.in b/src/test/centos-7/ceph.spec.in
index 52c5c1d..487232c 100644
--- a/src/test/centos-7/ceph.spec.in
+++ b/src/test/centos-7/ceph.spec.in
@@ -1,4 +1,19 @@
 # vim: set noexpandtab ts=8 sw=8 :
+#
+# spec file for package ceph
+#
+# Copyright (C) 2004-2016 The Ceph Project Developers. See COPYING file
+# at the top-level directory of this distribution and at
+# https://github.com/ceph/ceph/blob/master/COPYING
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon.
+#
+# This file is under the GNU Lesser General Public License, version 2.1
+#
+# Please submit bugfixes or comments via http://tracker.ceph.com/
+# 
 %bcond_with ocf
 %bcond_without cephfs_java
 %bcond_with tests
@@ -133,6 +148,7 @@ BuildRequires:	python-requests
 BuildRequires:	python-virtualenv
 BuildRequires:	snappy-devel
 BuildRequires:	util-linux
+BuildRequires:	valgrind-devel
 BuildRequires:	xfsprogs
 BuildRequires:	xfsprogs-devel
 BuildRequires:	xmlstarlet
@@ -168,7 +184,6 @@ BuildRequires:	libatomic-ops-devel
 %if 0%{?_with_systemd}
 Requires:	systemd
 %endif
-BuildRequires:  bzip2-devel
 BuildRequires:	nss-devel
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	libatomic_ops-devel
@@ -790,6 +805,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ceph-mon
 %{_bindir}/ceph-mds
 %{_bindir}/ceph-objectstore-tool
+%{_bindir}/ceph-bluefs-tool
 %{_bindir}/ceph-osd
 %{_bindir}/ceph-detect-init
 %{_bindir}/librados-config
@@ -844,6 +860,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/rados-classes/libcls_journal.so*
 %dir %{_libdir}/ceph/erasure-code
 %{_libdir}/ceph/erasure-code/libec_*.so*
+%dir %{_libdir}/ceph/compressor
+%{_libdir}/ceph/compressor/libceph_*.so*
 %if 0%{?_with_lttng}
 %{_libdir}/libos_tp.so*
 %{_libdir}/libosd_tp.so*
@@ -1179,6 +1197,7 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %files -n python-cephfs
 %defattr(-,root,root,-)
 %{python_sitelib}/cephfs.py*
+%{python_sitelib}/ceph_volume_client.py*
 
 #################################################################################
 %files -n ceph-test
@@ -1204,7 +1223,6 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %{_bindir}/ceph_smalliobenchdumb
 %{_bindir}/ceph_smalliobenchfs
 %{_bindir}/ceph_smalliobenchrbd
-%{_bindir}/ceph_streamtest
 %{_bindir}/ceph_test_*
 %{_bindir}/ceph_tpbench
 %{_bindir}/ceph_xattr_bench
diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh
index be466fa..6b63527 100755
--- a/src/test/ceph-disk.sh
+++ b/src/test/ceph-disk.sh
@@ -49,6 +49,7 @@ CEPH_ARGS+=" --log-file=$DIR/\$name.log"
 CEPH_ARGS+=" --pid-file=$DIR/\$name.pidfile"
 if test -d .libs ; then
     CEPH_ARGS+=" --erasure-code-dir=.libs"
+    CEPH_ARGS+=" --compression-dir=.libs"
 fi
 CEPH_ARGS+=" --auth-supported=none"
 CEPH_ARGS+=" --osd-journal-size=100"
diff --git a/src/test/ceph_compatset.cc b/src/test/ceph_compatset.cc
index 2b57db0..5cd7ef2 100644
--- a/src/test/ceph_compatset.cc
+++ b/src/test/ceph_compatset.cc
@@ -37,8 +37,8 @@ TEST(CephCompatSet, AllSet) {
   CompatSet::FeatureSet ro;
   CompatSet::FeatureSet incompat;
 
-  EXPECT_THROW(compat.insert(CompatSet::Feature(0, "test")), FailedAssertion);
-  EXPECT_THROW(compat.insert(CompatSet::Feature(64, "test")), FailedAssertion);
+  EXPECT_DEATH(compat.insert(CompatSet::Feature(0, "test")), "");
+  EXPECT_DEATH(compat.insert(CompatSet::Feature(64, "test")), "");
 
   for (int i = 1; i < 64; i++) {
     stringstream cname;
diff --git a/src/test/ceph_objectstore_tool.py b/src/test/ceph_objectstore_tool.py
index 186b0b6..060e144 100755
--- a/src/test/ceph_objectstore_tool.py
+++ b/src/test/ceph_objectstore_tool.py
@@ -887,17 +887,14 @@ def main(argv):
     ERRORS += test_failure(cmd, "stdin is a tty and no --file filename specified", tty=True)
 
     # Specify a bad --type
-    cmd = (CFSD_PREFIX + "--type foobar --op list --pgid {pg}").format(osd=ONEOSD, pg=ONEPG)
-    ERRORS += test_failure(cmd, "Must provide --type (filestore, memstore, keyvaluestore)")
+    os.mkdir(OSDDIR + "/fakeosd")
+    cmd = ("./ceph-objectstore-tool --data-path " + OSDDIR + "/{osd} --type foobar --op list --pgid {pg}").format(osd="fakeosd", pg=ONEPG)
+    ERRORS += test_failure(cmd, "Need a valid --type e.g. filestore, memstore, keyvaluestore")
 
     # Don't specify a data-path
     cmd = "./ceph-objectstore-tool --journal-path {dir}/{osd}.journal --type memstore --op list --pgid {pg}".format(dir=OSDDIR, osd=ONEOSD, pg=ONEPG)
     ERRORS += test_failure(cmd, "Must provide --data-path")
 
-    # Don't specify a journal-path for filestore
-    cmd = "./ceph-objectstore-tool --type filestore --data-path {dir}/{osd} --op list --pgid {pg}".format(dir=OSDDIR, osd=ONEOSD, pg=ONEPG)
-    ERRORS += test_failure(cmd, "Must provide --journal-path")
-
     cmd = (CFSD_PREFIX + "--op remove").format(osd=ONEOSD)
     ERRORS += test_failure(cmd, "Must provide pgid")
 
@@ -907,7 +904,7 @@ def main(argv):
 
     # Specify a bad --op command
     cmd = (CFSD_PREFIX + "--op oops").format(osd=ONEOSD)
-    ERRORS += test_failure(cmd, "Must provide --op (info, log, remove, export, import, list, fix-lost, list-pgs, rm-past-intervals, set-allow-sharded-objects, dump-journal, dump-super, meta-list, get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete)")
+    ERRORS += test_failure(cmd, "Must provide --op (info, log, remove, fsck, export, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete)")
 
     # Provide just the object param not a command
     cmd = (CFSD_PREFIX + "object").format(osd=ONEOSD)
diff --git a/src/test/cli/crushtool/arg-order-checks.t b/src/test/cli/crushtool/arg-order-checks.t
index 787bb53..4d2ccae 100644
--- a/src/test/cli/crushtool/arg-order-checks.t
+++ b/src/test/cli/crushtool/arg-order-checks.t
@@ -79,7 +79,7 @@
   device 24 osd.24
   
   # types
-  type 0 device
+  type 0 osd
   type 1 node
   type 2 rack
   type 3 root
diff --git a/src/test/cli/crushtool/build.t b/src/test/cli/crushtool/build.t
index 57fb2b2..0bf13e0 100644
--- a/src/test/cli/crushtool/build.t
+++ b/src/test/cli/crushtool/build.t
@@ -36,7 +36,7 @@
   device 0 osd.0
   
   # types
-  type 0 device
+  type 0 osd
   type 1 root
   
   # buckets
diff --git a/src/test/cli/crushtool/check-overlapped-rules.crushmap.txt b/src/test/cli/crushtool/check-overlapped-rules.crushmap.txt
new file mode 100644
index 0000000..cd88863
--- /dev/null
+++ b/src/test/cli/crushtool/check-overlapped-rules.crushmap.txt
@@ -0,0 +1,89 @@
+device 0 device0
+device 1 device1
+device 2 device2
+device 3 device3
+device 4 device4
+
+type 0 osd
+type 1 host
+
+host host0 {
+	id -1
+	alg straw
+	hash 0
+	item device0 weight 1.000
+	item device1 weight 1.000
+	item device2 weight 1.000
+	item device3 weight 1.000
+	item device4 weight 1.000
+}
+
+rule rule-r0 {
+	ruleset 0
+	type replicated
+	min_size 1
+	max_size 3
+	step take host0
+	step choose firstn 0 type osd
+	step emit
+}
+
+rule rule-r1 {
+	ruleset 0
+	type replicated
+	min_size 1
+	max_size 1
+	step take host0
+	step choose firstn 0 type osd
+	step emit
+}
+
+rule rule-r2 {
+	ruleset 0
+	type replicated
+	min_size 1
+	max_size 2
+	step take host0
+	step choose firstn 0 type osd
+	step emit
+}
+
+rule rule-r3 {
+	ruleset 0
+	type replicated
+	min_size 2
+	max_size 3
+	step take host0
+	step choose indep 0 type osd
+	step emit
+}
+
+rule rule-r4 {
+	ruleset 0
+	type replicated
+	min_size 4
+	max_size 5
+	step take host0
+	step choose indep 0 type osd
+	step emit
+}
+
+rule rule-e0 {
+	ruleset 0
+	type erasure
+	min_size 1
+	max_size 10
+	step take host0
+	step choose indep 0 type osd
+	step emit
+}
+
+rule rule-e1 {
+	ruleset 1
+	type erasure
+	min_size 1
+	max_size 10
+	step take host0
+	step choose indep 0 type osd
+	step emit
+}
diff --git a/src/test/cli/crushtool/check-overlapped-rules.t b/src/test/cli/crushtool/check-overlapped-rules.t
new file mode 100644
index 0000000..acad57d
--- /dev/null
+++ b/src/test/cli/crushtool/check-overlapped-rules.t
@@ -0,0 +1,6 @@
+  $ crushtool -c "$TESTDIR/check-overlapped-rules.crushmap.txt" -o "$TESTDIR/check-overlapped-rules.crushmap"
+  $ crushtool -i "$TESTDIR/check-overlapped-rules.crushmap" --check
+  overlapped rules in ruleset 0: rule-r0, rule-r1, rule-r2
+  overlapped rules in ruleset 0: rule-r0, rule-r2, rule-r3
+  overlapped rules in ruleset 0: rule-r0, rule-r3
+  $ rm -f "$TESTDIR/check-overlapped-rules.crushmap"
diff --git a/src/test/cli/crushtool/help.t b/src/test/cli/crushtool/help.t
old mode 100644
new mode 100755
index b737474..e5ead08
--- a/src/test/cli/crushtool/help.t
+++ b/src/test/cli/crushtool/help.t
@@ -22,10 +22,11 @@
      [--outfn|-o outfile]
                            specify output for for (de)compilation
      --compile|-c map.txt  compile a map from source
-     --enable-unsafe-tunables compile with unsafe tunables
+     --enable-unsafe-tunables
+                           compile with unsafe tunables
      --build --num_osds N layer1 ...
                            build a new map, where each 'layer' is
-                             'name (uniform|straw|list|tree) size'
+                           'name (uniform|straw|list|tree) size'
   
   Options for the tunables adjustments stage
   
@@ -40,6 +41,8 @@
                            set chooseleaf to (not) retry the recursive descent
      --set-chooseleaf-vary-r <0|1>
                            set chooseleaf to (not) vary r based on parent
+     --set-chooseleaf-stable <0|1>
+                           set chooseleaf firstn to (not) return stable results
   
   Options for the modifications stage
   
@@ -73,7 +76,7 @@
                            number generator in place of the CRUSH
                            algorithm
      --show-utilization    show OSD usage
-     --show utilization-all
+     --show-utilization-all
                            include zero weight items
      --show-statistics     show chi squared statistics
      --show-mappings       show mappings
@@ -90,23 +93,23 @@
   Options for the output stage
   
      [--outfn|-o outfile]
-                           specify output for for modified crush map
+                           specify output for modified crush map
   
   $ crushtool --help-output
   data output from testing routine ...
-            absolute_weights
-                  the decimal weight of each OSD
-                  data layout: ROW MAJOR
-                               OSD id (int), weight (int)
+             absolute_weights
+                    the decimal weight of each OSD
+                    data layout: ROW MAJOR
+                                 OSD id (int), weight (int)
              batch_device_expected_utilization_all
-                   the expected number of objects each OSD should receive per placement batch
-                   which may be a decimal value
-                   data layout: COLUMN MAJOR
-                                round (int), objects expected on OSD 0...OSD n (float)
+                    the expected number of objects each OSD should receive per placement batch
+                    which may be a decimal value
+                    data layout: COLUMN MAJOR
+                                 round (int), objects expected on OSD 0...OSD n (float)
              batch_device_utilization_all
-                   the number of objects stored on each OSD during each placement round
-                   data layout: COLUMN MAJOR
-                                round (int), objects stored on OSD 0...OSD n (int)
+                    the number of objects stored on each OSD during each placement round
+                    data layout: COLUMN MAJOR
+                                 round (int), objects stored on OSD 0...OSD n (int)
              device_utilization_all
                     the number of objects stored on each OSD at the end of placements
                     data_layout: ROW MAJOR
diff --git a/src/test/cli/crushtool/test-map-hammer-tunables.crushmap b/src/test/cli/crushtool/test-map-hammer-tunables.crushmap
new file mode 100644
index 0000000..34a518d
Binary files /dev/null and b/src/test/cli/crushtool/test-map-hammer-tunables.crushmap differ
diff --git a/src/test/cli/crushtool/test-map-hammer-tunables.t b/src/test/cli/crushtool/test-map-hammer-tunables.t
new file mode 100644
index 0000000..75c15e2
--- /dev/null
+++ b/src/test/cli/crushtool/test-map-hammer-tunables.t
@@ -0,0 +1,10252 @@
+  $ crushtool -i "$TESTDIR/test-map-hammer-tunables.crushmap" --test --show-mappings --show-statistics --rule 0 --weight 12 0 --weight 20 0 --weight 30 0
+  rule 0 (data), x = 0..1023, numrep = 1..10
+  CRUSH rule 0 x 0 [101]
+  CRUSH rule 0 x 1 [80]
+  CRUSH rule 0 x 2 [91]
+  CRUSH rule 0 x 3 [51]
+  CRUSH rule 0 x 4 [50]
+  CRUSH rule 0 x 5 [89]
+  CRUSH rule 0 x 6 [91]
+  CRUSH rule 0 x 7 [104]
+  CRUSH rule 0 x 8 [78]
+  CRUSH rule 0 x 9 [101]
+  CRUSH rule 0 x 10 [61]
+  CRUSH rule 0 x 11 [13]
+  CRUSH rule 0 x 12 [83]
+  CRUSH rule 0 x 13 [108]
+  CRUSH rule 0 x 14 [105]
+  CRUSH rule 0 x 15 [18]
+  CRUSH rule 0 x 16 [103]
+  CRUSH rule 0 x 17 [85]
+  CRUSH rule 0 x 18 [11]
+  CRUSH rule 0 x 19 [75]
+  CRUSH rule 0 x 20 [79]
+  CRUSH rule 0 x 21 [84]
+  CRUSH rule 0 x 22 [23]
+  CRUSH rule 0 x 23 [118]
+  CRUSH rule 0 x 24 [83]
+  CRUSH rule 0 x 25 [81]
+  CRUSH rule 0 x 26 [38]
+  CRUSH rule 0 x 27 [76]
+  CRUSH rule 0 x 28 [76]
+  CRUSH rule 0 x 29 [8]
+  CRUSH rule 0 x 30 [94]
+  CRUSH rule 0 x 31 [76]
+  CRUSH rule 0 x 32 [72]
+  CRUSH rule 0 x 33 [77]
+  CRUSH rule 0 x 34 [74]
+  CRUSH rule 0 x 35 [22]
+  CRUSH rule 0 x 36 [104]
+  CRUSH rule 0 x 37 [38]
+  CRUSH rule 0 x 38 [72]
+  CRUSH rule 0 x 39 [68]
+  CRUSH rule 0 x 40 [103]
+  CRUSH rule 0 x 41 [85]
+  CRUSH rule 0 x 42 [106]
+  CRUSH rule 0 x 43 [10]
+  CRUSH rule 0 x 44 [101]
+  CRUSH rule 0 x 45 [8]
+  CRUSH rule 0 x 46 [65]
+  CRUSH rule 0 x 47 [106]
+  CRUSH rule 0 x 48 [34]
+  CRUSH rule 0 x 49 [0]
+  CRUSH rule 0 x 50 [42]
+  CRUSH rule 0 x 51 [104]
+  CRUSH rule 0 x 52 [83]
+  CRUSH rule 0 x 53 [32]
+  CRUSH rule 0 x 54 [28]
+  CRUSH rule 0 x 55 [14]
+  CRUSH rule 0 x 56 [21]
+  CRUSH rule 0 x 57 [93]
+  CRUSH rule 0 x 58 [45]
+  CRUSH rule 0 x 59 [80]
+  CRUSH rule 0 x 60 [90]
+  CRUSH rule 0 x 61 [88]
+  CRUSH rule 0 x 62 [81]
+  CRUSH rule 0 x 63 [79]
+  CRUSH rule 0 x 64 [1]
+  CRUSH rule 0 x 65 [13]
+  CRUSH rule 0 x 66 [48]
+  CRUSH rule 0 x 67 [94]
+  CRUSH rule 0 x 68 [102]
+  CRUSH rule 0 x 69 [62]
+  CRUSH rule 0 x 70 [84]
+  CRUSH rule 0 x 71 [55]
+  CRUSH rule 0 x 72 [97]
+  CRUSH rule 0 x 73 [64]
+  CRUSH rule 0 x 74 [96]
+  CRUSH rule 0 x 75 [29]
+  CRUSH rule 0 x 76 [55]
+  CRUSH rule 0 x 77 [107]
+  CRUSH rule 0 x 78 [31]
+  CRUSH rule 0 x 79 [64]
+  CRUSH rule 0 x 80 [0]
+  CRUSH rule 0 x 81 [71]
+  CRUSH rule 0 x 82 [37]
+  CRUSH rule 0 x 83 [92]
+  CRUSH rule 0 x 84 [49]
+  CRUSH rule 0 x 85 [54]
+  CRUSH rule 0 x 86 [37]
+  CRUSH rule 0 x 87 [116]
+  CRUSH rule 0 x 88 [38]
+  CRUSH rule 0 x 89 [76]
+  CRUSH rule 0 x 90 [14]
+  CRUSH rule 0 x 91 [93]
+  CRUSH rule 0 x 92 [86]
+  CRUSH rule 0 x 93 [44]
+  CRUSH rule 0 x 94 [61]
+  CRUSH rule 0 x 95 [93]
+  CRUSH rule 0 x 96 [66]
+  CRUSH rule 0 x 97 [111]
+  CRUSH rule 0 x 98 [66]
+  CRUSH rule 0 x 99 [78]
+  CRUSH rule 0 x 100 [28]
+  CRUSH rule 0 x 101 [84]
+  CRUSH rule 0 x 102 [82]
+  CRUSH rule 0 x 103 [66]
+  CRUSH rule 0 x 104 [14]
+  CRUSH rule 0 x 105 [87]
+  CRUSH rule 0 x 106 [69]
+  CRUSH rule 0 x 107 [1]
+  CRUSH rule 0 x 108 [94]
+  CRUSH rule 0 x 109 [112]
+  CRUSH rule 0 x 110 [54]
+  CRUSH rule 0 x 111 [10]
+  CRUSH rule 0 x 112 [89]
+  CRUSH rule 0 x 113 [69]
+  CRUSH rule 0 x 114 [79]
+  CRUSH rule 0 x 115 [50]
+  CRUSH rule 0 x 116 [96]
+  CRUSH rule 0 x 117 [87]
+  CRUSH rule 0 x 118 [23]
+  CRUSH rule 0 x 119 [104]
+  CRUSH rule 0 x 120 [57]
+  CRUSH rule 0 x 121 [105]
+  CRUSH rule 0 x 122 [45]
+  CRUSH rule 0 x 123 [112]
+  CRUSH rule 0 x 124 [110]
+  CRUSH rule 0 x 125 [66]
+  CRUSH rule 0 x 126 [51]
+  CRUSH rule 0 x 127 [70]
+  CRUSH rule 0 x 128 [90]
+  CRUSH rule 0 x 129 [103]
+  CRUSH rule 0 x 130 [50]
+  CRUSH rule 0 x 131 [23]
+  CRUSH rule 0 x 132 [69]
+  CRUSH rule 0 x 133 [52]
+  CRUSH rule 0 x 134 [78]
+  CRUSH rule 0 x 135 [78]
+  CRUSH rule 0 x 136 [32]
+  CRUSH rule 0 x 137 [92]
+  CRUSH rule 0 x 138 [17]
+  CRUSH rule 0 x 139 [89]
+  CRUSH rule 0 x 140 [39]
+  CRUSH rule 0 x 141 [89]
+  CRUSH rule 0 x 142 [70]
+  CRUSH rule 0 x 143 [51]
+  CRUSH rule 0 x 144 [13]
+  CRUSH rule 0 x 145 [77]
+  CRUSH rule 0 x 146 [96]
+  CRUSH rule 0 x 147 [2]
+  CRUSH rule 0 x 148 [74]
+  CRUSH rule 0 x 149 [76]
+  CRUSH rule 0 x 150 [38]
+  CRUSH rule 0 x 151 [90]
+  CRUSH rule 0 x 152 [49]
+  CRUSH rule 0 x 153 [71]
+  CRUSH rule 0 x 154 [94]
+  CRUSH rule 0 x 155 [75]
+  CRUSH rule 0 x 156 [107]
+  CRUSH rule 0 x 157 [112]
+  CRUSH rule 0 x 158 [26]
+  CRUSH rule 0 x 159 [52]
+  CRUSH rule 0 x 160 [41]
+  CRUSH rule 0 x 161 [84]
+  CRUSH rule 0 x 162 [55]
+  CRUSH rule 0 x 163 [54]
+  CRUSH rule 0 x 164 [45]
+  CRUSH rule 0 x 165 [25]
+  CRUSH rule 0 x 166 [73]
+  CRUSH rule 0 x 167 [89]
+  CRUSH rule 0 x 168 [47]
+  CRUSH rule 0 x 169 [51]
+  CRUSH rule 0 x 170 [68]
+  CRUSH rule 0 x 171 [73]
+  CRUSH rule 0 x 172 [117]
+  CRUSH rule 0 x 173 [13]
+  CRUSH rule 0 x 174 [116]
+  CRUSH rule 0 x 175 [3]
+  CRUSH rule 0 x 176 [94]
+  CRUSH rule 0 x 177 [52]
+  CRUSH rule 0 x 178 [39]
+  CRUSH rule 0 x 179 [72]
+  CRUSH rule 0 x 180 [60]
+  CRUSH rule 0 x 181 [18]
+  CRUSH rule 0 x 182 [22]
+  CRUSH rule 0 x 183 [11]
+  CRUSH rule 0 x 184 [92]
+  CRUSH rule 0 x 185 [97]
+  CRUSH rule 0 x 186 [67]
+  CRUSH rule 0 x 187 [116]
+  CRUSH rule 0 x 188 [69]
+  CRUSH rule 0 x 189 [47]
+  CRUSH rule 0 x 190 [65]
+  CRUSH rule 0 x 191 [49]
+  CRUSH rule 0 x 192 [68]
+  CRUSH rule 0 x 193 [0]
+  CRUSH rule 0 x 194 [62]
+  CRUSH rule 0 x 195 [119]
+  CRUSH rule 0 x 196 [72]
+  CRUSH rule 0 x 197 [106]
+  CRUSH rule 0 x 198 [114]
+  CRUSH rule 0 x 199 [0]
+  CRUSH rule 0 x 200 [35]
+  CRUSH rule 0 x 201 [27]
+  CRUSH rule 0 x 202 [98]
+  CRUSH rule 0 x 203 [36]
+  CRUSH rule 0 x 204 [10]
+  CRUSH rule 0 x 205 [81]
+  CRUSH rule 0 x 206 [49]
+  CRUSH rule 0 x 207 [80]
+  CRUSH rule 0 x 208 [63]
+  CRUSH rule 0 x 209 [85]
+  CRUSH rule 0 x 210 [79]
+  CRUSH rule 0 x 211 [26]
+  CRUSH rule 0 x 212 [28]
+  CRUSH rule 0 x 213 [91]
+  CRUSH rule 0 x 214 [91]
+  CRUSH rule 0 x 215 [61]
+  CRUSH rule 0 x 216 [99]
+  CRUSH rule 0 x 217 [86]
+  CRUSH rule 0 x 218 [70]
+  CRUSH rule 0 x 219 [28]
+  CRUSH rule 0 x 220 [56]
+  CRUSH rule 0 x 221 [0]
+  CRUSH rule 0 x 222 [50]
+  CRUSH rule 0 x 223 [29]
+  CRUSH rule 0 x 224 [52]
+  CRUSH rule 0 x 225 [15]
+  CRUSH rule 0 x 226 [44]
+  CRUSH rule 0 x 227 [42]
+  CRUSH rule 0 x 228 [117]
+  CRUSH rule 0 x 229 [100]
+  CRUSH rule 0 x 230 [41]
+  CRUSH rule 0 x 231 [56]
+  CRUSH rule 0 x 232 [23]
+  CRUSH rule 0 x 233 [88]
+  CRUSH rule 0 x 234 [4]
+  CRUSH rule 0 x 235 [26]
+  CRUSH rule 0 x 236 [32]
+  CRUSH rule 0 x 237 [92]
+  CRUSH rule 0 x 238 [10]
+  CRUSH rule 0 x 239 [15]
+  CRUSH rule 0 x 240 [109]
+  CRUSH rule 0 x 241 [47]
+  CRUSH rule 0 x 242 [24]
+  CRUSH rule 0 x 243 [76]
+  CRUSH rule 0 x 244 [103]
+  CRUSH rule 0 x 245 [27]
+  CRUSH rule 0 x 246 [5]
+  CRUSH rule 0 x 247 [99]
+  CRUSH rule 0 x 248 [8]
+  CRUSH rule 0 x 249 [85]
+  CRUSH rule 0 x 250 [93]
+  CRUSH rule 0 x 251 [28]
+  CRUSH rule 0 x 252 [95]
+  CRUSH rule 0 x 253 [109]
+  CRUSH rule 0 x 254 [80]
+  CRUSH rule 0 x 255 [103]
+  CRUSH rule 0 x 256 [37]
+  CRUSH rule 0 x 257 [69]
+  CRUSH rule 0 x 258 [34]
+  CRUSH rule 0 x 259 [70]
+  CRUSH rule 0 x 260 [98]
+  CRUSH rule 0 x 261 [94]
+  CRUSH rule 0 x 262 [42]
+  CRUSH rule 0 x 263 [65]
+  CRUSH rule 0 x 264 [36]
+  CRUSH rule 0 x 265 [66]
+  CRUSH rule 0 x 266 [75]
+  CRUSH rule 0 x 267 [58]
+  CRUSH rule 0 x 268 [38]
+  CRUSH rule 0 x 269 [86]
+  CRUSH rule 0 x 270 [58]
+  CRUSH rule 0 x 271 [19]
+  CRUSH rule 0 x 272 [73]
+  CRUSH rule 0 x 273 [108]
+  CRUSH rule 0 x 274 [47]
+  CRUSH rule 0 x 275 [92]
+  CRUSH rule 0 x 276 [7]
+  CRUSH rule 0 x 277 [19]
+  CRUSH rule 0 x 278 [116]
+  CRUSH rule 0 x 279 [101]
+  CRUSH rule 0 x 280 [113]
+  CRUSH rule 0 x 281 [14]
+  CRUSH rule 0 x 282 [106]
+  CRUSH rule 0 x 283 [8]
+  CRUSH rule 0 x 284 [10]
+  CRUSH rule 0 x 285 [88]
+  CRUSH rule 0 x 286 [27]
+  CRUSH rule 0 x 287 [84]
+  CRUSH rule 0 x 288 [103]
+  CRUSH rule 0 x 289 [9]
+  CRUSH rule 0 x 290 [115]
+  CRUSH rule 0 x 291 [48]
+  CRUSH rule 0 x 292 [89]
+  CRUSH rule 0 x 293 [27]
+  CRUSH rule 0 x 294 [79]
+  CRUSH rule 0 x 295 [37]
+  CRUSH rule 0 x 296 [56]
+  CRUSH rule 0 x 297 [35]
+  CRUSH rule 0 x 298 [71]
+  CRUSH rule 0 x 299 [116]
+  CRUSH rule 0 x 300 [67]
+  CRUSH rule 0 x 301 [51]
+  CRUSH rule 0 x 302 [78]
+  CRUSH rule 0 x 303 [19]
+  CRUSH rule 0 x 304 [101]
+  CRUSH rule 0 x 305 [81]
+  CRUSH rule 0 x 306 [0]
+  CRUSH rule 0 x 307 [44]
+  CRUSH rule 0 x 308 [91]
+  CRUSH rule 0 x 309 [38]
+  CRUSH rule 0 x 310 [26]
+  CRUSH rule 0 x 311 [36]
+  CRUSH rule 0 x 312 [33]
+  CRUSH rule 0 x 313 [104]
+  CRUSH rule 0 x 314 [28]
+  CRUSH rule 0 x 315 [16]
+  CRUSH rule 0 x 316 [4]
+  CRUSH rule 0 x 317 [118]
+  CRUSH rule 0 x 318 [17]
+  CRUSH rule 0 x 319 [24]
+  CRUSH rule 0 x 320 [36]
+  CRUSH rule 0 x 321 [26]
+  CRUSH rule 0 x 322 [87]
+  CRUSH rule 0 x 323 [73]
+  CRUSH rule 0 x 324 [21]
+  CRUSH rule 0 x 325 [52]
+  CRUSH rule 0 x 326 [111]
+  CRUSH rule 0 x 327 [62]
+  CRUSH rule 0 x 328 [7]
+  CRUSH rule 0 x 329 [93]
+  CRUSH rule 0 x 330 [24]
+  CRUSH rule 0 x 331 [41]
+  CRUSH rule 0 x 332 [61]
+  CRUSH rule 0 x 333 [16]
+  CRUSH rule 0 x 334 [3]
+  CRUSH rule 0 x 335 [71]
+  CRUSH rule 0 x 336 [16]
+  CRUSH rule 0 x 337 [37]
+  CRUSH rule 0 x 338 [109]
+  CRUSH rule 0 x 339 [37]
+  CRUSH rule 0 x 340 [119]
+  CRUSH rule 0 x 341 [63]
+  CRUSH rule 0 x 342 [92]
+  CRUSH rule 0 x 343 [49]
+  CRUSH rule 0 x 344 [103]
+  CRUSH rule 0 x 345 [56]
+  CRUSH rule 0 x 346 [3]
+  CRUSH rule 0 x 347 [106]
+  CRUSH rule 0 x 348 [10]
+  CRUSH rule 0 x 349 [96]
+  CRUSH rule 0 x 350 [63]
+  CRUSH rule 0 x 351 [60]
+  CRUSH rule 0 x 352 [103]
+  CRUSH rule 0 x 353 [49]
+  CRUSH rule 0 x 354 [55]
+  CRUSH rule 0 x 355 [73]
+  CRUSH rule 0 x 356 [114]
+  CRUSH rule 0 x 357 [14]
+  CRUSH rule 0 x 358 [97]
+  CRUSH rule 0 x 359 [4]
+  CRUSH rule 0 x 360 [106]
+  CRUSH rule 0 x 361 [27]
+  CRUSH rule 0 x 362 [28]
+  CRUSH rule 0 x 363 [45]
+  CRUSH rule 0 x 364 [23]
+  CRUSH rule 0 x 365 [24]
+  CRUSH rule 0 x 366 [14]
+  CRUSH rule 0 x 367 [103]
+  CRUSH rule 0 x 368 [103]
+  CRUSH rule 0 x 369 [37]
+  CRUSH rule 0 x 370 [11]
+  CRUSH rule 0 x 371 [34]
+  CRUSH rule 0 x 372 [58]
+  CRUSH rule 0 x 373 [98]
+  CRUSH rule 0 x 374 [110]
+  CRUSH rule 0 x 375 [19]
+  CRUSH rule 0 x 376 [22]
+  CRUSH rule 0 x 377 [98]
+  CRUSH rule 0 x 378 [67]
+  CRUSH rule 0 x 379 [77]
+  CRUSH rule 0 x 380 [69]
+  CRUSH rule 0 x 381 [55]
+  CRUSH rule 0 x 382 [26]
+  CRUSH rule 0 x 383 [48]
+  CRUSH rule 0 x 384 [15]
+  CRUSH rule 0 x 385 [82]
+  CRUSH rule 0 x 386 [108]
+  CRUSH rule 0 x 387 [70]
+  CRUSH rule 0 x 388 [5]
+  CRUSH rule 0 x 389 [14]
+  CRUSH rule 0 x 390 [68]
+  CRUSH rule 0 x 391 [113]
+  CRUSH rule 0 x 392 [72]
+  CRUSH rule 0 x 393 [115]
+  CRUSH rule 0 x 394 [38]
+  CRUSH rule 0 x 395 [0]
+  CRUSH rule 0 x 396 [59]
+  CRUSH rule 0 x 397 [87]
+  CRUSH rule 0 x 398 [44]
+  CRUSH rule 0 x 399 [9]
+  CRUSH rule 0 x 400 [101]
+  CRUSH rule 0 x 401 [79]
+  CRUSH rule 0 x 402 [107]
+  CRUSH rule 0 x 403 [23]
+  CRUSH rule 0 x 404 [76]
+  CRUSH rule 0 x 405 [10]
+  CRUSH rule 0 x 406 [38]
+  CRUSH rule 0 x 407 [70]
+  CRUSH rule 0 x 408 [55]
+  CRUSH rule 0 x 409 [102]
+  CRUSH rule 0 x 410 [59]
+  CRUSH rule 0 x 411 [34]
+  CRUSH rule 0 x 412 [108]
+  CRUSH rule 0 x 413 [54]
+  CRUSH rule 0 x 414 [70]
+  CRUSH rule 0 x 415 [107]
+  CRUSH rule 0 x 416 [79]
+  CRUSH rule 0 x 417 [8]
+  CRUSH rule 0 x 418 [51]
+  CRUSH rule 0 x 419 [117]
+  CRUSH rule 0 x 420 [109]
+  CRUSH rule 0 x 421 [114]
+  CRUSH rule 0 x 422 [109]
+  CRUSH rule 0 x 423 [59]
+  CRUSH rule 0 x 424 [71]
+  CRUSH rule 0 x 425 [101]
+  CRUSH rule 0 x 426 [47]
+  CRUSH rule 0 x 427 [86]
+  CRUSH rule 0 x 428 [68]
+  CRUSH rule 0 x 429 [76]
+  CRUSH rule 0 x 430 [9]
+  CRUSH rule 0 x 431 [105]
+  CRUSH rule 0 x 432 [46]
+  CRUSH rule 0 x 433 [6]
+  CRUSH rule 0 x 434 [64]
+  CRUSH rule 0 x 435 [16]
+  CRUSH rule 0 x 436 [89]
+  CRUSH rule 0 x 437 [29]
+  CRUSH rule 0 x 438 [105]
+  CRUSH rule 0 x 439 [29]
+  CRUSH rule 0 x 440 [38]
+  CRUSH rule 0 x 441 [112]
+  CRUSH rule 0 x 442 [55]
+  CRUSH rule 0 x 443 [44]
+  CRUSH rule 0 x 444 [11]
+  CRUSH rule 0 x 445 [19]
+  CRUSH rule 0 x 446 [40]
+  CRUSH rule 0 x 447 [100]
+  CRUSH rule 0 x 448 [7]
+  CRUSH rule 0 x 449 [67]
+  CRUSH rule 0 x 450 [117]
+  CRUSH rule 0 x 451 [93]
+  CRUSH rule 0 x 452 [70]
+  CRUSH rule 0 x 453 [82]
+  CRUSH rule 0 x 454 [53]
+  CRUSH rule 0 x 455 [91]
+  CRUSH rule 0 x 456 [17]
+  CRUSH rule 0 x 457 [113]
+  CRUSH rule 0 x 458 [119]
+  CRUSH rule 0 x 459 [25]
+  CRUSH rule 0 x 460 [11]
+  CRUSH rule 0 x 461 [21]
+  CRUSH rule 0 x 462 [25]
+  CRUSH rule 0 x 463 [6]
+  CRUSH rule 0 x 464 [19]
+  CRUSH rule 0 x 465 [29]
+  CRUSH rule 0 x 466 [66]
+  CRUSH rule 0 x 467 [27]
+  CRUSH rule 0 x 468 [97]
+  CRUSH rule 0 x 469 [98]
+  CRUSH rule 0 x 470 [50]
+  CRUSH rule 0 x 471 [40]
+  CRUSH rule 0 x 472 [74]
+  CRUSH rule 0 x 473 [95]
+  CRUSH rule 0 x 474 [51]
+  CRUSH rule 0 x 475 [3]
+  CRUSH rule 0 x 476 [110]
+  CRUSH rule 0 x 477 [25]
+  CRUSH rule 0 x 478 [19]
+  CRUSH rule 0 x 479 [70]
+  CRUSH rule 0 x 480 [62]
+  CRUSH rule 0 x 481 [26]
+  CRUSH rule 0 x 482 [84]
+  CRUSH rule 0 x 483 [36]
+  CRUSH rule 0 x 484 [37]
+  CRUSH rule 0 x 485 [84]
+  CRUSH rule 0 x 486 [92]
+  CRUSH rule 0 x 487 [106]
+  CRUSH rule 0 x 488 [42]
+  CRUSH rule 0 x 489 [76]
+  CRUSH rule 0 x 490 [68]
+  CRUSH rule 0 x 491 [80]
+  CRUSH rule 0 x 492 [21]
+  CRUSH rule 0 x 493 [99]
+  CRUSH rule 0 x 494 [4]
+  CRUSH rule 0 x 495 [40]
+  CRUSH rule 0 x 496 [13]
+  CRUSH rule 0 x 497 [102]
+  CRUSH rule 0 x 498 [68]
+  CRUSH rule 0 x 499 [22]
+  CRUSH rule 0 x 500 [50]
+  CRUSH rule 0 x 501 [60]
+  CRUSH rule 0 x 502 [11]
+  CRUSH rule 0 x 503 [117]
+  CRUSH rule 0 x 504 [90]
+  CRUSH rule 0 x 505 [91]
+  CRUSH rule 0 x 506 [82]
+  CRUSH rule 0 x 507 [6]
+  CRUSH rule 0 x 508 [34]
+  CRUSH rule 0 x 509 [88]
+  CRUSH rule 0 x 510 [11]
+  CRUSH rule 0 x 511 [72]
+  CRUSH rule 0 x 512 [118]
+  CRUSH rule 0 x 513 [22]
+  CRUSH rule 0 x 514 [82]
+  CRUSH rule 0 x 515 [27]
+  CRUSH rule 0 x 516 [66]
+  CRUSH rule 0 x 517 [83]
+  CRUSH rule 0 x 518 [18]
+  CRUSH rule 0 x 519 [67]
+  CRUSH rule 0 x 520 [15]
+  CRUSH rule 0 x 521 [63]
+  CRUSH rule 0 x 522 [4]
+  CRUSH rule 0 x 523 [36]
+  CRUSH rule 0 x 524 [33]
+  CRUSH rule 0 x 525 [63]
+  CRUSH rule 0 x 526 [83]
+  CRUSH rule 0 x 527 [37]
+  CRUSH rule 0 x 528 [108]
+  CRUSH rule 0 x 529 [107]
+  CRUSH rule 0 x 530 [49]
+  CRUSH rule 0 x 531 [27]
+  CRUSH rule 0 x 532 [68]
+  CRUSH rule 0 x 533 [5]
+  CRUSH rule 0 x 534 [97]
+  CRUSH rule 0 x 535 [48]
+  CRUSH rule 0 x 536 [3]
+  CRUSH rule 0 x 537 [116]
+  CRUSH rule 0 x 538 [85]
+  CRUSH rule 0 x 539 [10]
+  CRUSH rule 0 x 540 [100]
+  CRUSH rule 0 x 541 [111]
+  CRUSH rule 0 x 542 [50]
+  CRUSH rule 0 x 543 [45]
+  CRUSH rule 0 x 544 [106]
+  CRUSH rule 0 x 545 [43]
+  CRUSH rule 0 x 546 [108]
+  CRUSH rule 0 x 547 [27]
+  CRUSH rule 0 x 548 [53]
+  CRUSH rule 0 x 549 [60]
+  CRUSH rule 0 x 550 [47]
+  CRUSH rule 0 x 551 [14]
+  CRUSH rule 0 x 552 [70]
+  CRUSH rule 0 x 553 [96]
+  CRUSH rule 0 x 554 [61]
+  CRUSH rule 0 x 555 [76]
+  CRUSH rule 0 x 556 [106]
+  CRUSH rule 0 x 557 [39]
+  CRUSH rule 0 x 558 [70]
+  CRUSH rule 0 x 559 [106]
+  CRUSH rule 0 x 560 [94]
+  CRUSH rule 0 x 561 [27]
+  CRUSH rule 0 x 562 [97]
+  CRUSH rule 0 x 563 [64]
+  CRUSH rule 0 x 564 [96]
+  CRUSH rule 0 x 565 [66]
+  CRUSH rule 0 x 566 [27]
+  CRUSH rule 0 x 567 [88]
+  CRUSH rule 0 x 568 [17]
+  CRUSH rule 0 x 569 [102]
+  CRUSH rule 0 x 570 [7]
+  CRUSH rule 0 x 571 [95]
+  CRUSH rule 0 x 572 [62]
+  CRUSH rule 0 x 573 [51]
+  CRUSH rule 0 x 574 [89]
+  CRUSH rule 0 x 575 [19]
+  CRUSH rule 0 x 576 [112]
+  CRUSH rule 0 x 577 [8]
+  CRUSH rule 0 x 578 [64]
+  CRUSH rule 0 x 579 [78]
+  CRUSH rule 0 x 580 [68]
+  CRUSH rule 0 x 581 [55]
+  CRUSH rule 0 x 582 [27]
+  CRUSH rule 0 x 583 [74]
+  CRUSH rule 0 x 584 [72]
+  CRUSH rule 0 x 585 [88]
+  CRUSH rule 0 x 586 [33]
+  CRUSH rule 0 x 587 [106]
+  CRUSH rule 0 x 588 [0]
+  CRUSH rule 0 x 589 [7]
+  CRUSH rule 0 x 590 [59]
+  CRUSH rule 0 x 591 [42]
+  CRUSH rule 0 x 592 [45]
+  CRUSH rule 0 x 593 [89]
+  CRUSH rule 0 x 594 [27]
+  CRUSH rule 0 x 595 [7]
+  CRUSH rule 0 x 596 [82]
+  CRUSH rule 0 x 597 [72]
+  CRUSH rule 0 x 598 [34]
+  CRUSH rule 0 x 599 [119]
+  CRUSH rule 0 x 600 [9]
+  CRUSH rule 0 x 601 [104]
+  CRUSH rule 0 x 602 [48]
+  CRUSH rule 0 x 603 [24]
+  CRUSH rule 0 x 604 [89]
+  CRUSH rule 0 x 605 [104]
+  CRUSH rule 0 x 606 [49]
+  CRUSH rule 0 x 607 [95]
+  CRUSH rule 0 x 608 [49]
+  CRUSH rule 0 x 609 [61]
+  CRUSH rule 0 x 610 [106]
+  CRUSH rule 0 x 611 [66]
+  CRUSH rule 0 x 612 [103]
+  CRUSH rule 0 x 613 [84]
+  CRUSH rule 0 x 614 [81]
+  CRUSH rule 0 x 615 [61]
+  CRUSH rule 0 x 616 [41]
+  CRUSH rule 0 x 617 [111]
+  CRUSH rule 0 x 618 [3]
+  CRUSH rule 0 x 619 [92]
+  CRUSH rule 0 x 620 [108]
+  CRUSH rule 0 x 621 [106]
+  CRUSH rule 0 x 622 [67]
+  CRUSH rule 0 x 623 [94]
+  CRUSH rule 0 x 624 [115]
+  CRUSH rule 0 x 625 [111]
+  CRUSH rule 0 x 626 [3]
+  CRUSH rule 0 x 627 [19]
+  CRUSH rule 0 x 628 [65]
+  CRUSH rule 0 x 629 [119]
+  CRUSH rule 0 x 630 [109]
+  CRUSH rule 0 x 631 [48]
+  CRUSH rule 0 x 632 [81]
+  CRUSH rule 0 x 633 [65]
+  CRUSH rule 0 x 634 [87]
+  CRUSH rule 0 x 635 [107]
+  CRUSH rule 0 x 636 [23]
+  CRUSH rule 0 x 637 [102]
+  CRUSH rule 0 x 638 [43]
+  CRUSH rule 0 x 639 [31]
+  CRUSH rule 0 x 640 [113]
+  CRUSH rule 0 x 641 [45]
+  CRUSH rule 0 x 642 [47]
+  CRUSH rule 0 x 643 [64]
+  CRUSH rule 0 x 644 [31]
+  CRUSH rule 0 x 645 [76]
+  CRUSH rule 0 x 646 [37]
+  CRUSH rule 0 x 647 [58]
+  CRUSH rule 0 x 648 [31]
+  CRUSH rule 0 x 649 [88]
+  CRUSH rule 0 x 650 [116]
+  CRUSH rule 0 x 651 [97]
+  CRUSH rule 0 x 652 [57]
+  CRUSH rule 0 x 653 [38]
+  CRUSH rule 0 x 654 [49]
+  CRUSH rule 0 x 655 [89]
+  CRUSH rule 0 x 656 [0]
+  CRUSH rule 0 x 657 [47]
+  CRUSH rule 0 x 658 [75]
+  CRUSH rule 0 x 659 [26]
+  CRUSH rule 0 x 660 [65]
+  CRUSH rule 0 x 661 [91]
+  CRUSH rule 0 x 662 [111]
+  CRUSH rule 0 x 663 [88]
+  CRUSH rule 0 x 664 [59]
+  CRUSH rule 0 x 665 [78]
+  CRUSH rule 0 x 666 [112]
+  CRUSH rule 0 x 667 [97]
+  CRUSH rule 0 x 668 [97]
+  CRUSH rule 0 x 669 [85]
+  CRUSH rule 0 x 670 [41]
+  CRUSH rule 0 x 671 [116]
+  CRUSH rule 0 x 672 [44]
+  CRUSH rule 0 x 673 [83]
+  CRUSH rule 0 x 674 [59]
+  CRUSH rule 0 x 675 [88]
+  CRUSH rule 0 x 676 [62]
+  CRUSH rule 0 x 677 [88]
+  CRUSH rule 0 x 678 [98]
+  CRUSH rule 0 x 679 [70]
+  CRUSH rule 0 x 680 [55]
+  CRUSH rule 0 x 681 [53]
+  CRUSH rule 0 x 682 [27]
+  CRUSH rule 0 x 683 [57]
+  CRUSH rule 0 x 684 [98]
+  CRUSH rule 0 x 685 [106]
+  CRUSH rule 0 x 686 [86]
+  CRUSH rule 0 x 687 [49]
+  CRUSH rule 0 x 688 [16]
+  CRUSH rule 0 x 689 [6]
+  CRUSH rule 0 x 690 [43]
+  CRUSH rule 0 x 691 [34]
+  CRUSH rule 0 x 692 [40]
+  CRUSH rule 0 x 693 [29]
+  CRUSH rule 0 x 694 [6]
+  CRUSH rule 0 x 695 [31]
+  CRUSH rule 0 x 696 [36]
+  CRUSH rule 0 x 697 [96]
+  CRUSH rule 0 x 698 [61]
+  CRUSH rule 0 x 699 [47]
+  CRUSH rule 0 x 700 [0]
+  CRUSH rule 0 x 701 [42]
+  CRUSH rule 0 x 702 [0]
+  CRUSH rule 0 x 703 [92]
+  CRUSH rule 0 x 704 [10]
+  CRUSH rule 0 x 705 [105]
+  CRUSH rule 0 x 706 [74]
+  CRUSH rule 0 x 707 [0]
+  CRUSH rule 0 x 708 [84]
+  CRUSH rule 0 x 709 [114]
+  CRUSH rule 0 x 710 [94]
+  CRUSH rule 0 x 711 [68]
+  CRUSH rule 0 x 712 [34]
+  CRUSH rule 0 x 713 [29]
+  CRUSH rule 0 x 714 [81]
+  CRUSH rule 0 x 715 [71]
+  CRUSH rule 0 x 716 [40]
+  CRUSH rule 0 x 717 [61]
+  CRUSH rule 0 x 718 [40]
+  CRUSH rule 0 x 719 [59]
+  CRUSH rule 0 x 720 [69]
+  CRUSH rule 0 x 721 [62]
+  CRUSH rule 0 x 722 [115]
+  CRUSH rule 0 x 723 [117]
+  CRUSH rule 0 x 724 [45]
+  CRUSH rule 0 x 725 [53]
+  CRUSH rule 0 x 726 [84]
+  CRUSH rule 0 x 727 [109]
+  CRUSH rule 0 x 728 [76]
+  CRUSH rule 0 x 729 [108]
+  CRUSH rule 0 x 730 [28]
+  CRUSH rule 0 x 731 [78]
+  CRUSH rule 0 x 732 [55]
+  CRUSH rule 0 x 733 [84]
+  CRUSH rule 0 x 734 [27]
+  CRUSH rule 0 x 735 [83]
+  CRUSH rule 0 x 736 [70]
+  CRUSH rule 0 x 737 [117]
+  CRUSH rule 0 x 738 [118]
+  CRUSH rule 0 x 739 [87]
+  CRUSH rule 0 x 740 [29]
+  CRUSH rule 0 x 741 [96]
+  CRUSH rule 0 x 742 [106]
+  CRUSH rule 0 x 743 [105]
+  CRUSH rule 0 x 744 [23]
+  CRUSH rule 0 x 745 [28]
+  CRUSH rule 0 x 746 [18]
+  CRUSH rule 0 x 747 [65]
+  CRUSH rule 0 x 748 [48]
+  CRUSH rule 0 x 749 [102]
+  CRUSH rule 0 x 750 [50]
+  CRUSH rule 0 x 751 [36]
+  CRUSH rule 0 x 752 [69]
+  CRUSH rule 0 x 753 [9]
+  CRUSH rule 0 x 754 [9]
+  CRUSH rule 0 x 755 [98]
+  CRUSH rule 0 x 756 [113]
+  CRUSH rule 0 x 757 [47]
+  CRUSH rule 0 x 758 [57]
+  CRUSH rule 0 x 759 [74]
+  CRUSH rule 0 x 760 [53]
+  CRUSH rule 0 x 761 [78]
+  CRUSH rule 0 x 762 [87]
+  CRUSH rule 0 x 763 [13]
+  CRUSH rule 0 x 764 [106]
+  CRUSH rule 0 x 765 [109]
+  CRUSH rule 0 x 766 [76]
+  CRUSH rule 0 x 767 [41]
+  CRUSH rule 0 x 768 [13]
+  CRUSH rule 0 x 769 [91]
+  CRUSH rule 0 x 770 [105]
+  CRUSH rule 0 x 771 [10]
+  CRUSH rule 0 x 772 [8]
+  CRUSH rule 0 x 773 [116]
+  CRUSH rule 0 x 774 [100]
+  CRUSH rule 0 x 775 [15]
+  CRUSH rule 0 x 776 [69]
+  CRUSH rule 0 x 777 [76]
+  CRUSH rule 0 x 778 [38]
+  CRUSH rule 0 x 779 [46]
+  CRUSH rule 0 x 780 [63]
+  CRUSH rule 0 x 781 [19]
+  CRUSH rule 0 x 782 [117]
+  CRUSH rule 0 x 783 [60]
+  CRUSH rule 0 x 784 [82]
+  CRUSH rule 0 x 785 [27]
+  CRUSH rule 0 x 786 [41]
+  CRUSH rule 0 x 787 [13]
+  CRUSH rule 0 x 788 [4]
+  CRUSH rule 0 x 789 [50]
+  CRUSH rule 0 x 790 [58]
+  CRUSH rule 0 x 791 [96]
+  CRUSH rule 0 x 792 [45]
+  CRUSH rule 0 x 793 [6]
+  CRUSH rule 0 x 794 [14]
+  CRUSH rule 0 x 795 [51]
+  CRUSH rule 0 x 796 [114]
+  CRUSH rule 0 x 797 [79]
+  CRUSH rule 0 x 798 [42]
+  CRUSH rule 0 x 799 [48]
+  CRUSH rule 0 x 800 [91]
+  CRUSH rule 0 x 801 [2]
+  CRUSH rule 0 x 802 [116]
+  CRUSH rule 0 x 803 [37]
+  CRUSH rule 0 x 804 [6]
+  CRUSH rule 0 x 805 [96]
+  CRUSH rule 0 x 806 [67]
+  CRUSH rule 0 x 807 [47]
+  CRUSH rule 0 x 808 [76]
+  CRUSH rule 0 x 809 [27]
+  CRUSH rule 0 x 810 [119]
+  CRUSH rule 0 x 811 [75]
+  CRUSH rule 0 x 812 [25]
+  CRUSH rule 0 x 813 [64]
+  CRUSH rule 0 x 814 [110]
+  CRUSH rule 0 x 815 [84]
+  CRUSH rule 0 x 816 [25]
+  CRUSH rule 0 x 817 [40]
+  CRUSH rule 0 x 818 [34]
+  CRUSH rule 0 x 819 [88]
+  CRUSH rule 0 x 820 [104]
+  CRUSH rule 0 x 821 [58]
+  CRUSH rule 0 x 822 [29]
+  CRUSH rule 0 x 823 [100]
+  CRUSH rule 0 x 824 [102]
+  CRUSH rule 0 x 825 [47]
+  CRUSH rule 0 x 826 [45]
+  CRUSH rule 0 x 827 [101]
+  CRUSH rule 0 x 828 [60]
+  CRUSH rule 0 x 829 [45]
+  CRUSH rule 0 x 830 [51]
+  CRUSH rule 0 x 831 [6]
+  CRUSH rule 0 x 832 [57]
+  CRUSH rule 0 x 833 [34]
+  CRUSH rule 0 x 834 [90]
+  CRUSH rule 0 x 835 [55]
+  CRUSH rule 0 x 836 [38]
+  CRUSH rule 0 x 837 [51]
+  CRUSH rule 0 x 838 [6]
+  CRUSH rule 0 x 839 [106]
+  CRUSH rule 0 x 840 [33]
+  CRUSH rule 0 x 841 [110]
+  CRUSH rule 0 x 842 [66]
+  CRUSH rule 0 x 843 [62]
+  CRUSH rule 0 x 844 [74]
+  CRUSH rule 0 x 845 [74]
+  CRUSH rule 0 x 846 [98]
+  CRUSH rule 0 x 847 [10]
+  CRUSH rule 0 x 848 [89]
+  CRUSH rule 0 x 849 [42]
+  CRUSH rule 0 x 850 [40]
+  CRUSH rule 0 x 851 [65]
+  CRUSH rule 0 x 852 [31]
+  CRUSH rule 0 x 853 [49]
+  CRUSH rule 0 x 854 [83]
+  CRUSH rule 0 x 855 [2]
+  CRUSH rule 0 x 856 [6]
+  CRUSH rule 0 x 857 [15]
+  CRUSH rule 0 x 858 [10]
+  CRUSH rule 0 x 859 [14]
+  CRUSH rule 0 x 860 [114]
+  CRUSH rule 0 x 861 [1]
+  CRUSH rule 0 x 862 [22]
+  CRUSH rule 0 x 863 [79]
+  CRUSH rule 0 x 864 [68]
+  CRUSH rule 0 x 865 [25]
+  CRUSH rule 0 x 866 [18]
+  CRUSH rule 0 x 867 [53]
+  CRUSH rule 0 x 868 [81]
+  CRUSH rule 0 x 869 [111]
+  CRUSH rule 0 x 870 [73]
+  CRUSH rule 0 x 871 [25]
+  CRUSH rule 0 x 872 [39]
+  CRUSH rule 0 x 873 [92]
+  CRUSH rule 0 x 874 [96]
+  CRUSH rule 0 x 875 [115]
+  CRUSH rule 0 x 876 [98]
+  CRUSH rule 0 x 877 [73]
+  CRUSH rule 0 x 878 [64]
+  CRUSH rule 0 x 879 [15]
+  CRUSH rule 0 x 880 [56]
+  CRUSH rule 0 x 881 [109]
+  CRUSH rule 0 x 882 [60]
+  CRUSH rule 0 x 883 [93]
+  CRUSH rule 0 x 884 [67]
+  CRUSH rule 0 x 885 [31]
+  CRUSH rule 0 x 886 [2]
+  CRUSH rule 0 x 887 [5]
+  CRUSH rule 0 x 888 [16]
+  CRUSH rule 0 x 889 [27]
+  CRUSH rule 0 x 890 [48]
+  CRUSH rule 0 x 891 [86]
+  CRUSH rule 0 x 892 [64]
+  CRUSH rule 0 x 893 [118]
+  CRUSH rule 0 x 894 [16]
+  CRUSH rule 0 x 895 [40]
+  CRUSH rule 0 x 896 [97]
+  CRUSH rule 0 x 897 [107]
+  CRUSH rule 0 x 898 [10]
+  CRUSH rule 0 x 899 [75]
+  CRUSH rule 0 x 900 [102]
+  CRUSH rule 0 x 901 [66]
+  CRUSH rule 0 x 902 [102]
+  CRUSH rule 0 x 903 [5]
+  CRUSH rule 0 x 904 [50]
+  CRUSH rule 0 x 905 [99]
+  CRUSH rule 0 x 906 [75]
+  CRUSH rule 0 x 907 [47]
+  CRUSH rule 0 x 908 [96]
+  CRUSH rule 0 x 909 [94]
+  CRUSH rule 0 x 910 [88]
+  CRUSH rule 0 x 911 [102]
+  CRUSH rule 0 x 912 [91]
+  CRUSH rule 0 x 913 [29]
+  CRUSH rule 0 x 914 [84]
+  CRUSH rule 0 x 915 [70]
+  CRUSH rule 0 x 916 [32]
+  CRUSH rule 0 x 917 [43]
+  CRUSH rule 0 x 918 [91]
+  CRUSH rule 0 x 919 [13]
+  CRUSH rule 0 x 920 [18]
+  CRUSH rule 0 x 921 [104]
+  CRUSH rule 0 x 922 [33]
+  CRUSH rule 0 x 923 [28]
+  CRUSH rule 0 x 924 [69]
+  CRUSH rule 0 x 925 [71]
+  CRUSH rule 0 x 926 [64]
+  CRUSH rule 0 x 927 [99]
+  CRUSH rule 0 x 928 [13]
+  CRUSH rule 0 x 929 [117]
+  CRUSH rule 0 x 930 [31]
+  CRUSH rule 0 x 931 [83]
+  CRUSH rule 0 x 932 [60]
+  CRUSH rule 0 x 933 [63]
+  CRUSH rule 0 x 934 [68]
+  CRUSH rule 0 x 935 [31]
+  CRUSH rule 0 x 936 [65]
+  CRUSH rule 0 x 937 [110]
+  CRUSH rule 0 x 938 [29]
+  CRUSH rule 0 x 939 [77]
+  CRUSH rule 0 x 940 [76]
+  CRUSH rule 0 x 941 [66]
+  CRUSH rule 0 x 942 [83]
+  CRUSH rule 0 x 943 [32]
+  CRUSH rule 0 x 944 [113]
+  CRUSH rule 0 x 945 [71]
+  CRUSH rule 0 x 946 [37]
+  CRUSH rule 0 x 947 [107]
+  CRUSH rule 0 x 948 [55]
+  CRUSH rule 0 x 949 [11]
+  CRUSH rule 0 x 950 [96]
+  CRUSH rule 0 x 951 [40]
+  CRUSH rule 0 x 952 [93]
+  CRUSH rule 0 x 953 [55]
+  CRUSH rule 0 x 954 [84]
+  CRUSH rule 0 x 955 [31]
+  CRUSH rule 0 x 956 [72]
+  CRUSH rule 0 x 957 [3]
+  CRUSH rule 0 x 958 [23]
+  CRUSH rule 0 x 959 [42]
+  CRUSH rule 0 x 960 [113]
+  CRUSH rule 0 x 961 [116]
+  CRUSH rule 0 x 962 [13]
+  CRUSH rule 0 x 963 [0]
+  CRUSH rule 0 x 964 [59]
+  CRUSH rule 0 x 965 [47]
+  CRUSH rule 0 x 966 [88]
+  CRUSH rule 0 x 967 [71]
+  CRUSH rule 0 x 968 [73]
+  CRUSH rule 0 x 969 [53]
+  CRUSH rule 0 x 970 [111]
+  CRUSH rule 0 x 971 [87]
+  CRUSH rule 0 x 972 [5]
+  CRUSH rule 0 x 973 [113]
+  CRUSH rule 0 x 974 [49]
+  CRUSH rule 0 x 975 [83]
+  CRUSH rule 0 x 976 [81]
+  CRUSH rule 0 x 977 [95]
+  CRUSH rule 0 x 978 [35]
+  CRUSH rule 0 x 979 [98]
+  CRUSH rule 0 x 980 [52]
+  CRUSH rule 0 x 981 [89]
+  CRUSH rule 0 x 982 [1]
+  CRUSH rule 0 x 983 [34]
+  CRUSH rule 0 x 984 [78]
+  CRUSH rule 0 x 985 [99]
+  CRUSH rule 0 x 986 [4]
+  CRUSH rule 0 x 987 [78]
+  CRUSH rule 0 x 988 [79]
+  CRUSH rule 0 x 989 [87]
+  CRUSH rule 0 x 990 [47]
+  CRUSH rule 0 x 991 [61]
+  CRUSH rule 0 x 992 [83]
+  CRUSH rule 0 x 993 [74]
+  CRUSH rule 0 x 994 [74]
+  CRUSH rule 0 x 995 [100]
+  CRUSH rule 0 x 996 [41]
+  CRUSH rule 0 x 997 [89]
+  CRUSH rule 0 x 998 [92]
+  CRUSH rule 0 x 999 [117]
+  CRUSH rule 0 x 1000 [9]
+  CRUSH rule 0 x 1001 [49]
+  CRUSH rule 0 x 1002 [99]
+  CRUSH rule 0 x 1003 [43]
+  CRUSH rule 0 x 1004 [89]
+  CRUSH rule 0 x 1005 [105]
+  CRUSH rule 0 x 1006 [45]
+  CRUSH rule 0 x 1007 [19]
+  CRUSH rule 0 x 1008 [31]
+  CRUSH rule 0 x 1009 [19]
+  CRUSH rule 0 x 1010 [42]
+  CRUSH rule 0 x 1011 [25]
+  CRUSH rule 0 x 1012 [68]
+  CRUSH rule 0 x 1013 [5]
+  CRUSH rule 0 x 1014 [33]
+  CRUSH rule 0 x 1015 [14]
+  CRUSH rule 0 x 1016 [88]
+  CRUSH rule 0 x 1017 [0]
+  CRUSH rule 0 x 1018 [63]
+  CRUSH rule 0 x 1019 [104]
+  CRUSH rule 0 x 1020 [96]
+  CRUSH rule 0 x 1021 [117]
+  CRUSH rule 0 x 1022 [73]
+  CRUSH rule 0 x 1023 [0]
+  rule 0 (data) num_rep 1 result size == 1:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114]
+  CRUSH rule 0 x 1 [80,79]
+  CRUSH rule 0 x 2 [91,19]
+  CRUSH rule 0 x 3 [51,4]
+  CRUSH rule 0 x 4 [50,89]
+  CRUSH rule 0 x 5 [89,94]
+  CRUSH rule 0 x 6 [91,76]
+  CRUSH rule 0 x 7 [104,25]
+  CRUSH rule 0 x 8 [78,14]
+  CRUSH rule 0 x 9 [101,102]
+  CRUSH rule 0 x 10 [61,6]
+  CRUSH rule 0 x 11 [13,31]
+  CRUSH rule 0 x 12 [83,46]
+  CRUSH rule 0 x 13 [108,85]
+  CRUSH rule 0 x 14 [105,3]
+  CRUSH rule 0 x 15 [18,7]
+  CRUSH rule 0 x 16 [103,3]
+  CRUSH rule 0 x 17 [85,110]
+  CRUSH rule 0 x 18 [11,65]
+  CRUSH rule 0 x 19 [75,50]
+  CRUSH rule 0 x 20 [79,70]
+  CRUSH rule 0 x 21 [84,9]
+  CRUSH rule 0 x 22 [23,104]
+  CRUSH rule 0 x 23 [118,17]
+  CRUSH rule 0 x 24 [83,110]
+  CRUSH rule 0 x 25 [81,64]
+  CRUSH rule 0 x 26 [38,99]
+  CRUSH rule 0 x 27 [76,107]
+  CRUSH rule 0 x 28 [76,71]
+  CRUSH rule 0 x 29 [8,119]
+  CRUSH rule 0 x 30 [94,87]
+  CRUSH rule 0 x 31 [76,95]
+  CRUSH rule 0 x 32 [72,95]
+  CRUSH rule 0 x 33 [77,86]
+  CRUSH rule 0 x 34 [74,73]
+  CRUSH rule 0 x 35 [22,88]
+  CRUSH rule 0 x 36 [104,65]
+  CRUSH rule 0 x 37 [38,81]
+  CRUSH rule 0 x 38 [72,11]
+  CRUSH rule 0 x 39 [68,103]
+  CRUSH rule 0 x 40 [103,78]
+  CRUSH rule 0 x 41 [85,11]
+  CRUSH rule 0 x 42 [106,75]
+  CRUSH rule 0 x 43 [10,68]
+  CRUSH rule 0 x 44 [101,116]
+  CRUSH rule 0 x 45 [8,64]
+  CRUSH rule 0 x 46 [65,1]
+  CRUSH rule 0 x 47 [106,53]
+  CRUSH rule 0 x 48 [34,6]
+  CRUSH rule 0 x 49 [0,81]
+  CRUSH rule 0 x 50 [42,6]
+  CRUSH rule 0 x 51 [104,75]
+  CRUSH rule 0 x 52 [83,19]
+  CRUSH rule 0 x 53 [32,75]
+  CRUSH rule 0 x 54 [28,79]
+  CRUSH rule 0 x 55 [14,5]
+  CRUSH rule 0 x 56 [21,72]
+  CRUSH rule 0 x 57 [93,84]
+  CRUSH rule 0 x 58 [45,106]
+  CRUSH rule 0 x 59 [80,41]
+  CRUSH rule 0 x 60 [90,57]
+  CRUSH rule 0 x 61 [88,37]
+  CRUSH rule 0 x 62 [81,1]
+  CRUSH rule 0 x 63 [79,113]
+  CRUSH rule 0 x 64 [1,89]
+  CRUSH rule 0 x 65 [13,0]
+  CRUSH rule 0 x 66 [48,49]
+  CRUSH rule 0 x 67 [94,103]
+  CRUSH rule 0 x 68 [102,91]
+  CRUSH rule 0 x 69 [62,77]
+  CRUSH rule 0 x 70 [84,105]
+  CRUSH rule 0 x 71 [55,19]
+  CRUSH rule 0 x 72 [97,42]
+  CRUSH rule 0 x 73 [64,83]
+  CRUSH rule 0 x 74 [96,59]
+  CRUSH rule 0 x 75 [29,28]
+  CRUSH rule 0 x 76 [55,0]
+  CRUSH rule 0 x 77 [107,21]
+  CRUSH rule 0 x 78 [31,94]
+  CRUSH rule 0 x 79 [64,51]
+  CRUSH rule 0 x 80 [0,31]
+  CRUSH rule 0 x 81 [71,109]
+  CRUSH rule 0 x 82 [37,40]
+  CRUSH rule 0 x 83 [92,103]
+  CRUSH rule 0 x 84 [49,115]
+  CRUSH rule 0 x 85 [54,101]
+  CRUSH rule 0 x 86 [37,7]
+  CRUSH rule 0 x 87 [116,4]
+  CRUSH rule 0 x 88 [38,55]
+  CRUSH rule 0 x 89 [76,77]
+  CRUSH rule 0 x 90 [14,50]
+  CRUSH rule 0 x 91 [93,34]
+  CRUSH rule 0 x 92 [86,9]
+  CRUSH rule 0 x 93 [44,65]
+  CRUSH rule 0 x 94 [61,102]
+  CRUSH rule 0 x 95 [93,86]
+  CRUSH rule 0 x 96 [66,87]
+  CRUSH rule 0 x 97 [111,9]
+  CRUSH rule 0 x 98 [66,91]
+  CRUSH rule 0 x 99 [78,3]
+  CRUSH rule 0 x 100 [28,8]
+  CRUSH rule 0 x 101 [84,16]
+  CRUSH rule 0 x 102 [82,105]
+  CRUSH rule 0 x 103 [66,6]
+  CRUSH rule 0 x 104 [14,95]
+  CRUSH rule 0 x 105 [87,1]
+  CRUSH rule 0 x 106 [69,116]
+  CRUSH rule 0 x 107 [1,55]
+  CRUSH rule 0 x 108 [94,53]
+  CRUSH rule 0 x 109 [112,63]
+  CRUSH rule 0 x 110 [54,61]
+  CRUSH rule 0 x 111 [10,58]
+  CRUSH rule 0 x 112 [89,9]
+  CRUSH rule 0 x 113 [69,2]
+  CRUSH rule 0 x 114 [79,17]
+  CRUSH rule 0 x 115 [50,85]
+  CRUSH rule 0 x 116 [96,16]
+  CRUSH rule 0 x 117 [87,56]
+  CRUSH rule 0 x 118 [23,56]
+  CRUSH rule 0 x 119 [104,11]
+  CRUSH rule 0 x 120 [57,5]
+  CRUSH rule 0 x 121 [105,117]
+  CRUSH rule 0 x 122 [45,110]
+  CRUSH rule 0 x 123 [112,22]
+  CRUSH rule 0 x 124 [110,11]
+  CRUSH rule 0 x 125 [66,105]
+  CRUSH rule 0 x 126 [51,28]
+  CRUSH rule 0 x 127 [70,6]
+  CRUSH rule 0 x 128 [90,16]
+  CRUSH rule 0 x 129 [103,110]
+  CRUSH rule 0 x 130 [50,11]
+  CRUSH rule 0 x 131 [23,60]
+  CRUSH rule 0 x 132 [69,70]
+  CRUSH rule 0 x 133 [52,25]
+  CRUSH rule 0 x 134 [78,6]
+  CRUSH rule 0 x 135 [78,3]
+  CRUSH rule 0 x 136 [32,29]
+  CRUSH rule 0 x 137 [92,41]
+  CRUSH rule 0 x 138 [17,118]
+  CRUSH rule 0 x 139 [89,60]
+  CRUSH rule 0 x 140 [39,62]
+  CRUSH rule 0 x 141 [89,98]
+  CRUSH rule 0 x 142 [70,61]
+  CRUSH rule 0 x 143 [51,28]
+  CRUSH rule 0 x 144 [13,81]
+  CRUSH rule 0 x 145 [77,119]
+  CRUSH rule 0 x 146 [96,69]
+  CRUSH rule 0 x 147 [2,95]
+  CRUSH rule 0 x 148 [74,69]
+  CRUSH rule 0 x 149 [76,13]
+  CRUSH rule 0 x 150 [38,47]
+  CRUSH rule 0 x 151 [90,67]
+  CRUSH rule 0 x 152 [49,18]
+  CRUSH rule 0 x 153 [71,44]
+  CRUSH rule 0 x 154 [94,81]
+  CRUSH rule 0 x 155 [75,112]
+  CRUSH rule 0 x 156 [107,66]
+  CRUSH rule 0 x 157 [112,43]
+  CRUSH rule 0 x 158 [26,17]
+  CRUSH rule 0 x 159 [52,9]
+  CRUSH rule 0 x 160 [41,0]
+  CRUSH rule 0 x 161 [84,45]
+  CRUSH rule 0 x 162 [55,2]
+  CRUSH rule 0 x 163 [54,8]
+  CRUSH rule 0 x 164 [45,5]
+  CRUSH rule 0 x 165 [25,72]
+  CRUSH rule 0 x 166 [73,36]
+  CRUSH rule 0 x 167 [89,58]
+  CRUSH rule 0 x 168 [47,40]
+  CRUSH rule 0 x 169 [51,21]
+  CRUSH rule 0 x 170 [68,91]
+  CRUSH rule 0 x 171 [73,90]
+  CRUSH rule 0 x 172 [117,41]
+  CRUSH rule 0 x 173 [13,34]
+  CRUSH rule 0 x 174 [116,25]
+  CRUSH rule 0 x 175 [3,41]
+  CRUSH rule 0 x 176 [94,91]
+  CRUSH rule 0 x 177 [52,85]
+  CRUSH rule 0 x 178 [39,2]
+  CRUSH rule 0 x 179 [72,97]
+  CRUSH rule 0 x 180 [60,61]
+  CRUSH rule 0 x 181 [18,59]
+  CRUSH rule 0 x 182 [22,90]
+  CRUSH rule 0 x 183 [11,74]
+  CRUSH rule 0 x 184 [92,8]
+  CRUSH rule 0 x 185 [97,8]
+  CRUSH rule 0 x 186 [67,116]
+  CRUSH rule 0 x 187 [116,11]
+  CRUSH rule 0 x 188 [69,110]
+  CRUSH rule 0 x 189 [47,84]
+  CRUSH rule 0 x 190 [65,82]
+  CRUSH rule 0 x 191 [49,38]
+  CRUSH rule 0 x 192 [68,93]
+  CRUSH rule 0 x 193 [0,33]
+  CRUSH rule 0 x 194 [62,99]
+  CRUSH rule 0 x 195 [119,4]
+  CRUSH rule 0 x 196 [72,27]
+  CRUSH rule 0 x 197 [106,83]
+  CRUSH rule 0 x 198 [114,21]
+  CRUSH rule 0 x 199 [0,83]
+  CRUSH rule 0 x 200 [35,86]
+  CRUSH rule 0 x 201 [27,26]
+  CRUSH rule 0 x 202 [98,33]
+  CRUSH rule 0 x 203 [36,91]
+  CRUSH rule 0 x 204 [10,98]
+  CRUSH rule 0 x 205 [81,17]
+  CRUSH rule 0 x 206 [49,112]
+  CRUSH rule 0 x 207 [80,39]
+  CRUSH rule 0 x 208 [63,26]
+  CRUSH rule 0 x 209 [85,111]
+  CRUSH rule 0 x 210 [79,18]
+  CRUSH rule 0 x 211 [26,10]
+  CRUSH rule 0 x 212 [28,103]
+  CRUSH rule 0 x 213 [91,0]
+  CRUSH rule 0 x 214 [91,38]
+  CRUSH rule 0 x 215 [61,86]
+  CRUSH rule 0 x 216 [99,94]
+  CRUSH rule 0 x 217 [86,89]
+  CRUSH rule 0 x 218 [70,4]
+  CRUSH rule 0 x 219 [28,59]
+  CRUSH rule 0 x 220 [56,8]
+  CRUSH rule 0 x 221 [0,9]
+  CRUSH rule 0 x 222 [50,63]
+  CRUSH rule 0 x 223 [29,1]
+  CRUSH rule 0 x 224 [52,10]
+  CRUSH rule 0 x 225 [15,35]
+  CRUSH rule 0 x 226 [44,7]
+  CRUSH rule 0 x 227 [42,3]
+  CRUSH rule 0 x 228 [117,49]
+  CRUSH rule 0 x 229 [100,79]
+  CRUSH rule 0 x 230 [41,114]
+  CRUSH rule 0 x 231 [56,95]
+  CRUSH rule 0 x 232 [23,8]
+  CRUSH rule 0 x 233 [88,103]
+  CRUSH rule 0 x 234 [4,101]
+  CRUSH rule 0 x 235 [26,10]
+  CRUSH rule 0 x 236 [32,37]
+  CRUSH rule 0 x 237 [92,3]
+  CRUSH rule 0 x 238 [10,26]
+  CRUSH rule 0 x 239 [15,105]
+  CRUSH rule 0 x 240 [109,14]
+  CRUSH rule 0 x 241 [47,108]
+  CRUSH rule 0 x 242 [24,99]
+  CRUSH rule 0 x 243 [76,8]
+  CRUSH rule 0 x 244 [103,13]
+  CRUSH rule 0 x 245 [27,82]
+  CRUSH rule 0 x 246 [5,43]
+  CRUSH rule 0 x 247 [99,102]
+  CRUSH rule 0 x 248 [8,29]
+  CRUSH rule 0 x 249 [85,1]
+  CRUSH rule 0 x 250 [93,102]
+  CRUSH rule 0 x 251 [28,103]
+  CRUSH rule 0 x 252 [95,22]
+  CRUSH rule 0 x 253 [109,27]
+  CRUSH rule 0 x 254 [80,13]
+  CRUSH rule 0 x 255 [103,13]
+  CRUSH rule 0 x 256 [37,38]
+  CRUSH rule 0 x 257 [69,117]
+  CRUSH rule 0 x 258 [34,55]
+  CRUSH rule 0 x 259 [70,17]
+  CRUSH rule 0 x 260 [98,29]
+  CRUSH rule 0 x 261 [94,83]
+  CRUSH rule 0 x 262 [42,49]
+  CRUSH rule 0 x 263 [65,42]
+  CRUSH rule 0 x 264 [36,49]
+  CRUSH rule 0 x 265 [66,63]
+  CRUSH rule 0 x 266 [75,92]
+  CRUSH rule 0 x 267 [58,35]
+  CRUSH rule 0 x 268 [38,9]
+  CRUSH rule 0 x 269 [86,59]
+  CRUSH rule 0 x 270 [58,37]
+  CRUSH rule 0 x 271 [19,33]
+  CRUSH rule 0 x 272 [73,9]
+  CRUSH rule 0 x 273 [108,29]
+  CRUSH rule 0 x 274 [47,64]
+  CRUSH rule 0 x 275 [92,19]
+  CRUSH rule 0 x 276 [7,79]
+  CRUSH rule 0 x 277 [19,68]
+  CRUSH rule 0 x 278 [116,105]
+  CRUSH rule 0 x 279 [101,3]
+  CRUSH rule 0 x 280 [113,69]
+  CRUSH rule 0 x 281 [14,93]
+  CRUSH rule 0 x 282 [106,61]
+  CRUSH rule 0 x 283 [8,118]
+  CRUSH rule 0 x 284 [10,110]
+  CRUSH rule 0 x 285 [88,63]
+  CRUSH rule 0 x 286 [27,4]
+  CRUSH rule 0 x 287 [84,65]
+  CRUSH rule 0 x 288 [103,8]
+  CRUSH rule 0 x 289 [9,64]
+  CRUSH rule 0 x 290 [115,17]
+  CRUSH rule 0 x 291 [48,45]
+  CRUSH rule 0 x 292 [89,109]
+  CRUSH rule 0 x 293 [27,24]
+  CRUSH rule 0 x 294 [79,36]
+  CRUSH rule 0 x 295 [37,116]
+  CRUSH rule 0 x 296 [56,61]
+  CRUSH rule 0 x 297 [35,40]
+  CRUSH rule 0 x 298 [71,118]
+  CRUSH rule 0 x 299 [116,61]
+  CRUSH rule 0 x 300 [67,5]
+  CRUSH rule 0 x 301 [51,110]
+  CRUSH rule 0 x 302 [78,67]
+  CRUSH rule 0 x 303 [19,94]
+  CRUSH rule 0 x 304 [101,66]
+  CRUSH rule 0 x 305 [81,62]
+  CRUSH rule 0 x 306 [0,23]
+  CRUSH rule 0 x 307 [44,15]
+  CRUSH rule 0 x 308 [91,98]
+  CRUSH rule 0 x 309 [38,63]
+  CRUSH rule 0 x 310 [26,89]
+  CRUSH rule 0 x 311 [36,83]
+  CRUSH rule 0 x 312 [33,22]
+  CRUSH rule 0 x 313 [104,16]
+  CRUSH rule 0 x 314 [28,4]
+  CRUSH rule 0 x 315 [16,117]
+  CRUSH rule 0 x 316 [4,1]
+  CRUSH rule 0 x 317 [118,8]
+  CRUSH rule 0 x 318 [17,47]
+  CRUSH rule 0 x 319 [24,83]
+  CRUSH rule 0 x 320 [36,65]
+  CRUSH rule 0 x 321 [26,85]
+  CRUSH rule 0 x 322 [87,116]
+  CRUSH rule 0 x 323 [73,0]
+  CRUSH rule 0 x 324 [21,37]
+  CRUSH rule 0 x 325 [52,16]
+  CRUSH rule 0 x 326 [111,93]
+  CRUSH rule 0 x 327 [62,8]
+  CRUSH rule 0 x 328 [7,42]
+  CRUSH rule 0 x 329 [93,34]
+  CRUSH rule 0 x 330 [24,4]
+  CRUSH rule 0 x 331 [41,117]
+  CRUSH rule 0 x 332 [61,110]
+  CRUSH rule 0 x 333 [16,8]
+  CRUSH rule 0 x 334 [3,35]
+  CRUSH rule 0 x 335 [71,74]
+  CRUSH rule 0 x 336 [16,19]
+  CRUSH rule 0 x 337 [37,40]
+  CRUSH rule 0 x 338 [109,13]
+  CRUSH rule 0 x 339 [37,21]
+  CRUSH rule 0 x 340 [119,67]
+  CRUSH rule 0 x 341 [63,8]
+  CRUSH rule 0 x 342 [92,25]
+  CRUSH rule 0 x 343 [49,26]
+  CRUSH rule 0 x 344 [103,26]
+  CRUSH rule 0 x 345 [56,25]
+  CRUSH rule 0 x 346 [3,79]
+  CRUSH rule 0 x 347 [106,27]
+  CRUSH rule 0 x 348 [10,117]
+  CRUSH rule 0 x 349 [96,37]
+  CRUSH rule 0 x 350 [63,32]
+  CRUSH rule 0 x 351 [60,85]
+  CRUSH rule 0 x 352 [103,84]
+  CRUSH rule 0 x 353 [49,113]
+  CRUSH rule 0 x 354 [55,52]
+  CRUSH rule 0 x 355 [73,68]
+  CRUSH rule 0 x 356 [114,41]
+  CRUSH rule 0 x 357 [14,96]
+  CRUSH rule 0 x 358 [97,62]
+  CRUSH rule 0 x 359 [4,105]
+  CRUSH rule 0 x 360 [106,69]
+  CRUSH rule 0 x 361 [27,46]
+  CRUSH rule 0 x 362 [28,33]
+  CRUSH rule 0 x 363 [45,26]
+  CRUSH rule 0 x 364 [23,50]
+  CRUSH rule 0 x 365 [24,22]
+  CRUSH rule 0 x 366 [14,58]
+  CRUSH rule 0 x 367 [103,50]
+  CRUSH rule 0 x 368 [103,32]
+  CRUSH rule 0 x 369 [37,4]
+  CRUSH rule 0 x 370 [11,89]
+  CRUSH rule 0 x 371 [34,55]
+  CRUSH rule 0 x 372 [58,10]
+  CRUSH rule 0 x 373 [98,8]
+  CRUSH rule 0 x 374 [110,95]
+  CRUSH rule 0 x 375 [19,92]
+  CRUSH rule 0 x 376 [22,86]
+  CRUSH rule 0 x 377 [98,105]
+  CRUSH rule 0 x 378 [67,36]
+  CRUSH rule 0 x 379 [77,8]
+  CRUSH rule 0 x 380 [69,104]
+  CRUSH rule 0 x 381 [55,1]
+  CRUSH rule 0 x 382 [26,51]
+  CRUSH rule 0 x 383 [48,25]
+  CRUSH rule 0 x 384 [15,100]
+  CRUSH rule 0 x 385 [82,61]
+  CRUSH rule 0 x 386 [108,63]
+  CRUSH rule 0 x 387 [70,15]
+  CRUSH rule 0 x 388 [5,67]
+  CRUSH rule 0 x 389 [14,29]
+  CRUSH rule 0 x 390 [68,10]
+  CRUSH rule 0 x 391 [113,69]
+  CRUSH rule 0 x 392 [72,14]
+  CRUSH rule 0 x 393 [115,6]
+  CRUSH rule 0 x 394 [38,21]
+  CRUSH rule 0 x 395 [0,27]
+  CRUSH rule 0 x 396 [59,92]
+  CRUSH rule 0 x 397 [87,1]
+  CRUSH rule 0 x 398 [44,75]
+  CRUSH rule 0 x 399 [9,2]
+  CRUSH rule 0 x 400 [101,102]
+  CRUSH rule 0 x 401 [79,34]
+  CRUSH rule 0 x 402 [107,98]
+  CRUSH rule 0 x 403 [23,82]
+  CRUSH rule 0 x 404 [76,75]
+  CRUSH rule 0 x 405 [10,32]
+  CRUSH rule 0 x 406 [38,16]
+  CRUSH rule 0 x 407 [70,85]
+  CRUSH rule 0 x 408 [55,72]
+  CRUSH rule 0 x 409 [102,15]
+  CRUSH rule 0 x 410 [59,13]
+  CRUSH rule 0 x 411 [34,29]
+  CRUSH rule 0 x 412 [108,99]
+  CRUSH rule 0 x 413 [54,107]
+  CRUSH rule 0 x 414 [70,4]
+  CRUSH rule 0 x 415 [107,36]
+  CRUSH rule 0 x 416 [79,68]
+  CRUSH rule 0 x 417 [8,79]
+  CRUSH rule 0 x 418 [51,46]
+  CRUSH rule 0 x 419 [117,16]
+  CRUSH rule 0 x 420 [109,105]
+  CRUSH rule 0 x 421 [114,17]
+  CRUSH rule 0 x 422 [109,8]
+  CRUSH rule 0 x 423 [59,98]
+  CRUSH rule 0 x 424 [71,5]
+  CRUSH rule 0 x 425 [101,111]
+  CRUSH rule 0 x 426 [47,46]
+  CRUSH rule 0 x 427 [86,87]
+  CRUSH rule 0 x 428 [68,35]
+  CRUSH rule 0 x 429 [76,6]
+  CRUSH rule 0 x 430 [9,86]
+  CRUSH rule 0 x 431 [105,119]
+  CRUSH rule 0 x 432 [46,37]
+  CRUSH rule 0 x 433 [6,101]
+  CRUSH rule 0 x 434 [64,69]
+  CRUSH rule 0 x 435 [16,50]
+  CRUSH rule 0 x 436 [89,102]
+  CRUSH rule 0 x 437 [29,114]
+  CRUSH rule 0 x 438 [105,98]
+  CRUSH rule 0 x 439 [29,119]
+  CRUSH rule 0 x 440 [38,13]
+  CRUSH rule 0 x 441 [112,105]
+  CRUSH rule 0 x 442 [55,108]
+  CRUSH rule 0 x 443 [44,57]
+  CRUSH rule 0 x 444 [11,27]
+  CRUSH rule 0 x 445 [19,5]
+  CRUSH rule 0 x 446 [40,47]
+  CRUSH rule 0 x 447 [100,61]
+  CRUSH rule 0 x 448 [7,68]
+  CRUSH rule 0 x 449 [67,19]
+  CRUSH rule 0 x 450 [117,101]
+  CRUSH rule 0 x 451 [93,108]
+  CRUSH rule 0 x 452 [70,49]
+  CRUSH rule 0 x 453 [82,51]
+  CRUSH rule 0 x 454 [53,18]
+  CRUSH rule 0 x 455 [91,92]
+  CRUSH rule 0 x 456 [17,16]
+  CRUSH rule 0 x 457 [113,31]
+  CRUSH rule 0 x 458 [119,43]
+  CRUSH rule 0 x 459 [25,115]
+  CRUSH rule 0 x 460 [11,97]
+  CRUSH rule 0 x 461 [21,111]
+  CRUSH rule 0 x 462 [25,62]
+  CRUSH rule 0 x 463 [6,105]
+  CRUSH rule 0 x 464 [19,109]
+  CRUSH rule 0 x 465 [29,86]
+  CRUSH rule 0 x 466 [66,91]
+  CRUSH rule 0 x 467 [27,68]
+  CRUSH rule 0 x 468 [97,26]
+  CRUSH rule 0 x 469 [98,75]
+  CRUSH rule 0 x 470 [50,67]
+  CRUSH rule 0 x 471 [40,79]
+  CRUSH rule 0 x 472 [74,79]
+  CRUSH rule 0 x 473 [95,36]
+  CRUSH rule 0 x 474 [51,14]
+  CRUSH rule 0 x 475 [3,79]
+  CRUSH rule 0 x 476 [110,31]
+  CRUSH rule 0 x 477 [25,106]
+  CRUSH rule 0 x 478 [19,105]
+  CRUSH rule 0 x 479 [70,37]
+  CRUSH rule 0 x 480 [62,57]
+  CRUSH rule 0 x 481 [26,19]
+  CRUSH rule 0 x 482 [84,14]
+  CRUSH rule 0 x 483 [36,53]
+  CRUSH rule 0 x 484 [37,36]
+  CRUSH rule 0 x 485 [84,15]
+  CRUSH rule 0 x 486 [92,10]
+  CRUSH rule 0 x 487 [106,51]
+  CRUSH rule 0 x 488 [42,43]
+  CRUSH rule 0 x 489 [76,16]
+  CRUSH rule 0 x 490 [68,87]
+  CRUSH rule 0 x 491 [80,71]
+  CRUSH rule 0 x 492 [21,57]
+  CRUSH rule 0 x 493 [99,78]
+  CRUSH rule 0 x 494 [4,87]
+  CRUSH rule 0 x 495 [40,43]
+  CRUSH rule 0 x 496 [13,38]
+  CRUSH rule 0 x 497 [102,71]
+  CRUSH rule 0 x 498 [68,83]
+  CRUSH rule 0 x 499 [22,26]
+  CRUSH rule 0 x 500 [50,6]
+  CRUSH rule 0 x 501 [60,79]
+  CRUSH rule 0 x 502 [11,28]
+  CRUSH rule 0 x 503 [117,25]
+  CRUSH rule 0 x 504 [90,41]
+  CRUSH rule 0 x 505 [91,100]
+  CRUSH rule 0 x 506 [82,103]
+  CRUSH rule 0 x 507 [6,103]
+  CRUSH rule 0 x 508 [34,87]
+  CRUSH rule 0 x 509 [88,63]
+  CRUSH rule 0 x 510 [11,73]
+  CRUSH rule 0 x 511 [72,27]
+  CRUSH rule 0 x 512 [118,73]
+  CRUSH rule 0 x 513 [22,76]
+  CRUSH rule 0 x 514 [82,15]
+  CRUSH rule 0 x 515 [27,0]
+  CRUSH rule 0 x 516 [66,85]
+  CRUSH rule 0 x 517 [83,4]
+  CRUSH rule 0 x 518 [18,3]
+  CRUSH rule 0 x 519 [67,119]
+  CRUSH rule 0 x 520 [15,114]
+  CRUSH rule 0 x 521 [63,113]
+  CRUSH rule 0 x 522 [4,73]
+  CRUSH rule 0 x 523 [36,35]
+  CRUSH rule 0 x 524 [33,38]
+  CRUSH rule 0 x 525 [63,119]
+  CRUSH rule 0 x 526 [83,50]
+  CRUSH rule 0 x 527 [37,0]
+  CRUSH rule 0 x 528 [108,35]
+  CRUSH rule 0 x 529 [107,15]
+  CRUSH rule 0 x 530 [49,3]
+  CRUSH rule 0 x 531 [27,7]
+  CRUSH rule 0 x 532 [68,71]
+  CRUSH rule 0 x 533 [5,85]
+  CRUSH rule 0 x 534 [97,24]
+  CRUSH rule 0 x 535 [48,75]
+  CRUSH rule 0 x 536 [3,37]
+  CRUSH rule 0 x 537 [116,7]
+  CRUSH rule 0 x 538 [85,8]
+  CRUSH rule 0 x 539 [10,9]
+  CRUSH rule 0 x 540 [100,101]
+  CRUSH rule 0 x 541 [111,77]
+  CRUSH rule 0 x 542 [50,27]
+  CRUSH rule 0 x 543 [45,21]
+  CRUSH rule 0 x 544 [106,93]
+  CRUSH rule 0 x 545 [43,114]
+  CRUSH rule 0 x 546 [108,79]
+  CRUSH rule 0 x 547 [27,50]
+  CRUSH rule 0 x 548 [53,82]
+  CRUSH rule 0 x 549 [60,37]
+  CRUSH rule 0 x 550 [47,68]
+  CRUSH rule 0 x 551 [14,88]
+  CRUSH rule 0 x 552 [70,73]
+  CRUSH rule 0 x 553 [96,105]
+  CRUSH rule 0 x 554 [61,0]
+  CRUSH rule 0 x 555 [76,37]
+  CRUSH rule 0 x 556 [106,89]
+  CRUSH rule 0 x 557 [39,113]
+  CRUSH rule 0 x 558 [70,79]
+  CRUSH rule 0 x 559 [106,69]
+  CRUSH rule 0 x 560 [94,43]
+  CRUSH rule 0 x 561 [27,76]
+  CRUSH rule 0 x 562 [97,62]
+  CRUSH rule 0 x 563 [64,103]
+  CRUSH rule 0 x 564 [96,41]
+  CRUSH rule 0 x 565 [66,71]
+  CRUSH rule 0 x 566 [27,38]
+  CRUSH rule 0 x 567 [88,8]
+  CRUSH rule 0 x 568 [17,96]
+  CRUSH rule 0 x 569 [102,63]
+  CRUSH rule 0 x 570 [7,27]
+  CRUSH rule 0 x 571 [95,98]
+  CRUSH rule 0 x 572 [62,89]
+  CRUSH rule 0 x 573 [51,118]
+  CRUSH rule 0 x 574 [89,78]
+  CRUSH rule 0 x 575 [19,101]
+  CRUSH rule 0 x 576 [112,73]
+  CRUSH rule 0 x 577 [8,84]
+  CRUSH rule 0 x 578 [64,8]
+  CRUSH rule 0 x 579 [78,77]
+  CRUSH rule 0 x 580 [68,95]
+  CRUSH rule 0 x 581 [55,52]
+  CRUSH rule 0 x 582 [27,13]
+  CRUSH rule 0 x 583 [74,105]
+  CRUSH rule 0 x 584 [72,13]
+  CRUSH rule 0 x 585 [88,99]
+  CRUSH rule 0 x 586 [33,108]
+  CRUSH rule 0 x 587 [106,99]
+  CRUSH rule 0 x 588 [0,83]
+  CRUSH rule 0 x 589 [7,95]
+  CRUSH rule 0 x 590 [59,112]
+  CRUSH rule 0 x 591 [42,23]
+  CRUSH rule 0 x 592 [45,72]
+  CRUSH rule 0 x 593 [89,14]
+  CRUSH rule 0 x 594 [27,76]
+  CRUSH rule 0 x 595 [7,10]
+  CRUSH rule 0 x 596 [82,59]
+  CRUSH rule 0 x 597 [72,83]
+  CRUSH rule 0 x 598 [34,15]
+  CRUSH rule 0 x 599 [119,61]
+  CRUSH rule 0 x 600 [9,84]
+  CRUSH rule 0 x 601 [104,15]
+  CRUSH rule 0 x 602 [48,45]
+  CRUSH rule 0 x 603 [24,9]
+  CRUSH rule 0 x 604 [89,0]
+  CRUSH rule 0 x 605 [104,87]
+  CRUSH rule 0 x 606 [49,34]
+  CRUSH rule 0 x 607 [95,40]
+  CRUSH rule 0 x 608 [49,80]
+  CRUSH rule 0 x 609 [61,66]
+  CRUSH rule 0 x 610 [106,16]
+  CRUSH rule 0 x 611 [66,87]
+  CRUSH rule 0 x 612 [103,8]
+  CRUSH rule 0 x 613 [84,91]
+  CRUSH rule 0 x 614 [81,7]
+  CRUSH rule 0 x 615 [61,19]
+  CRUSH rule 0 x 616 [41,15]
+  CRUSH rule 0 x 617 [111,69]
+  CRUSH rule 0 x 618 [3,99]
+  CRUSH rule 0 x 619 [92,27]
+  CRUSH rule 0 x 620 [108,103]
+  CRUSH rule 0 x 621 [106,99]
+  CRUSH rule 0 x 622 [67,48]
+  CRUSH rule 0 x 623 [94,3]
+  CRUSH rule 0 x 624 [115,59]
+  CRUSH rule 0 x 625 [111,27]
+  CRUSH rule 0 x 626 [3,55]
+  CRUSH rule 0 x 627 [19,29]
+  CRUSH rule 0 x 628 [65,88]
+  CRUSH rule 0 x 629 [119,7]
+  CRUSH rule 0 x 630 [109,19]
+  CRUSH rule 0 x 631 [48,75]
+  CRUSH rule 0 x 632 [81,0]
+  CRUSH rule 0 x 633 [65,68]
+  CRUSH rule 0 x 634 [87,50]
+  CRUSH rule 0 x 635 [107,9]
+  CRUSH rule 0 x 636 [23,78]
+  CRUSH rule 0 x 637 [102,45]
+  CRUSH rule 0 x 638 [43,114]
+  CRUSH rule 0 x 639 [31,78]
+  CRUSH rule 0 x 640 [113,73]
+  CRUSH rule 0 x 641 [45,96]
+  CRUSH rule 0 x 642 [47,66]
+  CRUSH rule 0 x 643 [64,47]
+  CRUSH rule 0 x 644 [31,21]
+  CRUSH rule 0 x 645 [76,19]
+  CRUSH rule 0 x 646 [37,54]
+  CRUSH rule 0 x 647 [58,87]
+  CRUSH rule 0 x 648 [31,21]
+  CRUSH rule 0 x 649 [88,45]
+  CRUSH rule 0 x 650 [116,7]
+  CRUSH rule 0 x 651 [97,106]
+  CRUSH rule 0 x 652 [57,112]
+  CRUSH rule 0 x 653 [38,39]
+  CRUSH rule 0 x 654 [49,32]
+  CRUSH rule 0 x 655 [89,62]
+  CRUSH rule 0 x 656 [0,49]
+  CRUSH rule 0 x 657 [47,32]
+  CRUSH rule 0 x 658 [75,82]
+  CRUSH rule 0 x 659 [26,83]
+  CRUSH rule 0 x 660 [65,110]
+  CRUSH rule 0 x 661 [91,48]
+  CRUSH rule 0 x 662 [111,99]
+  CRUSH rule 0 x 663 [88,35]
+  CRUSH rule 0 x 664 [59,78]
+  CRUSH rule 0 x 665 [78,15]
+  CRUSH rule 0 x 666 [112,4]
+  CRUSH rule 0 x 667 [97,46]
+  CRUSH rule 0 x 668 [97,15]
+  CRUSH rule 0 x 669 [85,66]
+  CRUSH rule 0 x 670 [41,38]
+  CRUSH rule 0 x 671 [116,97]
+  CRUSH rule 0 x 672 [44,55]
+  CRUSH rule 0 x 673 [83,50]
+  CRUSH rule 0 x 674 [59,78]
+  CRUSH rule 0 x 675 [88,14]
+  CRUSH rule 0 x 676 [62,8]
+  CRUSH rule 0 x 677 [88,67]
+  CRUSH rule 0 x 678 [98,83]
+  CRUSH rule 0 x 679 [70,59]
+  CRUSH rule 0 x 680 [55,96]
+  CRUSH rule 0 x 681 [53,68]
+  CRUSH rule 0 x 682 [27,58]
+  CRUSH rule 0 x 683 [57,80]
+  CRUSH rule 0 x 684 [98,65]
+  CRUSH rule 0 x 685 [106,55]
+  CRUSH rule 0 x 686 [86,95]
+  CRUSH rule 0 x 687 [49,72]
+  CRUSH rule 0 x 688 [16,114]
+  CRUSH rule 0 x 689 [6,48]
+  CRUSH rule 0 x 690 [43,70]
+  CRUSH rule 0 x 691 [34,105]
+  CRUSH rule 0 x 692 [40,97]
+  CRUSH rule 0 x 693 [29,84]
+  CRUSH rule 0 x 694 [6,41]
+  CRUSH rule 0 x 695 [31,60]
+  CRUSH rule 0 x 696 [36,3]
+  CRUSH rule 0 x 697 [96,77]
+  CRUSH rule 0 x 698 [61,68]
+  CRUSH rule 0 x 699 [47,62]
+  CRUSH rule 0 x 700 [0,55]
+  CRUSH rule 0 x 701 [42,11]
+  CRUSH rule 0 x 702 [0,71]
+  CRUSH rule 0 x 703 [92,67]
+  CRUSH rule 0 x 704 [10,19]
+  CRUSH rule 0 x 705 [105,82]
+  CRUSH rule 0 x 706 [74,105]
+  CRUSH rule 0 x 707 [0,77]
+  CRUSH rule 0 x 708 [84,8]
+  CRUSH rule 0 x 709 [114,97]
+  CRUSH rule 0 x 710 [94,7]
+  CRUSH rule 0 x 711 [68,49]
+  CRUSH rule 0 x 712 [34,75]
+  CRUSH rule 0 x 713 [29,0]
+  CRUSH rule 0 x 714 [81,115]
+  CRUSH rule 0 x 715 [71,84]
+  CRUSH rule 0 x 716 [40,17]
+  CRUSH rule 0 x 717 [61,62]
+  CRUSH rule 0 x 718 [40,85]
+  CRUSH rule 0 x 719 [59,42]
+  CRUSH rule 0 x 720 [69,72]
+  CRUSH rule 0 x 721 [62,41]
+  CRUSH rule 0 x 722 [115,8]
+  CRUSH rule 0 x 723 [117,41]
+  CRUSH rule 0 x 724 [45,21]
+  CRUSH rule 0 x 725 [53,113]
+  CRUSH rule 0 x 726 [84,23]
+  CRUSH rule 0 x 727 [109,14]
+  CRUSH rule 0 x 728 [76,16]
+  CRUSH rule 0 x 729 [108,6]
+  CRUSH rule 0 x 730 [28,47]
+  CRUSH rule 0 x 731 [78,27]
+  CRUSH rule 0 x 732 [55,90]
+  CRUSH rule 0 x 733 [84,3]
+  CRUSH rule 0 x 734 [27,117]
+  CRUSH rule 0 x 735 [83,28]
+  CRUSH rule 0 x 736 [70,67]
+  CRUSH rule 0 x 737 [117,15]
+  CRUSH rule 0 x 738 [118,33]
+  CRUSH rule 0 x 739 [87,38]
+  CRUSH rule 0 x 740 [29,38]
+  CRUSH rule 0 x 741 [96,73]
+  CRUSH rule 0 x 742 [106,83]
+  CRUSH rule 0 x 743 [105,94]
+  CRUSH rule 0 x 744 [23,42]
+  CRUSH rule 0 x 745 [28,59]
+  CRUSH rule 0 x 746 [18,47]
+  CRUSH rule 0 x 747 [65,70]
+  CRUSH rule 0 x 748 [48,89]
+  CRUSH rule 0 x 749 [102,51]
+  CRUSH rule 0 x 750 [50,27]
+  CRUSH rule 0 x 751 [36,25]
+  CRUSH rule 0 x 752 [69,52]
+  CRUSH rule 0 x 753 [9,32]
+  CRUSH rule 0 x 754 [9,57]
+  CRUSH rule 0 x 755 [98,81]
+  CRUSH rule 0 x 756 [113,87]
+  CRUSH rule 0 x 757 [47,66]
+  CRUSH rule 0 x 758 [57,88]
+  CRUSH rule 0 x 759 [74,27]
+  CRUSH rule 0 x 760 [53,90]
+  CRUSH rule 0 x 761 [78,97]
+  CRUSH rule 0 x 762 [87,8]
+  CRUSH rule 0 x 763 [13,45]
+  CRUSH rule 0 x 764 [106,81]
+  CRUSH rule 0 x 765 [109,91]
+  CRUSH rule 0 x 766 [76,97]
+  CRUSH rule 0 x 767 [41,116]
+  CRUSH rule 0 x 768 [13,114]
+  CRUSH rule 0 x 769 [91,104]
+  CRUSH rule 0 x 770 [105,96]
+  CRUSH rule 0 x 771 [10,76]
+  CRUSH rule 0 x 772 [8,111]
+  CRUSH rule 0 x 773 [116,75]
+  CRUSH rule 0 x 774 [100,43]
+  CRUSH rule 0 x 775 [15,34]
+  CRUSH rule 0 x 776 [69,38]
+  CRUSH rule 0 x 777 [76,49]
+  CRUSH rule 0 x 778 [38,13]
+  CRUSH rule 0 x 779 [46,21]
+  CRUSH rule 0 x 780 [63,102]
+  CRUSH rule 0 x 781 [19,85]
+  CRUSH rule 0 x 782 [117,31]
+  CRUSH rule 0 x 783 [60,93]
+  CRUSH rule 0 x 784 [82,81]
+  CRUSH rule 0 x 785 [27,84]
+  CRUSH rule 0 x 786 [41,80]
+  CRUSH rule 0 x 787 [13,54]
+  CRUSH rule 0 x 788 [4,100]
+  CRUSH rule 0 x 789 [50,37]
+  CRUSH rule 0 x 790 [58,16]
+  CRUSH rule 0 x 791 [96,97]
+  CRUSH rule 0 x 792 [45,4]
+  CRUSH rule 0 x 793 [6,71]
+  CRUSH rule 0 x 794 [14,89]
+  CRUSH rule 0 x 795 [51,108]
+  CRUSH rule 0 x 796 [114,77]
+  CRUSH rule 0 x 797 [79,100]
+  CRUSH rule 0 x 798 [42,8]
+  CRUSH rule 0 x 799 [48,11]
+  CRUSH rule 0 x 800 [91,7]
+  CRUSH rule 0 x 801 [2,6]
+  CRUSH rule 0 x 802 [116,14]
+  CRUSH rule 0 x 803 [37,32]
+  CRUSH rule 0 x 804 [6,73]
+  CRUSH rule 0 x 805 [96,22]
+  CRUSH rule 0 x 806 [67,90]
+  CRUSH rule 0 x 807 [47,42]
+  CRUSH rule 0 x 808 [76,31]
+  CRUSH rule 0 x 809 [27,26]
+  CRUSH rule 0 x 810 [119,61]
+  CRUSH rule 0 x 811 [75,72]
+  CRUSH rule 0 x 812 [25,52]
+  CRUSH rule 0 x 813 [64,13]
+  CRUSH rule 0 x 814 [110,53]
+  CRUSH rule 0 x 815 [84,67]
+  CRUSH rule 0 x 816 [25,22]
+  CRUSH rule 0 x 817 [40,29]
+  CRUSH rule 0 x 818 [34,85]
+  CRUSH rule 0 x 819 [88,17]
+  CRUSH rule 0 x 820 [104,49]
+  CRUSH rule 0 x 821 [58,69]
+  CRUSH rule 0 x 822 [29,72]
+  CRUSH rule 0 x 823 [100,103]
+  CRUSH rule 0 x 824 [102,81]
+  CRUSH rule 0 x 825 [47,17]
+  CRUSH rule 0 x 826 [45,11]
+  CRUSH rule 0 x 827 [101,11]
+  CRUSH rule 0 x 828 [60,27]
+  CRUSH rule 0 x 829 [45,90]
+  CRUSH rule 0 x 830 [51,96]
+  CRUSH rule 0 x 831 [6,102]
+  CRUSH rule 0 x 832 [57,78]
+  CRUSH rule 0 x 833 [34,97]
+  CRUSH rule 0 x 834 [90,33]
+  CRUSH rule 0 x 835 [55,46]
+  CRUSH rule 0 x 836 [38,43]
+  CRUSH rule 0 x 837 [51,74]
+  CRUSH rule 0 x 838 [6,32]
+  CRUSH rule 0 x 839 [106,8]
+  CRUSH rule 0 x 840 [33,109]
+  CRUSH rule 0 x 841 [110,15]
+  CRUSH rule 0 x 842 [66,67]
+  CRUSH rule 0 x 843 [62,63]
+  CRUSH rule 0 x 844 [74,13]
+  CRUSH rule 0 x 845 [74,43]
+  CRUSH rule 0 x 846 [98,107]
+  CRUSH rule 0 x 847 [10,94]
+  CRUSH rule 0 x 848 [89,17]
+  CRUSH rule 0 x 849 [42,59]
+  CRUSH rule 0 x 850 [40,73]
+  CRUSH rule 0 x 851 [65,4]
+  CRUSH rule 0 x 852 [31,94]
+  CRUSH rule 0 x 853 [49,11]
+  CRUSH rule 0 x 854 [83,54]
+  CRUSH rule 0 x 855 [2,19]
+  CRUSH rule 0 x 856 [6,107]
+  CRUSH rule 0 x 857 [15,82]
+  CRUSH rule 0 x 858 [10,80]
+  CRUSH rule 0 x 859 [14,43]
+  CRUSH rule 0 x 860 [114,75]
+  CRUSH rule 0 x 861 [1,33]
+  CRUSH rule 0 x 862 [22,25]
+  CRUSH rule 0 x 863 [79,0]
+  CRUSH rule 0 x 864 [68,6]
+  CRUSH rule 0 x 865 [25,92]
+  CRUSH rule 0 x 866 [18,89]
+  CRUSH rule 0 x 867 [53,78]
+  CRUSH rule 0 x 868 [81,98]
+  CRUSH rule 0 x 869 [111,11]
+  CRUSH rule 0 x 870 [73,19]
+  CRUSH rule 0 x 871 [25,54]
+  CRUSH rule 0 x 872 [39,48]
+  CRUSH rule 0 x 873 [92,8]
+  CRUSH rule 0 x 874 [96,11]
+  CRUSH rule 0 x 875 [115,59]
+  CRUSH rule 0 x 876 [98,75]
+  CRUSH rule 0 x 877 [73,5]
+  CRUSH rule 0 x 878 [64,45]
+  CRUSH rule 0 x 879 [15,18]
+  CRUSH rule 0 x 880 [56,91]
+  CRUSH rule 0 x 881 [109,69]
+  CRUSH rule 0 x 882 [60,33]
+  CRUSH rule 0 x 883 [93,96]
+  CRUSH rule 0 x 884 [67,38]
+  CRUSH rule 0 x 885 [31,115]
+  CRUSH rule 0 x 886 [2,9]
+  CRUSH rule 0 x 887 [5,7]
+  CRUSH rule 0 x 888 [16,13]
+  CRUSH rule 0 x 889 [27,76]
+  CRUSH rule 0 x 890 [48,63]
+  CRUSH rule 0 x 891 [86,79]
+  CRUSH rule 0 x 892 [64,107]
+  CRUSH rule 0 x 893 [118,22]
+  CRUSH rule 0 x 894 [16,111]
+  CRUSH rule 0 x 895 [40,3]
+  CRUSH rule 0 x 896 [97,96]
+  CRUSH rule 0 x 897 [107,78]
+  CRUSH rule 0 x 898 [10,2]
+  CRUSH rule 0 x 899 [75,15]
+  CRUSH rule 0 x 900 [102,81]
+  CRUSH rule 0 x 901 [66,87]
+  CRUSH rule 0 x 902 [102,49]
+  CRUSH rule 0 x 903 [5,69]
+  CRUSH rule 0 x 904 [50,16]
+  CRUSH rule 0 x 905 [99,76]
+  CRUSH rule 0 x 906 [75,119]
+  CRUSH rule 0 x 907 [47,5]
+  CRUSH rule 0 x 908 [96,37]
+  CRUSH rule 0 x 909 [94,75]
+  CRUSH rule 0 x 910 [88,63]
+  CRUSH rule 0 x 911 [102,23]
+  CRUSH rule 0 x 912 [91,60]
+  CRUSH rule 0 x 913 [29,17]
+  CRUSH rule 0 x 914 [84,14]
+  CRUSH rule 0 x 915 [70,27]
+  CRUSH rule 0 x 916 [32,9]
+  CRUSH rule 0 x 917 [43,108]
+  CRUSH rule 0 x 918 [91,98]
+  CRUSH rule 0 x 919 [13,69]
+  CRUSH rule 0 x 920 [18,9]
+  CRUSH rule 0 x 921 [104,33]
+  CRUSH rule 0 x 922 [33,32]
+  CRUSH rule 0 x 923 [28,8]
+  CRUSH rule 0 x 924 [69,88]
+  CRUSH rule 0 x 925 [71,32]
+  CRUSH rule 0 x 926 [64,69]
+  CRUSH rule 0 x 927 [99,17]
+  CRUSH rule 0 x 928 [13,113]
+  CRUSH rule 0 x 929 [117,61]
+  CRUSH rule 0 x 930 [31,82]
+  CRUSH rule 0 x 931 [83,66]
+  CRUSH rule 0 x 932 [60,13]
+  CRUSH rule 0 x 933 [63,82]
+  CRUSH rule 0 x 934 [68,4]
+  CRUSH rule 0 x 935 [31,18]
+  CRUSH rule 0 x 936 [65,32]
+  CRUSH rule 0 x 937 [110,79]
+  CRUSH rule 0 x 938 [29,106]
+  CRUSH rule 0 x 939 [77,13]
+  CRUSH rule 0 x 940 [76,15]
+  CRUSH rule 0 x 941 [66,37]
+  CRUSH rule 0 x 942 [83,94]
+  CRUSH rule 0 x 943 [32,4]
+  CRUSH rule 0 x 944 [113,4]
+  CRUSH rule 0 x 945 [71,52]
+  CRUSH rule 0 x 946 [37,70]
+  CRUSH rule 0 x 947 [107,74]
+  CRUSH rule 0 x 948 [55,98]
+  CRUSH rule 0 x 949 [11,72]
+  CRUSH rule 0 x 950 [96,23]
+  CRUSH rule 0 x 951 [40,93]
+  CRUSH rule 0 x 952 [93,46]
+  CRUSH rule 0 x 953 [55,92]
+  CRUSH rule 0 x 954 [84,57]
+  CRUSH rule 0 x 955 [31,117]
+  CRUSH rule 0 x 956 [72,11]
+  CRUSH rule 0 x 957 [3,74]
+  CRUSH rule 0 x 958 [23,106]
+  CRUSH rule 0 x 959 [42,59]
+  CRUSH rule 0 x 960 [113,107]
+  CRUSH rule 0 x 961 [116,8]
+  CRUSH rule 0 x 962 [13,62]
+  CRUSH rule 0 x 963 [0,99]
+  CRUSH rule 0 x 964 [59,56]
+  CRUSH rule 0 x 965 [47,115]
+  CRUSH rule 0 x 966 [88,63]
+  CRUSH rule 0 x 967 [71,15]
+  CRUSH rule 0 x 968 [73,7]
+  CRUSH rule 0 x 969 [53,6]
+  CRUSH rule 0 x 970 [111,75]
+  CRUSH rule 0 x 971 [87,22]
+  CRUSH rule 0 x 972 [5,37]
+  CRUSH rule 0 x 973 [113,27]
+  CRUSH rule 0 x 974 [49,112]
+  CRUSH rule 0 x 975 [83,58]
+  CRUSH rule 0 x 976 [81,38]
+  CRUSH rule 0 x 977 [95,102]
+  CRUSH rule 0 x 978 [35,56]
+  CRUSH rule 0 x 979 [98,6]
+  CRUSH rule 0 x 980 [52,69]
+  CRUSH rule 0 x 981 [89,117]
+  CRUSH rule 0 x 982 [1,47]
+  CRUSH rule 0 x 983 [34,61]
+  CRUSH rule 0 x 984 [78,25]
+  CRUSH rule 0 x 985 [99,52]
+  CRUSH rule 0 x 986 [4,59]
+  CRUSH rule 0 x 987 [78,21]
+  CRUSH rule 0 x 988 [79,2]
+  CRUSH rule 0 x 989 [87,17]
+  CRUSH rule 0 x 990 [47,118]
+  CRUSH rule 0 x 991 [61,18]
+  CRUSH rule 0 x 992 [83,66]
+  CRUSH rule 0 x 993 [74,53]
+  CRUSH rule 0 x 994 [74,57]
+  CRUSH rule 0 x 995 [100,97]
+  CRUSH rule 0 x 996 [41,6]
+  CRUSH rule 0 x 997 [89,76]
+  CRUSH rule 0 x 998 [92,47]
+  CRUSH rule 0 x 999 [117,11]
+  CRUSH rule 0 x 1000 [9,119]
+  CRUSH rule 0 x 1001 [49,32]
+  CRUSH rule 0 x 1002 [99,113]
+  CRUSH rule 0 x 1003 [43,18]
+  CRUSH rule 0 x 1004 [89,54]
+  CRUSH rule 0 x 1005 [105,84]
+  CRUSH rule 0 x 1006 [45,111]
+  CRUSH rule 0 x 1007 [19,57]
+  CRUSH rule 0 x 1008 [31,14]
+  CRUSH rule 0 x 1009 [19,111]
+  CRUSH rule 0 x 1010 [42,89]
+  CRUSH rule 0 x 1011 [25,114]
+  CRUSH rule 0 x 1012 [68,71]
+  CRUSH rule 0 x 1013 [5,45]
+  CRUSH rule 0 x 1014 [33,4]
+  CRUSH rule 0 x 1015 [14,45]
+  CRUSH rule 0 x 1016 [88,19]
+  CRUSH rule 0 x 1017 [0,89]
+  CRUSH rule 0 x 1018 [63,5]
+  CRUSH rule 0 x 1019 [104,97]
+  CRUSH rule 0 x 1020 [96,99]
+  CRUSH rule 0 x 1021 [117,41]
+  CRUSH rule 0 x 1022 [73,22]
+  CRUSH rule 0 x 1023 [0,16]
+  rule 0 (data) num_rep 2 result size == 2:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 3 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 4 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 5 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 6 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 7 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 8 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 9 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,114,14]
+  CRUSH rule 0 x 1 [80,79,6]
+  CRUSH rule 0 x 2 [91,19,42]
+  CRUSH rule 0 x 3 [51,4,109]
+  CRUSH rule 0 x 4 [50,89,8]
+  CRUSH rule 0 x 5 [89,94,11]
+  CRUSH rule 0 x 6 [91,76,7]
+  CRUSH rule 0 x 7 [104,25,17]
+  CRUSH rule 0 x 8 [78,14,53]
+  CRUSH rule 0 x 9 [101,102,8]
+  CRUSH rule 0 x 10 [61,6,88]
+  CRUSH rule 0 x 11 [13,31,26]
+  CRUSH rule 0 x 12 [83,46,13]
+  CRUSH rule 0 x 13 [108,85,7]
+  CRUSH rule 0 x 14 [105,3,40]
+  CRUSH rule 0 x 15 [18,7,29]
+  CRUSH rule 0 x 16 [103,3,50]
+  CRUSH rule 0 x 17 [85,110,9]
+  CRUSH rule 0 x 18 [11,65,119]
+  CRUSH rule 0 x 19 [75,50,22]
+  CRUSH rule 0 x 20 [79,70,15]
+  CRUSH rule 0 x 21 [84,9,61]
+  CRUSH rule 0 x 22 [23,104,17]
+  CRUSH rule 0 x 23 [118,17,47]
+  CRUSH rule 0 x 24 [83,110,8]
+  CRUSH rule 0 x 25 [81,64,11]
+  CRUSH rule 0 x 26 [38,99,6]
+  CRUSH rule 0 x 27 [76,107,4]
+  CRUSH rule 0 x 28 [76,71,15]
+  CRUSH rule 0 x 29 [8,119,63]
+  CRUSH rule 0 x 30 [94,87,6]
+  CRUSH rule 0 x 31 [76,95,11]
+  CRUSH rule 0 x 32 [72,95,19]
+  CRUSH rule 0 x 33 [77,86,17]
+  CRUSH rule 0 x 34 [74,73,14]
+  CRUSH rule 0 x 35 [22,88,83]
+  CRUSH rule 0 x 36 [104,65,15]
+  CRUSH rule 0 x 37 [38,81,15]
+  CRUSH rule 0 x 38 [72,11,79]
+  CRUSH rule 0 x 39 [68,103,13]
+  CRUSH rule 0 x 40 [103,78,4]
+  CRUSH rule 0 x 41 [85,11,110]
+  CRUSH rule 0 x 42 [106,75,6]
+  CRUSH rule 0 x 43 [10,68,21]
+  CRUSH rule 0 x 44 [101,116,9]
+  CRUSH rule 0 x 45 [8,64,61]
+  CRUSH rule 0 x 46 [65,1,14]
+  CRUSH rule 0 x 47 [106,53,7]
+  CRUSH rule 0 x 48 [34,6,77]
+  CRUSH rule 0 x 49 [0,81,4]
+  CRUSH rule 0 x 50 [42,6,89]
+  CRUSH rule 0 x 51 [104,75,21]
+  CRUSH rule 0 x 52 [83,19,58]
+  CRUSH rule 0 x 53 [32,75,7]
+  CRUSH rule 0 x 54 [28,79,21]
+  CRUSH rule 0 x 55 [14,5,37]
+  CRUSH rule 0 x 56 [21,72,77]
+  CRUSH rule 0 x 57 [93,84,3]
+  CRUSH rule 0 x 58 [45,106,13]
+  CRUSH rule 0 x 59 [80,41,15]
+  CRUSH rule 0 x 60 [90,57,15]
+  CRUSH rule 0 x 61 [88,37,6]
+  CRUSH rule 0 x 62 [81,1,9]
+  CRUSH rule 0 x 63 [79,113,19]
+  CRUSH rule 0 x 64 [1,89,11]
+  CRUSH rule 0 x 65 [13,0,67]
+  CRUSH rule 0 x 66 [48,49,9]
+  CRUSH rule 0 x 67 [94,103,11]
+  CRUSH rule 0 x 68 [102,91,6]
+  CRUSH rule 0 x 69 [62,77,19]
+  CRUSH rule 0 x 70 [84,105,4]
+  CRUSH rule 0 x 71 [55,19,62]
+  CRUSH rule 0 x 72 [97,42,22]
+  CRUSH rule 0 x 73 [64,83,17]
+  CRUSH rule 0 x 74 [96,59,11]
+  CRUSH rule 0 x 75 [29,28,4]
+  CRUSH rule 0 x 76 [55,0,21]
+  CRUSH rule 0 x 77 [107,21,48]
+  CRUSH rule 0 x 78 [31,94,22]
+  CRUSH rule 0 x 79 [64,51,7]
+  CRUSH rule 0 x 80 [0,31,19]
+  CRUSH rule 0 x 81 [71,109,15]
+  CRUSH rule 0 x 82 [37,40,21]
+  CRUSH rule 0 x 83 [92,103,3]
+  CRUSH rule 0 x 84 [49,115,17]
+  CRUSH rule 0 x 85 [54,101,19]
+  CRUSH rule 0 x 86 [37,7,109]
+  CRUSH rule 0 x 87 [116,4,33]
+  CRUSH rule 0 x 88 [38,55,14]
+  CRUSH rule 0 x 89 [76,77,9]
+  CRUSH rule 0 x 90 [14,50,39]
+  CRUSH rule 0 x 91 [93,34,19]
+  CRUSH rule 0 x 92 [86,9,73]
+  CRUSH rule 0 x 93 [44,65,19]
+  CRUSH rule 0 x 94 [61,102,21]
+  CRUSH rule 0 x 95 [93,86,21]
+  CRUSH rule 0 x 96 [66,87,21]
+  CRUSH rule 0 x 97 [111,9,89]
+  CRUSH rule 0 x 98 [66,91,6]
+  CRUSH rule 0 x 99 [78,3,81]
+  CRUSH rule 0 x 100 [28,8,87]
+  CRUSH rule 0 x 101 [84,16,17]
+  CRUSH rule 0 x 102 [82,105,19]
+  CRUSH rule 0 x 103 [66,6,49]
+  CRUSH rule 0 x 104 [14,95,50]
+  CRUSH rule 0 x 105 [87,1,15]
+  CRUSH rule 0 x 106 [69,116,15]
+  CRUSH rule 0 x 107 [1,55,4]
+  CRUSH rule 0 x 108 [94,53,4]
+  CRUSH rule 0 x 109 [112,63,13]
+  CRUSH rule 0 x 110 [54,61,9]
+  CRUSH rule 0 x 111 [10,58,7]
+  CRUSH rule 0 x 112 [89,9,98]
+  CRUSH rule 0 x 113 [69,2,21]
+  CRUSH rule 0 x 114 [79,17,117]
+  CRUSH rule 0 x 115 [50,85,19]
+  CRUSH rule 0 x 116 [96,16,14]
+  CRUSH rule 0 x 117 [87,56,22]
+  CRUSH rule 0 x 118 [23,56,21]
+  CRUSH rule 0 x 119 [104,11,71]
+  CRUSH rule 0 x 120 [57,5,22]
+  CRUSH rule 0 x 121 [105,117,19]
+  CRUSH rule 0 x 122 [45,110,4]
+  CRUSH rule 0 x 123 [112,22,61]
+  CRUSH rule 0 x 124 [110,11,81]
+  CRUSH rule 0 x 125 [66,105,13]
+  CRUSH rule 0 x 126 [51,28,4]
+  CRUSH rule 0 x 127 [70,6,65]
+  CRUSH rule 0 x 128 [90,16,8]
+  CRUSH rule 0 x 129 [103,110,21]
+  CRUSH rule 0 x 130 [50,11,63]
+  CRUSH rule 0 x 131 [23,60,7]
+  CRUSH rule 0 x 132 [69,70,13]
+  CRUSH rule 0 x 133 [52,25,6]
+  CRUSH rule 0 x 134 [78,6,99]
+  CRUSH rule 0 x 135 [78,3,29]
+  CRUSH rule 0 x 136 [32,29,7]
+  CRUSH rule 0 x 137 [92,41,15]
+  CRUSH rule 0 x 138 [17,118,85]
+  CRUSH rule 0 x 139 [89,60,22]
+  CRUSH rule 0 x 140 [39,62,13]
+  CRUSH rule 0 x 141 [89,98,3]
+  CRUSH rule 0 x 142 [70,61,19]
+  CRUSH rule 0 x 143 [51,28,7]
+  CRUSH rule 0 x 144 [13,81,60]
+  CRUSH rule 0 x 145 [77,119,17]
+  CRUSH rule 0 x 146 [96,69,3]
+  CRUSH rule 0 x 147 [2,95,22]
+  CRUSH rule 0 x 148 [74,69,11]
+  CRUSH rule 0 x 149 [76,13,81]
+  CRUSH rule 0 x 150 [38,47,14]
+  CRUSH rule 0 x 151 [90,67,9]
+  CRUSH rule 0 x 152 [49,18,22]
+  CRUSH rule 0 x 153 [71,44,21]
+  CRUSH rule 0 x 154 [94,81,13]
+  CRUSH rule 0 x 155 [75,112,11]
+  CRUSH rule 0 x 156 [107,66,7]
+  CRUSH rule 0 x 157 [112,43,3]
+  CRUSH rule 0 x 158 [26,17,99]
+  CRUSH rule 0 x 159 [52,9,47]
+  CRUSH rule 0 x 160 [41,0,7]
+  CRUSH rule 0 x 161 [84,45,3]
+  CRUSH rule 0 x 162 [55,2,9]
+  CRUSH rule 0 x 163 [54,8,55]
+  CRUSH rule 0 x 164 [45,5,14]
+  CRUSH rule 0 x 165 [25,72,9]
+  CRUSH rule 0 x 166 [73,36,7]
+  CRUSH rule 0 x 167 [89,58,14]
+  CRUSH rule 0 x 168 [47,40,13]
+  CRUSH rule 0 x 169 [51,21,0]
+  CRUSH rule 0 x 170 [68,91,14]
+  CRUSH rule 0 x 171 [73,90,19]
+  CRUSH rule 0 x 172 [117,41,4]
+  CRUSH rule 0 x 173 [13,34,99]
+  CRUSH rule 0 x 174 [116,25,7]
+  CRUSH rule 0 x 175 [3,41,102]
+  CRUSH rule 0 x 176 [94,91,13]
+  CRUSH rule 0 x 177 [52,85,14]
+  CRUSH rule 0 x 178 [39,2,15]
+  CRUSH rule 0 x 179 [72,97,15]
+  CRUSH rule 0 x 180 [60,61,15]
+  CRUSH rule 0 x 181 [18,59,19]
+  CRUSH rule 0 x 182 [22,90,25]
+  CRUSH rule 0 x 183 [11,74,103]
+  CRUSH rule 0 x 184 [92,8,55]
+  CRUSH rule 0 x 185 [97,8,24]
+  CRUSH rule 0 x 186 [67,116,21]
+  CRUSH rule 0 x 187 [116,11,61]
+  CRUSH rule 0 x 188 [69,110,8]
+  CRUSH rule 0 x 189 [47,84,21]
+  CRUSH rule 0 x 190 [65,82,6]
+  CRUSH rule 0 x 191 [49,38,22]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,33,6]
+  CRUSH rule 0 x 194 [62,99,8]
+  CRUSH rule 0 x 195 [119,4,33]
+  CRUSH rule 0 x 196 [72,27,22]
+  CRUSH rule 0 x 197 [106,83,22]
+  CRUSH rule 0 x 198 [114,21,77]
+  CRUSH rule 0 x 199 [0,83,11]
+  CRUSH rule 0 x 200 [35,86,4]
+  CRUSH rule 0 x 201 [27,26,8]
+  CRUSH rule 0 x 202 [98,33,17]
+  CRUSH rule 0 x 203 [36,91,11]
+  CRUSH rule 0 x 204 [10,98,15]
+  CRUSH rule 0 x 205 [81,17,72]
+  CRUSH rule 0 x 206 [49,112,13]
+  CRUSH rule 0 x 207 [80,39,14]
+  CRUSH rule 0 x 208 [63,26,7]
+  CRUSH rule 0 x 209 [85,111,8]
+  CRUSH rule 0 x 210 [79,18,4]
+  CRUSH rule 0 x 211 [26,10,19]
+  CRUSH rule 0 x 212 [28,103,15]
+  CRUSH rule 0 x 213 [91,0,8]
+  CRUSH rule 0 x 214 [91,38,13]
+  CRUSH rule 0 x 215 [61,86,22]
+  CRUSH rule 0 x 216 [99,94,4]
+  CRUSH rule 0 x 217 [86,89,15]
+  CRUSH rule 0 x 218 [70,4,79]
+  CRUSH rule 0 x 219 [28,59,9]
+  CRUSH rule 0 x 220 [56,8,83]
+  CRUSH rule 0 x 221 [0,9,71]
+  CRUSH rule 0 x 222 [50,63,21]
+  CRUSH rule 0 x 223 [29,1,3]
+  CRUSH rule 0 x 224 [52,10,19]
+  CRUSH rule 0 x 225 [15,35,64]
+  CRUSH rule 0 x 226 [44,7,93]
+  CRUSH rule 0 x 227 [42,3,81]
+  CRUSH rule 0 x 228 [117,49,4]
+  CRUSH rule 0 x 229 [100,79,4]
+  CRUSH rule 0 x 230 [41,114,13]
+  CRUSH rule 0 x 231 [56,95,13]
+  CRUSH rule 0 x 232 [23,8,1]
+  CRUSH rule 0 x 233 [88,103,6]
+  CRUSH rule 0 x 234 [4,101,18]
+  CRUSH rule 0 x 235 [26,10,7]
+  CRUSH rule 0 x 236 [32,37,3]
+  CRUSH rule 0 x 237 [92,3,61]
+  CRUSH rule 0 x 238 [10,26,22]
+  CRUSH rule 0 x 239 [15,105,2]
+  CRUSH rule 0 x 240 [109,14,41]
+  CRUSH rule 0 x 241 [47,108,11]
+  CRUSH rule 0 x 242 [24,99,9]
+  CRUSH rule 0 x 243 [76,8,99]
+  CRUSH rule 0 x 244 [103,13,78]
+  CRUSH rule 0 x 245 [27,82,19]
+  CRUSH rule 0 x 246 [5,43,19]
+  CRUSH rule 0 x 247 [99,102,4]
+  CRUSH rule 0 x 248 [8,29,42]
+  CRUSH rule 0 x 249 [85,1,14]
+  CRUSH rule 0 x 250 [93,102,4]
+  CRUSH rule 0 x 251 [28,103,19]
+  CRUSH rule 0 x 252 [95,22,92]
+  CRUSH rule 0 x 253 [109,27,17]
+  CRUSH rule 0 x 254 [80,13,23]
+  CRUSH rule 0 x 255 [103,13,119]
+  CRUSH rule 0 x 256 [37,38,14]
+  CRUSH rule 0 x 257 [69,117,15]
+  CRUSH rule 0 x 258 [34,55,17]
+  CRUSH rule 0 x 259 [70,17,91]
+  CRUSH rule 0 x 260 [98,29,4]
+  CRUSH rule 0 x 261 [94,83,7]
+  CRUSH rule 0 x 262 [42,49,14]
+  CRUSH rule 0 x 263 [65,42,14]
+  CRUSH rule 0 x 264 [36,49,11]
+  CRUSH rule 0 x 265 [66,63,4]
+  CRUSH rule 0 x 266 [75,92,15]
+  CRUSH rule 0 x 267 [58,35,6]
+  CRUSH rule 0 x 268 [38,9,63]
+  CRUSH rule 0 x 269 [86,59,7]
+  CRUSH rule 0 x 270 [58,37,8]
+  CRUSH rule 0 x 271 [19,33,114]
+  CRUSH rule 0 x 272 [73,9,100]
+  CRUSH rule 0 x 273 [108,29,7]
+  CRUSH rule 0 x 274 [47,64,22]
+  CRUSH rule 0 x 275 [92,19,59]
+  CRUSH rule 0 x 276 [7,79,118]
+  CRUSH rule 0 x 277 [19,68,10]
+  CRUSH rule 0 x 278 [116,105,19]
+  CRUSH rule 0 x 279 [101,3,76]
+  CRUSH rule 0 x 280 [113,69,14]
+  CRUSH rule 0 x 281 [14,93,96]
+  CRUSH rule 0 x 282 [106,61,13]
+  CRUSH rule 0 x 283 [8,118,101]
+  CRUSH rule 0 x 284 [10,110,22]
+  CRUSH rule 0 x 285 [88,63,8]
+  CRUSH rule 0 x 286 [27,4,18]
+  CRUSH rule 0 x 287 [84,65,4]
+  CRUSH rule 0 x 288 [103,8,70]
+  CRUSH rule 0 x 289 [9,64,75]
+  CRUSH rule 0 x 290 [115,17,77]
+  CRUSH rule 0 x 291 [48,45,13]
+  CRUSH rule 0 x 292 [89,109,14]
+  CRUSH rule 0 x 293 [27,24,17]
+  CRUSH rule 0 x 294 [79,36,13]
+  CRUSH rule 0 x 295 [37,116,7]
+  CRUSH rule 0 x 296 [56,61,8]
+  CRUSH rule 0 x 297 [35,40,15]
+  CRUSH rule 0 x 298 [71,118,21]
+  CRUSH rule 0 x 299 [116,61,21]
+  CRUSH rule 0 x 300 [67,5,14]
+  CRUSH rule 0 x 301 [51,110,8]
+  CRUSH rule 0 x 302 [78,67,19]
+  CRUSH rule 0 x 303 [19,94,31]
+  CRUSH rule 0 x 304 [101,66,3]
+  CRUSH rule 0 x 305 [81,62,6]
+  CRUSH rule 0 x 306 [0,23,9]
+  CRUSH rule 0 x 307 [44,15,87]
+  CRUSH rule 0 x 308 [91,98,17]
+  CRUSH rule 0 x 309 [38,63,22]
+  CRUSH rule 0 x 310 [26,89,11]
+  CRUSH rule 0 x 311 [36,83,9]
+  CRUSH rule 0 x 312 [33,22,113]
+  CRUSH rule 0 x 313 [104,16,11]
+  CRUSH rule 0 x 314 [28,4,23]
+  CRUSH rule 0 x 315 [16,117,17]
+  CRUSH rule 0 x 316 [4,1,81]
+  CRUSH rule 0 x 317 [118,8,103]
+  CRUSH rule 0 x 318 [17,47,50]
+  CRUSH rule 0 x 319 [24,83,4]
+  CRUSH rule 0 x 320 [36,65,19]
+  CRUSH rule 0 x 321 [26,85,11]
+  CRUSH rule 0 x 322 [87,116,21]
+  CRUSH rule 0 x 323 [73,0,9]
+  CRUSH rule 0 x 324 [21,37,64]
+  CRUSH rule 0 x 325 [52,16,19]
+  CRUSH rule 0 x 326 [111,93,14]
+  CRUSH rule 0 x 327 [62,8,63]
+  CRUSH rule 0 x 328 [7,42,67]
+  CRUSH rule 0 x 329 [93,34,11]
+  CRUSH rule 0 x 330 [24,4,63]
+  CRUSH rule 0 x 331 [41,117,9]
+  CRUSH rule 0 x 332 [61,110,3]
+  CRUSH rule 0 x 333 [16,8,116]
+  CRUSH rule 0 x 334 [3,35,86]
+  CRUSH rule 0 x 335 [71,74,17]
+  CRUSH rule 0 x 336 [16,19,66]
+  CRUSH rule 0 x 337 [37,40,11]
+  CRUSH rule 0 x 338 [109,13,45]
+  CRUSH rule 0 x 339 [37,21,56]
+  CRUSH rule 0 x 340 [119,67,7]
+  CRUSH rule 0 x 341 [63,8,60]
+  CRUSH rule 0 x 342 [92,25,17]
+  CRUSH rule 0 x 343 [49,26,13]
+  CRUSH rule 0 x 344 [103,26,3]
+  CRUSH rule 0 x 345 [56,25,8]
+  CRUSH rule 0 x 346 [3,79,24]
+  CRUSH rule 0 x 347 [106,27,21]
+  CRUSH rule 0 x 348 [10,117,19]
+  CRUSH rule 0 x 349 [96,37,8]
+  CRUSH rule 0 x 350 [63,32,9]
+  CRUSH rule 0 x 351 [60,85,22]
+  CRUSH rule 0 x 352 [103,84,17]
+  CRUSH rule 0 x 353 [49,113,11]
+  CRUSH rule 0 x 354 [55,52,11]
+  CRUSH rule 0 x 355 [73,68,17]
+  CRUSH rule 0 x 356 [114,41,15]
+  CRUSH rule 0 x 357 [14,96,75]
+  CRUSH rule 0 x 358 [97,62,6]
+  CRUSH rule 0 x 359 [4,105,86]
+  CRUSH rule 0 x 360 [106,69,4]
+  CRUSH rule 0 x 361 [27,46,17]
+  CRUSH rule 0 x 362 [28,33,17]
+  CRUSH rule 0 x 363 [45,26,6]
+  CRUSH rule 0 x 364 [23,50,4]
+  CRUSH rule 0 x 365 [24,22,93]
+  CRUSH rule 0 x 366 [14,58,16]
+  CRUSH rule 0 x 367 [103,50,22]
+  CRUSH rule 0 x 368 [103,32,3]
+  CRUSH rule 0 x 369 [37,4,110]
+  CRUSH rule 0 x 370 [11,89,66]
+  CRUSH rule 0 x 371 [34,55,19]
+  CRUSH rule 0 x 372 [58,10,9]
+  CRUSH rule 0 x 373 [98,8,27]
+  CRUSH rule 0 x 374 [110,95,4]
+  CRUSH rule 0 x 375 [19,92,99]
+  CRUSH rule 0 x 376 [22,86,91]
+  CRUSH rule 0 x 377 [98,105,8]
+  CRUSH rule 0 x 378 [67,36,19]
+  CRUSH rule 0 x 379 [77,8,68]
+  CRUSH rule 0 x 380 [69,104,3]
+  CRUSH rule 0 x 381 [55,1,22]
+  CRUSH rule 0 x 382 [26,51,17]
+  CRUSH rule 0 x 383 [48,25,13]
+  CRUSH rule 0 x 384 [15,100,81]
+  CRUSH rule 0 x 385 [82,61,13]
+  CRUSH rule 0 x 386 [108,63,11]
+  CRUSH rule 0 x 387 [70,15,83]
+  CRUSH rule 0 x 388 [5,67,19]
+  CRUSH rule 0 x 389 [14,29,98]
+  CRUSH rule 0 x 390 [68,10,13]
+  CRUSH rule 0 x 391 [113,69,7]
+  CRUSH rule 0 x 392 [72,14,77]
+  CRUSH rule 0 x 393 [115,6,81]
+  CRUSH rule 0 x 394 [38,21,16]
+  CRUSH rule 0 x 395 [0,27,13]
+  CRUSH rule 0 x 396 [59,92,11]
+  CRUSH rule 0 x 397 [87,1,3]
+  CRUSH rule 0 x 398 [44,75,14]
+  CRUSH rule 0 x 399 [9,2,95]
+  CRUSH rule 0 x 400 [101,102,15]
+  CRUSH rule 0 x 401 [79,34,13]
+  CRUSH rule 0 x 402 [107,98,14]
+  CRUSH rule 0 x 403 [23,82,13]
+  CRUSH rule 0 x 404 [76,75,7]
+  CRUSH rule 0 x 405 [10,32,15]
+  CRUSH rule 0 x 406 [38,16,11]
+  CRUSH rule 0 x 407 [70,85,9]
+  CRUSH rule 0 x 408 [55,72,9]
+  CRUSH rule 0 x 409 [102,15,73]
+  CRUSH rule 0 x 410 [59,13,118]
+  CRUSH rule 0 x 411 [34,29,6]
+  CRUSH rule 0 x 412 [108,99,11]
+  CRUSH rule 0 x 413 [54,107,8]
+  CRUSH rule 0 x 414 [70,4,73]
+  CRUSH rule 0 x 415 [107,36,13]
+  CRUSH rule 0 x 416 [79,68,15]
+  CRUSH rule 0 x 417 [8,79,34]
+  CRUSH rule 0 x 418 [51,46,3]
+  CRUSH rule 0 x 419 [117,16,22]
+  CRUSH rule 0 x 420 [109,105,3]
+  CRUSH rule 0 x 421 [114,17,67]
+  CRUSH rule 0 x 422 [109,8,31]
+  CRUSH rule 0 x 423 [59,98,7]
+  CRUSH rule 0 x 424 [71,5,17]
+  CRUSH rule 0 x 425 [101,111,15]
+  CRUSH rule 0 x 426 [47,46,19]
+  CRUSH rule 0 x 427 [86,87,7]
+  CRUSH rule 0 x 428 [68,35,21]
+  CRUSH rule 0 x 429 [76,6,75]
+  CRUSH rule 0 x 430 [9,86,83]
+  CRUSH rule 0 x 431 [105,119,15]
+  CRUSH rule 0 x 432 [46,37,6]
+  CRUSH rule 0 x 433 [6,101,68]
+  CRUSH rule 0 x 434 [64,69,4]
+  CRUSH rule 0 x 435 [16,50,14]
+  CRUSH rule 0 x 436 [89,102,21]
+  CRUSH rule 0 x 437 [29,114,14]
+  CRUSH rule 0 x 438 [105,98,13]
+  CRUSH rule 0 x 439 [29,119,7]
+  CRUSH rule 0 x 440 [38,13,87]
+  CRUSH rule 0 x 441 [112,105,13]
+  CRUSH rule 0 x 442 [55,108,21]
+  CRUSH rule 0 x 443 [44,57,7]
+  CRUSH rule 0 x 444 [11,27,118]
+  CRUSH rule 0 x 445 [19,5,39]
+  CRUSH rule 0 x 446 [40,47,22]
+  CRUSH rule 0 x 447 [100,61,7]
+  CRUSH rule 0 x 448 [7,68,55]
+  CRUSH rule 0 x 449 [67,19,66]
+  CRUSH rule 0 x 450 [117,101,8]
+  CRUSH rule 0 x 451 [93,108,8]
+  CRUSH rule 0 x 452 [70,49,7]
+  CRUSH rule 0 x 453 [82,51,21]
+  CRUSH rule 0 x 454 [53,18,3]
+  CRUSH rule 0 x 455 [91,92,11]
+  CRUSH rule 0 x 456 [17,16,0]
+  CRUSH rule 0 x 457 [113,31,11]
+  CRUSH rule 0 x 458 [119,43,8]
+  CRUSH rule 0 x 459 [25,115,22]
+  CRUSH rule 0 x 460 [11,97,117]
+  CRUSH rule 0 x 461 [21,111,63]
+  CRUSH rule 0 x 462 [25,62,22]
+  CRUSH rule 0 x 463 [6,105,94]
+  CRUSH rule 0 x 464 [19,109,105]
+  CRUSH rule 0 x 465 [29,86,6]
+  CRUSH rule 0 x 466 [66,91,21]
+  CRUSH rule 0 x 467 [27,68,3]
+  CRUSH rule 0 x 468 [97,26,7]
+  CRUSH rule 0 x 469 [98,75,11]
+  CRUSH rule 0 x 470 [50,67,4]
+  CRUSH rule 0 x 471 [40,79,8]
+  CRUSH rule 0 x 472 [74,79,6]
+  CRUSH rule 0 x 473 [95,36,8]
+  CRUSH rule 0 x 474 [51,14,118]
+  CRUSH rule 0 x 475 [3,79,62]
+  CRUSH rule 0 x 476 [110,31,11]
+  CRUSH rule 0 x 477 [25,106,7]
+  CRUSH rule 0 x 478 [19,105,68]
+  CRUSH rule 0 x 479 [70,37,6]
+  CRUSH rule 0 x 480 [62,57,6]
+  CRUSH rule 0 x 481 [26,19,49]
+  CRUSH rule 0 x 482 [84,14,107]
+  CRUSH rule 0 x 483 [36,53,13]
+  CRUSH rule 0 x 484 [37,36,9]
+  CRUSH rule 0 x 485 [84,15,51]
+  CRUSH rule 0 x 486 [92,10,14]
+  CRUSH rule 0 x 487 [106,51,11]
+  CRUSH rule 0 x 488 [42,43,8]
+  CRUSH rule 0 x 489 [76,16,21]
+  CRUSH rule 0 x 490 [68,87,14]
+  CRUSH rule 0 x 491 [80,71,6]
+  CRUSH rule 0 x 492 [21,57,86]
+  CRUSH rule 0 x 493 [99,78,6]
+  CRUSH rule 0 x 494 [4,87,86]
+  CRUSH rule 0 x 495 [40,43,9]
+  CRUSH rule 0 x 496 [13,38,89]
+  CRUSH rule 0 x 497 [102,71,6]
+  CRUSH rule 0 x 498 [68,83,11]
+  CRUSH rule 0 x 499 [22,26,39]
+  CRUSH rule 0 x 500 [50,6,95]
+  CRUSH rule 0 x 501 [60,79,9]
+  CRUSH rule 0 x 502 [11,28,53]
+  CRUSH rule 0 x 503 [117,25,14]
+  CRUSH rule 0 x 504 [90,41,19]
+  CRUSH rule 0 x 505 [91,100,15]
+  CRUSH rule 0 x 506 [82,103,22]
+  CRUSH rule 0 x 507 [6,103,108]
+  CRUSH rule 0 x 508 [34,87,19]
+  CRUSH rule 0 x 509 [88,63,8]
+  CRUSH rule 0 x 510 [11,73,42]
+  CRUSH rule 0 x 511 [72,27,6]
+  CRUSH rule 0 x 512 [118,73,15]
+  CRUSH rule 0 x 513 [22,76,77]
+  CRUSH rule 0 x 514 [82,15,37]
+  CRUSH rule 0 x 515 [27,0,22]
+  CRUSH rule 0 x 516 [66,85,6]
+  CRUSH rule 0 x 517 [83,4,32]
+  CRUSH rule 0 x 518 [18,3,83]
+  CRUSH rule 0 x 519 [67,119,14]
+  CRUSH rule 0 x 520 [15,114,53]
+  CRUSH rule 0 x 521 [63,113,7]
+  CRUSH rule 0 x 522 [4,73,110]
+  CRUSH rule 0 x 523 [36,35,19]
+  CRUSH rule 0 x 524 [33,38,13]
+  CRUSH rule 0 x 525 [63,119,11]
+  CRUSH rule 0 x 526 [83,50,9]
+  CRUSH rule 0 x 527 [37,0,11]
+  CRUSH rule 0 x 528 [108,35,15]
+  CRUSH rule 0 x 529 [107,15,1]
+  CRUSH rule 0 x 530 [49,3,56]
+  CRUSH rule 0 x 531 [27,7,94]
+  CRUSH rule 0 x 532 [68,71,8]
+  CRUSH rule 0 x 533 [5,85,3]
+  CRUSH rule 0 x 534 [97,24,19]
+  CRUSH rule 0 x 535 [48,75,3]
+  CRUSH rule 0 x 536 [3,37,86]
+  CRUSH rule 0 x 537 [116,7,59]
+  CRUSH rule 0 x 538 [85,8,74]
+  CRUSH rule 0 x 539 [10,9,76]
+  CRUSH rule 0 x 540 [100,101,14]
+  CRUSH rule 0 x 541 [111,77,21]
+  CRUSH rule 0 x 542 [50,27,8]
+  CRUSH rule 0 x 543 [45,21,109]
+  CRUSH rule 0 x 544 [106,93,21]
+  CRUSH rule 0 x 545 [43,114,17]
+  CRUSH rule 0 x 546 [108,79,17]
+  CRUSH rule 0 x 547 [27,50,4]
+  CRUSH rule 0 x 548 [53,82,6]
+  CRUSH rule 0 x 549 [60,37,9]
+  CRUSH rule 0 x 550 [47,68,21]
+  CRUSH rule 0 x 551 [14,88,27]
+  CRUSH rule 0 x 552 [70,73,3]
+  CRUSH rule 0 x 553 [96,105,11]
+  CRUSH rule 0 x 554 [61,0,11]
+  CRUSH rule 0 x 555 [76,37,9]
+  CRUSH rule 0 x 556 [106,89,9]
+  CRUSH rule 0 x 557 [39,113,17]
+  CRUSH rule 0 x 558 [70,79,8]
+  CRUSH rule 0 x 559 [106,69,14]
+  CRUSH rule 0 x 560 [94,43,8]
+  CRUSH rule 0 x 561 [27,76,14]
+  CRUSH rule 0 x 562 [97,62,7]
+  CRUSH rule 0 x 563 [64,103,4]
+  CRUSH rule 0 x 564 [96,41,14]
+  CRUSH rule 0 x 565 [66,71,14]
+  CRUSH rule 0 x 566 [27,38,7]
+  CRUSH rule 0 x 567 [88,8,73]
+  CRUSH rule 0 x 568 [17,96,33]
+  CRUSH rule 0 x 569 [102,63,17]
+  CRUSH rule 0 x 570 [7,27,108]
+  CRUSH rule 0 x 571 [95,98,4]
+  CRUSH rule 0 x 572 [62,89,8]
+  CRUSH rule 0 x 573 [51,118,4]
+  CRUSH rule 0 x 574 [89,78,13]
+  CRUSH rule 0 x 575 [19,101,38]
+  CRUSH rule 0 x 576 [112,73,9]
+  CRUSH rule 0 x 577 [8,84,41]
+  CRUSH rule 0 x 578 [64,8,41]
+  CRUSH rule 0 x 579 [78,77,8]
+  CRUSH rule 0 x 580 [68,95,6]
+  CRUSH rule 0 x 581 [55,52,14]
+  CRUSH rule 0 x 582 [27,13,40]
+  CRUSH rule 0 x 583 [74,105,7]
+  CRUSH rule 0 x 584 [72,13,99]
+  CRUSH rule 0 x 585 [88,99,7]
+  CRUSH rule 0 x 586 [33,108,4]
+  CRUSH rule 0 x 587 [106,99,22]
+  CRUSH rule 0 x 588 [0,83,7]
+  CRUSH rule 0 x 589 [7,95,90]
+  CRUSH rule 0 x 590 [59,112,17]
+  CRUSH rule 0 x 591 [42,23,3]
+  CRUSH rule 0 x 592 [45,72,22]
+  CRUSH rule 0 x 593 [89,14,42]
+  CRUSH rule 0 x 594 [27,76,9]
+  CRUSH rule 0 x 595 [7,10,110]
+  CRUSH rule 0 x 596 [82,59,19]
+  CRUSH rule 0 x 597 [72,83,14]
+  CRUSH rule 0 x 598 [34,15,57]
+  CRUSH rule 0 x 599 [119,61,7]
+  CRUSH rule 0 x 600 [9,84,49]
+  CRUSH rule 0 x 601 [104,15,49]
+  CRUSH rule 0 x 602 [48,45,6]
+  CRUSH rule 0 x 603 [24,9,89]
+  CRUSH rule 0 x 604 [89,0,14]
+  CRUSH rule 0 x 605 [104,87,14]
+  CRUSH rule 0 x 606 [49,34,8]
+  CRUSH rule 0 x 607 [95,40,15]
+  CRUSH rule 0 x 608 [49,80,6]
+  CRUSH rule 0 x 609 [61,66,11]
+  CRUSH rule 0 x 610 [106,16,6]
+  CRUSH rule 0 x 611 [66,87,15]
+  CRUSH rule 0 x 612 [103,8,44]
+  CRUSH rule 0 x 613 [84,91,8]
+  CRUSH rule 0 x 614 [81,7,108]
+  CRUSH rule 0 x 615 [61,19,64]
+  CRUSH rule 0 x 616 [41,15,106]
+  CRUSH rule 0 x 617 [111,69,15]
+  CRUSH rule 0 x 618 [3,99,26]
+  CRUSH rule 0 x 619 [92,27,13]
+  CRUSH rule 0 x 620 [108,103,19]
+  CRUSH rule 0 x 621 [106,99,3]
+  CRUSH rule 0 x 622 [67,48,13]
+  CRUSH rule 0 x 623 [94,3,73]
+  CRUSH rule 0 x 624 [115,59,15]
+  CRUSH rule 0 x 625 [111,27,7]
+  CRUSH rule 0 x 626 [3,55,80]
+  CRUSH rule 0 x 627 [19,29,102]
+  CRUSH rule 0 x 628 [65,88,14]
+  CRUSH rule 0 x 629 [119,7,87]
+  CRUSH rule 0 x 630 [109,19,55]
+  CRUSH rule 0 x 631 [48,75,15]
+  CRUSH rule 0 x 632 [81,0,3]
+  CRUSH rule 0 x 633 [65,68,15]
+  CRUSH rule 0 x 634 [87,50,9]
+  CRUSH rule 0 x 635 [107,9,109]
+  CRUSH rule 0 x 636 [23,78,9]
+  CRUSH rule 0 x 637 [102,45,3]
+  CRUSH rule 0 x 638 [43,114,19]
+  CRUSH rule 0 x 639 [31,78,14]
+  CRUSH rule 0 x 640 [113,73,22]
+  CRUSH rule 0 x 641 [45,96,14]
+  CRUSH rule 0 x 642 [47,66,3]
+  CRUSH rule 0 x 643 [64,47,21]
+  CRUSH rule 0 x 644 [31,21,119]
+  CRUSH rule 0 x 645 [76,19,53]
+  CRUSH rule 0 x 646 [37,54,8]
+  CRUSH rule 0 x 647 [58,87,19]
+  CRUSH rule 0 x 648 [31,21,102]
+  CRUSH rule 0 x 649 [88,45,21]
+  CRUSH rule 0 x 650 [116,7,107]
+  CRUSH rule 0 x 651 [97,106,14]
+  CRUSH rule 0 x 652 [57,112,9]
+  CRUSH rule 0 x 653 [38,39,21]
+  CRUSH rule 0 x 654 [49,32,21]
+  CRUSH rule 0 x 655 [89,62,21]
+  CRUSH rule 0 x 656 [0,49,19]
+  CRUSH rule 0 x 657 [47,32,22]
+  CRUSH rule 0 x 658 [75,82,4]
+  CRUSH rule 0 x 659 [26,83,9]
+  CRUSH rule 0 x 660 [65,110,13]
+  CRUSH rule 0 x 661 [91,48,15]
+  CRUSH rule 0 x 662 [111,99,17]
+  CRUSH rule 0 x 663 [88,35,3]
+  CRUSH rule 0 x 664 [59,78,8]
+  CRUSH rule 0 x 665 [78,15,67]
+  CRUSH rule 0 x 666 [112,4,61]
+  CRUSH rule 0 x 667 [97,46,8]
+  CRUSH rule 0 x 668 [97,15,56]
+  CRUSH rule 0 x 669 [85,66,22]
+  CRUSH rule 0 x 670 [41,38,14]
+  CRUSH rule 0 x 671 [116,97,4]
+  CRUSH rule 0 x 672 [44,55,17]
+  CRUSH rule 0 x 673 [83,50,14]
+  CRUSH rule 0 x 674 [59,78,7]
+  CRUSH rule 0 x 675 [88,14,43]
+  CRUSH rule 0 x 676 [62,8,99]
+  CRUSH rule 0 x 677 [88,67,17]
+  CRUSH rule 0 x 678 [98,83,13]
+  CRUSH rule 0 x 679 [70,59,15]
+  CRUSH rule 0 x 680 [55,96,17]
+  CRUSH rule 0 x 681 [53,68,17]
+  CRUSH rule 0 x 682 [27,58,13]
+  CRUSH rule 0 x 683 [57,80,19]
+  CRUSH rule 0 x 684 [98,65,3]
+  CRUSH rule 0 x 685 [106,55,13]
+  CRUSH rule 0 x 686 [86,95,15]
+  CRUSH rule 0 x 687 [49,72,3]
+  CRUSH rule 0 x 688 [16,114,22]
+  CRUSH rule 0 x 689 [6,48,71]
+  CRUSH rule 0 x 690 [43,70,14]
+  CRUSH rule 0 x 691 [34,105,8]
+  CRUSH rule 0 x 692 [40,97,13]
+  CRUSH rule 0 x 693 [29,84,8]
+  CRUSH rule 0 x 694 [6,41,56]
+  CRUSH rule 0 x 695 [31,60,14]
+  CRUSH rule 0 x 696 [36,3,43]
+  CRUSH rule 0 x 697 [96,77,3]
+  CRUSH rule 0 x 698 [61,68,7]
+  CRUSH rule 0 x 699 [47,62,3]
+  CRUSH rule 0 x 700 [0,55,22]
+  CRUSH rule 0 x 701 [42,11,91]
+  CRUSH rule 0 x 702 [0,71,22]
+  CRUSH rule 0 x 703 [92,67,17]
+  CRUSH rule 0 x 704 [10,19,88]
+  CRUSH rule 0 x 705 [105,82,14]
+  CRUSH rule 0 x 706 [74,105,13]
+  CRUSH rule 0 x 707 [0,77,22]
+  CRUSH rule 0 x 708 [84,8,39]
+  CRUSH rule 0 x 709 [114,97,4]
+  CRUSH rule 0 x 710 [94,7,33]
+  CRUSH rule 0 x 711 [68,49,22]
+  CRUSH rule 0 x 712 [34,75,7]
+  CRUSH rule 0 x 713 [29,0,21]
+  CRUSH rule 0 x 714 [81,115,21]
+  CRUSH rule 0 x 715 [71,84,6]
+  CRUSH rule 0 x 716 [40,17,69]
+  CRUSH rule 0 x 717 [61,62,14]
+  CRUSH rule 0 x 718 [40,85,19]
+  CRUSH rule 0 x 719 [59,42,3]
+  CRUSH rule 0 x 720 [69,72,14]
+  CRUSH rule 0 x 721 [62,41,21]
+  CRUSH rule 0 x 722 [115,8,43]
+  CRUSH rule 0 x 723 [117,41,14]
+  CRUSH rule 0 x 724 [45,21,111]
+  CRUSH rule 0 x 725 [53,113,3]
+  CRUSH rule 0 x 726 [84,23,8]
+  CRUSH rule 0 x 727 [109,14,31]
+  CRUSH rule 0 x 728 [76,16,11]
+  CRUSH rule 0 x 729 [108,6,77]
+  CRUSH rule 0 x 730 [28,47,21]
+  CRUSH rule 0 x 731 [78,27,3]
+  CRUSH rule 0 x 732 [55,90,4]
+  CRUSH rule 0 x 733 [84,3,99]
+  CRUSH rule 0 x 734 [27,117,6]
+  CRUSH rule 0 x 735 [83,28,17]
+  CRUSH rule 0 x 736 [70,67,21]
+  CRUSH rule 0 x 737 [117,15,101]
+  CRUSH rule 0 x 738 [118,33,13]
+  CRUSH rule 0 x 739 [87,38,19]
+  CRUSH rule 0 x 740 [29,38,19]
+  CRUSH rule 0 x 741 [96,73,4]
+  CRUSH rule 0 x 742 [106,83,8]
+  CRUSH rule 0 x 743 [105,94,14]
+  CRUSH rule 0 x 744 [23,42,17]
+  CRUSH rule 0 x 745 [28,59,19]
+  CRUSH rule 0 x 746 [18,47,13]
+  CRUSH rule 0 x 747 [65,70,19]
+  CRUSH rule 0 x 748 [48,89,17]
+  CRUSH rule 0 x 749 [102,51,8]
+  CRUSH rule 0 x 750 [50,27,11]
+  CRUSH rule 0 x 751 [36,25,9]
+  CRUSH rule 0 x 752 [69,52,15]
+  CRUSH rule 0 x 753 [9,32,51]
+  CRUSH rule 0 x 754 [9,57,40]
+  CRUSH rule 0 x 755 [98,81,4]
+  CRUSH rule 0 x 756 [113,87,7]
+  CRUSH rule 0 x 757 [47,66,7]
+  CRUSH rule 0 x 758 [57,88,4]
+  CRUSH rule 0 x 759 [74,27,21]
+  CRUSH rule 0 x 760 [53,90,8]
+  CRUSH rule 0 x 761 [78,97,13]
+  CRUSH rule 0 x 762 [87,8,110]
+  CRUSH rule 0 x 763 [13,45,92]
+  CRUSH rule 0 x 764 [106,81,22]
+  CRUSH rule 0 x 765 [109,91,14]
+  CRUSH rule 0 x 766 [76,97,6]
+  CRUSH rule 0 x 767 [41,116,14]
+  CRUSH rule 0 x 768 [13,114,57]
+  CRUSH rule 0 x 769 [91,104,7]
+  CRUSH rule 0 x 770 [105,96,22]
+  CRUSH rule 0 x 771 [10,76,17]
+  CRUSH rule 0 x 772 [8,111,69]
+  CRUSH rule 0 x 773 [116,75,6]
+  CRUSH rule 0 x 774 [100,43,22]
+  CRUSH rule 0 x 775 [15,34,73]
+  CRUSH rule 0 x 776 [69,38,11]
+  CRUSH rule 0 x 777 [76,49,17]
+  CRUSH rule 0 x 778 [38,13,81]
+  CRUSH rule 0 x 779 [46,21,29]
+  CRUSH rule 0 x 780 [63,102,6]
+  CRUSH rule 0 x 781 [19,85,96]
+  CRUSH rule 0 x 782 [117,31,21]
+  CRUSH rule 0 x 783 [60,93,17]
+  CRUSH rule 0 x 784 [82,81,15]
+  CRUSH rule 0 x 785 [27,84,8]
+  CRUSH rule 0 x 786 [41,80,19]
+  CRUSH rule 0 x 787 [13,54,41]
+  CRUSH rule 0 x 788 [4,100,41]
+  CRUSH rule 0 x 789 [50,37,14]
+  CRUSH rule 0 x 790 [58,16,15]
+  CRUSH rule 0 x 791 [96,97,14]
+  CRUSH rule 0 x 792 [45,4,117]
+  CRUSH rule 0 x 793 [6,71,82]
+  CRUSH rule 0 x 794 [14,89,52]
+  CRUSH rule 0 x 795 [51,108,9]
+  CRUSH rule 0 x 796 [114,77,19]
+  CRUSH rule 0 x 797 [79,100,15]
+  CRUSH rule 0 x 798 [42,8,107]
+  CRUSH rule 0 x 799 [48,11,101]
+  CRUSH rule 0 x 800 [91,7,18]
+  CRUSH rule 0 x 801 [2,6,73]
+  CRUSH rule 0 x 802 [116,14,67]
+  CRUSH rule 0 x 803 [37,32,7]
+  CRUSH rule 0 x 804 [6,73,106]
+  CRUSH rule 0 x 805 [96,22,41]
+  CRUSH rule 0 x 806 [67,90,9]
+  CRUSH rule 0 x 807 [47,42,14]
+  CRUSH rule 0 x 808 [76,31,14]
+  CRUSH rule 0 x 809 [27,26,3]
+  CRUSH rule 0 x 810 [119,61,17]
+  CRUSH rule 0 x 811 [75,72,8]
+  CRUSH rule 0 x 812 [25,52,22]
+  CRUSH rule 0 x 813 [64,13,77]
+  CRUSH rule 0 x 814 [110,53,3]
+  CRUSH rule 0 x 815 [84,67,3]
+  CRUSH rule 0 x 816 [25,22,84]
+  CRUSH rule 0 x 817 [40,29,17]
+  CRUSH rule 0 x 818 [34,85,22]
+  CRUSH rule 0 x 819 [88,17,85]
+  CRUSH rule 0 x 820 [104,49,13]
+  CRUSH rule 0 x 821 [58,69,15]
+  CRUSH rule 0 x 822 [29,72,6]
+  CRUSH rule 0 x 823 [100,103,17]
+  CRUSH rule 0 x 824 [102,81,21]
+  CRUSH rule 0 x 825 [47,17,32]
+  CRUSH rule 0 x 826 [45,11,100]
+  CRUSH rule 0 x 827 [101,11,66]
+  CRUSH rule 0 x 828 [60,27,19]
+  CRUSH rule 0 x 829 [45,90,9]
+  CRUSH rule 0 x 830 [51,96,17]
+  CRUSH rule 0 x 831 [6,102,73]
+  CRUSH rule 0 x 832 [57,78,13]
+  CRUSH rule 0 x 833 [34,97,14]
+  CRUSH rule 0 x 834 [90,33,6]
+  CRUSH rule 0 x 835 [55,46,7]
+  CRUSH rule 0 x 836 [38,43,3]
+  CRUSH rule 0 x 837 [51,74,8]
+  CRUSH rule 0 x 838 [6,32,51]
+  CRUSH rule 0 x 839 [106,8,39]
+  CRUSH rule 0 x 840 [33,109,4]
+  CRUSH rule 0 x 841 [110,15,49]
+  CRUSH rule 0 x 842 [66,67,8]
+  CRUSH rule 0 x 843 [62,63,6]
+  CRUSH rule 0 x 844 [74,13,59]
+  CRUSH rule 0 x 845 [74,43,22]
+  CRUSH rule 0 x 846 [98,107,8]
+  CRUSH rule 0 x 847 [10,94,3]
+  CRUSH rule 0 x 848 [89,17,111]
+  CRUSH rule 0 x 849 [42,59,6]
+  CRUSH rule 0 x 850 [40,73,13]
+  CRUSH rule 0 x 851 [65,4,5]
+  CRUSH rule 0 x 852 [31,94,13]
+  CRUSH rule 0 x 853 [49,11,114]
+  CRUSH rule 0 x 854 [83,54,6]
+  CRUSH rule 0 x 855 [2,19,59]
+  CRUSH rule 0 x 856 [6,107,116]
+  CRUSH rule 0 x 857 [15,82,91]
+  CRUSH rule 0 x 858 [10,80,7]
+  CRUSH rule 0 x 859 [14,43,38]
+  CRUSH rule 0 x 860 [114,75,19]
+  CRUSH rule 0 x 861 [1,33,13]
+  CRUSH rule 0 x 862 [22,25,76]
+  CRUSH rule 0 x 863 [79,0,19]
+  CRUSH rule 0 x 864 [68,6,41]
+  CRUSH rule 0 x 865 [25,92,14]
+  CRUSH rule 0 x 866 [18,89,7]
+  CRUSH rule 0 x 867 [53,78,22]
+  CRUSH rule 0 x 868 [81,98,11]
+  CRUSH rule 0 x 869 [111,11,89]
+  CRUSH rule 0 x 870 [73,19,114]
+  CRUSH rule 0 x 871 [25,54,6]
+  CRUSH rule 0 x 872 [39,48,11]
+  CRUSH rule 0 x 873 [92,8,75]
+  CRUSH rule 0 x 874 [96,11,23]
+  CRUSH rule 0 x 875 [115,59,14]
+  CRUSH rule 0 x 876 [98,75,21]
+  CRUSH rule 0 x 877 [73,5,17]
+  CRUSH rule 0 x 878 [64,45,22]
+  CRUSH rule 0 x 879 [15,18,53]
+  CRUSH rule 0 x 880 [56,91,11]
+  CRUSH rule 0 x 881 [109,69,14]
+  CRUSH rule 0 x 882 [60,33,21]
+  CRUSH rule 0 x 883 [93,96,6]
+  CRUSH rule 0 x 884 [67,38,4]
+  CRUSH rule 0 x 885 [31,115,17]
+  CRUSH rule 0 x 886 [2,9,57]
+  CRUSH rule 0 x 887 [5,7,79]
+  CRUSH rule 0 x 888 [16,13,62]
+  CRUSH rule 0 x 889 [27,76,14]
+  CRUSH rule 0 x 890 [48,63,17]
+  CRUSH rule 0 x 891 [86,79,14]
+  CRUSH rule 0 x 892 [64,107,8]
+  CRUSH rule 0 x 893 [118,22,37]
+  CRUSH rule 0 x 894 [16,111,11]
+  CRUSH rule 0 x 895 [40,3,77]
+  CRUSH rule 0 x 896 [97,96,9]
+  CRUSH rule 0 x 897 [107,78,19]
+  CRUSH rule 0 x 898 [10,2,21]
+  CRUSH rule 0 x 899 [75,15,56]
+  CRUSH rule 0 x 900 [102,81,3]
+  CRUSH rule 0 x 901 [66,87,14]
+  CRUSH rule 0 x 902 [102,49,14]
+  CRUSH rule 0 x 903 [5,69,6]
+  CRUSH rule 0 x 904 [50,16,21]
+  CRUSH rule 0 x 905 [99,76,11]
+  CRUSH rule 0 x 906 [75,119,6]
+  CRUSH rule 0 x 907 [47,5,6]
+  CRUSH rule 0 x 908 [96,37,17]
+  CRUSH rule 0 x 909 [94,75,19]
+  CRUSH rule 0 x 910 [88,63,15]
+  CRUSH rule 0 x 911 [102,23,3]
+  CRUSH rule 0 x 912 [91,60,13]
+  CRUSH rule 0 x 913 [29,17,96]
+  CRUSH rule 0 x 914 [84,14,69]
+  CRUSH rule 0 x 915 [70,27,13]
+  CRUSH rule 0 x 916 [32,9,57]
+  CRUSH rule 0 x 917 [43,108,19]
+  CRUSH rule 0 x 918 [91,98,11]
+  CRUSH rule 0 x 919 [13,69,24]
+  CRUSH rule 0 x 920 [18,9,39]
+  CRUSH rule 0 x 921 [104,33,14]
+  CRUSH rule 0 x 922 [33,32,3]
+  CRUSH rule 0 x 923 [28,8,101]
+  CRUSH rule 0 x 924 [69,88,19]
+  CRUSH rule 0 x 925 [71,32,17]
+  CRUSH rule 0 x 926 [64,69,11]
+  CRUSH rule 0 x 927 [99,17,62]
+  CRUSH rule 0 x 928 [13,113,95]
+  CRUSH rule 0 x 929 [117,61,21]
+  CRUSH rule 0 x 930 [31,82,14]
+  CRUSH rule 0 x 931 [83,66,22]
+  CRUSH rule 0 x 932 [60,13,103]
+  CRUSH rule 0 x 933 [63,82,4]
+  CRUSH rule 0 x 934 [68,4,99]
+  CRUSH rule 0 x 935 [31,18,4]
+  CRUSH rule 0 x 936 [65,32,6]
+  CRUSH rule 0 x 937 [110,79,14]
+  CRUSH rule 0 x 938 [29,106,15]
+  CRUSH rule 0 x 939 [77,13,52]
+  CRUSH rule 0 x 940 [76,15,63]
+  CRUSH rule 0 x 941 [66,37,8]
+  CRUSH rule 0 x 942 [83,94,9]
+  CRUSH rule 0 x 943 [32,4,89]
+  CRUSH rule 0 x 944 [113,4,16]
+  CRUSH rule 0 x 945 [71,52,8]
+  CRUSH rule 0 x 946 [37,70,15]
+  CRUSH rule 0 x 947 [107,74,9]
+  CRUSH rule 0 x 948 [55,98,9]
+  CRUSH rule 0 x 949 [11,72,65]
+  CRUSH rule 0 x 950 [96,23,3]
+  CRUSH rule 0 x 951 [40,93,7]
+  CRUSH rule 0 x 952 [93,46,3]
+  CRUSH rule 0 x 953 [55,92,6]
+  CRUSH rule 0 x 954 [84,57,7]
+  CRUSH rule 0 x 955 [31,117,13]
+  CRUSH rule 0 x 956 [72,11,55]
+  CRUSH rule 0 x 957 [3,74,87]
+  CRUSH rule 0 x 958 [23,106,17]
+  CRUSH rule 0 x 959 [42,59,22]
+  CRUSH rule 0 x 960 [113,107,11]
+  CRUSH rule 0 x 961 [116,8,53]
+  CRUSH rule 0 x 962 [13,62,79]
+  CRUSH rule 0 x 963 [0,99,17]
+  CRUSH rule 0 x 964 [59,56,21]
+  CRUSH rule 0 x 965 [47,115,9]
+  CRUSH rule 0 x 966 [88,63,6]
+  CRUSH rule 0 x 967 [71,15,70]
+  CRUSH rule 0 x 968 [73,7,68]
+  CRUSH rule 0 x 969 [53,6,2]
+  CRUSH rule 0 x 970 [111,75,15]
+  CRUSH rule 0 x 971 [87,22,84]
+  CRUSH rule 0 x 972 [5,37,3]
+  CRUSH rule 0 x 973 [113,27,4]
+  CRUSH rule 0 x 974 [49,112,13]
+  CRUSH rule 0 x 975 [83,58,22]
+  CRUSH rule 0 x 976 [81,38,19]
+  CRUSH rule 0 x 977 [95,102,22]
+  CRUSH rule 0 x 978 [35,56,15]
+  CRUSH rule 0 x 979 [98,6,45]
+  CRUSH rule 0 x 980 [52,69,15]
+  CRUSH rule 0 x 981 [89,117,15]
+  CRUSH rule 0 x 982 [1,47,4]
+  CRUSH rule 0 x 983 [34,61,13]
+  CRUSH rule 0 x 984 [78,25,3]
+  CRUSH rule 0 x 985 [99,52,6]
+  CRUSH rule 0 x 986 [4,59,84]
+  CRUSH rule 0 x 987 [78,21,27]
+  CRUSH rule 0 x 988 [79,2,11]
+  CRUSH rule 0 x 989 [87,17,32]
+  CRUSH rule 0 x 990 [47,118,19]
+  CRUSH rule 0 x 991 [61,18,6]
+  CRUSH rule 0 x 992 [83,66,17]
+  CRUSH rule 0 x 993 [74,53,6]
+  CRUSH rule 0 x 994 [74,57,9]
+  CRUSH rule 0 x 995 [100,97,21]
+  CRUSH rule 0 x 996 [41,6,58]
+  CRUSH rule 0 x 997 [89,76,22]
+  CRUSH rule 0 x 998 [92,47,11]
+  CRUSH rule 0 x 999 [117,11,91]
+  CRUSH rule 0 x 1000 [9,119,37]
+  CRUSH rule 0 x 1001 [49,32,7]
+  CRUSH rule 0 x 1002 [99,113,7]
+  CRUSH rule 0 x 1003 [43,18,6]
+  CRUSH rule 0 x 1004 [89,54,14]
+  CRUSH rule 0 x 1005 [105,84,6]
+  CRUSH rule 0 x 1006 [45,111,7]
+  CRUSH rule 0 x 1007 [19,57,5]
+  CRUSH rule 0 x 1008 [31,14,50]
+  CRUSH rule 0 x 1009 [19,111,91]
+  CRUSH rule 0 x 1010 [42,89,13]
+  CRUSH rule 0 x 1011 [25,114,11]
+  CRUSH rule 0 x 1012 [68,71,6]
+  CRUSH rule 0 x 1013 [5,45,3]
+  CRUSH rule 0 x 1014 [33,4,109]
+  CRUSH rule 0 x 1015 [14,45,74]
+  CRUSH rule 0 x 1016 [88,19,105]
+  CRUSH rule 0 x 1017 [0,89,22]
+  CRUSH rule 0 x 1018 [63,5,22]
+  CRUSH rule 0 x 1019 [104,97,4]
+  CRUSH rule 0 x 1020 [96,99,8]
+  CRUSH rule 0 x 1021 [117,41,15]
+  CRUSH rule 0 x 1022 [73,22,36]
+  CRUSH rule 0 x 1023 [0,16,14]
+  rule 0 (data) num_rep 10 result size == 3:\t1024/1024 (esc)
diff --git a/src/test/cli/crushtool/test-map-jewel-tunables.crushmap b/src/test/cli/crushtool/test-map-jewel-tunables.crushmap
new file mode 100644
index 0000000..d4d3f28
Binary files /dev/null and b/src/test/cli/crushtool/test-map-jewel-tunables.crushmap differ
diff --git a/src/test/cli/crushtool/test-map-jewel-tunables.t b/src/test/cli/crushtool/test-map-jewel-tunables.t
new file mode 100644
index 0000000..f0c632b
--- /dev/null
+++ b/src/test/cli/crushtool/test-map-jewel-tunables.t
@@ -0,0 +1,10252 @@
+  $ crushtool -i "$TESTDIR/test-map-jewel-tunables.crushmap" --test --show-mappings --show-statistics --rule 0 --weight 12 0 --weight 20 0 --weight 30 0
+  rule 0 (data), x = 0..1023, numrep = 1..10
+  CRUSH rule 0 x 0 [101]
+  CRUSH rule 0 x 1 [80]
+  CRUSH rule 0 x 2 [91]
+  CRUSH rule 0 x 3 [51]
+  CRUSH rule 0 x 4 [50]
+  CRUSH rule 0 x 5 [89]
+  CRUSH rule 0 x 6 [91]
+  CRUSH rule 0 x 7 [104]
+  CRUSH rule 0 x 8 [78]
+  CRUSH rule 0 x 9 [101]
+  CRUSH rule 0 x 10 [61]
+  CRUSH rule 0 x 11 [13]
+  CRUSH rule 0 x 12 [83]
+  CRUSH rule 0 x 13 [108]
+  CRUSH rule 0 x 14 [105]
+  CRUSH rule 0 x 15 [18]
+  CRUSH rule 0 x 16 [103]
+  CRUSH rule 0 x 17 [85]
+  CRUSH rule 0 x 18 [11]
+  CRUSH rule 0 x 19 [75]
+  CRUSH rule 0 x 20 [79]
+  CRUSH rule 0 x 21 [84]
+  CRUSH rule 0 x 22 [23]
+  CRUSH rule 0 x 23 [118]
+  CRUSH rule 0 x 24 [83]
+  CRUSH rule 0 x 25 [81]
+  CRUSH rule 0 x 26 [38]
+  CRUSH rule 0 x 27 [76]
+  CRUSH rule 0 x 28 [76]
+  CRUSH rule 0 x 29 [8]
+  CRUSH rule 0 x 30 [94]
+  CRUSH rule 0 x 31 [76]
+  CRUSH rule 0 x 32 [72]
+  CRUSH rule 0 x 33 [77]
+  CRUSH rule 0 x 34 [74]
+  CRUSH rule 0 x 35 [22]
+  CRUSH rule 0 x 36 [104]
+  CRUSH rule 0 x 37 [38]
+  CRUSH rule 0 x 38 [72]
+  CRUSH rule 0 x 39 [68]
+  CRUSH rule 0 x 40 [103]
+  CRUSH rule 0 x 41 [85]
+  CRUSH rule 0 x 42 [106]
+  CRUSH rule 0 x 43 [10]
+  CRUSH rule 0 x 44 [101]
+  CRUSH rule 0 x 45 [8]
+  CRUSH rule 0 x 46 [65]
+  CRUSH rule 0 x 47 [106]
+  CRUSH rule 0 x 48 [34]
+  CRUSH rule 0 x 49 [0]
+  CRUSH rule 0 x 50 [42]
+  CRUSH rule 0 x 51 [104]
+  CRUSH rule 0 x 52 [83]
+  CRUSH rule 0 x 53 [32]
+  CRUSH rule 0 x 54 [28]
+  CRUSH rule 0 x 55 [14]
+  CRUSH rule 0 x 56 [21]
+  CRUSH rule 0 x 57 [93]
+  CRUSH rule 0 x 58 [45]
+  CRUSH rule 0 x 59 [80]
+  CRUSH rule 0 x 60 [90]
+  CRUSH rule 0 x 61 [88]
+  CRUSH rule 0 x 62 [81]
+  CRUSH rule 0 x 63 [79]
+  CRUSH rule 0 x 64 [1]
+  CRUSH rule 0 x 65 [13]
+  CRUSH rule 0 x 66 [48]
+  CRUSH rule 0 x 67 [94]
+  CRUSH rule 0 x 68 [102]
+  CRUSH rule 0 x 69 [62]
+  CRUSH rule 0 x 70 [84]
+  CRUSH rule 0 x 71 [55]
+  CRUSH rule 0 x 72 [97]
+  CRUSH rule 0 x 73 [64]
+  CRUSH rule 0 x 74 [96]
+  CRUSH rule 0 x 75 [29]
+  CRUSH rule 0 x 76 [55]
+  CRUSH rule 0 x 77 [107]
+  CRUSH rule 0 x 78 [31]
+  CRUSH rule 0 x 79 [64]
+  CRUSH rule 0 x 80 [0]
+  CRUSH rule 0 x 81 [71]
+  CRUSH rule 0 x 82 [37]
+  CRUSH rule 0 x 83 [92]
+  CRUSH rule 0 x 84 [49]
+  CRUSH rule 0 x 85 [54]
+  CRUSH rule 0 x 86 [37]
+  CRUSH rule 0 x 87 [116]
+  CRUSH rule 0 x 88 [38]
+  CRUSH rule 0 x 89 [76]
+  CRUSH rule 0 x 90 [14]
+  CRUSH rule 0 x 91 [93]
+  CRUSH rule 0 x 92 [86]
+  CRUSH rule 0 x 93 [44]
+  CRUSH rule 0 x 94 [61]
+  CRUSH rule 0 x 95 [93]
+  CRUSH rule 0 x 96 [66]
+  CRUSH rule 0 x 97 [111]
+  CRUSH rule 0 x 98 [66]
+  CRUSH rule 0 x 99 [78]
+  CRUSH rule 0 x 100 [28]
+  CRUSH rule 0 x 101 [84]
+  CRUSH rule 0 x 102 [82]
+  CRUSH rule 0 x 103 [66]
+  CRUSH rule 0 x 104 [14]
+  CRUSH rule 0 x 105 [87]
+  CRUSH rule 0 x 106 [69]
+  CRUSH rule 0 x 107 [1]
+  CRUSH rule 0 x 108 [94]
+  CRUSH rule 0 x 109 [112]
+  CRUSH rule 0 x 110 [54]
+  CRUSH rule 0 x 111 [10]
+  CRUSH rule 0 x 112 [89]
+  CRUSH rule 0 x 113 [69]
+  CRUSH rule 0 x 114 [79]
+  CRUSH rule 0 x 115 [50]
+  CRUSH rule 0 x 116 [96]
+  CRUSH rule 0 x 117 [87]
+  CRUSH rule 0 x 118 [23]
+  CRUSH rule 0 x 119 [104]
+  CRUSH rule 0 x 120 [57]
+  CRUSH rule 0 x 121 [105]
+  CRUSH rule 0 x 122 [45]
+  CRUSH rule 0 x 123 [112]
+  CRUSH rule 0 x 124 [110]
+  CRUSH rule 0 x 125 [66]
+  CRUSH rule 0 x 126 [51]
+  CRUSH rule 0 x 127 [70]
+  CRUSH rule 0 x 128 [90]
+  CRUSH rule 0 x 129 [103]
+  CRUSH rule 0 x 130 [50]
+  CRUSH rule 0 x 131 [23]
+  CRUSH rule 0 x 132 [69]
+  CRUSH rule 0 x 133 [52]
+  CRUSH rule 0 x 134 [78]
+  CRUSH rule 0 x 135 [78]
+  CRUSH rule 0 x 136 [32]
+  CRUSH rule 0 x 137 [92]
+  CRUSH rule 0 x 138 [17]
+  CRUSH rule 0 x 139 [89]
+  CRUSH rule 0 x 140 [39]
+  CRUSH rule 0 x 141 [89]
+  CRUSH rule 0 x 142 [70]
+  CRUSH rule 0 x 143 [51]
+  CRUSH rule 0 x 144 [13]
+  CRUSH rule 0 x 145 [77]
+  CRUSH rule 0 x 146 [96]
+  CRUSH rule 0 x 147 [2]
+  CRUSH rule 0 x 148 [74]
+  CRUSH rule 0 x 149 [76]
+  CRUSH rule 0 x 150 [38]
+  CRUSH rule 0 x 151 [90]
+  CRUSH rule 0 x 152 [49]
+  CRUSH rule 0 x 153 [71]
+  CRUSH rule 0 x 154 [94]
+  CRUSH rule 0 x 155 [75]
+  CRUSH rule 0 x 156 [107]
+  CRUSH rule 0 x 157 [112]
+  CRUSH rule 0 x 158 [26]
+  CRUSH rule 0 x 159 [52]
+  CRUSH rule 0 x 160 [41]
+  CRUSH rule 0 x 161 [84]
+  CRUSH rule 0 x 162 [55]
+  CRUSH rule 0 x 163 [54]
+  CRUSH rule 0 x 164 [45]
+  CRUSH rule 0 x 165 [25]
+  CRUSH rule 0 x 166 [73]
+  CRUSH rule 0 x 167 [89]
+  CRUSH rule 0 x 168 [47]
+  CRUSH rule 0 x 169 [51]
+  CRUSH rule 0 x 170 [68]
+  CRUSH rule 0 x 171 [73]
+  CRUSH rule 0 x 172 [117]
+  CRUSH rule 0 x 173 [13]
+  CRUSH rule 0 x 174 [116]
+  CRUSH rule 0 x 175 [3]
+  CRUSH rule 0 x 176 [94]
+  CRUSH rule 0 x 177 [52]
+  CRUSH rule 0 x 178 [39]
+  CRUSH rule 0 x 179 [72]
+  CRUSH rule 0 x 180 [60]
+  CRUSH rule 0 x 181 [18]
+  CRUSH rule 0 x 182 [22]
+  CRUSH rule 0 x 183 [11]
+  CRUSH rule 0 x 184 [92]
+  CRUSH rule 0 x 185 [97]
+  CRUSH rule 0 x 186 [67]
+  CRUSH rule 0 x 187 [116]
+  CRUSH rule 0 x 188 [69]
+  CRUSH rule 0 x 189 [47]
+  CRUSH rule 0 x 190 [65]
+  CRUSH rule 0 x 191 [49]
+  CRUSH rule 0 x 192 [68]
+  CRUSH rule 0 x 193 [0]
+  CRUSH rule 0 x 194 [62]
+  CRUSH rule 0 x 195 [119]
+  CRUSH rule 0 x 196 [72]
+  CRUSH rule 0 x 197 [106]
+  CRUSH rule 0 x 198 [114]
+  CRUSH rule 0 x 199 [0]
+  CRUSH rule 0 x 200 [35]
+  CRUSH rule 0 x 201 [27]
+  CRUSH rule 0 x 202 [98]
+  CRUSH rule 0 x 203 [36]
+  CRUSH rule 0 x 204 [10]
+  CRUSH rule 0 x 205 [81]
+  CRUSH rule 0 x 206 [49]
+  CRUSH rule 0 x 207 [80]
+  CRUSH rule 0 x 208 [63]
+  CRUSH rule 0 x 209 [85]
+  CRUSH rule 0 x 210 [79]
+  CRUSH rule 0 x 211 [26]
+  CRUSH rule 0 x 212 [28]
+  CRUSH rule 0 x 213 [91]
+  CRUSH rule 0 x 214 [91]
+  CRUSH rule 0 x 215 [61]
+  CRUSH rule 0 x 216 [99]
+  CRUSH rule 0 x 217 [86]
+  CRUSH rule 0 x 218 [70]
+  CRUSH rule 0 x 219 [28]
+  CRUSH rule 0 x 220 [56]
+  CRUSH rule 0 x 221 [0]
+  CRUSH rule 0 x 222 [50]
+  CRUSH rule 0 x 223 [29]
+  CRUSH rule 0 x 224 [52]
+  CRUSH rule 0 x 225 [15]
+  CRUSH rule 0 x 226 [44]
+  CRUSH rule 0 x 227 [42]
+  CRUSH rule 0 x 228 [117]
+  CRUSH rule 0 x 229 [100]
+  CRUSH rule 0 x 230 [41]
+  CRUSH rule 0 x 231 [56]
+  CRUSH rule 0 x 232 [23]
+  CRUSH rule 0 x 233 [88]
+  CRUSH rule 0 x 234 [4]
+  CRUSH rule 0 x 235 [26]
+  CRUSH rule 0 x 236 [32]
+  CRUSH rule 0 x 237 [92]
+  CRUSH rule 0 x 238 [10]
+  CRUSH rule 0 x 239 [15]
+  CRUSH rule 0 x 240 [109]
+  CRUSH rule 0 x 241 [47]
+  CRUSH rule 0 x 242 [24]
+  CRUSH rule 0 x 243 [76]
+  CRUSH rule 0 x 244 [103]
+  CRUSH rule 0 x 245 [27]
+  CRUSH rule 0 x 246 [5]
+  CRUSH rule 0 x 247 [99]
+  CRUSH rule 0 x 248 [8]
+  CRUSH rule 0 x 249 [85]
+  CRUSH rule 0 x 250 [93]
+  CRUSH rule 0 x 251 [28]
+  CRUSH rule 0 x 252 [95]
+  CRUSH rule 0 x 253 [109]
+  CRUSH rule 0 x 254 [80]
+  CRUSH rule 0 x 255 [103]
+  CRUSH rule 0 x 256 [37]
+  CRUSH rule 0 x 257 [69]
+  CRUSH rule 0 x 258 [34]
+  CRUSH rule 0 x 259 [70]
+  CRUSH rule 0 x 260 [98]
+  CRUSH rule 0 x 261 [94]
+  CRUSH rule 0 x 262 [42]
+  CRUSH rule 0 x 263 [65]
+  CRUSH rule 0 x 264 [36]
+  CRUSH rule 0 x 265 [66]
+  CRUSH rule 0 x 266 [75]
+  CRUSH rule 0 x 267 [58]
+  CRUSH rule 0 x 268 [38]
+  CRUSH rule 0 x 269 [86]
+  CRUSH rule 0 x 270 [58]
+  CRUSH rule 0 x 271 [19]
+  CRUSH rule 0 x 272 [73]
+  CRUSH rule 0 x 273 [108]
+  CRUSH rule 0 x 274 [47]
+  CRUSH rule 0 x 275 [92]
+  CRUSH rule 0 x 276 [7]
+  CRUSH rule 0 x 277 [19]
+  CRUSH rule 0 x 278 [116]
+  CRUSH rule 0 x 279 [101]
+  CRUSH rule 0 x 280 [113]
+  CRUSH rule 0 x 281 [14]
+  CRUSH rule 0 x 282 [106]
+  CRUSH rule 0 x 283 [8]
+  CRUSH rule 0 x 284 [10]
+  CRUSH rule 0 x 285 [88]
+  CRUSH rule 0 x 286 [27]
+  CRUSH rule 0 x 287 [84]
+  CRUSH rule 0 x 288 [103]
+  CRUSH rule 0 x 289 [9]
+  CRUSH rule 0 x 290 [115]
+  CRUSH rule 0 x 291 [48]
+  CRUSH rule 0 x 292 [89]
+  CRUSH rule 0 x 293 [27]
+  CRUSH rule 0 x 294 [79]
+  CRUSH rule 0 x 295 [37]
+  CRUSH rule 0 x 296 [56]
+  CRUSH rule 0 x 297 [35]
+  CRUSH rule 0 x 298 [71]
+  CRUSH rule 0 x 299 [116]
+  CRUSH rule 0 x 300 [67]
+  CRUSH rule 0 x 301 [51]
+  CRUSH rule 0 x 302 [78]
+  CRUSH rule 0 x 303 [19]
+  CRUSH rule 0 x 304 [101]
+  CRUSH rule 0 x 305 [81]
+  CRUSH rule 0 x 306 [0]
+  CRUSH rule 0 x 307 [44]
+  CRUSH rule 0 x 308 [91]
+  CRUSH rule 0 x 309 [38]
+  CRUSH rule 0 x 310 [26]
+  CRUSH rule 0 x 311 [36]
+  CRUSH rule 0 x 312 [33]
+  CRUSH rule 0 x 313 [104]
+  CRUSH rule 0 x 314 [28]
+  CRUSH rule 0 x 315 [16]
+  CRUSH rule 0 x 316 [4]
+  CRUSH rule 0 x 317 [118]
+  CRUSH rule 0 x 318 [17]
+  CRUSH rule 0 x 319 [24]
+  CRUSH rule 0 x 320 [36]
+  CRUSH rule 0 x 321 [26]
+  CRUSH rule 0 x 322 [87]
+  CRUSH rule 0 x 323 [73]
+  CRUSH rule 0 x 324 [21]
+  CRUSH rule 0 x 325 [52]
+  CRUSH rule 0 x 326 [111]
+  CRUSH rule 0 x 327 [62]
+  CRUSH rule 0 x 328 [7]
+  CRUSH rule 0 x 329 [93]
+  CRUSH rule 0 x 330 [24]
+  CRUSH rule 0 x 331 [41]
+  CRUSH rule 0 x 332 [61]
+  CRUSH rule 0 x 333 [16]
+  CRUSH rule 0 x 334 [3]
+  CRUSH rule 0 x 335 [71]
+  CRUSH rule 0 x 336 [16]
+  CRUSH rule 0 x 337 [37]
+  CRUSH rule 0 x 338 [109]
+  CRUSH rule 0 x 339 [37]
+  CRUSH rule 0 x 340 [119]
+  CRUSH rule 0 x 341 [63]
+  CRUSH rule 0 x 342 [92]
+  CRUSH rule 0 x 343 [49]
+  CRUSH rule 0 x 344 [103]
+  CRUSH rule 0 x 345 [56]
+  CRUSH rule 0 x 346 [3]
+  CRUSH rule 0 x 347 [106]
+  CRUSH rule 0 x 348 [10]
+  CRUSH rule 0 x 349 [96]
+  CRUSH rule 0 x 350 [63]
+  CRUSH rule 0 x 351 [60]
+  CRUSH rule 0 x 352 [103]
+  CRUSH rule 0 x 353 [49]
+  CRUSH rule 0 x 354 [55]
+  CRUSH rule 0 x 355 [73]
+  CRUSH rule 0 x 356 [114]
+  CRUSH rule 0 x 357 [14]
+  CRUSH rule 0 x 358 [97]
+  CRUSH rule 0 x 359 [4]
+  CRUSH rule 0 x 360 [106]
+  CRUSH rule 0 x 361 [27]
+  CRUSH rule 0 x 362 [28]
+  CRUSH rule 0 x 363 [45]
+  CRUSH rule 0 x 364 [23]
+  CRUSH rule 0 x 365 [24]
+  CRUSH rule 0 x 366 [14]
+  CRUSH rule 0 x 367 [103]
+  CRUSH rule 0 x 368 [103]
+  CRUSH rule 0 x 369 [37]
+  CRUSH rule 0 x 370 [11]
+  CRUSH rule 0 x 371 [34]
+  CRUSH rule 0 x 372 [58]
+  CRUSH rule 0 x 373 [98]
+  CRUSH rule 0 x 374 [110]
+  CRUSH rule 0 x 375 [19]
+  CRUSH rule 0 x 376 [22]
+  CRUSH rule 0 x 377 [98]
+  CRUSH rule 0 x 378 [67]
+  CRUSH rule 0 x 379 [77]
+  CRUSH rule 0 x 380 [69]
+  CRUSH rule 0 x 381 [55]
+  CRUSH rule 0 x 382 [26]
+  CRUSH rule 0 x 383 [48]
+  CRUSH rule 0 x 384 [15]
+  CRUSH rule 0 x 385 [82]
+  CRUSH rule 0 x 386 [108]
+  CRUSH rule 0 x 387 [70]
+  CRUSH rule 0 x 388 [5]
+  CRUSH rule 0 x 389 [14]
+  CRUSH rule 0 x 390 [68]
+  CRUSH rule 0 x 391 [113]
+  CRUSH rule 0 x 392 [72]
+  CRUSH rule 0 x 393 [115]
+  CRUSH rule 0 x 394 [38]
+  CRUSH rule 0 x 395 [0]
+  CRUSH rule 0 x 396 [59]
+  CRUSH rule 0 x 397 [87]
+  CRUSH rule 0 x 398 [44]
+  CRUSH rule 0 x 399 [9]
+  CRUSH rule 0 x 400 [101]
+  CRUSH rule 0 x 401 [79]
+  CRUSH rule 0 x 402 [107]
+  CRUSH rule 0 x 403 [23]
+  CRUSH rule 0 x 404 [76]
+  CRUSH rule 0 x 405 [10]
+  CRUSH rule 0 x 406 [38]
+  CRUSH rule 0 x 407 [70]
+  CRUSH rule 0 x 408 [55]
+  CRUSH rule 0 x 409 [102]
+  CRUSH rule 0 x 410 [59]
+  CRUSH rule 0 x 411 [34]
+  CRUSH rule 0 x 412 [108]
+  CRUSH rule 0 x 413 [54]
+  CRUSH rule 0 x 414 [70]
+  CRUSH rule 0 x 415 [107]
+  CRUSH rule 0 x 416 [79]
+  CRUSH rule 0 x 417 [8]
+  CRUSH rule 0 x 418 [51]
+  CRUSH rule 0 x 419 [117]
+  CRUSH rule 0 x 420 [109]
+  CRUSH rule 0 x 421 [114]
+  CRUSH rule 0 x 422 [109]
+  CRUSH rule 0 x 423 [59]
+  CRUSH rule 0 x 424 [71]
+  CRUSH rule 0 x 425 [101]
+  CRUSH rule 0 x 426 [47]
+  CRUSH rule 0 x 427 [86]
+  CRUSH rule 0 x 428 [68]
+  CRUSH rule 0 x 429 [76]
+  CRUSH rule 0 x 430 [9]
+  CRUSH rule 0 x 431 [105]
+  CRUSH rule 0 x 432 [46]
+  CRUSH rule 0 x 433 [6]
+  CRUSH rule 0 x 434 [64]
+  CRUSH rule 0 x 435 [16]
+  CRUSH rule 0 x 436 [89]
+  CRUSH rule 0 x 437 [29]
+  CRUSH rule 0 x 438 [105]
+  CRUSH rule 0 x 439 [29]
+  CRUSH rule 0 x 440 [38]
+  CRUSH rule 0 x 441 [112]
+  CRUSH rule 0 x 442 [55]
+  CRUSH rule 0 x 443 [44]
+  CRUSH rule 0 x 444 [11]
+  CRUSH rule 0 x 445 [19]
+  CRUSH rule 0 x 446 [40]
+  CRUSH rule 0 x 447 [100]
+  CRUSH rule 0 x 448 [7]
+  CRUSH rule 0 x 449 [67]
+  CRUSH rule 0 x 450 [117]
+  CRUSH rule 0 x 451 [93]
+  CRUSH rule 0 x 452 [70]
+  CRUSH rule 0 x 453 [82]
+  CRUSH rule 0 x 454 [53]
+  CRUSH rule 0 x 455 [91]
+  CRUSH rule 0 x 456 [17]
+  CRUSH rule 0 x 457 [113]
+  CRUSH rule 0 x 458 [119]
+  CRUSH rule 0 x 459 [25]
+  CRUSH rule 0 x 460 [11]
+  CRUSH rule 0 x 461 [21]
+  CRUSH rule 0 x 462 [25]
+  CRUSH rule 0 x 463 [6]
+  CRUSH rule 0 x 464 [19]
+  CRUSH rule 0 x 465 [29]
+  CRUSH rule 0 x 466 [66]
+  CRUSH rule 0 x 467 [27]
+  CRUSH rule 0 x 468 [97]
+  CRUSH rule 0 x 469 [98]
+  CRUSH rule 0 x 470 [50]
+  CRUSH rule 0 x 471 [40]
+  CRUSH rule 0 x 472 [74]
+  CRUSH rule 0 x 473 [95]
+  CRUSH rule 0 x 474 [51]
+  CRUSH rule 0 x 475 [3]
+  CRUSH rule 0 x 476 [110]
+  CRUSH rule 0 x 477 [25]
+  CRUSH rule 0 x 478 [19]
+  CRUSH rule 0 x 479 [70]
+  CRUSH rule 0 x 480 [62]
+  CRUSH rule 0 x 481 [26]
+  CRUSH rule 0 x 482 [84]
+  CRUSH rule 0 x 483 [36]
+  CRUSH rule 0 x 484 [37]
+  CRUSH rule 0 x 485 [84]
+  CRUSH rule 0 x 486 [92]
+  CRUSH rule 0 x 487 [106]
+  CRUSH rule 0 x 488 [42]
+  CRUSH rule 0 x 489 [76]
+  CRUSH rule 0 x 490 [68]
+  CRUSH rule 0 x 491 [80]
+  CRUSH rule 0 x 492 [21]
+  CRUSH rule 0 x 493 [99]
+  CRUSH rule 0 x 494 [4]
+  CRUSH rule 0 x 495 [40]
+  CRUSH rule 0 x 496 [13]
+  CRUSH rule 0 x 497 [102]
+  CRUSH rule 0 x 498 [68]
+  CRUSH rule 0 x 499 [22]
+  CRUSH rule 0 x 500 [50]
+  CRUSH rule 0 x 501 [60]
+  CRUSH rule 0 x 502 [11]
+  CRUSH rule 0 x 503 [117]
+  CRUSH rule 0 x 504 [90]
+  CRUSH rule 0 x 505 [91]
+  CRUSH rule 0 x 506 [82]
+  CRUSH rule 0 x 507 [6]
+  CRUSH rule 0 x 508 [34]
+  CRUSH rule 0 x 509 [88]
+  CRUSH rule 0 x 510 [11]
+  CRUSH rule 0 x 511 [72]
+  CRUSH rule 0 x 512 [118]
+  CRUSH rule 0 x 513 [22]
+  CRUSH rule 0 x 514 [82]
+  CRUSH rule 0 x 515 [27]
+  CRUSH rule 0 x 516 [66]
+  CRUSH rule 0 x 517 [83]
+  CRUSH rule 0 x 518 [18]
+  CRUSH rule 0 x 519 [67]
+  CRUSH rule 0 x 520 [15]
+  CRUSH rule 0 x 521 [63]
+  CRUSH rule 0 x 522 [4]
+  CRUSH rule 0 x 523 [36]
+  CRUSH rule 0 x 524 [33]
+  CRUSH rule 0 x 525 [63]
+  CRUSH rule 0 x 526 [83]
+  CRUSH rule 0 x 527 [37]
+  CRUSH rule 0 x 528 [108]
+  CRUSH rule 0 x 529 [107]
+  CRUSH rule 0 x 530 [49]
+  CRUSH rule 0 x 531 [27]
+  CRUSH rule 0 x 532 [68]
+  CRUSH rule 0 x 533 [5]
+  CRUSH rule 0 x 534 [97]
+  CRUSH rule 0 x 535 [48]
+  CRUSH rule 0 x 536 [3]
+  CRUSH rule 0 x 537 [116]
+  CRUSH rule 0 x 538 [85]
+  CRUSH rule 0 x 539 [10]
+  CRUSH rule 0 x 540 [100]
+  CRUSH rule 0 x 541 [111]
+  CRUSH rule 0 x 542 [50]
+  CRUSH rule 0 x 543 [45]
+  CRUSH rule 0 x 544 [106]
+  CRUSH rule 0 x 545 [43]
+  CRUSH rule 0 x 546 [108]
+  CRUSH rule 0 x 547 [27]
+  CRUSH rule 0 x 548 [53]
+  CRUSH rule 0 x 549 [60]
+  CRUSH rule 0 x 550 [47]
+  CRUSH rule 0 x 551 [14]
+  CRUSH rule 0 x 552 [70]
+  CRUSH rule 0 x 553 [96]
+  CRUSH rule 0 x 554 [61]
+  CRUSH rule 0 x 555 [76]
+  CRUSH rule 0 x 556 [106]
+  CRUSH rule 0 x 557 [39]
+  CRUSH rule 0 x 558 [70]
+  CRUSH rule 0 x 559 [106]
+  CRUSH rule 0 x 560 [94]
+  CRUSH rule 0 x 561 [27]
+  CRUSH rule 0 x 562 [97]
+  CRUSH rule 0 x 563 [64]
+  CRUSH rule 0 x 564 [96]
+  CRUSH rule 0 x 565 [66]
+  CRUSH rule 0 x 566 [27]
+  CRUSH rule 0 x 567 [88]
+  CRUSH rule 0 x 568 [17]
+  CRUSH rule 0 x 569 [102]
+  CRUSH rule 0 x 570 [7]
+  CRUSH rule 0 x 571 [95]
+  CRUSH rule 0 x 572 [62]
+  CRUSH rule 0 x 573 [51]
+  CRUSH rule 0 x 574 [89]
+  CRUSH rule 0 x 575 [19]
+  CRUSH rule 0 x 576 [112]
+  CRUSH rule 0 x 577 [8]
+  CRUSH rule 0 x 578 [64]
+  CRUSH rule 0 x 579 [78]
+  CRUSH rule 0 x 580 [68]
+  CRUSH rule 0 x 581 [55]
+  CRUSH rule 0 x 582 [27]
+  CRUSH rule 0 x 583 [74]
+  CRUSH rule 0 x 584 [72]
+  CRUSH rule 0 x 585 [88]
+  CRUSH rule 0 x 586 [33]
+  CRUSH rule 0 x 587 [106]
+  CRUSH rule 0 x 588 [0]
+  CRUSH rule 0 x 589 [7]
+  CRUSH rule 0 x 590 [59]
+  CRUSH rule 0 x 591 [42]
+  CRUSH rule 0 x 592 [45]
+  CRUSH rule 0 x 593 [89]
+  CRUSH rule 0 x 594 [27]
+  CRUSH rule 0 x 595 [7]
+  CRUSH rule 0 x 596 [82]
+  CRUSH rule 0 x 597 [72]
+  CRUSH rule 0 x 598 [34]
+  CRUSH rule 0 x 599 [119]
+  CRUSH rule 0 x 600 [9]
+  CRUSH rule 0 x 601 [104]
+  CRUSH rule 0 x 602 [48]
+  CRUSH rule 0 x 603 [24]
+  CRUSH rule 0 x 604 [89]
+  CRUSH rule 0 x 605 [104]
+  CRUSH rule 0 x 606 [49]
+  CRUSH rule 0 x 607 [95]
+  CRUSH rule 0 x 608 [49]
+  CRUSH rule 0 x 609 [61]
+  CRUSH rule 0 x 610 [106]
+  CRUSH rule 0 x 611 [66]
+  CRUSH rule 0 x 612 [103]
+  CRUSH rule 0 x 613 [84]
+  CRUSH rule 0 x 614 [81]
+  CRUSH rule 0 x 615 [61]
+  CRUSH rule 0 x 616 [41]
+  CRUSH rule 0 x 617 [111]
+  CRUSH rule 0 x 618 [3]
+  CRUSH rule 0 x 619 [92]
+  CRUSH rule 0 x 620 [108]
+  CRUSH rule 0 x 621 [106]
+  CRUSH rule 0 x 622 [67]
+  CRUSH rule 0 x 623 [94]
+  CRUSH rule 0 x 624 [115]
+  CRUSH rule 0 x 625 [111]
+  CRUSH rule 0 x 626 [3]
+  CRUSH rule 0 x 627 [19]
+  CRUSH rule 0 x 628 [65]
+  CRUSH rule 0 x 629 [119]
+  CRUSH rule 0 x 630 [109]
+  CRUSH rule 0 x 631 [48]
+  CRUSH rule 0 x 632 [81]
+  CRUSH rule 0 x 633 [65]
+  CRUSH rule 0 x 634 [87]
+  CRUSH rule 0 x 635 [107]
+  CRUSH rule 0 x 636 [23]
+  CRUSH rule 0 x 637 [102]
+  CRUSH rule 0 x 638 [43]
+  CRUSH rule 0 x 639 [31]
+  CRUSH rule 0 x 640 [113]
+  CRUSH rule 0 x 641 [45]
+  CRUSH rule 0 x 642 [47]
+  CRUSH rule 0 x 643 [64]
+  CRUSH rule 0 x 644 [31]
+  CRUSH rule 0 x 645 [76]
+  CRUSH rule 0 x 646 [37]
+  CRUSH rule 0 x 647 [58]
+  CRUSH rule 0 x 648 [31]
+  CRUSH rule 0 x 649 [88]
+  CRUSH rule 0 x 650 [116]
+  CRUSH rule 0 x 651 [97]
+  CRUSH rule 0 x 652 [57]
+  CRUSH rule 0 x 653 [38]
+  CRUSH rule 0 x 654 [49]
+  CRUSH rule 0 x 655 [89]
+  CRUSH rule 0 x 656 [0]
+  CRUSH rule 0 x 657 [47]
+  CRUSH rule 0 x 658 [75]
+  CRUSH rule 0 x 659 [26]
+  CRUSH rule 0 x 660 [65]
+  CRUSH rule 0 x 661 [91]
+  CRUSH rule 0 x 662 [111]
+  CRUSH rule 0 x 663 [88]
+  CRUSH rule 0 x 664 [59]
+  CRUSH rule 0 x 665 [78]
+  CRUSH rule 0 x 666 [112]
+  CRUSH rule 0 x 667 [97]
+  CRUSH rule 0 x 668 [97]
+  CRUSH rule 0 x 669 [85]
+  CRUSH rule 0 x 670 [41]
+  CRUSH rule 0 x 671 [116]
+  CRUSH rule 0 x 672 [44]
+  CRUSH rule 0 x 673 [83]
+  CRUSH rule 0 x 674 [59]
+  CRUSH rule 0 x 675 [88]
+  CRUSH rule 0 x 676 [62]
+  CRUSH rule 0 x 677 [88]
+  CRUSH rule 0 x 678 [98]
+  CRUSH rule 0 x 679 [70]
+  CRUSH rule 0 x 680 [55]
+  CRUSH rule 0 x 681 [53]
+  CRUSH rule 0 x 682 [27]
+  CRUSH rule 0 x 683 [57]
+  CRUSH rule 0 x 684 [98]
+  CRUSH rule 0 x 685 [106]
+  CRUSH rule 0 x 686 [86]
+  CRUSH rule 0 x 687 [49]
+  CRUSH rule 0 x 688 [16]
+  CRUSH rule 0 x 689 [6]
+  CRUSH rule 0 x 690 [43]
+  CRUSH rule 0 x 691 [34]
+  CRUSH rule 0 x 692 [40]
+  CRUSH rule 0 x 693 [29]
+  CRUSH rule 0 x 694 [6]
+  CRUSH rule 0 x 695 [31]
+  CRUSH rule 0 x 696 [36]
+  CRUSH rule 0 x 697 [96]
+  CRUSH rule 0 x 698 [61]
+  CRUSH rule 0 x 699 [47]
+  CRUSH rule 0 x 700 [0]
+  CRUSH rule 0 x 701 [42]
+  CRUSH rule 0 x 702 [0]
+  CRUSH rule 0 x 703 [92]
+  CRUSH rule 0 x 704 [10]
+  CRUSH rule 0 x 705 [105]
+  CRUSH rule 0 x 706 [74]
+  CRUSH rule 0 x 707 [0]
+  CRUSH rule 0 x 708 [84]
+  CRUSH rule 0 x 709 [114]
+  CRUSH rule 0 x 710 [94]
+  CRUSH rule 0 x 711 [68]
+  CRUSH rule 0 x 712 [34]
+  CRUSH rule 0 x 713 [29]
+  CRUSH rule 0 x 714 [81]
+  CRUSH rule 0 x 715 [71]
+  CRUSH rule 0 x 716 [40]
+  CRUSH rule 0 x 717 [61]
+  CRUSH rule 0 x 718 [40]
+  CRUSH rule 0 x 719 [59]
+  CRUSH rule 0 x 720 [69]
+  CRUSH rule 0 x 721 [62]
+  CRUSH rule 0 x 722 [115]
+  CRUSH rule 0 x 723 [117]
+  CRUSH rule 0 x 724 [45]
+  CRUSH rule 0 x 725 [53]
+  CRUSH rule 0 x 726 [84]
+  CRUSH rule 0 x 727 [109]
+  CRUSH rule 0 x 728 [76]
+  CRUSH rule 0 x 729 [108]
+  CRUSH rule 0 x 730 [28]
+  CRUSH rule 0 x 731 [78]
+  CRUSH rule 0 x 732 [55]
+  CRUSH rule 0 x 733 [84]
+  CRUSH rule 0 x 734 [27]
+  CRUSH rule 0 x 735 [83]
+  CRUSH rule 0 x 736 [70]
+  CRUSH rule 0 x 737 [117]
+  CRUSH rule 0 x 738 [118]
+  CRUSH rule 0 x 739 [87]
+  CRUSH rule 0 x 740 [29]
+  CRUSH rule 0 x 741 [96]
+  CRUSH rule 0 x 742 [106]
+  CRUSH rule 0 x 743 [105]
+  CRUSH rule 0 x 744 [23]
+  CRUSH rule 0 x 745 [28]
+  CRUSH rule 0 x 746 [18]
+  CRUSH rule 0 x 747 [65]
+  CRUSH rule 0 x 748 [48]
+  CRUSH rule 0 x 749 [102]
+  CRUSH rule 0 x 750 [50]
+  CRUSH rule 0 x 751 [36]
+  CRUSH rule 0 x 752 [69]
+  CRUSH rule 0 x 753 [9]
+  CRUSH rule 0 x 754 [9]
+  CRUSH rule 0 x 755 [98]
+  CRUSH rule 0 x 756 [113]
+  CRUSH rule 0 x 757 [47]
+  CRUSH rule 0 x 758 [57]
+  CRUSH rule 0 x 759 [74]
+  CRUSH rule 0 x 760 [53]
+  CRUSH rule 0 x 761 [78]
+  CRUSH rule 0 x 762 [87]
+  CRUSH rule 0 x 763 [13]
+  CRUSH rule 0 x 764 [106]
+  CRUSH rule 0 x 765 [109]
+  CRUSH rule 0 x 766 [76]
+  CRUSH rule 0 x 767 [41]
+  CRUSH rule 0 x 768 [13]
+  CRUSH rule 0 x 769 [91]
+  CRUSH rule 0 x 770 [105]
+  CRUSH rule 0 x 771 [10]
+  CRUSH rule 0 x 772 [8]
+  CRUSH rule 0 x 773 [116]
+  CRUSH rule 0 x 774 [100]
+  CRUSH rule 0 x 775 [15]
+  CRUSH rule 0 x 776 [69]
+  CRUSH rule 0 x 777 [76]
+  CRUSH rule 0 x 778 [38]
+  CRUSH rule 0 x 779 [46]
+  CRUSH rule 0 x 780 [63]
+  CRUSH rule 0 x 781 [19]
+  CRUSH rule 0 x 782 [117]
+  CRUSH rule 0 x 783 [60]
+  CRUSH rule 0 x 784 [82]
+  CRUSH rule 0 x 785 [27]
+  CRUSH rule 0 x 786 [41]
+  CRUSH rule 0 x 787 [13]
+  CRUSH rule 0 x 788 [4]
+  CRUSH rule 0 x 789 [50]
+  CRUSH rule 0 x 790 [58]
+  CRUSH rule 0 x 791 [96]
+  CRUSH rule 0 x 792 [45]
+  CRUSH rule 0 x 793 [6]
+  CRUSH rule 0 x 794 [14]
+  CRUSH rule 0 x 795 [51]
+  CRUSH rule 0 x 796 [114]
+  CRUSH rule 0 x 797 [79]
+  CRUSH rule 0 x 798 [42]
+  CRUSH rule 0 x 799 [48]
+  CRUSH rule 0 x 800 [91]
+  CRUSH rule 0 x 801 [2]
+  CRUSH rule 0 x 802 [116]
+  CRUSH rule 0 x 803 [37]
+  CRUSH rule 0 x 804 [6]
+  CRUSH rule 0 x 805 [96]
+  CRUSH rule 0 x 806 [67]
+  CRUSH rule 0 x 807 [47]
+  CRUSH rule 0 x 808 [76]
+  CRUSH rule 0 x 809 [27]
+  CRUSH rule 0 x 810 [119]
+  CRUSH rule 0 x 811 [75]
+  CRUSH rule 0 x 812 [25]
+  CRUSH rule 0 x 813 [64]
+  CRUSH rule 0 x 814 [110]
+  CRUSH rule 0 x 815 [84]
+  CRUSH rule 0 x 816 [25]
+  CRUSH rule 0 x 817 [40]
+  CRUSH rule 0 x 818 [34]
+  CRUSH rule 0 x 819 [88]
+  CRUSH rule 0 x 820 [104]
+  CRUSH rule 0 x 821 [58]
+  CRUSH rule 0 x 822 [29]
+  CRUSH rule 0 x 823 [100]
+  CRUSH rule 0 x 824 [102]
+  CRUSH rule 0 x 825 [47]
+  CRUSH rule 0 x 826 [45]
+  CRUSH rule 0 x 827 [101]
+  CRUSH rule 0 x 828 [60]
+  CRUSH rule 0 x 829 [45]
+  CRUSH rule 0 x 830 [51]
+  CRUSH rule 0 x 831 [6]
+  CRUSH rule 0 x 832 [57]
+  CRUSH rule 0 x 833 [34]
+  CRUSH rule 0 x 834 [90]
+  CRUSH rule 0 x 835 [55]
+  CRUSH rule 0 x 836 [38]
+  CRUSH rule 0 x 837 [51]
+  CRUSH rule 0 x 838 [6]
+  CRUSH rule 0 x 839 [106]
+  CRUSH rule 0 x 840 [33]
+  CRUSH rule 0 x 841 [110]
+  CRUSH rule 0 x 842 [66]
+  CRUSH rule 0 x 843 [62]
+  CRUSH rule 0 x 844 [74]
+  CRUSH rule 0 x 845 [74]
+  CRUSH rule 0 x 846 [98]
+  CRUSH rule 0 x 847 [10]
+  CRUSH rule 0 x 848 [89]
+  CRUSH rule 0 x 849 [42]
+  CRUSH rule 0 x 850 [40]
+  CRUSH rule 0 x 851 [65]
+  CRUSH rule 0 x 852 [31]
+  CRUSH rule 0 x 853 [49]
+  CRUSH rule 0 x 854 [83]
+  CRUSH rule 0 x 855 [2]
+  CRUSH rule 0 x 856 [6]
+  CRUSH rule 0 x 857 [15]
+  CRUSH rule 0 x 858 [10]
+  CRUSH rule 0 x 859 [14]
+  CRUSH rule 0 x 860 [114]
+  CRUSH rule 0 x 861 [1]
+  CRUSH rule 0 x 862 [22]
+  CRUSH rule 0 x 863 [79]
+  CRUSH rule 0 x 864 [68]
+  CRUSH rule 0 x 865 [25]
+  CRUSH rule 0 x 866 [18]
+  CRUSH rule 0 x 867 [53]
+  CRUSH rule 0 x 868 [81]
+  CRUSH rule 0 x 869 [111]
+  CRUSH rule 0 x 870 [73]
+  CRUSH rule 0 x 871 [25]
+  CRUSH rule 0 x 872 [39]
+  CRUSH rule 0 x 873 [92]
+  CRUSH rule 0 x 874 [96]
+  CRUSH rule 0 x 875 [115]
+  CRUSH rule 0 x 876 [98]
+  CRUSH rule 0 x 877 [73]
+  CRUSH rule 0 x 878 [64]
+  CRUSH rule 0 x 879 [15]
+  CRUSH rule 0 x 880 [56]
+  CRUSH rule 0 x 881 [109]
+  CRUSH rule 0 x 882 [60]
+  CRUSH rule 0 x 883 [93]
+  CRUSH rule 0 x 884 [67]
+  CRUSH rule 0 x 885 [31]
+  CRUSH rule 0 x 886 [2]
+  CRUSH rule 0 x 887 [5]
+  CRUSH rule 0 x 888 [16]
+  CRUSH rule 0 x 889 [27]
+  CRUSH rule 0 x 890 [48]
+  CRUSH rule 0 x 891 [86]
+  CRUSH rule 0 x 892 [64]
+  CRUSH rule 0 x 893 [118]
+  CRUSH rule 0 x 894 [16]
+  CRUSH rule 0 x 895 [40]
+  CRUSH rule 0 x 896 [97]
+  CRUSH rule 0 x 897 [107]
+  CRUSH rule 0 x 898 [10]
+  CRUSH rule 0 x 899 [75]
+  CRUSH rule 0 x 900 [102]
+  CRUSH rule 0 x 901 [66]
+  CRUSH rule 0 x 902 [102]
+  CRUSH rule 0 x 903 [5]
+  CRUSH rule 0 x 904 [50]
+  CRUSH rule 0 x 905 [99]
+  CRUSH rule 0 x 906 [75]
+  CRUSH rule 0 x 907 [47]
+  CRUSH rule 0 x 908 [96]
+  CRUSH rule 0 x 909 [94]
+  CRUSH rule 0 x 910 [88]
+  CRUSH rule 0 x 911 [102]
+  CRUSH rule 0 x 912 [91]
+  CRUSH rule 0 x 913 [29]
+  CRUSH rule 0 x 914 [84]
+  CRUSH rule 0 x 915 [70]
+  CRUSH rule 0 x 916 [32]
+  CRUSH rule 0 x 917 [43]
+  CRUSH rule 0 x 918 [91]
+  CRUSH rule 0 x 919 [13]
+  CRUSH rule 0 x 920 [18]
+  CRUSH rule 0 x 921 [104]
+  CRUSH rule 0 x 922 [33]
+  CRUSH rule 0 x 923 [28]
+  CRUSH rule 0 x 924 [69]
+  CRUSH rule 0 x 925 [71]
+  CRUSH rule 0 x 926 [64]
+  CRUSH rule 0 x 927 [99]
+  CRUSH rule 0 x 928 [13]
+  CRUSH rule 0 x 929 [117]
+  CRUSH rule 0 x 930 [31]
+  CRUSH rule 0 x 931 [83]
+  CRUSH rule 0 x 932 [60]
+  CRUSH rule 0 x 933 [63]
+  CRUSH rule 0 x 934 [68]
+  CRUSH rule 0 x 935 [31]
+  CRUSH rule 0 x 936 [65]
+  CRUSH rule 0 x 937 [110]
+  CRUSH rule 0 x 938 [29]
+  CRUSH rule 0 x 939 [77]
+  CRUSH rule 0 x 940 [76]
+  CRUSH rule 0 x 941 [66]
+  CRUSH rule 0 x 942 [83]
+  CRUSH rule 0 x 943 [32]
+  CRUSH rule 0 x 944 [113]
+  CRUSH rule 0 x 945 [71]
+  CRUSH rule 0 x 946 [37]
+  CRUSH rule 0 x 947 [107]
+  CRUSH rule 0 x 948 [55]
+  CRUSH rule 0 x 949 [11]
+  CRUSH rule 0 x 950 [96]
+  CRUSH rule 0 x 951 [40]
+  CRUSH rule 0 x 952 [93]
+  CRUSH rule 0 x 953 [55]
+  CRUSH rule 0 x 954 [84]
+  CRUSH rule 0 x 955 [31]
+  CRUSH rule 0 x 956 [72]
+  CRUSH rule 0 x 957 [3]
+  CRUSH rule 0 x 958 [23]
+  CRUSH rule 0 x 959 [42]
+  CRUSH rule 0 x 960 [113]
+  CRUSH rule 0 x 961 [116]
+  CRUSH rule 0 x 962 [13]
+  CRUSH rule 0 x 963 [0]
+  CRUSH rule 0 x 964 [59]
+  CRUSH rule 0 x 965 [47]
+  CRUSH rule 0 x 966 [88]
+  CRUSH rule 0 x 967 [71]
+  CRUSH rule 0 x 968 [73]
+  CRUSH rule 0 x 969 [53]
+  CRUSH rule 0 x 970 [111]
+  CRUSH rule 0 x 971 [87]
+  CRUSH rule 0 x 972 [5]
+  CRUSH rule 0 x 973 [113]
+  CRUSH rule 0 x 974 [49]
+  CRUSH rule 0 x 975 [83]
+  CRUSH rule 0 x 976 [81]
+  CRUSH rule 0 x 977 [95]
+  CRUSH rule 0 x 978 [35]
+  CRUSH rule 0 x 979 [98]
+  CRUSH rule 0 x 980 [52]
+  CRUSH rule 0 x 981 [89]
+  CRUSH rule 0 x 982 [1]
+  CRUSH rule 0 x 983 [34]
+  CRUSH rule 0 x 984 [78]
+  CRUSH rule 0 x 985 [99]
+  CRUSH rule 0 x 986 [4]
+  CRUSH rule 0 x 987 [78]
+  CRUSH rule 0 x 988 [79]
+  CRUSH rule 0 x 989 [87]
+  CRUSH rule 0 x 990 [47]
+  CRUSH rule 0 x 991 [61]
+  CRUSH rule 0 x 992 [83]
+  CRUSH rule 0 x 993 [74]
+  CRUSH rule 0 x 994 [74]
+  CRUSH rule 0 x 995 [100]
+  CRUSH rule 0 x 996 [41]
+  CRUSH rule 0 x 997 [89]
+  CRUSH rule 0 x 998 [92]
+  CRUSH rule 0 x 999 [117]
+  CRUSH rule 0 x 1000 [9]
+  CRUSH rule 0 x 1001 [49]
+  CRUSH rule 0 x 1002 [99]
+  CRUSH rule 0 x 1003 [43]
+  CRUSH rule 0 x 1004 [89]
+  CRUSH rule 0 x 1005 [105]
+  CRUSH rule 0 x 1006 [45]
+  CRUSH rule 0 x 1007 [19]
+  CRUSH rule 0 x 1008 [31]
+  CRUSH rule 0 x 1009 [19]
+  CRUSH rule 0 x 1010 [42]
+  CRUSH rule 0 x 1011 [25]
+  CRUSH rule 0 x 1012 [68]
+  CRUSH rule 0 x 1013 [5]
+  CRUSH rule 0 x 1014 [33]
+  CRUSH rule 0 x 1015 [14]
+  CRUSH rule 0 x 1016 [88]
+  CRUSH rule 0 x 1017 [0]
+  CRUSH rule 0 x 1018 [63]
+  CRUSH rule 0 x 1019 [104]
+  CRUSH rule 0 x 1020 [96]
+  CRUSH rule 0 x 1021 [117]
+  CRUSH rule 0 x 1022 [73]
+  CRUSH rule 0 x 1023 [0]
+  rule 0 (data) num_rep 1 result size == 1:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28]
+  CRUSH rule 0 x 1 [80,13]
+  CRUSH rule 0 x 2 [91,11]
+  CRUSH rule 0 x 3 [51,13]
+  CRUSH rule 0 x 4 [50,101]
+  CRUSH rule 0 x 5 [89,113]
+  CRUSH rule 0 x 6 [91,109]
+  CRUSH rule 0 x 7 [104,51]
+  CRUSH rule 0 x 8 [78,75]
+  CRUSH rule 0 x 9 [101,80]
+  CRUSH rule 0 x 10 [61,4]
+  CRUSH rule 0 x 11 [13,43]
+  CRUSH rule 0 x 12 [83,0]
+  CRUSH rule 0 x 13 [108,22]
+  CRUSH rule 0 x 14 [105,9]
+  CRUSH rule 0 x 15 [18,7]
+  CRUSH rule 0 x 16 [103,4]
+  CRUSH rule 0 x 17 [85,80]
+  CRUSH rule 0 x 18 [11,71]
+  CRUSH rule 0 x 19 [75,114]
+  CRUSH rule 0 x 20 [79,64]
+  CRUSH rule 0 x 21 [84,7]
+  CRUSH rule 0 x 22 [23,66]
+  CRUSH rule 0 x 23 [118,6]
+  CRUSH rule 0 x 24 [83,111]
+  CRUSH rule 0 x 25 [81,116]
+  CRUSH rule 0 x 26 [38,69]
+  CRUSH rule 0 x 27 [76,103]
+  CRUSH rule 0 x 28 [76,103]
+  CRUSH rule 0 x 29 [8,46]
+  CRUSH rule 0 x 30 [94,7]
+  CRUSH rule 0 x 31 [76,35]
+  CRUSH rule 0 x 32 [72,35]
+  CRUSH rule 0 x 33 [77,104]
+  CRUSH rule 0 x 34 [74,67]
+  CRUSH rule 0 x 35 [22,115]
+  CRUSH rule 0 x 36 [104,33]
+  CRUSH rule 0 x 37 [38,57]
+  CRUSH rule 0 x 38 [72,11]
+  CRUSH rule 0 x 39 [68,73]
+  CRUSH rule 0 x 40 [103,76]
+  CRUSH rule 0 x 41 [85,4]
+  CRUSH rule 0 x 42 [106,39]
+  CRUSH rule 0 x 43 [10,115]
+  CRUSH rule 0 x 44 [101,66]
+  CRUSH rule 0 x 45 [8,80]
+  CRUSH rule 0 x 46 [65,66]
+  CRUSH rule 0 x 47 [106,41]
+  CRUSH rule 0 x 48 [34,4]
+  CRUSH rule 0 x 49 [0,27]
+  CRUSH rule 0 x 50 [42,14]
+  CRUSH rule 0 x 51 [104,59]
+  CRUSH rule 0 x 52 [83,14]
+  CRUSH rule 0 x 53 [32,93]
+  CRUSH rule 0 x 54 [28,77]
+  CRUSH rule 0 x 55 [14,94]
+  CRUSH rule 0 x 56 [21,112]
+  CRUSH rule 0 x 57 [93,88]
+  CRUSH rule 0 x 58 [45,1]
+  CRUSH rule 0 x 59 [80,31]
+  CRUSH rule 0 x 60 [90,33]
+  CRUSH rule 0 x 61 [88,39]
+  CRUSH rule 0 x 62 [81,0]
+  CRUSH rule 0 x 63 [79,96]
+  CRUSH rule 0 x 64 [1,8]
+  CRUSH rule 0 x 65 [13,92]
+  CRUSH rule 0 x 66 [48,79]
+  CRUSH rule 0 x 67 [94,91]
+  CRUSH rule 0 x 68 [102,105]
+  CRUSH rule 0 x 69 [62,4]
+  CRUSH rule 0 x 70 [84,27]
+  CRUSH rule 0 x 71 [55,108]
+  CRUSH rule 0 x 72 [97,42]
+  CRUSH rule 0 x 73 [64,81]
+  CRUSH rule 0 x 74 [96,41]
+  CRUSH rule 0 x 75 [29,98]
+  CRUSH rule 0 x 76 [55,111]
+  CRUSH rule 0 x 77 [107,21]
+  CRUSH rule 0 x 78 [31,100]
+  CRUSH rule 0 x 79 [64,75]
+  CRUSH rule 0 x 80 [0,67]
+  CRUSH rule 0 x 81 [71,52]
+  CRUSH rule 0 x 82 [37,0]
+  CRUSH rule 0 x 83 [92,75]
+  CRUSH rule 0 x 84 [49,40]
+  CRUSH rule 0 x 85 [54,71]
+  CRUSH rule 0 x 86 [37,14]
+  CRUSH rule 0 x 87 [116,3]
+  CRUSH rule 0 x 88 [38,95]
+  CRUSH rule 0 x 89 [76,41]
+  CRUSH rule 0 x 90 [14,98]
+  CRUSH rule 0 x 91 [93,114]
+  CRUSH rule 0 x 92 [86,13]
+  CRUSH rule 0 x 93 [44,41]
+  CRUSH rule 0 x 94 [61,18]
+  CRUSH rule 0 x 95 [93,98]
+  CRUSH rule 0 x 96 [66,25]
+  CRUSH rule 0 x 97 [111,4]
+  CRUSH rule 0 x 98 [66,16]
+  CRUSH rule 0 x 99 [78,22]
+  CRUSH rule 0 x 100 [28,4]
+  CRUSH rule 0 x 101 [84,51]
+  CRUSH rule 0 x 102 [82,93]
+  CRUSH rule 0 x 103 [66,4]
+  CRUSH rule 0 x 104 [14,10]
+  CRUSH rule 0 x 105 [87,100]
+  CRUSH rule 0 x 106 [69,66]
+  CRUSH rule 0 x 107 [1,41]
+  CRUSH rule 0 x 108 [94,75]
+  CRUSH rule 0 x 109 [112,87]
+  CRUSH rule 0 x 110 [54,10]
+  CRUSH rule 0 x 111 [10,112]
+  CRUSH rule 0 x 112 [89,11]
+  CRUSH rule 0 x 113 [69,26]
+  CRUSH rule 0 x 114 [79,22]
+  CRUSH rule 0 x 115 [50,65]
+  CRUSH rule 0 x 116 [96,53]
+  CRUSH rule 0 x 117 [87,86]
+  CRUSH rule 0 x 118 [23,106]
+  CRUSH rule 0 x 119 [104,14]
+  CRUSH rule 0 x 120 [57,42]
+  CRUSH rule 0 x 121 [105,50]
+  CRUSH rule 0 x 122 [45,68]
+  CRUSH rule 0 x 123 [112,15]
+  CRUSH rule 0 x 124 [110,19]
+  CRUSH rule 0 x 125 [66,71]
+  CRUSH rule 0 x 126 [51,64]
+  CRUSH rule 0 x 127 [70,13]
+  CRUSH rule 0 x 128 [90,47]
+  CRUSH rule 0 x 129 [103,108]
+  CRUSH rule 0 x 130 [50,17]
+  CRUSH rule 0 x 131 [23,60]
+  CRUSH rule 0 x 132 [69,58]
+  CRUSH rule 0 x 133 [52,85]
+  CRUSH rule 0 x 134 [78,81]
+  CRUSH rule 0 x 135 [78,6]
+  CRUSH rule 0 x 136 [32,83]
+  CRUSH rule 0 x 137 [92,87]
+  CRUSH rule 0 x 138 [17,74]
+  CRUSH rule 0 x 139 [89,92]
+  CRUSH rule 0 x 140 [39,1]
+  CRUSH rule 0 x 141 [89,96]
+  CRUSH rule 0 x 142 [70,73]
+  CRUSH rule 0 x 143 [51,26]
+  CRUSH rule 0 x 144 [13,55]
+  CRUSH rule 0 x 145 [77,100]
+  CRUSH rule 0 x 146 [96,73]
+  CRUSH rule 0 x 147 [2,89]
+  CRUSH rule 0 x 148 [74,91]
+  CRUSH rule 0 x 149 [76,19]
+  CRUSH rule 0 x 150 [38,105]
+  CRUSH rule 0 x 151 [90,85]
+  CRUSH rule 0 x 152 [49,84]
+  CRUSH rule 0 x 153 [71,42]
+  CRUSH rule 0 x 154 [94,23]
+  CRUSH rule 0 x 155 [75,119]
+  CRUSH rule 0 x 156 [107,18]
+  CRUSH rule 0 x 157 [112,57]
+  CRUSH rule 0 x 158 [26,3]
+  CRUSH rule 0 x 159 [52,17]
+  CRUSH rule 0 x 160 [41,119]
+  CRUSH rule 0 x 161 [84,51]
+  CRUSH rule 0 x 162 [55,2]
+  CRUSH rule 0 x 163 [54,21]
+  CRUSH rule 0 x 164 [45,44]
+  CRUSH rule 0 x 165 [25,116]
+  CRUSH rule 0 x 166 [73,38]
+  CRUSH rule 0 x 167 [89,119]
+  CRUSH rule 0 x 168 [47,90]
+  CRUSH rule 0 x 169 [51,22]
+  CRUSH rule 0 x 170 [68,53]
+  CRUSH rule 0 x 171 [73,28]
+  CRUSH rule 0 x 172 [117,23]
+  CRUSH rule 0 x 173 [13,40]
+  CRUSH rule 0 x 174 [116,85]
+  CRUSH rule 0 x 175 [3,85]
+  CRUSH rule 0 x 176 [94,83]
+  CRUSH rule 0 x 177 [52,29]
+  CRUSH rule 0 x 178 [39,42]
+  CRUSH rule 0 x 179 [72,89]
+  CRUSH rule 0 x 180 [60,67]
+  CRUSH rule 0 x 181 [18,16]
+  CRUSH rule 0 x 182 [22,5]
+  CRUSH rule 0 x 183 [11,110]
+  CRUSH rule 0 x 184 [92,15]
+  CRUSH rule 0 x 185 [97,117]
+  CRUSH rule 0 x 186 [67,96]
+  CRUSH rule 0 x 187 [116,14]
+  CRUSH rule 0 x 188 [69,54]
+  CRUSH rule 0 x 189 [47,113]
+  CRUSH rule 0 x 190 [65,90]
+  CRUSH rule 0 x 191 [49,113]
+  CRUSH rule 0 x 192 [68,93]
+  CRUSH rule 0 x 193 [0,37]
+  CRUSH rule 0 x 194 [62,63]
+  CRUSH rule 0 x 195 [119,11]
+  CRUSH rule 0 x 196 [72,59]
+  CRUSH rule 0 x 197 [106,49]
+  CRUSH rule 0 x 198 [114,21]
+  CRUSH rule 0 x 199 [0,99]
+  CRUSH rule 0 x 200 [35,102]
+  CRUSH rule 0 x 201 [27,104]
+  CRUSH rule 0 x 202 [98,59]
+  CRUSH rule 0 x 203 [36,91]
+  CRUSH rule 0 x 204 [10,113]
+  CRUSH rule 0 x 205 [81,22]
+  CRUSH rule 0 x 206 [49,92]
+  CRUSH rule 0 x 207 [80,19]
+  CRUSH rule 0 x 208 [63,92]
+  CRUSH rule 0 x 209 [85,78]
+  CRUSH rule 0 x 210 [79,76]
+  CRUSH rule 0 x 211 [26,89]
+  CRUSH rule 0 x 212 [28,33]
+  CRUSH rule 0 x 213 [91,102]
+  CRUSH rule 0 x 214 [91,118]
+  CRUSH rule 0 x 215 [61,58]
+  CRUSH rule 0 x 216 [99,108]
+  CRUSH rule 0 x 217 [86,97]
+  CRUSH rule 0 x 218 [70,15]
+  CRUSH rule 0 x 219 [28,91]
+  CRUSH rule 0 x 220 [56,9]
+  CRUSH rule 0 x 221 [0,21]
+  CRUSH rule 0 x 222 [50,65]
+  CRUSH rule 0 x 223 [29,46]
+  CRUSH rule 0 x 224 [52,71]
+  CRUSH rule 0 x 225 [15,87]
+  CRUSH rule 0 x 226 [44,13]
+  CRUSH rule 0 x 227 [42,21]
+  CRUSH rule 0 x 228 [117,55]
+  CRUSH rule 0 x 229 [100,67]
+  CRUSH rule 0 x 230 [41,52]
+  CRUSH rule 0 x 231 [56,61]
+  CRUSH rule 0 x 232 [23,11]
+  CRUSH rule 0 x 233 [88,35]
+  CRUSH rule 0 x 234 [4,55]
+  CRUSH rule 0 x 235 [26,16]
+  CRUSH rule 0 x 236 [32,39]
+  CRUSH rule 0 x 237 [92,4]
+  CRUSH rule 0 x 238 [10,117]
+  CRUSH rule 0 x 239 [15,10]
+  CRUSH rule 0 x 240 [109,3]
+  CRUSH rule 0 x 241 [47,44]
+  CRUSH rule 0 x 242 [24,61]
+  CRUSH rule 0 x 243 [76,9]
+  CRUSH rule 0 x 244 [103,17]
+  CRUSH rule 0 x 245 [27,34]
+  CRUSH rule 0 x 246 [5,35]
+  CRUSH rule 0 x 247 [99,38]
+  CRUSH rule 0 x 248 [8,45]
+  CRUSH rule 0 x 249 [85,38]
+  CRUSH rule 0 x 250 [93,78]
+  CRUSH rule 0 x 251 [28,41]
+  CRUSH rule 0 x 252 [95,3]
+  CRUSH rule 0 x 253 [109,97]
+  CRUSH rule 0 x 254 [80,11]
+  CRUSH rule 0 x 255 [103,22]
+  CRUSH rule 0 x 256 [37,82]
+  CRUSH rule 0 x 257 [69,104]
+  CRUSH rule 0 x 258 [34,63]
+  CRUSH rule 0 x 259 [70,9]
+  CRUSH rule 0 x 260 [98,43]
+  CRUSH rule 0 x 261 [94,77]
+  CRUSH rule 0 x 262 [42,45]
+  CRUSH rule 0 x 263 [65,68]
+  CRUSH rule 0 x 264 [36,45]
+  CRUSH rule 0 x 265 [66,97]
+  CRUSH rule 0 x 266 [75,64]
+  CRUSH rule 0 x 267 [58,39]
+  CRUSH rule 0 x 268 [38,3]
+  CRUSH rule 0 x 269 [86,91]
+  CRUSH rule 0 x 270 [58,43]
+  CRUSH rule 0 x 271 [19,43]
+  CRUSH rule 0 x 272 [73,8]
+  CRUSH rule 0 x 273 [108,16]
+  CRUSH rule 0 x 274 [47,88]
+  CRUSH rule 0 x 275 [92,21]
+  CRUSH rule 0 x 276 [7,57]
+  CRUSH rule 0 x 277 [19,117]
+  CRUSH rule 0 x 278 [116,63]
+  CRUSH rule 0 x 279 [101,102]
+  CRUSH rule 0 x 280 [113,75]
+  CRUSH rule 0 x 281 [14,97]
+  CRUSH rule 0 x 282 [106,53]
+  CRUSH rule 0 x 283 [8,36]
+  CRUSH rule 0 x 284 [10,32]
+  CRUSH rule 0 x 285 [88,63]
+  CRUSH rule 0 x 286 [27,6]
+  CRUSH rule 0 x 287 [84,101]
+  CRUSH rule 0 x 288 [103,22]
+  CRUSH rule 0 x 289 [9,26]
+  CRUSH rule 0 x 290 [115,9]
+  CRUSH rule 0 x 291 [48,47]
+  CRUSH rule 0 x 292 [89,108]
+  CRUSH rule 0 x 293 [27,118]
+  CRUSH rule 0 x 294 [79,111]
+  CRUSH rule 0 x 295 [37,18]
+  CRUSH rule 0 x 296 [56,27]
+  CRUSH rule 0 x 297 [35,28]
+  CRUSH rule 0 x 298 [71,2]
+  CRUSH rule 0 x 299 [116,85]
+  CRUSH rule 0 x 300 [67,26]
+  CRUSH rule 0 x 301 [51,32]
+  CRUSH rule 0 x 302 [78,105]
+  CRUSH rule 0 x 303 [19,82]
+  CRUSH rule 0 x 304 [101,50]
+  CRUSH rule 0 x 305 [81,68]
+  CRUSH rule 0 x 306 [0,97]
+  CRUSH rule 0 x 307 [44,21]
+  CRUSH rule 0 x 308 [91,2]
+  CRUSH rule 0 x 309 [38,39]
+  CRUSH rule 0 x 310 [26,15]
+  CRUSH rule 0 x 311 [36,75]
+  CRUSH rule 0 x 312 [33,15]
+  CRUSH rule 0 x 313 [104,65]
+  CRUSH rule 0 x 314 [28,9]
+  CRUSH rule 0 x 315 [16,72]
+  CRUSH rule 0 x 316 [4,76]
+  CRUSH rule 0 x 317 [118,13]
+  CRUSH rule 0 x 318 [17,77]
+  CRUSH rule 0 x 319 [24,93]
+  CRUSH rule 0 x 320 [36,41]
+  CRUSH rule 0 x 321 [26,81]
+  CRUSH rule 0 x 322 [87,24]
+  CRUSH rule 0 x 323 [73,76]
+  CRUSH rule 0 x 324 [21,75]
+  CRUSH rule 0 x 325 [52,43]
+  CRUSH rule 0 x 326 [111,105]
+  CRUSH rule 0 x 327 [62,17]
+  CRUSH rule 0 x 328 [7,0]
+  CRUSH rule 0 x 329 [93,14]
+  CRUSH rule 0 x 330 [24,15]
+  CRUSH rule 0 x 331 [41,109]
+  CRUSH rule 0 x 332 [61,111]
+  CRUSH rule 0 x 333 [16,6]
+  CRUSH rule 0 x 334 [3,29]
+  CRUSH rule 0 x 335 [71,66]
+  CRUSH rule 0 x 336 [16,11]
+  CRUSH rule 0 x 337 [37,113]
+  CRUSH rule 0 x 338 [109,6]
+  CRUSH rule 0 x 339 [37,22]
+  CRUSH rule 0 x 340 [119,101]
+  CRUSH rule 0 x 341 [63,14]
+  CRUSH rule 0 x 342 [92,71]
+  CRUSH rule 0 x 343 [49,56]
+  CRUSH rule 0 x 344 [103,113]
+  CRUSH rule 0 x 345 [56,35]
+  CRUSH rule 0 x 346 [3,25]
+  CRUSH rule 0 x 347 [106,85]
+  CRUSH rule 0 x 348 [10,114]
+  CRUSH rule 0 x 349 [96,103]
+  CRUSH rule 0 x 350 [63,32]
+  CRUSH rule 0 x 351 [60,73]
+  CRUSH rule 0 x 352 [103,68]
+  CRUSH rule 0 x 353 [49,113]
+  CRUSH rule 0 x 354 [55,74]
+  CRUSH rule 0 x 355 [73,80]
+  CRUSH rule 0 x 356 [114,65]
+  CRUSH rule 0 x 357 [14,110]
+  CRUSH rule 0 x 358 [97,56]
+  CRUSH rule 0 x 359 [4,89]
+  CRUSH rule 0 x 360 [106,31]
+  CRUSH rule 0 x 361 [27,56]
+  CRUSH rule 0 x 362 [28,55]
+  CRUSH rule 0 x 363 [45,60]
+  CRUSH rule 0 x 364 [23,2]
+  CRUSH rule 0 x 365 [24,21]
+  CRUSH rule 0 x 366 [14,100]
+  CRUSH rule 0 x 367 [103,82]
+  CRUSH rule 0 x 368 [103,17]
+  CRUSH rule 0 x 369 [37,11]
+  CRUSH rule 0 x 370 [11,65]
+  CRUSH rule 0 x 371 [34,65]
+  CRUSH rule 0 x 372 [58,23]
+  CRUSH rule 0 x 373 [98,22]
+  CRUSH rule 0 x 374 [110,89]
+  CRUSH rule 0 x 375 [19,76]
+  CRUSH rule 0 x 376 [22,98]
+  CRUSH rule 0 x 377 [98,87]
+  CRUSH rule 0 x 378 [67,58]
+  CRUSH rule 0 x 379 [77,94]
+  CRUSH rule 0 x 380 [69,108]
+  CRUSH rule 0 x 381 [55,106]
+  CRUSH rule 0 x 382 [26,83]
+  CRUSH rule 0 x 383 [48,93]
+  CRUSH rule 0 x 384 [15,0]
+  CRUSH rule 0 x 385 [82,27]
+  CRUSH rule 0 x 386 [108,25]
+  CRUSH rule 0 x 387 [70,14]
+  CRUSH rule 0 x 388 [5,37]
+  CRUSH rule 0 x 389 [14,67]
+  CRUSH rule 0 x 390 [68,77]
+  CRUSH rule 0 x 391 [113,105]
+  CRUSH rule 0 x 392 [72,13]
+  CRUSH rule 0 x 393 [115,21]
+  CRUSH rule 0 x 394 [38,17]
+  CRUSH rule 0 x 395 [0,65]
+  CRUSH rule 0 x 396 [59,116]
+  CRUSH rule 0 x 397 [87,90]
+  CRUSH rule 0 x 398 [44,51]
+  CRUSH rule 0 x 399 [9,113]
+  CRUSH rule 0 x 400 [101,100]
+  CRUSH rule 0 x 401 [79,52]
+  CRUSH rule 0 x 402 [107,110]
+  CRUSH rule 0 x 403 [23,92]
+  CRUSH rule 0 x 404 [76,31]
+  CRUSH rule 0 x 405 [10,48]
+  CRUSH rule 0 x 406 [38,29]
+  CRUSH rule 0 x 407 [70,25]
+  CRUSH rule 0 x 408 [55,104]
+  CRUSH rule 0 x 409 [102,6]
+  CRUSH rule 0 x 410 [59,8]
+  CRUSH rule 0 x 411 [34,49]
+  CRUSH rule 0 x 412 [108,105]
+  CRUSH rule 0 x 413 [54,37]
+  CRUSH rule 0 x 414 [70,3]
+  CRUSH rule 0 x 415 [107,0]
+  CRUSH rule 0 x 416 [79,24]
+  CRUSH rule 0 x 417 [8,23]
+  CRUSH rule 0 x 418 [51,114]
+  CRUSH rule 0 x 419 [117,55]
+  CRUSH rule 0 x 420 [109,71]
+  CRUSH rule 0 x 421 [114,17]
+  CRUSH rule 0 x 422 [109,14]
+  CRUSH rule 0 x 423 [59,0]
+  CRUSH rule 0 x 424 [71,84]
+  CRUSH rule 0 x 425 [101,50]
+  CRUSH rule 0 x 426 [47,88]
+  CRUSH rule 0 x 427 [86,45]
+  CRUSH rule 0 x 428 [68,31]
+  CRUSH rule 0 x 429 [76,13]
+  CRUSH rule 0 x 430 [9,117]
+  CRUSH rule 0 x 431 [105,66]
+  CRUSH rule 0 x 432 [46,91]
+  CRUSH rule 0 x 433 [6,77]
+  CRUSH rule 0 x 434 [64,59]
+  CRUSH rule 0 x 435 [16,2]
+  CRUSH rule 0 x 436 [89,102]
+  CRUSH rule 0 x 437 [29,78]
+  CRUSH rule 0 x 438 [105,56]
+  CRUSH rule 0 x 439 [29,68]
+  CRUSH rule 0 x 440 [38,7]
+  CRUSH rule 0 x 441 [112,57]
+  CRUSH rule 0 x 442 [55,18]
+  CRUSH rule 0 x 443 [44,37]
+  CRUSH rule 0 x 444 [11,49]
+  CRUSH rule 0 x 445 [19,114]
+  CRUSH rule 0 x 446 [40,43]
+  CRUSH rule 0 x 447 [100,43]
+  CRUSH rule 0 x 448 [7,26]
+  CRUSH rule 0 x 449 [67,13]
+  CRUSH rule 0 x 450 [117,97]
+  CRUSH rule 0 x 451 [93,118]
+  CRUSH rule 0 x 452 [70,37]
+  CRUSH rule 0 x 453 [82,55]
+  CRUSH rule 0 x 454 [53,28]
+  CRUSH rule 0 x 455 [91,34]
+  CRUSH rule 0 x 456 [17,55]
+  CRUSH rule 0 x 457 [113,103]
+  CRUSH rule 0 x 458 [119,41]
+  CRUSH rule 0 x 459 [25,104]
+  CRUSH rule 0 x 460 [11,55]
+  CRUSH rule 0 x 461 [21,5]
+  CRUSH rule 0 x 462 [25,72]
+  CRUSH rule 0 x 463 [6,57]
+  CRUSH rule 0 x 464 [19,50]
+  CRUSH rule 0 x 465 [29,7]
+  CRUSH rule 0 x 466 [66,89]
+  CRUSH rule 0 x 467 [27,32]
+  CRUSH rule 0 x 468 [97,118]
+  CRUSH rule 0 x 469 [98,71]
+  CRUSH rule 0 x 470 [50,29]
+  CRUSH rule 0 x 471 [40,31]
+  CRUSH rule 0 x 472 [74,61]
+  CRUSH rule 0 x 473 [95,98]
+  CRUSH rule 0 x 474 [51,8]
+  CRUSH rule 0 x 475 [3,25]
+  CRUSH rule 0 x 476 [110,55]
+  CRUSH rule 0 x 477 [25,74]
+  CRUSH rule 0 x 478 [19,57]
+  CRUSH rule 0 x 479 [70,91]
+  CRUSH rule 0 x 480 [62,33]
+  CRUSH rule 0 x 481 [26,3]
+  CRUSH rule 0 x 482 [84,6]
+  CRUSH rule 0 x 483 [36,55]
+  CRUSH rule 0 x 484 [37,28]
+  CRUSH rule 0 x 485 [84,14]
+  CRUSH rule 0 x 486 [92,61]
+  CRUSH rule 0 x 487 [106,53]
+  CRUSH rule 0 x 488 [42,7]
+  CRUSH rule 0 x 489 [76,31]
+  CRUSH rule 0 x 490 [68,107]
+  CRUSH rule 0 x 491 [80,57]
+  CRUSH rule 0 x 492 [21,71]
+  CRUSH rule 0 x 493 [99,44]
+  CRUSH rule 0 x 494 [4,59]
+  CRUSH rule 0 x 495 [40,87]
+  CRUSH rule 0 x 496 [13,106]
+  CRUSH rule 0 x 497 [102,81]
+  CRUSH rule 0 x 498 [68,73]
+  CRUSH rule 0 x 499 [22,28]
+  CRUSH rule 0 x 500 [50,6]
+  CRUSH rule 0 x 501 [60,103]
+  CRUSH rule 0 x 502 [11,1]
+  CRUSH rule 0 x 503 [117,85]
+  CRUSH rule 0 x 504 [90,55]
+  CRUSH rule 0 x 505 [91,94]
+  CRUSH rule 0 x 506 [82,89]
+  CRUSH rule 0 x 507 [6,77]
+  CRUSH rule 0 x 508 [34,77]
+  CRUSH rule 0 x 509 [88,43]
+  CRUSH rule 0 x 510 [11,69]
+  CRUSH rule 0 x 511 [72,47]
+  CRUSH rule 0 x 512 [118,101]
+  CRUSH rule 0 x 513 [22,80]
+  CRUSH rule 0 x 514 [82,21]
+  CRUSH rule 0 x 515 [27,38]
+  CRUSH rule 0 x 516 [66,61]
+  CRUSH rule 0 x 517 [83,4]
+  CRUSH rule 0 x 518 [18,13]
+  CRUSH rule 0 x 519 [67,52]
+  CRUSH rule 0 x 520 [15,88]
+  CRUSH rule 0 x 521 [63,62]
+  CRUSH rule 0 x 522 [4,51]
+  CRUSH rule 0 x 523 [36,23]
+  CRUSH rule 0 x 524 [33,94]
+  CRUSH rule 0 x 525 [63,104]
+  CRUSH rule 0 x 526 [83,118]
+  CRUSH rule 0 x 527 [37,5]
+  CRUSH rule 0 x 528 [108,43]
+  CRUSH rule 0 x 529 [107,7]
+  CRUSH rule 0 x 530 [49,11]
+  CRUSH rule 0 x 531 [27,82]
+  CRUSH rule 0 x 532 [68,89]
+  CRUSH rule 0 x 533 [5,73]
+  CRUSH rule 0 x 534 [97,104]
+  CRUSH rule 0 x 535 [48,41]
+  CRUSH rule 0 x 536 [3,71]
+  CRUSH rule 0 x 537 [116,7]
+  CRUSH rule 0 x 538 [85,3]
+  CRUSH rule 0 x 539 [10,82]
+  CRUSH rule 0 x 540 [100,31]
+  CRUSH rule 0 x 541 [111,67]
+  CRUSH rule 0 x 542 [50,103]
+  CRUSH rule 0 x 543 [45,21]
+  CRUSH rule 0 x 544 [106,67]
+  CRUSH rule 0 x 545 [43,86]
+  CRUSH rule 0 x 546 [108,49]
+  CRUSH rule 0 x 547 [27,18]
+  CRUSH rule 0 x 548 [53,66]
+  CRUSH rule 0 x 549 [60,89]
+  CRUSH rule 0 x 550 [47,62]
+  CRUSH rule 0 x 551 [14,52]
+  CRUSH rule 0 x 552 [70,10]
+  CRUSH rule 0 x 553 [96,73]
+  CRUSH rule 0 x 554 [61,70]
+  CRUSH rule 0 x 555 [76,69]
+  CRUSH rule 0 x 556 [106,10]
+  CRUSH rule 0 x 557 [39,58]
+  CRUSH rule 0 x 558 [70,93]
+  CRUSH rule 0 x 559 [106,23]
+  CRUSH rule 0 x 560 [94,16]
+  CRUSH rule 0 x 561 [27,68]
+  CRUSH rule 0 x 562 [97,112]
+  CRUSH rule 0 x 563 [64,61]
+  CRUSH rule 0 x 564 [96,59]
+  CRUSH rule 0 x 565 [66,69]
+  CRUSH rule 0 x 566 [27,86]
+  CRUSH rule 0 x 567 [88,4]
+  CRUSH rule 0 x 568 [17,96]
+  CRUSH rule 0 x 569 [102,29]
+  CRUSH rule 0 x 570 [7,103]
+  CRUSH rule 0 x 571 [95,110]
+  CRUSH rule 0 x 572 [62,33]
+  CRUSH rule 0 x 573 [51,46]
+  CRUSH rule 0 x 574 [89,64]
+  CRUSH rule 0 x 575 [19,53]
+  CRUSH rule 0 x 576 [112,87]
+  CRUSH rule 0 x 577 [8,113]
+  CRUSH rule 0 x 578 [64,3]
+  CRUSH rule 0 x 579 [78,37]
+  CRUSH rule 0 x 580 [68,35]
+  CRUSH rule 0 x 581 [55,113]
+  CRUSH rule 0 x 582 [27,19]
+  CRUSH rule 0 x 583 [74,99]
+  CRUSH rule 0 x 584 [72,53]
+  CRUSH rule 0 x 585 [88,79]
+  CRUSH rule 0 x 586 [33,1]
+  CRUSH rule 0 x 587 [106,53]
+  CRUSH rule 0 x 588 [0,45]
+  CRUSH rule 0 x 589 [7,85]
+  CRUSH rule 0 x 590 [59,40]
+  CRUSH rule 0 x 591 [42,43]
+  CRUSH rule 0 x 592 [45,110]
+  CRUSH rule 0 x 593 [89,14]
+  CRUSH rule 0 x 594 [27,76]
+  CRUSH rule 0 x 595 [7,10]
+  CRUSH rule 0 x 596 [82,41]
+  CRUSH rule 0 x 597 [72,97]
+  CRUSH rule 0 x 598 [34,17]
+  CRUSH rule 0 x 599 [119,53]
+  CRUSH rule 0 x 600 [9,36]
+  CRUSH rule 0 x 601 [104,21]
+  CRUSH rule 0 x 602 [48,39]
+  CRUSH rule 0 x 603 [24,11]
+  CRUSH rule 0 x 604 [89,82]
+  CRUSH rule 0 x 605 [104,63]
+  CRUSH rule 0 x 606 [49,58]
+  CRUSH rule 0 x 607 [95,72]
+  CRUSH rule 0 x 608 [49,48]
+  CRUSH rule 0 x 609 [61,70]
+  CRUSH rule 0 x 610 [106,73]
+  CRUSH rule 0 x 611 [66,37]
+  CRUSH rule 0 x 612 [103,84]
+  CRUSH rule 0 x 613 [84,57]
+  CRUSH rule 0 x 614 [81,9]
+  CRUSH rule 0 x 615 [61,9]
+  CRUSH rule 0 x 616 [41,8]
+  CRUSH rule 0 x 617 [111,81]
+  CRUSH rule 0 x 618 [3,39]
+  CRUSH rule 0 x 619 [92,31]
+  CRUSH rule 0 x 620 [108,31]
+  CRUSH rule 0 x 621 [106,57]
+  CRUSH rule 0 x 622 [67,102]
+  CRUSH rule 0 x 623 [94,7]
+  CRUSH rule 0 x 624 [115,29]
+  CRUSH rule 0 x 625 [111,67]
+  CRUSH rule 0 x 626 [3,25]
+  CRUSH rule 0 x 627 [19,105]
+  CRUSH rule 0 x 628 [65,100]
+  CRUSH rule 0 x 629 [119,15]
+  CRUSH rule 0 x 630 [109,4]
+  CRUSH rule 0 x 631 [48,33]
+  CRUSH rule 0 x 632 [81,60]
+  CRUSH rule 0 x 633 [65,110]
+  CRUSH rule 0 x 634 [87,50]
+  CRUSH rule 0 x 635 [107,9]
+  CRUSH rule 0 x 636 [23,66]
+  CRUSH rule 0 x 637 [102,29]
+  CRUSH rule 0 x 638 [43,4]
+  CRUSH rule 0 x 639 [31,76]
+  CRUSH rule 0 x 640 [113,87]
+  CRUSH rule 0 x 641 [45,58]
+  CRUSH rule 0 x 642 [47,17]
+  CRUSH rule 0 x 643 [64,97]
+  CRUSH rule 0 x 644 [31,4]
+  CRUSH rule 0 x 645 [76,13]
+  CRUSH rule 0 x 646 [37,86]
+  CRUSH rule 0 x 647 [58,101]
+  CRUSH rule 0 x 648 [31,9]
+  CRUSH rule 0 x 649 [88,39]
+  CRUSH rule 0 x 650 [116,19]
+  CRUSH rule 0 x 651 [97,116]
+  CRUSH rule 0 x 652 [57,28]
+  CRUSH rule 0 x 653 [38,95]
+  CRUSH rule 0 x 654 [49,92]
+  CRUSH rule 0 x 655 [89,54]
+  CRUSH rule 0 x 656 [0,89]
+  CRUSH rule 0 x 657 [47,18]
+  CRUSH rule 0 x 658 [75,32]
+  CRUSH rule 0 x 659 [26,33]
+  CRUSH rule 0 x 660 [65,82]
+  CRUSH rule 0 x 661 [91,76]
+  CRUSH rule 0 x 662 [111,73]
+  CRUSH rule 0 x 663 [88,67]
+  CRUSH rule 0 x 664 [59,52]
+  CRUSH rule 0 x 665 [78,7]
+  CRUSH rule 0 x 666 [112,8]
+  CRUSH rule 0 x 667 [97,80]
+  CRUSH rule 0 x 668 [97,22]
+  CRUSH rule 0 x 669 [85,0]
+  CRUSH rule 0 x 670 [41,62]
+  CRUSH rule 0 x 671 [116,37]
+  CRUSH rule 0 x 672 [44,67]
+  CRUSH rule 0 x 673 [83,116]
+  CRUSH rule 0 x 674 [59,98]
+  CRUSH rule 0 x 675 [88,17]
+  CRUSH rule 0 x 676 [62,4]
+  CRUSH rule 0 x 677 [88,105]
+  CRUSH rule 0 x 678 [98,57]
+  CRUSH rule 0 x 679 [70,61]
+  CRUSH rule 0 x 680 [55,5]
+  CRUSH rule 0 x 681 [53,68]
+  CRUSH rule 0 x 682 [27,78]
+  CRUSH rule 0 x 683 [57,118]
+  CRUSH rule 0 x 684 [98,45]
+  CRUSH rule 0 x 685 [106,25]
+  CRUSH rule 0 x 686 [86,45]
+  CRUSH rule 0 x 687 [49,102]
+  CRUSH rule 0 x 688 [16,52]
+  CRUSH rule 0 x 689 [6,112]
+  CRUSH rule 0 x 690 [43,17]
+  CRUSH rule 0 x 691 [34,99]
+  CRUSH rule 0 x 692 [40,67]
+  CRUSH rule 0 x 693 [29,118]
+  CRUSH rule 0 x 694 [6,75]
+  CRUSH rule 0 x 695 [31,72]
+  CRUSH rule 0 x 696 [36,3]
+  CRUSH rule 0 x 697 [96,99]
+  CRUSH rule 0 x 698 [61,100]
+  CRUSH rule 0 x 699 [47,60]
+  CRUSH rule 0 x 700 [0,93]
+  CRUSH rule 0 x 701 [42,21]
+  CRUSH rule 0 x 702 [0,105]
+  CRUSH rule 0 x 703 [92,29]
+  CRUSH rule 0 x 704 [10,8]
+  CRUSH rule 0 x 705 [105,0]
+  CRUSH rule 0 x 706 [74,10]
+  CRUSH rule 0 x 707 [0,91]
+  CRUSH rule 0 x 708 [84,21]
+  CRUSH rule 0 x 709 [114,23]
+  CRUSH rule 0 x 710 [94,19]
+  CRUSH rule 0 x 711 [68,41]
+  CRUSH rule 0 x 712 [34,71]
+  CRUSH rule 0 x 713 [29,2]
+  CRUSH rule 0 x 714 [81,80]
+  CRUSH rule 0 x 715 [71,62]
+  CRUSH rule 0 x 716 [40,6]
+  CRUSH rule 0 x 717 [61,60]
+  CRUSH rule 0 x 718 [40,69]
+  CRUSH rule 0 x 719 [59,74]
+  CRUSH rule 0 x 720 [69,2]
+  CRUSH rule 0 x 721 [62,75]
+  CRUSH rule 0 x 722 [115,19]
+  CRUSH rule 0 x 723 [117,25]
+  CRUSH rule 0 x 724 [45,3]
+  CRUSH rule 0 x 725 [53,110]
+  CRUSH rule 0 x 726 [84,107]
+  CRUSH rule 0 x 727 [109,19]
+  CRUSH rule 0 x 728 [76,65]
+  CRUSH rule 0 x 729 [108,7]
+  CRUSH rule 0 x 730 [28,37]
+  CRUSH rule 0 x 731 [78,41]
+  CRUSH rule 0 x 732 [55,112]
+  CRUSH rule 0 x 733 [84,7]
+  CRUSH rule 0 x 734 [27,110]
+  CRUSH rule 0 x 735 [83,62]
+  CRUSH rule 0 x 736 [70,67]
+  CRUSH rule 0 x 737 [117,11]
+  CRUSH rule 0 x 738 [118,95]
+  CRUSH rule 0 x 739 [87,1]
+  CRUSH rule 0 x 740 [29,92]
+  CRUSH rule 0 x 741 [96,49]
+  CRUSH rule 0 x 742 [106,31]
+  CRUSH rule 0 x 743 [105,5]
+  CRUSH rule 0 x 744 [23,64]
+  CRUSH rule 0 x 745 [28,85]
+  CRUSH rule 0 x 746 [18,47]
+  CRUSH rule 0 x 747 [65,108]
+  CRUSH rule 0 x 748 [48,25]
+  CRUSH rule 0 x 749 [102,71]
+  CRUSH rule 0 x 750 [50,77]
+  CRUSH rule 0 x 751 [36,29]
+  CRUSH rule 0 x 752 [69,119]
+  CRUSH rule 0 x 753 [9,34]
+  CRUSH rule 0 x 754 [9,39]
+  CRUSH rule 0 x 755 [98,45]
+  CRUSH rule 0 x 756 [113,83]
+  CRUSH rule 0 x 757 [47,112]
+  CRUSH rule 0 x 758 [57,84]
+  CRUSH rule 0 x 759 [74,65]
+  CRUSH rule 0 x 760 [53,34]
+  CRUSH rule 0 x 761 [78,105]
+  CRUSH rule 0 x 762 [87,13]
+  CRUSH rule 0 x 763 [13,16]
+  CRUSH rule 0 x 764 [106,27]
+  CRUSH rule 0 x 765 [109,77]
+  CRUSH rule 0 x 766 [76,105]
+  CRUSH rule 0 x 767 [41,80]
+  CRUSH rule 0 x 768 [13,50]
+  CRUSH rule 0 x 769 [91,96]
+  CRUSH rule 0 x 770 [105,62]
+  CRUSH rule 0 x 771 [10,28]
+  CRUSH rule 0 x 772 [8,102]
+  CRUSH rule 0 x 773 [116,91]
+  CRUSH rule 0 x 774 [100,105]
+  CRUSH rule 0 x 775 [15,61]
+  CRUSH rule 0 x 776 [69,44]
+  CRUSH rule 0 x 777 [76,23]
+  CRUSH rule 0 x 778 [38,9]
+  CRUSH rule 0 x 779 [46,17]
+  CRUSH rule 0 x 780 [63,70]
+  CRUSH rule 0 x 781 [19,16]
+  CRUSH rule 0 x 782 [117,59]
+  CRUSH rule 0 x 783 [60,25]
+  CRUSH rule 0 x 784 [82,81]
+  CRUSH rule 0 x 785 [27,50]
+  CRUSH rule 0 x 786 [41,90]
+  CRUSH rule 0 x 787 [13,34]
+  CRUSH rule 0 x 788 [4,113]
+  CRUSH rule 0 x 789 [50,51]
+  CRUSH rule 0 x 790 [58,95]
+  CRUSH rule 0 x 791 [96,37]
+  CRUSH rule 0 x 792 [45,13]
+  CRUSH rule 0 x 793 [6,103]
+  CRUSH rule 0 x 794 [14,61]
+  CRUSH rule 0 x 795 [51,26]
+  CRUSH rule 0 x 796 [114,43]
+  CRUSH rule 0 x 797 [79,115]
+  CRUSH rule 0 x 798 [42,19]
+  CRUSH rule 0 x 799 [48,41]
+  CRUSH rule 0 x 800 [91,22]
+  CRUSH rule 0 x 801 [2,11]
+  CRUSH rule 0 x 802 [116,19]
+  CRUSH rule 0 x 803 [37,46]
+  CRUSH rule 0 x 804 [6,93]
+  CRUSH rule 0 x 805 [96,3]
+  CRUSH rule 0 x 806 [67,110]
+  CRUSH rule 0 x 807 [47,92]
+  CRUSH rule 0 x 808 [76,31]
+  CRUSH rule 0 x 809 [27,90]
+  CRUSH rule 0 x 810 [119,35]
+  CRUSH rule 0 x 811 [75,84]
+  CRUSH rule 0 x 812 [25,94]
+  CRUSH rule 0 x 813 [64,27]
+  CRUSH rule 0 x 814 [110,29]
+  CRUSH rule 0 x 815 [84,39]
+  CRUSH rule 0 x 816 [25,3]
+  CRUSH rule 0 x 817 [40,57]
+  CRUSH rule 0 x 818 [34,16]
+  CRUSH rule 0 x 819 [88,15]
+  CRUSH rule 0 x 820 [104,29]
+  CRUSH rule 0 x 821 [58,16]
+  CRUSH rule 0 x 822 [29,98]
+  CRUSH rule 0 x 823 [100,37]
+  CRUSH rule 0 x 824 [102,95]
+  CRUSH rule 0 x 825 [47,14]
+  CRUSH rule 0 x 826 [45,8]
+  CRUSH rule 0 x 827 [101,19]
+  CRUSH rule 0 x 828 [60,27]
+  CRUSH rule 0 x 829 [45,102]
+  CRUSH rule 0 x 830 [51,0]
+  CRUSH rule 0 x 831 [6,64]
+  CRUSH rule 0 x 832 [57,116]
+  CRUSH rule 0 x 833 [34,105]
+  CRUSH rule 0 x 834 [90,77]
+  CRUSH rule 0 x 835 [55,50]
+  CRUSH rule 0 x 836 [38,51]
+  CRUSH rule 0 x 837 [51,78]
+  CRUSH rule 0 x 838 [6,98]
+  CRUSH rule 0 x 839 [106,15]
+  CRUSH rule 0 x 840 [33,117]
+  CRUSH rule 0 x 841 [110,13]
+  CRUSH rule 0 x 842 [66,83]
+  CRUSH rule 0 x 843 [62,107]
+  CRUSH rule 0 x 844 [74,22]
+  CRUSH rule 0 x 845 [74,63]
+  CRUSH rule 0 x 846 [98,41]
+  CRUSH rule 0 x 847 [10,90]
+  CRUSH rule 0 x 848 [89,19]
+  CRUSH rule 0 x 849 [42,61]
+  CRUSH rule 0 x 850 [40,87]
+  CRUSH rule 0 x 851 [65,11]
+  CRUSH rule 0 x 852 [31,100]
+  CRUSH rule 0 x 853 [49,11]
+  CRUSH rule 0 x 854 [83,92]
+  CRUSH rule 0 x 855 [2,22]
+  CRUSH rule 0 x 856 [6,41]
+  CRUSH rule 0 x 857 [15,110]
+  CRUSH rule 0 x 858 [10,114]
+  CRUSH rule 0 x 859 [14,41]
+  CRUSH rule 0 x 860 [114,93]
+  CRUSH rule 0 x 861 [1,105]
+  CRUSH rule 0 x 862 [22,27]
+  CRUSH rule 0 x 863 [79,50]
+  CRUSH rule 0 x 864 [68,19]
+  CRUSH rule 0 x 865 [25,68]
+  CRUSH rule 0 x 866 [18,85]
+  CRUSH rule 0 x 867 [53,58]
+  CRUSH rule 0 x 868 [81,0]
+  CRUSH rule 0 x 869 [111,22]
+  CRUSH rule 0 x 870 [73,94]
+  CRUSH rule 0 x 871 [25,64]
+  CRUSH rule 0 x 872 [39,2]
+  CRUSH rule 0 x 873 [92,6]
+  CRUSH rule 0 x 874 [96,17]
+  CRUSH rule 0 x 875 [115,27]
+  CRUSH rule 0 x 876 [98,16]
+  CRUSH rule 0 x 877 [73,46]
+  CRUSH rule 0 x 878 [64,45]
+  CRUSH rule 0 x 879 [15,1]
+  CRUSH rule 0 x 880 [56,105]
+  CRUSH rule 0 x 881 [109,97]
+  CRUSH rule 0 x 882 [60,79]
+  CRUSH rule 0 x 883 [93,17]
+  CRUSH rule 0 x 884 [67,36]
+  CRUSH rule 0 x 885 [31,104]
+  CRUSH rule 0 x 886 [2,7]
+  CRUSH rule 0 x 887 [5,9]
+  CRUSH rule 0 x 888 [16,22]
+  CRUSH rule 0 x 889 [27,2]
+  CRUSH rule 0 x 890 [48,47]
+  CRUSH rule 0 x 891 [86,59]
+  CRUSH rule 0 x 892 [64,91]
+  CRUSH rule 0 x 893 [118,7]
+  CRUSH rule 0 x 894 [16,94]
+  CRUSH rule 0 x 895 [40,101]
+  CRUSH rule 0 x 896 [97,119]
+  CRUSH rule 0 x 897 [107,80]
+  CRUSH rule 0 x 898 [10,88]
+  CRUSH rule 0 x 899 [75,1]
+  CRUSH rule 0 x 900 [102,55]
+  CRUSH rule 0 x 901 [66,61]
+  CRUSH rule 0 x 902 [102,10]
+  CRUSH rule 0 x 903 [5,33]
+  CRUSH rule 0 x 904 [50,10]
+  CRUSH rule 0 x 905 [99,5]
+  CRUSH rule 0 x 906 [75,119]
+  CRUSH rule 0 x 907 [47,34]
+  CRUSH rule 0 x 908 [96,73]
+  CRUSH rule 0 x 909 [94,87]
+  CRUSH rule 0 x 910 [88,57]
+  CRUSH rule 0 x 911 [102,43]
+  CRUSH rule 0 x 912 [91,111]
+  CRUSH rule 0 x 913 [29,21]
+  CRUSH rule 0 x 914 [84,19]
+  CRUSH rule 0 x 915 [70,43]
+  CRUSH rule 0 x 916 [32,7]
+  CRUSH rule 0 x 917 [43,102]
+  CRUSH rule 0 x 918 [91,26]
+  CRUSH rule 0 x 919 [13,51]
+  CRUSH rule 0 x 920 [18,13]
+  CRUSH rule 0 x 921 [104,8]
+  CRUSH rule 0 x 922 [33,96]
+  CRUSH rule 0 x 923 [28,15]
+  CRUSH rule 0 x 924 [69,76]
+  CRUSH rule 0 x 925 [71,104]
+  CRUSH rule 0 x 926 [64,65]
+  CRUSH rule 0 x 927 [99,6]
+  CRUSH rule 0 x 928 [13,94]
+  CRUSH rule 0 x 929 [117,95]
+  CRUSH rule 0 x 930 [31,111]
+  CRUSH rule 0 x 931 [83,64]
+  CRUSH rule 0 x 932 [60,21]
+  CRUSH rule 0 x 933 [63,113]
+  CRUSH rule 0 x 934 [68,21]
+  CRUSH rule 0 x 935 [31,46]
+  CRUSH rule 0 x 936 [65,116]
+  CRUSH rule 0 x 937 [110,65]
+  CRUSH rule 0 x 938 [29,98]
+  CRUSH rule 0 x 939 [77,11]
+  CRUSH rule 0 x 940 [76,19]
+  CRUSH rule 0 x 941 [66,10]
+  CRUSH rule 0 x 942 [83,32]
+  CRUSH rule 0 x 943 [32,9]
+  CRUSH rule 0 x 944 [113,7]
+  CRUSH rule 0 x 945 [71,111]
+  CRUSH rule 0 x 946 [37,42]
+  CRUSH rule 0 x 947 [107,48]
+  CRUSH rule 0 x 948 [55,24]
+  CRUSH rule 0 x 949 [11,109]
+  CRUSH rule 0 x 950 [96,33]
+  CRUSH rule 0 x 951 [40,63]
+  CRUSH rule 0 x 952 [93,5]
+  CRUSH rule 0 x 953 [55,28]
+  CRUSH rule 0 x 954 [84,83]
+  CRUSH rule 0 x 955 [31,90]
+  CRUSH rule 0 x 956 [72,6]
+  CRUSH rule 0 x 957 [3,88]
+  CRUSH rule 0 x 958 [23,74]
+  CRUSH rule 0 x 959 [42,93]
+  CRUSH rule 0 x 960 [113,91]
+  CRUSH rule 0 x 961 [116,4]
+  CRUSH rule 0 x 962 [13,52]
+  CRUSH rule 0 x 963 [0,83]
+  CRUSH rule 0 x 964 [59,44]
+  CRUSH rule 0 x 965 [47,102]
+  CRUSH rule 0 x 966 [88,69]
+  CRUSH rule 0 x 967 [71,17]
+  CRUSH rule 0 x 968 [73,9]
+  CRUSH rule 0 x 969 [53,21]
+  CRUSH rule 0 x 970 [111,85]
+  CRUSH rule 0 x 971 [87,19]
+  CRUSH rule 0 x 972 [5,33]
+  CRUSH rule 0 x 973 [113,81]
+  CRUSH rule 0 x 974 [49,86]
+  CRUSH rule 0 x 975 [83,96]
+  CRUSH rule 0 x 976 [81,100]
+  CRUSH rule 0 x 977 [95,76]
+  CRUSH rule 0 x 978 [35,4]
+  CRUSH rule 0 x 979 [98,13]
+  CRUSH rule 0 x 980 [52,93]
+  CRUSH rule 0 x 981 [89,46]
+  CRUSH rule 0 x 982 [1,95]
+  CRUSH rule 0 x 983 [34,37]
+  CRUSH rule 0 x 984 [78,23]
+  CRUSH rule 0 x 985 [99,24]
+  CRUSH rule 0 x 986 [4,33]
+  CRUSH rule 0 x 987 [78,22]
+  CRUSH rule 0 x 988 [79,84]
+  CRUSH rule 0 x 989 [87,6]
+  CRUSH rule 0 x 990 [47,46]
+  CRUSH rule 0 x 991 [61,18]
+  CRUSH rule 0 x 992 [83,111]
+  CRUSH rule 0 x 993 [74,27]
+  CRUSH rule 0 x 994 [74,105]
+  CRUSH rule 0 x 995 [100,45]
+  CRUSH rule 0 x 996 [41,22]
+  CRUSH rule 0 x 997 [89,32]
+  CRUSH rule 0 x 998 [92,65]
+  CRUSH rule 0 x 999 [117,13]
+  CRUSH rule 0 x 1000 [9,48]
+  CRUSH rule 0 x 1001 [49,109]
+  CRUSH rule 0 x 1002 [99,106]
+  CRUSH rule 0 x 1003 [43,22]
+  CRUSH rule 0 x 1004 [89,106]
+  CRUSH rule 0 x 1005 [105,44]
+  CRUSH rule 0 x 1006 [45,5]
+  CRUSH rule 0 x 1007 [19,67]
+  CRUSH rule 0 x 1008 [31,3]
+  CRUSH rule 0 x 1009 [19,108]
+  CRUSH rule 0 x 1010 [42,67]
+  CRUSH rule 0 x 1011 [25,113]
+  CRUSH rule 0 x 1012 [68,81]
+  CRUSH rule 0 x 1013 [5,93]
+  CRUSH rule 0 x 1014 [33,8]
+  CRUSH rule 0 x 1015 [14,99]
+  CRUSH rule 0 x 1016 [88,6]
+  CRUSH rule 0 x 1017 [0,61]
+  CRUSH rule 0 x 1018 [63,26]
+  CRUSH rule 0 x 1019 [104,61]
+  CRUSH rule 0 x 1020 [96,83]
+  CRUSH rule 0 x 1021 [117,35]
+  CRUSH rule 0 x 1022 [73,6]
+  CRUSH rule 0 x 1023 [0,83]
+  rule 0 (data) num_rep 2 result size == 2:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 3 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 4 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 5 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 6 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 7 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 8 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 9 result size == 3:\t1024/1024 (esc)
+  CRUSH rule 0 x 0 [101,28,17]
+  CRUSH rule 0 x 1 [80,13,75]
+  CRUSH rule 0 x 2 [91,11,68]
+  CRUSH rule 0 x 3 [51,13,112]
+  CRUSH rule 0 x 4 [50,101,3]
+  CRUSH rule 0 x 5 [89,113,11]
+  CRUSH rule 0 x 6 [91,109,13]
+  CRUSH rule 0 x 7 [104,51,14]
+  CRUSH rule 0 x 8 [78,75,11]
+  CRUSH rule 0 x 9 [101,80,7]
+  CRUSH rule 0 x 10 [61,4,111]
+  CRUSH rule 0 x 11 [13,43,40]
+  CRUSH rule 0 x 12 [83,0,17]
+  CRUSH rule 0 x 13 [108,22,93]
+  CRUSH rule 0 x 14 [105,9,104]
+  CRUSH rule 0 x 15 [18,7,16]
+  CRUSH rule 0 x 16 [103,4,60]
+  CRUSH rule 0 x 17 [85,80,14]
+  CRUSH rule 0 x 18 [11,71,48]
+  CRUSH rule 0 x 19 [75,114,3]
+  CRUSH rule 0 x 20 [79,64,7]
+  CRUSH rule 0 x 21 [84,7,61]
+  CRUSH rule 0 x 22 [23,66,21]
+  CRUSH rule 0 x 23 [118,6,10]
+  CRUSH rule 0 x 24 [83,111,19]
+  CRUSH rule 0 x 25 [81,116,13]
+  CRUSH rule 0 x 26 [38,69,13]
+  CRUSH rule 0 x 27 [76,103,8]
+  CRUSH rule 0 x 28 [76,103,4]
+  CRUSH rule 0 x 29 [8,46,59]
+  CRUSH rule 0 x 30 [94,7,103]
+  CRUSH rule 0 x 31 [76,35,3]
+  CRUSH rule 0 x 32 [72,35,4]
+  CRUSH rule 0 x 33 [77,104,14]
+  CRUSH rule 0 x 34 [74,67,11]
+  CRUSH rule 0 x 35 [22,115,57]
+  CRUSH rule 0 x 36 [104,33,15]
+  CRUSH rule 0 x 37 [38,57,22]
+  CRUSH rule 0 x 38 [72,11,81]
+  CRUSH rule 0 x 39 [68,73,13]
+  CRUSH rule 0 x 40 [103,76,4]
+  CRUSH rule 0 x 41 [85,4,78]
+  CRUSH rule 0 x 42 [106,39,15]
+  CRUSH rule 0 x 43 [10,115,22]
+  CRUSH rule 0 x 44 [101,66,4]
+  CRUSH rule 0 x 45 [8,80,71]
+  CRUSH rule 0 x 46 [65,66,17]
+  CRUSH rule 0 x 47 [106,41,19]
+  CRUSH rule 0 x 48 [34,4,41]
+  CRUSH rule 0 x 49 [0,27,15]
+  CRUSH rule 0 x 50 [42,14,55]
+  CRUSH rule 0 x 51 [104,59,15]
+  CRUSH rule 0 x 52 [83,14,80]
+  CRUSH rule 0 x 53 [32,93,9]
+  CRUSH rule 0 x 54 [28,77,4]
+  CRUSH rule 0 x 55 [14,94,75]
+  CRUSH rule 0 x 56 [21,112,63]
+  CRUSH rule 0 x 57 [93,88,3]
+  CRUSH rule 0 x 58 [45,1,14]
+  CRUSH rule 0 x 59 [80,31,6]
+  CRUSH rule 0 x 60 [90,33,4]
+  CRUSH rule 0 x 61 [88,39,19]
+  CRUSH rule 0 x 62 [81,0,4]
+  CRUSH rule 0 x 63 [79,96,3]
+  CRUSH rule 0 x 64 [1,8,35]
+  CRUSH rule 0 x 65 [13,92,61]
+  CRUSH rule 0 x 66 [48,79,11]
+  CRUSH rule 0 x 67 [94,91,11]
+  CRUSH rule 0 x 68 [102,105,4]
+  CRUSH rule 0 x 69 [62,4,53]
+  CRUSH rule 0 x 70 [84,27,4]
+  CRUSH rule 0 x 71 [55,108,8]
+  CRUSH rule 0 x 72 [97,42,13]
+  CRUSH rule 0 x 73 [64,81,14]
+  CRUSH rule 0 x 74 [96,41,13]
+  CRUSH rule 0 x 75 [29,98,15]
+  CRUSH rule 0 x 76 [55,111,22]
+  CRUSH rule 0 x 77 [107,21,72]
+  CRUSH rule 0 x 78 [31,100,9]
+  CRUSH rule 0 x 79 [64,75,8]
+  CRUSH rule 0 x 80 [0,67,17]
+  CRUSH rule 0 x 81 [71,52,15]
+  CRUSH rule 0 x 82 [37,0,11]
+  CRUSH rule 0 x 83 [92,75,9]
+  CRUSH rule 0 x 84 [49,40,7]
+  CRUSH rule 0 x 85 [54,71,11]
+  CRUSH rule 0 x 86 [37,14,111]
+  CRUSH rule 0 x 87 [116,3,93]
+  CRUSH rule 0 x 88 [38,95,3]
+  CRUSH rule 0 x 89 [76,41,19]
+  CRUSH rule 0 x 90 [14,98,75]
+  CRUSH rule 0 x 91 [93,114,21]
+  CRUSH rule 0 x 92 [86,13,23]
+  CRUSH rule 0 x 93 [44,41,15]
+  CRUSH rule 0 x 94 [61,18,11]
+  CRUSH rule 0 x 95 [93,98,8]
+  CRUSH rule 0 x 96 [66,25,8]
+  CRUSH rule 0 x 97 [111,4,33]
+  CRUSH rule 0 x 98 [66,16,17]
+  CRUSH rule 0 x 99 [78,22,87]
+  CRUSH rule 0 x 100 [28,4,61]
+  CRUSH rule 0 x 101 [84,51,8]
+  CRUSH rule 0 x 102 [82,93,7]
+  CRUSH rule 0 x 103 [66,4,105]
+  CRUSH rule 0 x 104 [14,10,48]
+  CRUSH rule 0 x 105 [87,100,7]
+  CRUSH rule 0 x 106 [69,66,3]
+  CRUSH rule 0 x 107 [1,41,15]
+  CRUSH rule 0 x 108 [94,75,19]
+  CRUSH rule 0 x 109 [112,87,21]
+  CRUSH rule 0 x 110 [54,10,17]
+  CRUSH rule 0 x 111 [10,112,8]
+  CRUSH rule 0 x 112 [89,11,102]
+  CRUSH rule 0 x 113 [69,26,14]
+  CRUSH rule 0 x 114 [79,22,110]
+  CRUSH rule 0 x 115 [50,65,22]
+  CRUSH rule 0 x 116 [96,53,22]
+  CRUSH rule 0 x 117 [87,86,15]
+  CRUSH rule 0 x 118 [23,106,3]
+  CRUSH rule 0 x 119 [104,14,31]
+  CRUSH rule 0 x 120 [57,42,21]
+  CRUSH rule 0 x 121 [105,50,9]
+  CRUSH rule 0 x 122 [45,68,22]
+  CRUSH rule 0 x 123 [112,15,43]
+  CRUSH rule 0 x 124 [110,19,69]
+  CRUSH rule 0 x 125 [66,71,22]
+  CRUSH rule 0 x 126 [51,64,17]
+  CRUSH rule 0 x 127 [70,13,59]
+  CRUSH rule 0 x 128 [90,47,14]
+  CRUSH rule 0 x 129 [103,108,7]
+  CRUSH rule 0 x 130 [50,17,55]
+  CRUSH rule 0 x 131 [23,60,15]
+  CRUSH rule 0 x 132 [69,58,13]
+  CRUSH rule 0 x 133 [52,85,14]
+  CRUSH rule 0 x 134 [78,81,8]
+  CRUSH rule 0 x 135 [78,6,53]
+  CRUSH rule 0 x 136 [32,83,11]
+  CRUSH rule 0 x 137 [92,87,3]
+  CRUSH rule 0 x 138 [17,74,41]
+  CRUSH rule 0 x 139 [89,92,8]
+  CRUSH rule 0 x 140 [39,1,13]
+  CRUSH rule 0 x 141 [89,96,8]
+  CRUSH rule 0 x 142 [70,73,13]
+  CRUSH rule 0 x 143 [51,26,22]
+  CRUSH rule 0 x 144 [13,55,1]
+  CRUSH rule 0 x 145 [77,100,6]
+  CRUSH rule 0 x 146 [96,73,22]
+  CRUSH rule 0 x 147 [2,89,9]
+  CRUSH rule 0 x 148 [74,91,8]
+  CRUSH rule 0 x 149 [76,19,45]
+  CRUSH rule 0 x 150 [38,105,8]
+  CRUSH rule 0 x 151 [90,85,7]
+  CRUSH rule 0 x 152 [49,84,21]
+  CRUSH rule 0 x 153 [71,42,9]
+  CRUSH rule 0 x 154 [94,23,4]
+  CRUSH rule 0 x 155 [75,119,3]
+  CRUSH rule 0 x 156 [107,18,19]
+  CRUSH rule 0 x 157 [112,57,8]
+  CRUSH rule 0 x 158 [26,3,103]
+  CRUSH rule 0 x 159 [52,17,41]
+  CRUSH rule 0 x 160 [41,119,7]
+  CRUSH rule 0 x 161 [84,51,4]
+  CRUSH rule 0 x 162 [55,2,22]
+  CRUSH rule 0 x 163 [54,21,31]
+  CRUSH rule 0 x 164 [45,44,6]
+  CRUSH rule 0 x 165 [25,116,14]
+  CRUSH rule 0 x 166 [73,38,7]
+  CRUSH rule 0 x 167 [89,119,21]
+  CRUSH rule 0 x 168 [47,90,6]
+  CRUSH rule 0 x 169 [51,22,24]
+  CRUSH rule 0 x 170 [68,53,9]
+  CRUSH rule 0 x 171 [73,28,13]
+  CRUSH rule 0 x 172 [117,23,17]
+  CRUSH rule 0 x 173 [13,40,25]
+  CRUSH rule 0 x 174 [116,85,3]
+  CRUSH rule 0 x 175 [3,85,1]
+  CRUSH rule 0 x 176 [94,83,22]
+  CRUSH rule 0 x 177 [52,29,7]
+  CRUSH rule 0 x 178 [39,42,9]
+  CRUSH rule 0 x 179 [72,89,4]
+  CRUSH rule 0 x 180 [60,67,7]
+  CRUSH rule 0 x 181 [18,16,15]
+  CRUSH rule 0 x 182 [22,5,71]
+  CRUSH rule 0 x 183 [11,110,25]
+  CRUSH rule 0 x 184 [92,15,91]
+  CRUSH rule 0 x 185 [97,117,4]
+  CRUSH rule 0 x 186 [67,96,21]
+  CRUSH rule 0 x 187 [116,14,31]
+  CRUSH rule 0 x 188 [69,54,14]
+  CRUSH rule 0 x 189 [47,113,11]
+  CRUSH rule 0 x 190 [65,90,8]
+  CRUSH rule 0 x 191 [49,113,17]
+  CRUSH rule 0 x 192 [68,93,7]
+  CRUSH rule 0 x 193 [0,37,15]
+  CRUSH rule 0 x 194 [62,63,19]
+  CRUSH rule 0 x 195 [119,11,67]
+  CRUSH rule 0 x 196 [72,59,7]
+  CRUSH rule 0 x 197 [106,49,8]
+  CRUSH rule 0 x 198 [114,21,39]
+  CRUSH rule 0 x 199 [0,99,17]
+  CRUSH rule 0 x 200 [35,102,13]
+  CRUSH rule 0 x 201 [27,104,11]
+  CRUSH rule 0 x 202 [98,59,7]
+  CRUSH rule 0 x 203 [36,91,22]
+  CRUSH rule 0 x 204 [10,113,9]
+  CRUSH rule 0 x 205 [81,22,52]
+  CRUSH rule 0 x 206 [49,92,19]
+  CRUSH rule 0 x 207 [80,19,25]
+  CRUSH rule 0 x 208 [63,92,21]
+  CRUSH rule 0 x 209 [85,78,13]
+  CRUSH rule 0 x 210 [79,76,15]
+  CRUSH rule 0 x 211 [26,89,6]
+  CRUSH rule 0 x 212 [28,33,11]
+  CRUSH rule 0 x 213 [91,102,3]
+  CRUSH rule 0 x 214 [91,118,6]
+  CRUSH rule 0 x 215 [61,58,22]
+  CRUSH rule 0 x 216 [99,108,9]
+  CRUSH rule 0 x 217 [86,97,14]
+  CRUSH rule 0 x 218 [70,15,97]
+  CRUSH rule 0 x 219 [28,91,19]
+  CRUSH rule 0 x 220 [56,9,23]
+  CRUSH rule 0 x 221 [0,21,45]
+  CRUSH rule 0 x 222 [50,65,13]
+  CRUSH rule 0 x 223 [29,46,4]
+  CRUSH rule 0 x 224 [52,71,17]
+  CRUSH rule 0 x 225 [15,87,112]
+  CRUSH rule 0 x 226 [44,13,65]
+  CRUSH rule 0 x 227 [42,21,35]
+  CRUSH rule 0 x 228 [117,55,17]
+  CRUSH rule 0 x 229 [100,67,21]
+  CRUSH rule 0 x 230 [41,52,17]
+  CRUSH rule 0 x 231 [56,61,22]
+  CRUSH rule 0 x 232 [23,11,44]
+  CRUSH rule 0 x 233 [88,35,9]
+  CRUSH rule 0 x 234 [4,55,94]
+  CRUSH rule 0 x 235 [26,16,11]
+  CRUSH rule 0 x 236 [32,39,15]
+  CRUSH rule 0 x 237 [92,4,97]
+  CRUSH rule 0 x 238 [10,117,21]
+  CRUSH rule 0 x 239 [15,10,96]
+  CRUSH rule 0 x 240 [109,3,99]
+  CRUSH rule 0 x 241 [47,44,14]
+  CRUSH rule 0 x 242 [24,61,8]
+  CRUSH rule 0 x 243 [76,9,101]
+  CRUSH rule 0 x 244 [103,17,78]
+  CRUSH rule 0 x 245 [27,34,14]
+  CRUSH rule 0 x 246 [5,35,11]
+  CRUSH rule 0 x 247 [99,38,4]
+  CRUSH rule 0 x 248 [8,45,42]
+  CRUSH rule 0 x 249 [85,38,3]
+  CRUSH rule 0 x 250 [93,78,3]
+  CRUSH rule 0 x 251 [28,41,15]
+  CRUSH rule 0 x 252 [95,3,56]
+  CRUSH rule 0 x 253 [109,97,19]
+  CRUSH rule 0 x 254 [80,11,41]
+  CRUSH rule 0 x 255 [103,22,110]
+  CRUSH rule 0 x 256 [37,82,14]
+  CRUSH rule 0 x 257 [69,104,6]
+  CRUSH rule 0 x 258 [34,63,3]
+  CRUSH rule 0 x 259 [70,9,75]
+  CRUSH rule 0 x 260 [98,43,7]
+  CRUSH rule 0 x 261 [94,77,22]
+  CRUSH rule 0 x 262 [42,45,9]
+  CRUSH rule 0 x 263 [65,68,21]
+  CRUSH rule 0 x 264 [36,45,22]
+  CRUSH rule 0 x 265 [66,97,14]
+  CRUSH rule 0 x 266 [75,64,17]
+  CRUSH rule 0 x 267 [58,39,8]
+  CRUSH rule 0 x 268 [38,3,47]
+  CRUSH rule 0 x 269 [86,91,3]
+  CRUSH rule 0 x 270 [58,43,7]
+  CRUSH rule 0 x 271 [19,43,88]
+  CRUSH rule 0 x 272 [73,8,52]
+  CRUSH rule 0 x 273 [108,16,9]
+  CRUSH rule 0 x 274 [47,88,8]
+  CRUSH rule 0 x 275 [92,21,99]
+  CRUSH rule 0 x 276 [7,57,100]
+  CRUSH rule 0 x 277 [19,117,87]
+  CRUSH rule 0 x 278 [116,63,13]
+  CRUSH rule 0 x 279 [101,102,15]
+  CRUSH rule 0 x 280 [113,75,17]
+  CRUSH rule 0 x 281 [14,97,56]
+  CRUSH rule 0 x 282 [106,53,11]
+  CRUSH rule 0 x 283 [8,36,41]
+  CRUSH rule 0 x 284 [10,32,15]
+  CRUSH rule 0 x 285 [88,63,9]
+  CRUSH rule 0 x 286 [27,6,48]
+  CRUSH rule 0 x 287 [84,101,4]
+  CRUSH rule 0 x 288 [103,22,100]
+  CRUSH rule 0 x 289 [9,26,45]
+  CRUSH rule 0 x 290 [115,9,31]
+  CRUSH rule 0 x 291 [48,47,13]
+  CRUSH rule 0 x 292 [89,108,15]
+  CRUSH rule 0 x 293 [27,118,11]
+  CRUSH rule 0 x 294 [79,111,21]
+  CRUSH rule 0 x 295 [37,18,11]
+  CRUSH rule 0 x 296 [56,27,7]
+  CRUSH rule 0 x 297 [35,28,19]
+  CRUSH rule 0 x 298 [71,2,6]
+  CRUSH rule 0 x 299 [116,85,6]
+  CRUSH rule 0 x 300 [67,26,21]
+  CRUSH rule 0 x 301 [51,32,13]
+  CRUSH rule 0 x 302 [78,105,13]
+  CRUSH rule 0 x 303 [19,82,67]
+  CRUSH rule 0 x 304 [101,50,21]
+  CRUSH rule 0 x 305 [81,68,21]
+  CRUSH rule 0 x 306 [0,97,17]
+  CRUSH rule 0 x 307 [44,21,63]
+  CRUSH rule 0 x 308 [91,2,9]
+  CRUSH rule 0 x 309 [38,39,19]
+  CRUSH rule 0 x 310 [26,15,75]
+  CRUSH rule 0 x 311 [36,75,3]
+  CRUSH rule 0 x 312 [33,15,58]
+  CRUSH rule 0 x 313 [104,65,17]
+  CRUSH rule 0 x 314 [28,9,61]
+  CRUSH rule 0 x 315 [16,72,14]
+  CRUSH rule 0 x 316 [4,76,23]
+  CRUSH rule 0 x 317 [118,13,55]
+  CRUSH rule 0 x 318 [17,77,92]
+  CRUSH rule 0 x 319 [24,93,3]
+  CRUSH rule 0 x 320 [36,41,13]
+  CRUSH rule 0 x 321 [26,81,3]
+  CRUSH rule 0 x 322 [87,24,8]
+  CRUSH rule 0 x 323 [73,76,19]
+  CRUSH rule 0 x 324 [21,75,110]
+  CRUSH rule 0 x 325 [52,43,3]
+  CRUSH rule 0 x 326 [111,105,4]
+  CRUSH rule 0 x 327 [62,17,16]
+  CRUSH rule 0 x 328 [7,0,99]
+  CRUSH rule 0 x 329 [93,14,32]
+  CRUSH rule 0 x 330 [24,15,37]
+  CRUSH rule 0 x 331 [41,109,4]
+  CRUSH rule 0 x 332 [61,111,11]
+  CRUSH rule 0 x 333 [16,6,5]
+  CRUSH rule 0 x 334 [3,29,36]
+  CRUSH rule 0 x 335 [71,66,22]
+  CRUSH rule 0 x 336 [16,11,5]
+  CRUSH rule 0 x 337 [37,113,9]
+  CRUSH rule 0 x 338 [109,6,41]
+  CRUSH rule 0 x 339 [37,22,1]
+  CRUSH rule 0 x 340 [119,101,19]
+  CRUSH rule 0 x 341 [63,14,114]
+  CRUSH rule 0 x 342 [92,71,8]
+  CRUSH rule 0 x 343 [49,56,7]
+  CRUSH rule 0 x 344 [103,113,17]
+  CRUSH rule 0 x 345 [56,35,22]
+  CRUSH rule 0 x 346 [3,25,40]
+  CRUSH rule 0 x 347 [106,85,21]
+  CRUSH rule 0 x 348 [10,114,6]
+  CRUSH rule 0 x 349 [96,103,6]
+  CRUSH rule 0 x 350 [63,32,22]
+  CRUSH rule 0 x 351 [60,73,13]
+  CRUSH rule 0 x 352 [103,68,9]
+  CRUSH rule 0 x 353 [49,113,17]
+  CRUSH rule 0 x 354 [55,74,8]
+  CRUSH rule 0 x 355 [73,80,11]
+  CRUSH rule 0 x 356 [114,65,11]
+  CRUSH rule 0 x 357 [14,110,41]
+  CRUSH rule 0 x 358 [97,56,11]
+  CRUSH rule 0 x 359 [4,89,106]
+  CRUSH rule 0 x 360 [106,31,4]
+  CRUSH rule 0 x 361 [27,56,21]
+  CRUSH rule 0 x 362 [28,55,15]
+  CRUSH rule 0 x 363 [45,60,19]
+  CRUSH rule 0 x 364 [23,2,17]
+  CRUSH rule 0 x 365 [24,21,35]
+  CRUSH rule 0 x 366 [14,100,33]
+  CRUSH rule 0 x 367 [103,82,13]
+  CRUSH rule 0 x 368 [103,17,44]
+  CRUSH rule 0 x 369 [37,11,94]
+  CRUSH rule 0 x 370 [11,65,76]
+  CRUSH rule 0 x 371 [34,65,15]
+  CRUSH rule 0 x 372 [58,23,9]
+  CRUSH rule 0 x 373 [98,22,47]
+  CRUSH rule 0 x 374 [110,89,13]
+  CRUSH rule 0 x 375 [19,76,49]
+  CRUSH rule 0 x 376 [22,98,63]
+  CRUSH rule 0 x 377 [98,87,21]
+  CRUSH rule 0 x 378 [67,58,14]
+  CRUSH rule 0 x 379 [77,94,7]
+  CRUSH rule 0 x 380 [69,108,14]
+  CRUSH rule 0 x 381 [55,106,13]
+  CRUSH rule 0 x 382 [26,83,13]
+  CRUSH rule 0 x 383 [48,93,22]
+  CRUSH rule 0 x 384 [15,0,59]
+  CRUSH rule 0 x 385 [82,27,15]
+  CRUSH rule 0 x 386 [108,25,15]
+  CRUSH rule 0 x 387 [70,14,91]
+  CRUSH rule 0 x 388 [5,37,11]
+  CRUSH rule 0 x 389 [14,67,1]
+  CRUSH rule 0 x 390 [68,77,8]
+  CRUSH rule 0 x 391 [113,105,19]
+  CRUSH rule 0 x 392 [72,13,39]
+  CRUSH rule 0 x 393 [115,21,97]
+  CRUSH rule 0 x 394 [38,17,49]
+  CRUSH rule 0 x 395 [0,65,3]
+  CRUSH rule 0 x 396 [59,116,4]
+  CRUSH rule 0 x 397 [87,90,11]
+  CRUSH rule 0 x 398 [44,51,7]
+  CRUSH rule 0 x 399 [9,113,65]
+  CRUSH rule 0 x 400 [101,100,11]
+  CRUSH rule 0 x 401 [79,52,8]
+  CRUSH rule 0 x 402 [107,110,8]
+  CRUSH rule 0 x 403 [23,92,13]
+  CRUSH rule 0 x 404 [76,31,13]
+  CRUSH rule 0 x 405 [10,48,8]
+  CRUSH rule 0 x 406 [38,29,4]
+  CRUSH rule 0 x 407 [70,25,11]
+  CRUSH rule 0 x 408 [55,104,22]
+  CRUSH rule 0 x 409 [102,6,23]
+  CRUSH rule 0 x 410 [59,8,92]
+  CRUSH rule 0 x 411 [34,49,15]
+  CRUSH rule 0 x 412 [108,105,7]
+  CRUSH rule 0 x 413 [54,37,13]
+  CRUSH rule 0 x 414 [70,3,10]
+  CRUSH rule 0 x 415 [107,0,6]
+  CRUSH rule 0 x 416 [79,24,22]
+  CRUSH rule 0 x 417 [8,23,36]
+  CRUSH rule 0 x 418 [51,114,9]
+  CRUSH rule 0 x 419 [117,55,8]
+  CRUSH rule 0 x 420 [109,71,17]
+  CRUSH rule 0 x 421 [114,17,75]
+  CRUSH rule 0 x 422 [109,14,55]
+  CRUSH rule 0 x 423 [59,0,9]
+  CRUSH rule 0 x 424 [71,84,3]
+  CRUSH rule 0 x 425 [101,50,14]
+  CRUSH rule 0 x 426 [47,88,7]
+  CRUSH rule 0 x 427 [86,45,17]
+  CRUSH rule 0 x 428 [68,31,6]
+  CRUSH rule 0 x 429 [76,13,59]
+  CRUSH rule 0 x 430 [9,117,97]
+  CRUSH rule 0 x 431 [105,66,17]
+  CRUSH rule 0 x 432 [46,91,13]
+  CRUSH rule 0 x 433 [6,77,1]
+  CRUSH rule 0 x 434 [64,59,7]
+  CRUSH rule 0 x 435 [16,2,15]
+  CRUSH rule 0 x 436 [89,102,3]
+  CRUSH rule 0 x 437 [29,78,14]
+  CRUSH rule 0 x 438 [105,56,7]
+  CRUSH rule 0 x 439 [29,68,22]
+  CRUSH rule 0 x 440 [38,7,63]
+  CRUSH rule 0 x 441 [112,57,6]
+  CRUSH rule 0 x 442 [55,18,22]
+  CRUSH rule 0 x 443 [44,37,3]
+  CRUSH rule 0 x 444 [11,49,60]
+  CRUSH rule 0 x 445 [19,114,59]
+  CRUSH rule 0 x 446 [40,43,22]
+  CRUSH rule 0 x 447 [100,43,17]
+  CRUSH rule 0 x 448 [7,26,55]
+  CRUSH rule 0 x 449 [67,13,66]
+  CRUSH rule 0 x 450 [117,97,17]
+  CRUSH rule 0 x 451 [93,118,11]
+  CRUSH rule 0 x 452 [70,37,8]
+  CRUSH rule 0 x 453 [82,55,8]
+  CRUSH rule 0 x 454 [53,28,22]
+  CRUSH rule 0 x 455 [91,34,19]
+  CRUSH rule 0 x 456 [17,55,104]
+  CRUSH rule 0 x 457 [113,103,13]
+  CRUSH rule 0 x 458 [119,41,9]
+  CRUSH rule 0 x 459 [25,104,8]
+  CRUSH rule 0 x 460 [11,55,119]
+  CRUSH rule 0 x 461 [21,5,39]
+  CRUSH rule 0 x 462 [25,72,8]
+  CRUSH rule 0 x 463 [6,57,80]
+  CRUSH rule 0 x 464 [19,50,91]
+  CRUSH rule 0 x 465 [29,7,5]
+  CRUSH rule 0 x 466 [66,89,9]
+  CRUSH rule 0 x 467 [27,32,15]
+  CRUSH rule 0 x 468 [97,118,3]
+  CRUSH rule 0 x 469 [98,71,22]
+  CRUSH rule 0 x 470 [50,29,3]
+  CRUSH rule 0 x 471 [40,31,13]
+  CRUSH rule 0 x 472 [74,61,19]
+  CRUSH rule 0 x 473 [95,98,14]
+  CRUSH rule 0 x 474 [51,8,32]
+  CRUSH rule 0 x 475 [3,25,117]
+  CRUSH rule 0 x 476 [110,55,15]
+  CRUSH rule 0 x 477 [25,74,14]
+  CRUSH rule 0 x 478 [19,57,38]
+  CRUSH rule 0 x 479 [70,91,8]
+  CRUSH rule 0 x 480 [62,33,3]
+  CRUSH rule 0 x 481 [26,3,75]
+  CRUSH rule 0 x 482 [84,6,29]
+  CRUSH rule 0 x 483 [36,55,7]
+  CRUSH rule 0 x 484 [37,28,7]
+  CRUSH rule 0 x 485 [84,14,47]
+  CRUSH rule 0 x 486 [92,61,11]
+  CRUSH rule 0 x 487 [106,53,17]
+  CRUSH rule 0 x 488 [42,7,55]
+  CRUSH rule 0 x 489 [76,31,13]
+  CRUSH rule 0 x 490 [68,107,22]
+  CRUSH rule 0 x 491 [80,57,3]
+  CRUSH rule 0 x 492 [21,71,113]
+  CRUSH rule 0 x 493 [99,44,6]
+  CRUSH rule 0 x 494 [4,59,98]
+  CRUSH rule 0 x 495 [40,87,17]
+  CRUSH rule 0 x 496 [13,106,71]
+  CRUSH rule 0 x 497 [102,81,9]
+  CRUSH rule 0 x 498 [68,73,21]
+  CRUSH rule 0 x 499 [22,28,107]
+  CRUSH rule 0 x 500 [50,6,81]
+  CRUSH rule 0 x 501 [60,103,19]
+  CRUSH rule 0 x 502 [11,1,45]
+  CRUSH rule 0 x 503 [117,85,4]
+  CRUSH rule 0 x 504 [90,55,9]
+  CRUSH rule 0 x 505 [91,94,3]
+  CRUSH rule 0 x 506 [82,89,21]
+  CRUSH rule 0 x 507 [6,77,54]
+  CRUSH rule 0 x 508 [34,77,13]
+  CRUSH rule 0 x 509 [88,43,3]
+  CRUSH rule 0 x 510 [11,69,100]
+  CRUSH rule 0 x 511 [72,47,11]
+  CRUSH rule 0 x 512 [118,101,4]
+  CRUSH rule 0 x 513 [22,80,10]
+  CRUSH rule 0 x 514 [82,21,69]
+  CRUSH rule 0 x 515 [27,38,21]
+  CRUSH rule 0 x 516 [66,61,19]
+  CRUSH rule 0 x 517 [83,4,44]
+  CRUSH rule 0 x 518 [18,13,107]
+  CRUSH rule 0 x 519 [67,52,7]
+  CRUSH rule 0 x 520 [15,88,27]
+  CRUSH rule 0 x 521 [63,62,22]
+  CRUSH rule 0 x 522 [4,51,118]
+  CRUSH rule 0 x 523 [36,23,3]
+  CRUSH rule 0 x 524 [33,94,4]
+  CRUSH rule 0 x 525 [63,104,7]
+  CRUSH rule 0 x 526 [83,118,3]
+  CRUSH rule 0 x 527 [37,5,9]
+  CRUSH rule 0 x 528 [108,43,15]
+  CRUSH rule 0 x 529 [107,7,60]
+  CRUSH rule 0 x 530 [49,11,80]
+  CRUSH rule 0 x 531 [27,82,22]
+  CRUSH rule 0 x 532 [68,89,21]
+  CRUSH rule 0 x 533 [5,73,15]
+  CRUSH rule 0 x 534 [97,104,3]
+  CRUSH rule 0 x 535 [48,41,14]
+  CRUSH rule 0 x 536 [3,71,52]
+  CRUSH rule 0 x 537 [116,7,83]
+  CRUSH rule 0 x 538 [85,3,56]
+  CRUSH rule 0 x 539 [10,82,4]
+  CRUSH rule 0 x 540 [100,31,4]
+  CRUSH rule 0 x 541 [111,67,21]
+  CRUSH rule 0 x 542 [50,103,9]
+  CRUSH rule 0 x 543 [45,21,113]
+  CRUSH rule 0 x 544 [106,67,14]
+  CRUSH rule 0 x 545 [43,86,8]
+  CRUSH rule 0 x 546 [108,49,3]
+  CRUSH rule 0 x 547 [27,18,6]
+  CRUSH rule 0 x 548 [53,66,4]
+  CRUSH rule 0 x 549 [60,89,6]
+  CRUSH rule 0 x 550 [47,62,21]
+  CRUSH rule 0 x 551 [14,52,71]
+  CRUSH rule 0 x 552 [70,10,17]
+  CRUSH rule 0 x 553 [96,73,8]
+  CRUSH rule 0 x 554 [61,70,7]
+  CRUSH rule 0 x 555 [76,69,9]
+  CRUSH rule 0 x 556 [106,10,22]
+  CRUSH rule 0 x 557 [39,58,11]
+  CRUSH rule 0 x 558 [70,93,14]
+  CRUSH rule 0 x 559 [106,23,21]
+  CRUSH rule 0 x 560 [94,16,8]
+  CRUSH rule 0 x 561 [27,68,6]
+  CRUSH rule 0 x 562 [97,112,15]
+  CRUSH rule 0 x 563 [64,61,21]
+  CRUSH rule 0 x 564 [96,59,8]
+  CRUSH rule 0 x 565 [66,69,3]
+  CRUSH rule 0 x 566 [27,86,11]
+  CRUSH rule 0 x 567 [88,4,25]
+  CRUSH rule 0 x 568 [17,96,69]
+  CRUSH rule 0 x 569 [102,29,11]
+  CRUSH rule 0 x 570 [7,103,5]
+  CRUSH rule 0 x 571 [95,110,11]
+  CRUSH rule 0 x 572 [62,33,3]
+  CRUSH rule 0 x 573 [51,46,6]
+  CRUSH rule 0 x 574 [89,64,17]
+  CRUSH rule 0 x 575 [19,53,113]
+  CRUSH rule 0 x 576 [112,87,14]
+  CRUSH rule 0 x 577 [8,113,63]
+  CRUSH rule 0 x 578 [64,3,35]
+  CRUSH rule 0 x 579 [78,37,3]
+  CRUSH rule 0 x 580 [68,35,8]
+  CRUSH rule 0 x 581 [55,113,7]
+  CRUSH rule 0 x 582 [27,19,38]
+  CRUSH rule 0 x 583 [74,99,22]
+  CRUSH rule 0 x 584 [72,53,21]
+  CRUSH rule 0 x 585 [88,79,22]
+  CRUSH rule 0 x 586 [33,1,4]
+  CRUSH rule 0 x 587 [106,53,14]
+  CRUSH rule 0 x 588 [0,45,17]
+  CRUSH rule 0 x 589 [7,85,112]
+  CRUSH rule 0 x 590 [59,40,11]
+  CRUSH rule 0 x 591 [42,43,14]
+  CRUSH rule 0 x 592 [45,110,17]
+  CRUSH rule 0 x 593 [89,14,114]
+  CRUSH rule 0 x 594 [27,76,22]
+  CRUSH rule 0 x 595 [7,10,117]
+  CRUSH rule 0 x 596 [82,41,13]
+  CRUSH rule 0 x 597 [72,97,6]
+  CRUSH rule 0 x 598 [34,17,65]
+  CRUSH rule 0 x 599 [119,53,15]
+  CRUSH rule 0 x 600 [9,36,69]
+  CRUSH rule 0 x 601 [104,21,87]
+  CRUSH rule 0 x 602 [48,39,7]
+  CRUSH rule 0 x 603 [24,11,89]
+  CRUSH rule 0 x 604 [89,82,7]
+  CRUSH rule 0 x 605 [104,63,9]
+  CRUSH rule 0 x 606 [49,58,4]
+  CRUSH rule 0 x 607 [95,72,19]
+  CRUSH rule 0 x 608 [49,48,19]
+  CRUSH rule 0 x 609 [61,70,3]
+  CRUSH rule 0 x 610 [106,73,11]
+  CRUSH rule 0 x 611 [66,37,17]
+  CRUSH rule 0 x 612 [103,84,3]
+  CRUSH rule 0 x 613 [84,57,9]
+  CRUSH rule 0 x 614 [81,9,88]
+  CRUSH rule 0 x 615 [61,9,109]
+  CRUSH rule 0 x 616 [41,8,119]
+  CRUSH rule 0 x 617 [111,81,4]
+  CRUSH rule 0 x 618 [3,39,104]
+  CRUSH rule 0 x 619 [92,31,11]
+  CRUSH rule 0 x 620 [108,31,11]
+  CRUSH rule 0 x 621 [106,57,3]
+  CRUSH rule 0 x 622 [67,102,7]
+  CRUSH rule 0 x 623 [94,7,93]
+  CRUSH rule 0 x 624 [115,29,13]
+  CRUSH rule 0 x 625 [111,67,21]
+  CRUSH rule 0 x 626 [3,25,40]
+  CRUSH rule 0 x 627 [19,105,56]
+  CRUSH rule 0 x 628 [65,100,9]
+  CRUSH rule 0 x 629 [119,15,65]
+  CRUSH rule 0 x 630 [109,4,91]
+  CRUSH rule 0 x 631 [48,33,17]
+  CRUSH rule 0 x 632 [81,60,14]
+  CRUSH rule 0 x 633 [65,110,9]
+  CRUSH rule 0 x 634 [87,50,14]
+  CRUSH rule 0 x 635 [107,9,104]
+  CRUSH rule 0 x 636 [23,66,9]
+  CRUSH rule 0 x 637 [102,29,4]
+  CRUSH rule 0 x 638 [43,4,109]
+  CRUSH rule 0 x 639 [31,76,9]
+  CRUSH rule 0 x 640 [113,87,7]
+  CRUSH rule 0 x 641 [45,58,7]
+  CRUSH rule 0 x 642 [47,17,102]
+  CRUSH rule 0 x 643 [64,97,7]
+  CRUSH rule 0 x 644 [31,4,94]
+  CRUSH rule 0 x 645 [76,13,31]
+  CRUSH rule 0 x 646 [37,86,15]
+  CRUSH rule 0 x 647 [58,101,21]
+  CRUSH rule 0 x 648 [31,9,56]
+  CRUSH rule 0 x 649 [88,39,15]
+  CRUSH rule 0 x 650 [116,19,71]
+  CRUSH rule 0 x 651 [97,116,22]
+  CRUSH rule 0 x 652 [57,28,19]
+  CRUSH rule 0 x 653 [38,95,21]
+  CRUSH rule 0 x 654 [49,92,9]
+  CRUSH rule 0 x 655 [89,54,11]
+  CRUSH rule 0 x 656 [0,89,4]
+  CRUSH rule 0 x 657 [47,18,19]
+  CRUSH rule 0 x 658 [75,32,17]
+  CRUSH rule 0 x 659 [26,33,14]
+  CRUSH rule 0 x 660 [65,82,21]
+  CRUSH rule 0 x 661 [91,76,17]
+  CRUSH rule 0 x 662 [111,73,6]
+  CRUSH rule 0 x 663 [88,67,3]
+  CRUSH rule 0 x 664 [59,52,15]
+  CRUSH rule 0 x 665 [78,7,59]
+  CRUSH rule 0 x 666 [112,8,31]
+  CRUSH rule 0 x 667 [97,80,6]
+  CRUSH rule 0 x 668 [97,22,92]
+  CRUSH rule 0 x 669 [85,0,6]
+  CRUSH rule 0 x 670 [41,62,7]
+  CRUSH rule 0 x 671 [116,37,7]
+  CRUSH rule 0 x 672 [44,67,22]
+  CRUSH rule 0 x 673 [83,116,9]
+  CRUSH rule 0 x 674 [59,98,14]
+  CRUSH rule 0 x 675 [88,17,83]
+  CRUSH rule 0 x 676 [62,4,75]
+  CRUSH rule 0 x 677 [88,105,3]
+  CRUSH rule 0 x 678 [98,57,3]
+  CRUSH rule 0 x 679 [70,61,9]
+  CRUSH rule 0 x 680 [55,5,14]
+  CRUSH rule 0 x 681 [53,68,3]
+  CRUSH rule 0 x 682 [27,78,7]
+  CRUSH rule 0 x 683 [57,118,11]
+  CRUSH rule 0 x 684 [98,45,22]
+  CRUSH rule 0 x 685 [106,25,3]
+  CRUSH rule 0 x 686 [86,45,6]
+  CRUSH rule 0 x 687 [49,102,15]
+  CRUSH rule 0 x 688 [16,52,7]
+  CRUSH rule 0 x 689 [6,112,59]
+  CRUSH rule 0 x 690 [43,17,48]
+  CRUSH rule 0 x 691 [34,99,8]
+  CRUSH rule 0 x 692 [40,67,8]
+  CRUSH rule 0 x 693 [29,118,22]
+  CRUSH rule 0 x 694 [6,75,84]
+  CRUSH rule 0 x 695 [31,72,7]
+  CRUSH rule 0 x 696 [36,3,16]
+  CRUSH rule 0 x 697 [96,99,11]
+  CRUSH rule 0 x 698 [61,100,4]
+  CRUSH rule 0 x 699 [47,60,15]
+  CRUSH rule 0 x 700 [0,93,15]
+  CRUSH rule 0 x 701 [42,21,105]
+  CRUSH rule 0 x 702 [0,105,21]
+  CRUSH rule 0 x 703 [92,29,13]
+  CRUSH rule 0 x 704 [10,8,109]
+  CRUSH rule 0 x 705 [105,0,6]
+  CRUSH rule 0 x 706 [74,10,13]
+  CRUSH rule 0 x 707 [0,91,14]
+  CRUSH rule 0 x 708 [84,21,89]
+  CRUSH rule 0 x 709 [114,23,8]
+  CRUSH rule 0 x 710 [94,19,35]
+  CRUSH rule 0 x 711 [68,41,6]
+  CRUSH rule 0 x 712 [34,71,11]
+  CRUSH rule 0 x 713 [29,2,19]
+  CRUSH rule 0 x 714 [81,80,17]
+  CRUSH rule 0 x 715 [71,62,13]
+  CRUSH rule 0 x 716 [40,6,37]
+  CRUSH rule 0 x 717 [61,60,9]
+  CRUSH rule 0 x 718 [40,69,15]
+  CRUSH rule 0 x 719 [59,74,21]
+  CRUSH rule 0 x 720 [69,2,22]
+  CRUSH rule 0 x 721 [62,75,6]
+  CRUSH rule 0 x 722 [115,19,95]
+  CRUSH rule 0 x 723 [117,25,21]
+  CRUSH rule 0 x 724 [45,3,26]
+  CRUSH rule 0 x 725 [53,110,19]
+  CRUSH rule 0 x 726 [84,107,8]
+  CRUSH rule 0 x 727 [109,19,107]
+  CRUSH rule 0 x 728 [76,65,6]
+  CRUSH rule 0 x 729 [108,7,47]
+  CRUSH rule 0 x 730 [28,37,21]
+  CRUSH rule 0 x 731 [78,41,6]
+  CRUSH rule 0 x 732 [55,112,11]
+  CRUSH rule 0 x 733 [84,7,67]
+  CRUSH rule 0 x 734 [27,110,8]
+  CRUSH rule 0 x 735 [83,62,17]
+  CRUSH rule 0 x 736 [70,67,14]
+  CRUSH rule 0 x 737 [117,11,99]
+  CRUSH rule 0 x 738 [118,95,17]
+  CRUSH rule 0 x 739 [87,1,17]
+  CRUSH rule 0 x 740 [29,92,13]
+  CRUSH rule 0 x 741 [96,49,19]
+  CRUSH rule 0 x 742 [106,31,14]
+  CRUSH rule 0 x 743 [105,5,9]
+  CRUSH rule 0 x 744 [23,64,6]
+  CRUSH rule 0 x 745 [28,85,21]
+  CRUSH rule 0 x 746 [18,47,6]
+  CRUSH rule 0 x 747 [65,108,14]
+  CRUSH rule 0 x 748 [48,25,21]
+  CRUSH rule 0 x 749 [102,71,19]
+  CRUSH rule 0 x 750 [50,77,13]
+  CRUSH rule 0 x 751 [36,29,11]
+  CRUSH rule 0 x 752 [69,119,9]
+  CRUSH rule 0 x 753 [9,34,83]
+  CRUSH rule 0 x 754 [9,39,52]
+  CRUSH rule 0 x 755 [98,45,17]
+  CRUSH rule 0 x 756 [113,83,4]
+  CRUSH rule 0 x 757 [47,112,21]
+  CRUSH rule 0 x 758 [57,84,17]
+  CRUSH rule 0 x 759 [74,65,9]
+  CRUSH rule 0 x 760 [53,34,9]
+  CRUSH rule 0 x 761 [78,105,19]
+  CRUSH rule 0 x 762 [87,13,94]
+  CRUSH rule 0 x 763 [13,16,98]
+  CRUSH rule 0 x 764 [106,27,22]
+  CRUSH rule 0 x 765 [109,77,17]
+  CRUSH rule 0 x 766 [76,105,13]
+  CRUSH rule 0 x 767 [41,80,11]
+  CRUSH rule 0 x 768 [13,50,71]
+  CRUSH rule 0 x 769 [91,96,9]
+  CRUSH rule 0 x 770 [105,62,17]
+  CRUSH rule 0 x 771 [10,28,4]
+  CRUSH rule 0 x 772 [8,102,31]
+  CRUSH rule 0 x 773 [116,91,7]
+  CRUSH rule 0 x 774 [100,105,22]
+  CRUSH rule 0 x 775 [15,61,18]
+  CRUSH rule 0 x 776 [69,44,15]
+  CRUSH rule 0 x 777 [76,23,4]
+  CRUSH rule 0 x 778 [38,9,16]
+  CRUSH rule 0 x 779 [46,17,79]
+  CRUSH rule 0 x 780 [63,70,8]
+  CRUSH rule 0 x 781 [19,16,108]
+  CRUSH rule 0 x 782 [117,59,21]
+  CRUSH rule 0 x 783 [60,25,7]
+  CRUSH rule 0 x 784 [82,81,3]
+  CRUSH rule 0 x 785 [27,50,11]
+  CRUSH rule 0 x 786 [41,90,15]
+  CRUSH rule 0 x 787 [13,34,95]
+  CRUSH rule 0 x 788 [4,113,103]
+  CRUSH rule 0 x 789 [50,51,4]
+  CRUSH rule 0 x 790 [58,95,7]
+  CRUSH rule 0 x 791 [96,37,14]
+  CRUSH rule 0 x 792 [45,13,82]
+  CRUSH rule 0 x 793 [6,103,26]
+  CRUSH rule 0 x 794 [14,61,108]
+  CRUSH rule 0 x 795 [51,26,14]
+  CRUSH rule 0 x 796 [114,43,6]
+  CRUSH rule 0 x 797 [79,115,3]
+  CRUSH rule 0 x 798 [42,19,69]
+  CRUSH rule 0 x 799 [48,41,6]
+  CRUSH rule 0 x 800 [91,22,38]
+  CRUSH rule 0 x 801 [2,11,57]
+  CRUSH rule 0 x 802 [116,19,71]
+  CRUSH rule 0 x 803 [37,46,15]
+  CRUSH rule 0 x 804 [6,93,40]
+  CRUSH rule 0 x 805 [96,3,49]
+  CRUSH rule 0 x 806 [67,110,22]
+  CRUSH rule 0 x 807 [47,92,4]
+  CRUSH rule 0 x 808 [76,31,9]
+  CRUSH rule 0 x 809 [27,90,13]
+  CRUSH rule 0 x 810 [119,35,9]
+  CRUSH rule 0 x 811 [75,84,14]
+  CRUSH rule 0 x 812 [25,94,4]
+  CRUSH rule 0 x 813 [64,27,13]
+  CRUSH rule 0 x 814 [110,29,13]
+  CRUSH rule 0 x 815 [84,39,4]
+  CRUSH rule 0 x 816 [25,3,38]
+  CRUSH rule 0 x 817 [40,57,22]
+  CRUSH rule 0 x 818 [34,16,13]
+  CRUSH rule 0 x 819 [88,15,75]
+  CRUSH rule 0 x 820 [104,29,9]
+  CRUSH rule 0 x 821 [58,16,11]
+  CRUSH rule 0 x 822 [29,98,8]
+  CRUSH rule 0 x 823 [100,37,17]
+  CRUSH rule 0 x 824 [102,95,22]
+  CRUSH rule 0 x 825 [47,14,26]
+  CRUSH rule 0 x 826 [45,8,34]
+  CRUSH rule 0 x 827 [101,19,70]
+  CRUSH rule 0 x 828 [60,27,14]
+  CRUSH rule 0 x 829 [45,102,17]
+  CRUSH rule 0 x 830 [51,0,21]
+  CRUSH rule 0 x 831 [6,64,53]
+  CRUSH rule 0 x 832 [57,116,19]
+  CRUSH rule 0 x 833 [34,105,9]
+  CRUSH rule 0 x 834 [90,77,13]
+  CRUSH rule 0 x 835 [55,50,11]
+  CRUSH rule 0 x 836 [38,51,3]
+  CRUSH rule 0 x 837 [51,78,14]
+  CRUSH rule 0 x 838 [6,98,35]
+  CRUSH rule 0 x 839 [106,15,31]
+  CRUSH rule 0 x 840 [33,117,13]
+  CRUSH rule 0 x 841 [110,13,55]
+  CRUSH rule 0 x 842 [66,83,17]
+  CRUSH rule 0 x 843 [62,107,22]
+  CRUSH rule 0 x 844 [74,22,57]
+  CRUSH rule 0 x 845 [74,63,22]
+  CRUSH rule 0 x 846 [98,41,19]
+  CRUSH rule 0 x 847 [10,90,13]
+  CRUSH rule 0 x 848 [89,19,52]
+  CRUSH rule 0 x 849 [42,61,17]
+  CRUSH rule 0 x 850 [40,87,6]
+  CRUSH rule 0 x 851 [65,11,86]
+  CRUSH rule 0 x 852 [31,100,9]
+  CRUSH rule 0 x 853 [49,11,80]
+  CRUSH rule 0 x 854 [83,92,21]
+  CRUSH rule 0 x 855 [2,22,101]
+  CRUSH rule 0 x 856 [6,41,86]
+  CRUSH rule 0 x 857 [15,110,99]
+  CRUSH rule 0 x 858 [10,114,19]
+  CRUSH rule 0 x 859 [14,41,88]
+  CRUSH rule 0 x 860 [114,93,8]
+  CRUSH rule 0 x 861 [1,105,14]
+  CRUSH rule 0 x 862 [22,27,86]
+  CRUSH rule 0 x 863 [79,50,19]
+  CRUSH rule 0 x 864 [68,19,57]
+  CRUSH rule 0 x 865 [25,68,14]
+  CRUSH rule 0 x 866 [18,85,11]
+  CRUSH rule 0 x 867 [53,58,13]
+  CRUSH rule 0 x 868 [81,0,11]
+  CRUSH rule 0 x 869 [111,22,73]
+  CRUSH rule 0 x 870 [73,94,9]
+  CRUSH rule 0 x 871 [25,64,7]
+  CRUSH rule 0 x 872 [39,2,11]
+  CRUSH rule 0 x 873 [92,6,41]
+  CRUSH rule 0 x 874 [96,17,31]
+  CRUSH rule 0 x 875 [115,27,15]
+  CRUSH rule 0 x 876 [98,16,8]
+  CRUSH rule 0 x 877 [73,46,9]
+  CRUSH rule 0 x 878 [64,45,8]
+  CRUSH rule 0 x 879 [15,1,59]
+  CRUSH rule 0 x 880 [56,105,15]
+  CRUSH rule 0 x 881 [109,97,11]
+  CRUSH rule 0 x 882 [60,79,15]
+  CRUSH rule 0 x 883 [93,17,82]
+  CRUSH rule 0 x 884 [67,36,19]
+  CRUSH rule 0 x 885 [31,104,22]
+  CRUSH rule 0 x 886 [2,7,27]
+  CRUSH rule 0 x 887 [5,9,45]
+  CRUSH rule 0 x 888 [16,22,70]
+  CRUSH rule 0 x 889 [27,2,7]
+  CRUSH rule 0 x 890 [48,47,15]
+  CRUSH rule 0 x 891 [86,59,8]
+  CRUSH rule 0 x 892 [64,91,4]
+  CRUSH rule 0 x 893 [118,7,33]
+  CRUSH rule 0 x 894 [16,94,8]
+  CRUSH rule 0 x 895 [40,101,3]
+  CRUSH rule 0 x 896 [97,119,17]
+  CRUSH rule 0 x 897 [107,80,19]
+  CRUSH rule 0 x 898 [10,88,15]
+  CRUSH rule 0 x 899 [75,1,7]
+  CRUSH rule 0 x 900 [102,55,19]
+  CRUSH rule 0 x 901 [66,61,9]
+  CRUSH rule 0 x 902 [102,10,7]
+  CRUSH rule 0 x 903 [5,33,7]
+  CRUSH rule 0 x 904 [50,10,22]
+  CRUSH rule 0 x 905 [99,5,13]
+  CRUSH rule 0 x 906 [75,119,22]
+  CRUSH rule 0 x 907 [47,34,9]
+  CRUSH rule 0 x 908 [96,73,19]
+  CRUSH rule 0 x 909 [94,87,13]
+  CRUSH rule 0 x 910 [88,57,4]
+  CRUSH rule 0 x 911 [102,43,21]
+  CRUSH rule 0 x 912 [91,111,9]
+  CRUSH rule 0 x 913 [29,21,34]
+  CRUSH rule 0 x 914 [84,19,29]
+  CRUSH rule 0 x 915 [70,43,14]
+  CRUSH rule 0 x 916 [32,7,81]
+  CRUSH rule 0 x 917 [43,102,13]
+  CRUSH rule 0 x 918 [91,26,11]
+  CRUSH rule 0 x 919 [13,51,28]
+  CRUSH rule 0 x 920 [18,13,10]
+  CRUSH rule 0 x 921 [104,8,65]
+  CRUSH rule 0 x 922 [33,96,11]
+  CRUSH rule 0 x 923 [28,15,27]
+  CRUSH rule 0 x 924 [69,76,3]
+  CRUSH rule 0 x 925 [71,104,15]
+  CRUSH rule 0 x 926 [64,65,11]
+  CRUSH rule 0 x 927 [99,6,76]
+  CRUSH rule 0 x 928 [13,94,65]
+  CRUSH rule 0 x 929 [117,95,6]
+  CRUSH rule 0 x 930 [31,111,4]
+  CRUSH rule 0 x 931 [83,64,6]
+  CRUSH rule 0 x 932 [60,21,35]
+  CRUSH rule 0 x 933 [63,113,13]
+  CRUSH rule 0 x 934 [68,21,51]
+  CRUSH rule 0 x 935 [31,46,13]
+  CRUSH rule 0 x 936 [65,116,21]
+  CRUSH rule 0 x 937 [110,65,6]
+  CRUSH rule 0 x 938 [29,98,4]
+  CRUSH rule 0 x 939 [77,11,42]
+  CRUSH rule 0 x 940 [76,19,49]
+  CRUSH rule 0 x 941 [66,10,22]
+  CRUSH rule 0 x 942 [83,32,8]
+  CRUSH rule 0 x 943 [32,9,75]
+  CRUSH rule 0 x 944 [113,7,47]
+  CRUSH rule 0 x 945 [71,111,22]
+  CRUSH rule 0 x 946 [37,42,17]
+  CRUSH rule 0 x 947 [107,48,7]
+  CRUSH rule 0 x 948 [55,24,13]
+  CRUSH rule 0 x 949 [11,109,75]
+  CRUSH rule 0 x 950 [96,33,14]
+  CRUSH rule 0 x 951 [40,63,7]
+  CRUSH rule 0 x 952 [93,5,21]
+  CRUSH rule 0 x 953 [55,28,7]
+  CRUSH rule 0 x 954 [84,83,4]
+  CRUSH rule 0 x 955 [31,90,9]
+  CRUSH rule 0 x 956 [72,6,91]
+  CRUSH rule 0 x 957 [3,88,16]
+  CRUSH rule 0 x 958 [23,74,14]
+  CRUSH rule 0 x 959 [42,93,15]
+  CRUSH rule 0 x 960 [113,91,19]
+  CRUSH rule 0 x 961 [116,4,89]
+  CRUSH rule 0 x 962 [13,52,10]
+  CRUSH rule 0 x 963 [0,83,13]
+  CRUSH rule 0 x 964 [59,44,15]
+  CRUSH rule 0 x 965 [47,102,22]
+  CRUSH rule 0 x 966 [88,69,22]
+  CRUSH rule 0 x 967 [71,17,108]
+  CRUSH rule 0 x 968 [73,9,108]
+  CRUSH rule 0 x 969 [53,21,111]
+  CRUSH rule 0 x 970 [111,85,17]
+  CRUSH rule 0 x 971 [87,19,38]
+  CRUSH rule 0 x 972 [5,33,19]
+  CRUSH rule 0 x 973 [113,81,7]
+  CRUSH rule 0 x 974 [49,86,6]
+  CRUSH rule 0 x 975 [83,96,17]
+  CRUSH rule 0 x 976 [81,100,8]
+  CRUSH rule 0 x 977 [95,76,22]
+  CRUSH rule 0 x 978 [35,4,94]
+  CRUSH rule 0 x 979 [98,13,41]
+  CRUSH rule 0 x 980 [52,93,21]
+  CRUSH rule 0 x 981 [89,46,14]
+  CRUSH rule 0 x 982 [1,95,9]
+  CRUSH rule 0 x 983 [34,37,9]
+  CRUSH rule 0 x 984 [78,23,8]
+  CRUSH rule 0 x 985 [99,24,15]
+  CRUSH rule 0 x 986 [4,33,76]
+  CRUSH rule 0 x 987 [78,22,53]
+  CRUSH rule 0 x 988 [79,84,17]
+  CRUSH rule 0 x 989 [87,6,86]
+  CRUSH rule 0 x 990 [47,46,22]
+  CRUSH rule 0 x 991 [61,18,15]
+  CRUSH rule 0 x 992 [83,111,9]
+  CRUSH rule 0 x 993 [74,27,22]
+  CRUSH rule 0 x 994 [74,105,17]
+  CRUSH rule 0 x 995 [100,45,21]
+  CRUSH rule 0 x 996 [41,22,58]
+  CRUSH rule 0 x 997 [89,32,6]
+  CRUSH rule 0 x 998 [92,65,7]
+  CRUSH rule 0 x 999 [117,13,10]
+  CRUSH rule 0 x 1000 [9,48,85]
+  CRUSH rule 0 x 1001 [49,109,11]
+  CRUSH rule 0 x 1002 [99,106,17]
+  CRUSH rule 0 x 1003 [43,22,88]
+  CRUSH rule 0 x 1004 [89,106,9]
+  CRUSH rule 0 x 1005 [105,44,14]
+  CRUSH rule 0 x 1006 [45,5,14]
+  CRUSH rule 0 x 1007 [19,67,66]
+  CRUSH rule 0 x 1008 [31,3,76]
+  CRUSH rule 0 x 1009 [19,108,65]
+  CRUSH rule 0 x 1010 [42,67,19]
+  CRUSH rule 0 x 1011 [25,113,19]
+  CRUSH rule 0 x 1012 [68,81,13]
+  CRUSH rule 0 x 1013 [5,93,21]
+  CRUSH rule 0 x 1014 [33,8,88]
+  CRUSH rule 0 x 1015 [14,99,50]
+  CRUSH rule 0 x 1016 [88,6,25]
+  CRUSH rule 0 x 1017 [0,61,22]
+  CRUSH rule 0 x 1018 [63,26,9]
+  CRUSH rule 0 x 1019 [104,61,15]
+  CRUSH rule 0 x 1020 [96,83,14]
+  CRUSH rule 0 x 1021 [117,35,6]
+  CRUSH rule 0 x 1022 [73,6,36]
+  CRUSH rule 0 x 1023 [0,83,7]
+  rule 0 (data) num_rep 10 result size == 3:\t1024/1024 (esc)
diff --git a/src/test/cli/osdmaptool/crush.t b/src/test/cli/osdmaptool/crush.t
index 6be1743..d2f27ef 100644
--- a/src/test/cli/osdmaptool/crush.t
+++ b/src/test/cli/osdmaptool/crush.t
@@ -6,5 +6,5 @@
   osdmaptool: exported crush map to oc
   $ osdmaptool --import-crush oc myosdmap
   osdmaptool: osdmap file 'myosdmap'
-  osdmaptool: imported 491 byte crush map from oc
+  osdmaptool: imported 492 byte crush map from oc
   osdmaptool: writing epoch 3 to myosdmap
diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t
index 0b0f900..c233f61 100644
--- a/src/test/cli/radosgw-admin/help.t
+++ b/src/test/cli/radosgw-admin/help.t
@@ -44,6 +44,8 @@
     log list                   list log objects
     log show                   dump a log from specific object or (bucket + date
                                + bucket-id)
+                               (NOTE: required to specify formatting of date
+                               to "YYYY-MM-DD-hh")
     log rm                     remove log object
     usage show                 show usage (by user, date range)
     usage trim                 trim usage (by user, date range)
diff --git a/src/test/common/Throttle.cc b/src/test/common/Throttle.cc
index dc2d248..bd30471 100644
--- a/src/test/common/Throttle.cc
+++ b/src/test/common/Throttle.cc
@@ -37,13 +37,13 @@ protected:
     int64_t count;
     bool waited;
 
-    Thread_get(Throttle& _throttle, int64_t _count) : 
+    Thread_get(Throttle& _throttle, int64_t _count) :
       throttle(_throttle),
       count(_count),
       waited(false)
     {
     }
-    
+
     virtual void *entry() {
       waited = throttle.get(count);
       throttle.put(count);
@@ -54,9 +54,9 @@ protected:
 };
 
 TEST_F(ThrottleTest, Throttle) {
-  ASSERT_THROW({
+  ASSERT_DEATH({
       Throttle throttle(g_ceph_context, "throttle", -1);
-    }, FailedAssertion);
+    }, "");
 
   int64_t throttle_max = 10;
   Throttle throttle(g_ceph_context, "throttle", throttle_max);
@@ -67,7 +67,7 @@ TEST_F(ThrottleTest, Throttle) {
 TEST_F(ThrottleTest, take) {
   int64_t throttle_max = 10;
   Throttle throttle(g_ceph_context, "throttle", throttle_max);
-  ASSERT_THROW(throttle.take(-1), FailedAssertion);
+  ASSERT_DEATH(throttle.take(-1), "");
   ASSERT_EQ(throttle.take(throttle_max), throttle_max);
   ASSERT_EQ(throttle.take(throttle_max), throttle_max * 2);
 }
@@ -83,18 +83,18 @@ TEST_F(ThrottleTest, get) {
     ASSERT_EQ(throttle.put(throttle_max), 0);
   }
 
-  ASSERT_THROW(throttle.get(-1), FailedAssertion);
-  ASSERT_FALSE(throttle.get(5)); 
-  ASSERT_EQ(throttle.put(5), 0); 
+  ASSERT_DEATH(throttle.get(-1), "");
+  ASSERT_FALSE(throttle.get(5));
+  ASSERT_EQ(throttle.put(5), 0);
 
-  ASSERT_FALSE(throttle.get(throttle_max)); 
-  ASSERT_FALSE(throttle.get_or_fail(1)); 
-  ASSERT_FALSE(throttle.get(1, throttle_max + 1)); 
-  ASSERT_EQ(throttle.put(throttle_max + 1), 0); 
-  ASSERT_FALSE(throttle.get(0, throttle_max)); 
-  ASSERT_FALSE(throttle.get(throttle_max)); 
-  ASSERT_FALSE(throttle.get_or_fail(1)); 
-  ASSERT_EQ(throttle.put(throttle_max), 0); 
+  ASSERT_FALSE(throttle.get(throttle_max));
+  ASSERT_FALSE(throttle.get_or_fail(1));
+  ASSERT_FALSE(throttle.get(1, throttle_max + 1));
+  ASSERT_EQ(throttle.put(throttle_max + 1), 0);
+  ASSERT_FALSE(throttle.get(0, throttle_max));
+  ASSERT_FALSE(throttle.get(throttle_max));
+  ASSERT_FALSE(throttle.get_or_fail(1));
+  ASSERT_EQ(throttle.put(throttle_max), 0);
 
   useconds_t delay = 1;
 
@@ -103,31 +103,31 @@ TEST_F(ThrottleTest, get) {
   do {
     cout << "Trying (1) with delay " << delay << "us\n";
 
-    ASSERT_FALSE(throttle.get(throttle_max)); 
-    ASSERT_FALSE(throttle.get_or_fail(throttle_max));  
+    ASSERT_FALSE(throttle.get(throttle_max));
+    ASSERT_FALSE(throttle.get_or_fail(throttle_max));
 
     Thread_get t(throttle, 7);
-    t.create();
+    t.create("t_throttle_1");
     usleep(delay);
-    ASSERT_EQ(throttle.put(throttle_max), 0); 
+    ASSERT_EQ(throttle.put(throttle_max), 0);
     t.join();
 
     if (!(waited = t.waited))
       delay *= 2;
   } while(!waited);
-	  
+
   do {
     cout << "Trying (2) with delay " << delay << "us\n";
 
     ASSERT_FALSE(throttle.get(throttle_max / 2));
-    ASSERT_FALSE(throttle.get_or_fail(throttle_max));  
+    ASSERT_FALSE(throttle.get_or_fail(throttle_max));
 
     Thread_get t(throttle, throttle_max);
-    t.create();
+    t.create("t_throttle_2");
     usleep(delay);
 
     Thread_get u(throttle, 1);
-    u.create();
+    u.create("u_throttle_2");
     usleep(delay);
 
     throttle.put(throttle_max / 2);
@@ -138,13 +138,13 @@ TEST_F(ThrottleTest, get) {
     if (!(waited = t.waited && u.waited))
       delay *= 2;
   } while(!waited);
-	  
+
 }
 
 TEST_F(ThrottleTest, get_or_fail) {
   {
     Throttle throttle(g_ceph_context, "throttle");
-    
+
     ASSERT_TRUE(throttle.get_or_fail(5));
     ASSERT_TRUE(throttle.get_or_fail(5));
   }
@@ -161,8 +161,8 @@ TEST_F(ThrottleTest, get_or_fail) {
     ASSERT_FALSE(throttle.get_or_fail(throttle_max * 2));
     ASSERT_EQ(throttle.put(throttle_max * 2), 0);
 
-    ASSERT_TRUE(throttle.get_or_fail(throttle_max));  
-    ASSERT_FALSE(throttle.get_or_fail(1));  
+    ASSERT_TRUE(throttle.get_or_fail(throttle_max));
+    ASSERT_FALSE(throttle.get_or_fail(1));
     ASSERT_EQ(throttle.put(throttle_max), 0);
   }
 }
@@ -185,16 +185,16 @@ TEST_F(ThrottleTest, wait) {
     cout << "Trying (3) with delay " << delay << "us\n";
 
     ASSERT_FALSE(throttle.get(throttle_max / 2));
-    ASSERT_FALSE(throttle.get_or_fail(throttle_max));  
+    ASSERT_FALSE(throttle.get_or_fail(throttle_max));
 
     Thread_get t(throttle, throttle_max);
-    t.create();
+    t.create("t_throttle_3");
     usleep(delay);
 
     //
     // Throttle::_reset_max(int64_t m) used to contain a test
-    // that blocked the following statement, only if 
-    // the argument was greater than throttle_max. 
+    // that blocked the following statement, only if
+    // the argument was greater than throttle_max.
     // Although a value lower than throttle_max would cover
     // the same code in _reset_max, the throttle_max * 100
     // value is left here to demonstrate that the problem
@@ -220,10 +220,10 @@ TEST_F(ThrottleTest, destructor) {
     int64_t throttle_max = 10;
     Throttle *throttle = new Throttle(g_ceph_context, "throttle", throttle_max);
 
-    ASSERT_FALSE(throttle->get(5)); 
+    ASSERT_FALSE(throttle->get(5));
 
     t = new Thread_get(*throttle, 7);
-    t->create();
+    t->create("t_throttle");
     bool blocked;
     useconds_t delay = 1;
     do {
@@ -238,8 +238,8 @@ TEST_F(ThrottleTest, destructor) {
     } while(!blocked);
     delete throttle;
   }
-  
-  { // 
+
+  { //
     // The thread is left hanging, otherwise it will abort().
     // Deleting the Throttle on which it is waiting creates a
     // inconsistency that will be detected: the Throttle object that
@@ -265,8 +265,8 @@ int main(int argc, char **argv) {
 
 /*
  * Local Variables:
- * compile-command: "cd ../.. ; 
- *   make unittest_throttle ; 
+ * compile-command: "cd ../.. ;
+ *   make unittest_throttle ;
  *   ./unittest_throttle # --gtest_filter=ThrottleTest.destructor \
  *       --log-to-stderr=true --debug-filestore=20
  * "
diff --git a/src/test/common/test_shared_cache.cc b/src/test/common/test_shared_cache.cc
index 09f6fb1..cd921f5 100644
--- a/src/test/common/test_shared_cache.cc
+++ b/src/test/common/test_shared_cache.cc
@@ -175,7 +175,7 @@ TEST_F(SharedLRU_all, wait_lookup) {
   EXPECT_FALSE(cache.get_weak_refs()[key].first.lock());
 
   Thread_wait t(cache, key, value, Thread_wait::LOOKUP);
-  t.create();
+  t.create("wait_lookup_1");
   ASSERT_TRUE(wait_for(cache, 1));
   EXPECT_EQ(value, *t.ptr);
   // waiting on a key does not block lookups on other keys
@@ -201,7 +201,7 @@ TEST_F(SharedLRU_all, wait_lookup_or_create) {
   EXPECT_FALSE(cache.get_weak_refs()[key].first.lock());
 
   Thread_wait t(cache, key, value, Thread_wait::LOOKUP);
-  t.create();
+  t.create("wait_lookup_2");
   ASSERT_TRUE(wait_for(cache, 1));
   EXPECT_EQ(value, *t.ptr);
   // waiting on a key does not block lookups on other keys
@@ -246,7 +246,7 @@ TEST_F(SharedLRU_all, wait_lower_bound) {
   EXPECT_FALSE(cache.get_weak_refs()[key].first.lock());
 
   Thread_wait t(cache, key, value, Thread_wait::LOWER_BOUND);
-  t.create();
+  t.create("wait_lower_bnd");
   ASSERT_TRUE(wait_for(cache, 1));
   EXPECT_FALSE(t.ptr);
   // waiting on a key does not block getting lower_bound on other keys
diff --git a/src/test/common/test_sharedptr_registry.cc b/src/test/common/test_sharedptr_registry.cc
index 42bc8e6..98379c8 100644
--- a/src/test/common/test_sharedptr_registry.cc
+++ b/src/test/common/test_sharedptr_registry.cc
@@ -130,7 +130,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
     EXPECT_FALSE(registry.get_contents()[key].first.lock());
 
     Thread_wait t(registry, key, 0, Thread_wait::LOOKUP_OR_CREATE);
-    t.create();
+    t.create("wait_lookcreate");
     ASSERT_TRUE(wait_for(registry, 1));
     EXPECT_FALSE(t.ptr);
     // waiting on a key does not block lookups on other keys
@@ -150,7 +150,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
     EXPECT_FALSE(registry.get_contents()[key].first.lock());
 
     Thread_wait t(registry, key, value, Thread_wait::LOOKUP_OR_CREATE);
-    t.create();
+    t.create("wait_lookcreate");
     ASSERT_TRUE(wait_for(registry, 1));
     EXPECT_FALSE(t.ptr);
     // waiting on a key does not block lookups on other keys
@@ -193,7 +193,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup) {
   EXPECT_FALSE(registry.get_contents()[key].first.lock());
 
   Thread_wait t(registry, key, value, Thread_wait::LOOKUP);
-  t.create();
+  t.create("wait_lookup");
   ASSERT_TRUE(wait_for(registry, 1));
   EXPECT_EQ(value, *t.ptr);
   // waiting on a key does not block lookups on other keys
diff --git a/src/test/common/test_time.cc b/src/test/common/test_time.cc
new file mode 100644
index 0000000..e363085
--- /dev/null
+++ b/src/test/common/test_time.cc
@@ -0,0 +1,145 @@
+
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage at newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.	See file COPYING.
+ *
+ */
+
+#include <ctime>
+
+#include "common/ceph_time.h"
+#include "include/rados.h"
+#include "gtest/gtest.h"
+
+
+using ceph::real_clock;
+using ceph::real_time;
+
+using ceph::real_clock;
+using ceph::real_time;
+
+using ceph::coarse_real_clock;
+using ceph::coarse_mono_clock;
+
+using ceph::timespan;
+using ceph::signedspan;
+
+using std::chrono::seconds;
+using std::chrono::microseconds;
+using std::chrono::nanoseconds;
+
+static_assert(!real_clock::is_steady, "ceph::real_clock must not be steady.");
+static_assert(!coarse_real_clock::is_steady,
+	      "ceph::coarse_real_clock must not be steady.");
+
+static_assert(mono_clock::is_steady, "ceph::mono_clock must be steady.");
+static_assert(coarse_mono_clock::is_steady,
+	      "ceph::coarse_mono_clock must be steady.");
+
+// Before this file was written.
+static constexpr uint32_t bs = 1440701569;
+static constexpr uint32_t bns = 123456789;
+static constexpr uint32_t bus = 123456;
+static constexpr time_t btt = bs;
+static constexpr struct timespec bts = { bs, bns };
+static constexpr struct ceph_timespec bcts = { bs, bns };
+static constexpr struct timeval btv = { bs, bus };
+static constexpr double bd = bs + ((double)bns / 1000000000.);
+
+template<typename Clock>
+static void system_clock_sanity() {
+  static constexpr typename Clock::time_point brt(seconds(bs)
+						  + nanoseconds(bns));
+  const typename Clock::time_point now(Clock::now());
+
+  ASSERT_GT(now, brt);
+
+  ASSERT_GT(Clock::to_time_t(now), btt);
+
+  ASSERT_GT(Clock::to_timespec(now).tv_sec, bts.tv_sec);
+  ASSERT_LT(Clock::to_timespec(now).tv_nsec, 1000000000L);
+
+  ASSERT_GT(Clock::to_ceph_timespec(now).tv_sec, bcts.tv_sec);
+  ASSERT_LT(Clock::to_ceph_timespec(now).tv_nsec, 1000000000UL);
+
+  ASSERT_GT(Clock::to_timeval(now).tv_sec, btv.tv_sec);
+  ASSERT_LT(Clock::to_timeval(now).tv_usec, 1000000L);
+}
+
+template<typename Clock>
+static void system_clock_conversions() {
+  static constexpr typename Clock::time_point brt(seconds(bs) +
+						  nanoseconds(bns));
+
+  ASSERT_EQ(Clock::to_time_t(brt), btt);
+  ASSERT_EQ(Clock::from_time_t(btt) + nanoseconds(bns), brt);
+
+  {
+    const struct timespec tts = Clock::to_timespec(brt);
+    ASSERT_EQ(tts.tv_sec, bts.tv_sec);
+    ASSERT_EQ(tts.tv_nsec, bts.tv_nsec);
+  }
+  ASSERT_EQ(Clock::from_timespec(bts), brt);
+  {
+    struct timespec tts;
+    Clock::to_timespec(brt, tts);
+    ASSERT_EQ(tts.tv_sec, bts.tv_sec);
+    ASSERT_EQ(tts.tv_nsec, bts.tv_nsec);
+  }
+
+  {
+    const struct ceph_timespec tcts = Clock::to_ceph_timespec(brt);
+    ASSERT_EQ(tcts.tv_sec, bcts.tv_sec);
+    ASSERT_EQ(tcts.tv_nsec, bcts.tv_nsec);
+  }
+  ASSERT_EQ(Clock::from_ceph_timespec(bcts), brt);
+  {
+    struct ceph_timespec tcts;
+    Clock::to_ceph_timespec(brt, tcts);
+    ASSERT_EQ(tcts.tv_sec, bcts.tv_sec);
+    ASSERT_EQ(tcts.tv_nsec, bcts.tv_nsec);
+  }
+
+  {
+    const struct timeval ttv = Clock::to_timeval(brt);
+    ASSERT_EQ(ttv.tv_sec, btv.tv_sec);
+    ASSERT_EQ(ttv.tv_usec, btv.tv_usec);
+  }
+  ASSERT_EQ(Clock::from_timeval(btv), brt - nanoseconds(bns - bus * 1000));
+  {
+    struct timeval ttv;
+    Clock::to_timeval(brt, ttv);
+    ASSERT_EQ(ttv.tv_sec, btv.tv_sec);
+    ASSERT_EQ(ttv.tv_usec, btv.tv_usec);
+  }
+
+  ASSERT_EQ(Clock::to_double(brt), bd);
+  // Fudge factor
+  ASSERT_LT(abs((Clock::from_double(bd) - brt).count()), 30);
+}
+
+TEST(RealClock, Sanity) {
+  system_clock_sanity<real_clock>();
+}
+
+
+TEST(RealClock, Conversions) {
+  system_clock_conversions<real_clock>();
+}
+
+TEST(CoarseRealClock, Sanity) {
+  system_clock_sanity<coarse_real_clock>();
+}
+
+
+TEST(CoarseRealClock, Conversions) {
+  system_clock_conversions<coarse_real_clock>();
+}
diff --git a/src/test/compressor/Makefile.am b/src/test/compressor/Makefile.am
new file mode 100644
index 0000000..f5a8f4e
--- /dev/null
+++ b/src/test/compressor/Makefile.am
@@ -0,0 +1,49 @@
+if ENABLE_SERVER
+if WITH_OSD
+
+
+libceph_example_la_SOURCES = \
+	compressor/Compressor.cc \
+	test/compressor/compressor_plugin_example.cc
+noinst_HEADERS += test/compressor/compressor_example.h
+test/compressor/compressor_plugin_example.cc: ./ceph_ver.h
+libceph_example_la_CFLAGS = ${AM_CFLAGS}
+libceph_example_la_CXXFLAGS= ${AM_CXXFLAGS}
+libceph_example_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+libceph_example_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__compression_.*'
+compressorlib_LTLIBRARIES += libceph_example.la
+
+unittest_compression_plugin_SOURCES = \
+	compressor/Compressor.cc \
+	test/compressor/test_compression_plugin.cc 
+unittest_compression_plugin_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+unittest_compression_plugin_LDADD = $(LIBOSD) $(LIBCOMMON) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+if LINUX
+unittest_compression_plugin_LDADD += -ldl
+endif
+check_TESTPROGRAMS += unittest_compression_plugin
+
+unittest_compression_snappy_SOURCES = \
+	test/compressor/test_compression_snappy.cc \
+	${snappy_sources}
+unittest_compression_snappy_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+unittest_compression_snappy_LDADD = $(LIBOSD) $(LIBCOMMON) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
+unittest_compression_snappy_LDFLAGS = -lsnappy
+if LINUX
+unittest_compression_snappy_LDADD += -ldl
+endif
+check_TESTPROGRAMS += unittest_compression_snappy
+
+unittest_compression_plugin_snappy_SOURCES = \
+	test/compressor/test_compression_plugin_snappy.cc \
+	${snappy_sources}
+unittest_compression_plugin_snappy_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+unittest_compression_plugin_snappy_LDADD = $(LIBOSD) $(LIBCOMMON) $(UNITTEST_LDADD) $(CEPH_GLOBAL) $(LIBCOMPRESSOR)
+unittest_compression_plugin_snappy_LDFLAGS = -lsnappy
+if LINUX
+unittest_compression_plugin_snappy_LDADD += -ldl
+endif
+check_TESTPROGRAMS += unittest_compression_plugin_snappy
+
+endif # WITH_OSD
+endif # ENABLE_SERVER
diff --git a/src/test/compressor/compressor_example.h b/src/test/compressor/compressor_example.h
new file mode 100644
index 0000000..3a96f88
--- /dev/null
+++ b/src/test/compressor/compressor_example.h
@@ -0,0 +1,53 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph distributed storage system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ * 
+ */
+
+#ifndef CEPH_COMPRESSOR_EXAMPLE_H
+#define CEPH_COMPRESSOR_EXAMPLE_H
+
+#include <unistd.h>
+#include <errno.h>
+#include <algorithm>
+#include <sstream>
+
+#include "crush/CrushWrapper.h"
+#include "osd/osd_types.h"
+#include "compressor/Compressor.h"
+
+class CompressorExample : public Compressor {
+public:
+  virtual ~CompressorExample() {}
+
+  virtual int compress(bufferlist &in, bufferlist &out)
+  {
+    out = in;
+    return 0;
+  }
+
+  virtual int decompress(bufferlist &in, bufferlist &out)
+  {
+    out = in;
+    return 0;
+  }
+
+  virtual const char* get_method_name()
+  {
+    return "example";
+  }
+
+};
+
+#endif
diff --git a/src/test/compressor/compressor_plugin_example.cc b/src/test/compressor/compressor_plugin_example.cc
new file mode 100644
index 0000000..96914ee
--- /dev/null
+++ b/src/test/compressor/compressor_plugin_example.cc
@@ -0,0 +1,57 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph distributed storage system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ * 
+ */
+
+#include <unistd.h>
+
+#include "ceph_ver.h"
+#include "compressor/CompressionPlugin.h"
+#include "compressor_example.h"
+
+class CompressorPluginExample : public CompressionPlugin {
+public:
+
+  CompressorPluginExample(CephContext* cct) : CompressionPlugin(cct)
+  {}
+
+  virtual int factory(CompressorRef *cs,
+		      ostream *ss)
+  {
+    if (compressor == 0) {
+      CompressorExample *interface = new CompressorExample();
+      compressor = CompressorRef(interface);
+    }
+    *cs = compressor;
+    return 0;
+  }
+};
+
+// -----------------------------------------------------------------------------
+
+const char *__ceph_plugin_version()
+{
+  return CEPH_GIT_NICE_VER;
+}
+
+// -----------------------------------------------------------------------------
+
+int __ceph_plugin_init(CephContext *cct,
+                       const std::string& type,
+                       const std::string& name)
+{
+  PluginRegistry *instance = cct->get_plugin_registry();
+
+  return instance->add(type, name, new CompressorPluginExample(cct));
+}
diff --git a/src/test/compressor/test_compression_plugin.cc b/src/test/compressor/test_compression_plugin.cc
new file mode 100644
index 0000000..6d81532
--- /dev/null
+++ b/src/test/compressor/test_compression_plugin.cc
@@ -0,0 +1,71 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph distributed storage system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ * 
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <gtest/gtest.h>
+#include "global/global_init.h"
+#include "compressor/CompressionPlugin.h"
+#include "common/ceph_argparse.h"
+#include "global/global_context.h"
+#include "common/config.h"
+
+TEST(CompressionPlugin, all)
+{
+  string directory(".libs");
+  CompressorRef compressor;
+  PluginRegistry *reg = g_ceph_context->get_plugin_registry();
+  EXPECT_TRUE(reg);
+  CompressionPlugin *factory = dynamic_cast<CompressionPlugin*>(reg->get_with_load("compressor", "invalid"));
+  EXPECT_FALSE(factory);
+  factory = dynamic_cast<CompressionPlugin*>(reg->get_with_load("compressor", "example"));
+  EXPECT_TRUE(factory);
+  stringstream ss;
+  EXPECT_EQ(0, factory->factory(&compressor, &ss));
+  EXPECT_TRUE(compressor.get());
+  {
+    Mutex::Locker l(reg->lock);
+    EXPECT_EQ(-ENOENT, reg->remove("compressor", "does not exist"));
+    EXPECT_EQ(0, reg->remove("compressor", "example"));
+    EXPECT_EQ(0, reg->load("compressor", "example"));
+  }
+}
+
+int main(int argc, char **argv) {
+  vector<const char*> args;
+  argv_to_vec(argc, (const char **)argv, args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  system("mkdir -p .libs/compressor");
+  system("cp .libs/libceph_example.so* .libs/compressor/");
+  g_conf->set_val("plugin_dir", ".libs", false, false);
+
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
+/*
+ * Local Variables:
+ * compile-command: "cd ../.. ; make -j4 && 
+ *   make unittest_compression_plugin && 
+ *   valgrind --tool=memcheck \
+ *      ./unittest_compression_plugin \
+ *      --gtest_filter=*.* --log-to-stderr=true --debug-osd=20"
+ * End:
+ */
diff --git a/src/test/compressor/test_compression_plugin_snappy.cc b/src/test/compressor/test_compression_plugin_snappy.cc
new file mode 100644
index 0000000..495e641
--- /dev/null
+++ b/src/test/compressor/test_compression_plugin_snappy.cc
@@ -0,0 +1,58 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph distributed storage system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ * 
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <gtest/gtest.h>
+#include "global/global_init.h"
+#include "compressor/Compressor.h"
+#include "common/ceph_argparse.h"
+#include "global/global_context.h"
+#include "common/config.h"
+
+TEST(CompressionPluginSnappy, factory)
+{
+  CompressorRef compressor = Compressor::create(g_ceph_context, "snappy");
+  cout << compressor;
+  EXPECT_TRUE(compressor.get());
+}
+
+int main(int argc, char **argv) {
+  vector<const char*> args;
+  argv_to_vec(argc, (const char **)argv, args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  system("mkdir -p .libs/compressor");
+  system("cp .libs/libceph_snappy.so* .libs/compressor/");
+
+  g_conf->set_val("plugin_dir", ".libs", false, false);
+
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
+/*
+ * Local Variables:
+ * compile-command: "cd ../.. ; make -j4 && 
+ *   make unittest_compression_plugin_snappy && 
+ *   valgrind --tool=memcheck \
+ *      ./unittest_compression_plugin_snappy \
+ *      --gtest_filter=*.* --log-to-stderr=true --debug-osd=20"
+ * End:
+ */
diff --git a/src/test/compressor/test_compression_snappy.cc b/src/test/compressor/test_compression_snappy.cc
new file mode 100644
index 0000000..69b0ebf
--- /dev/null
+++ b/src/test/compressor/test_compression_snappy.cc
@@ -0,0 +1,62 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph distributed storage system
+ *
+ * Copyright (C) 2015 Mirantis, Inc.
+ *
+ * Author: Alyona Kiseleva <akiselyova at mirantis.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ * 
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <gtest/gtest.h>
+#include "global/global_init.h"
+#include "compressor/snappy/SnappyCompressor.h"
+#include "common/ceph_argparse.h"
+#include "global/global_context.h"
+#include "common/config.h"
+
+TEST(SnappyCompressor, compress_decompress)
+{
+  SnappyCompressor sp;
+  EXPECT_EQ(sp.get_method_name(), "snappy");
+  char* test = "This is test text";
+  int len = strlen(test);
+  bufferlist in, out;
+  in.append(test, len);
+  int res = sp.compress(in, out);
+  EXPECT_EQ(res, 0);
+  bufferlist after;
+  res = sp.decompress(out, after);
+  EXPECT_EQ(res, 0);
+}
+
+int main(int argc, char **argv) {
+  vector<const char*> args;
+  argv_to_vec(argc, (const char **)argv, args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  g_conf->set_val("compression_dir", ".libs", false, false);
+
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
+
+/*
+ * Local Variables:
+ * compile-command: "cd ../.. ; make -j4 && 
+ *   make unittest_compression_snappy && 
+ *   valgrind --tool=memcheck \
+ *      ./unittest_compression_snappy \
+ *      --gtest_filter=*.* --log-to-stderr=true --debug-osd=20"
+ * End:
+ */
diff --git a/src/test/crush/CrushWrapper.cc b/src/test/crush/CrushWrapper.cc
index ddfa0f0..1d85274 100644
--- a/src/test/crush/CrushWrapper.cc
+++ b/src/test/crush/CrushWrapper.cc
@@ -788,11 +788,13 @@ TEST(CrushWrapper, dump_rules) {
   // no ruleset by default
   {
     Formatter *f = Formatter::create("json-pretty");
+    f->open_array_section("rules");
     c->dump_rules(f);
+    f->close_section();
     stringstream ss;
     f->flush(ss);
     delete f;
-    EXPECT_EQ("\n", ss.str());
+    EXPECT_EQ("[]\n", ss.str());
   }
 
   string name("NAME");
diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h
index 26e672c..e63dc8d 100644
--- a/src/test/encoding/types.h
+++ b/src/test/encoding/types.h
@@ -108,9 +108,18 @@ TYPE(HitSet::Params)
 #include "os/ObjectStore.h"
 TYPE(ObjectStore::Transaction)
 
-#include "os/SequencerPosition.h"
+#include "os/filestore/SequencerPosition.h"
 TYPE(SequencerPosition)
 
+#include "os/bluestore/bluestore_types.h"
+TYPE(bluestore_cnode_t)
+TYPE(bluestore_extent_t)
+TYPE(bluestore_extent_ref_map_t)
+TYPE(bluestore_overlay_t)
+TYPE(bluestore_onode_t)
+TYPE(bluestore_wal_op_t)
+TYPE(bluestore_wal_transaction_t)
+
 #include "common/hobject.h"
 TYPE(hobject_t)
 TYPE(ghobject_t)
@@ -135,7 +144,7 @@ TYPE(MonCap)
 #include "mon/mon_types.h"
 TYPE(LevelDBStoreStats)
 
-#include "os/DBObjectMap.h"
+#include "os/filestore/DBObjectMap.h"
 TYPE(DBObjectMap::_Header)
 TYPE(DBObjectMap::State)
 
@@ -227,7 +236,7 @@ TYPE(ETableServer)
 TYPE(EUpdate)
 
 #ifdef WITH_RBD
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
 TYPE(librbd::journal::EventEntry)
 #include "librbd/WatchNotifyTypes.h"
 TYPE(librbd::watch_notify::NotifyMessage)
diff --git a/src/test/erasure-code/TestErasureCodeIsa.cc b/src/test/erasure-code/TestErasureCodeIsa.cc
index 84ad68e..29318e0 100644
--- a/src/test/erasure-code/TestErasureCodeIsa.cc
+++ b/src/test/erasure-code/TestErasureCodeIsa.cc
@@ -408,8 +408,8 @@ TEST_F(IsaErasureCodeTest, isa_vandermonde_exhaustive)
   profile["m"] = "4";
   Isa.init(profile, &cerr);
 
-  int k = 12;
-  int m = 4;
+  const int k = 12;
+  const int m = 4;
 
 #define LARGE_ENOUGH 2048
   bufferptr in_ptr(buffer::create_page_aligned(LARGE_ENOUGH));
diff --git a/src/test/erasure-code/TestErasureCodePlugin.cc b/src/test/erasure-code/TestErasureCodePlugin.cc
index 6cf241e..4691ff6 100644
--- a/src/test/erasure-code/TestErasureCodePlugin.cc
+++ b/src/test/erasure-code/TestErasureCodePlugin.cc
@@ -55,7 +55,7 @@ TEST_F(ErasureCodePluginRegistryTest, factory_mutex) {
   useconds_t delay = 0;
   const useconds_t DELAY_MAX = 20 * 1000 * 1000;
   Thread_factory sleep_forever;
-  sleep_forever.create();
+  sleep_forever.create("sleep_forever");
   do {
     cout << "Trying (1) with delay " << delay << "us\n";
     if (delay > 0)
diff --git a/src/test/fedora-21/ceph.spec.in b/src/test/fedora-21/ceph.spec.in
index 52c5c1d..487232c 100644
--- a/src/test/fedora-21/ceph.spec.in
+++ b/src/test/fedora-21/ceph.spec.in
@@ -1,4 +1,19 @@
 # vim: set noexpandtab ts=8 sw=8 :
+#
+# spec file for package ceph
+#
+# Copyright (C) 2004-2016 The Ceph Project Developers. See COPYING file
+# at the top-level directory of this distribution and at
+# https://github.com/ceph/ceph/blob/master/COPYING
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon.
+#
+# This file is under the GNU Lesser General Public License, version 2.1
+#
+# Please submit bugfixes or comments via http://tracker.ceph.com/
+# 
 %bcond_with ocf
 %bcond_without cephfs_java
 %bcond_with tests
@@ -133,6 +148,7 @@ BuildRequires:	python-requests
 BuildRequires:	python-virtualenv
 BuildRequires:	snappy-devel
 BuildRequires:	util-linux
+BuildRequires:	valgrind-devel
 BuildRequires:	xfsprogs
 BuildRequires:	xfsprogs-devel
 BuildRequires:	xmlstarlet
@@ -168,7 +184,6 @@ BuildRequires:	libatomic-ops-devel
 %if 0%{?_with_systemd}
 Requires:	systemd
 %endif
-BuildRequires:  bzip2-devel
 BuildRequires:	nss-devel
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	libatomic_ops-devel
@@ -790,6 +805,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ceph-mon
 %{_bindir}/ceph-mds
 %{_bindir}/ceph-objectstore-tool
+%{_bindir}/ceph-bluefs-tool
 %{_bindir}/ceph-osd
 %{_bindir}/ceph-detect-init
 %{_bindir}/librados-config
@@ -844,6 +860,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/rados-classes/libcls_journal.so*
 %dir %{_libdir}/ceph/erasure-code
 %{_libdir}/ceph/erasure-code/libec_*.so*
+%dir %{_libdir}/ceph/compressor
+%{_libdir}/ceph/compressor/libceph_*.so*
 %if 0%{?_with_lttng}
 %{_libdir}/libos_tp.so*
 %{_libdir}/libosd_tp.so*
@@ -1179,6 +1197,7 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %files -n python-cephfs
 %defattr(-,root,root,-)
 %{python_sitelib}/cephfs.py*
+%{python_sitelib}/ceph_volume_client.py*
 
 #################################################################################
 %files -n ceph-test
@@ -1204,7 +1223,6 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %{_bindir}/ceph_smalliobenchdumb
 %{_bindir}/ceph_smalliobenchfs
 %{_bindir}/ceph_smalliobenchrbd
-%{_bindir}/ceph_streamtest
 %{_bindir}/ceph_test_*
 %{_bindir}/ceph_tpbench
 %{_bindir}/ceph_xattr_bench
diff --git a/src/test/filestore/TestFileStore.cc b/src/test/filestore/TestFileStore.cc
index a9b58a1..a100a5f 100644
--- a/src/test/filestore/TestFileStore.cc
+++ b/src/test/filestore/TestFileStore.cc
@@ -16,7 +16,7 @@
 
 #include "common/ceph_argparse.h"
 #include "global/global_init.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include <gtest/gtest.h>
 
 class TestFileStore {
diff --git a/src/test/libcephfs/access.cc b/src/test/libcephfs/access.cc
index ac8cbd1..35d0573 100644
--- a/src/test/libcephfs/access.cc
+++ b/src/test/libcephfs/access.cc
@@ -13,7 +13,9 @@
  */
 
 #include "gtest/gtest.h"
+#include "common/ceph_argparse.h"
 #include "include/buffer.h"
+#include "include/stringify.h"
 #include "include/cephfs/libcephfs.h"
 #include "include/rados/librados.h"
 #include <errno.h>
@@ -26,8 +28,6 @@
 #include <sys/uio.h>
 #include <iostream>
 #include <vector>
-#include "common/ceph_argparse.h"
-#include "include/stringify.h"
 #include "json_spirit/json_spirit.h"
 
 #ifdef __linux__
@@ -247,6 +247,7 @@ TEST(AccessTest, User) {
   ASSERT_EQ(0, ceph_create(&admin, NULL));
   ASSERT_EQ(0, ceph_conf_read_file(admin, NULL));
   ASSERT_EQ(0, ceph_conf_parse_env(admin, NULL));
+  ASSERT_EQ(0, ceph_conf_set(admin, "client_permissions", "0"));
   ASSERT_EQ(0, ceph_mount(admin, "/"));
   ASSERT_EQ(0, ceph_mkdir(admin, dir.c_str(), 0755));
 
@@ -266,6 +267,7 @@ TEST(AccessTest, User) {
   ASSERT_EQ(-EACCES, ceph_mount(cmount, "/"));
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_mount_uid", "123"));
   ASSERT_EQ(0, ceph_conf_set(cmount, "client_mount_gid", "456"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
   ASSERT_EQ(0, ceph_mount(cmount, "/"));
 
   // user bits
@@ -337,8 +339,31 @@ TEST(AccessTest, User) {
   ceph_shutdown(admin);
 }
 
+static int update_root_mode()
+{
+  struct ceph_mount_info *admin;
+  int r = ceph_create(&admin, NULL);
+  if (r < 0)
+    return r;
+  ceph_conf_read_file(admin, NULL);
+  ceph_conf_parse_env(admin, NULL);
+  ceph_conf_set(admin, "client_permissions", "false");
+  r = ceph_mount(admin, "/");
+  if (r < 0)
+    goto out;
+  r = ceph_chmod(admin, "/", 0777);
+out:
+  ceph_shutdown(admin);
+  return r;
+}
+
+
 int main(int argc, char **argv)
 {
+  int r = update_root_mode();
+  if (r < 0)
+    exit(1);
+
   ::testing::InitGoogleTest(&argc, argv);
 
   srand(getpid());
@@ -346,7 +371,7 @@ int main(int argc, char **argv)
   rados_create(&cluster, NULL);
   rados_conf_read_file(cluster, NULL);
   rados_conf_parse_env(cluster, NULL);
-  int r = rados_connect(cluster);
+  r = rados_connect(cluster);
   if (r < 0)
     exit(1);
 
diff --git a/src/test/libcephfs/acl.cc b/src/test/libcephfs/acl.cc
new file mode 100644
index 0000000..941cbb6
--- /dev/null
+++ b/src/test/libcephfs/acl.cc
@@ -0,0 +1,307 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2011 New Dream Network
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+#include "include/types.h"
+#include "gtest/gtest.h"
+#include "include/cephfs/libcephfs.h"
+#include "include/ceph_fs.h"
+#include "client/posix_acl.h"
+#include <errno.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/xattr.h>
+
+static size_t acl_ea_size(int count)
+{
+  return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry);
+}
+
+static int acl_ea_count(size_t size)
+{
+  if (size < sizeof(acl_ea_header))
+    return -1;
+  size -= sizeof(acl_ea_header);
+  if (size % sizeof(acl_ea_entry))
+    return -1;
+  return size / sizeof(acl_ea_entry);
+}
+
+static int check_acl_and_mode(const void *buf, size_t size, mode_t mode)
+{
+  const acl_ea_entry *group_entry = NULL, *mask_entry = NULL;
+  const acl_ea_header *header = reinterpret_cast<const acl_ea_header*>(buf);
+  const acl_ea_entry *entry = header->a_entries;
+  int count = (size - sizeof(*header)) / sizeof(*entry);
+  for (int i = 0; i < count; ++i) {
+    __u16 tag = entry->e_tag;
+    __u16 perm = entry->e_perm;
+    switch(tag) {
+      case ACL_USER_OBJ:
+	if (perm != ((mode >> 6) & 7))
+	  return -EINVAL;
+	break;
+      case ACL_USER:
+      case ACL_GROUP:
+	break;
+      case ACL_GROUP_OBJ:
+	group_entry = entry;
+	break;
+      case ACL_OTHER:
+	if (perm != (mode & 7))
+	  return -EINVAL;
+	break;
+      case ACL_MASK:
+	mask_entry = entry;
+	break;
+      default:
+	return -EIO;
+    }
+    ++entry;
+  }
+  if (mask_entry) {
+    __u16 perm = mask_entry->e_perm;
+    if (perm != ((mode >> 3) & 7))
+      return -EINVAL;
+  } else {
+    if (!group_entry)
+      return -EIO;
+    __u16 perm = group_entry->e_perm;
+    if (perm != ((mode >> 3) & 7))
+      return -EINVAL;
+  }
+  return 0;
+}
+
+static int generate_test_acl(void *buf, size_t size, mode_t mode)
+{
+  if (acl_ea_count(size) != 5)
+    return -1;
+  acl_ea_header *header = reinterpret_cast<acl_ea_header*>(buf);
+  header->a_version = (__u32)ACL_EA_VERSION;
+  acl_ea_entry *entry = header->a_entries;
+  entry->e_tag = ACL_USER_OBJ;
+  entry->e_perm = (mode >> 6) & 7;
+  ++entry;
+  entry->e_tag = ACL_USER;
+  entry->e_perm = 7;
+  entry->e_id = getuid();
+  ++entry;
+  entry->e_tag = ACL_GROUP_OBJ;
+  entry->e_perm = (mode >> 3) & 7;
+  ++entry;
+  entry->e_tag = ACL_MASK;
+  entry->e_perm = 7;
+  ++entry;
+  entry->e_tag = ACL_OTHER;
+  entry->e_perm = mode & 7;
+  return 0;
+}
+
+static int generate_empty_acl(void *buf, size_t size, mode_t mode)
+{
+
+ if (acl_ea_count(size) != 3)
+    return -1;
+  acl_ea_header *header = reinterpret_cast<acl_ea_header*>(buf);
+  header->a_version = (__u32)ACL_EA_VERSION;
+  acl_ea_entry *entry = header->a_entries;
+  entry->e_tag = ACL_USER_OBJ;
+  entry->e_perm = (mode >> 6) & 7;
+  ++entry;
+  entry->e_tag = ACL_GROUP_OBJ;
+  entry->e_perm = (mode >> 3) & 7;
+  ++entry;
+  entry->e_tag = ACL_OTHER;
+  entry->e_perm = mode & 7;
+  return 0;
+}
+
+TEST(ACL, SetACL) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(0, ceph_create(&cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+  ASSERT_EQ(0, ceph_mount(cmount, "/"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_acl_type", "posix_acl"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
+
+  char test_file[256];
+  sprintf(test_file, "file1_setacl_%d", getpid());
+
+  int fd = ceph_open(cmount, test_file, O_CREAT|O_RDWR, 0600);
+  ASSERT_GT(fd, 0);
+  // change ownership to nobody -- we assume nobody exists and id is always 65534
+  ASSERT_EQ(ceph_fchown(cmount, fd, 65534, 65534), 0);
+
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "1"));
+  ASSERT_EQ(ceph_open(cmount, test_file, O_RDWR, 0), -EACCES);
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_permissions", "0"));
+
+  size_t acl_buf_size = acl_ea_size(5);
+  void *acl_buf = malloc(acl_buf_size);
+  ASSERT_EQ(generate_test_acl(acl_buf, acl_buf_size, 0750), 0);
+
+  // can't set default acl for non-directory
+  ASSERT_EQ(ceph_fsetxattr(cmount, fd, ACL_EA_DEFAULT, acl_buf, acl_buf_size, 0), -EACCES);
+  ASSERT_EQ(ceph_fsetxattr(cmount, fd, ACL_EA_ACCESS, acl_buf, acl_buf_size, 0), 0);
+
+  int tmpfd = ceph_open(cmount, test_file, O_RDWR, 0);
+  ASSERT_GT(tmpfd, 0);
+  ceph_close(cmount, tmpfd);
+
+  struct stat stbuf;
+  ASSERT_EQ(ceph_fstat(cmount, fd, &stbuf), 0);
+  // mode was modified according to ACL
+  ASSERT_EQ(stbuf.st_mode & 0777, 0770u);
+  ASSERT_EQ(check_acl_and_mode(acl_buf, acl_buf_size, stbuf.st_mode), 0);
+
+  acl_buf_size = acl_ea_size(3);
+  // setting ACL that is equivalent to file mode
+  ASSERT_EQ(generate_empty_acl(acl_buf, acl_buf_size, 0600), 0);
+  ASSERT_EQ(ceph_fsetxattr(cmount, fd, ACL_EA_ACCESS, acl_buf, acl_buf_size, 0), 0);
+  // ACL was deleted
+  ASSERT_EQ(ceph_fgetxattr(cmount, fd, ACL_EA_ACCESS, NULL, 0), -ENODATA);
+
+  ASSERT_EQ(ceph_fstat(cmount, fd, &stbuf), 0);
+  // mode was modified according to ACL
+  ASSERT_EQ(stbuf.st_mode & 0777, 0600u);
+
+  free(acl_buf);
+  ceph_close(cmount, fd);
+  ceph_shutdown(cmount);
+}
+
+TEST(ACL, Chmod) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(0, ceph_create(&cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+  ASSERT_EQ(0, ceph_mount(cmount, "/"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_acl_type", "posix_acl"));
+
+  char test_file[256];
+  sprintf(test_file, "file1_acl_chmod_%d", getpid());
+
+  int fd = ceph_open(cmount, test_file, O_CREAT|O_RDWR, 0600);
+  ASSERT_GT(fd, 0);
+
+  int acl_buf_size = acl_ea_size(5);
+  void *acl_buf = malloc(acl_buf_size);
+  ASSERT_EQ(generate_test_acl(acl_buf, acl_buf_size, 0775), 0);
+  ASSERT_EQ(ceph_fsetxattr(cmount, fd, ACL_EA_ACCESS, acl_buf, acl_buf_size, 0), 0);
+
+  struct stat stbuf;
+  ASSERT_EQ(ceph_fstat(cmount, fd, &stbuf), 0);
+  // mode was updated according to ACL
+  ASSERT_EQ(stbuf.st_mode & 0777, 0775u);
+
+  // change mode
+  ASSERT_EQ(ceph_fchmod(cmount, fd, 0640), 0);
+
+  ASSERT_EQ(ceph_fstat(cmount, fd, &stbuf), 0);
+  ASSERT_EQ(stbuf.st_mode & 0777, 0640u);
+
+  // ACL was updated according to mode
+  ASSERT_EQ(ceph_fgetxattr(cmount, fd, ACL_EA_ACCESS, acl_buf, acl_buf_size), acl_buf_size);
+  ASSERT_EQ(check_acl_and_mode(acl_buf, acl_buf_size, stbuf.st_mode), 0);
+
+  free(acl_buf);
+  ceph_close(cmount, fd);
+  ceph_shutdown(cmount);
+}
+
+TEST(ACL, DefaultACL) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(0, ceph_create(&cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+  ASSERT_EQ(0, ceph_mount(cmount, "/"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_acl_type", "posix_acl"));
+
+  int acl_buf_size = acl_ea_size(5);
+  void *acl1_buf = malloc(acl_buf_size);
+  void *acl2_buf = malloc(acl_buf_size);
+
+  ASSERT_EQ(generate_test_acl(acl1_buf, acl_buf_size, 0750), 0);
+
+  char test_dir1[256];
+  sprintf(test_dir1, "dir1_acl_default_%d", getpid());
+  ASSERT_EQ(ceph_mkdir(cmount, test_dir1, 0750), 0);
+
+  // set default acl
+  ASSERT_EQ(ceph_setxattr(cmount, test_dir1, ACL_EA_DEFAULT, acl1_buf, acl_buf_size, 0), 0);
+
+  char test_dir2[256];
+  sprintf(test_dir2, "%s/dir2", test_dir1);
+  ASSERT_EQ(ceph_mkdir(cmount, test_dir2, 0755), 0);
+
+  // inherit default acl
+  ASSERT_EQ(ceph_getxattr(cmount, test_dir2, ACL_EA_DEFAULT, acl2_buf, acl_buf_size), acl_buf_size);
+  ASSERT_EQ(memcmp(acl1_buf, acl2_buf, acl_buf_size), 0);
+
+  // mode and ACL are updated
+  ASSERT_EQ(ceph_getxattr(cmount, test_dir2, ACL_EA_ACCESS, acl2_buf, acl_buf_size), acl_buf_size);
+  {
+    struct stat stbuf;
+    ASSERT_EQ(ceph_stat(cmount, test_dir2, &stbuf), 0);
+    // other bits of mode &= acl other perm
+    ASSERT_EQ(stbuf.st_mode & 0777, 0750u);
+    ASSERT_EQ(check_acl_and_mode(acl2_buf, acl_buf_size, stbuf.st_mode), 0);
+  }
+
+  char test_file1[256];
+  sprintf(test_file1, "%s/file1", test_dir1);
+  int fd = ceph_open(cmount, test_file1, O_CREAT|O_RDWR, 0666);
+  ASSERT_GT(fd, 0);
+
+  // no default acl
+  ASSERT_EQ(ceph_fgetxattr(cmount, fd, ACL_EA_DEFAULT, NULL, 0), -ENODATA);
+
+  // mode and ACL are updated
+  ASSERT_EQ(ceph_fgetxattr(cmount, fd, ACL_EA_ACCESS, acl2_buf, acl_buf_size), acl_buf_size);
+  {
+    struct stat stbuf;
+    ASSERT_EQ(ceph_stat(cmount, test_file1, &stbuf), 0);
+    // other bits of mode &= acl other perm
+    ASSERT_EQ(stbuf.st_mode & 0777, 0660u);
+    ASSERT_EQ(check_acl_and_mode(acl2_buf, acl_buf_size, stbuf.st_mode), 0);
+  }
+
+  free(acl1_buf);
+  free(acl2_buf);
+  ceph_close(cmount, fd);
+  ceph_shutdown(cmount);
+}
+
+TEST(ACL, Disabled) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(0, ceph_create(&cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+  ASSERT_EQ(0, ceph_mount(cmount, "/"));
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_acl_type", ""));
+
+  size_t acl_buf_size = acl_ea_size(3);
+  void *acl_buf = malloc(acl_buf_size);
+  ASSERT_EQ(generate_empty_acl(acl_buf, acl_buf_size, 0755), 0);
+
+  char test_dir[256];
+  sprintf(test_dir, "dir1_acl_disabled_%d", getpid());
+  ASSERT_EQ(ceph_mkdir(cmount, test_dir, 0750), 0);
+
+  ASSERT_EQ(ceph_setxattr(cmount, test_dir, ACL_EA_DEFAULT, acl_buf, acl_buf_size, 0), -EOPNOTSUPP);
+  ASSERT_EQ(ceph_setxattr(cmount, test_dir, ACL_EA_ACCESS, acl_buf, acl_buf_size, 0), -EOPNOTSUPP);
+  ASSERT_EQ(ceph_getxattr(cmount, test_dir, ACL_EA_DEFAULT, acl_buf, acl_buf_size), -EOPNOTSUPP);
+  ASSERT_EQ(ceph_getxattr(cmount, test_dir, ACL_EA_ACCESS, acl_buf, acl_buf_size), -EOPNOTSUPP);
+
+  free(acl_buf);
+  ceph_shutdown(cmount);
+}
diff --git a/src/test/libcephfs/caps.cc b/src/test/libcephfs/caps.cc
index e49c63c..8107703 100644
--- a/src/test/libcephfs/caps.cc
+++ b/src/test/libcephfs/caps.cc
@@ -14,8 +14,8 @@
 #include "include/int_types.h"
 
 #include "gtest/gtest.h"
-#include "include/cephfs/libcephfs.h"
 #include "include/ceph_fs.h"
+#include "include/cephfs/libcephfs.h"
 #include <errno.h>
 #include <sys/fcntl.h>
 #include <unistd.h>
diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc
index 6b088df..139c7f3 100644
--- a/src/test/libcephfs/test.cc
+++ b/src/test/libcephfs/test.cc
@@ -66,6 +66,40 @@ TEST(LibCephFS, OpenEmptyComponent) {
   ceph_shutdown(cmount);
 }
 
+TEST(LibCephFS, OpenReadWrite) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(0, ceph_create(&cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
+  ASSERT_EQ(0, ceph_mount(cmount, "/"));
+
+  char c_path[1024];
+  sprintf(c_path, "test_open_rdwr_%d", getpid());
+  int fd = ceph_open(cmount, c_path, O_WRONLY|O_CREAT, 0666);
+  ASSERT_LT(0, fd);
+
+  const char *out_buf = "hello world";
+  size_t size = strlen(out_buf);
+  char in_buf[100];
+  ASSERT_EQ(ceph_write(cmount, fd, out_buf, size, 0), size);
+  ASSERT_EQ(ceph_read(cmount, fd, in_buf, sizeof(in_buf), 0), -EBADF);
+  ASSERT_EQ(0, ceph_close(cmount, fd));
+
+  fd = ceph_open(cmount, c_path, O_RDONLY, 0);
+  ASSERT_LT(0, fd);
+  ASSERT_EQ(ceph_write(cmount, fd, out_buf, size, 0), -EBADF);
+  ASSERT_EQ(ceph_read(cmount, fd, in_buf, sizeof(in_buf), 0), size);
+  ASSERT_EQ(0, ceph_close(cmount, fd));
+
+  fd = ceph_open(cmount, c_path, O_RDWR, 0);
+  ASSERT_LT(0, fd);
+  ASSERT_EQ(ceph_write(cmount, fd, out_buf, size, 0), size);
+  ASSERT_EQ(ceph_read(cmount, fd, in_buf, sizeof(in_buf), 0), size);
+  ASSERT_EQ(0, ceph_close(cmount, fd));
+
+  ceph_shutdown(cmount);
+}
+
 TEST(LibCephFS, MountNonExist) {
 
   struct ceph_mount_info *cmount;
@@ -301,8 +335,10 @@ TEST(LibCephFS, DirLs) {
 
   int count = 0;
   std::set<std::string> found;
-  while (count < r) {
+  while (true) {
     int len = ceph_getdents(cmount, ls_dir, (char *)getdents_entries, r * sizeof(*getdents_entries));
+    if (len == 0)
+      break;
     ASSERT_GT(len, 0);
     ASSERT_TRUE((len % sizeof(*getdents_entries)) == 0);
     int n = len / sizeof(*getdents_entries);
@@ -311,19 +347,16 @@ TEST(LibCephFS, DirLs) {
       ASSERT_STREQ(getdents_entries[0].d_name, ".");
       ASSERT_STREQ(getdents_entries[1].d_name, "..");
       j = 2;
-      count += n - 2;
     } else {
       j = 0;
-      count += n;
     }
+    count += n;
     for(; j < n; ++i, ++j) {
       const char *name = getdents_entries[j].d_name;
-      ASSERT_TRUE(found.count(name) == 0);
       found.insert(name);
     }
   }
-
-  ASSERT_EQ(count, r);
+  ASSERT_EQ(found.size(), r);
   free(getdents_entries);
 
   // test readdir_r
@@ -337,12 +370,15 @@ TEST(LibCephFS, DirLs) {
   ASSERT_STREQ(result->d_name, "..");
 
   found.clear();
-  for(i = 0; i < r; ++i) {
+  while (true) {
     struct dirent rdent;
-    ASSERT_EQ(ceph_readdir_r(cmount, ls_dir, &rdent), 1);
-    ASSERT_TRUE(found.count(rdent.d_name) ==  0);
+    int len = ceph_readdir_r(cmount, ls_dir, &rdent);
+    if (len == 0)
+      break;
+    ASSERT_EQ(len, 1);
     found.insert(rdent.d_name);
   }
+  ASSERT_EQ(found.size(), r);
 
   // test readdirplus
   ceph_rewinddir(cmount, ls_dir);
@@ -355,13 +391,15 @@ TEST(LibCephFS, DirLs) {
   ASSERT_STREQ(result->d_name, "..");
 
   found.clear();
-  for(i = 0; i < r; ++i) {
+  while (true) {
     struct dirent rdent;
     struct stat st;
     int stmask;
-    ASSERT_EQ(ceph_readdirplus_r(cmount, ls_dir, &rdent, &st, &stmask), 1);
+    int len = ceph_readdirplus_r(cmount, ls_dir, &rdent, &st, &stmask);
+    if (len == 0)
+      break;
+    ASSERT_EQ(len, 1);
     const char *name = rdent.d_name;
-    ASSERT_TRUE(found.count(name) == 0);
     found.insert(name);
     int size;
     sscanf(name, "dirf%d", &size);
@@ -369,6 +407,7 @@ TEST(LibCephFS, DirLs) {
     ASSERT_EQ(st.st_ino, rdent.d_ino);
     //ASSERT_EQ(st.st_mode, (mode_t)0666);
   }
+  ASSERT_EQ(found.size(), r);
 
   ASSERT_EQ(ceph_closedir(cmount, ls_dir), 0);
 
@@ -652,7 +691,9 @@ TEST(LibCephFS, Fchown) {
   ASSERT_EQ(ceph_fchmod(cmount, fd, 0600), 0);
 
   // change ownership to nobody -- we assume nobody exists and id is always 65534
+  ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "0"), 0);
   ASSERT_EQ(ceph_fchown(cmount, fd, 65534, 65534), 0);
+  ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "1"), 0);
 
   ceph_close(cmount, fd);
 
diff --git a/src/test/librados/TestCase.h b/src/test/librados/TestCase.h
index bcef5a0..8e9a93d 100644
--- a/src/test/librados/TestCase.h
+++ b/src/test/librados/TestCase.h
@@ -206,4 +206,17 @@ protected:
   std::string nspace;
   uint64_t alignment;
 };
+
+/**
+ * Test case without creating a temporary pool in advance.
+ * This is necessary for scenarios such that we need to
+ * manually create a pool, start some long-runing tasks and
+ * then the related pool is suddenly gone.
+ */
+class RadosTestNP: public ::testing::Test {
+public:
+  RadosTestNP() {}
+  virtual ~RadosTestNP() {}
+};
+
 #endif
diff --git a/src/test/librados/cmd.cc b/src/test/librados/cmd.cc
index d5e9d71..9261fb5 100644
--- a/src/test/librados/cmd.cc
+++ b/src/test/librados/cmd.cc
@@ -93,6 +93,27 @@ TEST(LibRadosCmd, OSDCmd) {
   rados_shutdown(cluster);
 }
 
+TEST(LibRadosCmd, OSDCmdPP) {
+  Rados cluster;
+  ASSERT_EQ("", connect_cluster_pp(cluster));
+  int r;
+  bufferlist inbl, outbl;
+  string outs;
+  string cmd;
+
+  // note: tolerate NXIO here in case the cluster is thrashing out underneath us.
+  cmd = "asdfasdf";
+  r = cluster.osd_command(0, cmd, inbl, &outbl, &outs);
+  ASSERT_TRUE(r == -22 || r == -ENXIO);
+  cmd = "version";
+  r = cluster.osd_command(0, cmd, inbl, &outbl, &outs);
+  ASSERT_TRUE(r == -22 || r == -ENXIO);
+  cmd = "{\"prefix\":\"version\"}";
+  r = cluster.osd_command(0, cmd, inbl, &outbl, &outs);
+  ASSERT_TRUE((r == 0 && outbl.length() > 0) || (r == -ENXIO && outbl.length() == 0));
+  cluster.shutdown();
+}
+
 TEST(LibRadosCmd, PGCmd) {
   rados_t cluster;
   std::string pool_name = get_temp_pool_name();
@@ -135,6 +156,45 @@ TEST(LibRadosCmd, PGCmd) {
   ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
 }
 
+TEST(LibRadosCmd, PGCmdPP) {
+  Rados cluster;
+  std::string pool_name = get_temp_pool_name();
+  ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+
+  int r;
+  bufferlist inbl, outbl;
+  string outs;
+  string cmd;
+
+  int64_t poolid = cluster.pool_lookup(pool_name.c_str());
+  ASSERT_LT(0, poolid);
+
+  string pgid = stringify(poolid) + ".0";
+
+  cmd = "asdfasdf";
+  // note: tolerate NXIO here in case the cluster is thrashing out underneath us.
+  r = cluster.pg_command(pgid.c_str(), cmd, inbl, &outbl, &outs);
+  ASSERT_TRUE(r == -22 || r == -ENXIO);
+
+  // make sure the pg exists on the osd before we query it
+  IoCtx io;
+  cluster.ioctx_create(pool_name.c_str(), io);
+  for (int i=0; i<100; i++) {
+    string oid = "obj" + stringify(i);
+    ASSERT_EQ(-ENOENT, io.stat(oid, NULL, NULL));
+  }
+  io.close();
+
+  cmd = "{\"prefix\":\"pg\", \"cmd\":\"query\", \"pgid\":\"" +  pgid + "\"}";
+  // note: tolerate ENOENT/ENXIO here if hte osd is thrashing out underneath us
+  r = cluster.pg_command(pgid.c_str(), cmd, inbl, &outbl, &outs);
+  ASSERT_TRUE(r == 0 || r == -ENOENT || r == -ENXIO);
+
+  ASSERT_LT(0u, outbl.length());
+
+  ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+}
+
 struct Log {
   list<string> log;
   Cond cond;
@@ -182,15 +242,11 @@ TEST(LibRadosCmd, WatchLog) {
   }
   ASSERT_TRUE(l.contains("onexx"));
 
-  /*
-    changing the subscribe level is currently broken.
-
   cmd[0] = (char *)"{\"prefix\":\"log\", \"logtext\":[\"twoxx\"]}";
   ASSERT_EQ(0, rados_monitor_log(cluster, "err", log_cb, &l));
   ASSERT_EQ(0, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen));
   sleep(2);
   ASSERT_FALSE(l.contains("twoxx"));
-  */
 
   ASSERT_EQ(0, rados_monitor_log(cluster, "info", log_cb, &l));
   cmd[0] = (char *)"{\"prefix\":\"log\", \"logtext\":[\"threexx\"]}";
diff --git a/src/test/librados/list.cc b/src/test/librados/list.cc
index 0e6aa5b..eb65ded 100644
--- a/src/test/librados/list.cc
+++ b/src/test/librados/list.cc
@@ -1,4 +1,5 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
 #include "include/rados/librados.h"
 #include "include/rados/librados.hpp"
 #include "include/stringify.h"
@@ -6,6 +7,7 @@
 #include "test/librados/TestCase.h"
 
 #include "include/types.h"
+#include "common/hobject.h"
 #include "gtest/gtest.h"
 #include <errno.h>
 #include <string>
@@ -17,6 +19,7 @@ typedef RadosTestNS LibRadosList;
 typedef RadosTestPPNS LibRadosListPP;
 typedef RadosTestECNS LibRadosListEC;
 typedef RadosTestECPPNS LibRadosListECPP;
+typedef RadosTestNP LibRadosListNP;
 
 TEST_F(LibRadosList, ListObjects) {
   char buf[128];
@@ -34,6 +37,7 @@ TEST_F(LibRadosList, ListObjects) {
   rados_objects_list_close(ctx);
 }
 
+
 #pragma GCC diagnostic ignored "-Wpragmas"
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -665,5 +669,242 @@ TEST_F(LibRadosListECPP, ListObjectsStartPP) {
   }
 }
 
+
+TEST_F(LibRadosList, EnumerateObjects) {
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+
+  const uint32_t n_objects = 16;
+  for (unsigned i=0; i<n_objects; ++i) {
+    ASSERT_EQ(0, rados_write(ioctx, stringify(i).c_str(), buf, sizeof(buf), 0));
+  }
+
+  // Ensure a non-power-of-two PG count to avoid only
+  // touching the easy path.
+  std::string err_str = set_pg_num(&s_cluster, pool_name, 11);
+  ASSERT_TRUE(err_str.empty());
+
+  std::set<std::string> saw_obj;
+  rados_object_list_cursor c = rados_object_list_begin(ioctx);
+  rados_object_list_cursor end = rados_object_list_end(ioctx);
+  while(!rados_object_list_is_end(ioctx, c))
+  {
+    rados_object_list_item results[12];
+    memset(results, 0, sizeof(rados_object_list_item) * 12);
+    int r = rados_object_list(ioctx,
+            c, rados_object_list_end(ioctx),
+            12, results, &c);
+    ASSERT_GE(r, 0);
+    for (int i = 0; i < r; ++i) {
+      std::string oid(results[i].oid, results[i].oid_length);
+      if (saw_obj.count(oid)) {
+          std::cerr << "duplicate obj " << oid << std::endl;
+      }
+      ASSERT_FALSE(saw_obj.count(oid));
+      saw_obj.insert(oid);
+    }
+    rados_object_list_free(12, results);
+  }
+  rados_object_list_cursor_free(ioctx, c);
+  rados_object_list_cursor_free(ioctx, end);
+
+  for (unsigned i=0; i<n_objects; ++i) {
+    if (!saw_obj.count(stringify(i))) {
+        std::cerr << "missing object " << i << std::endl;
+    }
+    ASSERT_TRUE(saw_obj.count(stringify(i)));
+  }
+  ASSERT_EQ(n_objects, saw_obj.size());
+}
+
+TEST_F(LibRadosList, EnumerateObjectsSplit) {
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+
+  const uint32_t n_objects = 16;
+  for (unsigned i=0; i<n_objects; ++i) {
+    ASSERT_EQ(0, rados_write(ioctx, stringify(i).c_str(), buf, sizeof(buf), 0));
+  }
+
+  // Ensure a non-power-of-two PG count to avoid only
+  // touching the easy path.
+  std::string err_str = set_pg_num(&s_cluster, pool_name, 11);
+  ASSERT_TRUE(err_str.empty());
+
+  rados_object_list_cursor begin = rados_object_list_begin(ioctx);
+  rados_object_list_cursor end = rados_object_list_end(ioctx);
+
+  // Step through an odd number of shards
+  unsigned m = 5;
+  std::set<std::string> saw_obj;
+  for (unsigned n = 0; n < m; ++n) {
+      rados_object_list_cursor shard_start = rados_object_list_begin(ioctx);;
+      rados_object_list_cursor shard_end = rados_object_list_end(ioctx);;
+
+      rados_object_list_slice(
+        ioctx,
+        begin,
+        end,
+        n,
+        m,
+        &shard_start,
+        &shard_end);
+      std::cout << "split " << n << "/" << m << " -> "
+		<< *(hobject_t*)shard_start << " "
+		<< *(hobject_t*)shard_end << std::endl;
+
+      rados_object_list_cursor c = shard_start;
+      //while(c < shard_end)
+      while(rados_object_list_cursor_cmp(ioctx, c, shard_end) == -1)
+      {
+        rados_object_list_item results[12];
+        memset(results, 0, sizeof(rados_object_list_item) * 12);
+        int r = rados_object_list(ioctx,
+                c, shard_end,
+                12, results, &c);
+        ASSERT_GE(r, 0);
+        for (int i = 0; i < r; ++i) {
+          std::string oid(results[i].oid, results[i].oid_length);
+          if (saw_obj.count(oid)) {
+              std::cerr << "duplicate obj " << oid << std::endl;
+          }
+          ASSERT_FALSE(saw_obj.count(oid));
+          saw_obj.insert(oid);
+        }
+        rados_object_list_free(12, results);
+      }
+      rados_object_list_cursor_free(ioctx, shard_start);
+      rados_object_list_cursor_free(ioctx, shard_end);
+  }
+
+  rados_object_list_cursor_free(ioctx, begin);
+  rados_object_list_cursor_free(ioctx, end);
+
+  for (unsigned i=0; i<n_objects; ++i) {
+    if (!saw_obj.count(stringify(i))) {
+        std::cerr << "missing object " << i << std::endl;
+    }
+    ASSERT_TRUE(saw_obj.count(stringify(i)));
+  }
+  ASSERT_EQ(n_objects, saw_obj.size());
+}
+
+TEST_F(LibRadosListPP, EnumerateObjectsPP) {
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+  bufferlist bl;
+  bl.append(buf, sizeof(buf));
+
+  const uint32_t n_objects = 16;
+  for (unsigned i=0; i<n_objects; ++i) {
+    ASSERT_EQ(0, ioctx.write(stringify(i), bl, sizeof(buf), 0));
+  }
+
+  std::set<std::string> saw_obj;
+  ObjectCursor c = ioctx.object_list_begin();
+  ObjectCursor end = ioctx.object_list_end();
+  while(!ioctx.object_list_is_end(c))
+  {
+    std::vector<ObjectItem> result;
+    int r = ioctx.object_list(c, end, 12, &result, &c);
+    ASSERT_GE(r, 0);
+    ASSERT_EQ(r, result.size());
+    for (int i = 0; i < r; ++i) {
+      auto oid = result[i].oid;
+      if (saw_obj.count(oid)) {
+          std::cerr << "duplicate obj " << oid << std::endl;
+      }
+      ASSERT_FALSE(saw_obj.count(oid));
+      saw_obj.insert(oid);
+    }
+  }
+
+  for (unsigned i=0; i<n_objects; ++i) {
+    if (!saw_obj.count(stringify(i))) {
+        std::cerr << "missing object " << i << std::endl;
+    }
+    ASSERT_TRUE(saw_obj.count(stringify(i)));
+  }
+  ASSERT_EQ(n_objects, saw_obj.size());
+}
+
+TEST_F(LibRadosListPP, EnumerateObjectsSplitPP) {
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+  bufferlist bl;
+  bl.append(buf, sizeof(buf));
+
+  const uint32_t n_objects = 16;
+  for (unsigned i=0; i<n_objects; ++i) {
+    ASSERT_EQ(0, ioctx.write(stringify(i), bl, sizeof(buf), 0));
+  }
+
+  ObjectCursor begin = ioctx.object_list_begin();
+  ObjectCursor end = ioctx.object_list_end();
+
+  // Step through an odd number of shards
+  unsigned m = 5;
+  std::set<std::string> saw_obj;
+  for (unsigned n = 0; n < m; ++n) {
+      ObjectCursor shard_start;
+      ObjectCursor shard_end;
+
+      ioctx.object_list_slice(
+        begin,
+        end,
+        n,
+        m,
+        &shard_start,
+        &shard_end);
+
+      ObjectCursor c(shard_start);
+      while(c < shard_end)
+      {
+        std::vector<ObjectItem> result;
+        int r = ioctx.object_list(c, shard_end, 12, &result, &c);
+        ASSERT_GE(r, 0);
+
+        for (const auto & i : result) {
+          const auto &oid = i.oid;
+          if (saw_obj.count(oid)) {
+              std::cerr << "duplicate obj " << oid << std::endl;
+          }
+          ASSERT_FALSE(saw_obj.count(oid));
+          saw_obj.insert(oid);
+        }
+      }
+  }
+
+  for (unsigned i=0; i<n_objects; ++i) {
+    if (!saw_obj.count(stringify(i))) {
+        std::cerr << "missing object " << i << std::endl;
+    }
+    ASSERT_TRUE(saw_obj.count(stringify(i)));
+  }
+  ASSERT_EQ(n_objects, saw_obj.size());
+}
+
+TEST_F(LibRadosListNP, ListObjectsError) {
+  std::string pool_name;
+  rados_t cluster;
+  rados_ioctx_t ioctx;
+  pool_name = get_temp_pool_name();
+  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
+  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+  rados_ioctx_set_namespace(ioctx, "");
+  ASSERT_EQ(0, rados_write(ioctx, "foo", buf, sizeof(buf), 0));
+  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
+  
+  rados_list_ctx_t ctx;
+  ASSERT_EQ(0, rados_objects_list_open(ioctx, &ctx));
+  const char *entry;
+  ASSERT_EQ(-ENOENT, rados_objects_list_next(ctx, &entry, NULL));
+  rados_objects_list_close(ctx);
+  rados_ioctx_destroy(ioctx);
+  rados_shutdown(cluster);
+}
+
 #pragma GCC diagnostic pop
 #pragma GCC diagnostic warning "-Wpragmas"
diff --git a/src/test/librados/nlist.cc b/src/test/librados/nlist.cc
index 19ff73f..c6fa82d 100644
--- a/src/test/librados/nlist.cc
+++ b/src/test/librados/nlist.cc
@@ -16,6 +16,7 @@ typedef RadosTestNS LibRadosList;
 typedef RadosTestPPNS LibRadosListPP;
 typedef RadosTestECNS LibRadosListEC;
 typedef RadosTestECPPNS LibRadosListECPP;
+typedef RadosTestNP LibRadosListNP;
 
 TEST_F(LibRadosList, ListObjects) {
   char buf[128];
@@ -730,3 +731,25 @@ TEST_F(LibRadosListPP, ListObjectsFilterPP) {
   ASSERT_TRUE(foundit);
 }
 
+TEST_F(LibRadosListNP, ListObjectsError) {
+  std::string pool_name;
+  rados_t cluster;
+  rados_ioctx_t ioctx;
+  pool_name = get_temp_pool_name();
+  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
+  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+  rados_ioctx_set_namespace(ioctx, "");
+  ASSERT_EQ(0, rados_write(ioctx, "foo", buf, sizeof(buf), 0));
+  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
+  
+  rados_list_ctx_t ctx;
+  ASSERT_EQ(0, rados_nobjects_list_open(ioctx, &ctx));
+  const char *entry;
+  ASSERT_EQ(-ENOENT, rados_nobjects_list_next(ctx, &entry, NULL, NULL));
+  rados_nobjects_list_close(ctx);
+  rados_ioctx_destroy(ioctx);
+  rados_shutdown(cluster);
+}
+
diff --git a/src/test/librados/test.cc b/src/test/librados/test.cc
index b82936a..469b714 100644
--- a/src/test/librados/test.cc
+++ b/src/test/librados/test.cc
@@ -5,6 +5,11 @@
 #include "include/rados/librados.hpp"
 #include "test/librados/test.h"
 
+#include "include/stringify.h"
+#include "common/Formatter.h"
+#include "json_spirit/json_spirit.h"
+#include "errno.h"
+
 #include <sstream>
 #include <stdlib.h>
 #include <string>
@@ -30,18 +35,113 @@ std::string get_temp_pool_name()
   return prefix;
 }
 
-std::string create_one_pool(const std::string &pool_name, rados_t *cluster)
+int wait_for_healthy(rados_t *cluster)
 {
-  std::string err = connect_cluster(cluster);
-  if (err.length())
-    return err;
+  bool healthy = false;
+  // This timeout is very long because the tests are sometimes
+  // run on a thrashing cluster
+  int timeout = 3600;
+  int slept = 0;
+
+  while(!healthy) {
+    JSONFormatter cmd_f;
+    cmd_f.open_object_section("command");
+    cmd_f.dump_string("prefix", "status");
+    cmd_f.dump_string("format", "json");
+    cmd_f.close_section();
+    std::ostringstream cmd_stream;
+    cmd_f.flush(cmd_stream);
+    const std::string serialized_cmd = cmd_stream.str();
+
+    const char *cmd[2];
+    cmd[1] = NULL;
+    cmd[0] = serialized_cmd.c_str();
+
+    char *outbuf = NULL;
+    size_t outlen = 0;
+    int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0,
+        &outbuf, &outlen, NULL, NULL);
+    if (ret) {
+      return ret;
+    }
+
+    std::string out(outbuf, outlen);
+    rados_buffer_free(outbuf);
+
+    json_spirit::mValue root;
+    assert(json_spirit::read(out, root));
+    json_spirit::mObject root_obj = root.get_obj();
+    json_spirit::mObject pgmap = root_obj["pgmap"].get_obj();
+    json_spirit::mArray pgs_by_state = pgmap["pgs_by_state"].get_array();
+
+    if (pgs_by_state.size() == 1) {
+      json_spirit::mObject state = pgs_by_state[0].get_obj();
+      std::string state_name = state["state_name"].get_str();
+      if (state_name != std::string("active+clean")) {
+        healthy = false;
+      } else {
+        healthy = true;
+      }
+
+    } else {
+      healthy = false;
+    }
+
+    if (slept >= timeout) {
+      return -ETIMEDOUT;
+    };
+
+    if (!healthy) {
+      sleep(1);
+      slept += 1;
+    }
+  }
+
+  return 0;
+}
+
+int rados_pool_set(
+    rados_t *cluster,
+    const std::string &pool_name,
+    const std::string &var,
+    const std::string val)
+{
+  JSONFormatter cmd_f;
+  cmd_f.open_object_section("command");
+  cmd_f.dump_string("prefix", "osd pool set"); 
+  cmd_f.dump_string("pool", pool_name);
+  cmd_f.dump_string("var", var);
+  cmd_f.dump_string("val", val);
+  cmd_f.close_section();
+
+  std::ostringstream cmd_stream;
+  cmd_f.flush(cmd_stream);
+
+  const std::string serialized_cmd = cmd_stream.str();
+
+  const char *cmd[2];
+  cmd[1] = NULL;
+  cmd[0] = serialized_cmd.c_str();
+  int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL,
+      NULL, NULL, NULL);
+  return ret;
+}
+
+std::string create_one_pool(
+    const std::string &pool_name, rados_t *cluster, uint32_t pg_num)
+{
+  std::string err_str = connect_cluster(cluster);
+  if (err_str.length())
+    return err_str;
+
   int ret = rados_pool_create(*cluster, pool_name.c_str());
   if (ret) {
     rados_shutdown(*cluster);
     std::ostringstream oss;
-    oss << "rados_pool_create(" << pool_name << ") failed with error " << ret;
+    oss << "create_one_pool(" << pool_name << ") failed with error " << ret;
     return oss.str();
   }
+
   return "";
 }
 
@@ -82,6 +182,36 @@ int destroy_ec_profile_and_ruleset(rados_t *cluster,
   return destroy_ruleset(cluster, ruleset, oss);
 }
 
+std::string set_pg_num(
+    rados_t *cluster, const std::string &pool_name, uint32_t pg_num)
+{
+  // Wait for 'creating' to clear
+  int r = wait_for_healthy(cluster);
+  if (r != 0) {
+    goto err;
+  }
+
+  // Adjust pg_num
+  r = rados_pool_set(cluster, pool_name, "pg_num", stringify(pg_num));
+  if (r != 0) {
+    goto err;
+  }
+
+  // Wait for 'creating' to clear
+  r = wait_for_healthy(cluster);
+  if (r != 0) {
+    goto err;
+  }
+
+  return "";
+
+err:
+  rados_shutdown(*cluster);
+  std::ostringstream oss;
+  oss << __func__ << "(" << pool_name << ") failed with error " << r;
+  return oss.str();
+}
+
 std::string create_one_ec_pool(const std::string &pool_name, rados_t *cluster)
 {
   std::string err = connect_cluster(cluster);
diff --git a/src/test/librados/test.h b/src/test/librados/test.h
index cd1f981..c5f948c 100644
--- a/src/test/librados/test.h
+++ b/src/test/librados/test.h
@@ -24,12 +24,16 @@
 
 std::string get_temp_pool_name();
 
-std::string create_one_pool(const std::string &pool_name, rados_t *cluster);
+std::string create_one_pool(const std::string &pool_name, rados_t *cluster,
+    uint32_t pg_num=0);
 std::string create_one_ec_pool(const std::string &pool_name, rados_t *cluster);
 std::string create_one_pool_pp(const std::string &pool_name,
 			    librados::Rados &cluster);
 std::string create_one_ec_pool_pp(const std::string &pool_name,
 			    librados::Rados &cluster);
+std::string set_pg_num(
+    rados_t *cluster, const std::string &pool_name, uint32_t pg_num);
+
 std::string connect_cluster(rados_t *cluster);
 std::string connect_cluster_pp(librados::Rados &cluster);
 int destroy_one_pool(const std::string &pool_name, rados_t *cluster);
diff --git a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h
index b0a481b..c9da11b 100644
--- a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h
+++ b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h
@@ -79,6 +79,12 @@ public:
     return TestMemIoCtxImpl::selfmanaged_snap_remove(snap_id);
   }
 
+  MOCK_METHOD2(selfmanaged_snap_rollback, int(const std::string& oid,
+                                              uint64_t snap_id));
+  int do_selfmanaged_snap_rollback(const std::string& oid, uint64_t snap_id) {
+    return TestMemIoCtxImpl::selfmanaged_snap_rollback(oid, snap_id);
+  }
+
   MOCK_METHOD3(truncate, int(const std::string& oid,
                              uint64_t size,
                              const SnapContext &snapc));
@@ -87,6 +93,13 @@ public:
     return TestMemIoCtxImpl::truncate(oid, size, snapc);
   }
 
+  MOCK_METHOD5(write, int(const std::string& oid, bufferlist& bl, size_t len,
+                          uint64_t off, const SnapContext &snapc));
+  int do_write(const std::string& oid, bufferlist& bl, size_t len, uint64_t off,
+                    const SnapContext &snapc) {
+    return TestMemIoCtxImpl::write(oid, bl, len, off, snapc);
+  }
+
   MOCK_METHOD3(write_full, int(const std::string& oid,
                                bufferlist& bl,
                                const SnapContext &snapc));
@@ -104,7 +117,9 @@ public:
     ON_CALL(*this, remove(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_remove));
     ON_CALL(*this, selfmanaged_snap_create(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_create));
     ON_CALL(*this, selfmanaged_snap_remove(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_remove));
+    ON_CALL(*this, selfmanaged_snap_rollback(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_rollback));
     ON_CALL(*this, truncate(_,_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_truncate));
+    ON_CALL(*this, write(_, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_write));
     ON_CALL(*this, write_full(_, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_write_full));
   }
 
diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc
index 3c26d5e..7330b99 100644
--- a/src/test/librbd/fsx.cc
+++ b/src/test/librbd/fsx.cc
@@ -37,6 +37,8 @@
 #include <assert.h>
 #include <errno.h>
 #include <math.h>
+#include <fcntl.h>
+#include <random>
 
 #include "include/intarith.h"
 #include "include/krbd.h"
@@ -233,22 +235,12 @@ simple_err(const char *msg, int err)
 /*
  * random
  */
+std::mt19937 random_generator;
 
-#define RND_STATE_LEN	256
-char	rnd_state[RND_STATE_LEN];
-struct random_data rnd_data;
-
-int32_t
+uint_fast32_t
 get_random(void)
 {
-	int32_t val;
-
-	if (random_r(&rnd_data, &val) < 0) {
-		prterr("random_r");
-		exit(1);
-	}
-
-	return val;
+	return random_generator();
 }
 
 /*
@@ -2335,14 +2327,7 @@ main(int argc, char **argv)
 	signal(SIGUSR1,	cleanup);
 	signal(SIGUSR2,	cleanup);
 
-	if (initstate_r(seed, rnd_state, RND_STATE_LEN, &rnd_data) < 0) {
-		prterr("initstate_r");
-		exit(1);
-	}
-	if (setstate_r(rnd_state, &rnd_data) < 0) {
-		prterr("setstate_r");
-		exit(1);
-	}
+	random_generator.seed(seed);
 
 	ret = create_image();
 	if (ret < 0) {
diff --git a/src/test/librbd/test_JournalEntries.cc b/src/test/librbd/journal/test_Entries.cc
similarity index 99%
rename from src/test/librbd/test_JournalEntries.cc
rename to src/test/librbd/journal/test_Entries.cc
index 1b8e082..d651d6f 100644
--- a/src/test/librbd/test_JournalEntries.cc
+++ b/src/test/librbd/journal/test_Entries.cc
@@ -7,7 +7,7 @@
 #include "librbd/AioImageRequestWQ.h"
 #include "librbd/internal.h"
 #include "librbd/Journal.h"
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
 #include "journal/Journaler.h"
 #include "journal/ReplayEntry.h"
 #include "journal/ReplayHandler.h"
diff --git a/src/test/librbd/test_JournalReplay.cc b/src/test/librbd/journal/test_Replay.cc
similarity index 86%
rename from src/test/librbd/test_JournalReplay.cc
rename to src/test/librbd/journal/test_Replay.cc
index c5a6ad6..f0f0409 100644
--- a/src/test/librbd/test_JournalReplay.cc
+++ b/src/test/librbd/journal/test_Replay.cc
@@ -10,7 +10,7 @@
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageWatcher.h"
 #include "librbd/Journal.h"
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
 
 void register_test_journal_replay() {
 }
@@ -63,10 +63,11 @@ TEST_F(TestJournalReplay, AioDiscardEvent) {
 
   librbd::journal::EventEntry event_entry(
     librbd::journal::AioDiscardEvent(0, payload.size()));
-  librbd::Journal::AioObjectRequests requests;
+  librbd::Journal<>::AioObjectRequests requests;
   {
     RWLock::RLocker owner_locker(ictx->owner_lock);
-    ictx->journal->append_io_event(NULL, event_entry, requests, 0, 0, true);
+    ictx->journal->append_io_event(NULL, std::move(event_entry), requests, 0, 0,
+                                   true);
   }
 
   // re-open the journal so that it replays the new entry
@@ -94,10 +95,11 @@ TEST_F(TestJournalReplay, AioWriteEvent) {
   payload_bl.append(payload);
   librbd::journal::EventEntry event_entry(
     librbd::journal::AioWriteEvent(0, payload.size(), payload_bl));
-  librbd::Journal::AioObjectRequests requests;
+  librbd::Journal<>::AioObjectRequests requests;
   {
     RWLock::RLocker owner_locker(ictx->owner_lock);
-    ictx->journal->append_io_event(NULL, event_entry, requests, 0, 0, true);
+    ictx->journal->append_io_event(NULL, std::move(event_entry), requests, 0, 0,
+                                   true);
   }
 
   // re-open the journal so that it replays the new entry
@@ -124,22 +126,23 @@ TEST_F(TestJournalReplay, AioFlushEvent) {
 
   librbd::journal::AioFlushEvent aio_flush_event;
   librbd::journal::EventEntry event_entry(aio_flush_event);
-  librbd::Journal::AioObjectRequests requests;
+  librbd::Journal<>::AioObjectRequests requests;
   {
     RWLock::RLocker owner_locker(ictx->owner_lock);
-    ictx->journal->append_io_event(NULL, event_entry, requests, 0, 0, true);
+    ictx->journal->append_io_event(NULL, std::move(event_entry), requests, 0, 0,
+                                   true);
   }
 
   // start an AIO write op
-  librbd::Journal *journal = ictx->journal;
+  librbd::Journal<> *journal = ictx->journal;
   ictx->journal = NULL;
 
   std::string payload(m_image_size, '1');
   librbd::AioCompletion *aio_comp = new librbd::AioCompletion();
   {
     RWLock::RLocker owner_lock(ictx->owner_lock);
-    librbd::AioImageRequest::aio_write(ictx, aio_comp, 0, payload.size(),
-                                       payload.c_str(), 0);
+    librbd::AioImageRequest<>::aio_write(ictx, aio_comp, 0, payload.size(),
+                                         payload.c_str(), 0);
   }
   ictx->journal = journal;
 
diff --git a/src/test/librbd/journal/test_mock_Replay.cc b/src/test/librbd/journal/test_mock_Replay.cc
new file mode 100644
index 0000000..81e8dd1
--- /dev/null
+++ b/src/test/librbd/journal/test_mock_Replay.cc
@@ -0,0 +1,790 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "test/librbd/test_mock_fixture.h"
+#include "test/librbd/test_support.h"
+#include "test/librbd/mock/MockImageCtx.h"
+#include "librbd/AioImageRequest.h"
+#include "librbd/journal/Entries.h"
+#include "librbd/journal/Replay.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include <boost/scope_exit.hpp>
+
+namespace librbd {
+
+template <>
+struct AioImageRequest<MockImageCtx> {
+  static AioImageRequest *s_instance;
+
+  MOCK_METHOD5(aio_write, void(AioCompletion *c, uint64_t off, size_t len,
+                               const char *buf, int op_flags));
+  static void aio_write(MockImageCtx *ictx, AioCompletion *c, uint64_t off,
+                        size_t len, const char *buf, int op_flags) {
+    assert(s_instance != nullptr);
+    s_instance->aio_write(c, off, len, buf, op_flags);
+  }
+
+  MOCK_METHOD3(aio_discard, void(AioCompletion *c, uint64_t off, uint64_t len));
+  static void aio_discard(MockImageCtx *ictx, AioCompletion *c, uint64_t off,
+                          uint64_t len) {
+    assert(s_instance != nullptr);
+    s_instance->aio_discard(c, off, len);
+  }
+
+  MOCK_METHOD1(aio_flush, void(AioCompletion *c));
+  static void aio_flush(MockImageCtx *ictx, AioCompletion *c) {
+    assert(s_instance != nullptr);
+    s_instance->aio_flush(c);
+  }
+
+  AioImageRequest() {
+    s_instance = this;
+  }
+};
+
+AioImageRequest<MockImageCtx> *AioImageRequest<MockImageCtx>::s_instance = nullptr;
+
+}
+
+// template definitions
+#include "librbd/journal/Replay.cc"
+template class librbd::journal::Replay<librbd::MockImageCtx>;
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::InSequence;
+using ::testing::Return;
+using ::testing::SaveArg;
+using ::testing::WithArgs;
+
+MATCHER_P(CStrEq, str, "") {
+  return (strncmp(arg, str, strlen(str)) == 0);
+}
+
+ACTION_P2(CompleteAioCompletion, r, image_ctx) {
+  CephContext *cct = image_ctx->cct;
+  image_ctx->op_work_queue->queue(new FunctionContext([cct, arg0](int r) {
+      arg0->get();
+      arg0->set_request_count(cct, 1);
+      arg0->complete_request(cct, r);
+    }), r);
+}
+
+namespace librbd {
+namespace journal {
+
+class TestMockJournalReplay : public TestMockFixture {
+public:
+  typedef AioImageRequest<MockImageCtx> MockAioImageRequest;
+  typedef Replay<MockImageCtx> MockJournalReplay;
+
+  void expect_aio_discard(MockAioImageRequest &mock_aio_image_request,
+                          AioCompletion **aio_comp, uint64_t off,
+                          uint64_t len) {
+    EXPECT_CALL(mock_aio_image_request, aio_discard(_, off, len))
+                  .WillOnce(SaveArg<0>(aio_comp));
+  }
+
+  void expect_aio_flush(MockAioImageRequest &mock_aio_image_request,
+                        AioCompletion **aio_comp) {
+    EXPECT_CALL(mock_aio_image_request, aio_flush(_))
+                  .WillOnce(SaveArg<0>(aio_comp));
+  }
+
+  void expect_aio_flush(MockImageCtx &mock_image_ctx,
+                        MockAioImageRequest &mock_aio_image_request, int r) {
+    EXPECT_CALL(mock_aio_image_request, aio_flush(_))
+                  .WillOnce(CompleteAioCompletion(r, mock_image_ctx.image_ctx));
+  }
+
+  void expect_aio_write(MockAioImageRequest &mock_aio_image_request,
+                        AioCompletion **aio_comp, uint64_t off,
+                        uint64_t len, const char *data) {
+    EXPECT_CALL(mock_aio_image_request,
+                aio_write(_, off, len, CStrEq(data), _))
+                  .WillOnce(SaveArg<0>(aio_comp));
+  }
+
+  void expect_flatten(MockImageCtx &mock_image_ctx, Context **on_finish) {
+    EXPECT_CALL(*mock_image_ctx.operations, flatten(_, _))
+                  .WillOnce(SaveArg<1>(on_finish));
+  }
+
+  void expect_rename(MockImageCtx &mock_image_ctx, Context **on_finish,
+                     const char *image_name) {
+    EXPECT_CALL(*mock_image_ctx.operations, rename(CStrEq(image_name), _))
+                  .WillOnce(SaveArg<1>(on_finish));
+  }
+
+  void expect_resize(MockImageCtx &mock_image_ctx, Context **on_finish,
+                     uint64_t size, uint64_t op_tid) {
+    EXPECT_CALL(*mock_image_ctx.operations, resize(size, _, _, op_tid))
+                  .WillOnce(SaveArg<2>(on_finish));
+  }
+
+  void expect_snap_create(MockImageCtx &mock_image_ctx,
+                          Context **on_finish, const char *snap_name,
+                          uint64_t op_tid) {
+    EXPECT_CALL(*mock_image_ctx.operations, snap_create(CStrEq(snap_name), _,
+                                                        op_tid))
+                  .WillOnce(SaveArg<1>(on_finish));
+  }
+
+  void expect_snap_remove(MockImageCtx &mock_image_ctx,
+                          Context **on_finish, const char *snap_name) {
+    EXPECT_CALL(*mock_image_ctx.operations, snap_remove(CStrEq(snap_name), _))
+                  .WillOnce(SaveArg<1>(on_finish));
+  }
+
+  void expect_snap_rename(MockImageCtx &mock_image_ctx,
+                          Context **on_finish, uint64_t snap_id,
+                          const char *snap_name) {
+    EXPECT_CALL(*mock_image_ctx.operations, snap_rename(snap_id, CStrEq(snap_name), _))
+                  .WillOnce(SaveArg<2>(on_finish));
+  }
+
+  void expect_snap_protect(MockImageCtx &mock_image_ctx,
+                           Context **on_finish, const char *snap_name) {
+    EXPECT_CALL(*mock_image_ctx.operations, snap_protect(CStrEq(snap_name), _))
+                  .WillOnce(SaveArg<1>(on_finish));
+  }
+
+  void expect_snap_unprotect(MockImageCtx &mock_image_ctx,
+                             Context **on_finish, const char *snap_name) {
+    EXPECT_CALL(*mock_image_ctx.operations, snap_unprotect(CStrEq(snap_name), _))
+                  .WillOnce(SaveArg<1>(on_finish));
+  }
+
+  void expect_snap_rollback(MockImageCtx &mock_image_ctx,
+                            Context **on_finish, const char *snap_name) {
+    EXPECT_CALL(*mock_image_ctx.operations, snap_rollback(CStrEq(snap_name), _, _))
+                  .WillOnce(SaveArg<2>(on_finish));
+  }
+
+  void when_process(MockJournalReplay &mock_journal_replay,
+                    EventEntry &&event_entry, Context *on_ready,
+                    Context *on_safe) {
+    bufferlist bl;
+    ::encode(event_entry, bl);
+
+    bufferlist::iterator it = bl.begin();
+    when_process(mock_journal_replay, &it, on_ready, on_safe);
+  }
+
+  void when_process(MockJournalReplay &mock_journal_replay,
+                    bufferlist::iterator *it, Context *on_ready,
+                    Context *on_safe) {
+    mock_journal_replay.process(it, on_ready, on_safe);
+  }
+
+  void when_complete(MockImageCtx &mock_image_ctx, AioCompletion *aio_comp,
+                     int r) {
+    aio_comp->get();
+    aio_comp->set_request_count(mock_image_ctx.cct, 1);
+    aio_comp->complete_request(mock_image_ctx.cct, r);
+  }
+
+  int when_flush(MockJournalReplay &mock_journal_replay) {
+    C_SaferCond ctx;
+    mock_journal_replay.flush(&ctx);
+    return ctx.wait();
+  }
+
+  void when_replay_op_ready(MockJournalReplay &mock_journal_replay,
+                            uint64_t op_tid, Context *on_resume) {
+    mock_journal_replay.replay_op_ready(op_tid, on_resume);
+  }
+
+  bufferlist to_bl(const std::string &str) {
+    bufferlist bl;
+    bl.append(str);
+    return bl;
+  }
+};
+
+TEST_F(TestMockJournalReplay, AioDiscard) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  MockAioImageRequest mock_aio_image_request;
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  AioCompletion *aio_comp;
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456);
+  when_process(mock_journal_replay,
+               EventEntry{AioDiscardEvent(123, 456)},
+               &on_ready, &on_safe);
+
+  when_complete(mock_image_ctx, aio_comp, 0);
+  ASSERT_EQ(0, on_ready.wait());
+
+  expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0);
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+  ASSERT_EQ(0, on_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, AioWrite) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  MockAioImageRequest mock_aio_image_request;
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  AioCompletion *aio_comp;
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  expect_aio_write(mock_aio_image_request, &aio_comp, 123, 456, "test");
+  when_process(mock_journal_replay,
+               EventEntry{AioWriteEvent(123, 456, to_bl("test"))},
+               &on_ready, &on_safe);
+
+  when_complete(mock_image_ctx, aio_comp, 0);
+  ASSERT_EQ(0, on_ready.wait());
+
+  expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0);
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+  ASSERT_EQ(0, on_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, AioFlush) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  MockAioImageRequest mock_aio_image_request;
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  AioCompletion *aio_comp;
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  expect_aio_flush(mock_aio_image_request, &aio_comp);
+  when_process(mock_journal_replay, EventEntry{AioFlushEvent()},
+               &on_ready, &on_safe);
+
+  when_complete(mock_image_ctx, aio_comp, 0);
+  ASSERT_EQ(0, on_safe.wait());
+
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+  ASSERT_EQ(0, on_ready.wait());
+}
+
+TEST_F(TestMockJournalReplay, IOError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  MockAioImageRequest mock_aio_image_request;
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  AioCompletion *aio_comp;
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456);
+  when_process(mock_journal_replay,
+               EventEntry{AioDiscardEvent(123, 456)},
+               &on_ready, &on_safe);
+
+  when_complete(mock_image_ctx, aio_comp, -EINVAL);
+  ASSERT_EQ(-EINVAL, on_safe.wait());
+
+  expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0);
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+  ASSERT_EQ(0, on_ready.wait());
+}
+
+TEST_F(TestMockJournalReplay, SoftFlushIO) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  MockAioImageRequest mock_aio_image_request;
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  const size_t io_count = 32;
+  C_SaferCond on_safes[io_count];
+  for (size_t i = 0; i < io_count; ++i) {
+    AioCompletion *aio_comp;
+    AioCompletion *flush_comp = nullptr;
+    C_SaferCond on_ready;
+    expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456);
+    if (i == io_count - 1) {
+      expect_aio_flush(mock_aio_image_request, &flush_comp);
+    }
+    when_process(mock_journal_replay,
+                 EventEntry{AioDiscardEvent(123, 456)},
+                 &on_ready, &on_safes[i]);
+    ASSERT_EQ(0, on_ready.wait());
+
+    when_complete(mock_image_ctx, aio_comp, 0);
+    if (flush_comp != nullptr) {
+      when_complete(mock_image_ctx, flush_comp, 0);
+    }
+  }
+  for (auto &on_safe : on_safes) {
+    ASSERT_EQ(0, on_safe.wait());
+  }
+
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+}
+
+TEST_F(TestMockJournalReplay, PauseIO) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  MockAioImageRequest mock_aio_image_request;
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  const size_t io_count = 64;
+  std::list<AioCompletion *> flush_comps;
+  C_SaferCond on_safes[io_count];
+  for (size_t i = 0; i < io_count; ++i) {
+    AioCompletion *aio_comp;
+    C_SaferCond on_ready;
+    expect_aio_write(mock_aio_image_request, &aio_comp, 123, 456, "test");
+    if ((i + 1) % 32 == 0) {
+      flush_comps.push_back(nullptr);
+      expect_aio_flush(mock_aio_image_request, &flush_comps.back());
+    }
+    when_process(mock_journal_replay,
+                 EventEntry{AioWriteEvent(123, 456, to_bl("test"))},
+                 &on_ready, &on_safes[i]);
+    if (i < io_count - 1) {
+      ASSERT_EQ(0, on_ready.wait());
+    }
+
+    when_complete(mock_image_ctx, aio_comp, 0);
+    if (i == io_count - 1) {
+      for (auto flush_comp : flush_comps) {
+        when_complete(mock_image_ctx, flush_comp, 0);
+        ASSERT_EQ(0, on_ready.wait());
+      }
+    }
+  }
+  for (auto &on_safe : on_safes) {
+    ASSERT_EQ(0, on_safe.wait());
+  }
+
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+}
+
+TEST_F(TestMockJournalReplay, MissingOpFinishEvent) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  when_process(mock_journal_replay, EventEntry{SnapRemoveEvent(123, "snap")},
+               &on_ready, &on_safe);
+
+  ASSERT_EQ(0, on_ready.wait());
+
+  ASSERT_EQ(0, when_flush(mock_journal_replay));
+  ASSERT_EQ(-ERESTART, on_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, MissingCompleteOpFinishEvent) {
+  // TODO
+}
+
+TEST_F(TestMockJournalReplay, UnknownOpFinishEvent) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_ready, &on_safe);
+
+  ASSERT_EQ(0, on_safe.wait());
+  ASSERT_EQ(0, on_ready.wait());
+}
+
+TEST_F(TestMockJournalReplay, OpEventError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_remove(mock_image_ctx, &on_finish, "snap");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{SnapRemoveEvent(123, "snap")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(-EINVAL);
+  ASSERT_EQ(-EINVAL, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(-EINVAL, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, SnapCreateEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_create(mock_image_ctx, &on_finish, "snap", 123);
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{SnapCreateEvent(123, "snap")},
+               &on_start_ready, &on_start_safe);
+
+  C_SaferCond on_resume;
+  when_replay_op_ready(mock_journal_replay, 123, &on_resume);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  ASSERT_EQ(0, on_resume.wait());
+  on_finish->complete(0);
+
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, SnapRemoveEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_remove(mock_image_ctx, &on_finish, "snap");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{SnapRemoveEvent(123, "snap")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, SnapRenameEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_rename(mock_image_ctx, &on_finish, 234, "snap");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay,
+               EventEntry{SnapRenameEvent(123, 234, "snap")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, SnapProtectEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_protect(mock_image_ctx, &on_finish, "snap");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{SnapProtectEvent(123, "snap")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, SnapUnprotectEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_unprotect(mock_image_ctx, &on_finish, "snap");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{SnapUnprotectEvent(123, "snap")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, SnapRollbackEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_snap_rollback(mock_image_ctx, &on_finish, "snap");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{SnapRollbackEvent(123, "snap")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, RenameEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_rename(mock_image_ctx, &on_finish, "image");
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{RenameEvent(123, "image")},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, ResizeEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_resize(mock_image_ctx, &on_finish, 234, 123);
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{ResizeEvent(123, 234)},
+               &on_start_ready, &on_start_safe);
+
+  C_SaferCond on_resume;
+  when_replay_op_ready(mock_journal_replay, 123, &on_resume);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  ASSERT_EQ(0, on_resume.wait());
+  on_finish->complete(0);
+
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, FlattenEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  Context *on_finish;
+  expect_flatten(mock_image_ctx, &on_finish);
+
+  C_SaferCond on_start_ready;
+  C_SaferCond on_start_safe;
+  when_process(mock_journal_replay, EventEntry{FlattenEvent(123)},
+               &on_start_ready, &on_start_safe);
+  ASSERT_EQ(0, on_start_ready.wait());
+
+  C_SaferCond on_finish_ready;
+  C_SaferCond on_finish_safe;
+  when_process(mock_journal_replay, EventEntry{OpFinishEvent(123, 0)},
+               &on_finish_ready, &on_finish_safe);
+
+  on_finish->complete(0);
+  ASSERT_EQ(0, on_start_safe.wait());
+  ASSERT_EQ(0, on_finish_ready.wait());
+  ASSERT_EQ(0, on_finish_safe.wait());
+}
+
+TEST_F(TestMockJournalReplay, UnknownEvent) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournalReplay mock_journal_replay(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  bufferlist bl;
+  ENCODE_START(1, 1, bl);
+  ::encode(static_cast<uint32_t>(-1), bl);
+  ENCODE_FINISH(bl);
+
+  bufferlist::iterator it = bl.begin();
+  C_SaferCond on_ready;
+  C_SaferCond on_safe;
+  when_process(mock_journal_replay, &it, &on_ready, &on_safe);
+
+  ASSERT_EQ(0, on_safe.wait());
+  ASSERT_EQ(0, on_ready.wait());
+}
+
+} // namespace journal
+} // namespace librbd
diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h
index c196920..7d198f5 100644
--- a/src/test/librbd/mock/MockImageCtx.h
+++ b/src/test/librbd/mock/MockImageCtx.h
@@ -10,6 +10,7 @@
 #include "test/librbd/mock/MockImageWatcher.h"
 #include "test/librbd/mock/MockJournal.h"
 #include "test/librbd/mock/MockObjectMap.h"
+#include "test/librbd/mock/MockOperations.h"
 #include "test/librbd/mock/MockReadahead.h"
 #include "common/RWLock.h"
 #include "common/WorkQueue.h"
@@ -18,13 +19,19 @@
 
 namespace librbd {
 
+namespace operation {
+template <typename> class ResizeRequest;
+}
+
 struct MockImageCtx {
   MockImageCtx(librbd::ImageCtx &image_ctx)
     : image_ctx(&image_ctx),
       cct(image_ctx.cct),
+      snap_id(image_ctx.snap_id),
       snapc(image_ctx.snapc),
       snaps(image_ctx.snaps),
       snap_info(image_ctx.snap_info),
+      object_cacher(image_ctx.object_cacher),
       old_format(image_ctx.old_format),
       read_only(image_ctx.read_only),
       owner_lock("owner_lock"),
@@ -41,11 +48,19 @@ struct MockImageCtx {
       layout(image_ctx.layout),
       aio_work_queue(new MockAioImageRequestWQ()),
       op_work_queue(new MockContextWQ()),
-      parent(NULL), image_watcher(NULL), object_map(NULL),
+      parent(NULL), operations(new MockOperations()),
+      image_watcher(NULL), object_map(NULL),
       exclusive_lock(NULL), journal(NULL),
       concurrent_management_ops(image_ctx.concurrent_management_ops),
       blacklist_on_break_lock(image_ctx.blacklist_on_break_lock),
-      blacklist_expire_seconds(image_ctx.blacklist_expire_seconds)
+      blacklist_expire_seconds(image_ctx.blacklist_expire_seconds),
+      journal_order(image_ctx.journal_order),
+      journal_splay_width(image_ctx.journal_splay_width),
+      journal_commit_age(image_ctx.journal_commit_age),
+      journal_object_flush_interval(image_ctx.journal_object_flush_interval),
+      journal_object_flush_bytes(image_ctx.journal_object_flush_bytes),
+      journal_object_flush_age(image_ctx.journal_object_flush_age),
+      journal_pool(image_ctx.journal_pool)
   {
     md_ctx.dup(image_ctx.md_ctx);
     data_ctx.dup(image_ctx.data_ctx);
@@ -60,6 +75,7 @@ struct MockImageCtx {
     image_ctx->md_ctx.aio_flush();
     image_ctx->data_ctx.aio_flush();
     image_ctx->op_work_queue->drain();
+    delete operations;
     delete image_watcher;
     delete op_work_queue;
     delete aio_work_queue;
@@ -79,6 +95,8 @@ struct MockImageCtx {
     ctx.wait();
   }
 
+  MOCK_CONST_METHOD1(get_object_name, std::string(uint64_t));
+  MOCK_CONST_METHOD0(get_current_size, uint64_t());
   MOCK_CONST_METHOD1(get_image_size, uint64_t(librados::snap_t));
   MOCK_CONST_METHOD1(get_snap_id, librados::snap_t(std::string in_snap_name));
   MOCK_CONST_METHOD1(get_snap_info, const SnapInfo*(librados::snap_t));
@@ -98,6 +116,7 @@ struct MockImageCtx {
   MOCK_METHOD1(flush, void(Context *));
   MOCK_METHOD1(flush_copyup, void(Context *));
 
+  MOCK_METHOD1(invalidate_cache, void(Context *));
   MOCK_METHOD1(shut_down_cache, void(Context *));
 
   MOCK_CONST_METHOD1(test_features, bool(uint64_t test_features));
@@ -110,10 +129,12 @@ struct MockImageCtx {
   ImageCtx *image_ctx;
   CephContext *cct;
 
+  uint64_t snap_id;
   ::SnapContext snapc;
   std::vector<librados::snap_t> snaps;
   std::map<librados::snap_t, SnapInfo> snap_info;
 
+  ObjectCacher *object_cacher;
 
   bool old_format;
   bool read_only;
@@ -136,15 +157,18 @@ struct MockImageCtx {
 
   ceph_file_layout layout;
 
+  xlist<operation::ResizeRequest<MockImageCtx>*> resize_reqs;
   xlist<AsyncRequest<MockImageCtx>*> async_requests;
   std::list<Context*> async_requests_waiters;
 
+
   MockAioImageRequestWQ *aio_work_queue;
   MockContextWQ *op_work_queue;
 
   MockReadahead readahead;
 
   MockImageCtx *parent;
+  MockOperations *operations;
 
   MockImageWatcher *image_watcher;
   MockObjectMap *object_map;
@@ -154,6 +178,13 @@ struct MockImageCtx {
   int concurrent_management_ops;
   bool blacklist_on_break_lock;
   uint32_t blacklist_expire_seconds;
+  uint8_t journal_order;
+  uint8_t journal_splay_width;
+  double journal_commit_age;
+  int journal_object_flush_interval;
+  uint64_t journal_object_flush_bytes;
+  double journal_object_flush_age;
+  std::string journal_pool;
 };
 
 } // namespace librbd
diff --git a/src/test/librbd/mock/MockJournal.h b/src/test/librbd/mock/MockJournal.h
index e0c8d1f..b71505e 100644
--- a/src/test/librbd/mock/MockJournal.h
+++ b/src/test/librbd/mock/MockJournal.h
@@ -5,8 +5,8 @@
 #define CEPH_TEST_LIBRBD_MOCK_JOURNAL_H
 
 #include "gmock/gmock.h"
-#include "librbd/JournalTypes.h"
 #include "librbd/Journal.h"
+#include "librbd/journal/Entries.h"
 
 namespace librbd {
 
@@ -19,8 +19,18 @@ struct MockJournal {
   MOCK_METHOD1(open, void(Context *));
   MOCK_METHOD1(close, void(Context *));
 
-  MOCK_METHOD1(append_op_event, uint64_t(journal::EventEntry&));
+  MOCK_METHOD0(allocate_op_tid, uint64_t());
+
+  MOCK_METHOD3(append_op_event_mock, void(uint64_t, const journal::EventEntry&,
+                                          Context *));
+  void append_op_event(uint64_t op_tid, journal::EventEntry &&event_entry,
+                       Context *on_safe) {
+    // googlemock doesn't support move semantics
+    append_op_event_mock(op_tid, event_entry, on_safe);
+  }
+
   MOCK_METHOD2(commit_op_event, void(uint64_t, int));
+  MOCK_METHOD2(replay_op_ready, void(uint64_t, Context *));
 };
 
 } // namespace librbd
diff --git a/src/test/librbd/mock/MockObjectMap.h b/src/test/librbd/mock/MockObjectMap.h
index 78c036c..5a0aeec 100644
--- a/src/test/librbd/mock/MockObjectMap.h
+++ b/src/test/librbd/mock/MockObjectMap.h
@@ -16,8 +16,12 @@ struct MockObjectMap {
   MOCK_METHOD1(lock, void(Context *on_finish));
   MOCK_METHOD1(unlock, void(Context *on_finish));
 
+  MOCK_METHOD3(aio_resize, void(uint64_t new_size, uint8_t default_object_state,
+                                Context *on_finish));
+
   MOCK_METHOD2(snapshot_add, void(uint64_t snap_id, Context *on_finish));
   MOCK_METHOD2(snapshot_remove, void(uint64_t snap_id, Context *on_finish));
+  MOCK_METHOD2(rollback, void(uint64_t snap_id, Context *on_finish));
 };
 
 } // namespace librbd
diff --git a/src/test/librbd/mock/MockOperations.h b/src/test/librbd/mock/MockOperations.h
new file mode 100644
index 0000000..c3bf9d9
--- /dev/null
+++ b/src/test/librbd/mock/MockOperations.h
@@ -0,0 +1,35 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_TEST_LIBRBD_MOCK_OPERATIONS_H
+#define CEPH_TEST_LIBRBD_MOCK_OPERATIONS_H
+
+#include "include/int_types.h"
+#include "gmock/gmock.h"
+
+class Context;
+
+namespace librbd {
+
+struct MockOperations {
+  MOCK_METHOD2(flatten, void(ProgressContext &prog_ctx, Context *on_finish));
+  MOCK_METHOD2(rebuild_object_map, void(ProgressContext &prog_ctx,
+                                        Context *on_finish));
+  MOCK_METHOD2(rename, void(const char *dstname, Context *on_finish));
+  MOCK_METHOD4(resize, void(uint64_t size, ProgressContext &prog_ctx,
+                            Context *on_finish, uint64_t journal_op_tid));
+  MOCK_METHOD3(snap_create, void(const char *snap_name, Context *on_finish,
+                                 uint64_t journal_op_tid));
+  MOCK_METHOD2(snap_remove, void(const char *snap_name, Context *on_finish));
+  MOCK_METHOD3(snap_rename, void(uint64_t src_snap_id, const char *snap_name,
+                                 Context *on_finish));
+  MOCK_METHOD3(snap_rollback, void(const char *snap_name,
+                                   ProgressContext &prog_ctx,
+                                   Context *on_finish));
+  MOCK_METHOD2(snap_protect, void(const char *snap_name, Context *on_finish));
+  MOCK_METHOD2(snap_unprotect, void(const char *snap_name, Context *on_finish));
+};
+
+} // namespace librbd
+
+#endif // CEPH_TEST_LIBRBD_MOCK_OPERATIONS_H
diff --git a/src/test/librbd/object_map/test_mock_InvalidateRequest.cc b/src/test/librbd/object_map/test_mock_InvalidateRequest.cc
index 9c0f4ea..9f20a47 100644
--- a/src/test/librbd/object_map/test_mock_InvalidateRequest.cc
+++ b/src/test/librbd/object_map/test_mock_InvalidateRequest.cc
@@ -77,7 +77,7 @@ TEST_F(TestMockObjectMapInvalidateRequest, UpdatesSnapOnDiskFlag) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, librbd::snap_set(ictx, "snap1"));
 
   C_SaferCond cond_ctx;
diff --git a/src/test/librbd/object_map/test_mock_ResizeRequest.cc b/src/test/librbd/object_map/test_mock_ResizeRequest.cc
index 197fabe..f21d645 100644
--- a/src/test/librbd/object_map/test_mock_ResizeRequest.cc
+++ b/src/test/librbd/object_map/test_mock_ResizeRequest.cc
@@ -98,7 +98,7 @@ TEST_F(TestMockObjectMapResizeRequest, UpdateSnapOnDisk) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, librbd::snap_set(ictx, "snap1"));
 
   uint64_t snap_id = ictx->snap_id;
diff --git a/src/test/librbd/object_map/test_mock_SnapshotRemoveRequest.cc b/src/test/librbd/object_map/test_mock_SnapshotRemoveRequest.cc
index 224a43d..a29699e 100644
--- a/src/test/librbd/object_map/test_mock_SnapshotRemoveRequest.cc
+++ b/src/test/librbd/object_map/test_mock_SnapshotRemoveRequest.cc
@@ -76,7 +76,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, Success) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -105,7 +105,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, LoadMapError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -132,7 +132,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, RemoveSnapshotMissing) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -159,7 +159,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, RemoveSnapshotError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -187,7 +187,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, RemoveMapMissing) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -216,7 +216,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, RemoveMapError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -245,7 +245,7 @@ TEST_F(TestMockObjectMapSnapshotRemoveRequest, ScrubCleanObjects) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
diff --git a/src/test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc b/src/test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc
index 25c615b..2465ffd 100644
--- a/src/test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc
+++ b/src/test/librbd/object_map/test_mock_SnapshotRollbackRequest.cc
@@ -66,7 +66,7 @@ TEST_F(TestMockObjectMapSnapshotRollbackRequest, Success) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -87,7 +87,7 @@ TEST_F(TestMockObjectMapSnapshotRollbackRequest, ReadMapError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
@@ -115,7 +115,7 @@ TEST_F(TestMockObjectMapSnapshotRollbackRequest, WriteMapError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   uint64_t snap_id = ictx->snap_info.rbegin()->first;
diff --git a/src/test/librbd/object_map/test_mock_UpdateRequest.cc b/src/test/librbd/object_map/test_mock_UpdateRequest.cc
index bc5cafa..0d7dffa 100644
--- a/src/test/librbd/object_map/test_mock_UpdateRequest.cc
+++ b/src/test/librbd/object_map/test_mock_UpdateRequest.cc
@@ -114,7 +114,7 @@ TEST_F(TestMockObjectMapUpdateRequest, UpdateSnapOnDisk) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, librbd::snap_set(ictx, "snap1"));
 
   uint64_t snap_id = ictx->snap_id;
@@ -169,7 +169,7 @@ TEST_F(TestMockObjectMapUpdateRequest, RebuildSnapOnDisk) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
   ASSERT_EQ(CEPH_NOSNAP, ictx->snap_id);
 
diff --git a/src/test/librbd/operation/test_mock_ResizeRequest.cc b/src/test/librbd/operation/test_mock_ResizeRequest.cc
new file mode 100644
index 0000000..dfe07bf
--- /dev/null
+++ b/src/test/librbd/operation/test_mock_ResizeRequest.cc
@@ -0,0 +1,359 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "test/librbd/test_mock_fixture.h"
+#include "test/librbd/test_support.h"
+#include "test/librbd/mock/MockImageCtx.h"
+#include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
+#include "common/bit_vector.hpp"
+#include "librbd/internal.h"
+#include "librbd/ObjectMap.h"
+#include "librbd/operation/ResizeRequest.h"
+#include "librbd/operation/TrimRequest.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace librbd {
+namespace operation {
+
+template <>
+class TrimRequest<MockImageCtx> {
+public:
+  static TrimRequest *s_instance;
+  static TrimRequest *create(MockImageCtx &image_ctx, Context *on_finish,
+                             uint64_t original_size, uint64_t new_size,
+                             ProgressContext &prog_ctx) {
+    assert(s_instance != nullptr);
+    s_instance->on_finish = on_finish;
+    return s_instance;
+  }
+
+  Context *on_finish = nullptr;
+
+  TrimRequest() {
+    s_instance = this;
+  }
+
+  MOCK_METHOD0(send, void());
+};
+
+TrimRequest<MockImageCtx> *TrimRequest<MockImageCtx>::s_instance = nullptr;
+
+} // namespace operation
+} // namespace librbd
+
+// template definitions
+#include "librbd/operation/ResizeRequest.cc"
+#include "librbd/operation/TrimRequest.cc"
+
+namespace librbd {
+namespace operation {
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::InSequence;
+using ::testing::Return;
+using ::testing::WithArg;
+
+class TestMockOperationResizeRequest : public TestMockFixture {
+public:
+  typedef ResizeRequest<MockImageCtx> MockResizeRequest;
+  typedef TrimRequest<MockImageCtx> MockTrimRequest;
+
+  void expect_block_writes(MockImageCtx &mock_image_ctx, int r) {
+    EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_))
+                  .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
+  }
+
+  void expect_unblock_writes(MockImageCtx &mock_image_ctx) {
+    EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes())
+                  .Times(1);
+  }
+
+  void expect_is_lock_owner(MockImageCtx &mock_image_ctx) {
+    if (mock_image_ctx.exclusive_lock != nullptr) {
+      EXPECT_CALL(*mock_image_ctx.exclusive_lock, is_lock_owner())
+                    .WillOnce(Return(true));
+    }
+  }
+
+  void expect_grow_object_map(MockImageCtx &mock_image_ctx) {
+    if (mock_image_ctx.object_map != nullptr) {
+      expect_is_lock_owner(mock_image_ctx);
+      EXPECT_CALL(*mock_image_ctx.object_map, aio_resize(_, _, _))
+                    .WillOnce(WithArg<2>(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)));
+    }
+  }
+
+  void expect_shrink_object_map(MockImageCtx &mock_image_ctx) {
+    if (mock_image_ctx.object_map != nullptr) {
+      expect_is_lock_owner(mock_image_ctx);
+      EXPECT_CALL(*mock_image_ctx.object_map, aio_resize(_, _, _))
+                    .WillOnce(WithArg<2>(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)));
+    }
+  }
+
+  void expect_update_header(MockImageCtx &mock_image_ctx, int r) {
+    if (mock_image_ctx.old_format) {
+      EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
+                  write(mock_image_ctx.header_oid, _, _, _, _))
+                    .WillOnce(Return(r));
+    } else {
+      expect_is_lock_owner(mock_image_ctx);
+      if (mock_image_ctx.exclusive_lock != nullptr) {
+        EXPECT_CALL(*mock_image_ctx.exclusive_lock, assert_header_locked(_));
+      }
+      EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
+                  exec(mock_image_ctx.header_oid, _, "rbd", "set_size", _, _, _))
+                    .WillOnce(Return(r));
+    }
+  }
+
+  void expect_trim(MockImageCtx &mock_image_ctx,
+                   MockTrimRequest &mock_trim_request, int r) {
+    EXPECT_CALL(mock_trim_request, send())
+                  .WillOnce(FinishRequest(&mock_trim_request, r, &mock_image_ctx));
+  }
+
+  void expect_invalidate_cache(MockImageCtx &mock_image_ctx, int r) {
+    EXPECT_CALL(mock_image_ctx, invalidate_cache(_))
+                  .WillOnce(CompleteContext(r, NULL));
+    expect_op_work_queue(mock_image_ctx);
+  }
+
+  void expect_resize_object_map(MockImageCtx &mock_image_ctx,
+                                uint64_t new_size) {
+    EXPECT_CALL(*mock_image_ctx.object_map, aio_resize(new_size, _, _))
+                  .WillOnce(WithArg<2>(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)));
+  }
+
+  int when_resize(MockImageCtx &mock_image_ctx, uint64_t new_size,
+                  uint64_t journal_op_tid, bool disable_journal) {
+    C_SaferCond cond_ctx;
+    librbd::NoOpProgressContext prog_ctx;
+    MockResizeRequest *req = new MockResizeRequest(
+      mock_image_ctx, &cond_ctx, new_size, prog_ctx, journal_op_tid,
+      disable_journal);
+    {
+      RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
+      req->send();
+    }
+    return cond_ctx.wait();
+  }
+};
+
+TEST_F(TestMockOperationResizeRequest, NoOpSuccess) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  expect_commit_op_event(mock_image_ctx, 0);
+  ASSERT_EQ(0, when_resize(mock_image_ctx, ictx->size, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, GrowSuccess) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  expect_grow_object_map(mock_image_ctx);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_update_header(mock_image_ctx, 0);
+  expect_commit_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(0, when_resize(mock_image_ctx, ictx->size * 2, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, ShrinkSuccess) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+
+  MockTrimRequest mock_trim_request;
+  expect_trim(mock_image_ctx, mock_trim_request, 0);
+  expect_invalidate_cache(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_update_header(mock_image_ctx, 0);
+  expect_commit_op_event(mock_image_ctx, 0);
+  expect_shrink_object_map(mock_image_ctx);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(0, when_resize(mock_image_ctx, ictx->size / 2, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, PreBlockWritesError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, TrimError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+
+  MockTrimRequest mock_trim_request;
+  expect_trim(mock_image_ctx, mock_trim_request, -EINVAL);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size / 2, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, InvalidateCacheError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+
+  MockTrimRequest mock_trim_request;
+  expect_trim(mock_image_ctx, mock_trim_request, 0);
+  expect_invalidate_cache(mock_image_ctx, -EINVAL);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size / 2, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, PostBlockWritesError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  expect_grow_object_map(mock_image_ctx);
+  expect_block_writes(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size * 2, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, UpdateHeaderError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  expect_grow_object_map(mock_image_ctx);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_update_header(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size * 2, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, JournalAppendError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_append_op_event(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size, 0, false));
+}
+
+TEST_F(TestMockOperationResizeRequest, JournalDisabled) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+
+  InSequence seq;
+  expect_block_writes(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(0, when_resize(mock_image_ctx, ictx->size, 0, true));
+}
+
+} // namespace operation
+} // namespace librbd
diff --git a/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc b/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc
index d9c8cce..d401943 100644
--- a/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc
+++ b/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc
@@ -31,7 +31,7 @@ public:
 
   void expect_block_writes(MockImageCtx &mock_image_ctx) {
     EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_))
-                  .WillRepeatedly(CompleteContext(0, NULL));
+                  .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
   }
 
   void expect_verify_lock_ownership(MockImageCtx &mock_image_ctx) {
@@ -133,7 +133,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, Success) {
 
   C_SaferCond cond_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
-    mock_image_ctx, &cond_ctx, "snap1");
+    mock_image_ctx, &cond_ctx, "snap1", 0);
   {
     RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
     req->send();
@@ -162,7 +162,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, AllocateSnapIdError) {
 
   C_SaferCond cond_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
-    mock_image_ctx, &cond_ctx, "snap1");
+    mock_image_ctx, &cond_ctx, "snap1", 0);
   {
     RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
     req->send();
@@ -198,7 +198,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, CreateSnapStale) {
 
   C_SaferCond cond_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
-    mock_image_ctx, &cond_ctx, "snap1");
+    mock_image_ctx, &cond_ctx, "snap1", 0);
   {
     RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
     req->send();
@@ -228,7 +228,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, CreateSnapError) {
 
   C_SaferCond cond_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
-    mock_image_ctx, &cond_ctx, "snap1");
+    mock_image_ctx, &cond_ctx, "snap1", 0);
   {
     RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
     req->send();
@@ -258,7 +258,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, ReleaseSnapIdError) {
 
   C_SaferCond cond_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
-    mock_image_ctx, &cond_ctx, "snap1");
+    mock_image_ctx, &cond_ctx, "snap1", 0);
   {
     RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
     req->send();
diff --git a/src/test/librbd/operation/test_mock_SnapshotProtectRequest.cc b/src/test/librbd/operation/test_mock_SnapshotProtectRequest.cc
index 3c64d27..ab7a8e4 100644
--- a/src/test/librbd/operation/test_mock_SnapshotProtectRequest.cc
+++ b/src/test/librbd/operation/test_mock_SnapshotProtectRequest.cc
@@ -61,7 +61,7 @@ TEST_F(TestMockOperationSnapshotProtectRequest, Success) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -88,7 +88,7 @@ TEST_F(TestMockOperationSnapshotProtectRequest, GetSnapIdMissing) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -113,7 +113,7 @@ TEST_F(TestMockOperationSnapshotProtectRequest, IsSnapProtectedError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -139,7 +139,7 @@ TEST_F(TestMockOperationSnapshotProtectRequest, SnapAlreadyProtected) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -165,7 +165,7 @@ TEST_F(TestMockOperationSnapshotProtectRequest, SetProtectionStateError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
diff --git a/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc b/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc
index 122f4bf..fc1fe2a 100644
--- a/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc
+++ b/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc
@@ -36,13 +36,13 @@ public:
       return r;
     }
 
-    r = librbd::snap_create(ictx, snap_name);
+    r = snap_create(*ictx, snap_name);
     if (r < 0) {
       return r;
     }
 
-    r = librbd::snap_protect(ictx, snap_name);
-     if (r < 0) {
+    r = snap_protect(*ictx, snap_name);
+    if (r < 0) {
       return r;
     }
     close_image(ictx);
@@ -119,7 +119,7 @@ public:
 TEST_F(TestMockOperationSnapshotRemoveRequest, Success) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -169,10 +169,10 @@ TEST_F(TestMockOperationSnapshotRemoveRequest, FlattenedCloneRemovesChild) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(clone_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
 
   librbd::NoOpProgressContext prog_ctx;
-  ASSERT_EQ(0, librbd::flatten(ictx, prog_ctx));
+  ASSERT_EQ(0, flatten(*ictx, prog_ctx));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -213,7 +213,7 @@ TEST_F(TestMockOperationSnapshotRemoveRequest, ObjectMapSnapRemoveError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -242,7 +242,7 @@ TEST_F(TestMockOperationSnapshotRemoveRequest, ObjectMapSnapRemoveError) {
 TEST_F(TestMockOperationSnapshotRemoveRequest, RemoveChildParentError) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -288,10 +288,10 @@ TEST_F(TestMockOperationSnapshotRemoveRequest, RemoveChildError) {
     return SUCCEED();
   }
 
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
 
   librbd::NoOpProgressContext prog_ctx;
-  ASSERT_EQ(0, librbd::flatten(ictx, prog_ctx));
+  ASSERT_EQ(0, flatten(*ictx, prog_ctx));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -321,7 +321,7 @@ TEST_F(TestMockOperationSnapshotRemoveRequest, RemoveChildError) {
 TEST_F(TestMockOperationSnapshotRemoveRequest, RemoveSnapError) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
diff --git a/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc b/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc
new file mode 100644
index 0000000..365d086
--- /dev/null
+++ b/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc
@@ -0,0 +1,310 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "test/librbd/test_mock_fixture.h"
+#include "test/librbd/test_support.h"
+#include "test/librbd/mock/MockImageCtx.h"
+#include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
+#include "include/stringify.h"
+#include "common/bit_vector.hpp"
+#include "librbd/ImageState.h"
+#include "librbd/internal.h"
+#include "librbd/operation/SnapshotRollbackRequest.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace librbd {
+namespace operation {
+
+template <>
+struct ResizeRequest<MockImageCtx> {
+  static ResizeRequest *s_instance;
+  Context *on_finish = nullptr;
+
+  static ResizeRequest* create(MockImageCtx &image_ctx, Context *on_finish,
+                               uint64_t new_size, ProgressContext &prog_ctx,
+                               uint64_t journal_op_tid, bool disable_journal) {
+    assert(s_instance != nullptr);
+    assert(journal_op_tid == 0);
+    assert(disable_journal);
+    s_instance->on_finish = on_finish;
+    return s_instance;
+  }
+
+  ResizeRequest() {
+    s_instance = this;
+  }
+
+  MOCK_METHOD0(send, void());
+};
+
+ResizeRequest<MockImageCtx> *ResizeRequest<MockImageCtx>::s_instance = nullptr;
+
+} // namespace operation
+} // namespace librbd
+
+// template definitions
+#include "librbd/operation/SnapshotRollbackRequest.cc"
+
+namespace librbd {
+namespace operation {
+
+using ::testing::_;
+using ::testing::InSequence;
+using ::testing::Return;
+using ::testing::WithArg;
+
+class TestMockOperationSnapshotRollbackRequest : public TestMockFixture {
+public:
+  typedef SnapshotRollbackRequest<MockImageCtx> MockSnapshotRollbackRequest;
+  typedef ResizeRequest<MockImageCtx> MockResizeRequest;
+
+  void expect_block_writes(MockImageCtx &mock_image_ctx, int r) {
+    EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_))
+                  .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
+  }
+
+  void expect_unblock_writes(MockImageCtx &mock_image_ctx) {
+    EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes())
+                  .Times(1);
+  }
+
+  void expect_get_image_size(MockImageCtx &mock_image_ctx,
+                             uint64_t size) {
+    EXPECT_CALL(mock_image_ctx, get_image_size(CEPH_NOSNAP))
+                  .WillOnce(Return(size));
+  }
+
+  void expect_resize(MockImageCtx &mock_image_ctx,
+                     MockResizeRequest &mock_resize_request, int r) {
+    expect_get_image_size(mock_image_ctx, 123);
+    EXPECT_CALL(mock_resize_request, send())
+                  .WillOnce(FinishRequest(&mock_resize_request, r,
+                                          &mock_image_ctx));
+  }
+
+  void expect_rollback_object_map(MockImageCtx &mock_image_ctx,
+                                  MockObjectMap &mock_object_map) {
+    if (mock_image_ctx.object_map != nullptr) {
+      EXPECT_CALL(mock_object_map, rollback(_, _))
+                    .WillOnce(WithArg<1>(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)));
+    }
+  }
+
+  void expect_get_object_name(MockImageCtx &mock_image_ctx,
+                              uint64_t object_num) {
+    EXPECT_CALL(mock_image_ctx, get_object_name(object_num))
+                  .WillOnce(Return("object-name-" + stringify(object_num)));
+  }
+
+  void expect_get_current_size(MockImageCtx &mock_image_ctx, uint64_t size) {
+    EXPECT_CALL(mock_image_ctx, get_current_size())
+                  .WillOnce(Return(size));
+  }
+
+  void expect_rollback_snap_id(MockImageCtx &mock_image_ctx,
+                               const std::string &oid, int r) {
+    EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx),
+                selfmanaged_snap_rollback(oid, _))
+                  .WillOnce(Return(r));
+  }
+
+  void expect_rollback(MockImageCtx &mock_image_ctx, int r) {
+    expect_get_current_size(mock_image_ctx, 1);
+    expect_get_object_name(mock_image_ctx, 0);
+    expect_rollback_snap_id(mock_image_ctx, "object-name-0", r);
+  }
+
+  void expect_create_object_map(MockImageCtx &mock_image_ctx,
+                                MockObjectMap *mock_object_map) {
+    EXPECT_CALL(mock_image_ctx, create_object_map(_))
+                  .WillOnce(Return(mock_object_map));
+  }
+
+  void expect_open_object_map(MockImageCtx &mock_image_ctx,
+                              MockObjectMap &mock_object_map) {
+    EXPECT_CALL(mock_object_map, open(_))
+                  .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
+  }
+
+  void expect_lock_object_map(MockImageCtx &mock_image_ctx,
+                              MockObjectMap &mock_object_map) {
+    EXPECT_CALL(mock_object_map, lock(_))
+                  .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
+  }
+
+  void expect_refresh_object_map(MockImageCtx &mock_image_ctx,
+                                 MockObjectMap &mock_object_map) {
+    if (mock_image_ctx.object_map != nullptr) {
+      expect_create_object_map(mock_image_ctx, &mock_object_map);
+      expect_open_object_map(mock_image_ctx, mock_object_map);
+    }
+  }
+
+  void expect_invalidate_cache(MockImageCtx &mock_image_ctx, int r) {
+    if (mock_image_ctx.object_cacher != nullptr) {
+      EXPECT_CALL(mock_image_ctx, invalidate_cache(_))
+                    .WillOnce(CompleteContext(r, NULL));
+    }
+  }
+
+  int when_snap_rollback(MockImageCtx &mock_image_ctx,
+                         const std::string &snap_name,
+                         uint64_t snap_id, uint64_t snap_size) {
+    C_SaferCond cond_ctx;
+    librbd::NoOpProgressContext prog_ctx;
+    MockSnapshotRollbackRequest *req = new MockSnapshotRollbackRequest(
+      mock_image_ctx, &cond_ctx, snap_name, snap_id, snap_size, prog_ctx);
+    {
+      RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
+      req->send();
+    }
+    return cond_ctx.wait();
+  }
+};
+
+TEST_F(TestMockOperationSnapshotRollbackRequest, Success) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap *mock_object_map = new MockObjectMap();
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      *mock_object_map);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  MockResizeRequest mock_resize_request;
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_resize(mock_image_ctx, mock_resize_request, 0);
+  expect_rollback_object_map(mock_image_ctx, *mock_object_map);
+  expect_rollback(mock_image_ctx, 0);
+  expect_refresh_object_map(mock_image_ctx, *mock_object_map);
+  expect_invalidate_cache(mock_image_ctx, 0);
+  expect_commit_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(0, when_snap_rollback(mock_image_ctx, "snap", 123, 0));
+}
+
+TEST_F(TestMockOperationSnapshotRollbackRequest, BlockWritesError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, -EINVAL);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(-EINVAL, when_snap_rollback(mock_image_ctx, "snap", 123, 0));
+}
+
+TEST_F(TestMockOperationSnapshotRollbackRequest, SkipResize) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap *mock_object_map = new MockObjectMap();
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      *mock_object_map);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_get_image_size(mock_image_ctx, 345);
+  expect_rollback_object_map(mock_image_ctx, *mock_object_map);
+  expect_rollback(mock_image_ctx, 0);
+  expect_refresh_object_map(mock_image_ctx, *mock_object_map);
+  expect_invalidate_cache(mock_image_ctx, 0);
+  expect_commit_op_event(mock_image_ctx, 0);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(0, when_snap_rollback(mock_image_ctx, "snap", 123, 345));
+}
+
+TEST_F(TestMockOperationSnapshotRollbackRequest, ResizeError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  MockResizeRequest mock_resize_request;
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_resize(mock_image_ctx, mock_resize_request, -EINVAL);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(-EINVAL, when_snap_rollback(mock_image_ctx, "snap", 123, 0));
+}
+
+TEST_F(TestMockOperationSnapshotRollbackRequest, RollbackObjectsError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap mock_object_map;
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      mock_object_map);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  MockResizeRequest mock_resize_request;
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_resize(mock_image_ctx, mock_resize_request, 0);
+  expect_rollback_object_map(mock_image_ctx, mock_object_map);
+  expect_rollback(mock_image_ctx, -EINVAL);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(-EINVAL, when_snap_rollback(mock_image_ctx, "snap", 123, 0));
+}
+
+TEST_F(TestMockOperationSnapshotRollbackRequest, InvalidateCacheError) {
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockExclusiveLock mock_exclusive_lock;
+  MockJournal mock_journal;
+  MockObjectMap *mock_object_map = new MockObjectMap();
+  initialize_features(ictx, mock_image_ctx, mock_exclusive_lock, mock_journal,
+                      *mock_object_map);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  MockResizeRequest mock_resize_request;
+  expect_append_op_event(mock_image_ctx, 0);
+  expect_block_writes(mock_image_ctx, 0);
+  expect_resize(mock_image_ctx, mock_resize_request, 0);
+  expect_rollback_object_map(mock_image_ctx, *mock_object_map);
+  expect_rollback(mock_image_ctx, 0);
+  expect_refresh_object_map(mock_image_ctx, *mock_object_map);
+  expect_invalidate_cache(mock_image_ctx, -EINVAL);
+  expect_commit_op_event(mock_image_ctx, -EINVAL);
+  expect_unblock_writes(mock_image_ctx);
+  ASSERT_EQ(-EINVAL, when_snap_rollback(mock_image_ctx, "snap", 123, 0));
+}
+
+} // namespace operation
+} // namespace librbd
diff --git a/src/test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc b/src/test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
index 07cb296..4d437d0 100644
--- a/src/test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
+++ b/src/test/librbd/operation/test_mock_SnapshotUnprotectRequest.cc
@@ -105,7 +105,7 @@ TEST_F(TestMockOperationSnapshotUnprotectRequest, Success) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -138,7 +138,7 @@ TEST_F(TestMockOperationSnapshotUnprotectRequest, GetSnapIdMissing) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -163,7 +163,7 @@ TEST_F(TestMockOperationSnapshotUnprotectRequest, IsSnapUnprotectedError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -189,7 +189,7 @@ TEST_F(TestMockOperationSnapshotUnprotectRequest, SnapAlreadyUnprotected) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -215,7 +215,7 @@ TEST_F(TestMockOperationSnapshotUnprotectRequest, SetProtectionStatusError) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
@@ -244,7 +244,7 @@ TEST_F(TestMockOperationSnapshotUnprotectRequest, ChildrenExist) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
diff --git a/src/test/librbd/test_fixture.cc b/src/test/librbd/test_fixture.cc
index 8c6a4b9..8ed4299 100644
--- a/src/test/librbd/test_fixture.cc
+++ b/src/test/librbd/test_fixture.cc
@@ -7,6 +7,7 @@
 #include "librbd/ExclusiveLock.h"
 #include "librbd/ImageState.h"
 #include "librbd/ImageWatcher.h"
+#include "librbd/Operations.h"
 #include "cls/lock/cls_lock_client.h"
 #include "cls/lock/cls_lock_types.h"
 #include "librbd/internal.h"
@@ -62,6 +63,21 @@ int TestFixture::open_image(const std::string &image_name,
   return (*ictx)->state->open();
 }
 
+int TestFixture::snap_create(librbd::ImageCtx &ictx,
+                             const std::string &snap_name) {
+  return ictx.operations->snap_create(snap_name.c_str());
+}
+
+int TestFixture::snap_protect(librbd::ImageCtx &ictx,
+                              const std::string &snap_name) {
+  return ictx.operations->snap_protect(snap_name.c_str());
+}
+
+int TestFixture::flatten(librbd::ImageCtx &ictx,
+                         librbd::ProgressContext &prog_ctx) {
+  return ictx.operations->flatten(prog_ctx);
+}
+
 void TestFixture::close_image(librbd::ImageCtx *ictx) {
   m_ictxs.erase(ictx);
 
diff --git a/src/test/librbd/test_fixture.h b/src/test/librbd/test_fixture.h
index 5d6b86e..a6fa6af 100644
--- a/src/test/librbd/test_fixture.h
+++ b/src/test/librbd/test_fixture.h
@@ -26,6 +26,11 @@ public:
   int open_image(const std::string &image_name, librbd::ImageCtx **ictx);
   void close_image(librbd::ImageCtx *ictx);
 
+  int snap_create(librbd::ImageCtx &ictx, const std::string &snap_name);
+  int snap_protect(librbd::ImageCtx &ictx, const std::string &snap_name);
+
+  int flatten(librbd::ImageCtx &ictx, librbd::ProgressContext &prog_ctx);
+
   int lock_image(librbd::ImageCtx &ictx, ClsLockType lock_type,
                  const std::string &cookie);
   int unlock_image();
diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc
index 61d58be..7c2f759 100644
--- a/src/test/librbd/test_internal.cc
+++ b/src/test/librbd/test_internal.cc
@@ -9,6 +9,7 @@
 #include "librbd/ImageWatcher.h"
 #include "librbd/internal.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/Operations.h"
 #include <boost/scope_exit.hpp>
 #include <boost/assign/list_of.hpp>
 #include <utility>
@@ -30,9 +31,9 @@ public:
       librbd::ImageCtx *ictx;
       EXPECT_EQ(0, open_image(m_image_name, &ictx));
       if (iter->second) {
-	EXPECT_EQ(0, librbd::snap_unprotect(ictx, iter->first.c_str()));
+	EXPECT_EQ(0, ictx->operations->snap_unprotect(iter->first.c_str()));
       }
-      EXPECT_EQ(0, librbd::snap_remove(ictx, iter->first.c_str()));
+      EXPECT_EQ(0, ictx->operations->snap_remove(iter->first.c_str()));
     }
 
     TestFixture::TearDown();
@@ -45,14 +46,14 @@ public:
       return r;
     }
 
-    r = librbd::snap_create(ictx, snap_name);
+    r = snap_create(*ictx, snap_name);
     if (r < 0) {
       return r;
     }
 
     m_snaps.push_back(std::make_pair(snap_name, snap_protect));
     if (snap_protect) {
-      r = librbd::snap_protect(ictx, snap_name);
+      r = ictx->operations->snap_protect(snap_name);
       if (r < 0) {
 	return r;
       }
@@ -97,7 +98,7 @@ TEST_F(TestInternal, ResizeLocksImage) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(0, librbd::resize(ictx, m_image_size >> 1, no_op));
+  ASSERT_EQ(0, ictx->operations->resize(m_image_size >> 1, no_op));
 
   bool is_owner;
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
@@ -112,7 +113,7 @@ TEST_F(TestInternal, ResizeFailsToLockImage) {
   ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, "manually locked"));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(-EROFS, librbd::resize(ictx, m_image_size >> 1, no_op));
+  ASSERT_EQ(-EROFS, ictx->operations->resize(m_image_size >> 1, no_op));
 }
 
 TEST_F(TestInternal, SnapCreateLocksImage) {
@@ -121,9 +122,9 @@ TEST_F(TestInternal, SnapCreateLocksImage) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
   BOOST_SCOPE_EXIT( (ictx) ) {
-    ASSERT_EQ(0, librbd::snap_remove(ictx, "snap1"));
+    ASSERT_EQ(0, ictx->operations->snap_remove("snap1"));
   } BOOST_SCOPE_EXIT_END;
 
   bool is_owner;
@@ -138,7 +139,7 @@ TEST_F(TestInternal, SnapCreateFailsToLockImage) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, "manually locked"));
 
-  ASSERT_EQ(-EROFS, librbd::snap_create(ictx, "snap1"));
+  ASSERT_EQ(-EROFS, snap_create(*ictx, "snap1"));
 }
 
 TEST_F(TestInternal, SnapRollbackLocksImage) {
@@ -150,7 +151,7 @@ TEST_F(TestInternal, SnapRollbackLocksImage) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(0, librbd::snap_rollback(ictx, "snap1", no_op));
+  ASSERT_EQ(0, ictx->operations->snap_rollback("snap1", no_op));
 
   bool is_owner;
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
@@ -168,7 +169,7 @@ TEST_F(TestInternal, SnapRollbackFailsToLockImage) {
   ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, "manually locked"));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(-EROFS, librbd::snap_rollback(ictx, "snap1", no_op));
+  ASSERT_EQ(-EROFS, ictx->operations->snap_rollback("snap1", no_op));
 }
 
 TEST_F(TestInternal, SnapSetReleasesLock) {
@@ -205,7 +206,7 @@ TEST_F(TestInternal, FlattenLocksImage) {
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(0, librbd::flatten(ictx2, no_op));
+  ASSERT_EQ(0, ictx2->operations->flatten(no_op));
 
   bool is_owner;
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx2, &is_owner));
@@ -243,7 +244,7 @@ TEST_F(TestInternal, FlattenFailsToLockImage) {
   ASSERT_EQ(0, lock_image(*ictx2, LOCK_EXCLUSIVE, "manually locked"));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(-EROFS, librbd::flatten(ictx2, no_op));
+  ASSERT_EQ(-EROFS, ictx2->operations->flatten(no_op));
 }
 
 TEST_F(TestInternal, AioWriteRequestsLock) {
@@ -320,7 +321,7 @@ TEST_F(TestInternal, CancelAsyncResize) {
     size -= MIN(size, 1<<18);
     {
       RWLock::RLocker l(ictx->owner_lock);
-      librbd::async_resize(ictx, &ctx, size, prog_ctx);
+      ictx->operations->resize(size, prog_ctx, &ctx, 0);
     }
 
     // try to interrupt the in-progress resize
@@ -368,7 +369,7 @@ TEST_F(TestInternal, MultipleResize) {
 
     RWLock::RLocker l(ictx->owner_lock);
     contexts.push_back(new C_SaferCond());
-    librbd::async_resize(ictx, contexts.back(), new_size, prog_ctx);
+    ictx->operations->resize(new_size, prog_ctx, contexts.back(), 0);
   }
 
   for (uint32_t i = 0; i < contexts.size(); ++i) {
@@ -478,8 +479,8 @@ TEST_F(TestInternal, SnapshotCopyup)
   bl.append(std::string(256, '1'));
   ASSERT_EQ(256, ictx->aio_work_queue->write(0, bl.length(), bl.c_str(), 0));
 
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
-  ASSERT_EQ(0, librbd::snap_protect(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
+  ASSERT_EQ(0, ictx->operations->snap_protect("snap1"));
 
   uint64_t features;
   ASSERT_EQ(0, librbd::get_features(ictx, &features));
@@ -492,8 +493,8 @@ TEST_F(TestInternal, SnapshotCopyup)
   librbd::ImageCtx *ictx2;
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
 
-  ASSERT_EQ(0, librbd::snap_create(ictx2, "snap1"));
-  ASSERT_EQ(0, librbd::snap_create(ictx2, "snap2"));
+  ASSERT_EQ(0, snap_create(*ictx2, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx2, "snap2"));
 
   ASSERT_EQ(256, ictx2->aio_work_queue->write(256, bl.length(), bl.c_str(), 0));
 
@@ -576,8 +577,8 @@ TEST_F(TestInternal, ResizeCopyup)
                                                        bl.c_str(), 0));
   }
 
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
-  ASSERT_EQ(0, librbd::snap_protect(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
+  ASSERT_EQ(0, ictx->operations->snap_protect("snap1"));
 
   std::string clone_name = get_temp_image_name();
   ASSERT_EQ(0, librbd::clone(m_ioctx, m_image_name.c_str(), "snap1", m_ioctx,
@@ -586,7 +587,7 @@ TEST_F(TestInternal, ResizeCopyup)
   librbd::ImageCtx *ictx2;
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
 
-  ASSERT_EQ(0, librbd::snap_create(ictx2, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx2, "snap1"));
 
   bufferptr read_ptr(bl.length());
   bufferlist read_bl;
@@ -594,7 +595,8 @@ TEST_F(TestInternal, ResizeCopyup)
 
   // verify full / partial object removal properly copyup
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(0, librbd::resize(ictx2, m_image_size - (1 << order) - 32, no_op));
+  ASSERT_EQ(0, ictx2->operations->resize(m_image_size - (1 << order) - 32,
+                                         no_op));
   ASSERT_EQ(0, librbd::snap_set(ictx2, "snap1"));
 
   {
@@ -633,8 +635,8 @@ TEST_F(TestInternal, DiscardCopyup)
                                                        bl.c_str(), 0));
   }
 
-  ASSERT_EQ(0, librbd::snap_create(ictx, "snap1"));
-  ASSERT_EQ(0, librbd::snap_protect(ictx, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx, "snap1"));
+  ASSERT_EQ(0, ictx->operations->snap_protect("snap1"));
 
   std::string clone_name = get_temp_image_name();
   ASSERT_EQ(0, librbd::clone(m_ioctx, m_image_name.c_str(), "snap1", m_ioctx,
@@ -643,7 +645,7 @@ TEST_F(TestInternal, DiscardCopyup)
   librbd::ImageCtx *ictx2;
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
 
-  ASSERT_EQ(0, librbd::snap_create(ictx2, "snap1"));
+  ASSERT_EQ(0, snap_create(*ictx2, "snap1"));
 
   bufferptr read_ptr(bl.length());
   bufferlist read_bl;
@@ -681,7 +683,7 @@ TEST_F(TestInternal, ShrinkFlushesCache) {
   ictx->aio_work_queue->aio_write(c, 0, buffer.size(), buffer.c_str(), 0);
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(0, librbd::resize(ictx, m_image_size >> 1, no_op));
+  ASSERT_EQ(0, ictx->operations->resize(m_image_size >> 1, no_op));
 
   ASSERT_TRUE(c->is_complete());
   ASSERT_EQ(0, c->wait_for_complete());
@@ -763,7 +765,7 @@ TEST_F(TestInternal, WriteFullCopyup) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
   librbd::NoOpProgressContext no_op;
-  ASSERT_EQ(0, librbd::resize(ictx, 1 << ictx->order, no_op));
+  ASSERT_EQ(0, ictx->operations->resize(1 << ictx->order, no_op));
 
   bufferlist bl;
   bl.append(std::string(1 << ictx->order, '1'));
@@ -782,7 +784,7 @@ TEST_F(TestInternal, WriteFullCopyup) {
   librbd::ImageCtx *ictx2 = NULL;
   BOOST_SCOPE_EXIT( (&m_ioctx) (clone_name) (parent) (&ictx2) ) {
     if (ictx2 != NULL) {
-      librbd::snap_remove(ictx2, "snap1");
+      ictx2->operations->snap_remove("snap1");
       parent->close_image(ictx2);
     }
 
@@ -791,7 +793,7 @@ TEST_F(TestInternal, WriteFullCopyup) {
   } BOOST_SCOPE_EXIT_END;
 
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
-  ASSERT_EQ(0, librbd::snap_create(ictx2, "snap1"));
+  ASSERT_EQ(0, ictx2->operations->snap_create("snap1"));
 
   bufferlist write_full_bl;
   write_full_bl.append(std::string(1 << ictx2->order, '2'));
@@ -799,7 +801,7 @@ TEST_F(TestInternal, WriteFullCopyup) {
             ictx2->aio_work_queue->write(0, write_full_bl.length(),
             write_full_bl.c_str(), 0));
 
-  ASSERT_EQ(0, librbd::flatten(ictx2, no_op));
+  ASSERT_EQ(0, ictx2->operations->flatten(no_op));
 
   bufferptr read_ptr(bl.length());
   bufferlist read_bl;
diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc
index 7b84d35..15f5084 100644
--- a/src/test/librbd/test_librbd.cc
+++ b/src/test/librbd/test_librbd.cc
@@ -668,21 +668,28 @@ TEST_F(TestLibRBD, TestCreateLsDeleteSnapPP)
     
     ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
     ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
-
-    ASSERT_FALSE(image.snap_exists("snap1"));
+   
+    bool exists;
+    ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+    ASSERT_FALSE(exists);
     ASSERT_EQ(0, image.snap_create("snap1"));
-    ASSERT_TRUE(image.snap_exists("snap1"));
+    ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+    ASSERT_TRUE(exists);
     ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
     ASSERT_EQ(0, image.resize(size2));
-    ASSERT_FALSE(image.snap_exists("snap2"));
+    ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+    ASSERT_FALSE(exists);
     ASSERT_EQ(0, image.snap_create("snap2"));
-    ASSERT_TRUE(image.snap_exists("snap2"));
+    ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+    ASSERT_TRUE(exists);
     ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
     ASSERT_EQ(0, image.snap_remove("snap1"));
-    ASSERT_FALSE(image.snap_exists("snap1"));
+    ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+    ASSERT_FALSE(exists);
     ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2", size2));
     ASSERT_EQ(0, image.snap_remove("snap2"));
-    ASSERT_FALSE(image.snap_exists("snap2"));
+    ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+    ASSERT_FALSE(exists);
     ASSERT_EQ(0, test_ls_snaps(image, 0));
   }
 
@@ -704,25 +711,34 @@ TEST_F(TestLibRBD, TestCreateLsRenameSnapPP)
     
     ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
     ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
-
-    ASSERT_FALSE(image.snap_exists("snap1"));
+    
+    bool exists;
+    ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+    ASSERT_FALSE(exists);
     ASSERT_EQ(0, image.snap_create("snap1"));
-    ASSERT_TRUE(image.snap_exists("snap1"));
+    ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+    ASSERT_TRUE(exists);
     ASSERT_EQ(1, test_ls_snaps(image, 1, "snap1", size));
     ASSERT_EQ(0, image.resize(size2));
-    ASSERT_FALSE(image.snap_exists("snap2"));
+    ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+    ASSERT_FALSE(exists);
     ASSERT_EQ(0, image.snap_create("snap2"));
-    ASSERT_TRUE(image.snap_exists("snap2"));
+    ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+    ASSERT_TRUE(exists);
     ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1", size, "snap2", size2));
     ASSERT_EQ(0, image.snap_rename("snap1","snap1-rename"));
     ASSERT_EQ(2, test_ls_snaps(image, 2, "snap1-rename", size, "snap2", size2));
-    ASSERT_FALSE(image.snap_exists("snap1"));
-    ASSERT_TRUE(image.snap_exists("snap1-rename"));
+    ASSERT_EQ(0, image.snap_exists2("snap1", &exists));
+    ASSERT_FALSE(exists);
+    ASSERT_EQ(0, image.snap_exists2("snap1-rename", &exists));
+    ASSERT_TRUE(exists);
     ASSERT_EQ(0, image.snap_remove("snap1-rename"));
     ASSERT_EQ(0, image.snap_rename("snap2","snap2-rename"));
     ASSERT_EQ(1, test_ls_snaps(image, 1, "snap2-rename", size2));
-    ASSERT_FALSE(image.snap_exists("snap2"));
-    ASSERT_TRUE(image.snap_exists("snap2-rename"));
+    ASSERT_EQ(0, image.snap_exists2("snap2", &exists));
+    ASSERT_FALSE(exists);
+    ASSERT_EQ(0, image.snap_exists2("snap2-rename", &exists));
+    ASSERT_TRUE(exists);
     ASSERT_EQ(0, image.snap_remove("snap2-rename"));
     ASSERT_EQ(0, test_ls_snaps(image, 0));
   }
@@ -2909,8 +2925,11 @@ TEST_F(TestLibRBD, SnapCreateViaLockOwner)
   ASSERT_FALSE(lock_owner);
 
   ASSERT_EQ(0, image2.snap_create("snap1"));
-  ASSERT_TRUE(image1.snap_exists("snap1"));
-  ASSERT_TRUE(image2.snap_exists("snap1"));
+  bool exists;
+  ASSERT_EQ(0, image1.snap_exists2("snap1", &exists));
+  ASSERT_TRUE(exists);
+  ASSERT_EQ(0, image2.snap_exists2("snap1", &exists));
+  ASSERT_TRUE(exists);
 
   ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner));
   ASSERT_TRUE(lock_owner);
@@ -2947,8 +2966,11 @@ TEST_F(TestLibRBD, SnapRemoveViaLockOwner)
   ASSERT_FALSE(lock_owner);
 
   ASSERT_EQ(0, image2.snap_remove("snap1"));
-  ASSERT_FALSE(image1.snap_exists("snap1"));
-  ASSERT_FALSE(image2.snap_exists("snap1"));
+  bool exists;
+  ASSERT_EQ(0, image1.snap_exists2("snap1", &exists));
+  ASSERT_FALSE(exists);
+  ASSERT_EQ(0, image2.snap_exists2("snap1", &exists));
+  ASSERT_FALSE(exists);
 
   ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner));
   ASSERT_TRUE(lock_owner);
@@ -2985,8 +3007,11 @@ TEST_F(TestLibRBD, SnapRenameViaLockOwner)
   ASSERT_FALSE(lock_owner);
 
   ASSERT_EQ(0, image2.snap_rename("snap1", "snap1-rename"));
-  ASSERT_TRUE(image1.snap_exists("snap1-rename"));
-  ASSERT_TRUE(image2.snap_exists("snap1-rename"));
+  bool exists;
+  ASSERT_EQ(0, image1.snap_exists2("snap1-rename", &exists));
+  ASSERT_TRUE(exists);
+  ASSERT_EQ(0, image2.snap_exists2("snap1-rename", &exists));
+  ASSERT_TRUE(exists);
 
   ASSERT_EQ(0, image1.is_exclusive_lock_owner(&lock_owner));
   ASSERT_TRUE(lock_owner);
@@ -3198,7 +3223,7 @@ TEST_F(TestLibRBD, ObjectMapConsistentSnap)
   ASSERT_EQ(0, rbd.open(ioctx, image1, name.c_str(), NULL));
 
   RBDWriter writer(image1);
-  writer.create();
+  writer.create("rbd_writer");
 
   int num_snaps = 10;
   for (int i = 0; i < num_snaps; ++i) {
diff --git a/src/test/librbd/test_mock_ExclusiveLock.cc b/src/test/librbd/test_mock_ExclusiveLock.cc
index cac28a6..6913d1d 100644
--- a/src/test/librbd/test_mock_ExclusiveLock.cc
+++ b/src/test/librbd/test_mock_ExclusiveLock.cc
@@ -89,6 +89,7 @@ public:
                   .WillOnce(FinishRequest(&acquire_request, r, &mock_image_ctx));
     if (r == 0) {
       expect_notify_acquired_lock(mock_image_ctx);
+      expect_unblock_writes(mock_image_ctx);
     }
   }
 
@@ -98,6 +99,9 @@ public:
     EXPECT_CALL(release_request, send())
                   .WillOnce(FinishRequest(&release_request, r, &mock_image_ctx));
     if (r == 0) {
+      if (shutting_down) {
+        expect_unblock_writes(mock_image_ctx);
+      }
       expect_notify_released_lock(mock_image_ctx);
       expect_writes_empty(mock_image_ctx);
     }
@@ -209,7 +213,6 @@ TEST_F(TestMockExclusiveLock, StateTransitions) {
   ASSERT_TRUE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   MockReleaseRequest shutdown_release;
-  expect_op_work_queue(mock_image_ctx);
   expect_release_lock(mock_image_ctx, shutdown_release, 0, true);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
   ASSERT_FALSE(is_lock_owner(mock_image_ctx, exclusive_lock));
@@ -235,7 +238,6 @@ TEST_F(TestMockExclusiveLock, TryLockLockedState) {
   ASSERT_EQ(0, when_try_lock(mock_image_ctx, exclusive_lock));
 
   MockReleaseRequest shutdown_release;
-  expect_op_work_queue(mock_image_ctx);
   expect_release_lock(mock_image_ctx, shutdown_release, 0, true);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
@@ -283,7 +285,6 @@ TEST_F(TestMockExclusiveLock, TryLockBusy) {
   ASSERT_FALSE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   expect_unblock_writes(mock_image_ctx);
-  expect_op_work_queue(mock_image_ctx);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
 
@@ -308,7 +309,6 @@ TEST_F(TestMockExclusiveLock, TryLockError) {
   ASSERT_FALSE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   expect_unblock_writes(mock_image_ctx);
-  expect_op_work_queue(mock_image_ctx);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
 
@@ -331,7 +331,6 @@ TEST_F(TestMockExclusiveLock, RequestLockLockedState) {
   ASSERT_EQ(0, when_try_lock(mock_image_ctx, exclusive_lock));
 
   MockReleaseRequest shutdown_release;
-  expect_op_work_queue(mock_image_ctx);
   expect_release_lock(mock_image_ctx, shutdown_release, 0, true);
   ASSERT_EQ(0, when_request_lock(mock_image_ctx, exclusive_lock));
 
@@ -360,7 +359,6 @@ TEST_F(TestMockExclusiveLock, RequestLockBlacklist) {
   ASSERT_FALSE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   expect_unblock_writes(mock_image_ctx);
-  expect_op_work_queue(mock_image_ctx);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
 
@@ -389,7 +387,6 @@ TEST_F(TestMockExclusiveLock, RequestLockBusy) {
   ASSERT_TRUE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   MockReleaseRequest shutdown_release;
-  expect_op_work_queue(mock_image_ctx);
   expect_release_lock(mock_image_ctx, shutdown_release, 0, true);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
@@ -419,7 +416,6 @@ TEST_F(TestMockExclusiveLock, RequestLockError) {
   ASSERT_TRUE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   MockReleaseRequest shutdown_release;
-  expect_op_work_queue(mock_image_ctx);
   expect_release_lock(mock_image_ctx, shutdown_release, 0, true);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
@@ -441,7 +437,6 @@ TEST_F(TestMockExclusiveLock, ReleaseLockUnlockedState) {
   ASSERT_EQ(0, when_release_lock(mock_image_ctx, exclusive_lock));
 
   expect_unblock_writes(mock_image_ctx);
-  expect_op_work_queue(mock_image_ctx);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
 }
 
@@ -470,7 +465,6 @@ TEST_F(TestMockExclusiveLock, ReleaseLockError) {
   ASSERT_TRUE(is_lock_owner(mock_image_ctx, exclusive_lock));
 
   MockReleaseRequest shutdown_release;
-  expect_op_work_queue(mock_image_ctx);
   expect_release_lock(mock_image_ctx, shutdown_release, 0, true);
   ASSERT_EQ(0, when_shut_down(mock_image_ctx, exclusive_lock));
   ASSERT_FALSE(is_lock_owner(mock_image_ctx, exclusive_lock));
diff --git a/src/test/librbd/test_mock_Journal.cc b/src/test/librbd/test_mock_Journal.cc
new file mode 100644
index 0000000..0de97a3
--- /dev/null
+++ b/src/test/librbd/test_mock_Journal.cc
@@ -0,0 +1,898 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "test/librbd/test_mock_fixture.h"
+#include "test/librbd/test_support.h"
+#include "test/librbd/mock/MockImageCtx.h"
+#include "common/Cond.h"
+#include "common/Mutex.h"
+#include "librbd/Journal.h"
+#include "librbd/Utils.h"
+#include "librbd/journal/Entries.h"
+#include "librbd/journal/Replay.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include <functional>
+#include <list>
+#include <boost/scope_exit.hpp>
+
+namespace journal {
+
+struct MockFuture {
+  static MockFuture *s_instance;
+  static MockFuture &get_instance() {
+    assert(s_instance != nullptr);
+    return *s_instance;
+  }
+
+  MockFuture() {
+    s_instance = this;
+  }
+
+  MOCK_CONST_METHOD0(is_valid, bool());
+  MOCK_METHOD1(flush, void(Context *));
+  MOCK_METHOD1(wait, void(Context *));
+};
+
+struct MockFutureProxy {
+  bool is_valid() const {
+    return MockFuture::get_instance().is_valid();
+  }
+
+  void flush(Context *on_safe) {
+    MockFuture::get_instance().flush(on_safe);
+  }
+
+  void wait(Context *on_safe) {
+    MockFuture::get_instance().wait(on_safe);
+  }
+};
+
+struct MockReplayEntry {
+  static MockReplayEntry *s_instance;
+  static MockReplayEntry &get_instance() {
+    assert(s_instance != nullptr);
+    return *s_instance;
+  }
+
+  MockReplayEntry() {
+    s_instance = this;
+  }
+
+  MOCK_METHOD0(get_data, bufferlist());
+};
+
+struct MockReplayEntryProxy {
+  bufferlist get_data() {
+    return MockReplayEntry::get_instance().get_data();
+  }
+};
+
+struct MockJournaler {
+  static MockJournaler *s_instance;
+  static MockJournaler &get_instance() {
+    assert(s_instance != nullptr);
+    return *s_instance;
+  }
+
+  MockJournaler() {
+    s_instance = this;
+  }
+
+  MOCK_METHOD0(construct, void());
+
+  MOCK_METHOD3(get_metadata, void(uint8_t *order, uint8_t *splay_width,
+                                  int64_t *pool_id));
+  MOCK_METHOD1(init, void(Context*));
+
+  MOCK_METHOD1(start_replay, void(::journal::ReplayHandler *replay_handler));
+  MOCK_METHOD1(try_pop_front, bool(MockReplayEntryProxy *replay_entry));
+  MOCK_METHOD0(stop_replay, void());
+
+  MOCK_METHOD3(start_append, void(int flush_interval, uint64_t flush_bytes,
+                                  double flush_age));
+  MOCK_METHOD2(append, MockFutureProxy(const std::string &tag,
+                                       const bufferlist &bl));
+  MOCK_METHOD1(flush, void(Context *on_safe));
+  MOCK_METHOD1(stop_append, void(Context *on_safe));
+
+  MOCK_METHOD1(committed, void(const MockReplayEntryProxy &replay_entry));
+  MOCK_METHOD1(committed, void(const MockFutureProxy &future));
+};
+
+struct MockJournalerProxy {
+  template <typename IoCtxT>
+  MockJournalerProxy(IoCtxT &header_ioctx, const std::string &,
+                     const std::string &, double) {
+    MockJournaler::get_instance().construct();
+  }
+
+  int exists(bool *header_exists) const {
+    return -EINVAL;
+  }
+  int create(uint8_t order, uint8_t splay_width, int64_t pool_id) {
+    return -EINVAL;
+  }
+  int remove(bool force) {
+    return -EINVAL;
+  }
+  int register_client(const std::string &description) {
+    return -EINVAL;
+  }
+
+  void get_metadata(uint8_t *order, uint8_t *splay_width, int64_t *pool_id) {
+    MockJournaler::get_instance().get_metadata(order, splay_width, pool_id);
+  }
+
+  void init(Context *on_finish) {
+    MockJournaler::get_instance().init(on_finish);
+  }
+
+  void start_replay(::journal::ReplayHandler *replay_handler) {
+    MockJournaler::get_instance().start_replay(replay_handler);
+  }
+
+  bool try_pop_front(MockReplayEntryProxy *replay_entry) {
+    return MockJournaler::get_instance().try_pop_front(replay_entry);
+  }
+
+  void stop_replay() {
+    MockJournaler::get_instance().stop_replay();
+  }
+
+  void start_append(int flush_interval, uint64_t flush_bytes, double flush_age) {
+    MockJournaler::get_instance().start_append(flush_interval, flush_bytes,
+                                               flush_age);
+  }
+
+  MockFutureProxy append(const std::string &tag, const bufferlist &bl) {
+    return MockJournaler::get_instance().append(tag, bl);
+  }
+
+  void flush(Context *on_safe) {
+    MockJournaler::get_instance().flush(on_safe);
+  }
+
+  void stop_append(Context *on_safe) {
+    MockJournaler::get_instance().stop_append(on_safe);
+  }
+
+  void committed(const MockReplayEntryProxy &replay_entry) {
+    MockJournaler::get_instance().committed(replay_entry);
+  }
+
+  void committed(const MockFutureProxy &future) {
+    MockJournaler::get_instance().committed(future);
+  }
+};
+
+MockFuture *MockFuture::s_instance = nullptr;
+MockReplayEntry *MockReplayEntry::s_instance = nullptr;
+MockJournaler *MockJournaler::s_instance = nullptr;
+
+} // namespace journal
+
+namespace librbd {
+namespace journal {
+
+template <>
+struct TypeTraits<MockImageCtx> {
+  typedef ::journal::MockJournalerProxy Journaler;
+  typedef ::journal::MockFutureProxy  Future;
+  typedef ::journal::MockReplayEntryProxy ReplayEntry;
+};
+
+struct MockReplay {
+  static MockReplay *s_instance;
+  static MockReplay &get_instance() {
+    assert(s_instance != nullptr);
+    return *s_instance;
+  }
+
+  MockReplay() {
+    s_instance = this;
+  }
+
+  MOCK_METHOD1(flush, void(Context *));
+  MOCK_METHOD3(process, void(bufferlist::iterator*, Context *, Context *));
+  MOCK_METHOD2(replay_op_ready, void(uint64_t, Context *));
+};
+
+template <>
+class Replay<MockImageCtx> {
+public:
+  static Replay *create(MockImageCtx &image_ctx) {
+    return new Replay();
+  }
+
+  void flush(Context *on_finish) {
+    MockReplay::get_instance().flush(on_finish);
+  }
+
+  void process(bufferlist::iterator *it, Context *on_ready,
+               Context *on_commit) {
+    MockReplay::get_instance().process(it, on_ready, on_commit);
+  }
+
+  void replay_op_ready(uint64_t op_tid, Context *on_resume) {
+    MockReplay::get_instance().replay_op_ready(op_tid, on_resume);
+  }
+};
+
+MockReplay *MockReplay::s_instance = nullptr;
+
+} // namespace journal
+} // namespace librbd
+
+// template definitions
+#include "librbd/Journal.cc"
+template class librbd::Journal<librbd::MockImageCtx>;
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::InSequence;
+using ::testing::Invoke;
+using ::testing::InvokeWithoutArgs;
+using ::testing::MatcherCast;
+using ::testing::Return;
+using ::testing::SaveArg;
+using ::testing::SetArgPointee;
+using ::testing::WithArg;
+using namespace std::placeholders;
+
+ACTION_P2(StartReplay, wq, ctx) {
+  ctx->replay_handler = arg0;
+  wq->queue(ctx, 0);
+}
+
+namespace librbd {
+
+class TestMockJournal : public TestMockFixture {
+public:
+  typedef journal::MockReplay MockJournalReplay;
+  typedef Journal<MockImageCtx> MockJournal;
+
+  typedef std::function<void(::journal::ReplayHandler*)> ReplayAction;
+  typedef std::list<ReplayAction> ReplayActions;
+  typedef std::list<Context *> Contexts;
+
+  TestMockJournal() : m_lock("lock") {
+  }
+
+  ~TestMockJournal() {
+    assert(m_commit_contexts.empty());
+  }
+
+  Mutex m_lock;
+  Cond m_cond;
+  Contexts m_commit_contexts;
+
+  struct C_StartReplay : public Context {
+    ReplayActions replay_actions;
+    ::journal::ReplayHandler *replay_handler;
+
+    C_StartReplay(const ReplayActions &replay_actions)
+      : replay_actions(replay_actions), replay_handler(nullptr) {
+    }
+    virtual void finish(int r) {
+      for (auto &action : replay_actions) {
+        action(replay_handler);
+      }
+    }
+  };
+
+  void expect_construct_journaler(::journal::MockJournaler &mock_journaler) {
+    EXPECT_CALL(mock_journaler, construct());
+  }
+
+  void expect_init_journaler(::journal::MockJournaler &mock_journaler, int r) {
+    EXPECT_CALL(mock_journaler, init(_))
+                  .WillOnce(CompleteContext(r, NULL));
+
+  }
+
+  void expect_start_replay(MockImageCtx &mock_image_ctx,
+                           ::journal::MockJournaler &mock_journaler,
+                           const ReplayActions &actions) {
+    EXPECT_CALL(mock_journaler, start_replay(_))
+                 .WillOnce(StartReplay(mock_image_ctx.image_ctx->op_work_queue,
+                                       new C_StartReplay(actions)));
+  }
+
+  void expect_stop_replay(::journal::MockJournaler &mock_journaler) {
+    EXPECT_CALL(mock_journaler, stop_replay());
+  }
+
+  void expect_flush_replay(MockImageCtx &mock_image_ctx,
+                           MockJournalReplay &mock_journal_replay, int r) {
+    EXPECT_CALL(mock_journal_replay, flush(_))
+                  .WillOnce(Invoke([this, &mock_image_ctx, r](Context *on_flush) {
+                    this->commit_replay(mock_image_ctx, on_flush, r);}));
+  }
+
+  void expect_get_data(::journal::MockReplayEntry &mock_replay_entry) {
+    EXPECT_CALL(mock_replay_entry, get_data())
+                  .WillOnce(Return(bufferlist()));
+  }
+
+  void expect_try_pop_front(::journal::MockJournaler &mock_journaler,
+                            bool entries_available,
+                            ::journal::MockReplayEntry &mock_replay_entry) {
+    EXPECT_CALL(mock_journaler, try_pop_front(_))
+                  .WillOnce(DoAll(SetArgPointee<0>(::journal::MockReplayEntryProxy()),
+                                  Return(entries_available)));
+    if (entries_available) {
+      expect_get_data(mock_replay_entry);
+    }
+  }
+
+  void expect_replay_process(MockJournalReplay &mock_journal_replay) {
+    EXPECT_CALL(mock_journal_replay, process(_, _, _))
+                  .WillOnce(DoAll(WithArg<2>(Invoke(this, &TestMockJournal::save_commit_context)),
+                                  WithArg<1>(CompleteContext(0, NULL))));
+  }
+
+  void expect_start_append(::journal::MockJournaler &mock_journaler) {
+    EXPECT_CALL(mock_journaler, start_append(_, _, _));
+  }
+
+  void expect_stop_append(::journal::MockJournaler &mock_journaler, int r) {
+    EXPECT_CALL(mock_journaler, stop_append(_))
+                  .WillOnce(CompleteContext(r, NULL));
+  }
+
+  void expect_committed(::journal::MockJournaler &mock_journaler,
+                        size_t events) {
+    EXPECT_CALL(mock_journaler, committed(MatcherCast<const ::journal::MockReplayEntryProxy&>(_)))
+                  .Times(events);
+  }
+
+  void expect_append_journaler(::journal::MockJournaler &mock_journaler) {
+    EXPECT_CALL(mock_journaler, append(_, _))
+                  .WillOnce(Return(::journal::MockFutureProxy()));
+  }
+
+  void expect_wait_future(::journal::MockFuture &mock_future,
+                          Context **on_safe) {
+    EXPECT_CALL(mock_future, wait(_))
+                  .WillOnce(SaveArg<0>(on_safe));
+  }
+
+  void expect_future_committed(::journal::MockJournaler &mock_journaler) {
+    EXPECT_CALL(mock_journaler, committed(MatcherCast<const ::journal::MockFutureProxy&>(_)));
+  }
+
+  void expect_future_is_valid(::journal::MockFuture &mock_future) {
+    EXPECT_CALL(mock_future, is_valid()).WillOnce(Return(false));
+  }
+
+  int when_open(MockJournal &mock_journal) {
+    C_SaferCond ctx;
+    mock_journal.open(&ctx);
+    return ctx.wait();
+  }
+
+  int when_close(MockJournal &mock_journal) {
+    C_SaferCond ctx;
+    mock_journal.close(&ctx);
+    return ctx.wait();
+  }
+
+  uint64_t when_append_io_event(MockImageCtx &mock_image_ctx,
+                                MockJournal &mock_journal,
+                                AioCompletion *aio_comp = nullptr) {
+    RWLock::RLocker owner_locker(mock_image_ctx.owner_lock);
+    return mock_journal.append_io_event(
+      aio_comp, journal::EventEntry{journal::AioFlushEvent{}}, {}, 0, 0, false);
+  }
+
+  void save_commit_context(Context *ctx) {
+    Mutex::Locker locker(m_lock);
+    m_commit_contexts.push_back(ctx);
+    m_cond.Signal();
+  }
+
+  void commit_replay(MockImageCtx &mock_image_ctx, Context *on_flush, int r) {
+    Contexts commit_contexts;
+    std::swap(commit_contexts, m_commit_contexts);
+
+    for (auto ctx : commit_contexts) {
+      mock_image_ctx.image_ctx->op_work_queue->queue(ctx, r);
+    }
+    mock_image_ctx.image_ctx->op_work_queue->queue(on_flush, 0);
+  }
+
+  void open_journal(MockImageCtx &mock_image_ctx, MockJournal &mock_journal,
+                    ::journal::MockJournaler &mock_journaler) {
+    expect_op_work_queue(mock_image_ctx);
+
+    InSequence seq;
+    expect_construct_journaler(mock_journaler);
+    expect_init_journaler(mock_journaler, 0);
+    expect_start_replay(
+      mock_image_ctx, mock_journaler, {
+        std::bind(&invoke_replay_complete, _1, 0)
+      });
+
+    MockJournalReplay mock_journal_replay;
+    expect_stop_replay(mock_journaler);
+    expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+    expect_committed(mock_journaler, 0);
+    expect_start_append(mock_journaler);
+    ASSERT_EQ(0, when_open(mock_journal));
+  }
+
+  void close_journal(MockJournal &mock_journal,
+                     ::journal::MockJournaler &mock_journaler) {
+    expect_stop_append(mock_journaler, 0);
+    ASSERT_EQ(0, when_close(mock_journal));
+  }
+
+  static void invoke_replay_ready(::journal::ReplayHandler *handler) {
+    handler->handle_entries_available();
+  }
+
+  static void invoke_replay_complete(::journal::ReplayHandler *handler, int r) {
+    handler->handle_complete(r);
+  }
+};
+
+TEST_F(TestMockJournal, StateTransitions) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_ready, _1),
+      std::bind(&invoke_replay_ready, _1),
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  ::journal::MockReplayEntry mock_replay_entry;
+  MockJournalReplay mock_journal_replay;
+  expect_try_pop_front(mock_journaler, true, mock_replay_entry);
+  expect_replay_process(mock_journal_replay);
+  expect_try_pop_front(mock_journaler, true, mock_replay_entry);
+  expect_replay_process(mock_journal_replay);
+  expect_try_pop_front(mock_journaler, false, mock_replay_entry);
+  expect_try_pop_front(mock_journaler, true, mock_replay_entry);
+  expect_replay_process(mock_journal_replay);
+  expect_try_pop_front(mock_journaler, false, mock_replay_entry);
+
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+  expect_committed(mock_journaler, 3);
+
+  expect_start_append(mock_journaler);
+
+  ASSERT_EQ(0, when_open(mock_journal));
+
+  expect_stop_append(mock_journaler, 0);
+  ASSERT_EQ(0, when_close(mock_journal));
+}
+
+TEST_F(TestMockJournal, InitError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, -EINVAL);
+  ASSERT_EQ(-EINVAL, when_open(mock_journal));
+}
+
+TEST_F(TestMockJournal, ReplayCompleteError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_complete, _1, -EINVAL)
+    });
+
+  MockJournalReplay mock_journal_replay;
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+
+  // replay failure should result in replay-restart
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+  expect_start_append(mock_journaler);
+  ASSERT_EQ(0, when_open(mock_journal));
+
+  expect_stop_append(mock_journaler, 0);
+  ASSERT_EQ(0, when_close(mock_journal));
+}
+
+TEST_F(TestMockJournal, FlushReplayError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_ready, _1),
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  ::journal::MockReplayEntry mock_replay_entry;
+  MockJournalReplay mock_journal_replay;
+  expect_try_pop_front(mock_journaler, true, mock_replay_entry);
+  expect_replay_process(mock_journal_replay);
+  expect_try_pop_front(mock_journaler, false, mock_replay_entry);
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, -EINVAL);
+
+  // replay flush failure should result in replay-restart
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+  expect_start_append(mock_journaler);
+  ASSERT_EQ(0, when_open(mock_journal));
+
+  expect_stop_append(mock_journaler, 0);
+  ASSERT_EQ(0, when_close(mock_journal));
+}
+
+TEST_F(TestMockJournal, StopError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  MockJournalReplay mock_journal_replay;
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+  expect_start_append(mock_journaler);
+  ASSERT_EQ(0, when_open(mock_journal));
+
+  expect_stop_append(mock_journaler, -EINVAL);
+  ASSERT_EQ(-EINVAL, when_close(mock_journal));
+}
+
+TEST_F(TestMockJournal, ReplayOnDiskPreFlushError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+
+  ::journal::ReplayHandler *replay_handler = nullptr;
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_ready, _1),
+      [&replay_handler] (::journal::ReplayHandler *handler) {replay_handler = handler;},
+    });
+
+  ::journal::MockReplayEntry mock_replay_entry;
+  MockJournalReplay mock_journal_replay;
+  expect_try_pop_front(mock_journaler, true, mock_replay_entry);
+
+  Context *on_ready;
+  EXPECT_CALL(mock_journal_replay, process(_, _, _))
+                .WillOnce(DoAll(SaveArg<1>(&on_ready),
+                                WithArg<2>(Invoke(this, &TestMockJournal::save_commit_context))));
+
+  expect_try_pop_front(mock_journaler, false, mock_replay_entry);
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+
+  // replay write-to-disk failure should result in replay-restart
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+  expect_start_append(mock_journaler);
+
+  C_SaferCond ctx;
+  mock_journal.open(&ctx);
+
+  // wait for the process callback
+  {
+    Mutex::Locker locker(m_lock);
+    while (m_commit_contexts.empty()) {
+      m_cond.Wait(m_lock);
+    }
+  }
+  on_ready->complete(0);
+
+  // inject RADOS error in the middle of replay
+  Context *on_safe = m_commit_contexts.front();
+  m_commit_contexts.clear();
+  on_safe->complete(-EINVAL);
+
+  // flag the replay as complete
+  replay_handler->handle_complete(0);
+
+  ASSERT_EQ(0, ctx.wait());
+
+  expect_stop_append(mock_journaler, 0);
+  ASSERT_EQ(0, when_close(mock_journal));
+}
+
+TEST_F(TestMockJournal, ReplayOnDiskPostFlushError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  expect_op_work_queue(mock_image_ctx);
+
+  InSequence seq;
+
+  ::journal::MockJournaler mock_journaler;
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_ready, _1),
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  ::journal::MockReplayEntry mock_replay_entry;
+  MockJournalReplay mock_journal_replay;
+  expect_try_pop_front(mock_journaler, true, mock_replay_entry);
+  expect_replay_process(mock_journal_replay);
+  expect_try_pop_front(mock_journaler, false, mock_replay_entry);
+  expect_stop_replay(mock_journaler);
+
+  Context *on_flush;
+  EXPECT_CALL(mock_journal_replay, flush(_)).WillOnce(SaveArg<0>(&on_flush));
+
+  // replay write-to-disk failure should result in replay-restart
+  expect_construct_journaler(mock_journaler);
+  expect_init_journaler(mock_journaler, 0);
+  expect_start_replay(
+    mock_image_ctx, mock_journaler, {
+      std::bind(&invoke_replay_complete, _1, 0)
+    });
+
+  expect_stop_replay(mock_journaler);
+  expect_flush_replay(mock_image_ctx, mock_journal_replay, 0);
+  expect_start_append(mock_journaler);
+
+  C_SaferCond ctx;
+  mock_journal.open(&ctx);
+
+  {
+    // wait for the on_safe process callback
+    Mutex::Locker locker(m_lock);
+    while (m_commit_contexts.empty()) {
+      m_cond.Wait(m_lock);
+    }
+  }
+  m_commit_contexts.front()->complete(-EINVAL);
+  m_commit_contexts.clear();
+
+  // proceed with the flush
+  on_flush->complete(0);
+
+  ASSERT_EQ(0, ctx.wait());
+
+  expect_stop_append(mock_journaler, 0);
+  ASSERT_EQ(0, when_close(mock_journal));
+}
+
+TEST_F(TestMockJournal, EventAndIOCommitOrder) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  ::journal::MockJournaler mock_journaler;
+  open_journal(mock_image_ctx, mock_journal, mock_journaler);
+  BOOST_SCOPE_EXIT_ALL(&) {
+    close_journal(mock_journal, mock_journaler);
+  };
+
+  ::journal::MockFuture mock_future;
+  Context *on_journal_safe1;
+  expect_append_journaler(mock_journaler);
+  expect_wait_future(mock_future, &on_journal_safe1);
+  ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal));
+
+  Context *on_journal_safe2;
+  expect_append_journaler(mock_journaler);
+  expect_wait_future(mock_future, &on_journal_safe2);
+  ASSERT_EQ(2U, when_append_io_event(mock_image_ctx, mock_journal));
+
+  // commit journal event followed by IO event (standard)
+  on_journal_safe1->complete(0);
+  expect_future_committed(mock_journaler);
+  mock_journal.commit_io_event(1U, 0);
+
+  // commit IO event followed by journal event (cache overwrite)
+  mock_journal.commit_io_event(2U, 0);
+  expect_future_committed(mock_journaler);
+
+  C_SaferCond event_ctx;
+  mock_journal.wait_event(2U, &event_ctx);
+  on_journal_safe2->complete(0);
+  ASSERT_EQ(0, event_ctx.wait());
+}
+
+TEST_F(TestMockJournal, EventCommitError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  ::journal::MockJournaler mock_journaler;
+  open_journal(mock_image_ctx, mock_journal, mock_journaler);
+  BOOST_SCOPE_EXIT_ALL(&) {
+    close_journal(mock_journal, mock_journaler);
+  };
+
+  AioCompletion *comp = new AioCompletion();
+  comp->get();
+
+  ::journal::MockFuture mock_future;
+  Context *on_journal_safe;
+  expect_append_journaler(mock_journaler);
+  expect_wait_future(mock_future, &on_journal_safe);
+  ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal, comp));
+
+  // commit the event in the journal w/o waiting writeback
+  expect_future_committed(mock_journaler);
+  on_journal_safe->complete(-EINVAL);
+  ASSERT_EQ(0, comp->wait_for_complete());
+  ASSERT_EQ(-EINVAL, comp->get_return_value());
+  comp->put();
+
+  // cache should receive the error after attempting writeback
+  expect_future_is_valid(mock_future);
+  C_SaferCond flush_ctx;
+  mock_journal.flush_event(1U, &flush_ctx);
+  ASSERT_EQ(-EINVAL, flush_ctx.wait());
+}
+
+TEST_F(TestMockJournal, EventCommitErrorWithPendingWriteback) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  ::journal::MockJournaler mock_journaler;
+  open_journal(mock_image_ctx, mock_journal, mock_journaler);
+  BOOST_SCOPE_EXIT_ALL(&) {
+    close_journal(mock_journal, mock_journaler);
+  };
+
+  AioCompletion *comp = new AioCompletion();
+  comp->get();
+
+  ::journal::MockFuture mock_future;
+  Context *on_journal_safe;
+  expect_append_journaler(mock_journaler);
+  expect_wait_future(mock_future, &on_journal_safe);
+  ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal, comp));
+
+  expect_future_is_valid(mock_future);
+  C_SaferCond flush_ctx;
+  mock_journal.flush_event(1U, &flush_ctx);
+
+  // commit the event in the journal w/ waiting cache writeback
+  expect_future_committed(mock_journaler);
+  on_journal_safe->complete(-EINVAL);
+  ASSERT_EQ(0, comp->wait_for_complete());
+  ASSERT_EQ(-EINVAL, comp->get_return_value());
+  comp->put();
+
+  // cache should receive the error if waiting
+  ASSERT_EQ(-EINVAL, flush_ctx.wait());
+}
+
+TEST_F(TestMockJournal, IOCommitError) {
+  REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+  librbd::ImageCtx *ictx;
+  ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+  MockImageCtx mock_image_ctx(*ictx);
+  MockJournal mock_journal(mock_image_ctx);
+  ::journal::MockJournaler mock_journaler;
+  open_journal(mock_image_ctx, mock_journal, mock_journaler);
+  BOOST_SCOPE_EXIT_ALL(&) {
+    close_journal(mock_journal, mock_journaler);
+  };
+
+  ::journal::MockFuture mock_future;
+  Context *on_journal_safe;
+  expect_append_journaler(mock_journaler);
+  expect_wait_future(mock_future, &on_journal_safe);
+  ASSERT_EQ(1U, when_append_io_event(mock_image_ctx, mock_journal));
+
+  // failed IO remains uncommitted in journal
+  on_journal_safe->complete(0);
+  mock_journal.commit_io_event(1U, -EINVAL);
+}
+
+} // namespace librbd
diff --git a/src/test/librbd/test_mock_fixture.cc b/src/test/librbd/test_mock_fixture.cc
index d181914..f5a2394 100644
--- a/src/test/librbd/test_mock_fixture.cc
+++ b/src/test/librbd/test_mock_fixture.cc
@@ -17,6 +17,8 @@ template class librbd::operation::Request<librbd::MockImageCtx>;
 
 using ::testing::_;
 using ::testing::DoDefault;
+using ::testing::Return;
+using ::testing::WithArg;
 
 TestMockFixture::TestRadosClientPtr TestMockFixture::s_test_rados_client;
 ::testing::NiceMock<librados::MockTestMemRadosClient> *
@@ -68,3 +70,52 @@ librados::MockTestMemIoCtxImpl &TestMockFixture::get_mock_io_ctx(
     reinterpret_cast<librados::MockTestMemIoCtxImpl **>(&ioctx);
   return **mock;
 }
+
+void TestMockFixture::initialize_features(librbd::ImageCtx *ictx,
+                                          librbd::MockImageCtx &mock_image_ctx,
+                                          librbd::MockExclusiveLock &mock_exclusive_lock,
+                                          librbd::MockJournal &mock_journal,
+                                          librbd::MockObjectMap &mock_object_map) {
+  if (ictx->test_features(RBD_FEATURE_EXCLUSIVE_LOCK)) {
+    mock_image_ctx.exclusive_lock = &mock_exclusive_lock;
+  }
+  if (ictx->test_features(RBD_FEATURE_JOURNALING)) {
+    mock_image_ctx.journal = &mock_journal;
+  }
+  if (ictx->test_features(RBD_FEATURE_OBJECT_MAP)) {
+    mock_image_ctx.object_map = &mock_object_map;
+  }
+}
+
+void TestMockFixture::expect_is_journal_replaying(librbd::MockJournal &mock_journal) {
+  EXPECT_CALL(mock_journal, is_journal_replaying()).WillOnce(Return(false));
+}
+
+void TestMockFixture::expect_is_journal_ready(librbd::MockJournal &mock_journal) {
+  EXPECT_CALL(mock_journal, is_journal_ready()).WillOnce(Return(true));
+}
+
+void TestMockFixture::expect_allocate_op_tid(librbd::MockImageCtx &mock_image_ctx) {
+  if (mock_image_ctx.journal != nullptr) {
+    EXPECT_CALL(*mock_image_ctx.journal, allocate_op_tid())
+                  .WillOnce(Return(1U));
+  }
+}
+
+void TestMockFixture::expect_append_op_event(librbd::MockImageCtx &mock_image_ctx, int r) {
+  if (mock_image_ctx.journal != nullptr) {
+    expect_is_journal_replaying(*mock_image_ctx.journal);
+    expect_allocate_op_tid(mock_image_ctx);
+    EXPECT_CALL(*mock_image_ctx.journal, append_op_event_mock(_, _, _))
+                  .WillOnce(WithArg<2>(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue)));
+  }
+}
+
+void TestMockFixture::expect_commit_op_event(librbd::MockImageCtx &mock_image_ctx, int r) {
+  if (mock_image_ctx.journal != nullptr) {
+    expect_is_journal_replaying(*mock_image_ctx.journal);
+    expect_is_journal_ready(*mock_image_ctx.journal);
+    EXPECT_CALL(*mock_image_ctx.journal, commit_op_event(1U, r));
+  }
+}
+
diff --git a/src/test/librbd/test_mock_fixture.h b/src/test/librbd/test_mock_fixture.h
index bf8a0af..ce3e6d5 100644
--- a/src/test/librbd/test_mock_fixture.h
+++ b/src/test/librbd/test_mock_fixture.h
@@ -74,6 +74,18 @@ public:
   void expect_op_work_queue(librbd::MockImageCtx &mock_image_ctx);
   void expect_unlock_exclusive_lock(librbd::ImageCtx &ictx);
 
+  void initialize_features(librbd::ImageCtx *ictx,
+                           librbd::MockImageCtx &mock_image_ctx,
+                           librbd::MockExclusiveLock &mock_exclusive_lock,
+                           librbd::MockJournal &mock_journal,
+                           librbd::MockObjectMap &mock_object_map);
+
+  void expect_is_journal_replaying(librbd::MockJournal &mock_journal);
+  void expect_is_journal_ready(librbd::MockJournal &mock_journal);
+  void expect_allocate_op_tid(librbd::MockImageCtx &mock_image_ctx);
+  void expect_append_op_event(librbd::MockImageCtx &mock_image_ctx, int r);
+  void expect_commit_op_event(librbd::MockImageCtx &mock_image_ctx, int r);
+
 private:
   static TestRadosClientPtr s_test_rados_client;
   static ::testing::NiceMock<librados::MockTestMemRadosClient> *s_mock_rados_client;
diff --git a/src/test/mon/mkfs.sh b/src/test/mon/mkfs.sh
index 57a0301..f165fc6 100755
--- a/src/test/mon/mkfs.sh
+++ b/src/test/mon/mkfs.sh
@@ -43,6 +43,7 @@ function mon_mkfs() {
         --id $MON_ID \
         --fsid $fsid \
         --erasure-code-dir=.libs \
+        --compression-dir=.libs \
         --mkfs \
         --mon-data=$MON_DIR \
         --mon-initial-members=$MON_ID \
@@ -57,6 +58,7 @@ function mon_run() {
         --mon-osd-full-ratio=.99 \
         --mon-data-avail-crit=1 \
         --erasure-code-dir=.libs \
+        --compression-dir=.libs \
         --mon-data=$MON_DIR \
         --log-file=$MON_DIR/log \
         --mon-cluster-log-file=$MON_DIR/log \
@@ -84,6 +86,7 @@ function auth_none() {
         --mon-osd-full-ratio=.99 \
         --mon-data-avail-crit=1 \
         --erasure-code-dir=.libs \
+        --compression-dir=.libs \
         --mon-data=$MON_DIR \
         --extract-monmap $MON_DIR/monmap
 
@@ -151,6 +154,7 @@ function makedir() {
         --mon-osd-full-ratio=.99 \
         --mon-data-avail-crit=1 \
         --erasure-code-dir=.libs \
+        --compression-dir=.libs \
         --mkfs \
         --mon-data=$toodeep 2>&1 | tee $DIR/makedir.log
     grep 'toodeep.*No such file' $DIR/makedir.log > /dev/null
diff --git a/src/test/mon/osd-erasure-code-profile.sh b/src/test/mon/osd-erasure-code-profile.sh
index bc4e30f..8e9491f 100755
--- a/src/test/mon/osd-erasure-code-profile.sh
+++ b/src/test/mon/osd-erasure-code-profile.sh
@@ -21,7 +21,7 @@ function run() {
     local dir=$1
     shift
 
-    export CEPH_MON="127.0.0.1:7108" # git grep '\<7108\>' : there must be only one
+    export CEPH_MON="127.0.0.1:7220" # git grep '\<7220\>' : there must be only one
     export CEPH_ARGS
     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
     CEPH_ARGS+="--mon-host=$CEPH_MON "
diff --git a/src/test/mon/test_mon_workloadgen.cc b/src/test/mon/test_mon_workloadgen.cc
index e18906d..64575fe 100644
--- a/src/test/mon/test_mon_workloadgen.cc
+++ b/src/test/mon/test_mon_workloadgen.cc
@@ -935,7 +935,7 @@ void handle_test_signal(int signum)
   if ((signum != SIGINT) && (signum != SIGTERM))
     return;
 
-  std::cerr << "*** Got signal " << sys_siglist[signum] << " ***" << std::endl;
+  std::cerr << "*** Got signal " << sig_str(signum) << " ***" << std::endl;
   Mutex::Locker l(shutdown_lock);
   if (shutdown_timer) {
     shutdown_timer->cancel_all_events();
diff --git a/src/test/msgr/perf_msgr_client.cc b/src/test/msgr/perf_msgr_client.cc
index 17c4aca..fa21b49 100644
--- a/src/test/msgr/perf_msgr_client.cc
+++ b/src/test/msgr/perf_msgr_client.cc
@@ -142,7 +142,7 @@ class MessengerClient {
   }
   void start() {
     for (uint64_t i = 0; i < clients.size(); ++i)
-      clients[i]->create();
+      clients[i]->create("client");
     for (uint64_t i = 0; i < msgrs.size(); ++i)
       msgrs[i]->wait();
   }
diff --git a/src/test/msgr/perf_msgr_server.cc b/src/test/msgr/perf_msgr_server.cc
index b38a76a..3989cd2 100644
--- a/src/test/msgr/perf_msgr_server.cc
+++ b/src/test/msgr/perf_msgr_server.cc
@@ -72,7 +72,7 @@ class ServerDispatcher : public Dispatcher {
 
  public:
   ServerDispatcher(int threads, uint64_t delay): Dispatcher(g_ceph_context), think_time(delay),
-    op_tp(g_ceph_context, "ServerDispatcher::op_tp", threads, "serverdispatcher_op_threads"),
+    op_tp(g_ceph_context, "ServerDispatcher::op_tp", "tp_serv_disp", threads, "serverdispatcher_op_threads"),
     op_wq(30, 30, &op_tp) {
     op_tp.start();
   }
diff --git a/src/test/msgr/test_async_driver.cc b/src/test/msgr/test_async_driver.cc
index 1d6d290..fb46374 100644
--- a/src/test/msgr/test_async_driver.cc
+++ b/src/test/msgr/test_async_driver.cc
@@ -144,7 +144,7 @@ void* echoclient(void *arg)
   sa.sin_family = AF_INET;
   sa.sin_port = htons(port);
   char addr[] = "127.0.0.1";
-  int r = inet_aton(addr, &sa.sin_addr);
+  int r = inet_pton(AF_INET, addr, &sa.sin_addr);
 
   int connect_sd = ::socket(AF_INET, SOCK_STREAM, 0);
   if (connect_sd >= 0) {
@@ -307,8 +307,8 @@ TEST(EventCenterTest, DispatchTest) {
   atomic_t count(0);
   Mutex lock("DispatchTest::lock");
   Cond cond;
-  worker1.create();
-  worker2.create();
+  worker1.create("worker_1");
+  worker2.create("worker_2");
   for (int i = 0; i < 10000; ++i) {
     count.inc();
     worker1.center.dispatch_event_external(EventCallbackRef(new CountEvent(&count, &lock, &cond)));
diff --git a/src/test/objectstore/FileStoreDiff.cc b/src/test/objectstore/FileStoreDiff.cc
index a49e4af..6a08e9c 100644
--- a/src/test/objectstore/FileStoreDiff.cc
+++ b/src/test/objectstore/FileStoreDiff.cc
@@ -15,7 +15,7 @@
 #include <map>
 #include <boost/scoped_ptr.hpp>
 #include "common/debug.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "common/config.h"
 
 #include "FileStoreDiff.h"
diff --git a/src/test/objectstore/FileStoreDiff.h b/src/test/objectstore/FileStoreDiff.h
index f7aedee..ba9cfb9 100644
--- a/src/test/objectstore/FileStoreDiff.h
+++ b/src/test/objectstore/FileStoreDiff.h
@@ -18,7 +18,7 @@
 #include <map>
 #include <boost/scoped_ptr.hpp>
 #include "common/debug.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "common/config.h"
 
 class FileStoreDiff {
diff --git a/src/test/objectstore/FileStoreTracker.h b/src/test/objectstore/FileStoreTracker.h
index e350c80..a324fa2 100644
--- a/src/test/objectstore/FileStoreTracker.h
+++ b/src/test/objectstore/FileStoreTracker.h
@@ -3,7 +3,7 @@
 #ifndef FILESTORE_TRACKER_H
 #define FILESTORE_TRACKER_H
 #include "test/common/ObjectContents.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "kv/KeyValueDB.h"
 #include <boost/scoped_ptr.hpp>
 #include <list>
diff --git a/src/test/objectstore/TestRocksdbOptionParse.cc b/src/test/objectstore/TestRocksdbOptionParse.cc
index eaccfa1..f89e27e 100644
--- a/src/test/objectstore/TestRocksdbOptionParse.cc
+++ b/src/test/objectstore/TestRocksdbOptionParse.cc
@@ -14,7 +14,7 @@ const string dir("store_test_temp_dir");
 TEST(RocksDBOption, simple) {
   rocksdb::Options options;
   rocksdb::Status status;
-  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir);
+  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, NULL);
   string options_string = ""
 			  "write_buffer_size=536870912;"
 			  "create_if_missing=true;"
@@ -30,14 +30,14 @@ TEST(RocksDBOption, simple) {
 			  "disable_data_sync = false;";
   int r = db->ParseOptionsFromString(options_string, options);
   ASSERT_EQ(0, r);
-  ASSERT_EQ(536870912, options.write_buffer_size);
+  ASSERT_EQ(536870912u, options.write_buffer_size);
   ASSERT_EQ(4, options.max_write_buffer_number);
   ASSERT_EQ(4, options.max_background_compactions);
-  ASSERT_EQ(5, options.stats_dump_period_sec);
+  ASSERT_EQ(5u, options.stats_dump_period_sec);
   ASSERT_EQ(2, options.min_write_buffer_number_to_merge);
   ASSERT_EQ(4, options.level0_file_num_compaction_trigger);
-  ASSERT_EQ(104857600, options.max_bytes_for_level_base);
-  ASSERT_EQ(10485760, options.target_file_size_base);
+  ASSERT_EQ(104857600u, options.max_bytes_for_level_base);
+  ASSERT_EQ(10485760u, options.target_file_size_base);
   ASSERT_EQ(3, options.num_levels);
   ASSERT_FALSE(options.disableDataSync);
  // ASSERT_EQ("none", options.compression);
@@ -45,7 +45,7 @@ TEST(RocksDBOption, simple) {
 TEST(RocksDBOption, interpret) {
   rocksdb::Options options;
   rocksdb::Status status;
-  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir);
+  RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, NULL);
   string options_string = "compact_on_mount = true; compaction_threads=10;flusher_threads=5;";
   
   int r = db->ParseOptionsFromString(options_string, options);
@@ -67,7 +67,7 @@ TEST(RocksDBOption, interpret) {
     if (it->thread_type == rocksdb::ThreadStatus::LOW_PRIORITY)
       num_low_pri_threads++;
   }
-  ASSERT_EQ(15, thread_list.size());
+  ASSERT_EQ(15u, thread_list.size());
   //low pri threads is compaction_threads
   ASSERT_EQ(10, num_low_pri_threads);
   //high pri threads is flusher_threads
diff --git a/src/test/objectstore/chain_xattr.cc b/src/test/objectstore/chain_xattr.cc
index 51efd55..5080321 100644
--- a/src/test/objectstore/chain_xattr.cc
+++ b/src/test/objectstore/chain_xattr.cc
@@ -21,7 +21,7 @@
 
 #include <stdio.h>
 #include <signal.h>
-#include "os/chain_xattr.h"
+#include "os/filestore/chain_xattr.h"
 #include "include/Context.h"
 #include "common/errno.h"
 #include "common/ceph_argparse.h"
@@ -120,8 +120,8 @@ TEST(chain_xattr, get_and_set) {
   {
     int x;
     const string name = user + string(CHAIN_XATTR_MAX_NAME_LEN * 2, '@');
-    ASSERT_THROW(chain_setxattr(file, name.c_str(), &x, sizeof(x)), FailedAssertion);
-    ASSERT_THROW(chain_fsetxattr(fd, name.c_str(), &x, sizeof(x)), FailedAssertion);
+    ASSERT_DEATH(chain_setxattr(file, name.c_str(), &x, sizeof(x)), "");
+    ASSERT_DEATH(chain_fsetxattr(fd, name.c_str(), &x, sizeof(x)), "");
   }
 
   {
@@ -229,7 +229,7 @@ TEST(chain_xattr, listxattr) {
   const string name2 = user + string(CHAIN_XATTR_MAX_NAME_LEN - user.size(), '@');
   const string x(LARGE_BLOCK_LEN, 'X');
   const int y = 1234;
-  
+
   ASSERT_EQ(LARGE_BLOCK_LEN, chain_setxattr(file, name1.c_str(), x.c_str(), LARGE_BLOCK_LEN));
   ASSERT_EQ((int)sizeof(y), chain_setxattr(file, name2.c_str(), &y, sizeof(y)));
 
diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc
index 7f95a4f..d57e82c 100644
--- a/src/test/objectstore/store_test.cc
+++ b/src/test/objectstore/store_test.cc
@@ -18,8 +18,7 @@
 #include <time.h>
 #include <sys/mount.h>
 #include "os/ObjectStore.h"
-#include "os/FileStore.h"
-#include "os/KeyValueStore.h"
+#include "os/filestore/FileStore.h"
 #include "include/Context.h"
 #include "common/ceph_argparse.h"
 #include "global/global_init.h"
@@ -43,9 +42,20 @@ public:
   boost::scoped_ptr<ObjectStore> store;
 
   StoreTest() : store(0) {}
+
+  void rm_r(string path) {
+    string cmd = string("rm -r ") + path;
+    cout << "==> " << cmd << std::endl;
+    int r = ::system(cmd.c_str());
+    if (r) {
+      cerr << "failed with exit code " << r
+	   << ", continuing anyway" << std::endl;
+    }
+  }
+
   virtual void SetUp() {
     int r = ::mkdir("store_test_temp_dir", 0777);
-    if (r < 0 && errno != EEXIST) {
+    if (r < 0) {
       r = -errno;
       cerr << __func__ << ": unable to create store_test_temp_dir" << ": " << cpp_strerror(r) << std::endl;
       return;
@@ -59,14 +69,16 @@ public:
       cerr << __func__ << ": objectstore type " << string(GetParam()) << " doesn't exist yet!" << std::endl;
       return;
     }
+    EXPECT_EQ(store_->mkfs(), 0);
+    EXPECT_EQ(store_->mount(), 0);
     store.reset(store_);
-    EXPECT_EQ(store->mkfs(), 0);
-    EXPECT_EQ(store->mount(), 0);
   }
 
   virtual void TearDown() {
-    if (store)
+    if (store) {
       store->umount();
+      rm_r("store_test_temp_dir");
+    }
   }
 };
 
@@ -97,6 +109,9 @@ TEST_P(StoreTest, collect_metadata) {
   }
 }
 
+TEST_P(StoreTest, Trivial) {
+}
+
 TEST_P(StoreTest, TrivialRemount) {
   store->umount();
   int r = store->mount();
@@ -137,6 +152,24 @@ TEST_P(StoreTest, SimpleRemount) {
     r = store->apply_transaction(&osr, t);
     ASSERT_EQ(r, 0);
   }
+  store->umount();
+  r = store->mount();
+  ASSERT_EQ(0, r);
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+    bool exists = store->exists(cid, hoid);
+    ASSERT_TRUE(!exists);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove_collection(cid);
+    cerr << "remove collection" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
 }
 
 TEST_P(StoreTest, IORemount) {
@@ -182,6 +215,82 @@ TEST_P(StoreTest, IORemount) {
   }
 }
 
+TEST_P(StoreTest, FiemapEmpty) {
+  ObjectStore::Sequencer osr("test");
+  coll_t cid;
+  int r = 0;
+  ghobject_t oid(hobject_t(sobject_t("fiemap_object", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    t.touch(cid, oid);
+    t.truncate(cid, oid, 100000);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    bufferlist bl;
+    store->fiemap(cid, oid, 0, 100000, bl);
+    map<uint64_t,uint64_t> m, e;
+    bufferlist::iterator p = bl.begin();
+    ::decode(m, p);
+    cout << " got " << m << std::endl;
+    e[0] = 100000;
+    EXPECT_TRUE(m == e || m.empty());
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, oid);
+    t.remove_collection(cid);
+    cerr << "remove collection" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
+TEST_P(StoreTest, FiemapHoles) {
+  ObjectStore::Sequencer osr("test");
+  coll_t cid;
+  int r = 0;
+  ghobject_t oid(hobject_t(sobject_t("fiemap_object", CEPH_NOSNAP)));
+  bufferlist bl;
+  bl.append("foo");
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    t.touch(cid, oid);
+    t.write(cid, oid, 0, 3, bl);
+    t.write(cid, oid, 1048576, 3, bl);
+    t.write(cid, oid, 4194304, 3, bl);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    bufferlist bl;
+    store->fiemap(cid, oid, 0, 0, bl);
+    map<uint64_t,uint64_t> m, e;
+    bufferlist::iterator p = bl.begin();
+    ::decode(m, p);
+    cout << " got " << m << std::endl;
+    ASSERT_TRUE(!m.empty());
+    ASSERT_GE(m[0], 3);
+    ASSERT_TRUE((m.size() == 1 &&
+		 m[0] > 4194304u) ||
+		(m.size() == 3 &&
+		 m.count(0) &&
+		 m.count(1048576) &&
+		 m.count(4194304)));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, oid);
+    t.remove_collection(cid);
+    cerr << "remove collection" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
 TEST_P(StoreTest, SimpleMetaColTest) {
   ObjectStore::Sequencer osr("test");
   coll_t cid;
@@ -468,6 +577,193 @@ TEST_P(StoreTest, ManySmallWrite) {
   }
 }
 
+TEST_P(StoreTest, SmallSkipFront) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid;
+  ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.touch(cid, a);
+    t.truncate(cid, a, 3000);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    bufferlist bl;
+    bufferptr bp(4096);
+    memset(bp.c_str(), 1, 4096);
+    bl.append(bp);
+    ObjectStore::Transaction t;
+    t.write(cid, a, 4096, 4096, bl);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    bufferlist bl;
+    ASSERT_EQ(8192, store->read(cid, a, 0, 8192, bl));
+    for (unsigned i=0; i<4096; ++i)
+      ASSERT_EQ(0, bl[i]);
+    for (unsigned i=4096; i<8192; ++i)
+      ASSERT_EQ(1, bl[i]);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, a);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
+TEST_P(StoreTest, SmallSequentialUnaligned) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid;
+  ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  bufferlist bl;
+  int len = 1000;
+  bufferptr bp(len);
+  bp.zero();
+  bl.append(bp);
+  for (int i=0; i<1000; ++i) {
+    ObjectStore::Transaction t;
+    t.write(cid, a, i*len, len, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, a);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
+TEST_P(StoreTest, ManyBigWrite) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid;
+  ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  ghobject_t b(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  bufferlist bl;
+  bufferptr bp(4 * 1048576);
+  bp.zero();
+  bl.append(bp);
+  for (int i=0; i<10; ++i) {
+    ObjectStore::Transaction t;
+    t.write(cid, a, i*4*1048586, 4*1048576, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  // aligned
+  for (int i=0; i<10; ++i) {
+    ObjectStore::Transaction t;
+    t.write(cid, b, (rand() % 256)*4*1048576, 4*1048576, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  // unaligned
+  for (int i=0; i<10; ++i) {
+    ObjectStore::Transaction t;
+    t.write(cid, b, (rand() % (256*4096))*1024, 4*1048576, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  // do some zeros
+  for (int i=0; i<10; ++i) {
+    ObjectStore::Transaction t;
+    t.zero(cid, b, (rand() % (256*4096))*1024, 16*1048576);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, a);
+    t.remove(cid, b);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
+TEST_P(StoreTest, MiscFragmentTests) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid;
+  ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  bufferlist bl;
+  bufferptr bp(524288);
+  bp.zero();
+  bl.append(bp);
+  {
+    ObjectStore::Transaction t;
+    t.write(cid, a, 0, 524288, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.write(cid, a, 1048576, 524288, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    bufferlist inbl;
+    int r = store->read(cid, a, 524288 + 131072, 1024, inbl);
+    ASSERT_EQ(r, 1024);
+    ASSERT_EQ(inbl.length(), 1024u);
+    ASSERT_TRUE(inbl.is_zero());
+  }
+  {
+    ObjectStore::Transaction t;
+    t.write(cid, a, 1048576 - 4096, 524288, bl, 0);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, a);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+
+}
+
 TEST_P(StoreTest, SimpleAttrTest) {
   ObjectStore::Sequencer osr("test");
   int r;
@@ -702,7 +998,8 @@ TEST_P(StoreTest, SimpleCloneTest) {
     r = store->apply_transaction(&osr, t);
     ASSERT_EQ(r, 0);
   }
-  ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP),
+			    "key", 123, -1, ""));
   bufferlist small, large, xlarge, newdata, attr;
   small.append("small");
   large.append("large");
@@ -713,12 +1010,14 @@ TEST_P(StoreTest, SimpleCloneTest) {
     t.setattr(cid, hoid, "attr1", small);
     t.setattr(cid, hoid, "attr2", large);
     t.setattr(cid, hoid, "attr3", xlarge);
+    t.write(cid, hoid, 0, small.length(), small);
     t.write(cid, hoid, 10, small.length(), small);
     cerr << "Creating object and set attr " << hoid << std::endl;
     r = store->apply_transaction(&osr, t);
     ASSERT_EQ(r, 0);
   }
-  ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+  ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP),
+			     "key", 123, -1, ""));
   {
     ObjectStore::Transaction t;
     t.clone(cid, hoid, hoid2);
@@ -736,6 +1035,11 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ASSERT_TRUE(newdata.contents_equal(large));
 
     newdata.clear();
+    r = store->read(cid, hoid, 0, 5, newdata);
+    ASSERT_EQ(r, 5);
+    ASSERT_TRUE(newdata.contents_equal(small));
+
+    newdata.clear();
     r = store->read(cid, hoid2, 10, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(newdata.contents_equal(small));
@@ -758,6 +1062,275 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ObjectStore::Transaction t;
     t.remove(cid, hoid);
     t.remove(cid, hoid2);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+  }
+  {
+    bufferlist final;
+    bufferptr p(16384);
+    memset(p.c_str(), 1, p.length());
+    bufferlist pl;
+    pl.append(p);
+    final.append(p);
+    ObjectStore::Transaction t;
+    t.write(cid, hoid, 0, pl.length(), pl);
+    t.clone(cid, hoid, hoid2);
+    bufferptr a(4096);
+    memset(a.c_str(), 2, a.length());
+    bufferlist al;
+    al.append(a);
+    final.append(a);
+    t.write(cid, hoid, pl.length(), a.length(), al);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+    bufferlist rl;
+    ASSERT_EQ((int)final.length(),
+	      store->read(cid, hoid, 0, final.length(), rl));
+    ASSERT_TRUE(final.contents_equal(rl));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+  }
+  {
+    bufferlist final;
+    bufferptr p(16384);
+    memset(p.c_str(), 111, p.length());
+    bufferlist pl;
+    pl.append(p);
+    final.append(p);
+    ObjectStore::Transaction t;
+    t.write(cid, hoid, 0, pl.length(), pl);
+    t.clone(cid, hoid, hoid2);
+    bufferptr z(4096);
+    z.zero();
+    final.append(z);
+    bufferptr a(4096);
+    memset(a.c_str(), 112, a.length());
+    bufferlist al;
+    al.append(a);
+    final.append(a);
+    t.write(cid, hoid, pl.length() + z.length(), a.length(), al);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+    bufferlist rl;
+    ASSERT_EQ((int)final.length(),
+	      store->read(cid, hoid, 0, final.length(), rl));
+    ASSERT_TRUE(final.contents_equal(rl));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+  }
+  {
+    bufferlist final;
+    bufferptr p(16000);
+    memset(p.c_str(), 5, p.length());
+    bufferlist pl;
+    pl.append(p);
+    final.append(p);
+    ObjectStore::Transaction t;
+    t.write(cid, hoid, 0, pl.length(), pl);
+    t.clone(cid, hoid, hoid2);
+    bufferptr z(1000);
+    z.zero();
+    final.append(z);
+    bufferptr a(8000);
+    memset(a.c_str(), 6, a.length());
+    bufferlist al;
+    al.append(a);
+    final.append(a);
+    t.write(cid, hoid, 17000, a.length(), al);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+    bufferlist rl;
+    ASSERT_EQ((int)final.length(),
+	      store->read(cid, hoid, 0, final.length(), rl));
+    /*cout << "expected:\n";
+    final.hexdump(cout);
+    cout << "got:\n";
+    rl.hexdump(cout);*/
+    ASSERT_TRUE(final.contents_equal(rl));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+  }
+  {
+    bufferptr p(1048576);
+    memset(p.c_str(), 3, p.length());
+    bufferlist pl;
+    pl.append(p);
+    ObjectStore::Transaction t;
+    t.write(cid, hoid, 0, pl.length(), pl);
+    t.clone(cid, hoid, hoid2);
+    bufferptr a(65536);
+    memset(a.c_str(), 4, a.length());
+    bufferlist al;
+    al.append(a);
+    t.write(cid, hoid, a.length(), a.length(), al);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+    bufferlist rl;
+    bufferlist final;
+    final.substr_of(pl, 0, al.length());
+    final.append(al);
+    bufferlist end;
+    end.substr_of(pl, al.length()*2, pl.length() - al.length()*2);
+    final.append(end);
+    ASSERT_EQ((int)final.length(),
+	      store->read(cid, hoid, 0, final.length(), rl));
+    /*cout << "expected:\n";
+    final.hexdump(cout);
+    cout << "got:\n";
+    rl.hexdump(cout);*/
+    ASSERT_TRUE(final.contents_equal(rl));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+  }
+  {
+    bufferptr p(65536);
+    memset(p.c_str(), 7, p.length());
+    bufferlist pl;
+    pl.append(p);
+    ObjectStore::Transaction t;
+    t.write(cid, hoid, 0, pl.length(), pl);
+    t.clone(cid, hoid, hoid2);
+    bufferptr a(4096);
+    memset(a.c_str(), 8, a.length());
+    bufferlist al;
+    al.append(a);
+    t.write(cid, hoid, 32768, a.length(), al);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+    bufferlist rl;
+    bufferlist final;
+    final.substr_of(pl, 0, 32768);
+    final.append(al);
+    bufferlist end;
+    end.substr_of(pl, final.length(), pl.length() - final.length());
+    final.append(end);
+    ASSERT_EQ((int)final.length(),
+	      store->read(cid, hoid, 0, final.length(), rl));
+    /*cout << "expected:\n";
+    final.hexdump(cout);
+    cout << "got:\n";
+    rl.hexdump(cout);*/
+    ASSERT_TRUE(final.contents_equal(rl));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+  }
+  {
+    bufferptr p(65536);
+    memset(p.c_str(), 9, p.length());
+    bufferlist pl;
+    pl.append(p);
+    ObjectStore::Transaction t;
+    t.write(cid, hoid, 0, pl.length(), pl);
+    t.clone(cid, hoid, hoid2);
+    bufferptr a(4096);
+    memset(a.c_str(), 10, a.length());
+    bufferlist al;
+    al.append(a);
+    t.write(cid, hoid, 33768, a.length(), al);
+    ASSERT_EQ(0u, store->apply_transaction(&osr, t));
+    bufferlist rl;
+    bufferlist final;
+    final.substr_of(pl, 0, 33768);
+    final.append(al);
+    bufferlist end;
+    end.substr_of(pl, final.length(), pl.length() - final.length());
+    final.append(end);
+    ASSERT_EQ((int)final.length(),
+	      store->read(cid, hoid, 0, final.length(), rl));
+    /*cout << "expected:\n";
+    final.hexdump(cout);
+    cout << "got:\n";
+    rl.hexdump(cout);*/
+    ASSERT_TRUE(final.contents_equal(rl));
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
+    t.remove(cid, hoid2);
+    t.remove_collection(cid);
+    cerr << "Cleaning" << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
+TEST_P(StoreTest, OmapSimple) {
+  ObjectStore::Sequencer osr("test");
+  int r;
+  coll_t cid;
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    cerr << "Creating collection " << cid << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  ghobject_t hoid(hobject_t(sobject_t("omap_obj", CEPH_NOSNAP),
+			    "key", 123, -1, ""));
+  bufferlist small;
+  small.append("small");
+  map<string,bufferlist> km;
+  km["foo"] = small;
+  km["bar"].append("asdfjkasdkjdfsjkafskjsfdj");
+  bufferlist header;
+  header.append("this is a header");
+  {
+    ObjectStore::Transaction t;
+    t.touch(cid, hoid);
+    t.omap_setkeys(cid, hoid, km);
+    t.omap_setheader(cid, hoid, header);
+    cerr << "Creating object and set omap " << hoid << std::endl;
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  // get header, keys
+  {
+    bufferlist h;
+    map<string,bufferlist> r;
+    store->omap_get(cid, hoid, &h, &r);
+    ASSERT_TRUE(h.contents_equal(header));
+    ASSERT_EQ(r.size(), km.size());
+    cout << "r: " << r << std::endl;
+  }
+  // test iterator with seek_to_first
+  {
+    map<string,bufferlist> r;
+    ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, hoid);
+    for (iter->seek_to_first(); iter->valid(); iter->next(false)) {
+      r[iter->key()] = iter->value();
+    }
+    cout << "r: " << r << std::endl;
+    ASSERT_EQ(r.size(), km.size());
+  }
+  // test iterator with initial lower_bound
+  {
+    map<string,bufferlist> r;
+    ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, hoid);
+    for (iter->lower_bound(string()); iter->valid(); iter->next(false)) {
+      r[iter->key()] = iter->value();
+    }
+    cout << "r: " << r << std::endl;
+    ASSERT_EQ(r.size(), km.size());
+  }
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, hoid);
     t.remove_collection(cid);
     cerr << "Cleaning" << std::endl;
     r = store->apply_transaction(&osr, t);
@@ -776,7 +1349,8 @@ TEST_P(StoreTest, OmapCloneTest) {
     r = store->apply_transaction(&osr, t);
     ASSERT_EQ(r, 0);
   }
-  ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP),
+			    "key", 123, -1, ""));
   bufferlist small;
   small.append("small");
   map<string,bufferlist> km;
@@ -793,7 +1367,8 @@ TEST_P(StoreTest, OmapCloneTest) {
     r = store->apply_transaction(&osr, t);
     ASSERT_EQ(r, 0);
   }
-  ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+  ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP),
+			     "key", 123, -1, ""));
   {
     ObjectStore::Transaction t;
     t.clone(cid, hoid, hoid2);
@@ -1047,24 +1622,31 @@ public:
   MixedGenerator(int64_t p) : seq(0), poolid(p) {}
   ghobject_t create_object(gen_type *gen) {
     char buf[100];
-    snprintf(buf, sizeof(buf), "%u", seq);
-
-    boost::uniform_int<> true_false(0, 1);
+    snprintf(buf, sizeof(buf), "OBJ_%u", seq);
     string name(buf);
-    if (true_false(*gen)) {
-      // long
-      for (int i = 0; i < 100; ++i) name.append("aaaaa");
-    } else if (true_false(*gen)) {
-      name = "DIR_" + name;
-    }
-
-    // hash
-    //boost::binomial_distribution<uint32_t> bin(0xFFFFFF, 0.5);
     ++seq;
-    return ghobject_t(hobject_t(name, string(), rand() & 2 ? CEPH_NOSNAP : rand(), rand() & 0xFF, poolid, ""));
+    return ghobject_t(
+      hobject_t(
+	name, string(), rand() & 2 ? CEPH_NOSNAP : rand(),
+	seq % 16, // use smaller set of hash values so clone can work
+	poolid, ""));
   }
 };
 
+static void dump_bl_mismatch(bufferlist& expected, bufferlist& actual)
+{
+  cout << __func__ << std::endl;
+  unsigned offset = 0;
+  while (expected[offset] == actual[offset])
+    ++offset;
+  cout << "--- buffer mismatch at offset 0x" << std::hex << offset << std::dec
+       << std::endl;
+  cout << "--- expected:\n";
+  expected.hexdump(cout);
+  cout << "--- actual:\n";
+  actual.hexdump(cout);
+}
+
 class SyntheticWorkloadState {
   struct Object {
     bufferlist data;
@@ -1073,11 +1655,11 @@ class SyntheticWorkloadState {
 public:
   static const unsigned max_in_flight = 16;
   static const unsigned max_objects = 3000;
-  static const unsigned max_object_len = 1024 * 40;
   static const unsigned max_attr_size = 5;
   static const unsigned max_attr_name_len = 100;
   static const unsigned max_attr_value_len = 1024 * 4;
   coll_t cid;
+  unsigned max_object_len;
   unsigned in_flight;
   map<ghobject_t, Object, ghobject_t::BitwiseComparator> contents;
   set<ghobject_t, ghobject_t::BitwiseComparator> available_objects;
@@ -1090,6 +1672,16 @@ public:
   Mutex lock;
   Cond cond;
 
+  struct EnterExit {
+    const char *msg;
+    EnterExit(const char *m) : msg(m) {
+      //cout << pthread_self() << " enter " << msg << std::endl;
+    }
+    ~EnterExit() {
+      //cout << pthread_self() << " exit " << msg << std::endl;
+    }
+  };
+
   class C_SyntheticOnReadable : public Context {
   public:
     SyntheticWorkloadState *state;
@@ -1101,6 +1693,7 @@ public:
 
     void finish(int r) {
       Mutex::Locker locker(state->lock);
+      EnterExit ee("onreadable finish");
       ASSERT_TRUE(state->in_flight_objects.count(hoid));
       ASSERT_EQ(r, 0);
       state->in_flight_objects.erase(hoid);
@@ -1108,6 +1701,15 @@ public:
         state->available_objects.insert(hoid);
       --(state->in_flight);
       state->cond.Signal();
+
+      bufferlist r2;
+      r = state->store->read(state->cid, hoid, 0, state->contents[hoid].data.length(), r2);
+      if (!state->contents[hoid].data.contents_equal(r2)) {
+	dump_bl_mismatch(state->contents[hoid].data, r2);
+	assert(0 == "mismatch in OnReadable");
+        ASSERT_TRUE(state->contents[hoid].data.contents_equal(r2));
+      }
+      state->cond.Signal();
     }
   };
 
@@ -1123,6 +1725,7 @@ public:
 
     void finish(int r) {
       Mutex::Locker locker(state->lock);
+      EnterExit ee("clone finish");
       ASSERT_TRUE(state->in_flight_objects.count(oid));
       ASSERT_EQ(r, 0);
       state->in_flight_objects.erase(oid);
@@ -1134,7 +1737,8 @@ public:
       bufferlist r2;
       r = state->store->read(state->cid, noid, 0, state->contents[noid].data.length(), r2);
       if (!state->contents[noid].data.contents_equal(r2)) {
-        assert(state->contents[noid].data.contents_equal(r2));
+	dump_bl_mismatch(state->contents[noid].data, r2);
+	assert(0 == " mismatch after clone");
         ASSERT_TRUE(state->contents[noid].data.contents_equal(r2));
       }
       state->cond.Signal();
@@ -1160,8 +1764,10 @@ public:
 			 ObjectGenerator *gen,
 			 gen_type *rng,
 			 ObjectStore::Sequencer *osr,
-			 coll_t cid)
-    : cid(cid), in_flight(0), object_gen(gen), rng(rng), store(store), osr(osr),
+			 coll_t cid,
+			 unsigned max_size)
+    : cid(cid), max_object_len(max_size),
+      in_flight(0), object_gen(gen), rng(rng), store(store), osr(osr),
       lock("State lock") {}
 
   int init() {
@@ -1169,6 +1775,25 @@ public:
     t.create_collection(cid, 0);
     return store->apply_transaction(osr, t);
   }
+  void shutdown() {
+    while (1) {
+      vector<ghobject_t> objects;
+      int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+				     true, 10, &objects, 0);
+      assert(r >= 0);
+      if (objects.empty())
+	break;
+      ObjectStore::Transaction t;
+      for (vector<ghobject_t>::iterator p = objects.begin();
+	   p != objects.end(); ++p) {
+	t.remove(cid, *p);
+      }
+      store->apply_transaction(osr, t);
+    }
+    ObjectStore::Transaction t;
+    t.remove_collection(cid);
+    store->apply_transaction(osr, t);
+  }
 
   ghobject_t get_uniform_random_object() {
     while (in_flight >= max_in_flight || available_objects.empty())
@@ -1203,6 +1828,7 @@ public:
 
   int touch() {
     Mutex::Locker locker(lock);
+    EnterExit ee("touch");
     if (!can_create())
       return -ENOSPC;
     wait_for_ready();
@@ -1219,6 +1845,7 @@ public:
 
   int clone() {
     Mutex::Locker locker(lock);
+    EnterExit ee("clone");
     if (!can_unlink())
       return -ENOENT;
     if (!can_create())
@@ -1226,11 +1853,14 @@ public:
     wait_for_ready();
 
     ghobject_t old_obj;
+    int max = 20;
     do {
       old_obj = get_uniform_random_object();
-    } while (contents[old_obj].data.length());
+    } while (--max && !contents[old_obj].data.length());
     available_objects.erase(old_obj);
     ghobject_t new_obj = object_gen->create_object(rng);
+    // make the hash match
+    new_obj.hobj.set_hash(old_obj.hobj.get_hash());
     available_objects.erase(new_obj);
 
     ObjectStore::Transaction *t = new ObjectStore::Transaction;
@@ -1238,12 +1868,17 @@ public:
     ++in_flight;
     in_flight_objects.insert(old_obj);
 
-    contents[new_obj] = contents[old_obj];
+    // *copy* the data buffer, since we may modify it later.
+    contents[new_obj].attrs = contents[old_obj].attrs;
+    contents[new_obj].data.clear();
+    contents[new_obj].data.append(contents[old_obj].data.c_str(),
+				  contents[old_obj].data.length());
     return store->queue_transaction(osr, t, new C_SyntheticOnClone(this, t, old_obj, new_obj));
   }
 
   int setattrs() {
     Mutex::Locker locker(lock);
+    EnterExit ee("setattrs");
     if (!can_unlink())
       return -ENOENT;
     wait_for_ready();
@@ -1288,9 +1923,12 @@ public:
   }
 
   void getattrs() {
+    EnterExit ee("getattrs");
     ghobject_t obj;
+    map<string, bufferlist> expected;
     {
       Mutex::Locker locker(lock);
+      EnterExit ee("getattrs locked");
       if (!can_unlink())
         return ;
       wait_for_ready();
@@ -1301,23 +1939,27 @@ public:
         if (!--retry)
           return ;
       } while (contents[obj].attrs.empty());
+      expected = contents[obj].attrs;
     }
     map<string, bufferlist> attrs;
     int r = store->getattrs(cid, obj, attrs);
     ASSERT_TRUE(r == 0);
-    ASSERT_TRUE(attrs.size() == contents[obj].attrs.size());
-    for (map<string, bufferlist>::iterator it = contents[obj].attrs.begin();
-         it != contents[obj].attrs.end(); ++it) {
+    ASSERT_TRUE(attrs.size() == expected.size());
+    for (map<string, bufferlist>::iterator it = expected.begin();
+         it != expected.end(); ++it) {
       ASSERT_TRUE(it->second.contents_equal(attrs[it->first]));
     }
   }
 
   void getattr() {
+    EnterExit ee("getattr");
     ghobject_t obj;
     int r;
     int retry;
+    map<string, bufferlist> expected;
     {
       Mutex::Locker locker(lock);
+      EnterExit ee("getattr locked");
       if (!can_unlink())
         return ;
       wait_for_ready();
@@ -1328,10 +1970,11 @@ public:
         if (!--retry)
           return ;
       } while (contents[obj].attrs.empty());
+      expected = contents[obj].attrs;
     }
-    boost::uniform_int<> u(0, contents[obj].attrs.size()-1);
+    boost::uniform_int<> u(0, expected.size()-1);
     retry = u(*rng);
-    map<string, bufferlist>::iterator it = contents[obj].attrs.begin();
+    map<string, bufferlist>::iterator it = expected.begin();
     while (retry) {
       retry--;
       ++it;
@@ -1345,6 +1988,7 @@ public:
 
   int rmattr() {
     Mutex::Locker locker(lock);
+    EnterExit ee("rmattr");
     if (!can_unlink())
       return -ENOENT;
     wait_for_ready();
@@ -1377,6 +2021,7 @@ public:
 
   int write() {
     Mutex::Locker locker(lock);
+    EnterExit ee("write");
     if (!can_unlink())
       return -ENOENT;
     wait_for_ready();
@@ -1395,17 +2040,19 @@ public:
 
     filled_byte_array(bl, len);
 
-    if (contents[new_obj].data.length() <= offset) {
-      contents[new_obj].data.append_zero(offset-contents[new_obj].data.length());
-      contents[new_obj].data.append(bl);
+    bufferlist& data = contents[new_obj].data;
+    if (data.length() <= offset) {
+      data.append_zero(offset-data.length());
+      data.append(bl);
     } else {
       bufferlist value;
-      contents[new_obj].data.copy(0, offset, value);
+      assert(data.length() > offset);
+      data.copy(0, offset, value);
       value.append(bl);
-      if (value.length() < contents[new_obj].data.length())
-        contents[new_obj].data.copy(value.length(),
-                                    contents[new_obj].data.length()-value.length(), value);
-      value.swap(contents[new_obj].data);
+      if (value.length() < data.length())
+        data.copy(value.length(),
+		  data.length()-value.length(), value);
+      value.swap(data);
     }
 
     t->write(cid, new_obj, offset, len, bl);
@@ -1415,6 +2062,7 @@ public:
   }
 
   void read() {
+    EnterExit ee("read");
     boost::uniform_int<> u1(0, max_object_len/2);
     boost::uniform_int<> u2(0, max_object_len);
     uint64_t offset = u1(*rng);
@@ -1423,40 +2071,49 @@ public:
       swap(offset, len);
 
     ghobject_t obj;
+    bufferlist expected;
     int r;
     {
       Mutex::Locker locker(lock);
+      EnterExit ee("read locked");
       if (!can_unlink())
         return ;
       wait_for_ready();
 
       obj = get_uniform_random_object();
+      expected = contents[obj].data;
     }
     bufferlist bl, result;
+    if (0) cout << " obj " << obj
+	 << " size " << expected.length()
+	 << " offset " << offset
+	 << " len " << len << std::endl;
     r = store->read(cid, obj, offset, len, result);
-    if (offset >= contents[obj].data.length()) {
+    if (offset >= expected.length()) {
       ASSERT_EQ(r, 0);
     } else {
-      size_t max_len = contents[obj].data.length() - offset;
+      size_t max_len = expected.length() - offset;
       if (len > max_len)
         len = max_len;
       assert(len == result.length());
       ASSERT_EQ(len, result.length());
-      contents[obj].data.copy(offset, len, bl);
+      expected.copy(offset, len, bl);
       ASSERT_EQ(r, (int)len);
       if (!result.contents_equal(bl)) {
-	cout << "result:\n";
-	result.hexdump(cout);
-	cout << "expected:\n";
-	bl.hexdump(cout);
-	assert(0);
+	cout << " obj " << obj
+	 << " size " << expected.length()
+	 << " offset " << offset
+	 << " len " << len << std::endl;
+	dump_bl_mismatch(bl, result);
+	assert(0 == "mismatch after read");
+	ASSERT_TRUE(result.contents_equal(bl));
       }
-      ASSERT_TRUE(result.contents_equal(bl));
     }
   }
 
   int truncate() {
     Mutex::Locker locker(lock);
+    EnterExit ee("truncate");
     if (!can_unlink())
       return -ENOENT;
     wait_for_ready();
@@ -1472,11 +2129,12 @@ public:
     t->truncate(cid, obj, len);
     ++in_flight;
     in_flight_objects.insert(obj);
-    if (contents[obj].data.length() <= len)
-      contents[obj].data.append_zero(len - contents[obj].data.length());
+    bufferlist& data = contents[obj].data;
+    if (data.length() <= len)
+      data.append_zero(len - data.length());
     else {
-      contents[obj].data.copy(0, len, bl);
-      bl.swap(contents[obj].data);
+      data.copy(0, len, bl);
+      bl.swap(data);
     }
 
     return store->queue_transaction(osr, t, new C_SyntheticOnReadable(this, t, obj));
@@ -1484,13 +2142,14 @@ public:
 
   void scan() {
     Mutex::Locker locker(lock);
+    EnterExit ee("scan");
     while (in_flight)
       cond.Wait(lock);
     vector<ghobject_t> objects;
     set<ghobject_t, ghobject_t::BitwiseComparator> objects_set, objects_set2;
     ghobject_t next, current;
     while (1) {
-      cerr << "scanning..." << std::endl;
+      //cerr << "scanning..." << std::endl;
       int r = store->collection_list(cid, current, ghobject_t::get_max(),
 				     true, 100,
 				     &objects, &next);
@@ -1541,23 +2200,28 @@ public:
   }
 
   void stat() {
+    EnterExit ee("stat");
     ghobject_t hoid;
+    uint64_t expected;
     {
       Mutex::Locker locker(lock);
+      EnterExit ee("stat lock1");
       if (!can_unlink())
         return ;
       hoid = get_uniform_random_object();
       in_flight_objects.insert(hoid);
       available_objects.erase(hoid);
       ++in_flight;
+      expected = contents[hoid].data.length();
     }
     struct stat buf;
     int r = store->stat(cid, hoid, &buf);
     ASSERT_EQ(0, r);
-    assert(buf.st_size == contents[hoid].data.length());
-    ASSERT_TRUE(buf.st_size == contents[hoid].data.length());
+    assert((uint64_t)buf.st_size == expected);
+    ASSERT_TRUE((uint64_t)buf.st_size == expected);
     {
       Mutex::Locker locker(lock);
+      EnterExit ee("stat lock2");
       --in_flight;
       cond.Signal();
       in_flight_objects.erase(hoid);
@@ -1567,6 +2231,7 @@ public:
 
   int unlink() {
     Mutex::Locker locker(lock);
+    EnterExit ee("unlink");
     if (!can_unlink())
       return -ENOENT;
     ghobject_t to_remove = get_uniform_random_object();
@@ -1581,6 +2246,7 @@ public:
 
   int zero() {
     Mutex::Locker locker(lock);
+    EnterExit ee("zero");
     if (!can_unlink())
       return -ENOENT;
     wait_for_ready();
@@ -1622,14 +2288,14 @@ TEST_P(StoreTest, Synthetic) {
   gen_type rng(time(NULL));
   coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
 
-  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid);
+  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 400*1024);
   test_obj.init();
   for (int i = 0; i < 1000; ++i) {
-    if (!(i % 10)) cerr << "seeding object " << i << std::endl;
+    if (!(i % 500)) cerr << "seeding object " << i << std::endl;
     test_obj.touch();
   }
   for (int i = 0; i < 10000; ++i) {
-    if (!(i % 10)) {
+    if (!(i % 1000)) {
       cerr << "Op " << i << std::endl;
       test_obj.print_internal_state();
     }
@@ -1654,6 +2320,7 @@ TEST_P(StoreTest, Synthetic) {
     }
   }
   test_obj.wait_for_done();
+  test_obj.shutdown();
 }
 
 TEST_P(StoreTest, AttrSynthetic) {
@@ -1662,14 +2329,14 @@ TEST_P(StoreTest, AttrSynthetic) {
   gen_type rng(time(NULL));
   coll_t cid(spg_t(pg_t(0,447),shard_id_t::NO_SHARD));
 
-  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid);
+  SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 40*1024);
   test_obj.init();
   for (int i = 0; i < 500; ++i) {
     if (!(i % 10)) cerr << "seeding object " << i << std::endl;
     test_obj.touch();
   }
-  for (int i = 0; i < 10000; ++i) {
-    if (!(i % 10)) {
+  for (int i = 0; i < 1000; ++i) {
+    if (!(i % 100)) {
       cerr << "Op " << i << std::endl;
       test_obj.print_internal_state();
     }
@@ -1692,6 +2359,7 @@ TEST_P(StoreTest, AttrSynthetic) {
     }
   }
   test_obj.wait_for_done();
+  test_obj.shutdown();
 }
 
 TEST_P(StoreTest, HashCollisionTest) {
@@ -1714,7 +2382,7 @@ TEST_P(StoreTest, HashCollisionTest) {
   for (int i = 0; i < 1000; ++i) {
     char buf[100];
     sprintf(buf, "%d", i);
-    if (!(i % 5)) {
+    if (!(i % 100)) {
       cerr << "Object n" << n << " "<< i << std::endl;
     }
     ghobject_t hoid(hobject_t(string(buf) + base, string(), CEPH_NOSNAP, 0, poolid, string(nbuf)));
@@ -2387,6 +3055,42 @@ TEST_P(StoreTest, TwoHash) {
   ASSERT_EQ(r, 0);
 }
 
+TEST_P(StoreTest, Rename) {
+  ObjectStore::Sequencer osr("test");
+  coll_t cid(spg_t(pg_t(0, 2122),shard_id_t::NO_SHARD));
+  ghobject_t srcoid(hobject_t("src_oid", "", CEPH_NOSNAP, 0, 0, ""));
+  ghobject_t dstoid(hobject_t("dest_oid", "", CEPH_NOSNAP, 0, 0, ""));
+  bufferlist data;
+  data.append("foo");
+  int r;
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    t.write(cid, srcoid, 0, data.length(), data);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  ASSERT_TRUE(store->exists(cid, srcoid));
+  {
+    ObjectStore::Transaction t;
+    t.collection_move_rename(cid, srcoid, cid, dstoid);
+    t.write(cid, srcoid, 0, data.length(), data);
+    t.setattr(cid, srcoid, "attr", data);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+  ASSERT_TRUE(store->exists(cid, srcoid));
+  ASSERT_TRUE(store->exists(cid, dstoid));
+  {
+    ObjectStore::Transaction t;
+    t.remove(cid, dstoid);
+    t.remove(cid, srcoid);
+    t.remove_collection(cid);
+    r = store->apply_transaction(&osr, t);
+    ASSERT_EQ(r, 0);
+  }
+}
+
 TEST_P(StoreTest, MoveRename) {
   ObjectStore::Sequencer osr("test");
   coll_t cid(spg_t(pg_t(0, 212),shard_id_t::NO_SHARD));
@@ -2454,7 +3158,6 @@ TEST_P(StoreTest, MoveRename) {
 
 TEST_P(StoreTest, BigRGWObjectName) {
   ObjectStore::Sequencer osr("test");
-  store->set_allow_sharded_objects();
   coll_t cid(spg_t(pg_t(0,12),shard_id_t::NO_SHARD));
   ghobject_t oid(
     hobject_t(
@@ -2556,7 +3259,8 @@ INSTANTIATE_TEST_CASE_P(
     "memstore",
     "filestore",
     "keyvaluestore",
-    "newstore"));
+    "bluestore",
+    "kstore"));
 
 #else
 
@@ -2641,13 +3345,19 @@ int main(int argc, char **argv) {
   g_ceph_context->_conf->set_val("filestore_op_thread_suicide_timeout", "10000");
   g_ceph_context->_conf->set_val("filestore_debug_disable_sharded_check", "true");
   g_ceph_context->_conf->set_val("filestore_fiemap", "true");
+  g_ceph_context->_conf->set_val("bluestore_fsck_on_mount", "true");
+  g_ceph_context->_conf->set_val("bluestore_fsck_on_umount", "true");
+  g_ceph_context->_conf->set_val("bluestore_debug_misc", "true");
+  g_ceph_context->_conf->set_val("bluestore_debug_small_allocations", "4");
+  g_ceph_context->_conf->set_val("bluestore_debug_freelist", "true");
   g_ceph_context->_conf->set_val(
-    "enable_experimental_unrecoverable_data_corrupting_features",
-    "keyvaluestore, newstore, rocksdb");
+    "enable_experimental_unrecoverable_data_corrupting_features", "*");
   g_ceph_context->_conf->apply_changes(NULL);
 
   ::testing::InitGoogleTest(&argc, argv);
-  return RUN_ALL_TESTS();
+  int r = RUN_ALL_TESTS();
+  g_ceph_context->put();
+  return r;
 }
 
 /*
diff --git a/src/test/objectstore/test_bluefs.cc b/src/test/objectstore/test_bluefs.cc
new file mode 100644
index 0000000..b1f9013
--- /dev/null
+++ b/src/test/objectstore/test_bluefs.cc
@@ -0,0 +1,148 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+#include <time.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "global/global_init.h"
+#include "common/ceph_argparse.h"
+#include "include/stringify.h"
+#include "common/errno.h"
+#include <gtest/gtest.h>
+
+#include "os/bluestore/BlueFS.h"
+
+string get_temp_bdev(uint64_t size)
+{
+  static int n = 0;
+  string fn = "ceph_test_bluefs.tmp.block." + stringify(getpid())
+    + "." + stringify(++n);
+  int fd = ::open(fn.c_str(), O_CREAT|O_RDWR|O_TRUNC, 0644);
+  assert(fd >= 0);
+  int r = ::ftruncate(fd, size);
+  assert(r >= 0);
+  ::close(fd);
+  return fn;
+}
+
+void rm_temp_bdev(string f)
+{
+  ::unlink(f.c_str());
+}
+
+TEST(BlueFS, mkfs) {
+  uint64_t size = 1048476 * 128;
+  string fn = get_temp_bdev(size);
+  uuid_d fsid;
+  BlueFS fs;
+  fs.add_block_device(0, fn);
+  fs.add_block_extent(0, 1048576, size - 1048576);
+  fs.mkfs(fsid);
+  rm_temp_bdev(fn);
+}
+
+TEST(BlueFS, mkfs_mount) {
+  uint64_t size = 1048476 * 128;
+  string fn = get_temp_bdev(size);
+  BlueFS fs;
+  ASSERT_EQ(0, fs.add_block_device(0, fn));
+  fs.add_block_extent(0, 1048576, size - 1048576);
+  uuid_d fsid;
+  ASSERT_EQ(0, fs.mkfs(fsid));
+  ASSERT_EQ(0, fs.mount());
+  ASSERT_EQ(fs.get_total(0), size - 1048576);
+  ASSERT_LT(fs.get_free(0), size - 1048576);
+  fs.umount();
+  rm_temp_bdev(fn);
+}
+
+TEST(BlueFS, write_read) {
+  uint64_t size = 1048476 * 128;
+  string fn = get_temp_bdev(size);
+  BlueFS fs;
+  ASSERT_EQ(0, fs.add_block_device(0, fn));
+  fs.add_block_extent(0, 1048576, size - 1048576);
+  uuid_d fsid;
+  ASSERT_EQ(0, fs.mkfs(fsid));
+  ASSERT_EQ(0, fs.mount());
+  {
+    BlueFS::FileWriter *h;
+    ASSERT_EQ(0, fs.mkdir("dir"));
+    ASSERT_EQ(0, fs.open_for_write("dir", "file", &h, false));
+    bufferlist bl;
+    bl.append("foo");
+    h->append(bl);
+    bl.append("bar");
+    h->append(bl);
+    bl.append("baz");
+    h->append(bl);
+    fs.fsync(h);
+    fs.close_writer(h);
+  }
+  {
+    BlueFS::FileReader *h;
+    ASSERT_EQ(0, fs.open_for_read("dir", "file", &h));
+    bufferlist bl;
+    BlueFS::FileReaderBuffer buf(4096);
+    ASSERT_EQ(9, fs.read(h, &buf, 0, 1024, &bl, NULL));
+    ASSERT_EQ(0, strncmp("foobarbaz", bl.c_str(), 9));
+    delete h;
+  }
+  fs.umount();
+  rm_temp_bdev(fn);
+}
+
+TEST(BlueFS, small_appends) {
+  uint64_t size = 1048476 * 128;
+  string fn = get_temp_bdev(size);
+  BlueFS fs;
+  ASSERT_EQ(0, fs.add_block_device(0, fn));
+  fs.add_block_extent(0, 1048576, size - 1048576);
+  uuid_d fsid;
+  ASSERT_EQ(0, fs.mkfs(fsid));
+  ASSERT_EQ(0, fs.mount());
+  {
+    BlueFS::FileWriter *h;
+    ASSERT_EQ(0, fs.mkdir("dir"));
+    ASSERT_EQ(0, fs.open_for_write("dir", "file", &h, false));
+    for (unsigned i = 0; i < 10000; ++i) {
+      bufferlist bl;
+      bl.append("fddjdjdjdjdjdjdjdjdjdjjddjoo");
+      h->append(bl);
+    }
+    fs.fsync(h);
+    fs.close_writer(h);
+  }
+  {
+    BlueFS::FileWriter *h;
+    ASSERT_EQ(0, fs.open_for_write("dir", "file_sync", &h, false));
+    for (unsigned i = 0; i < 1000; ++i) {
+      bufferlist bl;
+      bl.append("fddjdjdjdjdjdjdjdjdjdjjddjoo");
+      h->append(bl);
+      fs.fsync(h);
+    }
+    fs.close_writer(h);
+  }
+  fs.umount();
+  rm_temp_bdev(fn);
+}
+
+int main(int argc, char **argv) {
+  vector<const char*> args;
+  argv_to_vec(argc, (const char **)argv, args);
+  env_to_vec(args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+  g_ceph_context->_conf->set_val(
+    "enable_experimental_unrecoverable_data_corrupting_features",
+    "*");
+  g_ceph_context->_conf->apply_changes(NULL);
+
+  ::testing::InitGoogleTest(&argc, argv);
+  return RUN_ALL_TESTS();
+}
diff --git a/src/test/objectstore/test_bluestore_types.cc b/src/test/objectstore/test_bluestore_types.cc
new file mode 100644
index 0000000..bfe46d4
--- /dev/null
+++ b/src/test/objectstore/test_bluestore_types.cc
@@ -0,0 +1,157 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "include/types.h"
+#include "os/bluestore/bluestore_types.h"
+#include "gtest/gtest.h"
+#include "include/stringify.h"
+
+#include <sstream>
+
+TEST(bluestore_extent_ref_map_t, add)
+{
+  bluestore_extent_ref_map_t m;
+  m.add(10, 10);
+  ASSERT_EQ(1u, m.ref_map.size());
+  cout << m << std::endl;
+  m.add(20, 10);
+  cout << m << std::endl;
+  ASSERT_EQ(1u, m.ref_map.size());
+  ASSERT_EQ(20u, m.ref_map[10].length);
+  ASSERT_EQ(2u, m.ref_map[10].refs);
+  m.add(40, 10);
+  cout << m << std::endl;
+  ASSERT_EQ(2u, m.ref_map.size());
+  m.add(30, 10);
+  cout << m << std::endl;
+  ASSERT_EQ(1u, m.ref_map.size());
+  m.add(50, 10, 3);
+  cout << m << std::endl;
+  ASSERT_EQ(2u, m.ref_map.size());
+}
+
+TEST(bluestore_extent_ref_map_t, get)
+{
+  bluestore_extent_ref_map_t m;
+  m.add(00, 30);
+  cout << m << std::endl;
+  m.get(10, 10);
+  cout << m << std::endl;
+  ASSERT_EQ(3u, m.ref_map.size());
+  ASSERT_EQ(10u, m.ref_map[0].length);
+  ASSERT_EQ(2u, m.ref_map[0].refs);
+  ASSERT_EQ(10u, m.ref_map[10].length);
+  ASSERT_EQ(3u, m.ref_map[10].refs);
+  ASSERT_EQ(10u, m.ref_map[20].length);
+  ASSERT_EQ(2u, m.ref_map[20].refs);
+  m.get(20, 5);
+  cout << m << std::endl;
+  ASSERT_EQ(3u, m.ref_map.size());
+  ASSERT_EQ(15u, m.ref_map[10].length);
+  ASSERT_EQ(3u, m.ref_map[10].refs);
+  ASSERT_EQ(5u, m.ref_map[25].length);
+  ASSERT_EQ(2u, m.ref_map[25].refs);
+  m.get(5, 20);
+  cout << m << std::endl;
+  ASSERT_EQ(4u, m.ref_map.size());
+  ASSERT_EQ(5u, m.ref_map[0].length);
+  ASSERT_EQ(2u, m.ref_map[0].refs);
+  ASSERT_EQ(5u, m.ref_map[5].length);
+  ASSERT_EQ(3u, m.ref_map[5].refs);
+  ASSERT_EQ(15u, m.ref_map[10].length);
+  ASSERT_EQ(4u, m.ref_map[10].refs);
+  ASSERT_EQ(5u, m.ref_map[25].length);
+  ASSERT_EQ(2u, m.ref_map[25].refs);
+  m.get(25, 3);
+  cout << m << std::endl;
+  ASSERT_EQ(5u, m.ref_map.size());
+  ASSERT_EQ(5u, m.ref_map[0].length);
+  ASSERT_EQ(2u, m.ref_map[0].refs);
+  ASSERT_EQ(5u, m.ref_map[5].length);
+  ASSERT_EQ(3u, m.ref_map[5].refs);
+  ASSERT_EQ(15u, m.ref_map[10].length);
+  ASSERT_EQ(4u, m.ref_map[10].refs);
+  ASSERT_EQ(3u, m.ref_map[25].length);
+  ASSERT_EQ(3u, m.ref_map[25].refs);
+  ASSERT_EQ(2u, m.ref_map[28].length);
+  ASSERT_EQ(2u, m.ref_map[28].refs);
+}
+
+TEST(bluestore_extent_ref_map_t, put)
+{
+  bluestore_extent_ref_map_t m;
+  vector<bluestore_extent_t> r;
+  m.add(10, 30, 1);
+  m.put(10, 30, &r);
+  cout << m << " " << r << std::endl;
+  ASSERT_EQ(0u, m.ref_map.size());
+  ASSERT_EQ(1u, r.size());
+  ASSERT_EQ(10u, r[0].offset);
+  ASSERT_EQ(30u, r[0].length);
+  r.clear();
+  m.add(10, 30, 1);
+  m.get(20, 10);
+  m.put(10, 30, &r);
+  cout << m << " " << r << std::endl;
+  ASSERT_EQ(1u, m.ref_map.size());
+  ASSERT_EQ(10u, m.ref_map[20].length);
+  ASSERT_EQ(1u, m.ref_map[20].refs);
+  ASSERT_EQ(2u, r.size());
+  ASSERT_EQ(10u, r[0].offset);
+  ASSERT_EQ(10u, r[0].length);
+  ASSERT_EQ(30u, r[1].offset);
+  ASSERT_EQ(10u, r[1].length);
+  r.clear();
+  m.add(30, 10);
+  m.put(20, 15, &r);
+  cout << m << " " << r << std::endl;
+  ASSERT_EQ(2u, m.ref_map.size());
+  ASSERT_EQ(5u, m.ref_map[30].length);
+  ASSERT_EQ(1u, m.ref_map[30].refs);
+  ASSERT_EQ(5u, m.ref_map[35].length);
+  ASSERT_EQ(2u, m.ref_map[35].refs);
+  ASSERT_EQ(1u, r.size());
+  ASSERT_EQ(20u, r[0].offset);
+  ASSERT_EQ(10u, r[0].length);
+  r.clear();
+  m.put(33, 5, &r);
+  cout << m << " " << r << std::endl;
+  ASSERT_EQ(3u, m.ref_map.size());
+  ASSERT_EQ(3u, m.ref_map[30].length);
+  ASSERT_EQ(1u, m.ref_map[30].refs);
+  ASSERT_EQ(3u, m.ref_map[35].length);
+  ASSERT_EQ(1u, m.ref_map[35].refs);
+  ASSERT_EQ(2u, m.ref_map[38].length);
+  ASSERT_EQ(2u, m.ref_map[38].refs);
+  ASSERT_EQ(1u, r.size());
+  ASSERT_EQ(33u, r[0].offset);
+  ASSERT_EQ(2u, r[0].length);
+}
+
+TEST(bluestore_extent_ref_map_t, contains)
+{
+  bluestore_extent_ref_map_t m;
+  m.add(10, 30, 1);
+  ASSERT_TRUE(m.contains(10, 30));
+  ASSERT_TRUE(m.contains(10, 10));
+  ASSERT_TRUE(m.contains(30, 10));
+  ASSERT_FALSE(m.contains(0, 10));
+  ASSERT_FALSE(m.contains(0, 20));
+  ASSERT_FALSE(m.contains(0, 100));
+  ASSERT_FALSE(m.contains(40, 10));
+  ASSERT_FALSE(m.contains(30, 11));
+  m.add(40, 10, 2);
+  ASSERT_TRUE(m.contains(30, 11));
+  ASSERT_TRUE(m.contains(30, 20));
+  ASSERT_TRUE(m.contains(10, 40));
+  ASSERT_FALSE(m.contains(0, 50));
+  ASSERT_FALSE(m.contains(40, 20));
+  m.add(60, 100);
+  ASSERT_TRUE(m.contains(60, 10));
+  ASSERT_TRUE(m.contains(40, 10));
+  ASSERT_FALSE(m.contains(40, 11));
+  ASSERT_FALSE(m.contains(40, 20));
+  ASSERT_FALSE(m.contains(40, 30));
+  ASSERT_FALSE(m.contains(40, 3000));
+  ASSERT_FALSE(m.contains(4000, 30));
+}
diff --git a/src/test/objectstore/test_idempotent.cc b/src/test/objectstore/test_idempotent.cc
index d52f7db..8c663a6 100644
--- a/src/test/objectstore/test_idempotent.cc
+++ b/src/test/objectstore/test_idempotent.cc
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <sstream>
 #include <boost/scoped_ptr.hpp>
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "global/global_init.h"
 #include "common/ceph_argparse.h"
 #include "common/debug.h"
diff --git a/src/test/objectstore/test_idempotent_sequence.cc b/src/test/objectstore/test_idempotent_sequence.cc
index 95bf196..75ebc33 100644
--- a/src/test/objectstore/test_idempotent_sequence.cc
+++ b/src/test/objectstore/test_idempotent_sequence.cc
@@ -19,7 +19,7 @@
 #include "common/ceph_argparse.h"
 #include "global/global_init.h"
 #include "common/debug.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 
 #include "DeterministicOpSequence.h"
 #include "FileStoreDiff.h"
diff --git a/src/test/opensuse-13.2/ceph.spec.in b/src/test/opensuse-13.2/ceph.spec.in
index 52c5c1d..487232c 100644
--- a/src/test/opensuse-13.2/ceph.spec.in
+++ b/src/test/opensuse-13.2/ceph.spec.in
@@ -1,4 +1,19 @@
 # vim: set noexpandtab ts=8 sw=8 :
+#
+# spec file for package ceph
+#
+# Copyright (C) 2004-2016 The Ceph Project Developers. See COPYING file
+# at the top-level directory of this distribution and at
+# https://github.com/ceph/ceph/blob/master/COPYING
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon.
+#
+# This file is under the GNU Lesser General Public License, version 2.1
+#
+# Please submit bugfixes or comments via http://tracker.ceph.com/
+# 
 %bcond_with ocf
 %bcond_without cephfs_java
 %bcond_with tests
@@ -133,6 +148,7 @@ BuildRequires:	python-requests
 BuildRequires:	python-virtualenv
 BuildRequires:	snappy-devel
 BuildRequires:	util-linux
+BuildRequires:	valgrind-devel
 BuildRequires:	xfsprogs
 BuildRequires:	xfsprogs-devel
 BuildRequires:	xmlstarlet
@@ -168,7 +184,6 @@ BuildRequires:	libatomic-ops-devel
 %if 0%{?_with_systemd}
 Requires:	systemd
 %endif
-BuildRequires:  bzip2-devel
 BuildRequires:	nss-devel
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	libatomic_ops-devel
@@ -790,6 +805,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_bindir}/ceph-mon
 %{_bindir}/ceph-mds
 %{_bindir}/ceph-objectstore-tool
+%{_bindir}/ceph-bluefs-tool
 %{_bindir}/ceph-osd
 %{_bindir}/ceph-detect-init
 %{_bindir}/librados-config
@@ -844,6 +860,8 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/rados-classes/libcls_journal.so*
 %dir %{_libdir}/ceph/erasure-code
 %{_libdir}/ceph/erasure-code/libec_*.so*
+%dir %{_libdir}/ceph/compressor
+%{_libdir}/ceph/compressor/libceph_*.so*
 %if 0%{?_with_lttng}
 %{_libdir}/libos_tp.so*
 %{_libdir}/libosd_tp.so*
@@ -1179,6 +1197,7 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %files -n python-cephfs
 %defattr(-,root,root,-)
 %{python_sitelib}/cephfs.py*
+%{python_sitelib}/ceph_volume_client.py*
 
 #################################################################################
 %files -n ceph-test
@@ -1204,7 +1223,6 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1
 %{_bindir}/ceph_smalliobenchdumb
 %{_bindir}/ceph_smalliobenchfs
 %{_bindir}/ceph_smalliobenchrbd
-%{_bindir}/ceph_streamtest
 %{_bindir}/ceph_test_*
 %{_bindir}/ceph_tpbench
 %{_bindir}/ceph_xattr_bench
diff --git a/src/test/os/TestLFNIndex.cc b/src/test/os/TestLFNIndex.cc
index 5e44355..ad4cb75 100644
--- a/src/test/os/TestLFNIndex.cc
+++ b/src/test/os/TestLFNIndex.cc
@@ -21,8 +21,8 @@
 
 #include <stdio.h>
 #include <signal.h>
-#include "os/LFNIndex.h"
-#include "os/chain_xattr.h"
+#include "os/filestore/LFNIndex.h"
+#include "os/filestore/chain_xattr.h"
 #include "common/ceph_argparse.h"
 #include "global/global_init.h"
 #include <gtest/gtest.h>
diff --git a/src/test/osd/Object.cc b/src/test/osd/Object.cc
index 4f791cd..6990053 100644
--- a/src/test/osd/Object.cc
+++ b/src/test/osd/Object.cc
@@ -210,9 +210,14 @@ bool ObjectDesc::check_sparse(const std::map<uint64_t, uint64_t>& extents,
   }
   uint64_t size = layers.empty() ? 0 :
     most_recent_gen()->get_length(most_recent());
-  if (pos != size) {
-    std::cout << "only read " << pos << " out of size " << size << std::endl;
-    return false;
+  while (pos < size) {
+    if (*i != '\0') {
+      std::cout << "sparse read omitted non-zero data at " << pos << std::endl;
+      return false;
+    }
+    ++i;
+    ++pos;
   }
+  assert(pos == size);
   return true;
 }
diff --git a/src/test/osd/TestPGLog.cc b/src/test/osd/TestPGLog.cc
index e928cea..a7f074e 100644
--- a/src/test/osd/TestPGLog.cc
+++ b/src/test/osd/TestPGLog.cc
@@ -291,9 +291,8 @@ TEST_F(PGLogTest, rewind_divergent_log) {
 
     log.tail = eversion_t(2, 1);
     TestHandler h(remove_snap);
-    EXPECT_THROW(rewind_divergent_log(t, eversion_t(1, 1), info, &h,
-				      dirty_info, dirty_big_info),
-		 FailedAssertion);
+    EXPECT_DEATH(rewind_divergent_log(t, eversion_t(1, 1), info, &h,
+				      dirty_info, dirty_big_info), "");
   }
 
   /*        +----------------+
@@ -1234,8 +1233,8 @@ TEST_F(PGLogTest, merge_log) {
     olog.tail = eversion_t(1, 1);
 
     TestHandler h(remove_snap);
-    ASSERT_THROW(merge_log(t, oinfo, olog, fromosd, info, &h,
-                           dirty_info, dirty_big_info), FailedAssertion);
+    ASSERT_DEATH(merge_log(t, oinfo, olog, fromosd, info, &h,
+			   dirty_info, dirty_big_info), "");
   }
 
   /*        +--------------------------+
@@ -1298,8 +1297,8 @@ TEST_F(PGLogTest, merge_log) {
     }
 
     TestHandler h(remove_snap);
-    EXPECT_THROW(merge_log(t, oinfo, olog, fromosd, info, &h,
-                           dirty_info, dirty_big_info), FailedAssertion);
+    EXPECT_DEATH(merge_log(t, oinfo, olog, fromosd, info, &h,
+			   dirty_info, dirty_big_info), "");
   }
 }
 
diff --git a/src/test/osd/osd-markdown.sh b/src/test/osd/osd-markdown.sh
new file mode 100755
index 0000000..4dfa78d
--- /dev/null
+++ b/src/test/osd/osd-markdown.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+#
+# Copyright (C) 2015 Intel <contact at intel.com.com>
+# Copyright (C) 2014, 2015 Red Hat <contact at redhat.com>
+#
+# Author: Xiaoxi Chen <xiaoxi.chen at intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+
+source ../qa/workunits/ceph-helpers.sh
+
+function run() {
+    local dir=$1
+    shift
+
+    export CEPH_MON="127.0.0.1:7108" # git grep '\<7108\>' : there must be only one
+    export CEPH_ARGS
+    CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
+    CEPH_ARGS+="--mon-host=$CEPH_MON "
+
+    local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    for func in $funcs ; do
+        setup $dir || return 1
+        $func $dir || return 1
+        teardown $dir || return 1
+    done
+}
+
+function markdown_N_impl() {
+  markdown_times=$1
+  total_time=$2
+  interval=$(($total_time / markdown_times))
+  sleep 10
+  for i in `seq 1 $markdown_times`
+  do
+    # check the OSD is UP
+    ./ceph osd tree
+    ./ceph osd tree | grep osd.0 |grep up || return 1
+    # mark the OSD down.
+    ./ceph osd down 0
+    sleep $interval
+  done
+}
+
+
+function TEST_markdown_exceed_maxdown_count() {
+    local dir=$1
+
+    run_mon $dir a || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    run_osd $dir 2 || return 1
+    local count=5
+    local period=40
+    ceph tell osd.0 injectargs '--osd_max_markdown_count '$count'' || return 1
+    ceph tell osd.0 injectargs '--osd_max_markdown_period '$period'' || return 1
+
+    markdown_N_impl $(($count+1)) $period
+    # down N+1 times ,the osd.0 shoud die
+    ./ceph osd tree | grep down | grep osd.0 || return 1
+}
+
+function TEST_markdown_boot() {
+    local dir=$1
+
+    run_mon $dir a || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    run_osd $dir 2 || return 1
+
+    local count=5
+    local period=40
+    ceph tell osd.0 injectargs '--osd_max_markdown_count '$count'' || return 1
+    ceph tell osd.0 injectargs '--osd_max_markdown_period '$period'' || return 1
+
+    markdown_N_impl $count $period
+    #down N times, osd.0 should be up
+    ./ceph osd tree | grep up | grep osd.0 || return 1
+}
+
+function TEST_markdown_boot_exceed_time() {
+    local dir=$1
+
+    run_mon $dir a || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    run_osd $dir 2 || return 1
+
+    local count=5
+    local period=40
+    ceph tell osd.0 injectargs '--osd_max_markdown_count '$count'' || return 1
+    ceph tell osd.0 injectargs '--osd_max_markdown_period '$period'' || return 1
+
+    #actually we will down 6 times in 60s, so the 5th down will be in 50s > period
+    markdown_N_impl $(($count+1)) $(($period + 20))
+    ./ceph osd tree | grep up | grep osd.0 || return 1
+}
+
+main osd-markdown "$@"
+
+# Local Variables:
+# compile-command: "cd ../.. ; make -j4 && test/osd/osd-bench.sh"
+# End:
diff --git a/src/test/osd/osd-reuse-id.sh b/src/test/osd/osd-reuse-id.sh
new file mode 100755
index 0000000..8efdf5c
--- /dev/null
+++ b/src/test/osd/osd-reuse-id.sh
@@ -0,0 +1,51 @@
+#! /bin/bash
+#
+# Copyright (C) 2015 Red Hat <contact at redhat.com>
+#
+# Author: Loic Dachary <loic at dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+source ../qa/workunits/ceph-helpers.sh
+
+function run() {
+    local dir=$1
+    shift
+
+    export CEPH_MON="127.0.0.1:7123" # git grep '\<7123\>' : there must be only one
+    export CEPH_ARGS
+    CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
+    CEPH_ARGS+="--mon-host=$CEPH_MON "
+
+    local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    for func in $funcs ; do
+        $func $dir || return 1
+    done
+}
+
+function TEST_reuse_id() {
+    local dir=$1
+
+    setup $dir || return 1
+    run_mon $dir a --osd_pool_default_size=1 || return 1
+    run_osd $dir 0 || return 1
+    run_osd $dir 1 || return 1
+    wait_for_clean || return 1
+    destroy_osd $dir 1 || return 1
+    run_osd $dir 1 || return 1
+}
+
+main osd-reuse-id "$@"
+
+# Local Variables:
+# compile-command: "cd ../.. ; make -j4 && test/osd/osd-reuse-id.sh"
+# End:
+
diff --git a/src/test/osd/osd-scrub-repair.sh b/src/test/osd/osd-scrub-repair.sh
index 2b22ab9..06d7b6b 100755
--- a/src/test/osd/osd-scrub-repair.sh
+++ b/src/test/osd/osd-scrub-repair.sh
@@ -34,6 +34,7 @@ function run() {
 function add_something() {
     local dir=$1
     local poolname=$2
+    local obj=${3:-SOMETHING}
 
     wait_for_clean || return 1
 
@@ -42,7 +43,7 @@ function add_something() {
 
     local payload=ABCDEF
     echo $payload > $dir/ORIGINAL
-    rados --pool $poolname put SOMETHING $dir/ORIGINAL || return 1
+    rados --pool $poolname put $obj $dir/ORIGINAL || return 1
 }
 
 #
@@ -274,6 +275,56 @@ function TEST_unfound_erasure_coded() {
     teardown $dir || return 1
 }
 
+#
+# list_missing for EC pool
+#
+function TEST_list_missing_erasure_coded() {
+    local dir=$1
+    local poolname=ecpool
+    local profile=myprofile
+
+    setup $dir || return 1
+    run_mon $dir a || return 1
+    for id in $(seq 0 2) ; do
+        run_osd $dir $id || return 1
+    done
+    wait_for_clean || return 1
+
+    ceph osd erasure-code-profile set $profile \
+        k=2 m=1 ruleset-failure-domain=osd || return 1
+    ceph osd pool create $poolname 1 1 erasure $profile \
+        || return 1
+    wait_for_clean || return 1
+
+    # Put an object and remove the two shards (including primary)
+    add_something $dir $poolname OBJ0 || return 1
+    local -a osds=($(get_osds $poolname OBJ0))
+    objectstore_tool $dir ${osds[0]} OBJ0 remove || return 1
+    objectstore_tool $dir ${osds[1]} OBJ0 remove || return 1
+
+    # Put another object and remove two shards (excluding primary)
+    add_something $dir $poolname OBJ1 || return 1
+    local -a osds=($(get_osds $poolname OBJ1))
+    objectstore_tool $dir ${osds[1]} OBJ1 remove || return 1
+    objectstore_tool $dir ${osds[2]} OBJ1 remove || return 1
+
+    # Get get - both objects should in the same PG
+    local pg=$(get_pg $poolname OBJ0)
+
+    # Repair the PG, which triggers the recovering,
+    # and should mark the object as unfound
+    ceph pg repair $pg
+    
+    for i in $(seq 0 120) ; do
+        [ $i -lt 60 ] || return 1
+        matches=$(ceph pg $pg list_missing | egrep "OBJ0|OBJ1" | wc -l)
+        [ $matches -eq 2 ] && break
+    done
+
+    teardown $dir || return 1
+}
+
+
 main osd-scrub-repair "$@"
 
 # Local Variables:
diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc
index 1652ac5..67d6ac8 100644
--- a/src/test/osd/types.cc
+++ b/src/test/osd/types.cc
@@ -907,7 +907,7 @@ TEST(pg_missing_t, add_next_event)
     e.op = pg_log_entry_t::BACKLOG;
     EXPECT_TRUE(e.is_backlog());
     EXPECT_FALSE(missing.is_missing(oid));
-    EXPECT_THROW(missing.add_next_event(e), FailedAssertion);
+    EXPECT_DEATH(missing.add_next_event(e), "");
   }
 
   // adding a DELETE matching an existing event
@@ -1020,14 +1020,14 @@ TEST(pg_missing_t, got)
     hobject_t oid(object_t("objname"), "key", 123, 456, 0, "");
     pg_missing_t missing;
     // assert if the oid does not exist
-    EXPECT_THROW(missing.got(oid, eversion_t()), FailedAssertion);
+    EXPECT_DEATH(missing.got(oid, eversion_t()), "");
     EXPECT_FALSE(missing.is_missing(oid));
     epoch_t epoch = 10;
     eversion_t need(epoch,10);
     missing.add(oid, need, eversion_t());
     EXPECT_TRUE(missing.is_missing(oid));
     // assert if that the version to be removed is lower than the version of the object
-    EXPECT_THROW(missing.got(oid, eversion_t(epoch / 2,20)), FailedAssertion);
+    EXPECT_DEATH(missing.got(oid, eversion_t(epoch / 2,20)), "");
     // remove of a later version removes the object
     missing.got(oid, eversion_t(epoch * 2,20));
     EXPECT_FALSE(missing.is_missing(oid));
@@ -1161,7 +1161,7 @@ TEST_F(ObjectContextTest, read_write_lock)
     EXPECT_EQ(1, obc.unstable_writes);
 
     Thread_read_lock t(obc);
-    t.create();
+    t.create("obc_read");
 
     do {
       cout << "Trying (1) with delay " << delay << "us\n";
@@ -1218,7 +1218,7 @@ TEST_F(ObjectContextTest, read_write_lock)
     EXPECT_EQ(0, obc.unstable_writes);
 
     Thread_write_lock t(obc);
-    t.create();
+    t.create("obc_write");
 
     do {
       cout << "Trying (3) with delay " << delay << "us\n";
@@ -1372,6 +1372,25 @@ TEST(coll_t, temp) {
   ASSERT_EQ(pgid, pgid2);
 }
 
+TEST(coll_t, assigment) {
+  spg_t pgid;
+  coll_t right(pgid);
+  ASSERT_EQ(right.to_str(), string("0.0_head"));
+
+  coll_t left, middle;
+
+  ASSERT_EQ(left.to_str(), string("meta"));
+  ASSERT_EQ(middle.to_str(), string("meta"));
+
+  left = middle = right;
+
+  ASSERT_EQ(left.to_str(), string("0.0_head"));
+  ASSERT_EQ(middle.to_str(), string("0.0_head"));
+  
+  ASSERT_NE(middle.c_str(), right.c_str());
+  ASSERT_NE(left.c_str(), middle.c_str());
+}
+
 TEST(ghobject_t, cmp) {
   ghobject_t min;
   ghobject_t sep;
@@ -1390,7 +1409,7 @@ TEST(ghobject_t, cmp) {
 
 TEST(pool_opts_t, invalid_opt) {
   EXPECT_FALSE(pool_opts_t::is_opt_name("INVALID_OPT"));
-  EXPECT_THROW(pool_opts_t::get_opt_desc("INVALID_OPT"), FailedAssertion);
+  EXPECT_DEATH(pool_opts_t::get_opt_desc("INVALID_OPT"), "");
 }
 
 TEST(pool_opts_t, scrub_min_interval) {
@@ -1401,7 +1420,7 @@ TEST(pool_opts_t, scrub_min_interval) {
 
   pool_opts_t opts;
   EXPECT_FALSE(opts.is_set(pool_opts_t::SCRUB_MIN_INTERVAL));
-  EXPECT_THROW(opts.get(pool_opts_t::SCRUB_MIN_INTERVAL), FailedAssertion);
+  EXPECT_DEATH(opts.get(pool_opts_t::SCRUB_MIN_INTERVAL), "");
   double val;
   EXPECT_FALSE(opts.get(pool_opts_t::SCRUB_MIN_INTERVAL, &val));
   opts.set(pool_opts_t::SCRUB_MIN_INTERVAL, static_cast<double>(2015));
@@ -1419,7 +1438,7 @@ TEST(pool_opts_t, scrub_max_interval) {
 
   pool_opts_t opts;
   EXPECT_FALSE(opts.is_set(pool_opts_t::SCRUB_MAX_INTERVAL));
-  EXPECT_THROW(opts.get(pool_opts_t::SCRUB_MAX_INTERVAL), FailedAssertion);
+  EXPECT_DEATH(opts.get(pool_opts_t::SCRUB_MAX_INTERVAL), "");
   double val;
   EXPECT_FALSE(opts.get(pool_opts_t::SCRUB_MAX_INTERVAL, &val));
   opts.set(pool_opts_t::SCRUB_MAX_INTERVAL, static_cast<double>(2015));
@@ -1437,7 +1456,7 @@ TEST(pool_opts_t, deep_scrub_interval) {
 
   pool_opts_t opts;
   EXPECT_FALSE(opts.is_set(pool_opts_t::DEEP_SCRUB_INTERVAL));
-  EXPECT_THROW(opts.get(pool_opts_t::DEEP_SCRUB_INTERVAL), FailedAssertion);
+  EXPECT_DEATH(opts.get(pool_opts_t::DEEP_SCRUB_INTERVAL), "");
   double val;
   EXPECT_FALSE(opts.get(pool_opts_t::DEEP_SCRUB_INTERVAL, &val));
   opts.set(pool_opts_t::DEEP_SCRUB_INTERVAL, static_cast<double>(2015));
diff --git a/src/test/osdc/FakeWriteback.cc b/src/test/osdc/FakeWriteback.cc
index 32ae4f5..5ba05d3 100644
--- a/src/test/osdc/FakeWriteback.cc
+++ b/src/test/osdc/FakeWriteback.cc
@@ -4,12 +4,13 @@
 #include <errno.h>
 #include <time.h>
 
+#include <thread>
 #include "common/debug.h"
 #include "common/Cond.h"
 #include "common/Finisher.h"
 #include "common/Mutex.h"
 #include "include/assert.h"
-#include "include/utime.h"
+#include "common/ceph_time.h"
 
 #include "FakeWriteback.h"
 
@@ -20,7 +21,7 @@
 class C_Delay : public Context {
   CephContext *m_cct;
   Context *m_con;
-  utime_t m_delay;
+  ceph::timespan m_delay;
   Mutex *m_lock;
   bufferlist *m_bl;
   uint64_t m_off;
@@ -28,11 +29,10 @@ class C_Delay : public Context {
 public:
   C_Delay(CephContext *cct, Context *c, Mutex *lock, uint64_t off,
 	  bufferlist *pbl, uint64_t delay_ns=0)
-    : m_cct(cct), m_con(c), m_delay(0, delay_ns), m_lock(lock), m_bl(pbl), m_off(off) {}
+    : m_cct(cct), m_con(c), m_delay(delay_ns * std::chrono::nanoseconds(1)),
+      m_lock(lock), m_bl(pbl), m_off(off) {}
   void finish(int r) {
-    struct timespec delay;
-    m_delay.to_timespec(&delay);
-    nanosleep(&delay, NULL);
+    std::this_thread::sleep_for(m_delay);
     if (m_bl) {
       buffer::ptr bp(r);
       bp.zero();
@@ -64,24 +64,27 @@ void FakeWriteback::read(const object_t& oid, uint64_t object_no,
 			 bufferlist *pbl, uint64_t trunc_size,
 			 __u32 trunc_seq, int op_flags, Context *onfinish)
 {
-  C_Delay *wrapper = new C_Delay(m_cct, onfinish, m_lock, off, pbl, m_delay_ns);
+  C_Delay *wrapper = new C_Delay(m_cct, onfinish, m_lock, off, pbl,
+				 m_delay_ns);
   m_finisher->queue(wrapper, len);
 }
 
 ceph_tid_t FakeWriteback::write(const object_t& oid,
-			   const object_locator_t& oloc,
-			   uint64_t off, uint64_t len,
-			   const SnapContext& snapc,
-			   const bufferlist &bl, utime_t mtime,
-			   uint64_t trunc_size, __u32 trunc_seq,
-			   ceph_tid_t journal_tid, Context *oncommit)
+				const object_locator_t& oloc,
+				uint64_t off, uint64_t len,
+				const SnapContext& snapc,
+				const bufferlist &bl, ceph::real_time mtime,
+				uint64_t trunc_size, __u32 trunc_seq,
+				ceph_tid_t journal_tid, Context *oncommit)
 {
-  C_Delay *wrapper = new C_Delay(m_cct, oncommit, m_lock, off, NULL, m_delay_ns);
+  C_Delay *wrapper = new C_Delay(m_cct, oncommit, m_lock, off, NULL,
+				 m_delay_ns);
   m_finisher->queue(wrapper, 0);
   return m_tid.inc();
 }
 
-bool FakeWriteback::may_copy_on_write(const object_t&, uint64_t, uint64_t, snapid_t)
+bool FakeWriteback::may_copy_on_write(const object_t&, uint64_t, uint64_t,
+				      snapid_t)
 {
   return false;
 }
diff --git a/src/test/osdc/FakeWriteback.h b/src/test/osdc/FakeWriteback.h
index 351d521..2d77e92 100644
--- a/src/test/osdc/FakeWriteback.h
+++ b/src/test/osdc/FakeWriteback.h
@@ -23,13 +23,14 @@ public:
 		    __u32 trunc_seq, int op_flags, Context *onfinish);
 
   virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
-		           uint64_t off, uint64_t len,
+			   uint64_t off, uint64_t len,
 			   const SnapContext& snapc, const bufferlist &bl,
-			   utime_t mtime, uint64_t trunc_size,
+			   ceph::real_time mtime, uint64_t trunc_size,
 			   __u32 trunc_seq, ceph_tid_t journal_tid,
-                           Context *oncommit);
+			   Context *oncommit);
 
-  virtual bool may_copy_on_write(const object_t&, uint64_t, uint64_t, snapid_t);
+  virtual bool may_copy_on_write(const object_t&, uint64_t, uint64_t,
+				 snapid_t);
 private:
   CephContext *m_cct;
   Mutex *m_lock;
diff --git a/src/test/osdc/object_cacher_stress.cc b/src/test/osdc/object_cacher_stress.cc
index 7b04d4a..b961f75 100644
--- a/src/test/osdc/object_cacher_stress.cc
+++ b/src/test/osdc/object_cacher_stress.cc
@@ -110,8 +110,9 @@ int stress_test(uint64_t num_ops, uint64_t num_objs,
       else
 	assert(r == 0);
     } else {
-      ObjectCacher::OSDWrite *wr = obc.prepare_write(snapc, bl, utime_t(), 0,
-                                                     ++journal_tid);
+      ObjectCacher::OSDWrite *wr = obc.prepare_write(snapc, bl,
+						     ceph::real_time::min(), 0,
+						     ++journal_tid);
       wr->extents.push_back(op->extent);
       lock.Lock();
       obc.writex(wr, &object_set, NULL);
diff --git a/src/test/perf_local.cc b/src/test/perf_local.cc
index 9672be2..fe64258 100644
--- a/src/test/perf_local.cc
+++ b/src/test/perf_local.cc
@@ -340,7 +340,7 @@ class CondPingPong {
   CondPingPong(): mutex("CondPingPong::mutex"), prod(0), cons(0), count(10000), consumer(this) {}
 
   double run() {
-    consumer.create();
+    consumer.create("consumer");
     uint64_t start = Cycles::rdtsc();
     produce();
     uint64_t stop = Cycles::rdtsc();
@@ -498,7 +498,7 @@ double eventcenter_dispatch()
 
   CenterWorker worker(g_ceph_context);
   atomic_t flag(1);
-  worker.create();
+  worker.create("evt_center_disp");
   EventCallbackRef count_event(new CountEvent(&flag));
 
   worker.center.dispatch_event_external(count_event);
@@ -759,7 +759,7 @@ double spawn_thread()
   ThreadHelper thread;
   uint64_t start = Cycles::rdtsc();
   for (int i = 0; i < count; i++) {
-    thread.create();
+    thread.create("thread_helper");
     thread.join();
   }
   uint64_t stop = Cycles::rdtsc();
diff --git a/src/test/pybind/test_ceph_argparse.py b/src/test/pybind/test_ceph_argparse.py
index 53d420f..7c96881 100755
--- a/src/test/pybind/test_ceph_argparse.py
+++ b/src/test/pybind/test_ceph_argparse.py
@@ -381,7 +381,15 @@ class TestMDS(TestArgparse):
         self.check_1_natural_arg('mds', 'set_max_mds')
 
     def test_setmap(self):
-        self.check_1_natural_arg('mds', 'setmap')
+        self.assert_valid_command(['mds', 'setmap', '1'])
+        self.assert_valid_command(['mds', 'setmap', '1', '--yes-i-really-mean-it'])
+        assert_equal({}, validate_command(sigdict, ['mds', 'setmap',
+                                                    '--yes-i-really-mean-it']))
+        assert_equal({}, validate_command(sigdict, ['mds', 'setmap', '-1',
+                                                    '--yes-i-really-mean-it']))
+        assert_equal({}, validate_command(sigdict, ['mds', 'setmap', '1',
+                                                    '--yes-i-really-mean-it',
+                                                    'toomany']))
 
     def test_set_state(self):
         self.assert_valid_command(['mds', 'set_state', '1', '2'])
@@ -405,7 +413,15 @@ class TestMDS(TestArgparse):
         assert_equal({}, validate_command(sigdict, ['mds', 'rm', '1', 'mds.42']))
 
     def test_rmfailed(self):
-        self.check_1_natural_arg('mds', 'rmfailed')
+        self.assert_valid_command(['mds', 'rmfailed', '0'])
+        self.assert_valid_command(['mds', 'rmfailed', '0', '--yes-i-really-mean-it'])
+        assert_equal({}, validate_command(sigdict, ['mds', 'rmfailed',
+                                                    '--yes-i-really-mean-it']))
+        assert_equal({}, validate_command(sigdict, ['mds', 'rmfailed', '-1',
+                                                    '--yes-i-really-mean-it']))
+        assert_equal({}, validate_command(sigdict, ['mds', 'rmfailed', '0',
+                                                    '--yes-i-really-mean-it',
+                                                    'toomany']))
 
     def test_cluster_down(self):
         self.check_no_arg('mds', 'cluster_down')
diff --git a/src/test/python/ceph-disk/tests/test_ceph_disk.py b/src/test/python/ceph-disk/tests/test_ceph_disk.py
index b0c818c..1ec4ed1 100644
--- a/src/test/python/ceph-disk/tests/test_ceph_disk.py
+++ b/src/test/python/ceph-disk/tests/test_ceph_disk.py
@@ -243,6 +243,38 @@ class TestCephDisk(object):
                     'magic': ceph_disk.CEPH_OSD_ONDISK_MAGIC,
                     'state': 'prepared'} == desc
 
+    @patch('os.path.exists')
+    def test_list_paths_to_names(self, m_exists):
+
+        def exists(path):
+            return path in (
+                '/sys/block/sda',
+                '/sys/block/sdb',
+                '/sys/block/cciss!c0d0',
+                '/sys/block/cciss!c0d1',
+                '/sys/block/cciss!c0d2',
+            )
+
+        m_exists.side_effect = exists
+        paths = [
+            '/dev/sda',
+            '/dev/cciss/c0d0',
+            'cciss!c0d1',
+            'cciss/c0d2',
+            'sdb',
+        ]
+        expected = [
+            'sda',
+            'cciss!c0d0',
+            'cciss!c0d1',
+            'cciss!c0d2',
+            'sdb',
+        ]
+        assert expected == ceph_disk.list_paths_to_names(paths)
+        with pytest.raises(ceph_disk.Error) as excinfo:
+            ceph_disk.list_paths_to_names(['unknown'])
+        assert 'unknown' in excinfo.value.message
+
     def test_list_all_partitions(self):
         partition_uuid = "56244cf5-83ef-4984-888a-2d8b8e0e04b2"
         disk = "Xda"
diff --git a/src/test/python/ceph-disk/tox.ini b/src/test/python/ceph-disk/tox.ini
index 194c0fc..a89f0e3 100644
--- a/src/test/python/ceph-disk/tox.ini
+++ b/src/test/python/ceph-disk/tox.ini
@@ -11,7 +11,7 @@ deps=
 
 commands=
   python setup.py develop
-  py.test -vv --cov=ceph_disk.py --cov-report=term-missing
+  py.test -vv --cov=ceph_disk.py --cov-report=term-missing {posargs:tests}
 
 [testenv:flake8]
 deps=
diff --git a/src/test/streamtest.cc b/src/test/streamtest.cc
deleted file mode 100644
index e19dbce..0000000
--- a/src/test/streamtest.cc
+++ /dev/null
@@ -1,192 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2004-2006 Sage Weil <sage at newdream.net>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software 
- * Foundation.  See file COPYING.
- * 
- */
-
-#include <iostream>
-#include "os/FileStore.h"
-#include "global/global_init.h"
-#include "common/ceph_argparse.h"
-#include "common/debug.h"
-
-#undef dout_prefix
-#define dout_prefix *_dout
-
-struct io {
-  utime_t start, ack, commit;
-  bool done() {
-    return ack.sec() && commit.sec();
-  }
-};
-map<off_t,io> writes;
-Cond cond;
-Mutex test_lock("streamtest.cc lock");
-
-unsigned concurrent = 1;
-void throttle()
-{ 
-  Mutex::Locker l(test_lock);
-  while (writes.size() >= concurrent) {
-    //generic_dout(0) << "waiting" << dendl;
-    cond.Wait(test_lock);
-  }
-}
-
-double total_ack = 0;
-double total_commit = 0;
-int total_num = 0;
-
-void pr(off_t off)
-{
-  io &i = writes[off];
-  if (false) cout << off << "\t" 
-       << (i.ack - i.start) << "\t"
-       << (i.commit - i.start) << std::endl;
-  total_num++;
-  total_ack += (i.ack - i.start);
-  total_commit += (i.commit - i.start);
-  writes.erase(off);
-  cond.Signal();
-}
-
-void set_start(off_t off, utime_t t)
-{
-  Mutex::Locker l(test_lock);
-  writes[off].start = t;
-}
-
-void set_ack(off_t off, utime_t t)
-{
-  Mutex::Locker l(test_lock);
-  //generic_dout(0) << "ack " << off << dendl;
-  writes[off].ack = t;
-  if (writes[off].done())
-    pr(off);
-}
-
-void set_commit(off_t off, utime_t t)
-{
-  Mutex::Locker l(test_lock);
-  //generic_dout(0) << "commit " << off << dendl;
-  writes[off].commit = t;
-  if (writes[off].done())
-    pr(off);
-}
-
-
-struct C_Ack : public Context {
-  off_t off;
-  C_Ack(off_t o) : off(o) {}
-  void finish(int r) {
-    set_ack(off, ceph_clock_now(g_ceph_context));
-  }
-};
-struct C_Commit : public Context {
-  off_t off;
-  C_Commit(off_t o) : off(o) {}
-  void finish(int r) {
-    set_commit(off, ceph_clock_now(g_ceph_context));
-  }
-};
-
-
-int main(int argc, const char **argv)
-{
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  env_to_vec(args);
-
-  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-
-  // args
-  if (args.size() < 3) return -1;
-  const char *filename = args[0];
-  int seconds = atoi(args[1]);
-  int bytes = atoi(args[2]);
-  const char *journal = 0;
-  if (args.size() >= 4)
-    journal = args[3];
-  if (args.size() >= 5)
-    concurrent = atoi(args[4]);
-
-  cout << "concurrent = " << concurrent << std::endl;
-
-  buffer::ptr bp(bytes);
-  bp.zero();
-  bufferlist bl;
-  bl.push_back(bp);
-
-  //float interval = 1.0 / 1000;
-  
-  cout << "#dev " << filename
-       << ", " << seconds << " seconds, " << bytes << " bytes per write" << std::endl;
-
-  ObjectStore *fs = new FileStore(filename, journal);
-  
-  if (fs->mkfs() < 0) {
-    cout << "mkfs failed" << std::endl;
-    return -1;
-  }
-  
-  if (fs->mount() < 0) {
-    cout << "mount failed" << std::endl;
-    return -1;
-  }
-
-  ObjectStore::Sequencer osr(__func__);
-  ObjectStore::Transaction ft;
-  ft.create_collection(coll_t(), 0);
-  fs->apply_transaction(&osr, ft);
-
-  utime_t now = ceph_clock_now(g_ceph_context);
-  utime_t start = now;
-  utime_t end = now;
-  end += seconds;
-  off_t pos = 0;
-  //cout << "stop at " << end << std::endl;
-  cout << "# offset\tack\tcommit" << std::endl;
-  while (now < end) {
-    sobject_t poid(object_t("streamtest"), 0);
-
-    set_start(pos, ceph_clock_now(g_ceph_context));
-    ObjectStore::Transaction *t = new ObjectStore::Transaction;
-    t->write(coll_t(), ghobject_t(hobject_t(poid)), pos, bytes, bl);
-    fs->queue_transaction(NULL, t, new C_Ack(pos), new C_Commit(pos));
-    pos += bytes;
-
-    throttle();
-
-    now = ceph_clock_now(g_ceph_context);
-
-    // wait?
-    /*
-    utime_t next = start;
-    next += interval;
-    if (now < next) {
-      float s = next - now;
-      s *= 1000 * 1000;  // s -> us
-      //cout << "sleeping for " << s << " us" << std::endl;
-      usleep((int)s);
-    }
-    */
-  }
-
-  cout << "total num " << total_num << std::endl;
-  cout << "avg ack\t" << (total_ack / (double)total_num) << std::endl;
-  cout << "avg commit\t" << (total_commit / (double)total_num) << std::endl;
-  cout << "tput\t" << prettybyte_t((double)(total_num * bytes) / (double)(end-start)) << "/sec" << std::endl;
-
-  fs->umount();
-
-}
-
diff --git a/src/test/test_filejournal.cc b/src/test/test_filejournal.cc
index bd0ff52..d9dfb30 100644
--- a/src/test/test_filejournal.cc
+++ b/src/test/test_filejournal.cc
@@ -8,11 +8,11 @@
 #include "global/global_init.h"
 #include "common/config.h"
 #include "common/Finisher.h"
-#include "os/FileJournal.h"
+#include "os/filestore/FileJournal.h"
 #include "include/Context.h"
 #include "common/Mutex.h"
 #include "common/safe_io.h"
-#include "os/JournalingObjectStore.h"
+#include "os/filestore/JournalingObjectStore.h"
 
 Finisher *finisher;
 Cond sync_cond;
diff --git a/src/test/test_ipaddr.cc b/src/test/test_ipaddr.cc
index 8200821..1f58130 100644
--- a/src/test/test_ipaddr.cc
+++ b/src/test/test_ipaddr.cc
@@ -29,9 +29,11 @@ TEST(CommonIPAddr, TestNotFound)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv4(&a_one, "10.11.12.13");
   ipv6(&a_two, "2001:1234:5678:90ab::cdef");
@@ -51,9 +53,11 @@ TEST(CommonIPAddr, TestV4_Simple)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv4(&a_one, "10.11.12.13");
   ipv6(&a_two, "2001:1234:5678:90ab::cdef");
@@ -73,9 +77,11 @@ TEST(CommonIPAddr, TestV4_Prefix25)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv4(&a_one, "10.11.12.13");
   ipv4(&a_two, "10.11.12.129");
@@ -95,9 +101,11 @@ TEST(CommonIPAddr, TestV4_Prefix16)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv4(&a_one, "10.1.1.2");
   ipv4(&a_two, "10.2.1.123");
@@ -116,6 +124,7 @@ TEST(CommonIPAddr, TestV4_PrefixTooLong)
 
   one.ifa_next = NULL;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   ipv4(&a_one, "10.11.12.13");
   ipv4(&net, "10.11.12.12");
@@ -134,9 +143,11 @@ TEST(CommonIPAddr, TestV4_PrefixZero)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv6(&a_one, "2001:1234:5678:900F::cdef");
   ipv4(&a_two, "10.1.2.3");
@@ -156,9 +167,11 @@ TEST(CommonIPAddr, TestV6_Simple)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv4(&a_one, "10.11.12.13");
   ipv6(&a_two, "2001:1234:5678:90ab::cdef");
@@ -178,9 +191,11 @@ TEST(CommonIPAddr, TestV6_Prefix57)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv6(&a_one, "2001:1234:5678:900F::cdef");
   ipv6(&a_two, "2001:1234:5678:90ab::cdef");
@@ -199,6 +214,7 @@ TEST(CommonIPAddr, TestV6_PrefixTooLong)
 
   one.ifa_next = NULL;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   ipv6(&a_one, "2001:1234:5678:900F::cdef");
   ipv6(&net, "2001:1234:5678:900F::cdee");
@@ -217,9 +233,11 @@ TEST(CommonIPAddr, TestV6_PrefixZero)
 
   one.ifa_next = &two;
   one.ifa_addr = (struct sockaddr*)&a_one;
+  one.ifa_name = "eth0";
 
   two.ifa_next = NULL;
   two.ifa_addr = (struct sockaddr*)&a_two;
+  two.ifa_name = "eth1";
 
   ipv4(&a_one, "10.2.3.4");
   ipv6(&a_two, "2001:f00b::1");
diff --git a/src/test/test_objectstore_memstore.sh b/src/test/test_objectstore_memstore.sh
index 5296fd3..a0f062a 100755
--- a/src/test/test_objectstore_memstore.sh
+++ b/src/test/test_objectstore_memstore.sh
@@ -1,5 +1,6 @@
 #!/bin/sh -ex
 
+rm -rf store_test_temp_dir
 ./ceph_test_objectstore --gtest_filter=\*/0
 
 echo OK
diff --git a/src/test/test_pageset.cc b/src/test/test_pageset.cc
index c105af7..bfc7ab7 100644
--- a/src/test/test_pageset.cc
+++ b/src/test/test_pageset.cc
@@ -2,7 +2,7 @@
 // vim: ts=8 sw=2 smarttab
 #include "gtest/gtest.h"
 
-#include "os/PageSet.h"
+#include "os/memstore/PageSet.h"
 
 TEST(PageSet, AllocAligned)
 {
diff --git a/src/test/test_snap_mapper.cc b/src/test/test_snap_mapper.cc
index 873e88c..17cb898 100644
--- a/src/test/test_snap_mapper.cc
+++ b/src/test/test_snap_mapper.cc
@@ -167,7 +167,7 @@ private:
 
 public:
   PausyAsyncMap() : lock("PausyAsyncMap"), doer(this) {
-    doer.create();
+    doer.create("doer");
   }
   ~PausyAsyncMap() {
     doer.join();
diff --git a/src/test/test_stress_watch.cc b/src/test/test_stress_watch.cc
index 6ddfee5..cafdc20 100644
--- a/src/test/test_stress_watch.cc
+++ b/src/test/test_stress_watch.cc
@@ -76,7 +76,7 @@ TEST_P(WatchStress, Stress1) {
   WatchNotifyTestCtx ctx;
 
   WatcherUnwatcher *thr = new WatcherUnwatcher(pool_name);
-  thr->create();
+  thr->create("watcher_unwatch");
   ASSERT_EQ(0, nioctx.create("foo", false));
 
   for (unsigned i = 0; i < 75; ++i) {
diff --git a/src/test/test_texttable.cc b/src/test/test_texttable.cc
index 03ae3c8..60b0a1c 100644
--- a/src/test/test_texttable.cc
+++ b/src/test/test_texttable.cc
@@ -72,6 +72,5 @@ TEST(TextTable, TooManyItems) {
   t.define_column("3", TextTable::LEFT, TextTable::LEFT);
 
   // expect assertion failure on this, which throws FailedAssertion
-  ASSERT_THROW((t << "1" << "2" << "3" << "4" << TextTable::endrow),
-	       FailedAssertion);
+  ASSERT_DEATH((t << "1" << "2" << "3" << "4" << TextTable::endrow), "");
 }
diff --git a/src/test/test_trans.cc b/src/test/test_trans.cc
index c374ed4..415dea3 100644
--- a/src/test/test_trans.cc
+++ b/src/test/test_trans.cc
@@ -15,7 +15,7 @@
 #include <iostream>
 #include "common/ceph_argparse.h"
 #include "common/debug.h"
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "global/global_init.h"
 #include "include/assert.h"
 
@@ -70,7 +70,7 @@ int main(int argc, const char **argv)
   }
   
   dout(0) << "starting thread" << dendl;
-  foo.create();
+  foo.create("foo");
   dout(0) << "starting op" << dendl;
   fs->apply_transaction(&osr, t);
 
diff --git a/src/test/test_workqueue.cc b/src/test/test_workqueue.cc
index 602a0ec..c7ff433 100644
--- a/src/test/test_workqueue.cc
+++ b/src/test/test_workqueue.cc
@@ -8,7 +8,7 @@
 
 TEST(WorkQueue, StartStop)
 {
-  ThreadPool tp(g_ceph_context, "foo", 10, "");
+  ThreadPool tp(g_ceph_context, "foo", "tp_foo", 10, "");
   
   tp.start();
   tp.pause();
@@ -21,7 +21,7 @@ TEST(WorkQueue, StartStop)
 
 TEST(WorkQueue, Resize)
 {
-  ThreadPool tp(g_ceph_context, "bar", 2, "osd_op_threads");
+  ThreadPool tp(g_ceph_context, "bar", "tp_bar", 2, "osd_op_threads");
   
   tp.start();
 
diff --git a/src/test/xattr_bench.cc b/src/test/xattr_bench.cc
index e26e32f..544bb34 100644
--- a/src/test/xattr_bench.cc
+++ b/src/test/xattr_bench.cc
@@ -17,7 +17,7 @@
 #include <string.h>
 #include <iostream>
 #include <sstream>
-#include "os/FileStore.h"
+#include "os/filestore/FileStore.h"
 #include "include/Context.h"
 #include "common/ceph_argparse.h"
 #include "global/global_init.h"
diff --git a/src/tools/ceph_authtool.cc b/src/tools/ceph_authtool.cc
index caf1f0a..469c9f3 100644
--- a/src/tools/ceph_authtool.cc
+++ b/src/tools/ceph_authtool.cc
@@ -62,226 +62,221 @@ int main(int argc, const char **argv)
   map<string,bufferlist> caps;
   std::string fn;
 
-  try {
-    global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
-  	      CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
+	      CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
 
-    bool gen_key = false;
-    bool gen_print_key = false;
-    bool list = false;
-    bool print_key = false;
-    bool create_keyring = false;
-    bool set_auid = false;
-    std::vector<const char*>::iterator i;
+  bool gen_key = false;
+  bool gen_print_key = false;
+  bool list = false;
+  bool print_key = false;
+  bool create_keyring = false;
+  bool set_auid = false;
+  std::vector<const char*>::iterator i;
 
-    for (i = args.begin(); i != args.end(); ) {
-      std::string val;
-      if (ceph_argparse_double_dash(args, i)) {
-        break;
-      } else if (ceph_argparse_flag(args, i, "-g", "--gen-key", (char*)NULL)) {
-        gen_key = true;
-      } else if (ceph_argparse_flag(args, i, "--gen-print-key", (char*)NULL)) {
-        gen_print_key = true;
-      } else if (ceph_argparse_witharg(args, i, &val, "-a", "--add-key", (char*)NULL)) {
-        add_key = val;
-      } else if (ceph_argparse_flag(args, i, "-l", "--list", (char*)NULL)) {
-        list = true;
-      } else if (ceph_argparse_witharg(args, i, &val, "--caps", (char*)NULL)) {
-        caps_fn = val;
-      } else if (ceph_argparse_witharg(args, i, &val, "--cap", (char*)NULL)) {
-        std::string my_key = val;
-        if (i == args.end()) {
-  	cerr << "must give two arguments to --cap: key and val." << std::endl;
-  	exit(1);
-        }
-        std::string my_val = *i;
-        ++i;
-        ::encode(my_val, caps[my_key]);
-      } else if (ceph_argparse_flag(args, i, "-p", "--print-key", (char*)NULL)) {
-        print_key = true;
-      } else if (ceph_argparse_flag(args, i, "-C", "--create-keyring", (char*)NULL)) {
-        create_keyring = true;
-      } else if (ceph_argparse_witharg(args, i, &val, "--import-keyring", (char*)NULL)) {
-        import_keyring = val;
-      } else if (ceph_argparse_witharg(args, i, &val, "-u", "--set-uid", (char*)NULL)) {
-        std::string err;
-        auid = strict_strtoll(val.c_str(), 10, &err);
-        if (!err.empty()) {
-  	cerr << "error parsing UID: " << err << std::endl;
-  	exit(1);
-        }
-        set_auid = true;
-      } else if (fn.empty()) {
-        fn = *i++;
-      } else {
-        cerr << argv[0] << ": unexpected '" << *i << "'" << std::endl;
-        usage();
+  for (i = args.begin(); i != args.end(); ) {
+    std::string val;
+    if (ceph_argparse_double_dash(args, i)) {
+      break;
+    } else if (ceph_argparse_flag(args, i, "-g", "--gen-key", (char*)NULL)) {
+      gen_key = true;
+    } else if (ceph_argparse_flag(args, i, "--gen-print-key", (char*)NULL)) {
+      gen_print_key = true;
+    } else if (ceph_argparse_witharg(args, i, &val, "-a", "--add-key", (char*)NULL)) {
+      add_key = val;
+    } else if (ceph_argparse_flag(args, i, "-l", "--list", (char*)NULL)) {
+      list = true;
+    } else if (ceph_argparse_witharg(args, i, &val, "--caps", (char*)NULL)) {
+      caps_fn = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--cap", (char*)NULL)) {
+      std::string my_key = val;
+      if (i == args.end()) {
+	cerr << "must give two arguments to --cap: key and val." << std::endl;
+	exit(1);
       }
-    }
-    if (fn.empty() && !gen_print_key) {
-      cerr << argv[0] << ": must specify filename" << std::endl;
-      usage();
-    }
-    if (!(gen_key ||
-  	gen_print_key ||
-  	!add_key.empty() ||
-  	list ||
-  	!caps_fn.empty() ||
-  	!caps.empty() ||
-  	set_auid ||
-  	print_key ||
-  	create_keyring ||
-  	!import_keyring.empty())) {
-      cerr << "no command specified" << std::endl;
-      usage();
-    }
-    if (gen_key && (!add_key.empty())) {
-      cerr << "can't both gen_key and add_key" << std::endl;
-      usage();
-    }	
-  
-    common_init_finish(g_ceph_context);
-    EntityName ename(g_conf->name);
-  
-    if (gen_print_key) {
-      CryptoKey key;
-      key.create(g_ceph_context, CEPH_CRYPTO_AES);
-      cout << key << std::endl;    
-      return 0;
-    }
-  
-    // keyring --------
-    bool modified = false;
-    KeyRing keyring;
-  
-    bufferlist bl;
-    int r = 0;
-    if (create_keyring) {
-      cout << "creating " << fn << std::endl;
-      modified = true;
-    } else {
+      std::string my_val = *i;
+      ++i;
+      ::encode(my_val, caps[my_key]);
+    } else if (ceph_argparse_flag(args, i, "-p", "--print-key", (char*)NULL)) {
+      print_key = true;
+    } else if (ceph_argparse_flag(args, i, "-C", "--create-keyring", (char*)NULL)) {
+      create_keyring = true;
+    } else if (ceph_argparse_witharg(args, i, &val, "--import-keyring", (char*)NULL)) {
+      import_keyring = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "-u", "--set-uid", (char*)NULL)) {
       std::string err;
-      r = bl.read_file(fn.c_str(), &err);
-      if (r >= 0) {
-        try {
-  	bufferlist::iterator iter = bl.begin();
-  	::decode(keyring, iter);
-        } catch (const buffer::error &err) {
-  	cerr << "error reading file " << fn << std::endl;
-  	exit(1);
-        }
-      } else {
-        cerr << "can't open " << fn << ": " << err << std::endl;
-        exit(1);
+      auid = strict_strtoll(val.c_str(), 10, &err);
+      if (!err.empty()) {
+	cerr << "error parsing UID: " << err << std::endl;
+	exit(1);
       }
+      set_auid = true;
+    } else if (fn.empty()) {
+      fn = *i++;
+    } else {
+      cerr << argv[0] << ": unexpected '" << *i << "'" << std::endl;
+      usage();
     }
-  
-    // write commands
-    if (!import_keyring.empty()) {
-      KeyRing other;
-      bufferlist obl;
-      std::string err;
-      int r = obl.read_file(import_keyring.c_str(), &err);
-      if (r >= 0) {
-        try {
-  	bufferlist::iterator iter = obl.begin();
-  	::decode(other, iter);
-        } catch (const buffer::error &err) {
-  	cerr << "error reading file " << import_keyring << std::endl;
-  	exit(1);
-        }
-        
-        cout << "importing contents of " << import_keyring << " into " << fn << std::endl;
-        //other.print(cout);
-        keyring.import(g_ceph_context, other);
-        modified = true;
-      } else {
-        cerr << "can't open " << import_keyring << ": " << err << std::endl;
-        exit(1);
-      }
-    }
-    if (gen_key) {
-      EntityAuth eauth;
-      eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
-      keyring.add(ename, eauth);
-      modified = true;
-    }
-    if (!add_key.empty()) {
-      EntityAuth eauth;
+  }
+  if (fn.empty() && !gen_print_key) {
+    cerr << argv[0] << ": must specify filename" << std::endl;
+    usage();
+  }
+  if (!(gen_key ||
+	gen_print_key ||
+	!add_key.empty() ||
+	list ||
+	!caps_fn.empty() ||
+	!caps.empty() ||
+	set_auid ||
+	print_key ||
+	create_keyring ||
+	!import_keyring.empty())) {
+    cerr << "no command specified" << std::endl;
+    usage();
+  }
+  if (gen_key && (!add_key.empty())) {
+    cerr << "can't both gen_key and add_key" << std::endl;
+    usage();
+  }
+
+  common_init_finish(g_ceph_context);
+  EntityName ename(g_conf->name);
+
+  if (gen_print_key) {
+    CryptoKey key;
+    key.create(g_ceph_context, CEPH_CRYPTO_AES);
+    cout << key << std::endl;
+    return 0;
+  }
+
+  // keyring --------
+  bool modified = false;
+  KeyRing keyring;
+
+  bufferlist bl;
+  int r = 0;
+  if (create_keyring) {
+    cout << "creating " << fn << std::endl;
+    modified = true;
+  } else {
+    std::string err;
+    r = bl.read_file(fn.c_str(), &err);
+    if (r >= 0) {
       try {
-        eauth.key.decode_base64(add_key);
+	bufferlist::iterator iter = bl.begin();
+	::decode(keyring, iter);
       } catch (const buffer::error &err) {
-        cerr << "can't decode key '" << add_key << "'" << std::endl;
-        exit(1);
+	cerr << "error reading file " << fn << std::endl;
+	exit(1);
       }
-      keyring.add(ename, eauth);
-      modified = true;
-      cout << "added entity " << ename << " auth " << eauth << std::endl;
+    } else {
+      cerr << "can't open " << fn << ": " << err << std::endl;
+      exit(1);
     }
-    if (!caps_fn.empty()) {
-      ConfFile cf;
-      std::deque<std::string> parse_errors;
-      if (cf.parse_file(caps_fn, &parse_errors, &cerr) != 0) {
-        cerr << "could not parse caps file " << caps_fn << std::endl;
-        exit(1);
-      }
-      complain_about_parse_errors(g_ceph_context, &parse_errors);
-      map<string, bufferlist> caps;
-      const char *key_names[] = { "mon", "osd", "mds", NULL };
-      for (int i=0; key_names[i]; i++) {
-        std::string val;
-        if (cf.read("global", key_names[i], val) == 0) {
-          bufferlist bl;
-          ::encode(val, bl);
-          string s(key_names[i]);
-          caps[s] = bl; 
-        }
+  }
+
+  // write commands
+  if (!import_keyring.empty()) {
+    KeyRing other;
+    bufferlist obl;
+    std::string err;
+    int r = obl.read_file(import_keyring.c_str(), &err);
+    if (r >= 0) {
+      try {
+	bufferlist::iterator iter = obl.begin();
+	::decode(other, iter);
+      } catch (const buffer::error &err) {
+	cerr << "error reading file " << import_keyring << std::endl;
+	exit(1);
       }
-      keyring.set_caps(ename, caps);
+
+      cout << "importing contents of " << import_keyring << " into " << fn << std::endl;
+      //other.print(cout);
+      keyring.import(g_ceph_context, other);
       modified = true;
+    } else {
+      cerr << "can't open " << import_keyring << ": " << err << std::endl;
+      exit(1);
     }
-    if (!caps.empty()) {
-      keyring.set_caps(ename, caps);
-      modified = true;
+  }
+  if (gen_key) {
+    EntityAuth eauth;
+    eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
+    keyring.add(ename, eauth);
+    modified = true;
+  }
+  if (!add_key.empty()) {
+    EntityAuth eauth;
+    try {
+      eauth.key.decode_base64(add_key);
+    } catch (const buffer::error &err) {
+      cerr << "can't decode key '" << add_key << "'" << std::endl;
+      exit(1);
     }
-    if (set_auid) {
-      keyring.set_uid(ename, auid);
-      modified = true;
+    keyring.add(ename, eauth);
+    modified = true;
+    cout << "added entity " << ename << " auth " << eauth << std::endl;
+  }
+  if (!caps_fn.empty()) {
+    ConfFile cf;
+    std::deque<std::string> parse_errors;
+    if (cf.parse_file(caps_fn, &parse_errors, &cerr) != 0) {
+      cerr << "could not parse caps file " << caps_fn << std::endl;
+      exit(1);
     }
-  
-    // read commands
-    if (list) {
-      try {
-        keyring.print(cout);
-      } catch (ceph::buffer::end_of_buffer &eob) {
-        cout << "Exception (end_of_buffer) in print(), exit." << std::endl;
-        exit(1);
+    complain_about_parse_errors(g_ceph_context, &parse_errors);
+    map<string, bufferlist> caps;
+    const char *key_names[] = { "mon", "osd", "mds", NULL };
+    for (int i=0; key_names[i]; i++) {
+      std::string val;
+      if (cf.read("global", key_names[i], val) == 0) {
+	bufferlist bl;
+	::encode(val, bl);
+	string s(key_names[i]);
+	caps[s] = bl;
       }
     }
-    if (print_key) {
-      CryptoKey key;
-      if (keyring.get_secret(ename, key)) {
-        cout << key << std::endl;
-      } else {
-        cerr << "entity " << ename << " not found" << std::endl;
-        exit(1);
-      }
+    keyring.set_caps(ename, caps);
+    modified = true;
+  }
+  if (!caps.empty()) {
+    keyring.set_caps(ename, caps);
+    modified = true;
+  }
+  if (set_auid) {
+    keyring.set_uid(ename, auid);
+    modified = true;
+  }
+
+  // read commands
+  if (list) {
+    try {
+      keyring.print(cout);
+    } catch (ceph::buffer::end_of_buffer &eob) {
+      cout << "Exception (end_of_buffer) in print(), exit." << std::endl;
+      exit(1);
     }
-  
-    // write result?
-    if (modified) {
-      bufferlist bl;
-      keyring.encode_plaintext(bl);
-      r = bl.write_file(fn.c_str(), 0600);
-      if (r < 0) {
-        cerr << "could not write " << fn << std::endl;
-        exit(1);
-      }
-      //cout << "wrote " << bl.length() << " bytes to " << fn << std::endl;
+  }
+  if (print_key) {
+    CryptoKey key;
+    if (keyring.get_secret(ename, key)) {
+      cout << key << std::endl;
+    } else {
+      cerr << "entity " << ename << " not found" << std::endl;
+      exit(1);
+    }
+  }
+
+  // write result?
+  if (modified) {
+    bufferlist bl;
+    keyring.encode_plaintext(bl);
+    r = bl.write_file(fn.c_str(), 0600);
+    if (r < 0) {
+      cerr << "could not write " << fn << std::endl;
+      exit(1);
     }
-  } catch (ceph::FailedAssertion &a) {
-    cout << "Failed assert, exit." << std::endl;
-    exit(1); 
-  } 
+    //cout << "wrote " << bl.length() << " bytes to " << fn << std::endl;
+  }
   return 0;
 }
diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc
index 83ad9ce..c37c3af 100644
--- a/src/tools/ceph_monstore_tool.cc
+++ b/src/tools/ceph_monstore_tool.cc
@@ -170,6 +170,7 @@ int parse_cmd_args(
  *  replay-trace
  *  random-gen
  *  rewrite-crush
+ *  inflate-pgmap
  *
  * wanted syntax:
  *
@@ -200,6 +201,8 @@ void usage(const char *n, po::options_description &d)
   << "                                  (default: last committed)\n"
   << "  get crushmap [-- options]       get crushmap (version VER if specified)\n"
   << "                                  (default: last committed)\n"
+  << "  show-versions [-- options]      show the first&last committed version of map\n"
+  << "                                  (show-versions -- --help for more info)\n"
   << "  dump-keys                       dumps store keys to FILE\n"
   << "                                  (default: stdout)\n"
   << "  dump-paxos [-- options]         dump paxos transactions\n"
@@ -212,6 +215,8 @@ void usage(const char *n, po::options_description &d)
   << "                                  (random-gen -- --help for more info)\n"
   << "  rewrite-crush [-- options]      add a rewrite commit to the store\n"
   << "                                  (rewrite-crush -- --help for more info)\n"
+  << "  inflate-pgmap [-- options]      add given number of pgmaps to store\n"
+  << "                                  (inflate-pgmap -- --help for more info)\n"
   << std::endl;
   std::cerr << d << std::endl;
   std::cerr
@@ -440,6 +445,70 @@ int rewrite_crush(const char* progname,
   return 0;
 }
 
+int inflate_pgmap(MonitorDBStore& st, unsigned n, bool can_be_trimmed) {
+  // put latest pg map into monstore to bloat it up
+  // only format version == 1 is supported
+  version_t last = st.get("pgmap", "last_committed");
+  bufferlist bl;
+
+  // get the latest delta
+  int r = st.get("pgmap", last, bl);
+  if (r) {
+    std::cerr << "Error getting pgmap: " << cpp_strerror(r) << std::endl;
+    return r;
+  }
+
+  // try to pull together an idempotent "delta"
+  ceph::unordered_map<pg_t, pg_stat_t> pg_stat;
+  for (KeyValueDB::Iterator i = st.get_iterator("pgmap_pg");
+       i->valid(); i->next()) {
+    pg_t pgid;
+    if (!pgid.parse(i->key().c_str())) {
+      std::cerr << "unable to parse key " << i->key() << std::endl;
+      continue;
+    }
+    bufferlist pg_bl = i->value();
+    pg_stat_t ps;
+    bufferlist::iterator p = pg_bl.begin();
+    ::decode(ps, p);
+    // will update the last_epoch_clean of all the pgs.
+    pg_stat[pgid] = ps;
+  }
+
+  version_t first = st.get("pgmap", "first_committed");
+  version_t ver = last;
+  MonitorDBStore::TransactionRef txn(new MonitorDBStore::Transaction);
+  for (unsigned i = 0; i < n; i++) {
+    bufferlist trans_bl;
+    bufferlist dirty_pgs;
+    for (ceph::unordered_map<pg_t, pg_stat_t>::iterator ps = pg_stat.begin();
+	 ps != pg_stat.end(); ++ps) {
+      ::encode(ps->first, dirty_pgs);
+      if (!can_be_trimmed) {
+	ps->second.last_epoch_clean = first;
+      }
+      ::encode(ps->second, dirty_pgs);
+    }
+    utime_t inc_stamp = ceph_clock_now(NULL);
+    ::encode(inc_stamp, trans_bl);
+    ::encode_destructively(dirty_pgs, trans_bl);
+    bufferlist dirty_osds;
+    ::encode(dirty_osds, trans_bl);
+    txn->put("pgmap", ++ver, trans_bl);
+    // update the db in batch
+    if (txn->size() > 1024) {
+      st.apply_transaction(txn);
+      // reset the transaction
+      txn.reset(new MonitorDBStore::Transaction);
+    }
+  }
+  txn->put("pgmap", "last_committed", ver);
+  txn->put("pgmap_meta", "version", ver);
+  // this will also piggy back the leftover pgmap added in the loop above
+  st.apply_transaction(txn);
+  return 0;
+}
+
 int main(int argc, char **argv) {
   int err = 0;
   po::options_description desc("Allowed options");
@@ -676,6 +745,38 @@ int main(int argc, char **argv) {
                 << " version " << v << " to " << outpath
                 << std::endl;
     }
+  } else if (cmd == "show-versions") {
+    string map_type; //map type:osdmap,monmap...
+    // visible options for this command
+    po::options_description op_desc("Allowed 'show-versions' options");
+    op_desc.add_options()
+      ("help,h", "produce this help message")
+      ("map-type", po::value<string>(&map_type), "map_type");
+
+    po::positional_options_description op_positional;
+    op_positional.add("map-type", 1);
+
+    po::variables_map op_vm;
+    int r = parse_cmd_args(&op_desc, NULL, &op_positional,
+                           subcmds, &op_vm);
+    if (r < 0) {
+      err = -r;
+      goto done;
+    }
+
+    if (op_vm.count("help") || map_type.empty()) {
+      usage(argv[0], op_desc);
+      err = 0;
+      goto done;
+    }
+
+    unsigned int v_first = 0;
+    unsigned int v_last = 0;
+    v_first = st.get(map_type, "first_committed");
+    v_last = st.get(map_type, "last_committed");
+
+    std::cout << "first committed:\t" << v_first << "\n"
+              << "last  committed:\t" << v_last << std::endl;
   } else if (cmd == "dump-paxos") {
     unsigned dstart = 0;
     unsigned dstop = ~0;
@@ -970,6 +1071,29 @@ int main(int argc, char **argv) {
               << std::endl;
   } else if (cmd == "rewrite-crush") {
     err = rewrite_crush(argv[0], subcmds, st);
+  } else if (cmd == "inflate-pgmap") {
+    unsigned n = 2000;
+    bool can_be_trimmed = false;
+    po::options_description op_desc("Allowed 'inflate-pgmap' options");
+    op_desc.add_options()
+      ("num-maps,n", po::value<unsigned>(&n),
+       "number of maps to add (default: 2000)")
+      ("can-be-trimmed", po::value<bool>(&can_be_trimmed),
+       "can be trimmed (default: false)")
+      ;
+
+    po::variables_map op_vm;
+    try {
+      po::parsed_options op_parsed = po::command_line_parser(subcmds).
+        options(op_desc).run();
+      po::store(op_parsed, op_vm);
+      po::notify(op_vm);
+    } catch (po::error &e) {
+      std::cerr << "error: " << e.what() << std::endl;
+      err = EINVAL;
+      goto done;
+    }
+    err = inflate_pgmap(st, n, can_be_trimmed);
   } else {
     std::cerr << "Unrecognized command: " << cmd << std::endl;
     usage(argv[0], desc);
diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc
index 23870cf..7f39f92 100644
--- a/src/tools/ceph_objectstore_tool.cc
+++ b/src/tools/ceph_objectstore_tool.cc
@@ -25,8 +25,7 @@
 #include "global/global_init.h"
 
 #include "os/ObjectStore.h"
-#include "os/FileStore.h"
-#include "os/FileJournal.h"
+#include "os/filestore/FileJournal.h"
 
 #include "osd/PGLog.h"
 #include "osd/OSD.h"
@@ -413,8 +412,7 @@ int finish_remove_pgs(ObjectStore *store)
     spg_t pgid;
 
     if (it->is_temp(&pgid) ||
-	it->is_removal(&pgid) ||
-	(it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
+       (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
       cout << "finish_remove_pgs " << *it << " removing " << pgid << std::endl;
       OSD::recursive_remove_collection(store, pgid, *it);
       continue;
@@ -1269,14 +1267,6 @@ int ObjectStoreTool::do_import(ObjectStore *store, OSDSuperblock& sb,
 
     cerr << "Export has incompatible features set " << unsupported << std::endl;
 
-    // If shards setting the issue, then inform user what they can do about it.
-    if (unsupported.incompat.contains(CEPH_OSD_FEATURE_INCOMPAT_SHARDS)) {
-      cerr << std::endl;
-      cerr << "OSD requires sharding to be enabled" << std::endl;
-      cerr << std::endl;
-      cerr << "If you wish to import, first do 'ceph-objectstore-tool...--op set-allow-sharded-objects'" << std::endl;
-      return -EINVAL;
-    }
     // Let them import if they specify the --force option
     if (!force)
         return 11;  // Positive return means exit status
@@ -2238,7 +2228,7 @@ int main(int argc, char **argv)
     ("pgid", po::value<string>(&pgidstr),
      "PG id, mandatory for info, log, remove, export, rm-past-intervals, mark-complete")
     ("op", po::value<string>(&op),
-     "Arg is one of [info, log, remove, export, import, list, fix-lost, list-pgs, rm-past-intervals, set-allow-sharded-objects, dump-journal, dump-super, meta-list, "
+     "Arg is one of [info, log, remove, fsck, export, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, "
 	 "get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete]")
     ("epoch", po::value<unsigned>(&epoch),
      "epoch# for get-osdmap and get-inc-osdmap, the current epoch in use if not specified")
@@ -2319,7 +2309,23 @@ int main(int argc, char **argv)
     ceph_options.push_back(i->c_str());
   }
 
-  if (!vm.count("type")) {
+  char fn[PATH_MAX];
+  snprintf(fn, sizeof(fn), "%s/type", dpath.c_str());
+  int fd = ::open(fn, O_RDONLY);
+  if (fd >= 0) {
+    bufferlist bl;
+    bl.read_fd(fd, 64);
+    if (bl.length()) {
+      string dp_type = string(bl.c_str(), bl.length() - 1);  // drop \n
+      if (vm.count("type") && dp_type != "" && type != dp_type)
+        cerr << "WARNING: Ignoring type \"" << type << "\" - found data-path type \""
+             << dp_type << "\"" << std::endl;
+      type = dp_type;
+      //cout << "object store type is " << type << std::endl;
+    }
+    ::close(fd);
+  }
+  if (!vm.count("type") && type == "") {
     type = "filestore";
   }
   if (!vm.count("data-path") &&
@@ -2329,16 +2335,14 @@ int main(int argc, char **argv)
     myexit(1);
   }
   if (type == "filestore" && !vm.count("journal-path")) {
-    cerr << "Must provide --journal-path" << std::endl;
-    usage(desc);
-    myexit(1);
+    jpath = dpath + "/journal";
   }
   if (!vm.count("op") && !vm.count("object")) {
     cerr << "Must provide --op or object command..." << std::endl;
     usage(desc);
     myexit(1);
   }
-  if (op != "list" && vm.count("op") && vm.count("object")) {
+  if (op != "list" && op != "fsck" && vm.count("op") && vm.count("object")) {
     cerr << "Can't specify both --op and object command syntax" << std::endl;
     usage(desc);
     myexit(1);
@@ -2462,7 +2466,7 @@ int main(int argc, char **argv)
 
   ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags);
   if (fs == NULL) {
-    cerr << "Must provide --type (filestore, memstore, keyvaluestore)" << std::endl;
+    cerr << "Need a valid --type e.g. filestore, memstore, keyvaluestore" << std::endl;
     if (type == "keyvaluestore") {
       cerr << "Add \"keyvaluestore\" to "
            << "enable_experimental_unrecoverable_data_corrupting_features"
@@ -2471,6 +2475,20 @@ int main(int argc, char **argv)
     myexit(1);
   }
 
+  if (op == "fsck") {
+    int r = fs->fsck();
+    if (r < 0) {
+      cerr << "fsck failed: " << cpp_strerror(r) << std::endl;
+      exit(1);
+    }
+    if (r > 0) {
+      cerr << "fsck found " << r << " errors" << std::endl;
+      exit(1);
+    }
+    cout << "fsck found no errors" << std::endl;
+    exit(0);
+  }
+
   ObjectStore::Sequencer *osr = new ObjectStore::Sequencer(__func__);
   int ret = fs->mount();
   if (ret < 0) {
@@ -2482,8 +2500,6 @@ int main(int argc, char **argv)
     myexit(1);
   }
 
-  bool fs_sharded_objects = fs->get_allow_sharded_objects();
-
   vector<coll_t> ls;
   vector<coll_t>::iterator it;
   CompatSet supported;
@@ -2510,13 +2526,6 @@ int main(int argc, char **argv)
     cerr << "Cluster fsid=" << superblock.cluster_fsid << std::endl;
   }
 
-#ifdef INTERNAL_TEST2
-  fs->set_allow_sharded_objects();
-  assert(fs->get_allow_sharded_objects());
-  fs_sharded_objects = true;
-  superblock.compat_features.incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_SHARDS);
-#endif
-
   if (debug) {
     cerr << "Supported features: " << supported << std::endl;
     cerr << "On-disk features: " << superblock.compat_features << std::endl;
@@ -2632,96 +2641,6 @@ int main(int argc, char **argv)
     goto out;
   }
 
-  if (op == "set-allow-sharded-objects") {
-    // This could only happen if we backport changes to an older release
-    if (!supported.incompat.contains(CEPH_OSD_FEATURE_INCOMPAT_SHARDS)) {
-      cerr << "Can't enable sharded objects in this release" << std::endl;
-      ret = 1;
-      goto out;
-    }
-    if (superblock.compat_features.incompat.contains(CEPH_OSD_FEATURE_INCOMPAT_SHARDS) &&
-        fs_sharded_objects) {
-      cerr << "Sharded objects already fully enabled" << std::endl;
-      ret = 0;
-      goto out;
-    }
-    OSDMap curmap;
-    bufferlist bl;
-    ret = get_osdmap(fs, superblock.current_epoch, curmap, bl);
-    if (ret) {
-        cerr << "Can't find local OSDMap" << std::endl;
-        goto out;
-    }
-
-    // Based on OSDMonitor::check_cluster_features()
-    // XXX: The up state of osds in the last map isn't
-    // as important from a non-running osd.  I'm using
-    // get_all_osds() instead.  An osd which was never
-    // upgraded and never removed would be flagged here.
-    stringstream unsupported_ss;
-    int unsupported_count = 0;
-    uint64_t features = CEPH_FEATURE_OSD_ERASURE_CODES;
-    set<int32_t> all_osds;
-    curmap.get_all_osds(all_osds);
-    for (set<int32_t>::iterator it = all_osds.begin();
-         it != all_osds.end(); ++it) {
-        const osd_xinfo_t &xi = curmap.get_xinfo(*it);
-#ifdef INTERNAL_TEST3
-        // Force one of the OSDs to not have support for erasure codes
-        if (unsupported_count == 0)
-            ((osd_xinfo_t &)xi).features &= ~features;
-#endif
-        if ((xi.features & features) != features) {
-            if (unsupported_count > 0)
-                unsupported_ss << ", ";
-            unsupported_ss << "osd." << *it;
-            unsupported_count ++;
-        }
-    }
-
-    if (unsupported_count > 0) {
-        cerr << "ERASURE_CODES feature unsupported by: "
-           << unsupported_ss.str() << std::endl;
-        ret = 1;
-        goto out;
-    }
-
-    if (!dry_run) {
-      superblock.compat_features.incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_SHARDS);
-      ObjectStore::Transaction t;
-      bl.clear();
-      ::encode(superblock, bl);
-      t.write(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
-      ret = fs->apply_transaction(osr, t);
-      if (ret < 0) {
-        cerr << "Error writing OSD superblock: " << cpp_strerror(ret) << std::endl;
-        goto out;
-      }
-
-      fs->set_allow_sharded_objects();
-    }
-    cout << "Enabled on-disk sharded objects" << std::endl;
-
-    ret = 0;
-    goto out;
-  }
-
-  // If there was a crash as an OSD was transitioning to sharded objects
-  // and hadn't completed a set_allow_sharded_objects().
-  // This utility does not want to attempt to finish that transition.
-  if (superblock.compat_features.incompat.contains(CEPH_OSD_FEATURE_INCOMPAT_SHARDS) != fs_sharded_objects) {
-    // An OSD should never have call set_allow_sharded_objects() before
-    // updating its own OSD features.
-    if (fs_sharded_objects)
-      cerr << "FileStore sharded but OSD not set, Corruption?" << std::endl;
-    else
-      cerr << "Found incomplete transition to sharded objects" << std::endl;
-    cerr << std::endl;
-    cerr << "Use --op set-allow-sharded-objects to repair" << std::endl;
-    ret = -EINVAL;
-    goto out;
-  }
-
   if (op == "import") {
 
     try {
@@ -2904,7 +2823,7 @@ int main(int argc, char **argv)
   // If not an object command nor any of the ops handled below, then output this usage
   // before complaining about a bad pgid
   if (!vm.count("objcmd") && op != "export" && op != "info" && op != "log" && op != "rm-past-intervals" && op != "mark-complete") {
-    cerr << "Must provide --op (info, log, remove, export, import, list, fix-lost, list-pgs, rm-past-intervals, set-allow-sharded-objects, dump-journal, dump-super, meta-list, "
+    cerr << "Must provide --op (info, log, remove, fsck, export, import, list, fix-lost, list-pgs, rm-past-intervals, dump-journal, dump-super, meta-list, "
       "get-osdmap, set-osdmap, get-inc-osdmap, set-inc-osdmap, mark-complete)"
 	 << std::endl;
     usage(desc);
diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc
index 465ffda..ffb4528 100644
--- a/src/tools/ceph_osdomap_tool.cc
+++ b/src/tools/ceph_osdomap_tool.cc
@@ -19,7 +19,7 @@
 #include "common/errno.h"
 #include "global/global_init.h"
 
-#include "os/DBObjectMap.h"
+#include "os/filestore/DBObjectMap.h"
 #include "kv/KeyValueDB.h"
 
 namespace po = boost::program_options;
diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc
index f97029e..1abd74c 100644
--- a/src/tools/cephfs/Dumper.cc
+++ b/src/tools/cephfs/Dumper.cc
@@ -246,7 +246,8 @@ int Dumper::undump(const char *dump_file)
   cout << "writing header " << oid << std::endl;
   C_SaferCond header_cond;
   lock.Lock();
-  objecter->write_full(oid, oloc, snapc, hbl, ceph_clock_now(g_ceph_context), 0, 
+  objecter->write_full(oid, oloc, snapc, hbl,
+		       ceph::real_clock::now(g_ceph_context), 0,
 		       NULL, &header_cond);
   lock.Unlock();
 
@@ -272,11 +273,12 @@ int Dumper::undump(const char *dump_file)
     C_SaferCond purge_cond;
     cout << "Purging " << purge_count << " objects from " << last_obj << std::endl;
     lock.Lock();
-    filer.purge_range(ino, &h.layout, snapc, last_obj, purge_count, ceph_clock_now(g_ceph_context), 0, &purge_cond);
+    filer.purge_range(ino, &h.layout, snapc, last_obj, purge_count,
+		      ceph::real_clock::now(g_ceph_context), 0, &purge_cond);
     lock.Unlock();
     purge_cond.wait();
   }
-  
+
   // Stream from `fd` to `filer`
   uint64_t pos = start;
   uint64_t left = len;
@@ -291,7 +293,8 @@ int Dumper::undump(const char *dump_file)
     cout << " writing " << pos << "~" << l << std::endl;
     C_SaferCond write_cond;
     lock.Lock();
-    filer.write(ino, &h.layout, snapc, pos, l, j, ceph_clock_now(g_ceph_context), 0, NULL, &write_cond);
+    filer.write(ino, &h.layout, snapc, pos, l, j,
+		ceph::real_clock::now(g_ceph_context), 0, NULL, &write_cond);
     lock.Unlock();
 
     r = write_cond.wait();
diff --git a/src/tools/cephfs/MDSUtility.cc b/src/tools/cephfs/MDSUtility.cc
index 708b57c..d335d92 100644
--- a/src/tools/cephfs/MDSUtility.cc
+++ b/src/tools/cephfs/MDSUtility.cc
@@ -22,7 +22,7 @@ MDSUtility::MDSUtility() :
   objecter(NULL),
   lock("MDSUtility::lock"),
   timer(g_ceph_context, lock),
-  finisher(g_ceph_context, "MDSUtility"),
+  finisher(g_ceph_context, "MDSUtility", "fn_mds_utility"),
   waiting_for_mds_map(NULL)
 {
   monc = new MonClient(g_ceph_context);
diff --git a/src/tools/cephfs/MDSUtility.h b/src/tools/cephfs/MDSUtility.h
index 1674ed0..4034043 100644
--- a/src/tools/cephfs/MDSUtility.h
+++ b/src/tools/cephfs/MDSUtility.h
@@ -21,6 +21,7 @@
 #include "msg/Messenger.h"
 #include "auth/Auth.h"
 #include "common/Finisher.h"
+#include "common/Timer.h"
 
 /// MDS Utility
 /**
diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc
index 532ffe1..5d2d542 100644
--- a/src/tools/crushtool.cc
+++ b/src/tools/crushtool.cc
@@ -68,19 +68,19 @@ static int get_fd_data(int fd, bufferlist &bl)
 void data_analysis_usage()
 {
 cout << "data output from testing routine ...\n";
-cout << "          absolute_weights\n";
-cout << "                the decimal weight of each OSD\n";
-cout << "                data layout: ROW MAJOR\n";
-cout << "                             OSD id (int), weight (int)\n";
+cout << "           absolute_weights\n";
+cout << "                  the decimal weight of each OSD\n";
+cout << "                  data layout: ROW MAJOR\n";
+cout << "                               OSD id (int), weight (int)\n";
 cout << "           batch_device_expected_utilization_all\n";
-cout << "                 the expected number of objects each OSD should receive per placement batch\n";
-cout << "                 which may be a decimal value\n";
-cout << "                 data layout: COLUMN MAJOR\n";
-cout << "                              round (int), objects expected on OSD 0...OSD n (float)\n";
+cout << "                  the expected number of objects each OSD should receive per placement batch\n";
+cout << "                  which may be a decimal value\n";
+cout << "                  data layout: COLUMN MAJOR\n";
+cout << "                               round (int), objects expected on OSD 0...OSD n (float)\n";
 cout << "           batch_device_utilization_all\n";
-cout << "                 the number of objects stored on each OSD during each placement round\n";
-cout << "                 data layout: COLUMN MAJOR\n";
-cout << "                              round (int), objects stored on OSD 0...OSD n (int)\n";
+cout << "                  the number of objects stored on each OSD during each placement round\n";
+cout << "                  data layout: COLUMN MAJOR\n";
+cout << "                               round (int), objects stored on OSD 0...OSD n (int)\n";
 cout << "           device_utilization_all\n";
 cout << "                  the number of objects stored on each OSD at the end of placements\n";
 cout << "                  data_layout: ROW MAJOR\n";
@@ -128,10 +128,11 @@ void usage()
   cout << "   [--outfn|-o outfile]\n";
   cout << "                         specify output for for (de)compilation\n";
   cout << "   --compile|-c map.txt  compile a map from source\n";
-  cout << "   --enable-unsafe-tunables compile with unsafe tunables\n";
+  cout << "   --enable-unsafe-tunables\n";
+  cout << "                         compile with unsafe tunables\n";
   cout << "   --build --num_osds N layer1 ...\n";
   cout << "                         build a new map, where each 'layer' is\n";
-  cout << "                           'name (uniform|straw|list|tree) size'\n";
+  cout << "                         'name (uniform|straw|list|tree) size'\n";
   cout << "\n";
   cout << "Options for the tunables adjustments stage\n";
   cout << "\n";
@@ -146,6 +147,8 @@ void usage()
   cout << "                         set chooseleaf to (not) retry the recursive descent\n";
   cout << "   --set-chooseleaf-vary-r <0|1>\n";
   cout << "                         set chooseleaf to (not) vary r based on parent\n";
+  cout << "   --set-chooseleaf-stable <0|1>\n";
+  cout << "                         set chooseleaf firstn to (not) return stable results\n";
   cout << "\n";
   cout << "Options for the modifications stage\n";
   cout << "\n";
@@ -179,7 +182,7 @@ void usage()
   cout << "                         number generator in place of the CRUSH\n";
   cout << "                         algorithm\n";
   cout << "   --show-utilization    show OSD usage\n";
-  cout << "   --show utilization-all\n";
+  cout << "   --show-utilization-all\n";
   cout << "                         include zero weight items\n";
   cout << "   --show-statistics     show chi squared statistics\n";
   cout << "   --show-mappings       show mappings\n";
@@ -196,7 +199,7 @@ void usage()
   cout << "Options for the output stage\n";
   cout << "\n";
   cout << "   [--outfn|-o outfile]\n";
-  cout << "                         specify output for for modified crush map\n";
+  cout << "                         specify output for modified crush map\n";
   cout << "\n";
 }
 
@@ -255,6 +258,7 @@ int main(int argc, const char **argv)
   int choose_total_tries = -1;
   int chooseleaf_descend_once = -1;
   int chooseleaf_vary_r = -1;
+  int chooseleaf_stable = -1;
   int straw_calc_version = -1;
   int allowed_bucket_algs = -1;
 
@@ -338,6 +342,9 @@ int main(int argc, const char **argv)
     } else if (ceph_argparse_witharg(args, i, &chooseleaf_vary_r, err,
 				     "--set_chooseleaf_vary_r", (char*)NULL)) {
       adjust = true;
+    } else if (ceph_argparse_witharg(args, i, &chooseleaf_stable, err,
+				     "--set_chooseleaf_stable", (char*)NULL)) {
+      adjust = true;
     } else if (ceph_argparse_witharg(args, i, &straw_calc_version, err,
 				     "--set_straw_calc_version", (char*)NULL)) {
       adjust = true;
@@ -617,6 +624,7 @@ int main(int argc, const char **argv)
       crush.set_item_name(i, "osd." + stringify(i));
     }
 
+    crush.set_type_name(0, "osd");
     int type = 1;
     for (vector<layer_t>::iterator p = layers.begin(); p != layers.end(); ++p, type++) {
       layer_t &l = *p;
@@ -636,7 +644,7 @@ int main(int argc, const char **argv)
 	  break;
 	}
       if (buckettype < 0) {
-	cerr << "unknown bucket type '" << l.buckettype << "'" << std::endl << std::endl;
+	cerr << "unknown bucket type '" << l.buckettype << "'" << std::endl;
 	exit(EXIT_FAILURE);
       }
 
@@ -671,8 +679,9 @@ int main(int argc, const char **argv)
 	int id;
 	int r = crush.add_bucket(0, buckettype, CRUSH_HASH_DEFAULT, type, j, items, weights, &id);
 	if (r < 0) {
-	  dout(2) << "Couldn't add bucket: " << cpp_strerror(r) << dendl;
-	}
+          cerr << " Couldn't add bucket: " << cpp_strerror(r) << std::endl;
+          return r;
+        }
 
 	char format[20];
 	format[sizeof(format)-1] = '\0';
@@ -738,6 +747,10 @@ int main(int argc, const char **argv)
     crush.set_chooseleaf_vary_r(chooseleaf_vary_r);
     modified = true;
   }
+  if (chooseleaf_stable >= 0) {
+    crush.set_chooseleaf_stable(chooseleaf_stable);
+    modified = true;
+  }
   if (straw_calc_version >= 0) {
     crush.set_straw_calc_version(straw_calc_version);
     modified = true;
@@ -835,8 +848,11 @@ int main(int argc, const char **argv)
   }
 
   if (check) {
-    if (!tester.check_name_maps(max_id)) {
-      exit(1);
+    tester.check_overlapped_rules();
+    if (max_id >= 0) {
+      if (!tester.check_name_maps(max_id)) {
+	exit(1);
+      }
     }
   }
 
diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc
index 0506cfe..ad75e9f 100644
--- a/src/tools/rados/rados.cc
+++ b/src/tools/rados/rados.cc
@@ -84,7 +84,7 @@ void usage(ostream& out)
 "   put <obj-name> [infile]          write object\n"
 "   truncate <obj-name> length       truncate object\n"
 "   create <obj-name>                create object\n"
-"   rm <obj-name> ...                remove object(s)\n"
+"   rm <obj-name> ...[--force-full]  [force no matter full or not]remove object(s)\n"
 "   cp <obj-name> [target-obj]       copy object\n"
 "   clonedata <src-obj> <dst-obj>    clone object data\n"
 "   listxattr <obj-name>\n"
@@ -1239,7 +1239,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
 
   std::string run_name;
   std::string prefix;
-
+  bool forcefull = false;
   Formatter *formatter = NULL;
   bool pretty_format = false;
   const char *output = NULL;
@@ -1282,6 +1282,11 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   if (i != opts.end()) {
     run_name = i->second;
   }
+
+  i = opts.find("force-full");
+  if (i != opts.end()) {
+    forcefull = true;
+  }
   i = opts.find("prefix");
   if (i != opts.end()) {
     prefix = i->second;
@@ -2161,9 +2166,17 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
     for (; iter != nargs.end(); ++iter) {
       const string & oid = *iter;
       if (use_striper) {
-	ret = striper.remove(oid);
+	if (forcefull) {
+	  ret = striper.remove(oid, CEPH_OSD_FLAG_FULL_FORCE);
+	} else {
+	  ret = striper.remove(oid);
+	}
       } else {
-	ret = io_ctx.remove(oid);
+	if (forcefull) {
+	  ret = io_ctx.remove(oid, CEPH_OSD_FLAG_FULL_FORCE);
+	} else {
+	  ret = io_ctx.remove(oid);
+	}
       }
       if (ret < 0) {
         string name = (nspace.size() ? nspace + "/" : "" ) + oid;
@@ -2946,6 +2959,8 @@ int main(int argc, const char **argv)
       exit(0);
     } else if (ceph_argparse_flag(args, i, "-f", "--force", (char*)NULL)) {
       opts["force"] = "true";
+    } else if (ceph_argparse_flag(args, i, "--force-full", (char*)NULL)) {
+      opts["force-full"] = "true";
     } else if (ceph_argparse_flag(args, i, "-d", "--delete-after", (char*)NULL)) {
       opts["delete-after"] = "true";
     } else if (ceph_argparse_flag(args, i, "-C", "--create", "--create-pool",
diff --git a/src/tools/rbd/Shell.cc b/src/tools/rbd/Shell.cc
index 57af89a..76aa8ed 100644
--- a/src/tools/rbd/Shell.cc
+++ b/src/tools/rbd/Shell.cc
@@ -66,8 +66,17 @@ std::string format_option_suffix(
 
 } // anonymous namespace
 
-std::vector<Shell::Action *> Shell::s_actions;
-std::set<std::string> Shell::s_switch_arguments;
+std::vector<Shell::Action *>& Shell::get_actions() {
+  static std::vector<Action *> actions;
+
+  return actions;
+}
+
+std::set<std::string>& Shell::get_switch_arguments() {
+  static std::set<std::string> switch_arguments;
+
+  return switch_arguments;
+}
 
 int Shell::execute(int arg_count, const char **arg_values) {
 
@@ -187,9 +196,10 @@ void Shell::get_command_spec(const std::vector<std::string> &arguments,
     } else if (arg[0] == '-') {
       // if the option is not a switch, skip its value
       if (arg.size() >= 2 &&
-          (arg[1] == '-' || s_switch_arguments.count(arg.substr(1, 1)) == 0) &&
+          (arg[1] == '-' ||
+	   get_switch_arguments().count(arg.substr(1, 1)) == 0) &&
           (arg[1] != '-' ||
-             s_switch_arguments.count(arg.substr(2, std::string::npos)) == 0) &&
+	   get_switch_arguments().count(arg.substr(2, std::string::npos)) == 0) &&
           at::SWITCH_ARGUMENTS.count(arg.substr(2, std::string::npos)) == 0 &&
           arg.find('=') == std::string::npos) {
         ++i;
@@ -202,8 +212,8 @@ void Shell::get_command_spec(const std::vector<std::string> &arguments,
 
 Shell::Action *Shell::find_action(const CommandSpec &command_spec,
                                   CommandSpec **matching_spec) {
-  for (size_t i = 0; i < s_actions.size(); ++i) {
-    Action *action = s_actions[i];
+  for (size_t i = 0; i < get_actions().size(); ++i) {
+    Action *action = get_actions()[i];
     if (action->command_spec.size() <= command_spec.size()) {
       if (std::includes(action->command_spec.begin(),
                         action->command_spec.end(),
@@ -277,7 +287,7 @@ void Shell::print_help() {
             << "Command-line interface for managing Ceph RBD images."
             << std::endl << std::endl;
 
-  std::vector<Action *> actions(s_actions);
+  std::vector<Action *> actions(get_actions());
   std::sort(actions.begin(), actions.end(),
             [](Action *lhs, Action *rhs) { return lhs->command_spec <
                                                     rhs->command_spec; });
@@ -368,8 +378,8 @@ void Shell::print_bash_completion(const CommandSpec &command_spec) {
     print_bash_completion_options(command_opts);
   } else {
     std::cout << "|help";
-    for (size_t i = 0; i < s_actions.size(); ++i) {
-      Action *action = s_actions[i];
+    for (size_t i = 0; i < get_actions().size(); ++i) {
+      Action *action = get_actions()[i];
       std::cout << "|"
                 << joinify<std::string>(action->command_spec.begin(),
                                         action->command_spec.end(), " ");
diff --git a/src/tools/rbd/Shell.h b/src/tools/rbd/Shell.h
index 4a21325..b65483e 100644
--- a/src/tools/rbd/Shell.h
+++ b/src/tools/rbd/Shell.h
@@ -36,22 +36,22 @@ public:
         : command_spec(command_spec), alias_command_spec(alias_command_spec),
           description(description), help(help), get_arguments(args),
           execute(execute) {
-      Shell::s_actions.push_back(this);
+      Shell::get_actions().push_back(this);
     }
 
   };
 
   struct SwitchArguments {
     SwitchArguments(const std::initializer_list<std::string> &arguments) {
-      Shell::s_switch_arguments.insert(arguments.begin(), arguments.end());
+      Shell::get_switch_arguments().insert(arguments.begin(), arguments.end());
     }
   };
 
   int execute(int arg_count, const char **arg_values);
 
 private:
-  static std::vector<Action *> s_actions;
-  static std::set<std::string> s_switch_arguments;
+  static std::vector<Action *>& get_actions();
+  static std::set<std::string>& get_switch_arguments();
 
   void get_command_spec(const std::vector<std::string> &arguments,
                         std::vector<std::string> *command_spec);
diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc
index 3f6cc2a..4f4b2e8 100644
--- a/src/tools/rbd/Utils.cc
+++ b/src/tools/rbd/Utils.cc
@@ -328,7 +328,7 @@ int get_image_options(const boost::program_options::variables_map &vm,
     object_size = vm[at::IMAGE_OBJECT_SIZE].as<uint64_t>();
     order = std::round(std::log2(object_size)); 
   } else {
-    order = 22;
+    order = g_conf->rbd_default_order;
   }
 
   if (vm.count(at::IMAGE_FEATURES)) {
@@ -355,10 +355,21 @@ int get_image_options(const boost::program_options::variables_map &vm,
     std::cerr << "must specify both (or neither) of stripe-unit and stripe-count"
               << std::endl;
     return -EINVAL;
-  } else if ((stripe_unit || stripe_count) &&
-             (stripe_unit != (1ull << order) && stripe_count != 1)) {
+  } else if (stripe_unit || stripe_count) {
+    if ((1ull << order) % stripe_unit || stripe_unit >= (1ull << order)) {
+      std::cerr << "stripe unit is not a factor of the object size" << std::endl;
+      return -EINVAL;
+    }
+    if (stripe_count == 1) {
+      std::cerr << "stripe count not allowed to be 1" << std::endl;
+      return -EINVAL;
+    }
     features |= RBD_FEATURE_STRIPINGV2;
   } else {
+    if (features_specified && ((features & RBD_FEATURE_STRIPINGV2) != 0)) {
+      std::cerr << "must specify both of stripe-unit and stripe-count when specify striping features" << std::endl;
+      return -EINVAL;
+    }
     features &= ~RBD_FEATURE_STRIPINGV2;
   }
 
diff --git a/src/tools/rbd/action/ImportDiff.cc b/src/tools/rbd/action/ImportDiff.cc
index 9f600f8..21a817c 100644
--- a/src/tools/rbd/action/ImportDiff.cc
+++ b/src/tools/rbd/action/ImportDiff.cc
@@ -74,7 +74,12 @@ static int do_import_diff(librbd::Image &image, const char *path,
         goto done;
       dout(2) << " from snap " << from << dendl;
 
-      if (!image.snap_exists(from.c_str())) {
+      bool exists; 
+      r = image.snap_exists2(from.c_str(), &exists);
+      if (r < 0)
+        goto done;
+
+      if (!exists) {
         std::cerr << "start snapshot '" << from
                   << "' does not exist in the image, aborting" << std::endl;
         r = -EINVAL;
@@ -88,7 +93,12 @@ static int do_import_diff(librbd::Image &image, const char *path,
       dout(2) << "   to snap " << to << dendl;
 
       // verify this snap isn't already present
-      if (image.snap_exists(to.c_str())) {
+      bool exists;
+      r = image.snap_exists2(to.c_str(), &exists);
+      if (r < 0)
+        goto done;
+      
+      if (exists) {
         std::cerr << "end snapshot '" << to
                   << "' already exists, aborting" << std::endl;
         r = -EEXIST;
diff --git a/src/tools/rbd/action/Journal.cc b/src/tools/rbd/action/Journal.cc
index e00665b..cd4213a 100644
--- a/src/tools/rbd/action/Journal.cc
+++ b/src/tools/rbd/action/Journal.cc
@@ -21,7 +21,7 @@
 #include "journal/ReplayEntry.h"
 #include "journal/ReplayHandler.h"
 //#include "librbd/Journal.h" // XXXMG: for librbd::Journal::reset()
-#include "librbd/JournalTypes.h"
+#include "librbd/journal/Entries.h"
 
 namespace rbd {
 namespace action {
diff --git a/src/tools/rbd/action/MergeDiff.cc b/src/tools/rbd/action/MergeDiff.cc
index eb3f3a3..f56ec1f 100644
--- a/src/tools/rbd/action/MergeDiff.cc
+++ b/src/tools/rbd/action/MergeDiff.cc
@@ -290,9 +290,9 @@ static int do_merge_diff(const char *first, const char *second,
       uint64_t last_off = s_off;
 
       r = parse_diff_body(sd, &s_tag, &s_off, &s_len);
-      dout(2) << "second diff data chunk: tag=" << f_tag << ", "
-              << "off=" << f_off << ", "
-              << "len=" << f_len << dendl;
+      dout(2) << "second diff data chunk: tag=" << s_tag << ", "
+              << "off=" << s_off << ", "
+              << "len=" << s_len << dendl;
       if (r < 0) {
         std::cerr << "rbd: failed to read second diff data chunk header"
                   << std::endl;
diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc
index b86bceb..41fcfc2 100644
--- a/src/tools/rbd_nbd/rbd-nbd.cc
+++ b/src/tools/rbd_nbd/rbd-nbd.cc
@@ -1,3 +1,21 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+/*
+ * rbd-nbd - RBD in userspace
+ *
+ * Copyright (C) 2015 - 2016 Kylin Corporation
+ *
+ * Author: Yunchuan Wen <yunchuan.wen at kylin-cloud.com>
+ *         Li Wang <li.wang at kylin-cloud.com>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+*/
+
 #include "include/int_types.h"
 
 #include <stdio.h>
@@ -20,6 +38,7 @@
 
 #include "mon/MonClient.h"
 #include "common/config.h"
+#include "common/dout.h"
 
 #include "common/errno.h"
 #include "common/module.h"
@@ -31,18 +50,23 @@
 #include "include/rados/librados.hpp"
 #include "include/rbd/librbd.hpp"
 
+#define dout_subsys ceph_subsys_rbd
+#undef dout_prefix
+#define dout_prefix *_dout << "rbd-nbd: "
+
 static void usage()
 {
   std::cout << "Usage: rbd-nbd [options] map <image-or-snap-spec>  Map a image to nbd device\n"
             << "               unmap <device path>                 Unmap nbd device\n"
             << "               list-mapped                         List mapped nbd devices\n"
-            << "Options: --device <device path>                    Specify nbd device path\n"
-            << "         --read-only                               Map readonly\n"
-            << "         --nbds_max <limit>                        Override for module param\n"
+            << "Options:\n"
+            << "  --device <device path>                    Specify nbd device path\n"
+            << "  --read-only                               Map readonly\n"
+            << "  --nbds_max <limit>                        Override for module param\n"
             << std::endl;
+  generic_server_usage();
 }
 
-static Preforker forker;
 static std::string devpath, poolname("rbd"), imgname, snapname;
 static bool readonly = false;
 static int nbds_max = 0;
@@ -100,6 +124,8 @@ private:
     {}
   };
 
+  friend std::ostream &operator<<(std::ostream &os, const IOContext &ctx);
+
   Mutex lock;
   Cond cond;
   xlist<IOContext*> io_pending;
@@ -155,9 +181,19 @@ private:
 
     IOContext *ctx = reinterpret_cast<IOContext *>(arg);
     int ret = aio_completion->get_return_value();
-    if (ret > 0)
-      ret = 0;
-    ctx->reply.error = htonl(ret);
+
+    dout(20) << __func__ << ": " << *ctx << dendl;
+
+    if (ret < 0) {
+      ctx->reply.error = htonl(-ret);
+    } else if ((ctx->command == NBD_CMD_WRITE || ctx->command == NBD_CMD_READ)
+	       && ret != static_cast<int>(ctx->request.len)) {
+      derr << __func__ << ": " << *ctx << ": unexpected return value: " << ret
+	   << " (" << ctx->request.len << " expected)" << dendl;
+      ctx->reply.error = htonl(EIO);
+    } else {
+      ctx->reply.error = htonl(0);
+    }
     ctx->server->io_finish(ctx);
 
     aio_completion->release();
@@ -168,11 +204,20 @@ private:
     while (!terminated.read()) {
       ceph::unique_ptr<IOContext> ctx(new IOContext());
       ctx->server = this;
-      if (safe_read_exact(fd, &ctx->request, sizeof(struct nbd_request)) < 0)
-        return;
 
-      if (ctx->request.magic != htonl(NBD_REQUEST_MAGIC))
-        return;
+      dout(20) << __func__ << ": waiting for nbd request" << dendl;
+
+      int r = safe_read_exact(fd, &ctx->request, sizeof(struct nbd_request));
+      if (r < 0) {
+	derr << "failed to read nbd request header: " << cpp_strerror(errno)
+	     << dendl;
+	return;
+      }
+
+      if (ctx->request.magic != htonl(NBD_REQUEST_MAGIC)) {
+	derr << "invalid nbd request header" << dendl;
+	return;
+      }
 
       ctx->request.from = ntohll(ctx->request.from);
       ctx->request.type = ntohl(ctx->request.type);
@@ -183,14 +228,21 @@ private:
 
       ctx->command = ctx->request.type & 0x0000ffff;
 
+      dout(20) << *ctx << ": start" << dendl;
+
       switch (ctx->command)
       {
         case NBD_CMD_DISC:
+	  dout(0) << "disconnect request received" << dendl;
           return;
         case NBD_CMD_WRITE:
           bufferptr ptr(ctx->request.len);
-          if (safe_read_exact(fd, ptr.c_str(), ctx->request.len) < 0)
+	  r = safe_read_exact(fd, ptr.c_str(), ctx->request.len);
+          if (r < 0) {
+	    derr << *ctx << ": failed to read nbd request data: "
+		 << cpp_strerror(errno) << dendl;
             return;
+	  }
           ctx->data.push_back(ptr);
           break;
       }
@@ -213,25 +265,42 @@ private:
           image.aio_discard(pctx->request.from, pctx->request.len, c);
           break;
         default:
+	  derr << *pctx << ": invalid request command" << dendl;
           return;
       }
     }
+    dout(20) << __func__ << ": terminated" << dendl;
   }
 
   void writer_entry()
   {
     while (!terminated.read()) {
+      dout(20) << __func__ << ": waiting for io request" << dendl;
       ceph::unique_ptr<IOContext> ctx(wait_io_finish());
-      if (!ctx)
+      if (!ctx) {
+	dout(20) << __func__ << ": no io requests, terminating" << dendl;
         return;
+      }
+
+      dout(20) << __func__ << ": got: " << *ctx << dendl;
 
-      if (safe_write(fd, &ctx->reply, sizeof(struct nbd_reply)) < 0)
+      int r = safe_write(fd, &ctx->reply, sizeof(struct nbd_reply));
+      if (r < 0) {
+	derr << *ctx << ": failed to write reply header: " << cpp_strerror(r)
+	     << dendl;
         return;
+      }
       if (ctx->command == NBD_CMD_READ && ctx->reply.error == htonl(0)) {
-        if (ctx->data.write_fd(fd) < 0)
+	r = ctx->data.write_fd(fd);
+        if (r < 0) {
+	  derr << *ctx << ": failed to write replay data: " << cpp_strerror(r)
+	       << dendl;
           return;
+	}
       }
+      dout(20) << *ctx << ": finish" << dendl;
     }
+    dout(20) << __func__ << ": terminated" << dendl;
   }
 
   class ThreadHelper : public Thread
@@ -260,16 +329,20 @@ public:
   void start()
   {
     if (!started) {
+      dout(10) << __func__ << ": starting" << dendl;
+
       started = true;
 
-      reader_thread.create();
-      writer_thread.create();
+      reader_thread.create("rbd_reader");
+      writer_thread.create("rbd_writer");
     }
   }
 
   void stop()
   {
     if (started) {
+      dout(10) << __func__ << ": terminating" << dendl;
+
       shutdown();
 
       reader_thread.join();
@@ -287,6 +360,34 @@ public:
   }
 };
 
+std::ostream &operator<<(std::ostream &os, const NBDServer::IOContext &ctx) {
+
+  os << "[" << std::hex << ntohll(*((uint64_t *)ctx.request.handle));
+
+  switch (ctx.command)
+  {
+  case NBD_CMD_WRITE:
+    os << " WRITE ";
+    break;
+  case NBD_CMD_READ:
+    os << " READ ";
+    break;
+  case NBD_CMD_FLUSH:
+    os << " FLUSH ";
+    break;
+  case NBD_CMD_TRIM:
+    os << " TRIM ";
+    break;
+  default:
+    os << " UNKNOW(" << ctx.command << ") ";
+    break;
+  }
+
+  os << ctx.request.from << "~" << ctx.request.len << " "
+     << ntohl(ctx.reply.error) << "]";
+
+  return os;
+}
 
 class NBDWatchCtx : public librados::WatchCtx2
 {
@@ -322,11 +423,11 @@ public:
 
       if (new_size != size) {
         if (ioctl(fd, BLKFLSBUF, NULL) < 0)
-          std::cerr << "rbd-nbd: invalidate page cache failed status: " << cpp_strerror(errno) << std::endl;
+            derr << "invalidate page cache failed: " << cpp_strerror(errno) << dendl;
         if (ioctl(fd, NBD_SET_SIZE, new_size) < 0)
-          std::cerr << "rbd-nbd: resize failed status: " << cpp_strerror(errno) << std::endl;
+            derr << "resize failed: " << cpp_strerror(errno) << dendl;
         if (image.invalidate_cache() < 0)
-          std::cerr << "rbd-nbd: invalidate rbd cache failed" << std::endl;
+            derr << "invalidate rbd cache failed" << dendl;
         size = new_size;
       }
     }
@@ -377,11 +478,31 @@ static int do_map()
 
   int fd[2];
   int nbd;
-  int null_fd = -1;
 
   uint8_t old_format;
   librbd::image_info_t info;
 
+  Preforker forker;
+
+  if (global_init_prefork(g_ceph_context) >= 0) {
+    std::string err;
+    r = forker.prefork(err);
+    if (r < 0) {
+      cerr << err << std::endl;
+      return r;
+    }
+
+    if (forker.is_parent()) {
+      if (forker.parent_wait(err) != 0) {
+	return -ENXIO;
+      }
+      return 0;
+    }
+  }
+
+  common_init_finish(g_ceph_context);
+  global_init_chdir(g_ceph_context);
+
   if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
     r = -errno;
     goto close_ret;
@@ -503,22 +624,12 @@ static int do_map()
     if (r < 0)
       goto close_nbd;
 
-    if (g_conf->daemonize) {
-      r = open("/dev/null", O_RDWR);
-      if (r < 0)
-        goto close_watcher;
-      null_fd = r;
-    }
-
     cout << devpath << std::endl;
 
     if (g_conf->daemonize) {
       forker.daemonize();
-
-      ::dup2(null_fd, STDIN_FILENO);
-      ::dup2(null_fd, STDOUT_FILENO);
-      ::dup2(null_fd, STDERR_FILENO);
-      close(null_fd);
+      global_init_postfork_start(g_ceph_context);
+      global_init_postfork_finish(g_ceph_context);
     }
 
     {
@@ -529,7 +640,6 @@ static int do_map()
       server.stop();
     }
 
-close_watcher:
     io_ctx.unwatch2(watcher);
   }
 
@@ -546,11 +656,16 @@ close_ret:
   image.close();
   io_ctx.close();
   rados.shutdown();
+
+  forker.exit(r < 0 ? EXIT_FAILURE : 0);
+  // Unreachable;
   return r;
 }
 
 static int do_unmap()
 {
+  common_init_finish(g_ceph_context);
+
   int nbd = open_device(devpath.c_str());
   if (nbd < 0) {
     cerr << "rbd-nbd: failed to open device: " << devpath << std::endl;
@@ -585,14 +700,19 @@ static int parse_imgpath(const std::string &imgpath)
   return 0;
 }
 
-static void list_mapped_devices()
+static int do_list_mapped_devices()
 {
   char path[64];
   int m = 0;
   int fd[2];
 
-  if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1)
-    return;
+  common_init_finish(g_ceph_context);
+
+  if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) == -1) {
+    int r = -errno;
+    cerr << "rbd-nbd: socketpair failed: " << cpp_strerror(-r) << std::endl;
+    return r;
+  }
 
   while (true) {
     snprintf(path, sizeof(path), "/dev/nbd%d", m);
@@ -609,6 +729,8 @@ static void list_mapped_devices()
 
   close(fd[0]);
   close(fd[1]);
+
+  return 0;
 }
 
 static int rbd_nbd(int argc, const char *argv[])
@@ -692,8 +814,6 @@ static int rbd_nbd(int argc, const char *argv[])
 
   switch (cmd) {
     case Connect:
-      common_init_finish(g_ceph_context);
-
       if (imgname.empty()) {
         cerr << "rbd-nbd: image name was not specified" << std::endl;
         return EXIT_FAILURE;
@@ -709,7 +829,9 @@ static int rbd_nbd(int argc, const char *argv[])
         return EXIT_FAILURE;
       break;
     case List:
-      list_mapped_devices();
+      r = do_list_mapped_devices();
+      if (r < 0)
+        return EXIT_FAILURE;
       break;
     default:
       usage();
@@ -721,19 +843,5 @@ static int rbd_nbd(int argc, const char *argv[])
 
 int main(int argc, const char *argv[])
 {
-  std::string err;
-
-  if (forker.prefork(err) < 0) {
-    cerr << err << std::endl;
-    return EXIT_FAILURE;
-  }
-
-  if (forker.is_child()) {
-    forker.exit(rbd_nbd(argc, argv));
-  } else if (forker.parent_wait(err) < 0) {
-    cerr << err << std::endl;
-    return EXIT_FAILURE;
-  } else {
-    return 0;
-  }
+  return rbd_nbd(argc, argv);
 }
diff --git a/src/tracing/librbd.tp b/src/tracing/librbd.tp
index 146e06e..58cbc13 100644
--- a/src/tracing/librbd.tp
+++ b/src/tracing/librbd.tp
@@ -1217,6 +1217,32 @@ TRACEPOINT_EVENT(librbd, snap_is_protected_exit,
     )
 )
 
+TRACEPOINT_EVENT(librbd, snap_exists_enter,
+    TP_ARGS(
+        void*, imagectx,
+        const char*, name,
+        const char*, snap_name,
+        char, read_only,
+        const char*, snap_name_to_check),
+    TP_FIELDS(
+        ctf_integer_hex(void*, imagectx, imagectx)
+        ctf_string(name, name)
+        ctf_string(snap_name, snap_name)
+        ctf_integer(char, read_only, read_only)
+        ctf_string(snap_name_to_check, snap_name_to_check)
+    )
+)
+
+TRACEPOINT_EVENT(librbd, snap_exists_exit,
+    TP_ARGS(
+        int, retval,
+        int, exists),
+    TP_FIELDS(
+        ctf_integer(int, retval, retval)
+        ctf_integer(int, exists, exists)
+    )
+)
+
 TRACEPOINT_EVENT(librbd, snap_set_enter,
     TP_ARGS(
         void*, imagectx,
diff --git a/src/vstart.sh b/src/vstart.sh
index daf4d7d..e515479 100755
--- a/src/vstart.sh
+++ b/src/vstart.sh
@@ -33,17 +33,31 @@ if [ -e CMakeCache.txt ]; then
     ln -sf ../${file} ec_plugins/`basename $file`
   done
   [ -z "$EC_PATH" ] && EC_PATH=./ec_plugins
+  # check for compression plugins
+  mkdir -p .libs/compressor
+  for file in ./src/compressor/*/libcs_*.so*;
+  do
+    ln -sf ../${file} .libs/compressor/`basename $file`
+  done
+else
+    mkdir -p .libs/compressor
+    for f in `ls -d compressor/*/`; 
+    do 
+        cp .libs/libceph_`basename $f`.so* .libs/compressor/;
+    done
 fi
 
 if [ -z "$CEPH_BUILD_ROOT" ]; then
         [ -z "$CEPH_BIN" ] && CEPH_BIN=.
         [ -z "$CEPH_LIB" ] && CEPH_LIB=.libs
         [ -z $EC_PATH ] && EC_PATH=$CEPH_LIB
+        [ -z $CS_PATH ] && CS_PATH=$CEPH_LIB
         [ -z $OBJCLASS_PATH ] && OBJCLASS_PATH=$CEPH_LIB
 else
         [ -z $CEPH_BIN ] && CEPH_BIN=$CEPH_BUILD_ROOT/bin
         [ -z $CEPH_LIB ] && CEPH_LIB=$CEPH_BUILD_ROOT/lib
         [ -z $EC_PATH ] && EC_PATH=$CEPH_LIB/erasure-code
+        [ -z $CS_PATH ] && CS_PATH=$CEPH_LIB/compressor
         [ -z $OBJCLASS_PATH ] && OBJCLASS_PATH=$CEPH_LIB/rados-classes
 fi
 
@@ -91,7 +105,7 @@ overwrite_conf=1
 cephx=1 #turn cephx on by default
 cache=""
 memstore=0
-newstore=0
+bluestore=0
 journal=1
 
 MON_ADDR=""
@@ -230,8 +244,8 @@ case $1 in
     --memstore )
 	    memstore=1
 	    ;;
-    --newstore )
-	    newstore=1
+    --bluestore )
+	    bluestore=1
 	    ;;
     --hitset )
 	    hitset="$hitset $2 $3"
@@ -308,7 +322,10 @@ else
         debug monc = 20
         debug journal = 20
         debug filestore = 20
-        debug newstore = 30
+        debug bluestore = 30
+        debug bluefs = 20
+        debug rocksdb = 10
+        debug bdev = 20
         debug rgw = 20
         debug objclass = 20'
     CMDSDEBUG='
@@ -331,9 +348,12 @@ if [ "$memstore" -eq 1 ]; then
     COSDMEMSTORE='
 	osd objectstore = memstore'
 fi
-if [ "$newstore" -eq 1 ]; then
+if [ "$bluestore" -eq 1 ]; then
     COSDMEMSTORE='
-	osd objectstore = newstore'
+	osd objectstore = bluestore
+	bluestore fsck on mount = true
+	bluestore block db size = 67108864
+	bluestore block wal size = 134217728'
 fi
 
 # lockdep everywhere?
@@ -427,6 +447,7 @@ if [ "$start_mon" -eq 1 ]; then
         mon data avail warn = 10
         mon data avail crit = 1
         erasure code dir = $EC_PATH
+        plugin dir = $CS_PATH
         osd pool default erasure code profile = plugin=jerasure technique=reed_sol_van k=2 m=1 ruleset-failure-domain=osd
         rgw frontends = fastcgi, civetweb port=$CEPH_RGW_PORT
         rgw dns name = localhost
@@ -575,6 +596,7 @@ EOF
 		    rm -rf $CEPH_DEV_DIR/osd$osd || true
 		    for f in $CEPH_DEV_DIR/osd$osd/* ; do btrfs sub delete $f || true ; done || true
 		    mkdir -p $CEPH_DEV_DIR/osd$osd
+
 	    fi
 
 	    uuid=`uuidgen`
@@ -664,9 +686,8 @@ fi
 
 if [ "$ec" -eq 1 ]; then
     $SUDO $CEPH_ADM <<EOF
-osd erasure-code-profile set ec-profile m=2 k=1
+osd erasure-code-profile set ec-profile m=2 k=2
 osd pool create ec 8 8 erasure ec-profile
-quit
 EOF
 fi
 
@@ -680,7 +701,6 @@ osd pool create ${p}-cache 8
 osd tier add $p ${p}-cache
 osd tier cache-mode ${p}-cache writeback
 osd tier set-overlay $p ${p}-cache
-quit
 EOF
     done
 }
@@ -697,7 +717,6 @@ do_hitsets() {
 osd pool set $pool hit_set_type $type
 osd pool set $pool hit_set_count 8
 osd pool set $pool hit_set_period 30
-quit
 EOF
     done
 }
diff --git a/systemd/Makefile.in b/systemd/Makefile.in
index 17a6821..c15b42b 100644
--- a/systemd/Makefile.in
+++ b/systemd/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -80,7 +90,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 subdir = systemd
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/ac_prog_jar.m4 \
@@ -99,6 +108,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_classpath.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/src/acconfig.h
 CONFIG_CLEAN_FILES =
@@ -152,6 +162,7 @@ am__uninstall_files_from_dir = { \
 am__installdirs = "$(DESTDIR)$(unitdir)"
 DATA = $(unit_DATA)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -242,6 +253,7 @@ LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 LTTNG_GEN_TP_CHECK = @LTTNG_GEN_TP_CHECK@
 LTTNG_GEN_TP_PROG = @LTTNG_GEN_TP_PROG@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -338,6 +350,7 @@ program_transform_name = @program_transform_name@
 psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -391,7 +404,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign systemd/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign systemd/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -590,6 +602,8 @@ uninstall-am: uninstall-unitDATA
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
 	ps ps-am tags-am uninstall uninstall-am uninstall-unitDATA
 
+.PRECIOUS: Makefile
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/test-driver b/test-driver
index d306056..8e575b0 100755
--- a/test-driver
+++ b/test-driver
@@ -3,7 +3,7 @@
 
 scriptversion=2013-07-13.22; # UTC
 
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -106,11 +106,14 @@ trap "st=143; $do_exit" 15
 # Test script is run here.
 "$@" >$log_file 2>&1
 estatus=$?
+
 if test $enable_hard_errors = no && test $estatus -eq 99; then
-  estatus=1
+  tweaked_estatus=1
+else
+  tweaked_estatus=$estatus
 fi
 
-case $estatus:$expect_failure in
+case $tweaked_estatus:$expect_failure in
   0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
   0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
   77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
@@ -119,6 +122,12 @@ case $estatus:$expect_failure in
   *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
 esac
 
+# Report the test outcome and exit status in the logs, so that one can
+# know whether the test passed or failed simply by looking at the '.log'
+# file, without the need of also peaking into the corresponding '.trs'
+# file (automake bug#11814).
+echo "$res $test_name (exit status: $estatus)" >>$log_file
+
 # Report outcome to console.
 echo "${col}${res}${std}: $test_name"
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ceph/ceph.git



More information about the Pkg-ceph-commits mailing list